aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--src/application.c76
-rw-r--r--src/application.h1
-rw-r--r--src/contact.c15
-rw-r--r--src/event.c56
-rw-r--r--src/ui.c72
-rw-r--r--src/ui.h40
-rw-r--r--src/ui/account_entry.c19
-rw-r--r--src/ui/chat.c16
-rw-r--r--src/ui/chat_entry.c10
-rw-r--r--src/ui/contact_entry.c23
-rw-r--r--src/ui/contact_info.c15
-rw-r--r--src/ui/message.c5
-rw-r--r--src/ui/messenger.c18
-rw-r--r--src/ui/new_account.c4
-rw-r--r--src/ui/new_contact.c14
-rw-r--r--src/ui/new_group.c9
-rw-r--r--src/ui/new_platform.c6
-rw-r--r--src/ui/send_file.c1
19 files changed, 288 insertions, 113 deletions
diff --git a/Makefile b/Makefile
index da81bf9..42a0b8b 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,7 @@ SOURCES = messenger_gtk.c\
12 event.c\ 12 event.c\
13 file.c\ 13 file.c\
14 resources.c\ 14 resources.c\
15 ui.c\
15 chat/messenger.c\ 16 chat/messenger.c\
16 ui/about.c\ 17 ui/about.c\
17 ui/account_entry.c\ 18 ui/account_entry.c\
diff --git a/src/application.c b/src/application.c
index d960ed9..1ae2f88 100644
--- a/src/application.c
+++ b/src/application.c
@@ -53,6 +53,8 @@ _application_accounts(gpointer user_data)
53{ 53{
54 MESSENGER_Application *app = (MESSENGER_Application*) user_data; 54 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
55 55
56 app->init = 0;
57
56 ui_accounts_dialog_init(app, &(app->ui.accounts)); 58 ui_accounts_dialog_init(app, &(app->ui.accounts));
57 ui_accounts_dialog_refresh(app, &(app->ui.accounts)); 59 ui_accounts_dialog_refresh(app, &(app->ui.accounts));
58 60
@@ -61,17 +63,71 @@ _application_accounts(gpointer user_data)
61} 63}
62 64
63static void 65static void
64_application_activate(UNUSED GtkApplication* application, 66_application_init(MESSENGER_Application *app)
65 gpointer user_data)
66{ 67{
67 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
68
69 ui_messenger_init(app, &(app->ui.messenger)); 68 ui_messenger_init(app, &(app->ui.messenger));
70 69
71 if (app->chat.identity) 70 if (app->chat.identity)
72 gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window)); 71 gtk_widget_show(GTK_WIDGET(app->ui.messenger.main_window));
73 else 72 else
74 g_idle_add(G_SOURCE_FUNC(_application_accounts), app); 73 app->init = g_idle_add(G_SOURCE_FUNC(_application_accounts), app);
74}
75
76static void
77_application_activate(GApplication* application,
78 gpointer user_data)
79{
80 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
81
82 g_application_hold(application);
83
84 _application_init(app);
85
86 g_application_release(application);
87}
88
89static void
90_application_open(GApplication* application,
91 GFile **files,
92 gint n_files,
93 UNUSED gchar* hint,
94 gpointer user_data)
95{
96 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
97
98 g_application_hold(application);
99
100 _application_init(app);
101
102 for (gint i = 0; i < n_files; i++) {
103 if (!g_file_has_uri_scheme(files[i], "gnunet"))
104 continue;
105
106 gchar *uri_string = g_file_get_uri(files[i]);
107
108 if (!uri_string)
109 continue;
110
111 char *emsg = NULL;
112 struct GNUNET_CHAT_Uri *uri = GNUNET_CHAT_uri_parse(uri_string, &emsg);
113
114 if (emsg)
115 {
116 g_printerr("ERROR: %s\n", emsg);
117 GNUNET_free(emsg);
118 }
119
120 if (!uri)
121 goto free_string;
122
123 GNUNET_CHAT_lobby_join(app->chat.messenger.handle, uri);
124 GNUNET_CHAT_uri_destroy(uri);
125
126 free_string:
127 g_free(uri_string);
128 }
129
130 g_application_release(application);
75} 131}
76 132
77void 133void
@@ -84,12 +140,13 @@ application_init(MESSENGER_Application *app,
84 app->argc = argc; 140 app->argc = argc;
85 app->argv = argv; 141 app->argv = argv;
86 142
87 gst_init (&argc, &argv); 143 gst_init(&argc, &argv);
88 gtk_init(&argc, &argv); 144 gtk_init(&argc, &argv);
89 hdy_init(); 145 hdy_init();
90 146
91 app->application = gtk_application_new( 147 app->application = gtk_application_new(
92 MESSENGER_APPLICATION_ID, 148 MESSENGER_APPLICATION_ID,
149 G_APPLICATION_HANDLES_OPEN |
93 G_APPLICATION_NON_UNIQUE 150 G_APPLICATION_NON_UNIQUE
94 ); 151 );
95 152
@@ -136,6 +193,13 @@ application_init(MESSENGER_Application *app,
136 G_CALLBACK(_application_activate), 193 G_CALLBACK(_application_activate),
137 app 194 app
138 ); 195 );
196
197 g_signal_connect(
198 app->application,
199 "open",
200 G_CALLBACK(_application_open),
201 app
202 );
139} 203}
140 204
141const gchar* 205const gchar*
diff --git a/src/application.h b/src/application.h
index 8c7b599..2c0972b 100644
--- a/src/application.h
+++ b/src/application.h
@@ -71,6 +71,7 @@ typedef struct MESSENGER_Application
71 71
72 GtkApplication *application; 72 GtkApplication *application;
73 GList *notifications; 73 GList *notifications;
74 guint init;
74 75
75 struct { 76 struct {
76 GQuark widget; 77 GQuark widget;
diff --git a/src/contact.c b/src/contact.c
index 78045bb..0ebe9c6 100644
--- a/src/contact.c
+++ b/src/contact.c
@@ -24,6 +24,8 @@
24 24
25#include "contact.h" 25#include "contact.h"
26 26
27#include "ui.h"
28
27void 29void
28contact_create_info(struct GNUNET_CHAT_Contact *contact) 30contact_create_info(struct GNUNET_CHAT_Contact *contact)
29{ 31{
@@ -67,7 +69,8 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact,
67 return; 69 return;
68 70
69 const char *name = GNUNET_CHAT_contact_get_name(contact); 71 const char *name = GNUNET_CHAT_contact_get_name(contact);
70 gtk_label_set_text(label, name? name : ""); 72
73 ui_label_set_text(label, name);
71 74
72 info->name_labels = g_list_append(info->name_labels, label); 75 info->name_labels = g_list_append(info->name_labels, label);
73} 76}
@@ -82,7 +85,8 @@ contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact,
82 return; 85 return;
83 86
84 const char *name = GNUNET_CHAT_contact_get_name(contact); 87 const char *name = GNUNET_CHAT_contact_get_name(contact);
85 hdy_avatar_set_text(avatar, name? name : ""); 88
89 ui_avatar_set_text(avatar, name);
86 90
87 info->name_avatars = g_list_append(info->name_avatars, avatar); 91 info->name_avatars = g_list_append(info->name_avatars, avatar);
88} 92}
@@ -99,11 +103,8 @@ contact_update_info(const struct GNUNET_CHAT_Contact *contact)
99 const char *name = GNUNET_CHAT_contact_get_name(contact); 103 const char *name = GNUNET_CHAT_contact_get_name(contact);
100 104
101 for (list = info->name_labels; list; list = list->next) 105 for (list = info->name_labels; list; list = list->next)
102 gtk_label_set_text(GTK_LABEL(list->data), name? name : ""); 106 ui_label_set_text(GTK_LABEL(list->data), name);
103
104 if (!name)
105 return;
106 107
107 for (list = info->name_avatars; list; list = list->next) 108 for (list = info->name_avatars; list; list = list->next)
108 hdy_avatar_set_text(HDY_AVATAR(list->data), name); 109 ui_avatar_set_text(HDY_AVATAR(list->data), name);
109} 110}
diff --git a/src/event.c b/src/event.c
index 8cfdaa7..59c47d6 100644
--- a/src/event.c
+++ b/src/event.c
@@ -26,8 +26,9 @@
26 26
27#include "contact.h" 27#include "contact.h"
28#include "file.h" 28#include "file.h"
29#include "ui/account_entry.h" 29#include "ui.h"
30 30
31#include "ui/account_entry.h"
31#include "ui/chat_entry.h" 32#include "ui/chat_entry.h"
32#include "ui/contact_entry.h" 33#include "ui/contact_entry.h"
33#include "ui/message.h" 34#include "ui/message.h"
@@ -50,9 +51,9 @@ static void
50_show_notification(MESSENGER_Application *app, 51_show_notification(MESSENGER_Application *app,
51 UNUSED struct GNUNET_CHAT_Context *context, 52 UNUSED struct GNUNET_CHAT_Context *context,
52 const struct GNUNET_CHAT_Contact *contact, 53 const struct GNUNET_CHAT_Contact *contact,
53 const gchar *text, 54 const char *text,
54 const gchar *icon, 55 const char *icon,
55 const gchar *category) 56 const char *category)
56{ 57{
57 if (app->settings.disable_notifications) 58 if (app->settings.disable_notifications)
58 return; 59 return;
@@ -85,13 +86,13 @@ event_handle_warning(MESSENGER_Application *app,
85 struct GNUNET_CHAT_Context *context, 86 struct GNUNET_CHAT_Context *context,
86 const struct GNUNET_CHAT_Message *msg) 87 const struct GNUNET_CHAT_Message *msg)
87{ 88{
88 const gchar *text = GNUNET_CHAT_message_get_text(msg); 89 const char *text = GNUNET_CHAT_message_get_text(msg);
89 90
90 const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( 91 const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender(
91 msg 92 msg
92 ); 93 );
93 94
94 fprintf(stderr, "ERROR: %s\n", text); 95 g_printerr("ERROR: %s\n", text);
95 96
96 _show_notification( 97 _show_notification(
97 app, 98 app,
@@ -141,7 +142,7 @@ _select_chat_to_activate(gpointer user_data)
141{ 142{
142 UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) user_data; 143 UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) user_data;
143 144
144 if (!(entry->chat)) 145 if ((!entry) || (!(entry->chat)) || (!(entry->entry_box)))
145 return FALSE; 146 return FALSE;
146 147
147 MESSENGER_Application *app = entry->chat->app; 148 MESSENGER_Application *app = entry->chat->app;
@@ -149,12 +150,15 @@ _select_chat_to_activate(gpointer user_data)
149 if (!app) 150 if (!app)
150 return FALSE; 151 return FALSE;
151 152
152 UI_MESSENGER_Handle *ui = &(app->ui.messenger);
153
154 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 153 GtkListBoxRow *row = GTK_LIST_BOX_ROW(
155 gtk_widget_get_parent(entry->entry_box) 154 gtk_widget_get_parent(entry->entry_box)
156 ); 155 );
157 156
157 if (!row)
158 return FALSE;
159
160 UI_MESSENGER_Handle *ui = &(app->ui.messenger);
161
158 gtk_list_box_select_row(ui->chats_listbox, row); 162 gtk_list_box_select_row(ui->chats_listbox, row);
159 gtk_list_box_invalidate_filter(ui->chats_listbox); 163 gtk_list_box_invalidate_filter(ui->chats_listbox);
160 164
@@ -224,9 +228,7 @@ _add_new_chat_entry(MESSENGER_Application *app,
224 228
225 ui->chat_entries = g_list_append(ui->chat_entries, entry); 229 ui->chat_entries = g_list_append(ui->chat_entries, entry);
226 230
227 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 231 GtkWidget *row = gtk_widget_get_parent(entry->entry_box);
228 gtk_widget_get_parent(entry->entry_box)
229 );
230 232
231 g_object_set_qdata( 233 g_object_set_qdata(
232 G_OBJECT(row), 234 G_OBJECT(row),
@@ -305,16 +307,12 @@ event_update_profile(MESSENGER_Application *app)
305 307
306 const char *name = GNUNET_CHAT_get_name(chat->handle); 308 const char *name = GNUNET_CHAT_get_name(chat->handle);
307 309
308 if (name) 310 ui_avatar_set_text(ui->profile_avatar, name);
309 { 311 ui_label_set_text(ui->profile_label, name);
310 hdy_avatar_set_text(ui->profile_avatar, name);
311 gtk_label_set_text(ui->profile_label, name);
312 }
313 312
314 const char *key = GNUNET_CHAT_get_key(chat->handle); 313 const char *key = GNUNET_CHAT_get_key(chat->handle);
315 314
316 if (key) 315 ui_label_set_text(ui->profile_key_label, key);
317 gtk_label_set_text(ui->profile_key_label, key);
318 316
319 gtk_container_foreach( 317 gtk_container_foreach(
320 GTK_CONTAINER(ui->chats_listbox), 318 GTK_CONTAINER(ui->chats_listbox),
@@ -430,7 +428,7 @@ event_presence_contact(MESSENGER_Application *app,
430 contact_add_name_avatar_to_info(contact, message->sender_avatar); 428 contact_add_name_avatar_to_info(contact, message->sender_avatar);
431 contact_add_name_label_to_info(contact, message->sender_label); 429 contact_add_name_label_to_info(contact, message->sender_label);
432 430
433 const gchar *presence_message = ( 431 const char *text = (
434 GNUNET_CHAT_KIND_JOIN == kind? _("joined the chat") : _("left the chat") 432 GNUNET_CHAT_KIND_JOIN == kind? _("joined the chat") : _("left the chat")
435 ); 433 );
436 434
@@ -439,7 +437,7 @@ event_presence_contact(MESSENGER_Application *app,
439 app, 437 app,
440 context, 438 context,
441 contact, 439 contact,
442 presence_message, 440 text,
443 "avatar-default-symbolic", 441 "avatar-default-symbolic",
444 "presence.online" 442 "presence.online"
445 ); 443 );
@@ -448,10 +446,10 @@ event_presence_contact(MESSENGER_Application *app,
448 msg 446 msg
449 ); 447 );
450 448
451 const gchar *time = GNUNET_STRINGS_absolute_time_to_string(timestamp); 449 const char *time = GNUNET_STRINGS_absolute_time_to_string(timestamp);
452 450
453 gtk_label_set_text(message->text_label, presence_message); 451 ui_label_set_text(message->text_label, text);
454 gtk_label_set_text(message->timestamp_label, time? time : ""); 452 ui_label_set_text(message->timestamp_label, time);
455 453
456 ui_chat_add_message(handle->chat, app, message); 454 ui_chat_add_message(handle->chat, app, message);
457 455
@@ -531,7 +529,7 @@ event_invitation(MESSENGER_Application *app,
531 contact_add_name_avatar_to_info(contact, message->sender_avatar); 529 contact_add_name_avatar_to_info(contact, message->sender_avatar);
532 contact_add_name_label_to_info(contact, message->sender_label); 530 contact_add_name_label_to_info(contact, message->sender_label);
533 531
534 const gchar *invite_message = _("invited you to a chat"); 532 const char *invite_message = _("invited you to a chat");
535 533
536 if (!ui_messenger_is_context_active(&(app->ui.messenger), context)) 534 if (!ui_messenger_is_context_active(&(app->ui.messenger), context))
537 _show_notification( 535 _show_notification(
@@ -543,7 +541,7 @@ event_invitation(MESSENGER_Application *app,
543 "im.received" 541 "im.received"
544 ); 542 );
545 543
546 gtk_label_set_text(message->text_label, invite_message); 544 ui_label_set_text(message->text_label, invite_message);
547 545
548 g_signal_connect( 546 g_signal_connect(
549 message->accept_button, 547 message->accept_button,
@@ -632,7 +630,7 @@ event_receive_message(MESSENGER_Application *app,
632 msg 630 msg
633 ); 631 );
634 632
635 const gchar *time = GNUNET_STRINGS_absolute_time_to_string(timestamp); 633 const char *time = GNUNET_STRINGS_absolute_time_to_string(timestamp);
636 634
637 if ((!ui_messenger_is_context_active(&(app->ui.messenger), context)) && 635 if ((!ui_messenger_is_context_active(&(app->ui.messenger), context)) &&
638 (GNUNET_YES != sent)) 636 (GNUNET_YES != sent))
@@ -645,8 +643,8 @@ event_receive_message(MESSENGER_Application *app,
645 "im.received" 643 "im.received"
646 ); 644 );
647 645
648 gtk_label_set_text(message->text_label, text? text : ""); 646 ui_label_set_text(message->text_label, text);
649 gtk_label_set_text(message->timestamp_label, time? time : ""); 647 ui_label_set_text(message->timestamp_label, time);
650 648
651 ui_chat_add_message(handle->chat, app, message); 649 ui_chat_add_message(handle->chat, app, message);
652 650
diff --git a/src/ui.c b/src/ui.c
new file mode 100644
index 0000000..420d1cc
--- /dev/null
+++ b/src/ui.c
@@ -0,0 +1,72 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 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.c
23 */
24
25#include "ui.h"
26
27void
28ui_label_set_text(GtkLabel *label, const char *text)
29{
30 if (!text)
31 {
32 gtk_label_set_text(label, "");
33 return;
34 }
35
36 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
37 gtk_label_set_text(label, _text);
38 g_free(_text);
39}
40
41void
42ui_entry_set_text(GtkEntry *entry, const char *text)
43{
44 if (!text)
45 {
46 gtk_entry_set_text(entry, "");
47 return;
48 }
49
50 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
51 gtk_entry_set_text(entry, _text);
52 g_free(_text);
53}
54
55void
56ui_avatar_set_text(HdyAvatar *avatar, const char *text)
57{
58 if (!text)
59 {
60 const gchar *state = hdy_avatar_get_text(avatar);
61
62 if ((!state) || (!g_utf8_strlen(state, 1)))
63 return;
64
65 hdy_avatar_set_text(avatar, "");
66 return;
67 }
68
69 gchar *_text = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
70 hdy_avatar_set_text(avatar, _text);
71 g_free(_text);
72}
diff --git a/src/ui.h b/src/ui.h
new file mode 100644
index 0000000..3c06bcc
--- /dev/null
+++ b/src/ui.h
@@ -0,0 +1,40 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 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.h
23 */
24
25#ifndef UI_H_
26#define UI_H_
27
28#include <gtk-3.0/gtk/gtk.h>
29#include <libhandy-1/handy.h>
30
31void
32ui_label_set_text(GtkLabel *label, const char *text);
33
34void
35ui_entry_set_text(GtkEntry *entry, const char *text);
36
37void
38ui_avatar_set_text(HdyAvatar *avatar, const char *text);
39
40#endif /* UI_H_ */
diff --git a/src/ui/account_entry.c b/src/ui/account_entry.c
index 4d8355a..7a9ccdb 100644
--- a/src/ui/account_entry.c
+++ b/src/ui/account_entry.c
@@ -25,6 +25,7 @@
25#include "account_entry.h" 25#include "account_entry.h"
26 26
27#include "../application.h" 27#include "../application.h"
28#include "../ui.h"
28 29
29UI_ACCOUNT_ENTRY_Handle* 30UI_ACCOUNT_ENTRY_Handle*
30ui_account_entry_new(MESSENGER_Application *app) 31ui_account_entry_new(MESSENGER_Application *app)
@@ -54,26 +55,20 @@ void
54ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle, 55ui_account_entry_set_account(UI_ACCOUNT_ENTRY_Handle* handle,
55 const struct GNUNET_CHAT_Account *account) 56 const struct GNUNET_CHAT_Account *account)
56{ 57{
57 const gchar *name = GNUNET_CHAT_account_get_name(account); 58 const char *name = GNUNET_CHAT_account_get_name(account);
58 59
59 if (!name) 60 ui_avatar_set_text(handle->entry_avatar, name);
60 return; 61 ui_label_set_text(handle->entry_label, name);
61
62 hdy_avatar_set_text(handle->entry_avatar, name);
63 gtk_label_set_text(handle->entry_label, name);
64} 62}
65 63
66void 64void
67ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle, 65ui_account_entry_set_contact(UI_ACCOUNT_ENTRY_Handle* handle,
68 const struct GNUNET_CHAT_Contact *contact) 66 const struct GNUNET_CHAT_Contact *contact)
69{ 67{
70 const gchar *name = GNUNET_CHAT_contact_get_name(contact); 68 const char *name = GNUNET_CHAT_contact_get_name(contact);
71
72 if (!name)
73 return;
74 69
75 hdy_avatar_set_text(handle->entry_avatar, name); 70 ui_avatar_set_text(handle->entry_avatar, name);
76 gtk_label_set_text(handle->entry_label, name); 71 ui_label_set_text(handle->entry_label, name);
77} 72}
78 73
79void 74void
diff --git a/src/ui/chat.c b/src/ui/chat.c
index d266726..4928c04 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -38,6 +38,7 @@
38#include "../application.h" 38#include "../application.h"
39#include "../contact.h" 39#include "../contact.h"
40#include "../file.h" 40#include "../file.h"
41#include "../ui.h"
41 42
42static gboolean 43static gboolean
43_flap_chat_details_reveal_switch(gpointer user_data) 44_flap_chat_details_reveal_switch(gpointer user_data)
@@ -520,7 +521,7 @@ handle_send_record_button_click(GtkButton *button,
520 { 521 {
521 UI_FILE_LOAD_ENTRY_Handle *file_load = ui_file_load_entry_new(app); 522 UI_FILE_LOAD_ENTRY_Handle *file_load = ui_file_load_entry_new(app);
522 523
523 gtk_label_set_text(file_load->file_label, handle->recording_filename); 524 ui_label_set_text(file_load->file_label, handle->recording_filename);
524 gtk_progress_bar_set_fraction(file_load->load_progress_bar, 0.0); 525 gtk_progress_bar_set_fraction(file_load->load_progress_bar, 0.0);
525 526
526 struct GNUNET_CHAT_File *file = GNUNET_CHAT_context_send_file( 527 struct GNUNET_CHAT_File *file = GNUNET_CHAT_context_send_file(
@@ -1493,17 +1494,14 @@ ui_chat_update(UI_CHAT_Handle *handle,
1493 ); 1494 );
1494 } 1495 }
1495 1496
1496 hdy_avatar_set_text(handle->chat_avatar, title? title : ""); 1497 ui_avatar_set_text(handle->chat_avatar, title);
1497 hdy_avatar_set_icon_name(handle->chat_avatar, icon); 1498 hdy_avatar_set_icon_name(handle->chat_avatar, icon);
1498 1499
1499 hdy_avatar_set_text(handle->chat_details_avatar, title? title : ""); 1500 ui_avatar_set_text(handle->chat_details_avatar, title);
1500 hdy_avatar_set_icon_name(handle->chat_details_avatar, icon); 1501 hdy_avatar_set_icon_name(handle->chat_details_avatar, icon);
1501 1502
1502 if (title) 1503 ui_label_set_text(handle->chat_title, title);
1503 { 1504 ui_label_set_text(handle->chat_details_label, title);
1504 gtk_label_set_text(handle->chat_title, title);
1505 gtk_label_set_text(handle->chat_details_label, title);
1506 }
1507 1505
1508 if (subtitle->len > 0) 1506 if (subtitle->len > 0)
1509 gtk_label_set_text(handle->chat_subtitle, subtitle->str); 1507 gtk_label_set_text(handle->chat_subtitle, subtitle->str);
@@ -1694,7 +1692,7 @@ ui_chat_remove_file_load(UI_CHAT_Handle *handle,
1694 1692
1695 gtk_container_remove( 1693 gtk_container_remove(
1696 GTK_CONTAINER(handle->chat_load_listbox), 1694 GTK_CONTAINER(handle->chat_load_listbox),
1697 gtk_widget_get_parent(GTK_WIDGET(file_load->entry_box)) 1695 gtk_widget_get_parent(file_load->entry_box)
1698 ); 1696 );
1699 1697
1700 if (handle->loads) 1698 if (handle->loads)
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c
index 85684f0..89272be 100644
--- a/src/ui/chat_entry.c
+++ b/src/ui/chat_entry.c
@@ -24,10 +24,11 @@
24 24
25#include "chat_entry.h" 25#include "chat_entry.h"
26 26
27#include "message.h"
28
27#include "../application.h" 29#include "../application.h"
28#include "../contact.h" 30#include "../contact.h"
29 31#include "../ui.h"
30#include "message.h"
31 32
32UI_CHAT_ENTRY_Handle* 33UI_CHAT_ENTRY_Handle*
33ui_chat_entry_new(MESSENGER_Application *app) 34ui_chat_entry_new(MESSENGER_Application *app)
@@ -99,9 +100,8 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle,
99 icon = "system-users-symbolic"; 100 icon = "system-users-symbolic";
100 } 101 }
101 102
102 gtk_label_set_text(handle->title_label, title? title : ""); 103 ui_label_set_text(handle->title_label, title);
103 104 ui_avatar_set_text(handle->entry_avatar, title);
104 hdy_avatar_set_text(handle->entry_avatar, title? title : "");
105 hdy_avatar_set_icon_name(handle->entry_avatar, icon); 105 hdy_avatar_set_icon_name(handle->entry_avatar, icon);
106 106
107 if (!(handle->chat)) 107 if (!(handle->chat))
diff --git a/src/ui/contact_entry.c b/src/ui/contact_entry.c
index 54fe80a..b9789da 100644
--- a/src/ui/contact_entry.c
+++ b/src/ui/contact_entry.c
@@ -25,6 +25,7 @@
25#include "contact_entry.h" 25#include "contact_entry.h"
26 26
27#include "../application.h" 27#include "../application.h"
28#include "../ui.h"
28 29
29UI_CONTACT_ENTRY_Handle* 30UI_CONTACT_ENTRY_Handle*
30ui_contact_entry_new(MESSENGER_Application *app) 31ui_contact_entry_new(MESSENGER_Application *app)
@@ -59,24 +60,12 @@ ui_contact_entry_set_contact(UI_CONTACT_ENTRY_Handle* handle,
59 const struct GNUNET_CHAT_Contact *contact) 60 const struct GNUNET_CHAT_Contact *contact)
60{ 61{
61 62
62 const gchar *name; 63 const char *name = GNUNET_CHAT_contact_get_name(contact);
63 const gchar *key; 64 const char *key = GNUNET_CHAT_contact_get_key(contact);
64 65
65 name = GNUNET_CHAT_contact_get_name(contact); 66 ui_avatar_set_text(handle->entry_avatar, name);
66 67 ui_label_set_text(handle->title_label, name);
67 if (!name) 68 ui_label_set_text(handle->subtitle_label, key);
68 goto skip_name;
69
70 hdy_avatar_set_text(handle->entry_avatar, name);
71 gtk_label_set_text(handle->title_label, name);
72
73skip_name:
74 key = GNUNET_CHAT_contact_get_key(contact);
75
76 if (!key)
77 return;
78
79 gtk_label_set_text(handle->subtitle_label, name);
80} 69}
81 70
82void 71void
diff --git a/src/ui/contact_info.c b/src/ui/contact_info.c
index 05f12a6..f6c2e91 100644
--- a/src/ui/contact_info.c
+++ b/src/ui/contact_info.c
@@ -25,7 +25,9 @@
25#include "contact_info.h" 25#include "contact_info.h"
26 26
27#include "chat_entry.h" 27#include "chat_entry.h"
28
28#include "../application.h" 29#include "../application.h"
30#include "../ui.h"
29 31
30static void 32static void
31handle_contact_edit_button_click(UNUSED GtkButton *button, 33handle_contact_edit_button_click(UNUSED GtkButton *button,
@@ -137,13 +139,16 @@ handle_open_chat_button_click(UNUSED GtkButton *button,
137 139
138 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context); 140 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context);
139 141
140 if (!entry) 142 if ((!entry) || (!(entry->entry_box)))
141 return; 143 return;
142 144
143 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 145 GtkListBoxRow *row = GTK_LIST_BOX_ROW(
144 gtk_widget_get_parent(entry->entry_box) 146 gtk_widget_get_parent(entry->entry_box)
145 ); 147 );
146 148
149 if (!row)
150 return;
151
147 gtk_list_box_select_row(handle->app->ui.messenger.chats_listbox, row); 152 gtk_list_box_select_row(handle->app->ui.messenger.chats_listbox, row);
148 gtk_list_box_invalidate_filter(handle->app->ui.messenger.chats_listbox); 153 gtk_list_box_invalidate_filter(handle->app->ui.messenger.chats_listbox);
149 154
@@ -415,8 +420,8 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle,
415{ 420{
416 const char *name = GNUNET_CHAT_contact_get_name(contact); 421 const char *name = GNUNET_CHAT_contact_get_name(contact);
417 422
418 hdy_avatar_set_text(handle->contact_avatar, name? name : ""); 423 ui_avatar_set_text(handle->contact_avatar, name);
419 gtk_entry_set_text(handle->contact_name_entry, name? name : ""); 424 ui_entry_set_text(handle->contact_name_entry, name);
420 425
421 g_object_set_qdata( 426 g_object_set_qdata(
422 G_OBJECT(handle->contact_name_entry), 427 G_OBJECT(handle->contact_name_entry),
@@ -440,12 +445,12 @@ ui_contact_info_dialog_update(UI_CONTACT_INFO_Handle *handle,
440 else 445 else
441 handle->qr = NULL; 446 handle->qr = NULL;
442 447
443 gtk_label_set_text(handle->name_label, name? name : ""); 448 ui_label_set_text(handle->name_label, name);
444 449
445 if (handle->id_drawing_area) 450 if (handle->id_drawing_area)
446 gtk_widget_queue_draw(GTK_WIDGET(handle->id_drawing_area)); 451 gtk_widget_queue_draw(GTK_WIDGET(handle->id_drawing_area));
447 452
448 gtk_entry_set_text(handle->id_entry, key? key : ""); 453 ui_entry_set_text(handle->id_entry, key);
449 454
450 gtk_widget_set_sensitive( 455 gtk_widget_set_sensitive(
451 GTK_WIDGET(handle->reveal_identity_button), 456 GTK_WIDGET(handle->reveal_identity_button),
diff --git a/src/ui/message.c b/src/ui/message.c
index c1bd648..8d5627f 100644
--- a/src/ui/message.c
+++ b/src/ui/message.c
@@ -28,6 +28,7 @@
28 28
29#include "../application.h" 29#include "../application.h"
30#include "../file.h" 30#include "../file.h"
31#include "../ui.h"
31 32
32static void 33static void
33handle_downloading_file(void *cls, 34handle_downloading_file(void *cls,
@@ -434,6 +435,8 @@ _update_file_message(UI_MESSAGE_Handle *handle,
434 MESSENGER_Application *app, 435 MESSENGER_Application *app,
435 struct GNUNET_CHAT_File *file) 436 struct GNUNET_CHAT_File *file)
436{ 437{
438 const char *filename = GNUNET_CHAT_file_get_name(file);
439
437 uint64_t size = GNUNET_CHAT_file_get_size(file); 440 uint64_t size = GNUNET_CHAT_file_get_size(file);
438 uint64_t local_size = GNUNET_CHAT_file_get_local_size(file); 441 uint64_t local_size = GNUNET_CHAT_file_get_local_size(file);
439 442
@@ -498,7 +501,7 @@ file_progress:
498 ); 501 );
499 502
500file_content: 503file_content:
501 gtk_label_set_text(handle->filename_label, GNUNET_CHAT_file_get_name(file)); 504 ui_label_set_text(handle->filename_label, filename);
502 505
503 gtk_stack_set_visible_child( 506 gtk_stack_set_visible_child(
504 handle->content_stack, 507 handle->content_stack,
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 69200f9..7d68f27 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -37,6 +37,7 @@
37#include "settings.h" 37#include "settings.h"
38 38
39#include "../application.h" 39#include "../application.h"
40#include "../ui.h"
40 41
41static gboolean 42static gboolean
42_flap_user_details_reveal_switch(gpointer user_data) 43_flap_user_details_reveal_switch(gpointer user_data)
@@ -605,24 +606,22 @@ _messenger_iterate_accounts(void *cls,
605 MESSENGER_Application *app = (MESSENGER_Application*) cls; 606 MESSENGER_Application *app = (MESSENGER_Application*) cls;
606 UI_MESSENGER_Handle *ui = &(app->ui.messenger); 607 UI_MESSENGER_Handle *ui = &(app->ui.messenger);
607 608
608 const gchar *name = GNUNET_CHAT_account_get_name(account); 609 const char *name = GNUNET_CHAT_account_get_name(account);
609 610
610 UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app); 611 UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app);
611 612
612 hdy_avatar_set_text(entry->entry_avatar, name); 613 ui_avatar_set_text(entry->entry_avatar, name);
613 gtk_label_set_text(entry->entry_label, name); 614 ui_label_set_text(entry->entry_label, name);
614 615
615 gtk_list_box_prepend(ui->accounts_listbox, entry->entry_box); 616 gtk_list_box_prepend(ui->accounts_listbox, entry->entry_box);
616 617
617 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 618 GtkWidget *row = gtk_widget_get_parent(entry->entry_box);
618 gtk_widget_get_parent(entry->entry_box)
619 );
620 619
621 g_object_set_qdata(G_OBJECT(row), app->quarks.data, account); 620 g_object_set_qdata(G_OBJECT(row), app->quarks.data, account);
622 621
623 if ((account == GNUNET_CHAT_get_connected(handle)) || 622 if ((account == GNUNET_CHAT_get_connected(handle)) ||
624 ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) 623 ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name))))
625 gtk_widget_activate(GTK_WIDGET(row)); 624 gtk_widget_activate(row);
626 625
627 ui_account_entry_delete(entry); 626 ui_account_entry_delete(entry);
628 return GNUNET_YES; 627 return GNUNET_YES;
@@ -673,13 +672,16 @@ ui_messenger_is_context_active(UI_MESSENGER_Handle *handle,
673 672
674 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context); 673 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context);
675 674
676 if (!entry) 675 if ((!entry) || (!(entry->entry_box)))
677 return FALSE; 676 return FALSE;
678 677
679 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 678 GtkListBoxRow *row = GTK_LIST_BOX_ROW(
680 gtk_widget_get_parent(entry->entry_box) 679 gtk_widget_get_parent(entry->entry_box)
681 ); 680 );
682 681
682 if (!row)
683 return FALSE;
684
683 return gtk_list_box_row_is_selected(row); 685 return gtk_list_box_row_is_selected(row);
684} 686}
685 687
diff --git a/src/ui/new_account.c b/src/ui/new_account.c
index a64e016..452000b 100644
--- a/src/ui/new_account.c
+++ b/src/ui/new_account.c
@@ -63,7 +63,9 @@ handle_account_entry_changed(GtkEditable *editable,
63 HdyAvatar *avatar = HDY_AVATAR(user_data); 63 HdyAvatar *avatar = HDY_AVATAR(user_data);
64 GtkEntry *entry = GTK_ENTRY(editable); 64 GtkEntry *entry = GTK_ENTRY(editable);
65 65
66 hdy_avatar_set_text(avatar, gtk_entry_get_text(entry)); 66 const gchar *text = gtk_entry_get_text(entry);
67
68 hdy_avatar_set_text(avatar, text);
67} 69}
68 70
69static void 71static void
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c
index 7d5d395..094dd67 100644
--- a/src/ui/new_contact.c
+++ b/src/ui/new_contact.c
@@ -49,18 +49,18 @@ handle_confirm_button_click(UNUSED GtkButton *button,
49 gchar *emsg = NULL; 49 gchar *emsg = NULL;
50 struct GNUNET_CHAT_Uri *uri = GNUNET_CHAT_uri_parse(id_text, &emsg); 50 struct GNUNET_CHAT_Uri *uri = GNUNET_CHAT_uri_parse(id_text, &emsg);
51 51
52 if (uri)
53 {
54 GNUNET_CHAT_lobby_join(app->chat.messenger.handle, uri);
55 GNUNET_CHAT_uri_destroy(uri);
56 }
57
58 if (emsg) 52 if (emsg)
59 { 53 {
60 printf("ERROR: %s\n", emsg); 54 g_printerr("ERROR: %s\n", emsg);
61 GNUNET_free(emsg); 55 GNUNET_free(emsg);
62 } 56 }
63 57
58 if (!uri)
59 goto close_dialog;
60
61 GNUNET_CHAT_lobby_join(app->chat.messenger.handle, uri);
62 GNUNET_CHAT_uri_destroy(uri);
63
64close_dialog: 64close_dialog:
65 gtk_window_close(GTK_WINDOW(app->ui.new_contact.dialog)); 65 gtk_window_close(GTK_WINDOW(app->ui.new_contact.dialog));
66} 66}
diff --git a/src/ui/new_group.c b/src/ui/new_group.c
index 6b60145..6f76e4f 100644
--- a/src/ui/new_group.c
+++ b/src/ui/new_group.c
@@ -68,7 +68,9 @@ handle_group_entry_changed(GtkEditable *editable,
68 HdyAvatar *avatar = HDY_AVATAR(user_data); 68 HdyAvatar *avatar = HDY_AVATAR(user_data);
69 GtkEntry *entry = GTK_ENTRY(editable); 69 GtkEntry *entry = GTK_ENTRY(editable);
70 70
71 hdy_avatar_set_text(avatar, gtk_entry_get_text(entry)); 71 const gchar *text = gtk_entry_get_text(entry);
72
73 hdy_avatar_set_text(avatar, text);
72} 74}
73 75
74static void 76static void
@@ -166,10 +168,7 @@ _iterate_contacts(void *cls,
166 entry->entry_box 168 entry->entry_box
167 ); 169 );
168 170
169 GtkListBoxRow *row = GTK_LIST_BOX_ROW( 171 GtkWidget *row = gtk_widget_get_parent(entry->entry_box);
170 gtk_widget_get_parent(entry->entry_box)
171 );
172
173 g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); 172 g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact);
174 173
175 app->ui.new_group.contact_entries = g_list_append( 174 app->ui.new_group.contact_entries = g_list_append(
diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c
index 5eea8d5..1216239 100644
--- a/src/ui/new_platform.c
+++ b/src/ui/new_platform.c
@@ -51,7 +51,11 @@ handle_platform_entry_changed(GtkEditable *editable,
51 HdyAvatar *avatar = HDY_AVATAR(user_data); 51 HdyAvatar *avatar = HDY_AVATAR(user_data);
52 GtkEntry *entry = GTK_ENTRY(editable); 52 GtkEntry *entry = GTK_ENTRY(editable);
53 53
54 GString *topic_string = g_string_new(gtk_entry_get_text(entry)); 54 const gchar *text = gtk_entry_get_text(entry);
55
56 hdy_avatar_set_text(avatar, text);
57
58 GString *topic_string = g_string_new(text);
55 59
56 g_string_prepend_c(topic_string, '#'); 60 g_string_prepend_c(topic_string, '#');
57 hdy_avatar_set_text(avatar, topic_string->str); 61 hdy_avatar_set_text(avatar, topic_string->str);
diff --git a/src/ui/send_file.c b/src/ui/send_file.c
index b2e6bb0..52fee25 100644
--- a/src/ui/send_file.c
+++ b/src/ui/send_file.c
@@ -30,6 +30,7 @@
30 30
31#include "../application.h" 31#include "../application.h"
32#include "../file.h" 32#include "../file.h"
33#include "../ui.h"
33 34
34static void 35static void
35handle_cancel_button_click(UNUSED GtkButton *button, 36handle_cancel_button_click(UNUSED GtkButton *button,