diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-11-01 21:27:54 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-11-01 21:27:54 +0100 |
commit | 21eff6c7c215672d9d0fedd68bc1ca3c3eb4762f (patch) | |
tree | 97a4cb5a8e8a3d5c672f1b3cba78b27ad1a630ae /src/ui | |
parent | 9d5b6a94224d6fcf6820bbc4230ef7cf1c2f9714 (diff) | |
download | messenger-gtk-21eff6c7c215672d9d0fedd68bc1ca3c3eb4762f.tar.gz messenger-gtk-21eff6c7c215672d9d0fedd68bc1ca3c3eb4762f.zip |
Added ui files for messages and automated some debug entries
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/chat_entry.c | 20 | ||||
-rw-r--r-- | src/ui/chat_entry.h | 9 | ||||
-rw-r--r-- | src/ui/message.c | 74 | ||||
-rw-r--r-- | src/ui/message.h | 52 | ||||
-rw-r--r-- | src/ui/messenger.c | 4 | ||||
-rw-r--r-- | src/ui/messenger.h | 2 |
6 files changed, 149 insertions, 12 deletions
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c index 5ff7063..b314211 100644 --- a/src/ui/chat_entry.c +++ b/src/ui/chat_entry.c | |||
@@ -35,20 +35,24 @@ ui_chat_entry_new(void) | |||
35 | gtk_builder_get_object(builder, "entry_box") | 35 | gtk_builder_get_object(builder, "entry_box") |
36 | ); | 36 | ); |
37 | 37 | ||
38 | handle->avatar = HDY_AVATAR( | 38 | handle->entry_avatar = HDY_AVATAR( |
39 | gtk_builder_get_object(builder, "avatar") | 39 | gtk_builder_get_object(builder, "entry_avatar") |
40 | ); | 40 | ); |
41 | 41 | ||
42 | handle->title = GTK_LABEL( | 42 | handle->title_label = GTK_LABEL( |
43 | gtk_builder_get_object(builder, "title") | 43 | gtk_builder_get_object(builder, "title_label") |
44 | ); | 44 | ); |
45 | 45 | ||
46 | handle->timestamp = GTK_LABEL( | 46 | handle->timestamp_label = GTK_LABEL( |
47 | gtk_builder_get_object(builder, "timestamp") | 47 | gtk_builder_get_object(builder, "timestamp_label") |
48 | ); | 48 | ); |
49 | 49 | ||
50 | handle->text = GTK_LABEL( | 50 | handle->text_label = GTK_LABEL( |
51 | gtk_builder_get_object(builder, "text") | 51 | gtk_builder_get_object(builder, "text_label") |
52 | ); | ||
53 | |||
54 | handle->read_receipt_image = GTK_IMAGE( | ||
55 | gtk_builder_get_object(builder, "read_receipt_image") | ||
52 | ); | 56 | ); |
53 | 57 | ||
54 | return handle; | 58 | return handle; |
diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h index 48f2fb7..2315686 100644 --- a/src/ui/chat_entry.h +++ b/src/ui/chat_entry.h | |||
@@ -34,12 +34,13 @@ typedef struct UI_CHAT_ENTRY_Handle | |||
34 | { | 34 | { |
35 | GtkWidget* entry_box; | 35 | GtkWidget* entry_box; |
36 | 36 | ||
37 | HdyAvatar* avatar; | 37 | HdyAvatar* entry_avatar; |
38 | 38 | ||
39 | GtkLabel* title; | 39 | GtkLabel* title_label; |
40 | GtkLabel* timestamp; | 40 | GtkLabel* timestamp_label; |
41 | 41 | ||
42 | GtkLabel* text; | 42 | GtkLabel* text_label; |
43 | GtkImage* read_receipt_image; | ||
43 | } UI_CHAT_ENTRY_Handle; | 44 | } UI_CHAT_ENTRY_Handle; |
44 | 45 | ||
45 | UI_CHAT_ENTRY_Handle* | 46 | UI_CHAT_ENTRY_Handle* |
diff --git a/src/ui/message.c b/src/ui/message.c new file mode 100644 index 0000000..f48bbaa --- /dev/null +++ b/src/ui/message.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file ui/message.c | ||
23 | */ | ||
24 | |||
25 | #include "message.h" | ||
26 | |||
27 | #include "../application.h" | ||
28 | |||
29 | UI_MESSAGE_Handle* | ||
30 | ui_message_new(MESSENGER_Application *app, | ||
31 | bool sent) | ||
32 | { | ||
33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | ||
34 | GtkBuilder* builder; | ||
35 | |||
36 | if (sent) | ||
37 | builder = gtk_builder_new_from_file("resources/ui/message-sent.ui"); | ||
38 | else | ||
39 | builder = gtk_builder_new_from_file("resources/ui/message.ui"); | ||
40 | |||
41 | handle->message_box = GTK_WIDGET( | ||
42 | gtk_builder_get_object(builder, "message_box") | ||
43 | ); | ||
44 | |||
45 | handle->sender_avatar = HDY_AVATAR( | ||
46 | gtk_builder_get_object(builder, "sender_avatar") | ||
47 | ); | ||
48 | |||
49 | handle->sender_label = GTK_LABEL( | ||
50 | gtk_builder_get_object(builder, "sender_label") | ||
51 | ); | ||
52 | |||
53 | if (sent) | ||
54 | { | ||
55 | const char *sender = GNUNET_CHAT_get_name(app->chat.messenger.handle); | ||
56 | |||
57 | hdy_avatar_set_text(handle->sender_avatar, sender); | ||
58 | gtk_label_set_text(handle->sender_label, sender); | ||
59 | } | ||
60 | |||
61 | handle->text_label = GTK_LABEL( | ||
62 | gtk_builder_get_object(builder, "text_label") | ||
63 | ); | ||
64 | |||
65 | handle->timestamp_label = GTK_LABEL( | ||
66 | gtk_builder_get_object(builder, "timestamp_label") | ||
67 | ); | ||
68 | |||
69 | handle->read_receipt_image = GTK_IMAGE( | ||
70 | gtk_builder_get_object(builder, "read_receipt_image") | ||
71 | ); | ||
72 | |||
73 | return handle; | ||
74 | } | ||
diff --git a/src/ui/message.h b/src/ui/message.h new file mode 100644 index 0000000..b55cb8d --- /dev/null +++ b/src/ui/message.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file ui/message.h | ||
23 | */ | ||
24 | |||
25 | #ifndef UI_MESSAGE_H_ | ||
26 | #define UI_MESSAGE_H_ | ||
27 | |||
28 | #include <stdbool.h> | ||
29 | |||
30 | #include <gtk-3.0/gtk/gtk.h> | ||
31 | #include <libhandy-1/handy.h> | ||
32 | |||
33 | typedef struct MESSENGER_Application MESSENGER_Application; | ||
34 | |||
35 | typedef struct UI_MESSAGE_Handle | ||
36 | { | ||
37 | GtkWidget* message_box; | ||
38 | |||
39 | HdyAvatar* sender_avatar; | ||
40 | GtkLabel* sender_label; | ||
41 | |||
42 | GtkLabel* text_label; | ||
43 | |||
44 | GtkLabel* timestamp_label; | ||
45 | GtkImage* read_receipt_image; | ||
46 | } UI_MESSAGE_Handle; | ||
47 | |||
48 | UI_MESSAGE_Handle* | ||
49 | ui_message_new(MESSENGER_Application *app, | ||
50 | bool sent); | ||
51 | |||
52 | #endif /* UI_MESSAGE_H_ */ | ||
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 37827d8..196b00a 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -279,6 +279,10 @@ ui_messenger_init(MESSENGER_Application *app, | |||
279 | handle->flap_chat_details | 279 | handle->flap_chat_details |
280 | ); | 280 | ); |
281 | 281 | ||
282 | handle->messages_listbox = GTK_LIST_BOX( | ||
283 | gtk_builder_get_object(builder, "messages_listbox") | ||
284 | ); | ||
285 | |||
282 | gtk_widget_show(GTK_WIDGET(handle->main_window)); | 286 | gtk_widget_show(GTK_WIDGET(handle->main_window)); |
283 | 287 | ||
284 | g_signal_connect( | 288 | g_signal_connect( |
diff --git a/src/ui/messenger.h b/src/ui/messenger.h index 4174754..e923964 100644 --- a/src/ui/messenger.h +++ b/src/ui/messenger.h | |||
@@ -67,6 +67,8 @@ typedef struct UI_MESSENGER_Handle | |||
67 | GtkButton *chat_details_button; | 67 | GtkButton *chat_details_button; |
68 | 68 | ||
69 | GtkButton *hide_chat_details_button; | 69 | GtkButton *hide_chat_details_button; |
70 | |||
71 | GtkListBox *messages_listbox; | ||
70 | } UI_MESSENGER_Handle; | 72 | } UI_MESSENGER_Handle; |
71 | 73 | ||
72 | void | 74 | void |