blob: bf59a083c9f446458c55b42de6940fe30949b2d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
}
}
}
}
|