aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-02-17 13:39:13 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-02-17 13:39:13 +0100
commitef325fba989867bb5d17b0cf4e3ae8cd653ffd1e (patch)
treea10d9f2176bfedf1d77e7231e7c785b4d2dc2f37
parent5f2a26c5509d32548220d665f425aebccc93dbab (diff)
downloadmessenger-gtk-ef325fba989867bb5d17b0cf4e3ae8cd653ffd1e.tar.gz
messenger-gtk-ef325fba989867bb5d17b0cf4e3ae8cd653ffd1e.zip
Tweaked usability when switching between accounts
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--resources/ui/messenger.ui2
-rw-r--r--src/event.c2
-rw-r--r--src/ui/messenger.c35
-rw-r--r--src/ui/messenger.h1
4 files changed, 28 insertions, 12 deletions
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
index 9076e67..fdc8146 100644
--- a/resources/ui/messenger.ui
+++ b/resources/ui/messenger.ui
@@ -724,7 +724,7 @@ Author: Tobias Frisch
724 <property name="visible">True</property> 724 <property name="visible">True</property>
725 <property name="can-focus">False</property> 725 <property name="can-focus">False</property>
726 <child> 726 <child>
727 <object class="GtkBox"> 727 <object class="GtkBox" id="no_chat_box">
728 <property name="visible">True</property> 728 <property name="visible">True</property>
729 <property name="can-focus">False</property> 729 <property name="can-focus">False</property>
730 <property name="orientation">vertical</property> 730 <property name="orientation">vertical</property>
diff --git a/src/event.c b/src/event.c
index 4df457b..8133b54 100644
--- a/src/event.c
+++ b/src/event.c
@@ -243,6 +243,8 @@ event_update_profile(MESSENGER_Application *app)
243 ui->chats_listbox 243 ui->chats_listbox
244 ); 244 );
245 245
246 gtk_stack_set_visible_child(ui->chats_stack, ui->no_chat_box);
247
246 GNUNET_CHAT_iterate_contacts(chat->handle, _iterate_profile_contacts, app); 248 GNUNET_CHAT_iterate_contacts(chat->handle, _iterate_profile_contacts, app);
247 GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app); 249 GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app);
248} 250}
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 26b1993..058fcbf 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -57,24 +57,33 @@ handle_flap_via_button_click(UNUSED GtkButton* button,
57} 57}
58 58
59static void 59static void
60_switch_details_revealer_visibility(UI_MESSENGER_Handle *handle,
61 gboolean state)
62{
63 GtkRevealer *revealer = handle->account_details_revealer;
64 GtkImage *symbol = handle->account_details_symbol;
65
66 gtk_revealer_set_reveal_child(revealer, state);
67 gtk_image_set_from_icon_name(
68 symbol,
69 state?
70 "go-up-symbolic" :
71 "go-down-symbolic",
72 GTK_ICON_SIZE_BUTTON
73 );
74}
75
76static void
60handle_account_details_button_click(UNUSED GtkButton* button, 77handle_account_details_button_click(UNUSED GtkButton* button,
61 gpointer user_data) 78 gpointer user_data)
62{ 79{
63 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; 80 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data;
64 81
65 GtkRevealer *revealer = handle->account_details_revealer; 82 GtkRevealer *revealer = handle->account_details_revealer;
66 GtkImage *symbol = handle->account_details_symbol;
67 83
68 gboolean old_state = gtk_revealer_get_reveal_child(revealer); 84 gboolean old_state = gtk_revealer_get_reveal_child(revealer);
69 85
70 gtk_revealer_set_reveal_child(revealer, !old_state); 86 _switch_details_revealer_visibility(handle, !old_state);
71 gtk_image_set_from_icon_name(
72 symbol,
73 old_state?
74 "go-down-symbolic" :
75 "go-up-symbolic",
76 GTK_ICON_SIZE_BUTTON
77 );
78} 87}
79 88
80static void 89static void
@@ -86,6 +95,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox,
86 95
87 if (row == app->ui.messenger.add_account_listbox_row) 96 if (row == app->ui.messenger.add_account_listbox_row)
88 { 97 {
98 _switch_details_revealer_visibility(&(app->ui.messenger), FALSE);
89 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); 99 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
90 100
91 ui_new_account_dialog_init(app, &(app->ui.new_account)); 101 ui_new_account_dialog_init(app, &(app->ui.new_account));
@@ -101,6 +111,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox,
101 if (!account) 111 if (!account)
102 return; 112 return;
103 113
114 _switch_details_revealer_visibility(&(app->ui.messenger), FALSE);
104 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); 115 hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
105 116
106 GNUNET_CHAT_connect(app->chat.messenger.handle, account); 117 GNUNET_CHAT_connect(app->chat.messenger.handle, account);
@@ -206,8 +217,6 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row,
206{ 217{
207 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; 218 UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data;
208 219
209 printf("-- %lu\n", (uint64_t) row);
210
211 if ((!gtk_list_box_row_get_selectable(row)) || 220 if ((!gtk_list_box_row_get_selectable(row)) ||
212 (gtk_list_box_row_is_selected(row))) 221 (gtk_list_box_row_is_selected(row)))
213 return TRUE; 222 return TRUE;
@@ -469,6 +478,10 @@ ui_messenger_init(MESSENGER_Application *app,
469 gtk_builder_get_object(handle->builder, "chats_stack") 478 gtk_builder_get_object(handle->builder, "chats_stack")
470 ); 479 );
471 480
481 handle->no_chat_box = GTK_WIDGET(
482 gtk_builder_get_object(handle->builder, "no_chat_box")
483 );
484
472 g_signal_connect( 485 g_signal_connect(
473 handle->main_window, 486 handle->main_window,
474 "destroy", 487 "destroy",
diff --git a/src/ui/messenger.h b/src/ui/messenger.h
index 08ea78e..c44f74b 100644
--- a/src/ui/messenger.h
+++ b/src/ui/messenger.h
@@ -70,6 +70,7 @@ typedef struct UI_MESSENGER_Handle
70 GtkListBox *chats_listbox; 70 GtkListBox *chats_listbox;
71 71
72 GtkStack *chats_stack; 72 GtkStack *chats_stack;
73 GtkWidget *no_chat_box;
73} UI_MESSENGER_Handle; 74} UI_MESSENGER_Handle;
74 75
75void 76void