aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-03-30 00:23:56 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2022-03-30 00:23:56 +0200
commitad8dbe9b406b8b0b13be34234c9c1a40f3df5778 (patch)
treeb860af474d194d9a5633fbffaa14f72853707e2c /src/ui
parent299174878a9deb2f077294ed02beb79599246ea6 (diff)
downloadmessenger-gtk-ad8dbe9b406b8b0b13be34234c9c1a40f3df5778.tar.gz
messenger-gtk-ad8dbe9b406b8b0b13be34234c9c1a40f3df5778.zip
Added functions to solve utf8 conversion issues
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/ui')
-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
12 files changed, 69 insertions, 71 deletions
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,