commit ef325fba989867bb5d17b0cf4e3ae8cd653ffd1e
parent 5f2a26c5509d32548220d665f425aebccc93dbab
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Thu, 17 Feb 2022 13:39:13 +0100
Tweaked usability when switching between accounts
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui
@@ -724,7 +724,7 @@ Author: Tobias Frisch
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="no_chat_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
diff --git a/src/event.c b/src/event.c
@@ -243,6 +243,8 @@ event_update_profile(MESSENGER_Application *app)
ui->chats_listbox
);
+ gtk_stack_set_visible_child(ui->chats_stack, ui->no_chat_box);
+
GNUNET_CHAT_iterate_contacts(chat->handle, _iterate_profile_contacts, app);
GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app);
}
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
@@ -57,24 +57,33 @@ handle_flap_via_button_click(UNUSED GtkButton* button,
}
static void
+_switch_details_revealer_visibility(UI_MESSENGER_Handle *handle,
+ gboolean state)
+{
+ GtkRevealer *revealer = handle->account_details_revealer;
+ GtkImage *symbol = handle->account_details_symbol;
+
+ gtk_revealer_set_reveal_child(revealer, state);
+ gtk_image_set_from_icon_name(
+ symbol,
+ state?
+ "go-up-symbolic" :
+ "go-down-symbolic",
+ GTK_ICON_SIZE_BUTTON
+ );
+}
+
+static void
handle_account_details_button_click(UNUSED GtkButton* button,
gpointer user_data)
{
UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data;
GtkRevealer *revealer = handle->account_details_revealer;
- GtkImage *symbol = handle->account_details_symbol;
gboolean old_state = gtk_revealer_get_reveal_child(revealer);
- gtk_revealer_set_reveal_child(revealer, !old_state);
- gtk_image_set_from_icon_name(
- symbol,
- old_state?
- "go-down-symbolic" :
- "go-up-symbolic",
- GTK_ICON_SIZE_BUTTON
- );
+ _switch_details_revealer_visibility(handle, !old_state);
}
static void
@@ -86,6 +95,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox,
if (row == app->ui.messenger.add_account_listbox_row)
{
+ _switch_details_revealer_visibility(&(app->ui.messenger), FALSE);
hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
ui_new_account_dialog_init(app, &(app->ui.new_account));
@@ -101,6 +111,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox,
if (!account)
return;
+ _switch_details_revealer_visibility(&(app->ui.messenger), FALSE);
hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
GNUNET_CHAT_connect(app->chat.messenger.handle, account);
@@ -206,8 +217,6 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row,
{
UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data;
- printf("-- %lu\n", (uint64_t) row);
-
if ((!gtk_list_box_row_get_selectable(row)) ||
(gtk_list_box_row_is_selected(row)))
return TRUE;
@@ -469,6 +478,10 @@ ui_messenger_init(MESSENGER_Application *app,
gtk_builder_get_object(handle->builder, "chats_stack")
);
+ handle->no_chat_box = GTK_WIDGET(
+ gtk_builder_get_object(handle->builder, "no_chat_box")
+ );
+
g_signal_connect(
handle->main_window,
"destroy",
diff --git a/src/ui/messenger.h b/src/ui/messenger.h
@@ -70,6 +70,7 @@ typedef struct UI_MESSENGER_Handle
GtkListBox *chats_listbox;
GtkStack *chats_stack;
+ GtkWidget *no_chat_box;
} UI_MESSENGER_Handle;
void