From 220c58c5647047380b4dc4270a2b163fc456e44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 18 Jul 2024 22:57:41 +0200 Subject: [PATCH 1/6] libcmatrix: Update to 69ab951 ("room: Allow to fetch topic") Part-of: --- subprojects/libcmatrix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libcmatrix b/subprojects/libcmatrix index ead86eec..69ab951f 160000 --- a/subprojects/libcmatrix +++ b/subprojects/libcmatrix @@ -1 +1 @@ -Subproject commit ead86eec0ea77af5be3667c19d415cfb29d8651d +Subproject commit 69ab951fead4f3283a1ae20db4d608e4e8c5e0ca -- GitLab From 7b937e5a8173683d686614e1ea783e950ddf9c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 20 Jul 2024 16:09:36 +0200 Subject: [PATCH 2/6] window: Remove unused variables Part-of: --- src/chatty-window.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/chatty-window.c b/src/chatty-window.c index d0d1ab21..87fd6b13 100644 --- a/src/chatty-window.c +++ b/src/chatty-window.c @@ -330,7 +330,6 @@ window_block_chat_response_cb (AdwMessageDialog *dialog, { ChattyWindow *self = CHATTY_WINDOW (user_data); - g_autoptr(GError) error = NULL; g_assert (CHATTY_IS_WINDOW (self)); if (g_strcmp0 (response, "block") == 0) { @@ -400,7 +399,6 @@ window_delete_chat_response_cb (AdwMessageDialog *dialog, gpointer user_data) { ChattyWindow *self = CHATTY_WINDOW (user_data); - g_autoptr(GError) error = NULL; g_assert (CHATTY_IS_WINDOW (self)); @@ -439,7 +437,6 @@ chatty_window_delete_chat (GtkWidget *widget, const char *name; GtkWindow *window; AdwDialog *dialog; - g_autofree char *secondary_text = NULL; g_assert (CHATTY_IS_WINDOW (self)); -- GitLab From 9d6334b07582517db3a0d66da4fd7d4f84f43be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 20 Jul 2024 16:13:17 +0200 Subject: [PATCH 3/6] window: Disable per chat actions when no chat is set This is helpful when we bind keyboard shortcuts. Part-of: --- src/chatty-window.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/chatty-window.c b/src/chatty-window.c index 87fd6b13..c12a4bf4 100644 --- a/src/chatty-window.c +++ b/src/chatty-window.c @@ -137,6 +137,21 @@ chatty_window_open_item (ChattyWindow *self, } } + +static void +chatty_window_enable_per_chat_actions (ChattyWindow *self, gboolean enable) +{ + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.show-chat-details", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.leave-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.block-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.unblock-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.archive-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.unarchive-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.delete-chat", enable); + gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.call-user", enable); +} + + static void window_chat_list_selection_changed (ChattyWindow *self, ChattyChatList *list) @@ -147,6 +162,8 @@ window_chat_list_selection_changed (ChattyWindow *self, g_assert (CHATTY_IS_WINDOW (self)); g_assert (CHATTY_IS_CHAT_LIST (list)); + chatty_window_enable_per_chat_actions (self, FALSE); + chat_list = chatty_chat_list_get_selected (list); if (!chat_list->len) { @@ -173,6 +190,8 @@ window_chat_list_selection_changed (ChattyWindow *self, return; } + chatty_window_enable_per_chat_actions (self, TRUE); + #ifdef PURPLE_ENABLED if (CHATTY_IS_PP_CHAT (chat)) chatty_window_open_item (self, CHATTY_ITEM (chat)); @@ -771,6 +790,8 @@ chatty_window_init (ChattyWindow *self) gboolean folded; gtk_widget_init_template (GTK_WIDGET (self)); + chatty_window_enable_per_chat_actions (self, FALSE); + self->chat_list = chatty_side_bar_get_chat_list (CHATTY_SIDE_BAR (self->side_bar)); self->manager = g_object_ref (chatty_manager_get_default ()); chatty_main_view_set_db (CHATTY_MAIN_VIEW (self->main_view), -- GitLab From 9ebc249ab765bd9ef60d88ba834cdf53b1383fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 20 Jul 2024 15:43:57 +0200 Subject: [PATCH 4/6] info-dialog: Use AdwDialog This ensures we get bottom sheets on mobile / small sizes. We also get proper close buttons without GTK4 patches. We opt to recreate the dialog as this free us from updating chat details too. With this dialogs also close with `ESC` as expected. Part-of: --- src/chatty-window.c | 6 ++---- src/dialogs/chatty-info-dialog.c | 14 +++++--------- src/dialogs/chatty-info-dialog.h | 8 ++++---- src/ui/chatty-info-dialog.ui | 7 ++----- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/chatty-window.c b/src/chatty-window.c index c12a4bf4..8f6cdd95 100644 --- a/src/chatty-window.c +++ b/src/chatty-window.c @@ -47,7 +47,6 @@ struct _ChattyWindow GtkWidget *main_view; GtkWidget *new_chat_dialog; - GtkWidget *chat_info_dialog; GtkWidget *settings_dialog; @@ -546,10 +545,10 @@ chatty_window_show_chat_details (GtkWidget *widget, chat = (ChattyChat *)chatty_main_view_get_item (CHATTY_MAIN_VIEW (self->main_view)); g_return_if_fail (CHATTY_IS_CHAT (chat)); - dialog = CHATTY_INFO_DIALOG (self->chat_info_dialog); + dialog = chatty_info_dialog_new (); chatty_info_dialog_set_chat (dialog, chat); - gtk_window_present (GTK_WINDOW (dialog)); + adw_dialog_present (ADW_DIALOG (dialog), GTK_WIDGET (self)); } static void @@ -705,7 +704,6 @@ chatty_window_constructed (GObject *object) G_CALLBACK (new_chat_selection_changed_cb), self, G_CONNECT_SWAPPED); - self->chat_info_dialog = chatty_info_dialog_new (GTK_WINDOW (self)); G_OBJECT_CLASS (chatty_window_parent_class)->constructed (object); } diff --git a/src/dialogs/chatty-info-dialog.c b/src/dialogs/chatty-info-dialog.c index 86fbdf3a..bc15e826 100644 --- a/src/dialogs/chatty-info-dialog.c +++ b/src/dialogs/chatty-info-dialog.c @@ -27,7 +27,7 @@ struct _ChattyInfoDialog { - AdwWindow parent_instance; + AdwDialog parent_instance; GtkWidget *main_stack; GtkWidget *chat_type_stack; @@ -48,7 +48,7 @@ struct _ChattyInfoDialog ChattyChat *chat; }; -G_DEFINE_TYPE (ChattyInfoDialog, chatty_info_dialog, ADW_TYPE_WINDOW) +G_DEFINE_TYPE (ChattyInfoDialog, chatty_info_dialog, ADW_TYPE_DIALOG) static void info_dialog_new_invite_clicked_cb (ChattyInfoDialog *self) @@ -201,14 +201,10 @@ chatty_info_dialog_init (ChattyInfoDialog *self) #endif } -GtkWidget * -chatty_info_dialog_new (GtkWindow *parent_window) +ChattyInfoDialog * +chatty_info_dialog_new (void) { - g_return_val_if_fail (GTK_IS_WINDOW (parent_window), NULL); - - return g_object_new (CHATTY_TYPE_INFO_DIALOG, - "transient-for", parent_window, - NULL); + return g_object_new (CHATTY_TYPE_INFO_DIALOG, NULL); } void diff --git a/src/dialogs/chatty-info-dialog.h b/src/dialogs/chatty-info-dialog.h index bc5ff71c..ba367c08 100644 --- a/src/dialogs/chatty-info-dialog.h +++ b/src/dialogs/chatty-info-dialog.h @@ -18,10 +18,10 @@ G_BEGIN_DECLS #define CHATTY_TYPE_INFO_DIALOG (chatty_info_dialog_get_type ()) -G_DECLARE_FINAL_TYPE (ChattyInfoDialog, chatty_info_dialog, CHATTY, INFO_DIALOG, AdwWindow) +G_DECLARE_FINAL_TYPE (ChattyInfoDialog, chatty_info_dialog, CHATTY, INFO_DIALOG, AdwDialog) -GtkWidget *chatty_info_dialog_new (GtkWindow *parent_window); -void chatty_info_dialog_set_chat (ChattyInfoDialog *self, - ChattyChat *chat); +ChattyInfoDialog *chatty_info_dialog_new (void); +void chatty_info_dialog_set_chat (ChattyInfoDialog *self, + ChattyChat *chat); G_END_DECLS diff --git a/src/ui/chatty-info-dialog.ui b/src/ui/chatty-info-dialog.ui index 1db50948..f4a5132d 100644 --- a/src/ui/chatty-info-dialog.ui +++ b/src/ui/chatty-info-dialog.ui @@ -1,10 +1,7 @@ -