From 01a547ef18a52064cc85d1050c60f37bb50bd028 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Sun, 8 Oct 2023 17:45:16 +0200 Subject: Allow blocking entire domain from conversation details - the block domain option is in a drop down of the block button - when blocking the domain, the "Blocked domain" button appears and block button disappears and vice versa. --- main/src/windows/conversation_details.vala | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'main/src/windows/conversation_details.vala') diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala index 1dac02c7..02463cbc 100644 --- a/main/src/windows/conversation_details.vala +++ b/main/src/windows/conversation_details.vala @@ -11,8 +11,10 @@ namespace Dino.Ui.ConversationDetails { [GtkChild] public unowned Box about_box; [GtkChild] public unowned Button pin_button; [GtkChild] public unowned Adw.ButtonContent pin_button_content; - [GtkChild] public unowned Button block_button; + [GtkChild] public unowned Adw.SplitButton block_button; [GtkChild] public unowned Adw.ButtonContent block_button_content; + [GtkChild] public unowned Button block_domain_button; + [GtkChild] public unowned Adw.ButtonContent block_domain_button_content; [GtkChild] public unowned Button notification_button_toggle; [GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content; [GtkChild] public unowned MenuButton notification_button_menu; @@ -27,16 +29,19 @@ namespace Dino.Ui.ConversationDetails { install_action("notification.off", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.OFF); } ); install_action("notification.highlight", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT); } ); install_action("notification.default", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.DEFAULT); } ); + install_action("domain.on", null, (widget, action_name) => { ((Dialog) widget).model.domain_block_changed(); } ); } construct { pin_button.clicked.connect(() => { model.pin_changed(); }); block_button.clicked.connect(() => { model.block_changed(); }); + block_domain_button.clicked.connect(() => { model.domain_block_changed(); }); notification_button_toggle.clicked.connect(() => { model.notification_flipped(); }); notification_button_split.clicked.connect(() => { model.notification_flipped(); }); model.notify["pinned"].connect(update_pinned_button); model.notify["blocked"].connect(update_blocked_button); + model.notify["domain-blocked"].connect(update_blocked_button); model.notify["notification"].connect(update_notification_button); model.notify["notification"].connect(update_notification_button_state); model.notify["notification-options"].connect(update_notification_button_visibility); @@ -66,11 +71,23 @@ namespace Dino.Ui.ConversationDetails { private void update_blocked_button() { block_button_content.icon_name = "dino-block-symbolic"; block_button_content.label = model.blocked ? _("Blocked") : _("Block"); + block_domain_button_content.label = model.domain_blocked ? _("Domain blocked") : _("Block domain"); + block_domain_button.visible = false; if (model.blocked) { + block_button.visible = true; + block_domain_button.visible = false; block_button.add_css_class("error"); } else { block_button.remove_css_class("error"); } + + if (model.domain_blocked) { + block_domain_button.visible = true; + block_button.visible = false; + block_domain_button.add_css_class("error"); + } else { + block_button.visible = true; + } } private void update_notification_button() { @@ -229,4 +246,4 @@ namespace Dino.Ui.ConversationDetails { return preference_group; } } -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf