messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit bcf36809da07651976fc6528a391f3b51fc5ce0b
parent 56a206cd17e1caf23fbfd679c39752e5e194f35d
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sun, 14 Nov 2021 17:54:23 +0100

Fixed segfault and added convenience

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Msrc/ui/messenger.c | 19++++++++++---------
Msrc/ui/new_platform.c | 52++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/src/ui/messenger.c b/src/ui/messenger.c @@ -291,16 +291,17 @@ ui_messenger_init(MESSENGER_Application *app, ); } -static void -_free_ui_chat_entry (gpointer user_data) -{ - UI_CHAT_ENTRY_Handle* handle = (UI_CHAT_ENTRY_Handle*) user_data; - - ui_chat_entry_delete(handle); -} - void ui_messenger_cleanup(UI_MESSENGER_Handle *handle) { - g_list_free_full(handle->chat_entries, _free_ui_chat_entry); + GList *list = handle->chat_entries; + + while (list) { + if (list->data) + ui_chat_entry_delete((UI_CHAT_ENTRY_Handle*) list->data); + + list = list->next; + } + + g_list_free(handle->chat_entries); } diff --git a/src/ui/new_platform.c b/src/ui/new_platform.c @@ -27,6 +27,25 @@ #include "../application.h" static void +_open_new_platform(GtkEntry *entry, MESSENGER_Application *app) +{ + const gchar *topic = gtk_entry_get_text(entry); + + GString *topic_string = g_string_new(topic); + + struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( + app->chat.messenger.handle, + topic_string->str + ); + + g_string_prepend_c(topic_string, '#'); + + GNUNET_CHAT_group_set_name(group, topic_string->str); + + g_string_free(topic_string, TRUE); +} + +static void handle_platform_entry_changed(GtkEditable *editable, gpointer user_data) { @@ -37,6 +56,17 @@ handle_platform_entry_changed(GtkEditable *editable, } static void +handle_platform_entry_activate(GtkEntry *entry, + gpointer user_data) +{ + MESSENGER_Application *app = (MESSENGER_Application*) user_data; + + _open_new_platform(entry, app); + + gtk_window_close(GTK_WINDOW(app->ui.new_platform.platform_dialog)); +} + +static void handle_cancel_button_click(UNUSED GtkButton *button, gpointer user_data) { @@ -50,20 +80,7 @@ handle_confirm_button_click(UNUSED GtkButton *button, { MESSENGER_Application *app = (MESSENGER_Application*) user_data; - const gchar *topic = gtk_entry_get_text(app->ui.new_platform.platform_entry); - - GString *topic_string = g_string_new(topic); - - struct GNUNET_CHAT_Group *group = GNUNET_CHAT_group_create( - app->chat.messenger.handle, - topic_string->str - ); - - g_string_prepend_c(topic_string, '#'); - - GNUNET_CHAT_group_set_name(group, topic_string->str); - - g_string_free(topic_string, TRUE); + _open_new_platform(app->ui.new_platform.platform_entry, app); gtk_window_close(GTK_WINDOW(app->ui.new_platform.platform_dialog)); } @@ -109,6 +126,13 @@ ui_new_platform_dialog_init(MESSENGER_Application *app, handle->platform_avatar ); + g_signal_connect( + handle->platform_entry, + "activate", + G_CALLBACK(handle_platform_entry_activate), + app + ); + handle->cancel_button = GTK_BUTTON( gtk_builder_get_object(builder, "cancel_button") );