Minor UI improvements: use a stack for the key management dialog
This commit is contained in:
parent
0bfab9d1d9
commit
14fc267e83
|
@ -38,12 +38,17 @@
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStack" id="manage_stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="transition-type">slide-left-right</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="main_screen">
|
<object class="GtkBox" id="main_screen">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="margin">12</property>
|
<property name="margin">12</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="main_desc">
|
<object class="GtkLabel" id="main_desc">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -64,48 +69,17 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
<packing>
|
||||||
<child>
|
<property name="name">main</property>
|
||||||
<object class="GtkBox" id="confirm_screen">
|
</packing>
|
||||||
<property name="visible">False</property>
|
|
||||||
<property name="margin">12</property>
|
|
||||||
<property name="spacing">12</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="confirm_image">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="confirm_title">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="scale" value="1.1"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="confirm_desc">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="justify">center</property>
|
|
||||||
<property name="wrap">True</property>
|
|
||||||
<property name="max-width-chars">40</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="scale" value="0.8"/>
|
|
||||||
</attributes>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="verify_screen">
|
<object class="GtkBox" id="verify_screen">
|
||||||
<property name="visible">False</property>
|
<property name="visible">True</property>
|
||||||
<property name="margin">12</property>
|
<property name="margin">12</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -149,6 +123,50 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">verify</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="confirm_screen">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="margin">12</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="confirm_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="confirm_title">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="1.1"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="confirm_desc">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="justify">center</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="max-width-chars">40</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="scale" value="0.8"/>
|
||||||
|
</attributes>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">confirm</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -33,6 +33,30 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
.set(plugin.db.identity_meta.trust_level, trust_level).perform();
|
.set(plugin.db.identity_meta.trust_level, trust_level).perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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("<span color='#1A63D9'>Accepted</span>");
|
||||||
|
break;
|
||||||
|
case Database.IdentityMetaTable.TrustLevel.UNTRUSTED:
|
||||||
|
img.icon_name = "action-unavailable-symbolic";
|
||||||
|
status_lbl.set_markup("<span color='#D91900'>Rejected</span>");
|
||||||
|
lbl.get_style_context().add_class("dim-label");
|
||||||
|
break;
|
||||||
|
case Database.IdentityMetaTable.TrustLevel.VERIFIED:
|
||||||
|
img.icon_name = "security-high-symbolic";
|
||||||
|
status_lbl.set_markup("<span color='#1A63D9'>Verified</span>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!now_active) {
|
||||||
|
img.icon_name= "appointment-missed-symbolic";
|
||||||
|
status_lbl.set_markup("<span color='#8b8e8f'>Unused</span>");
|
||||||
|
lbr.activatable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void add_fingerprint(Row device, Database.IdentityMetaTable.TrustLevel trust) {
|
private void add_fingerprint(Row device, Database.IdentityMetaTable.TrustLevel trust) {
|
||||||
keys_container.visible = true;
|
keys_container.visible = true;
|
||||||
|
|
||||||
|
@ -48,26 +72,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
Label lbl = new Label(res)
|
Label lbl = new Label(res)
|
||||||
{ use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false };
|
{ use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false };
|
||||||
|
|
||||||
switch(trust) {
|
set_row(trust, device[plugin.db.identity_meta.now_active], img, status_lbl, lbl, lbr);
|
||||||
case Database.IdentityMetaTable.TrustLevel.TRUSTED:
|
|
||||||
img.icon_name = "emblem-ok-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#1A63D9'>Accepted</span>");
|
|
||||||
break;
|
|
||||||
case Database.IdentityMetaTable.TrustLevel.UNTRUSTED:
|
|
||||||
img.icon_name = "action-unavailable-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#D91900'>Rejected</span>");
|
|
||||||
lbl.get_style_context().add_class("dim-label");
|
|
||||||
break;
|
|
||||||
case Database.IdentityMetaTable.TrustLevel.VERIFIED:
|
|
||||||
img.icon_name = "security-high-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#1A63D9'>Verified</span>");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!device[plugin.db.identity_meta.now_active]) {
|
|
||||||
img.icon_name= "appointment-missed-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#8b8e8f'>Unused</span>");
|
|
||||||
}
|
|
||||||
|
|
||||||
box.add(lbl);
|
box.add(lbl);
|
||||||
box.add(status);
|
box.add(status);
|
||||||
|
@ -84,29 +89,23 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
||||||
ManageKeyDialog manage_dialog = new ManageKeyDialog(updated_device, plugin.db);
|
ManageKeyDialog manage_dialog = new ManageKeyDialog(updated_device, plugin.db);
|
||||||
manage_dialog.set_transient_for((Window) get_toplevel());
|
manage_dialog.set_transient_for((Window) get_toplevel());
|
||||||
manage_dialog.present();
|
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) {
|
switch (response) {
|
||||||
case Database.IdentityMetaTable.TrustLevel.TRUSTED:
|
case Database.IdentityMetaTable.TrustLevel.TRUSTED:
|
||||||
img.icon_name = "emblem-ok-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#1A63D9'>Accepted</span>");
|
|
||||||
lbl.get_style_context().remove_class("dim-label");
|
|
||||||
set_device_trust(device, true);
|
set_device_trust(device, true);
|
||||||
break;
|
break;
|
||||||
case Database.IdentityMetaTable.TrustLevel.UNTRUSTED:
|
case Database.IdentityMetaTable.TrustLevel.UNTRUSTED:
|
||||||
img.icon_name = "action-unavailable-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#D91900'>Rejected</span>");
|
|
||||||
lbl.get_style_context().add_class("dim-label");
|
|
||||||
set_device_trust(device, false);
|
set_device_trust(device, false);
|
||||||
break;
|
break;
|
||||||
case Database.IdentityMetaTable.TrustLevel.VERIFIED:
|
case Database.IdentityMetaTable.TrustLevel.VERIFIED:
|
||||||
img.icon_name = "security-high-symbolic";
|
|
||||||
status_lbl.set_markup("<span size='large' color='#1A63D9'>Verified</span>");
|
|
||||||
lbl.get_style_context().remove_class("dim-label");
|
|
||||||
plugin.db.identity_meta.update()
|
plugin.db.identity_meta.update()
|
||||||
.with(plugin.db.identity_meta.identity_id, "=", account.id)
|
.with(plugin.db.identity_meta.identity_id, "=", account.id)
|
||||||
.with(plugin.db.identity_meta.address_name, "=", device[plugin.db.identity_meta.address_name])
|
.with(plugin.db.identity_meta.address_name, "=", device[plugin.db.identity_meta.address_name])
|
||||||
|
|
|
@ -6,6 +6,8 @@ namespace Dino.Plugins.Omemo {
|
||||||
[GtkTemplate (ui = "/im/dino/Dino/omemo/manage_key_dialog.ui")]
|
[GtkTemplate (ui = "/im/dino/Dino/omemo/manage_key_dialog.ui")]
|
||||||
public class ManageKeyDialog : Gtk.Dialog {
|
public class ManageKeyDialog : Gtk.Dialog {
|
||||||
|
|
||||||
|
[GtkChild] private Stack manage_stack;
|
||||||
|
|
||||||
[GtkChild] private Button cancel_button;
|
[GtkChild] private Button cancel_button;
|
||||||
[GtkChild] private Button ok_button;
|
[GtkChild] private Button ok_button;
|
||||||
|
|
||||||
|
@ -30,22 +32,19 @@ public class ManageKeyDialog : Gtk.Dialog {
|
||||||
private int current_response;
|
private int current_response;
|
||||||
|
|
||||||
private void handle_cancel() {
|
private void handle_cancel() {
|
||||||
if (main_screen.visible) close();
|
if (manage_stack.get_visible_child_name() == "main") close();
|
||||||
|
|
||||||
if (verify_screen.visible) {
|
if (manage_stack.get_visible_child_name() == "verify") {
|
||||||
verify_screen.visible = false;
|
manage_stack.set_visible_child_name("main");
|
||||||
main_screen.visible = true;
|
|
||||||
cancel_button.label = "Cancel";
|
cancel_button.label = "Cancel";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (confirm_screen.visible) {
|
if (manage_stack.get_visible_child_name() == "confirm") {
|
||||||
if (return_to_main) {
|
if (return_to_main) {
|
||||||
confirm_screen.visible = false;
|
manage_stack.set_visible_child_name("main");
|
||||||
main_screen.visible = true;
|
|
||||||
cancel_button.label = "Cancel";
|
cancel_button.label = "Cancel";
|
||||||
} else {
|
} else {
|
||||||
confirm_screen.visible = false;
|
manage_stack.set_visible_child_name("verify");
|
||||||
verify_screen.visible = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,24 +68,20 @@ public class ManageKeyDialog : Gtk.Dialog {
|
||||||
|
|
||||||
verify_yes.clicked.connect(() => {
|
verify_yes.clicked.connect(() => {
|
||||||
confirm_image.set_from_icon_name("security-high-symbolic", IconSize.DIALOG);
|
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 <b>$(device[db.identity_meta.address_name])</b> using this key will be highlighted accordingly in the chat window.");
|
confirm_desc.set_markup(@"Once confirmed, any future messages sent by <b>$(device[db.identity_meta.address_name])</b> using this key will be highlighted accordingly in the chat window.");
|
||||||
return_to_main = false;
|
manage_stack.set_visible_child_name("confirm");
|
||||||
verify_screen.visible = false;
|
|
||||||
confirm_screen.visible = true;
|
|
||||||
ok_button.sensitive = true;
|
ok_button.sensitive = true;
|
||||||
|
return_to_main = false;
|
||||||
current_response = Database.IdentityMetaTable.TrustLevel.VERIFIED;
|
current_response = Database.IdentityMetaTable.TrustLevel.VERIFIED;
|
||||||
});
|
});
|
||||||
|
|
||||||
verify_no.clicked.connect(() => {
|
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 <b>$(device[db.identity_meta.address_name])</b> using this key will be ignored and none of your messages will be readable using this key.");
|
|
||||||
return_to_main = false;
|
return_to_main = false;
|
||||||
verify_screen.visible = false;
|
confirm_image.set_from_icon_name("dialog-warning-symbolic", IconSize.DIALOG);
|
||||||
confirm_screen.visible = true;
|
confirm_title.label = "Fingerprints do not match";
|
||||||
ok_button.sensitive = true;
|
confirm_desc.set_markup(@"Please verify that you are comparing the correct fingerprint. If fingerprints do not match <b>$(device[db.identity_meta.address_name])</b>'s account may be compromised and you should consider rejecting this key.");
|
||||||
current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED;
|
manage_stack.set_visible_child_name("confirm");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,27 +157,28 @@ public class ManageKeyDialog : Gtk.Dialog {
|
||||||
|
|
||||||
main_action_list.row_activated.connect((row) => {
|
main_action_list.row_activated.connect((row) => {
|
||||||
if(row == verify) {
|
if(row == verify) {
|
||||||
verify_screen.visible = true;
|
manage_stack.set_visible_child_name("verify");
|
||||||
} else if (row == reject) {
|
} else if (row == reject) {
|
||||||
confirm_image.set_from_icon_name("action-unavailable-symbolic", IconSize.DIALOG);
|
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 <b>$(device[db.identity_meta.address_name])</b> using this key will be ignored and none of your messages will be readable using this key.");
|
confirm_desc.set_markup(@"Once confirmed, any future messages sent by <b>$(device[db.identity_meta.address_name])</b> using this key will be ignored and none of your messages will be readable using this key.");
|
||||||
return_to_main = true;
|
manage_stack.set_visible_child_name("confirm");
|
||||||
confirm_screen.visible = true;
|
|
||||||
ok_button.sensitive = true;
|
ok_button.sensitive = true;
|
||||||
|
return_to_main = true;
|
||||||
current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED;
|
current_response = Database.IdentityMetaTable.TrustLevel.UNTRUSTED;
|
||||||
} else if (row == accept) {
|
} else if (row == accept) {
|
||||||
confirm_image.set_from_icon_name("emblem-ok-symbolic", IconSize.DIALOG);
|
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 <b>$(device[db.identity_meta.address_name])</b> to receive and send messages.");
|
confirm_desc.set_markup(@"Once confirmed this key will be usable by <b>$(device[db.identity_meta.address_name])</b> to receive and send messages.");
|
||||||
return_to_main = true;
|
manage_stack.set_visible_child_name("confirm");
|
||||||
confirm_screen.visible = true;
|
|
||||||
ok_button.sensitive = true;
|
ok_button.sensitive = true;
|
||||||
|
return_to_main = true;
|
||||||
current_response = Database.IdentityMetaTable.TrustLevel.TRUSTED;
|
current_response = Database.IdentityMetaTable.TrustLevel.TRUSTED;
|
||||||
}
|
}
|
||||||
cancel_button.label = "Back";
|
cancel_button.label = "Back";
|
||||||
main_screen.visible = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
manage_stack.set_visible_child_name("main");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup_verify_screen() {
|
private void setup_verify_screen() {
|
||||||
|
|
Loading…
Reference in a new issue