aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-31 15:19:30 +0100
committerfiaxh <fiaxh@users.noreply.github.com>2017-10-31 15:40:42 +0100
commit7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (patch)
treeeda4f733870ded0eb6ccd8b4b8967d88c6960683 /main/src
parenta8d06e634bf0b5b18c7bffaf05c7293bcd29b056 (diff)
downloaddino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.tar.gz
dino-7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac.zip
Blocking setting in Contact Details
Diffstat (limited to 'main/src')
-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) {