aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/ui')
-rw-r--r--libdino/src/ui/application.vala113
-rw-r--r--libdino/src/ui/conversation_summary/merged_message_item.vala2
-rw-r--r--libdino/src/ui/conversation_titlebar.vala54
3 files changed, 32 insertions, 137 deletions
diff --git a/libdino/src/ui/application.vala b/libdino/src/ui/application.vala
deleted file mode 100644
index 0878e50d..00000000
--- a/libdino/src/ui/application.vala
+++ /dev/null
@@ -1,113 +0,0 @@
-using Gtk;
-
-using Dino.Entities;
-
-public class Dino.Ui.Application : Gtk.Application {
-
- private Database db;
- private StreamInteractor stream_interaction;
-
- private Notifications notifications;
- private UnifiedWindow? window;
- private ConversationSelector.View? filterable_conversation_list;
- private ConversationSelector.List? conversation_list;
- private ConversationSummary.View? conversation_frame;
- private ChatInput? chat_input;
-
- public Application() {
- this.db = new Database("store.sqlite3");
- this.stream_interaction = new StreamInteractor(db);
-
- AvatarManager.start(stream_interaction, db);
- MessageManager.start(stream_interaction, db);
- CounterpartInteractionManager.start(stream_interaction);
- PresenceManager.start(stream_interaction);
- MucManager.start(stream_interaction);
- PgpManager.start(stream_interaction, db);
- RosterManager.start(stream_interaction);
- ConversationManager.start(stream_interaction, db);
- ChatInteraction.start(stream_interaction);
-
- Notify.init("dino");
- notifications = new Notifications(stream_interaction);
- notifications.start();
-
- load_css();
- }
-
- public override void activate() {
- create_set_app_menu();
- create_window();
- window.show_all();
- restore();
- }
-
- private void create_window() {
- window = new UnifiedWindow(this, stream_interaction);
-
- filterable_conversation_list = window.filterable_conversation_list;
- conversation_list = window.filterable_conversation_list.conversation_list;
- conversation_frame = window.conversation_frame;
- chat_input = window.chat_input;
- }
-
- private void show_accounts_window() {
- ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
- dialog.set_transient_for(window);
- dialog.account_enabled.connect(add_connection);
- dialog.account_disabled.connect(remove_connection);
- dialog.show();
- }
-
- private void show_settings_window() {
- SettingsDialog dialog = new SettingsDialog();
- dialog.set_transient_for(window);
- dialog.show();
- }
-
- private void create_set_app_menu() {
- SimpleAction accounts_action = new SimpleAction("accounts", null);
- accounts_action.activate.connect(show_accounts_window);
- add_action(accounts_action);
-
- SimpleAction settings_action = new SimpleAction("settings", null);
- settings_action.activate.connect(show_settings_window);
- add_action(settings_action);
-
- SimpleAction quit_action = new SimpleAction("quit", null);
- quit_action.activate.connect(quit);
- add_action(quit_action);
- add_accelerator("<Ctrl>Q", "app.quit", null);
-
- Builder builder = new Builder.from_resource("/org/dino-im/menu_app.ui");
- MenuModel menu = builder.get_object("menu_app") as MenuModel;
-
- set_app_menu(menu);
- }
-
- private void restore() {
- foreach (Account account in db.get_accounts()) {
- if (account.enabled) add_connection(account);
- }
- }
-
- private void add_connection(Account account) {
- stream_interaction.connect(account);
- }
-
- private void remove_connection(Account account) {
- stream_interaction.disconnect(account);
- }
-
- private void load_css() {
- var css_provider = new Gtk.CssProvider ();
- try {
- var file = File.new_for_uri("resource:///org/dino-im/style.css");
- css_provider.load_from_file (file);
- } catch (GLib.Error e) {
- warning ("loading css: %s", e.message);
- }
- Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
-}
-
diff --git a/libdino/src/ui/conversation_summary/merged_message_item.vala b/libdino/src/ui/conversation_summary/merged_message_item.vala
index 4957b1a6..fa198d21 100644
--- a/libdino/src/ui/conversation_summary/merged_message_item.vala
+++ b/libdino/src/ui/conversation_summary/merged_message_item.vala
@@ -33,7 +33,7 @@ public class MergedMessageItem : Grid {
string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
name_label.set_markup(@"<span foreground=\"#$(Util.get_name_hex_color(display_name))\">$display_name</span>");
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(30, 30, image.scale_factor)).draw_message(stream_interactor, message));
- if (message.encryption == Entities.Message.Encryption.PGP) {
+ if (message.encryption != Encryption.NONE) {
encryption_image.visible = true;
encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.SMALL_TOOLBAR);
}
diff --git a/libdino/src/ui/conversation_titlebar.vala b/libdino/src/ui/conversation_titlebar.vala
index 0f34c785..4f472e05 100644
--- a/libdino/src/ui/conversation_titlebar.vala
+++ b/libdino/src/ui/conversation_titlebar.vala
@@ -1,4 +1,5 @@
using Gtk;
+using Gee;
using Dino.Entities;
@@ -12,7 +13,7 @@ public class ConversationTitlebar : Gtk.HeaderBar {
[GtkChild] private MenuButton groupchat_button;
private RadioButton? button_unencrypted;
- private RadioButton? button_pgp;
+ private Map<RadioButton, Plugins.EncryptionListEntry> encryption_radios = new HashMap<RadioButton, Plugins.EncryptionListEntry>();
private StreamInteractor stream_interactor;
private Conversation? conversation;
@@ -36,22 +37,19 @@ public class ConversationTitlebar : Gtk.HeaderBar {
}
private void update_encryption_menu_state() {
- string? pgp_id = PgpManager.get_instance(stream_interactor).get_key_id(conversation.account, conversation.counterpart);
- button_pgp.set_sensitive(pgp_id != null);
- switch (conversation.encryption) {
- case Conversation.Encryption.UNENCRYPTED:
- button_unencrypted.set_active(true);
- break;
- case Conversation.Encryption.PGP:
- button_pgp.set_active(true);
- break;
+ 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() {
encryption_button.visible = (conversation.type_ == Conversation.Type.CHAT);
if (conversation.type_ == Conversation.Type.CHAT) {
- if (conversation.encryption == Conversation.Encryption.UNENCRYPTED) {
+ if (conversation.encryption == Encryption.NONE) {
encryption_button.set_image(new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON));
} else {
encryption_button.set_image(new Image.from_icon_name("changes-prevent-symbolic", IconSize.BUTTON));
@@ -92,25 +90,35 @@ public class ConversationTitlebar : Gtk.HeaderBar {
menu_button.set_menu_model(menu);
}
+ 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 create_encryption_menu() {
Builder builder = new Builder.from_resource("/org/dino-im/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_pgp = builder.get_object("button_pgp") 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);
+ }
encryption_button.set_use_popover(true);
encryption_button.set_popover(menu);
encryption_button.set_image(new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON));
-
- button_unencrypted.toggled.connect(() => {
- if (conversation != null) {
- if (button_unencrypted.get_active()) {
- conversation.encryption = Conversation.Encryption.UNENCRYPTED;
- } else if (button_pgp.get_active()) {
- conversation.encryption = Conversation.Encryption.PGP;
- }
- update_encryption_menu_icon();
- }
- });
}
private void on_groupchat_subject_set(Account account, Jid jid, string subject) {