messenger-gtk

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

commit 0507724d094855279a36162ac61d97b2962fb7ab
parent 7521023e5e1bd2df76006418085f7ef5e1246abe
Author: Jacki <jacki@thejackimonster.de>
Date:   Thu, 25 Apr 2024 21:06:25 +0200

Close when no account is found with provided ego name

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Mresources/ui/new_account.ui | 1+
Msrc/application.c | 14+++++++-------
Msrc/event.c | 6+++---
Msrc/ui/messenger.c | 22++++++++++++++++++++++
Msrc/ui/new_account.c | 16+++++++++++-----
5 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/resources/ui/new_account.ui b/resources/ui/new_account.ui @@ -55,6 +55,7 @@ Author: Tobias Frisch <object class="GtkButton" id="confirm_button"> <property name="label" translatable="yes">Confirm</property> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">True</property> <property name="receives-default">True</property> </object> diff --git a/src/application.c b/src/application.c @@ -376,16 +376,16 @@ _application_chat_thread(void *args) struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ( - 'm', - "mobile", - "Optimize UI spacing for mobile devices", - &(app->settings.mobile_design) + 'm', + "mobile", + "Optimize UI spacing for mobile devices", + &(app->settings.mobile_design) ), GNUNET_GETOPT_option_string ( -'e', + 'e', "ego", -"IDENTITY", -"Identity to select for messaging", + "IDENTITY", + "Identity to select for messaging", &(app->chat.identity) ), GNUNET_GETOPT_OPTION_END diff --git a/src/event.c b/src/event.c @@ -149,8 +149,10 @@ _idle_refresh_accounts(gpointer user_data) MESSENGER_Application *app = (MESSENGER_Application*) user_data; + app->ui.messenger.account_refresh = 0; + if (!(app->ui.messenger.main_window)) - goto refresh_exit; + return FALSE; _reload_accounts(app); @@ -159,8 +161,6 @@ _idle_refresh_accounts(gpointer user_data) else ui_accounts_dialog_refresh(app, &(app->ui.accounts)); -refresh_exit: - app->ui.messenger.account_refresh = 0; return FALSE; } diff --git a/src/ui/messenger.c b/src/ui/messenger.c @@ -36,6 +36,7 @@ #include "new_platform.h" #include "settings.h" +#include "../account.h" #include "../application.h" #include "../ui.h" @@ -745,6 +746,17 @@ _clear_accounts_listbox(GtkWidget *widget, ); } +static gboolean +_close_messenger_missing_account(gpointer data) +{ + g_assert(data); + + UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) data; + + gtk_window_close(GTK_WINDOW(handle->main_window)); + return FALSE; +} + void ui_messenger_refresh(MESSENGER_Application *app, UI_MESSENGER_Handle *handle) @@ -765,6 +777,16 @@ ui_messenger_refresh(MESSENGER_Application *app, _messenger_iterate_accounts, app ); + + if (gtk_list_box_get_selected_row(handle->accounts_listbox)) + return; + + gtk_widget_hide(GTK_WIDGET(handle->main_window)); + + handle->account_refresh = util_idle_add( + G_SOURCE_FUNC(_close_messenger_missing_account), + handle + ); } gboolean diff --git a/src/ui/new_account.c b/src/ui/new_account.c @@ -58,6 +58,8 @@ _open_new_account(GtkEntry *entry, app->chat.identity = GNUNET_strdup(name); + gtk_widget_set_sensitive(GTK_WIDGET(app->ui.new_account.dialog), FALSE); + if (!gtk_widget_is_visible(GTK_WIDGET(app->ui.messenger.main_window))) app->ui.new_account.show_queued = util_idle_add( G_SOURCE_FUNC(_show_messenger_main_window), app @@ -70,12 +72,16 @@ handle_account_entry_changed(GtkEditable *editable, { g_assert((editable) && (user_data)); - HdyAvatar *avatar = HDY_AVATAR(user_data); - GtkEntry *entry = GTK_ENTRY(editable); + UI_NEW_ACCOUNT_Handle *handle = (UI_NEW_ACCOUNT_Handle*) user_data; + + const gchar *text = gtk_entry_get_text(GTK_ENTRY(editable)); - const gchar *text = gtk_entry_get_text(entry); + hdy_avatar_set_text(handle->account_avatar, text); - hdy_avatar_set_text(avatar, text); + gtk_widget_set_sensitive( + GTK_WIDGET(handle->confirm_button), + (text) && (strlen(text) > 0) + ); } static void @@ -229,7 +235,7 @@ ui_new_account_dialog_init(MESSENGER_Application *app, handle->account_entry, "changed", G_CALLBACK(handle_account_entry_changed), - handle->account_avatar + handle ); g_signal_connect(