diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.c | 27 | ||||
-rw-r--r-- | src/application.h | 4 | ||||
-rw-r--r-- | src/event.c | 22 | ||||
-rw-r--r-- | src/resources.c | 44 | ||||
-rw-r--r-- | src/resources.h | 34 | ||||
-rw-r--r-- | src/ui/chat.c | 8 | ||||
-rw-r--r-- | src/ui/chat_entry.c | 4 | ||||
-rw-r--r-- | src/ui/contact_entry.c | 6 | ||||
-rw-r--r-- | src/ui/contact_entry.h | 2 | ||||
-rw-r--r-- | src/ui/contacts.c | 6 | ||||
-rw-r--r-- | src/ui/invite_contact.c | 6 | ||||
-rw-r--r-- | src/ui/message.c | 44 | ||||
-rw-r--r-- | src/ui/message.h | 11 | ||||
-rw-r--r-- | src/ui/messenger.c | 4 | ||||
-rw-r--r-- | src/ui/new_contact.c | 4 | ||||
-rw-r--r-- | src/ui/new_group.c | 6 | ||||
-rw-r--r-- | src/ui/new_platform.c | 4 | ||||
-rw-r--r-- | src/ui/new_profile.c | 4 | ||||
-rw-r--r-- | src/ui/picker.c | 4 | ||||
-rw-r--r-- | src/ui/profile_entry.c | 6 | ||||
-rw-r--r-- | src/ui/profile_entry.h | 2 | ||||
-rw-r--r-- | src/ui/send_file.c | 4 | ||||
-rw-r--r-- | src/ui/settings.c | 4 |
23 files changed, 173 insertions, 87 deletions
diff --git a/src/application.c b/src/application.c index 7c78de0..f1a2fd8 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -23,16 +23,17 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "application.h" | 25 | #include "application.h" |
26 | #include "resources.h" | ||
26 | 27 | ||
27 | static void | 28 | static void |
28 | _load_ui_stylesheets(void) | 29 | _load_ui_stylesheets(void) |
29 | { | 30 | { |
30 | GdkScreen* screen = gdk_screen_get_default(); | 31 | GdkScreen* screen = gdk_screen_get_default(); |
31 | GtkCssProvider* provider = gtk_css_provider_new(); | 32 | GtkCssProvider* provider = gtk_css_provider_new(); |
32 | gtk_css_provider_load_from_path( | 33 | |
34 | gtk_css_provider_load_from_resource( | ||
33 | provider, | 35 | provider, |
34 | "resources/css/style.css", | 36 | "org/gnunet/Messenger-GTK/css/style.css" |
35 | NULL | ||
36 | ); | 37 | ); |
37 | 38 | ||
38 | gtk_style_context_add_provider_for_screen( | 39 | gtk_style_context_add_provider_for_screen( |
@@ -65,10 +66,12 @@ application_init(MESSENGER_Application *app, | |||
65 | hdy_init(); | 66 | hdy_init(); |
66 | 67 | ||
67 | app->application = gtk_application_new( | 68 | app->application = gtk_application_new( |
68 | "org.gnunet.MESSENGER-GTK", | 69 | "org.gnunet.Messenger-GTK", |
69 | G_APPLICATION_NON_UNIQUE | 70 | G_APPLICATION_NON_UNIQUE |
70 | ); | 71 | ); |
71 | 72 | ||
73 | resources_register(); | ||
74 | |||
72 | notify_init("Messenger-GTK"); | 75 | notify_init("Messenger-GTK"); |
73 | app->notifications = NULL; | 76 | app->notifications = NULL; |
74 | 77 | ||
@@ -112,6 +115,20 @@ application_init(MESSENGER_Application *app, | |||
112 | ); | 115 | ); |
113 | } | 116 | } |
114 | 117 | ||
118 | const gchar* | ||
119 | application_get_resource_path(MESSENGER_Application *app, | ||
120 | const char *path) | ||
121 | { | ||
122 | static gchar resource_path [PATH_MAX]; | ||
123 | |||
124 | const gchar *base_path = g_application_get_resource_base_path( | ||
125 | G_APPLICATION(app->application) | ||
126 | ); | ||
127 | |||
128 | snprintf(resource_path, PATH_MAX, "%s/%s", base_path, path); | ||
129 | return resource_path; | ||
130 | } | ||
131 | |||
115 | static void* | 132 | static void* |
116 | _application_chat_thread(void *args) | 133 | _application_chat_thread(void *args) |
117 | { | 134 | { |
@@ -178,6 +195,8 @@ application_run(MESSENGER_Application *app) | |||
178 | 195 | ||
179 | notify_uninit(); | 196 | notify_uninit(); |
180 | 197 | ||
198 | resources_unregister(); | ||
199 | |||
181 | g_object_unref(app->application); | 200 | g_object_unref(app->application); |
182 | } | 201 | } |
183 | 202 | ||
diff --git a/src/application.h b/src/application.h index 3c51a87..d66a0cd 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -94,6 +94,10 @@ application_init(MESSENGER_Application *app, | |||
94 | int argc, | 94 | int argc, |
95 | char **argv); | 95 | char **argv); |
96 | 96 | ||
97 | const gchar* | ||
98 | application_get_resource_path(MESSENGER_Application *app, | ||
99 | const char *path); | ||
100 | |||
97 | void | 101 | void |
98 | application_run(MESSENGER_Application *app); | 102 | application_run(MESSENGER_Application *app); |
99 | 103 | ||
diff --git a/src/event.c b/src/event.c index 7335e91..8f913f2 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -160,7 +160,7 @@ event_update_profile(MESSENGER_Application *app) | |||
160 | hdy_avatar_set_text(ui->profile_avatar, name); | 160 | hdy_avatar_set_text(ui->profile_avatar, name); |
161 | gtk_label_set_text(ui->profile_label, name); | 161 | gtk_label_set_text(ui->profile_label, name); |
162 | 162 | ||
163 | UI_PROFILE_ENTRY_Handle *profile = ui_profile_entry_new(); | 163 | UI_PROFILE_ENTRY_Handle *profile = ui_profile_entry_new(app); |
164 | 164 | ||
165 | hdy_avatar_set_text(profile->entry_avatar, name); | 165 | hdy_avatar_set_text(profile->entry_avatar, name); |
166 | gtk_label_set_text(profile->entry_label, name); | 166 | gtk_label_set_text(profile->entry_label, name); |
@@ -235,11 +235,7 @@ event_joining_contact(MESSENGER_Application *app, | |||
235 | if (!handle) | 235 | if (!handle) |
236 | return; | 236 | return; |
237 | 237 | ||
238 | UI_MESSAGE_Handle *message = ui_message_new( | 238 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); |
239 | UI_MESSAGE_STATUS, | ||
240 | UI_MESSAGE_CONTENT_TEXT | ||
241 | ); | ||
242 | |||
243 | ui_message_update(message, msg); | 239 | ui_message_update(message, msg); |
244 | 240 | ||
245 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 241 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
@@ -328,11 +324,7 @@ event_invitation(UNUSED MESSENGER_Application *app, | |||
328 | if (!invitation) | 324 | if (!invitation) |
329 | return; | 325 | return; |
330 | 326 | ||
331 | UI_MESSAGE_Handle *message = ui_message_new( | 327 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); |
332 | UI_MESSAGE_STATUS, | ||
333 | UI_MESSAGE_CONTENT_TEXT | ||
334 | ); | ||
335 | |||
336 | ui_message_update(message, msg); | 328 | ui_message_update(message, msg); |
337 | 329 | ||
338 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 330 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
@@ -384,15 +376,13 @@ event_receive_message(UNUSED MESSENGER_Application *app, | |||
384 | if (!handle) | 376 | if (!handle) |
385 | return; | 377 | return; |
386 | 378 | ||
387 | struct GNUNET_CHAT_File *file = GNUNET_CHAT_message_get_file(msg); | ||
388 | |||
389 | const int sent = GNUNET_CHAT_message_is_sent(msg); | 379 | const int sent = GNUNET_CHAT_message_is_sent(msg); |
390 | 380 | ||
391 | UI_MESSAGE_Handle *message = ui_message_new( | 381 | const UI_MESSAGE_Type type = ( |
392 | GNUNET_YES == sent? UI_MESSAGE_SENT : UI_MESSAGE_DEFAULT, | 382 | GNUNET_YES == sent? UI_MESSAGE_SENT : UI_MESSAGE_DEFAULT |
393 | file? UI_MESSAGE_CONTENT_FILE : UI_MESSAGE_CONTENT_TEXT | ||
394 | ); | 383 | ); |
395 | 384 | ||
385 | UI_MESSAGE_Handle *message = ui_message_new(app, type); | ||
396 | ui_message_update(message, msg); | 386 | ui_message_update(message, msg); |
397 | 387 | ||
398 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 388 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
diff --git a/src/resources.c b/src/resources.c new file mode 100644 index 0000000..5f997fe --- /dev/null +++ b/src/resources.c | |||
@@ -0,0 +1,44 @@ | |||
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 resources.c | ||
23 | */ | ||
24 | |||
25 | #include "resources.h" | ||
26 | |||
27 | #include <gio/gio.h> | ||
28 | |||
29 | #include "../resources/css.h" | ||
30 | #include "../resources/ui.h" | ||
31 | |||
32 | void | ||
33 | resources_register() | ||
34 | { | ||
35 | g_resources_register(css_get_resource()); | ||
36 | g_resources_register(ui_get_resource()); | ||
37 | } | ||
38 | |||
39 | void | ||
40 | resources_unregister() | ||
41 | { | ||
42 | g_resources_unregister(css_get_resource()); | ||
43 | g_resources_unregister(ui_get_resource()); | ||
44 | } | ||
diff --git a/src/resources.h b/src/resources.h new file mode 100644 index 0000000..82e8534 --- /dev/null +++ b/src/resources.h | |||
@@ -0,0 +1,34 @@ | |||
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 resources.h | ||
23 | */ | ||
24 | |||
25 | #ifndef RESOURCES_H_ | ||
26 | #define RESOURCES_H_ | ||
27 | |||
28 | void | ||
29 | resources_register(); | ||
30 | |||
31 | void | ||
32 | resources_unregister(); | ||
33 | |||
34 | #endif /* RESOURCES_H_ */ | ||
diff --git a/src/ui/chat.c b/src/ui/chat.c index 3831f66..71f7ebc 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -279,8 +279,8 @@ ui_chat_new(MESSENGER_Application *app) | |||
279 | handle->messages = NULL; | 279 | handle->messages = NULL; |
280 | handle->edge_value = 0; | 280 | handle->edge_value = 0; |
281 | 281 | ||
282 | handle->builder = gtk_builder_new_from_file( | 282 | handle->builder = gtk_builder_new_from_resource( |
283 | "resources/ui/chat.ui" | 283 | application_get_resource_path(app, "ui/chat.ui") |
284 | ); | 284 | ); |
285 | 285 | ||
286 | handle->chat_box = GTK_WIDGET( | 286 | handle->chat_box = GTK_WIDGET( |
@@ -466,6 +466,7 @@ ui_chat_new(MESSENGER_Application *app) | |||
466 | } | 466 | } |
467 | 467 | ||
468 | struct IterateChatGroupClosure { | 468 | struct IterateChatGroupClosure { |
469 | MESSENGER_Application *app; | ||
469 | GHashTable *bindings; | 470 | GHashTable *bindings; |
470 | GtkListBox *listbox; | 471 | GtkListBox *listbox; |
471 | }; | 472 | }; |
@@ -480,7 +481,7 @@ iterate_ui_chat_update_group_contacts(void *cls, | |||
480 | ); | 481 | ); |
481 | 482 | ||
482 | GtkListBox *listbox = closure->listbox; | 483 | GtkListBox *listbox = closure->listbox; |
483 | UI_PROFILE_ENTRY_Handle* entry = ui_profile_entry_new(); | 484 | UI_PROFILE_ENTRY_Handle* entry = ui_profile_entry_new(closure->app); |
484 | 485 | ||
485 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 486 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
486 | 487 | ||
@@ -559,6 +560,7 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
559 | if (group) | 560 | if (group) |
560 | { | 561 | { |
561 | struct IterateChatGroupClosure closure; | 562 | struct IterateChatGroupClosure closure; |
563 | closure.app = app; | ||
562 | closure.bindings = app->ui.bindings; | 564 | closure.bindings = app->ui.bindings; |
563 | closure.listbox = handle->chat_contacts_listbox; | 565 | closure.listbox = handle->chat_contacts_listbox; |
564 | 566 | ||
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c index 7de4064..1dabec8 100644 --- a/src/ui/chat_entry.c +++ b/src/ui/chat_entry.c | |||
@@ -35,7 +35,9 @@ ui_chat_entry_new(MESSENGER_Application *app) | |||
35 | UI_CHAT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CHAT_ENTRY_Handle)); | 35 | UI_CHAT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CHAT_ENTRY_Handle)); |
36 | 36 | ||
37 | handle->chat = ui_chat_new(app); | 37 | handle->chat = ui_chat_new(app); |
38 | handle->builder = gtk_builder_new_from_file("resources/ui/chat_entry.ui"); | 38 | handle->builder = gtk_builder_new_from_resource( |
39 | application_get_resource_path(app, "ui/chat_entry.ui") | ||
40 | ); | ||
39 | 41 | ||
40 | handle->entry_box = GTK_WIDGET( | 42 | handle->entry_box = GTK_WIDGET( |
41 | gtk_builder_get_object(handle->builder, "entry_box") | 43 | gtk_builder_get_object(handle->builder, "entry_box") |
diff --git a/src/ui/contact_entry.c b/src/ui/contact_entry.c index cf830db..291c3b0 100644 --- a/src/ui/contact_entry.c +++ b/src/ui/contact_entry.c | |||
@@ -27,11 +27,13 @@ | |||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | UI_CONTACT_ENTRY_Handle* | 29 | UI_CONTACT_ENTRY_Handle* |
30 | ui_contact_entry_new(void) | 30 | ui_contact_entry_new(MESSENGER_Application *app) |
31 | { | 31 | { |
32 | UI_CONTACT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CONTACT_ENTRY_Handle)); | 32 | UI_CONTACT_ENTRY_Handle* handle = g_malloc(sizeof(UI_CONTACT_ENTRY_Handle)); |
33 | 33 | ||
34 | handle->builder = gtk_builder_new_from_file("resources/ui/contact_entry.ui"); | 34 | handle->builder = gtk_builder_new_from_resource( |
35 | application_get_resource_path(app, "ui/contact_entry.ui") | ||
36 | ); | ||
35 | 37 | ||
36 | handle->entry_box = GTK_WIDGET( | 38 | handle->entry_box = GTK_WIDGET( |
37 | gtk_builder_get_object(handle->builder, "entry_box") | 39 | gtk_builder_get_object(handle->builder, "entry_box") |
diff --git a/src/ui/contact_entry.h b/src/ui/contact_entry.h index 6b39077..1ec97fc 100644 --- a/src/ui/contact_entry.h +++ b/src/ui/contact_entry.h | |||
@@ -40,7 +40,7 @@ typedef struct UI_CONTACT_ENTRY_Handle | |||
40 | } UI_CONTACT_ENTRY_Handle; | 40 | } UI_CONTACT_ENTRY_Handle; |
41 | 41 | ||
42 | UI_CONTACT_ENTRY_Handle* | 42 | UI_CONTACT_ENTRY_Handle* |
43 | ui_contact_entry_new(void); | 43 | ui_contact_entry_new(MESSENGER_Application *app); |
44 | 44 | ||
45 | void | 45 | void |
46 | ui_contact_entry_delete(UI_CONTACT_ENTRY_Handle *handle); | 46 | ui_contact_entry_delete(UI_CONTACT_ENTRY_Handle *handle); |
diff --git a/src/ui/contacts.c b/src/ui/contacts.c index fac9e62..3969446 100644 --- a/src/ui/contacts.c +++ b/src/ui/contacts.c | |||
@@ -104,7 +104,7 @@ _iterate_contacts(void *cls, | |||
104 | 104 | ||
105 | const char *key = GNUNET_CHAT_contact_get_key(contact); | 105 | const char *key = GNUNET_CHAT_contact_get_key(contact); |
106 | 106 | ||
107 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(); | 107 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(app); |
108 | gtk_list_box_prepend( | 108 | gtk_list_box_prepend( |
109 | app->ui.contacts.contacts_listbox, | 109 | app->ui.contacts.contacts_listbox, |
110 | entry->entry_box | 110 | entry->entry_box |
@@ -139,7 +139,9 @@ ui_contacts_dialog_init(MESSENGER_Application *app, | |||
139 | { | 139 | { |
140 | handle->contact_entries = NULL; | 140 | handle->contact_entries = NULL; |
141 | 141 | ||
142 | handle->builder = gtk_builder_new_from_file("resources/ui/contacts.ui"); | 142 | handle->builder = gtk_builder_new_from_resource( |
143 | application_get_resource_path(app, "ui/contacts.ui") | ||
144 | ); | ||
143 | 145 | ||
144 | handle->dialog = GTK_DIALOG( | 146 | handle->dialog = GTK_DIALOG( |
145 | gtk_builder_get_object(handle->builder, "contacts_dialog") | 147 | gtk_builder_get_object(handle->builder, "contacts_dialog") |
diff --git a/src/ui/invite_contact.c b/src/ui/invite_contact.c index 5b6a71c..8cbde0c 100644 --- a/src/ui/invite_contact.c +++ b/src/ui/invite_contact.c | |||
@@ -96,7 +96,7 @@ _iterate_contacts(void *cls, | |||
96 | 96 | ||
97 | const char *key = GNUNET_CHAT_contact_get_key(contact); | 97 | const char *key = GNUNET_CHAT_contact_get_key(contact); |
98 | 98 | ||
99 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(); | 99 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(app); |
100 | gtk_list_box_prepend( | 100 | gtk_list_box_prepend( |
101 | app->ui.invite_contact.contacts_listbox, | 101 | app->ui.invite_contact.contacts_listbox, |
102 | entry->entry_box | 102 | entry->entry_box |
@@ -131,7 +131,9 @@ ui_invite_contact_dialog_init(MESSENGER_Application *app, | |||
131 | { | 131 | { |
132 | handle->contact_entries = NULL; | 132 | handle->contact_entries = NULL; |
133 | 133 | ||
134 | handle->builder = gtk_builder_new_from_file("resources/ui/invite_contact.ui"); | 134 | handle->builder = gtk_builder_new_from_resource( |
135 | application_get_resource_path(app, "ui/invite_contact.ui") | ||
136 | ); | ||
135 | 137 | ||
136 | handle->dialog = GTK_DIALOG( | 138 | handle->dialog = GTK_DIALOG( |
137 | gtk_builder_get_object(handle->builder, "invite_contact_dialog") | 139 | gtk_builder_get_object(handle->builder, "invite_contact_dialog") |
diff --git a/src/ui/message.c b/src/ui/message.c index 47ec2aa..da6bb97 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -27,8 +27,8 @@ | |||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | UI_MESSAGE_Handle* | 29 | UI_MESSAGE_Handle* |
30 | ui_message_new(UI_MESSAGE_Type type, | 30 | ui_message_new(MESSENGER_Application *app, |
31 | UI_MESSAGE_ContentType content_type) | 31 | UI_MESSAGE_Type type) |
32 | { | 32 | { |
33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | 33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); |
34 | 34 | ||
@@ -39,17 +39,19 @@ ui_message_new(UI_MESSAGE_Type type, | |||
39 | switch (handle->type) | 39 | switch (handle->type) |
40 | { | 40 | { |
41 | case UI_MESSAGE_SENT: | 41 | case UI_MESSAGE_SENT: |
42 | ui_builder_file = "resources/ui/message-sent.ui"; | 42 | ui_builder_file = "ui/message-sent.ui"; |
43 | break; | 43 | break; |
44 | case UI_MESSAGE_STATUS: | 44 | case UI_MESSAGE_STATUS: |
45 | ui_builder_file = "resources/ui/message-status.ui"; | 45 | ui_builder_file = "ui/message-status.ui"; |
46 | break; | 46 | break; |
47 | default: | 47 | default: |
48 | ui_builder_file = "resources/ui/message.ui"; | 48 | ui_builder_file = "ui/message.ui"; |
49 | break; | 49 | break; |
50 | } | 50 | } |
51 | 51 | ||
52 | handle->builder = gtk_builder_new_from_file(ui_builder_file); | 52 | handle->builder = gtk_builder_new_from_resource( |
53 | application_get_resource_path(app, ui_builder_file) | ||
54 | ); | ||
53 | 55 | ||
54 | handle->message_box = GTK_WIDGET( | 56 | handle->message_box = GTK_WIDGET( |
55 | gtk_builder_get_object(handle->builder, "message_box") | 57 | gtk_builder_get_object(handle->builder, "message_box") |
@@ -94,8 +96,8 @@ ui_message_new(UI_MESSAGE_Type type, | |||
94 | gtk_builder_get_object(handle->builder, "content_box") | 96 | gtk_builder_get_object(handle->builder, "content_box") |
95 | ); | 97 | ); |
96 | 98 | ||
97 | GtkBuilder *builder = gtk_builder_new_from_file( | 99 | GtkBuilder *builder = gtk_builder_new_from_resource( |
98 | "resources/ui/message_content.ui" | 100 | application_get_resource_path(app, "ui/message_content.ui") |
99 | ); | 101 | ); |
100 | 102 | ||
101 | handle->timestamp_label = GTK_LABEL( | 103 | handle->timestamp_label = GTK_LABEL( |
@@ -131,32 +133,6 @@ ui_message_new(UI_MESSAGE_Type type, | |||
131 | break; | 133 | break; |
132 | } | 134 | } |
133 | 135 | ||
134 | switch (content_type) | ||
135 | { | ||
136 | case UI_MESSAGE_CONTENT_TEXT: | ||
137 | gtk_stack_set_visible_child( | ||
138 | handle->content_stack, | ||
139 | GTK_WIDGET(handle->text_label) | ||
140 | ); | ||
141 | break; | ||
142 | case UI_MESSAGE_CONTENT_FILE: | ||
143 | gtk_stack_set_visible_child( | ||
144 | handle->content_stack, | ||
145 | GTK_WIDGET(handle->file_revealer) | ||
146 | ); | ||
147 | |||
148 | gtk_revealer_set_reveal_child(handle->file_revealer, TRUE); | ||
149 | break; | ||
150 | case UI_MESSAGE_CONTENT_PREVIEW: | ||
151 | gtk_stack_set_visible_child( | ||
152 | handle->content_stack, | ||
153 | GTK_WIDGET(handle->preview_drawing_area) | ||
154 | ); | ||
155 | break; | ||
156 | default: | ||
157 | break; | ||
158 | } | ||
159 | |||
160 | gtk_container_add(content_box, GTK_WIDGET( | 136 | gtk_container_add(content_box, GTK_WIDGET( |
161 | gtk_builder_get_object(builder, "message_content_box") | 137 | gtk_builder_get_object(builder, "message_content_box") |
162 | )); | 138 | )); |
diff --git a/src/ui/message.h b/src/ui/message.h index 27577a9..f5883de 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -41,13 +41,6 @@ typedef enum UI_MESSAGE_Type | |||
41 | UI_MESSAGE_STATUS = 2 | 41 | UI_MESSAGE_STATUS = 2 |
42 | } UI_MESSAGE_Type; | 42 | } UI_MESSAGE_Type; |
43 | 43 | ||
44 | typedef enum UI_MESSAGE_ContentType | ||
45 | { | ||
46 | UI_MESSAGE_CONTENT_TEXT = 0, | ||
47 | UI_MESSAGE_CONTENT_FILE = 1, | ||
48 | UI_MESSAGE_CONTENT_PREVIEW = 2 | ||
49 | } UI_MESSAGE_ContentType; | ||
50 | |||
51 | typedef struct UI_MESSAGE_Handle | 44 | typedef struct UI_MESSAGE_Handle |
52 | { | 45 | { |
53 | UI_MESSAGE_Type type; | 46 | UI_MESSAGE_Type type; |
@@ -75,8 +68,8 @@ typedef struct UI_MESSAGE_Handle | |||
75 | } UI_MESSAGE_Handle; | 68 | } UI_MESSAGE_Handle; |
76 | 69 | ||
77 | UI_MESSAGE_Handle* | 70 | UI_MESSAGE_Handle* |
78 | ui_message_new(UI_MESSAGE_Type type, | 71 | ui_message_new(MESSENGER_Application *app, |
79 | UI_MESSAGE_ContentType content_type); | 72 | UI_MESSAGE_Type type); |
80 | 73 | ||
81 | void | 74 | void |
82 | ui_message_update(UI_MESSAGE_Handle *handle, | 75 | ui_message_update(UI_MESSAGE_Handle *handle, |
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 0db82a0..a926332 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -194,7 +194,9 @@ ui_messenger_init(MESSENGER_Application *app, | |||
194 | { | 194 | { |
195 | handle->chat_entries = NULL; | 195 | handle->chat_entries = NULL; |
196 | 196 | ||
197 | handle->builder = gtk_builder_new_from_file("resources/ui/messenger.ui"); | 197 | handle->builder = gtk_builder_new_from_resource( |
198 | application_get_resource_path(app, "ui/messenger.ui") | ||
199 | ); | ||
198 | 200 | ||
199 | handle->main_window = GTK_APPLICATION_WINDOW( | 201 | handle->main_window = GTK_APPLICATION_WINDOW( |
200 | gtk_builder_get_object(handle->builder, "main_window") | 202 | gtk_builder_get_object(handle->builder, "main_window") |
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c index 7e6f9c6..147f591 100644 --- a/src/ui/new_contact.c +++ b/src/ui/new_contact.c | |||
@@ -287,7 +287,9 @@ ui_new_contact_dialog_init(MESSENGER_Application *app, | |||
287 | handle->video = zbar_video_create(); | 287 | handle->video = zbar_video_create(); |
288 | handle->scanner = zbar_image_scanner_create(); | 288 | handle->scanner = zbar_image_scanner_create(); |
289 | 289 | ||
290 | handle->builder = gtk_builder_new_from_file("resources/ui/new_contact.ui"); | 290 | handle->builder = gtk_builder_new_from_resource( |
291 | application_get_resource_path(app, "ui/new_contact.ui") | ||
292 | ); | ||
291 | 293 | ||
292 | handle->dialog = GTK_DIALOG( | 294 | handle->dialog = GTK_DIALOG( |
293 | gtk_builder_get_object(handle->builder, "new_contact_dialog") | 295 | gtk_builder_get_object(handle->builder, "new_contact_dialog") |
diff --git a/src/ui/new_group.c b/src/ui/new_group.c index e161fbb..dbad66b 100644 --- a/src/ui/new_group.c +++ b/src/ui/new_group.c | |||
@@ -163,7 +163,7 @@ _iterate_contacts(void *cls, | |||
163 | 163 | ||
164 | const char *key = GNUNET_CHAT_contact_get_key(contact); | 164 | const char *key = GNUNET_CHAT_contact_get_key(contact); |
165 | 165 | ||
166 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(); | 166 | UI_CONTACT_ENTRY_Handle *entry = ui_contact_entry_new(app); |
167 | gtk_list_box_prepend( | 167 | gtk_list_box_prepend( |
168 | app->ui.new_group.contacts_listbox, | 168 | app->ui.new_group.contacts_listbox, |
169 | entry->entry_box | 169 | entry->entry_box |
@@ -198,7 +198,9 @@ ui_new_group_dialog_init(MESSENGER_Application *app, | |||
198 | { | 198 | { |
199 | handle->contact_entries = NULL; | 199 | handle->contact_entries = NULL; |
200 | 200 | ||
201 | handle->builder = gtk_builder_new_from_file("resources/ui/new_group.ui"); | 201 | handle->builder = gtk_builder_new_from_resource( |
202 | application_get_resource_path(app, "ui/new_group.ui") | ||
203 | ); | ||
202 | 204 | ||
203 | handle->dialog = GTK_DIALOG( | 205 | handle->dialog = GTK_DIALOG( |
204 | gtk_builder_get_object(handle->builder, "new_group_dialog") | 206 | gtk_builder_get_object(handle->builder, "new_group_dialog") |
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c index dad4ad1..544b7c7 100644 --- a/src/ui/new_platform.c +++ b/src/ui/new_platform.c | |||
@@ -100,7 +100,9 @@ void | |||
100 | ui_new_platform_dialog_init(MESSENGER_Application *app, | 100 | ui_new_platform_dialog_init(MESSENGER_Application *app, |
101 | UI_NEW_PLATFORM_Handle *handle) | 101 | UI_NEW_PLATFORM_Handle *handle) |
102 | { | 102 | { |
103 | handle->builder = gtk_builder_new_from_file("resources/ui/new_platform.ui"); | 103 | handle->builder = gtk_builder_new_from_resource( |
104 | application_get_resource_path(app, "ui/new_platform.ui") | ||
105 | ); | ||
104 | 106 | ||
105 | handle->dialog = GTK_DIALOG( | 107 | handle->dialog = GTK_DIALOG( |
106 | gtk_builder_get_object(handle->builder, "new_platform_dialog") | 108 | gtk_builder_get_object(handle->builder, "new_platform_dialog") |
diff --git a/src/ui/new_profile.c b/src/ui/new_profile.c index d845fdf..d1d0274 100644 --- a/src/ui/new_profile.c +++ b/src/ui/new_profile.c | |||
@@ -77,7 +77,9 @@ void | |||
77 | ui_new_profile_dialog_init(MESSENGER_Application *app, | 77 | ui_new_profile_dialog_init(MESSENGER_Application *app, |
78 | UI_NEW_PROFILE_Handle *handle) | 78 | UI_NEW_PROFILE_Handle *handle) |
79 | { | 79 | { |
80 | handle->builder = gtk_builder_new_from_file("resources/ui/new_profile.ui"); | 80 | handle->builder = gtk_builder_new_from_resource( |
81 | application_get_resource_path(app, "ui/new_profile.ui") | ||
82 | ); | ||
81 | 83 | ||
82 | handle->dialog = GTK_DIALOG( | 84 | handle->dialog = GTK_DIALOG( |
83 | gtk_builder_get_object(handle->builder, "new_profile_dialog") | 85 | gtk_builder_get_object(handle->builder, "new_profile_dialog") |
diff --git a/src/ui/picker.c b/src/ui/picker.c index 4a5d205..bdaa713 100644 --- a/src/ui/picker.c +++ b/src/ui/picker.c | |||
@@ -97,8 +97,8 @@ ui_picker_new(UNUSED MESSENGER_Application *app, | |||
97 | { | 97 | { |
98 | UI_PICKER_Handle *handle = g_malloc(sizeof(UI_PICKER_Handle)); | 98 | UI_PICKER_Handle *handle = g_malloc(sizeof(UI_PICKER_Handle)); |
99 | 99 | ||
100 | handle->builder = gtk_builder_new_from_file( | 100 | handle->builder = gtk_builder_new_from_resource( |
101 | "resources/ui/picker.ui" | 101 | application_get_resource_path(app, "ui/picker.ui") |
102 | ); | 102 | ); |
103 | 103 | ||
104 | handle->picker_box = GTK_WIDGET( | 104 | handle->picker_box = GTK_WIDGET( |
diff --git a/src/ui/profile_entry.c b/src/ui/profile_entry.c index 4a03f94..c2b232f 100644 --- a/src/ui/profile_entry.c +++ b/src/ui/profile_entry.c | |||
@@ -27,11 +27,13 @@ | |||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | UI_PROFILE_ENTRY_Handle* | 29 | UI_PROFILE_ENTRY_Handle* |
30 | ui_profile_entry_new(void) | 30 | ui_profile_entry_new(MESSENGER_Application *app) |
31 | { | 31 | { |
32 | UI_PROFILE_ENTRY_Handle* handle = g_malloc(sizeof(UI_PROFILE_ENTRY_Handle)); | 32 | UI_PROFILE_ENTRY_Handle* handle = g_malloc(sizeof(UI_PROFILE_ENTRY_Handle)); |
33 | 33 | ||
34 | handle->builder = gtk_builder_new_from_file("resources/ui/profile_entry.ui"); | 34 | handle->builder = gtk_builder_new_from_resource( |
35 | application_get_resource_path(app, "ui/profile_entry.ui") | ||
36 | ); | ||
35 | 37 | ||
36 | handle->entry_box = GTK_WIDGET( | 38 | handle->entry_box = GTK_WIDGET( |
37 | gtk_builder_get_object(handle->builder, "entry_box") | 39 | gtk_builder_get_object(handle->builder, "entry_box") |
diff --git a/src/ui/profile_entry.h b/src/ui/profile_entry.h index 6196737..92d2fd0 100644 --- a/src/ui/profile_entry.h +++ b/src/ui/profile_entry.h | |||
@@ -38,7 +38,7 @@ typedef struct UI_PROFILE_ENTRY_Handle | |||
38 | } UI_PROFILE_ENTRY_Handle; | 38 | } UI_PROFILE_ENTRY_Handle; |
39 | 39 | ||
40 | UI_PROFILE_ENTRY_Handle* | 40 | UI_PROFILE_ENTRY_Handle* |
41 | ui_profile_entry_new(void); | 41 | ui_profile_entry_new(MESSENGER_Application *app); |
42 | 42 | ||
43 | void | 43 | void |
44 | ui_profile_entry_delete(UI_PROFILE_ENTRY_Handle *handle); | 44 | ui_profile_entry_delete(UI_PROFILE_ENTRY_Handle *handle); |
diff --git a/src/ui/send_file.c b/src/ui/send_file.c index 0d0c04b..4b9643c 100644 --- a/src/ui/send_file.c +++ b/src/ui/send_file.c | |||
@@ -231,7 +231,9 @@ void | |||
231 | ui_send_file_dialog_init(MESSENGER_Application *app, | 231 | ui_send_file_dialog_init(MESSENGER_Application *app, |
232 | UI_SEND_FILE_Handle *handle) | 232 | UI_SEND_FILE_Handle *handle) |
233 | { | 233 | { |
234 | handle->builder = gtk_builder_new_from_file("resources/ui/send_file.ui"); | 234 | handle->builder = gtk_builder_new_from_resource( |
235 | application_get_resource_path(app, "ui/send_file.ui") | ||
236 | ); | ||
235 | 237 | ||
236 | handle->dialog = GTK_DIALOG( | 238 | handle->dialog = GTK_DIALOG( |
237 | gtk_builder_get_object(handle->builder, "send_file_dialog") | 239 | gtk_builder_get_object(handle->builder, "send_file_dialog") |
diff --git a/src/ui/settings.c b/src/ui/settings.c index ca58270..6863968 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -37,7 +37,9 @@ void | |||
37 | ui_settings_dialog_init(MESSENGER_Application *app, | 37 | ui_settings_dialog_init(MESSENGER_Application *app, |
38 | UI_SETTINGS_Handle *handle) | 38 | UI_SETTINGS_Handle *handle) |
39 | { | 39 | { |
40 | handle->builder = gtk_builder_new_from_file("resources/ui/settings.ui"); | 40 | handle->builder = gtk_builder_new_from_resource( |
41 | application_get_resource_path(app, "ui/settings.ui") | ||
42 | ); | ||
41 | 43 | ||
42 | handle->dialog = HDY_PREFERENCES_WINDOW( | 44 | handle->dialog = HDY_PREFERENCES_WINDOW( |
43 | gtk_builder_get_object(handle->builder, "settings_dialog") | 45 | gtk_builder_get_object(handle->builder, "settings_dialog") |