From 8944029128e3d0f9e32b61e00e880d92fceabb31 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 5 Sep 2017 23:53:18 +0200 Subject: Move encryption menu into ChatInput, PGP support for MUCs --- .../ui/conversation_titlebar/encryption_entry.vala | 86 ---------------------- main/src/ui/conversation_titlebar/view.vala | 2 +- 2 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 main/src/ui/conversation_titlebar/encryption_entry.vala (limited to 'main/src/ui/conversation_titlebar') diff --git a/main/src/ui/conversation_titlebar/encryption_entry.vala b/main/src/ui/conversation_titlebar/encryption_entry.vala deleted file mode 100644 index 16cc5fdd..00000000 --- a/main/src/ui/conversation_titlebar/encryption_entry.vala +++ /dev/null @@ -1,86 +0,0 @@ -using Gtk; -using Gee; - -using Dino.Entities; - -namespace Dino.Ui { - -class EncryptionEntry : Plugins.ConversationTitlebarEntry, Object { - public string id { get { return "encryption"; } } - - public double order { get { return 2; } } - public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) { - if (type == Plugins.WidgetType.GTK) { - return new EncryptionWidget() { visible=true }; - } - return null; - } -} - -class EncryptionWidget : MenuButton, Plugins.ConversationTitlebarWidget { - - private Conversation? conversation; - private RadioButton? button_unencrypted; - private Map encryption_radios = new HashMap(); - - public EncryptionWidget() { - Builder builder = new Builder.from_resource("/im/dino/menu_encryption.ui"); - PopoverMenu menu = builder.get_object("menu_encryption") as PopoverMenu; - Box encryption_box = builder.get_object("encryption_box") as Box; - button_unencrypted = builder.get_object("button_unencrypted") as RadioButton; - button_unencrypted.toggled.connect(encryption_changed); - Application app = GLib.Application.get_default() as Application; - foreach(var e in app.plugin_registry.encryption_list_entries) { - RadioButton btn = new RadioButton.with_label(button_unencrypted.get_group(), e.name); - encryption_radios[btn] = e; - btn.toggled.connect(encryption_changed); - btn.visible = true; - encryption_box.pack_end(btn, false); - } - clicked.connect(update_encryption_menu_state); - set_use_popover(true); - set_popover(menu); - set_image(new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON)); - } - - private void encryption_changed() { - foreach (RadioButton e in encryption_radios.keys) { - if (e.get_active()) { - conversation.encryption = encryption_radios[e].encryption; - update_encryption_menu_icon(); - return; - } - } - conversation.encryption = Encryption.NONE; - update_encryption_menu_icon(); - } - - private void update_encryption_menu_state() { - foreach (RadioButton e in encryption_radios.keys) { - e.set_sensitive(encryption_radios[e].can_encrypt(conversation)); - if (conversation.encryption == encryption_radios[e].encryption) e.set_active(true); - } - if (conversation.encryption == Encryption.NONE) { - button_unencrypted.set_active(true); - } - } - - private void update_encryption_menu_icon() { - visible = (conversation.type_ == Conversation.Type.CHAT); - if (conversation.type_ == Conversation.Type.CHAT) { - if (conversation.encryption == Encryption.NONE) { - set_image(new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON)); - } else { - set_image(new Image.from_icon_name("changes-prevent-symbolic", IconSize.BUTTON)); - } - } - } - - public new void set_conversation(Conversation conversation) { - this.conversation = conversation; - update_encryption_menu_state(); - update_encryption_menu_icon(); - } -} - -} diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index 9949f4fc..32d829fb 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -22,7 +22,6 @@ public class ConversationTitlebar : Gtk.HeaderBar { Application app = GLib.Application.get_default() as Application; app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor)); - app.plugin_registry.register_contact_titlebar_entry(new EncryptionEntry()); app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor, window)); foreach(var e in app.plugin_registry.conversation_titlebar_entries) { @@ -33,6 +32,7 @@ public class ConversationTitlebar : Gtk.HeaderBar { } } + stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => { Idle.add(() => { if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { -- cgit v1.2.3-54-g00ecf