From 21ae42762d8a57da5cb1ec40b46e7510fc3121ad Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 20 Jun 2024 12:05:20 +0200 Subject: Redesign and rewrite accounts and settings dialog into a combined one --- main/src/view_model/account_details.vala | 21 ++++++ main/src/view_model/preferences_window.vala | 109 ++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 main/src/view_model/account_details.vala create mode 100644 main/src/view_model/preferences_window.vala (limited to 'main/src/view_model') diff --git a/main/src/view_model/account_details.vala b/main/src/view_model/account_details.vala new file mode 100644 index 00000000..a9ddeca5 --- /dev/null +++ b/main/src/view_model/account_details.vala @@ -0,0 +1,21 @@ +using Dino; +using Dino.Entities; +using Xmpp; +using Xmpp.Xep; + +public class Dino.Ui.ViewModel.AccountDetails : Object { + public Entities.Account account { get; set; } + public string bare_jid { owned get { return account.bare_jid.to_string(); } } + public CompatAvatarPictureModel avatar_model { get; set; } + public ConnectionManager.ConnectionState connection_state { get; set; } + public ConnectionManager.ConnectionError? connection_error { get; set; } + + public AccountDetails(Account account, StreamInteractor stream_interactor) { + var account_conv = new Conversation(account.bare_jid, account, Conversation.Type.CHAT); + + this.account = account; + this.avatar_model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(account_conv); + this.connection_state = stream_interactor.connection_manager.get_state(account); + this.connection_error = stream_interactor.connection_manager.get_error(account); + } +} \ No newline at end of file diff --git a/main/src/view_model/preferences_window.vala b/main/src/view_model/preferences_window.vala new file mode 100644 index 00000000..9cc5a80e --- /dev/null +++ b/main/src/view_model/preferences_window.vala @@ -0,0 +1,109 @@ +using Dino.Entities; +using Xmpp; +using Xmpp.Xep; +using Gee; + +public class Dino.Ui.ViewModel.PreferencesWindow : Object { + public signal void update(); + + public HashMap account_details = new HashMap(Account.hash_func, Account.equals_func); + public AccountDetails selected_account { get; set; } + public Gtk.SingleSelection active_accounts_selection { get; default=new Gtk.SingleSelection(new GLib.ListStore(typeof(ViewModel.AccountDetails))); } + + public StreamInteractor stream_interactor; + public Database db; + + public GeneralPreferencesPage general_page { get; set; default=new GeneralPreferencesPage(); } + + public void populate(Database db, StreamInteractor stream_interactor) { + this.db = db; + this.stream_interactor = stream_interactor; + + stream_interactor.connection_manager.connection_error.connect((account, error) => { + var account_detail = account_details[account]; + if (account_details != null) { + account_detail.connection_error = error; + } + }); + stream_interactor.connection_manager.connection_state_changed.connect((account, state) => { + var account_detail = account_details[account]; + if (account_details != null) { + account_detail.connection_state = state; + account_detail.connection_error = stream_interactor.connection_manager.get_error(account); + } + }); + stream_interactor.account_added.connect(update_data); + stream_interactor.account_removed.connect(update_data); + + bind_general_page(); + update_data(); + } + + private void update_data() { + // account_details should hold the correct set of accounts (add or remove some if needed), but do not override remaining ones (would destroy bindings) + var current_accounts = db.get_accounts(); + var remove_accounts = new ArrayList(); + foreach (var account in account_details.keys) { + if (!current_accounts.contains(account)) remove_accounts.add(account); + } + foreach (var account in remove_accounts) { + account_details.unset(account); + } + foreach (var account in current_accounts) { + if (!account_details.has_key(account)) { + account_details[account] = new AccountDetails(account, stream_interactor); + } + if (selected_account == null && account.enabled) selected_account = account_details[account]; + } + + // Update account picker model with currently active accounts + var list_model = (GLib.ListStore) active_accounts_selection.model; + list_model.remove_all(); + foreach (var account in stream_interactor.get_accounts()) { + list_model.append(new ViewModel.AccountDetails(account, stream_interactor)); + } + + update(); + } + + public void set_avatar_uri(Account account, string uri) { + stream_interactor.get_module(AvatarManager.IDENTITY).publish(account, uri); + } + + public void remove_avatar(Account account) { + stream_interactor.get_module(AvatarManager.IDENTITY).unset_avatar(account); + } + + public void remove_account(Account account) { + stream_interactor.disconnect_account.begin(account, () => { + account.remove(); + update_data(); + }); + } + + public void reconnect_account(Account account) { + stream_interactor.disconnect_account.begin(account, () => { + stream_interactor.connect_account(account); + }); + } + + public void enable_disable_account(Account account) { + if (account.enabled) { + account.enabled = false; + stream_interactor.disconnect_account.begin(account); + } else { + account.enabled = true; + stream_interactor.connect_account(account); + } + update_data(); + } + + private void bind_general_page() { + var settings = Dino.Application.get_default().settings; + settings.bind_property("send-typing", general_page, "send-typing", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + settings.bind_property("send-marker", general_page, "send-marker", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + settings.bind_property("notifications", general_page, "notifications", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + settings.bind_property("convert-utf8-smileys", general_page, "convert-emojis", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + } +} + -- cgit v1.2.3-70-g09d2 From 8e7dedcaa62a49373c22dfc54bf1bb8b261bcb61 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/data/conversation_details.ui | 23 +++++++++++++-- main/src/ui/conversation_details.vala | 40 ++++++++++++++++++++++----- main/src/view_model/conversation_details.vala | 13 +++++++-- main/src/windows/conversation_details.vala | 19 +++++++++---- 4 files changed, 78 insertions(+), 17 deletions(-) (limited to 'main/src/view_model') diff --git a/main/data/conversation_details.ui b/main/data/conversation_details.ui index 4229d875..c34124a3 100644 --- a/main/data/conversation_details.ui +++ b/main/data/conversation_details.ui @@ -122,11 +122,12 @@ - + + block_menu_model - action-unavailable-symbolic + dino-block-symbolic Block @@ -203,4 +204,20 @@ - \ No newline at end of file + +
+ + Block user + do.block + + + Block entire domain + do.block_domain + + + Unblock + do.unblock + +
+
+ diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala index 1c82f105..90aa9244 100644 --- a/main/src/ui/conversation_details.vala +++ b/main/src/ui/conversation_details.vala @@ -10,6 +10,7 @@ namespace Dino.Ui.ConversationDetails { model.conversation = conversation; model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation); model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart); + model.domain_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart.domain_jid); if (conversation.type_ == Conversation.Type.GROUPCHAT) { stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => { @@ -58,6 +59,7 @@ namespace Dino.Ui.ConversationDetails { return true; }); model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE); + model.bind_property("domain_blocked", view_model, "domain_blocked", BindingFlags.SYNC_CREATE); model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => { var data_form = (DataForms.DataForm) from; if (data_form == null) return true; @@ -77,13 +79,37 @@ namespace Dino.Ui.ConversationDetails { view_model.pin_changed.connect(() => { model.conversation.pinned = model.conversation.pinned == 1 ? 0 : 1; }); - view_model.block_changed.connect(() => { - if (view_model.blocked) { - stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart); - } else { - stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart); + view_model.block_changed.connect((action) => { + switch (action) { + case USER: + stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart); + view_model.blocked = true; + break; + case DOMAIN: + stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart.domain_jid); + view_model.blocked = true; + view_model.domain_blocked = true; + break; + case UNBLOCK: + stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart); + stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid); + view_model.blocked = false; + view_model.domain_blocked = false; + break; + case TOGGLE: + if (view_model.blocked) { + view_model.block_changed(UNBLOCK); + } + else { + view_model.block_changed(USER); + } + if (view_model.domain_blocked) { + view_model.block_changed(UNBLOCK); + } + break; + default: + break; } - view_model.blocked = !view_model.blocked; }); view_model.notification_changed.connect((setting) => { switch (setting) { @@ -189,4 +215,4 @@ namespace Dino.Ui.ConversationDetails { break; } } -} \ No newline at end of file +} diff --git a/main/src/view_model/conversation_details.vala b/main/src/view_model/conversation_details.vala index 15bf7535..9a34be78 100644 --- a/main/src/view_model/conversation_details.vala +++ b/main/src/view_model/conversation_details.vala @@ -6,10 +6,17 @@ using Gtk; public class Dino.Ui.ViewModel.ConversationDetails : Object { public signal void pin_changed(); - public signal void block_changed(); + public signal void block_changed(BlockActions action); public signal void notification_flipped(); public signal void notification_changed(NotificationSetting setting); + public enum BlockActions { + USER, + DOMAIN, + UNBLOCK, + TOGGLE + } + public enum NotificationOptions { ON_OFF, ON_HIGHLIGHT_OFF @@ -32,6 +39,7 @@ public class Dino.Ui.ViewModel.ConversationDetails : Object { public bool show_blocked { get; set; } public bool blocked { get; set; } + public bool domain_blocked { get; set; } public GLib.ListStore preferences_rows = new GLib.ListStore(typeof(PreferencesRow.Any)); public GLib.ListStore about_rows = new GLib.ListStore(typeof(PreferencesRow.Any)); @@ -46,4 +54,5 @@ public class Dino.Ui.Model.ConversationDetails : Object { public DataForms.DataForm? data_form { get; set; } public string? data_form_bak; public bool blocked { get; set; } -} \ No newline at end of file + public bool domain_blocked { get; set; } +} diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala index 1dac02c7..b2b33fa3 100644 --- a/main/src/windows/conversation_details.vala +++ b/main/src/windows/conversation_details.vala @@ -11,7 +11,7 @@ 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 notification_button_toggle; [GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content; @@ -27,16 +27,20 @@ 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("do.block", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.USER); } ); + install_action("do.block_domain", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.DOMAIN); } ); + install_action("do.unblock", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.UNBLOCK); } ); } construct { pin_button.clicked.connect(() => { model.pin_changed(); }); - block_button.clicked.connect(() => { model.block_changed(); }); + block_button.clicked.connect(() => { model.block_changed(ViewModel.ConversationDetails.BlockActions.TOGGLE); }); 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); @@ -64,13 +68,18 @@ 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"); if (model.blocked) { + block_button_content.label = _("Blocked"); block_button.add_css_class("error"); } else { + block_button_content.label = _("Block"); block_button.remove_css_class("error"); } + + if (model.domain_blocked) { + block_button_content.label = _("Domain blocked"); + block_button.add_css_class("error"); + } } private void update_notification_button() { @@ -229,4 +238,4 @@ namespace Dino.Ui.ConversationDetails { return preference_group; } } -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2 From 88376cd6f75d5057caa6582d0a82fc76bb7b388f Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 18 Aug 2024 22:02:33 +0200 Subject: Conversation details: Make block button a stateful menu button --- main/data/conversation_details.ui | 19 +-------- main/src/ui/conversation_details.vala | 30 +++++---------- main/src/view_model/conversation_details.vala | 10 ++--- main/src/windows/conversation_details.vala | 55 +++++++++++++++++++-------- 4 files changed, 54 insertions(+), 60 deletions(-) (limited to 'main/src/view_model') diff --git a/main/data/conversation_details.ui b/main/data/conversation_details.ui index c34124a3..5ee156bb 100644 --- a/main/data/conversation_details.ui +++ b/main/data/conversation_details.ui @@ -122,8 +122,7 @@
- - block_menu_model + @@ -204,20 +203,4 @@ - -
- - Block user - do.block - - - Block entire domain - do.block_domain - - - Unblock - do.unblock - -
-
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala index 90aa9244..4c6a0481 100644 --- a/main/src/ui/conversation_details.vala +++ b/main/src/ui/conversation_details.vala @@ -25,6 +25,14 @@ namespace Dino.Ui.ConversationDetails { view_model.avatar = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(model.conversation); view_model.show_blocked = model.conversation.type_ == Conversation.Type.CHAT && stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(model.conversation.account); + if (model.domain_blocked) { + view_model.blocked = DOMAIN; + } else if (model.blocked) { + view_model.blocked = USER; + } else { + view_model.blocked = UNBLOCK; + } + model.display_name.bind_property("display-name", view_model, "name", BindingFlags.SYNC_CREATE); model.conversation.bind_property("notify-setting", view_model, "notification", BindingFlags.SYNC_CREATE, (_, from, ref to) => { switch (model.conversation.get_notification_setting(stream_interactor)) { @@ -58,8 +66,6 @@ namespace Dino.Ui.ConversationDetails { to = ty == Conversation.Type.GROUPCHAT ? ViewModel.ConversationDetails.NotificationOptions.ON_HIGHLIGHT_OFF : ViewModel.ConversationDetails.NotificationOptions.ON_OFF; return true; }); - model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE); - model.bind_property("domain_blocked", view_model, "domain_blocked", BindingFlags.SYNC_CREATE); model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => { var data_form = (DataForms.DataForm) from; if (data_form == null) return true; @@ -83,33 +89,17 @@ namespace Dino.Ui.ConversationDetails { switch (action) { case USER: stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart); - view_model.blocked = true; + stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid); break; case DOMAIN: stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart.domain_jid); - view_model.blocked = true; - view_model.domain_blocked = true; break; case UNBLOCK: stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart); stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid); - view_model.blocked = false; - view_model.domain_blocked = false; - break; - case TOGGLE: - if (view_model.blocked) { - view_model.block_changed(UNBLOCK); - } - else { - view_model.block_changed(USER); - } - if (view_model.domain_blocked) { - view_model.block_changed(UNBLOCK); - } - break; - default: break; } + view_model.blocked = action; }); view_model.notification_changed.connect((setting) => { switch (setting) { diff --git a/main/src/view_model/conversation_details.vala b/main/src/view_model/conversation_details.vala index 9a34be78..75fc9669 100644 --- a/main/src/view_model/conversation_details.vala +++ b/main/src/view_model/conversation_details.vala @@ -6,15 +6,14 @@ using Gtk; public class Dino.Ui.ViewModel.ConversationDetails : Object { public signal void pin_changed(); - public signal void block_changed(BlockActions action); + public signal void block_changed(BlockState action); public signal void notification_flipped(); public signal void notification_changed(NotificationSetting setting); - public enum BlockActions { + public enum BlockState { USER, DOMAIN, - UNBLOCK, - TOGGLE + UNBLOCK } public enum NotificationOptions { @@ -38,8 +37,7 @@ public class Dino.Ui.ViewModel.ConversationDetails : Object { public bool notification_is_default { get; set; } public bool show_blocked { get; set; } - public bool blocked { get; set; } - public bool domain_blocked { get; set; } + public BlockState blocked { get; set; } public GLib.ListStore preferences_rows = new GLib.ListStore(typeof(PreferencesRow.Any)); public GLib.ListStore about_rows = new GLib.ListStore(typeof(PreferencesRow.Any)); diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala index b2b33fa3..7ffa01f1 100644 --- a/main/src/windows/conversation_details.vala +++ b/main/src/windows/conversation_details.vala @@ -11,7 +11,7 @@ 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 Adw.SplitButton block_button; + [GtkChild] public unowned MenuButton block_button; [GtkChild] public unowned Adw.ButtonContent block_button_content; [GtkChild] public unowned Button notification_button_toggle; [GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content; @@ -22,25 +22,22 @@ namespace Dino.Ui.ConversationDetails { [GtkChild] public unowned ViewModel.ConversationDetails model { get; } + private SimpleAction block_action = new SimpleAction.stateful("block", VariantType.INT32, new Variant.int32(ViewModel.ConversationDetails.BlockState.UNBLOCK)); + class construct { install_action("notification.on", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.ON); } ); 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("do.block", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.USER); } ); - install_action("do.block_domain", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.DOMAIN); } ); - install_action("do.unblock", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.UNBLOCK); } ); } construct { pin_button.clicked.connect(() => { model.pin_changed(); }); - block_button.clicked.connect(() => { model.block_changed(ViewModel.ConversationDetails.BlockActions.TOGGLE); }); 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); @@ -51,10 +48,32 @@ namespace Dino.Ui.ConversationDetails { model.settings_rows.items_changed.connect(create_preferences_rows); model.notify["room-configuration-rows"].connect(create_preferences_rows); + // Create block action + SimpleActionGroup block_action_group = new SimpleActionGroup(); + block_action = new SimpleAction.stateful("block", VariantType.INT32, new Variant.int32(0)); + block_action.activate.connect((parameter) => { + block_action.set_state(parameter); + model.block_changed((ViewModel.ConversationDetails.BlockState) parameter.get_int32()); + }); + block_action_group.insert(block_action); + this.insert_action_group("block", block_action_group); + + // Create block menu model + Menu block_menu_model = new Menu(); + string[] menu_labels = new string[] { _("Block user"), _("Block entire domain"), _("Unblock") }; + ViewModel.ConversationDetails.BlockState[] menu_states = new ViewModel.ConversationDetails.BlockState[] { ViewModel.ConversationDetails.BlockState.USER, ViewModel.ConversationDetails.BlockState.DOMAIN, ViewModel.ConversationDetails.BlockState.UNBLOCK }; + for (int i = 0; i < menu_labels.length; i++) { + MenuItem item = new MenuItem(menu_labels[i], null); + item.set_action_and_target_value("block.block", new Variant.int32(menu_states[i])); + block_menu_model.append_item(item); + } + block_button.menu_model = block_menu_model; + #if Adw_1_4 // TODO: replace with putting buttons in new line on small screens notification_button_menu_content.can_shrink = true; #endif + update_blocked_button(); } private void update_pinned_button() { @@ -68,18 +87,22 @@ namespace Dino.Ui.ConversationDetails { } private void update_blocked_button() { - if (model.blocked) { - block_button_content.label = _("Blocked"); - block_button.add_css_class("error"); - } else { - block_button_content.label = _("Block"); - block_button.remove_css_class("error"); + switch (model.blocked) { + case USER: + block_button_content.label = _("Blocked"); + block_button.add_css_class("error"); + break; + case DOMAIN: + block_button_content.label = _("Domain blocked"); + block_button.add_css_class("error"); + break; + case UNBLOCK: + block_button_content.label = _("Block"); + block_button.remove_css_class("error"); + break; } - if (model.domain_blocked) { - block_button_content.label = _("Domain blocked"); - block_button.add_css_class("error"); - } + block_action.set_state(new Variant.int32(model.blocked)); } private void update_notification_button() { -- cgit v1.2.3-70-g09d2