diff --git a/src/chatty-window.c b/src/chatty-window.c index d0d1ab212b15feeea472b8fc4adbf909bdf32439..2ce82c78f14a4db54451180a4cf16ebf1582e2d6 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; @@ -137,6 +136,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 +161,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 +189,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)); @@ -330,7 +348,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 +417,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 +455,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)); @@ -530,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 @@ -689,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); } @@ -774,6 +788,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), @@ -786,6 +802,9 @@ chatty_window_init (ChattyWindow *self) chatty_side_bar_set_show_end_title_buttons (CHATTY_SIDE_BAR (self->side_bar), folded); chatty_main_view_set_item (CHATTY_MAIN_VIEW (self->main_view), NULL); + gtk_application_set_accels_for_action (GTK_APPLICATION (g_application_get_default ()), + "win.show-chat-details", + (const char *[]){"d", NULL, }); gtk_application_set_accels_for_action (GTK_APPLICATION (g_application_get_default ()), "win.search-chat", (const char *[]){"f", NULL, }); diff --git a/src/dialogs/chatty-info-dialog.c b/src/dialogs/chatty-info-dialog.c index 86fbdf3a9ff4b2f5eabb5e91360be26184397d5c..bc15e826a77fc251e07cc0930980ba48202785ad 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 bc5ff71cb7afb307fbc9dfc96651f5174cecb672..ba367c081afd36d90f7ae168575ca98f5dc5f264 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/dialogs/chatty-ma-chat-info.c b/src/dialogs/chatty-ma-chat-info.c index 8200a0e7f7851bbb3135b1b1da0f14c1c34885a6..7a04ba69f332419ac3bfeed6eb67f63c3314991f 100644 --- a/src/dialogs/chatty-ma-chat-info.c +++ b/src/dialogs/chatty-ma-chat-info.c @@ -46,6 +46,7 @@ struct _ChattyMaChatInfo GtkWidget *name_label; GtkWidget *matrix_id_label; + GtkWidget *topic_label; GtkWidget *encryption_spinner; GtkWidget *encryption_switch; }; @@ -124,6 +125,8 @@ chatty_ma_chat_info_set_item (ChattyChatInfo *info, chatty_chat_get_chat_name (self->chat)); gtk_label_set_text (GTK_LABEL (self->name_label), chatty_item_get_name (CHATTY_ITEM (self->chat))); + gtk_label_set_text (GTK_LABEL (self->topic_label), + chatty_ma_chat_get_topic (CHATTY_MA_CHAT (self->chat))); g_signal_connect_swapped (self->chat, "notify::encrypt", G_CALLBACK (ma_chat_encrypt_changed_cb), @@ -162,6 +165,7 @@ chatty_ma_chat_info_class_init (ChattyMaChatInfoClass *klass) gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, name_label); gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, matrix_id_label); + gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, topic_label); gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, encryption_spinner); gtk_widget_class_bind_template_child (widget_class, ChattyMaChatInfo, encryption_switch); diff --git a/src/matrix/chatty-ma-chat.c b/src/matrix/chatty-ma-chat.c index 6d528d271c3bd9eb32993d0acf3c4bacee8b0609..be837e5f8ffb05eb30951b0ce3f8dd0b575cf4bd 100644 --- a/src/matrix/chatty-ma-chat.c +++ b/src/matrix/chatty-ma-chat.c @@ -933,3 +933,11 @@ chatty_ma_chat_matches_id (ChattyMaChat *self, return g_strcmp0 (self->room_id, room_id) == 0; } + +const char * +chatty_ma_chat_get_topic (ChattyMaChat *self) +{ + g_return_val_if_fail (CHATTY_IS_MA_CHAT (self), NULL); + + return cm_room_get_topic (self->cm_room); +} diff --git a/src/matrix/chatty-ma-chat.h b/src/matrix/chatty-ma-chat.h index 9c2a82eabf0c363c19d9d639e707f8aa302f1737..c655dbae378e2f1511035dcb8ce8b0ccc5f36d22 100644 --- a/src/matrix/chatty-ma-chat.h +++ b/src/matrix/chatty-ma-chat.h @@ -25,6 +25,7 @@ G_DECLARE_FINAL_TYPE (ChattyMaChat, chatty_ma_chat, CHATTY, MA_CHAT, ChattyChat) ChattyMaChat *chatty_ma_chat_new_with_room (CmRoom *room); CmRoom *chatty_ma_chat_get_cm_room (ChattyMaChat *self); gboolean chatty_ma_chat_can_set_encryption (ChattyMaChat *self); +const char *chatty_ma_chat_get_topic (ChattyMaChat *self); void chatty_ma_chat_set_data (ChattyMaChat *self, ChattyAccount *account, gpointer client); diff --git a/src/ui/chatty-info-dialog.ui b/src/ui/chatty-info-dialog.ui index 1db509489c7a0435aa570e9720a3f27175f690d8..f4a5132d395f5bc64133a05c92082da583243a56 100644 --- a/src/ui/chatty-info-dialog.ui +++ b/src/ui/chatty-info-dialog.ui @@ -1,10 +1,7 @@ -