aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/contact_details/blocking_provider.vala36
-rw-r--r--main/src/ui/contact_details/dialog.vala1
2 files changed, 37 insertions, 0 deletions
diff --git a/main/src/ui/contact_details/blocking_provider.vala b/main/src/ui/contact_details/blocking_provider.vala
new file mode 100644
index 00000000..bf59a083
--- /dev/null
+++ b/main/src/ui/contact_details/blocking_provider.vala
@@ -0,0 +1,36 @@
+using Gtk;
+
+using Dino.Entities;
+
+namespace Dino.Ui.ContactDetails {
+
+public class BlockingProvider : Plugins.ContactDetailsProvider, Object {
+ public string id { get { return "blocking"; } }
+
+ private StreamInteractor stream_interactor;
+
+ public BlockingProvider(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+ }
+
+ public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
+ if (type != Plugins.WidgetType.GTK) return;
+ if (conversation.type_ != Conversation.Type.CHAT) return;
+
+ if (stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(conversation.account)) {
+ bool is_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(conversation.account, conversation.counterpart);
+ Switch sw = new Switch() { active=is_blocked, valign=Align.CENTER, visible=true };
+ sw.state_set.connect((state) => {
+ if (state) {
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(conversation.account, conversation.counterpart);
+ } else {
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(conversation.account, conversation.counterpart);
+ }
+ return false;
+ });
+ contact_details.add(_("Settings"), _("Block"), _("Communication and status updates in either direction are blocked"), sw);
+ }
+ }
+}
+
+}
diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala
index 147811f9..70e495d1 100644
--- a/main/src/ui/contact_details/dialog.vala
+++ b/main/src/ui/contact_details/dialog.vala
@@ -42,6 +42,7 @@ public class Dialog : Gtk.Dialog {
Application app = GLib.Application.get_default() as Application;
app.plugin_registry.register_contact_details_entry(new SettingsProvider(stream_interactor));
+ app.plugin_registry.register_contact_details_entry(new BlockingProvider(stream_interactor));
app.plugin_registry.register_contact_details_entry(new MucConfigFormProvider(stream_interactor));
foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) {