From 14fc267e83595a499ad1f2ca27c9192b0c9ec430 Mon Sep 17 00:00:00 2001 From: Samuel Hand Date: Tue, 7 Aug 2018 01:06:59 +0100 Subject: Minor UI improvements: use a stack for the key management dialog --- plugins/omemo/data/manage_key_dialog.ui | 176 ++++++++++++++------------ plugins/omemo/src/contact_details_dialog.vala | 61 +++++---- plugins/omemo/src/manage_key_dialog.vala | 52 ++++---- 3 files changed, 151 insertions(+), 138 deletions(-) (limited to 'plugins/omemo') diff --git a/plugins/omemo/data/manage_key_dialog.ui b/plugins/omemo/data/manage_key_dialog.ui index cd14e16c..1c07d971 100644 --- a/plugins/omemo/data/manage_key_dialog.ui +++ b/plugins/omemo/data/manage_key_dialog.ui @@ -39,114 +39,132 @@ True - + True - 12 - 12 - vertical + slide-left-right - - True - True - 0 - 1 - - - - + True + 12 + 12 + vertical + center - + True - none + True + 0 + 1 + + + + + True + + + True + none + + + + main + - - - - - False - 12 - 12 - vertical - - - True - - - - - True - - - - - - - - True - center - True - 40 - - - - - - - - - - - False - 12 - 12 - vertical - + True - Compare the fingerprint, character by character, with the one shown on your contacts device. - True - 0 - 45 + 12 + 12 + vertical + center + + + True + Compare the fingerprint, character by character, with the one shown on your contacts device. + True + 0 + 45 + + + + + True + vertical + 12 + 12 + 12 + False + center + + + True + 12 + 12 + right + + + + + True + True + Not Matching + + + + + True + True + Matching + + + + + + verify + - + True - vertical - 12 - 12 + 12 12 - False - center + vertical + center - + True - 12 - 12 - right - + True - True - Not Matching + + + - + True - True - Matching + center + True + 40 + + + + + + confirm + diff --git a/plugins/omemo/src/contact_details_dialog.vala b/plugins/omemo/src/contact_details_dialog.vala index 326a1b79..b14a108a 100644 --- a/plugins/omemo/src/contact_details_dialog.vala +++ b/plugins/omemo/src/contact_details_dialog.vala @@ -33,41 +33,46 @@ public class ContactDetailsDialog : Gtk.Dialog { .set(plugin.db.identity_meta.trust_level, trust_level).perform(); } - private void add_fingerprint(Row device, Database.IdentityMetaTable.TrustLevel trust) { - keys_container.visible = true; - - ListBoxRow lbr = new ListBoxRow() { visible = true, activatable = true, hexpand = true }; - Box box = new Box(Gtk.Orientation.HORIZONTAL, 40) { visible = true, margin_start = 20, margin_end = 20, margin_top = 14, margin_bottom = 14, hexpand = true }; - - Box status = new Box(Gtk.Orientation.HORIZONTAL, 5) { visible = true, hexpand = true }; - Label status_lbl = new Label(null) { visible = true, hexpand = true, xalign = 0 }; - - Image img = new Image() { visible = true, halign = Align.END, icon_size = IconSize.BUTTON }; - - string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64])); - Label lbl = new Label(res) - { use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false }; - + private void set_row(int trust, bool now_active, Image img, Label status_lbl, Label lbl, ListBoxRow lbr){ switch(trust) { case Database.IdentityMetaTable.TrustLevel.TRUSTED: img.icon_name = "emblem-ok-symbolic"; - status_lbl.set_markup("Accepted"); + status_lbl.set_markup("Accepted"); break; case Database.IdentityMetaTable.TrustLevel.UNTRUSTED: img.icon_name = "action-unavailable-symbolic"; - status_lbl.set_markup("Rejected"); + status_lbl.set_markup("Rejected"); lbl.get_style_context().add_class("dim-label"); break; case Database.IdentityMetaTable.TrustLevel.VERIFIED: img.icon_name = "security-high-symbolic"; - status_lbl.set_markup("Verified"); + status_lbl.set_markup("Verified"); break; } - if (!device[plugin.db.identity_meta.now_active]) { + if (!now_active) { img.icon_name= "appointment-missed-symbolic"; - status_lbl.set_markup("Unused"); + status_lbl.set_markup("Unused"); + lbr.activatable = false; } + } + + private void add_fingerprint(Row device, Database.IdentityMetaTable.TrustLevel trust) { + keys_container.visible = true; + + ListBoxRow lbr = new ListBoxRow() { visible = true, activatable = true, hexpand = true }; + Box box = new Box(Gtk.Orientation.HORIZONTAL, 40) { visible = true, margin_start = 20, margin_end = 20, margin_top = 14, margin_bottom = 14, hexpand = true }; + + Box status = new Box(Gtk.Orientation.HORIZONTAL, 5) { visible = true, hexpand = true }; + Label status_lbl = new Label(null) { visible = true, hexpand = true, xalign = 0 }; + + Image img = new Image() { visible = true, halign = Align.END, icon_size = IconSize.BUTTON }; + + string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64])); + Label lbl = new Label(res) + { use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false }; + + set_row(trust, device[plugin.db.identity_meta.now_active], img, status_lbl, lbl, lbr); box.add(lbl); box.add(status); @@ -84,29 +89,23 @@ public class ContactDetailsDialog : Gtk.Dialog { ManageKeyDialog manage_dialog = new ManageKeyDialog(updated_device, plugin.db); manage_dialog.set_transient_for((Window) get_toplevel()); manage_dialog.present(); - manage_dialog.response.connect((response) => update_row(response, img, lbl, status_lbl, device)); + manage_dialog.response.connect((response) => { + set_row(response, device[plugin.db.identity_meta.now_active], img, status_lbl, lbl, lbr); + update_device(response, device); + }); } }); } - private void update_row(int response, Image img, Label lbl, Label status_lbl, Row device){ + private void update_device(int response, Row device){ switch (response) { case Database.IdentityMetaTable.TrustLevel.TRUSTED: - img.icon_name = "emblem-ok-symbolic"; - status_lbl.set_markup("Accepted"); - lbl.get_style_context().remove_class("dim-label"); set_device_trust(device, true); break; case Database.IdentityMetaTable.TrustLevel.UNTRUSTED: - img.icon_name = "action-unavailable-symbolic"; - status_lbl.set_markup("Rejected"); - lbl.get_style_context().add_class("dim-label"); set_device_trust(device, false); break; case Database.IdentityMetaTable.TrustLevel.VERIFIED: - img.icon_name = "security-high-symbolic"; - status_lbl.set_markup("Verified"); - lbl.get_style_context().remove_class("dim-label"); plugin.db.identity_meta.update() .with(plugin.db.identity_meta.identity_id, "=", account.id) .with(plugin.db.identity_meta.address_name, "=", device[plugin.db.identity_meta.address_name]) diff --git a/plugins/omemo/src/manage_key_dialog.vala b/plugins/omemo/src/manage_key_dialog.vala index bb41ea0d..d359fd81 100644 --- a/plugins/omemo/src/manage_key_dialog.vala +++ b/plugins/omemo/src/manage_key_dialog.vala @@ -6,6 +6,8 @@ namespace Dino.Plugins.Omemo { [GtkTemplate (ui = "/im/dino/Dino/omemo/manage_key_dialog.ui")] public class ManageKeyDialog : Gtk.Dialog { + [GtkChild] private Stack manage_stack; + [GtkChild] private Button cancel_button; [GtkChild] private Button ok_button; @@ -30,22 +32,19 @@ public class ManageKeyDialog : Gtk.Dialog { private int current_response; private void handle_cancel() { - if (main_screen.visible) close(); + if (manage_stack.get_visible_child_name() == "main") close(); - if (verify_screen.visible) { - verify_screen.visible = false; - main_screen.visible = true; + if (manage_stack.get_visible_child_name() == "verify") { + manage_stack.set_visible_child_name("main"); cancel_button.label = "Cancel"; } - if (confirm_screen.visible) { + if (manage_stack.get_visible_child_name() == "confirm") { if (return_to_main) { - confirm_screen.visible = false; - main_screen.visible = true; + manage_stack.set_visible_child_name("main"); cancel_button.label = "Cancel"; } else { - confirm_screen.visible = false; - verify_screen.visible = true; + manage_stack.set_visible_child_name("verify"); } } @@ -69,24 +68,20 @@ public class ManageKeyDialog : Gtk.Dialog { verify_yes.clicked.connect(() => { confirm_image.set_from_icon_name("security-high-symbolic", IconSize.DIALOG); - confirm_title.label = "Complete key verfication"; + confirm_title.label = "Verify key"; confirm_desc.set_markup(@"Once confirmed, any future messages sent by $(device[db.identity_meta.address_name]) using this key will be highlighted accordingly in the chat window."); - return_to_main = false; - verify_screen.visible = false; - confirm_screen.visible = true; + manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; + return_to_main = false; current_response = Database.IdentityMetaTable.TrustLevel.VERIFIED; }); verify_no.clicked.connect(() => { - confirm_image.set_from_icon_name("action-unavailable-symbolic", IconSize.DIALOG); - confirm_title.label = "Complete key rejection"; - confirm_desc.set_markup(@"Once confirmed, any future messages sent by $(device[db.identity_meta.address_name]) using this key will be ignored and none of your messages will be readable using this key."); return_to_main = false; - verify_screen.visible = false; - confirm_screen.visible = true; - ok_button.sensitive = true; - current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED; + confirm_image.set_from_icon_name("dialog-warning-symbolic", IconSize.DIALOG); + confirm_title.label = "Fingerprints do not match"; + confirm_desc.set_markup(@"Please verify that you are comparing the correct fingerprint. If fingerprints do not match $(device[db.identity_meta.address_name])'s account may be compromised and you should consider rejecting this key."); + manage_stack.set_visible_child_name("confirm"); }); } @@ -162,27 +157,28 @@ public class ManageKeyDialog : Gtk.Dialog { main_action_list.row_activated.connect((row) => { if(row == verify) { - verify_screen.visible = true; + manage_stack.set_visible_child_name("verify"); } else if (row == reject) { confirm_image.set_from_icon_name("action-unavailable-symbolic", IconSize.DIALOG); - confirm_title.label = "Complete key rejection"; + confirm_title.label = "Reject key"; confirm_desc.set_markup(@"Once confirmed, any future messages sent by $(device[db.identity_meta.address_name]) using this key will be ignored and none of your messages will be readable using this key."); - return_to_main = true; - confirm_screen.visible = true; + manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; + return_to_main = true; current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED; } else if (row == accept) { confirm_image.set_from_icon_name("emblem-ok-symbolic", IconSize.DIALOG); - confirm_title.label = "Complete key acception"; + confirm_title.label = "Accept key"; confirm_desc.set_markup(@"Once confirmed this key will be usable by $(device[db.identity_meta.address_name]) to receive and send messages."); - return_to_main = true; - confirm_screen.visible = true; + manage_stack.set_visible_child_name("confirm"); ok_button.sensitive = true; + return_to_main = true; current_response = Database.IdentityMetaTable.TrustLevel.TRUSTED; } cancel_button.label = "Back"; - main_screen.visible = false; }); + + manage_stack.set_visible_child_name("main"); } private void setup_verify_screen() { -- cgit v1.2.3-54-g00ecf