diff --git a/omemo/fpr_dialog.ui b/omemo/fpr_dialog.ui index d8c78c2..d692792 100644 --- a/omemo/fpr_dialog.ui +++ b/omemo/fpr_dialog.ui @@ -1,7 +1,7 @@ - + - + @@ -16,16 +16,62 @@ - + True - True - + False + 18 + 18 + 18 + 18 + vertical + 12 - + True False - 12 - 10 + 6 + + + True + False + Own Fingerprint: + + + + + + False + True + 0 + + + + + True + False + <tt>-------- -------- -------- -------- -------- </tt> + True + True + + + False + False + 1 + + + + + False + True + 0 + + + + + True + False + vertical + 12 200 @@ -93,10 +139,10 @@ - + True False - 5 + start Trust/Revoke Fingerprint @@ -120,170 +166,12 @@ - - - - True - False - Contact - - - False - - - - - True - False - 12 - 10 - - - True - False - 10 - - - True - False - Own Fingerprint: - - - - - - False - True - 0 - - - - - True - False - <tt>-------- -------- -------- -------- -------- </tt> - True - True - - - False - False - 1 - - - - - False - False - 0 - - - - - 100 - True - True - - - True - True - True - fingerprint_store - False - 0 - 3 - - - - - - - True - Name - - - - 1 - - - - - - - True - Trust - - - - 2 - - - - - - - True - Fingerprint - - - - 3 - - - - - - - - - True - True - 1 - - - - - True - False - 5 - - - Trust/Revoke Fingerprint - 200 - True - True - True - - - - False - False - 0 - - - - - False - True - 2 - - - + False + True 1 - - - True - False - Own Devices - - - 1 - False - - True diff --git a/omemo/omemoplugin.py b/omemo/omemoplugin.py index cd59868..32a6804 100644 --- a/omemo/omemoplugin.py +++ b/omemo/omemoplugin.py @@ -288,20 +288,17 @@ class OmemoPlugin(GajimPlugin): omemo = self.get_omemo(account) transient = chat_control.parent_win.window if 'dialog' not in self.windowinstances: - if isinstance(chat_control, GroupchatControl): - self.windowinstances['dialog'] = \ - FingerprintWindow(self, contact, transient, - self.windowinstances, groupchat=True) - else: - self.windowinstances['dialog'] = \ - FingerprintWindow(self, contact, transient, - self.windowinstances) + is_groupchat = isinstance(chat_control, GroupchatControl) + self.windowinstances['dialog'] = \ + FingerprintWindow(self, contact, transient, + self.windowinstances, groupchat=is_groupchat) self.windowinstances['dialog'].show_all() if fingerprints: log.debug('%s => Showing Fingerprint Prompt for %s', account, contact.jid) omemo.store.setShownFingerprints(fingerprints) else: + self.windowinstances['dialog'].present() self.windowinstances['dialog'].update_context_list() if fingerprints: omemo.store.setShownFingerprints(fingerprints) diff --git a/omemo/ui.py b/omemo/ui.py index e58ad73..2eeb6e8 100644 --- a/omemo/ui.py +++ b/omemo/ui.py @@ -374,9 +374,8 @@ class FingerprintWindow(Gtk.Dialog): title=(_('Fingerprints for %s')) % contact.jid, parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT) - close_button = self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) - close_button.connect('clicked', self.on_close_button_clicked) - self.connect('delete-event', self.on_window_delete) + + self.connect('destroy', self._on_destroy) self.GTK_BUILDER_FILE_PATH = \ self.plugin.local_file_path('fpr_dialog.ui') @@ -389,7 +388,7 @@ class FingerprintWindow(Gtk.Dialog): self.fpr_view = self.xml.get_object('fingerprint_view') self.fpr_view_own = self.xml.get_object('fingerprint_view_own') - self.notebook = self.xml.get_object('notebook1') + self.notebook = self.xml.get_object('fingerprint_box') vbox = self.get_content_area() vbox.pack_start(self.notebook, True, True, 0) @@ -405,21 +404,13 @@ class FingerprintWindow(Gtk.Dialog): self.show_all() - def on_close_button_clicked(self, widget): + def _on_destroy(self, *args): del self.windowinstances['dialog'] - self.hide() - - def on_window_delete(self, widget, event): - del self.windowinstances['dialog'] - self.hide() def trust_button_clicked_cb(self, button, *args): state = self.omemostate - if self.notebook.get_current_page() == 1: - mod, paths = self.fpr_view_own.get_selection().get_selected_rows() - else: - mod, paths = self.fpr_view.get_selection().get_selected_rows() + mod, paths = self.fpr_view.get_selection().get_selected_rows() def on_yes(checked, identity_key): state.store.setTrust(identity_key, State.TRUSTED) @@ -440,8 +431,10 @@ class FingerprintWindow(Gtk.Dialog): YesNoDialog( _('Trust / Revoke Fingerprint?'), _('Do you want to trust the fingerprint of {jid} ' - 'on your account {account}?\n\n' - '{fingerprint}').format(jid=jid, account=self.account, fingerprint=fpr), + 'on your account {account}?\n\n' + '{fingerprint}').format(jid=jid, + account=self.account, + fingerprint=fpr), on_response_yes=(on_yes, identity_key), on_response_no=(on_no, identity_key), transient_for=self) @@ -468,10 +461,7 @@ class FingerprintWindow(Gtk.Dialog): return keep_selection def clipboard_button_cb(self, menuitem): - if self.notebook.get_current_page() == 1: - mod, paths = self.fpr_view_own.get_selection().get_selected_rows() - else: - mod, paths = self.fpr_view.get_selection().get_selected_rows() + mod, paths = self.fpr_view.get_selection().get_selected_rows() fprs = [] for path in paths: @@ -483,15 +473,14 @@ class FingerprintWindow(Gtk.Dialog): def update_context_list(self, *args): self.fpr_model.clear() + self._load_fingerprints(self.own_jid) + self._load_fingerprints(self.contact.jid, self.groupchat is True) + + def _load_fingerprints(self, contact_jid, groupchat=False): state = self.omemostate - if self.notebook.get_current_page() == 1: - contact_jid = self.own_jid - else: - contact_jid = self.contact.jid - trust_str = {0: 'False', 1: 'True', 2: 'Undecided'} - if self.groupchat and self.notebook.get_current_page() == 0: + if groupchat: contact_jids = [] for nick in self.con.groupchat[contact_jid]: real_jid = self.con.groupchat[contact_jid][nick]