[omemo] Hide inactive fingerprints by default
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
import os
|
||||
import time
|
||||
import locale
|
||||
import logging
|
||||
import tempfile
|
||||
|
||||
@@ -67,6 +68,7 @@ class KeyDialog(Gtk.Dialog):
|
||||
self._plugin = plugin
|
||||
self._omemo = self._plugin.get_omemo(self._account)
|
||||
self._own_jid = app.get_jid_from_account(self._account)
|
||||
self._show_inactive = False
|
||||
|
||||
path = self._plugin.local_file_path('gtk/key.ui')
|
||||
self._ui = get_builder(path)
|
||||
@@ -76,6 +78,9 @@ class KeyDialog(Gtk.Dialog):
|
||||
omemo_img_path = self._plugin.local_file_path('omemo.png')
|
||||
self._ui.omemo_image.set_from_file(omemo_img_path)
|
||||
|
||||
self._ui.list.set_filter_func(self._filter_func, None)
|
||||
self._ui.list.set_sort_func(self._sort_func, None)
|
||||
|
||||
self._identity_key = self._omemo.backend.storage.getIdentityKeyPair()
|
||||
ownfpr_format = get_fingerprint(self._identity_key, formatted=True)
|
||||
self._ui.own_fingerprint.set_text(ownfpr_format)
|
||||
@@ -84,9 +89,28 @@ class KeyDialog(Gtk.Dialog):
|
||||
|
||||
self.update()
|
||||
self._load_qrcode()
|
||||
self._ui.connect_signals(self)
|
||||
self.connect('destroy', self._on_destroy)
|
||||
self.show_all()
|
||||
|
||||
def _filter_func(self, row, _user_data):
|
||||
if self._show_inactive:
|
||||
return True
|
||||
return row.active
|
||||
|
||||
@staticmethod
|
||||
def _sort_func(row1, row2, _user_data):
|
||||
result = locale.strcoll(str(row1.jid), str(row2.jid))
|
||||
if result != 0:
|
||||
return result
|
||||
|
||||
if row1.active != row2.active:
|
||||
return -1 if row1.active else 1
|
||||
|
||||
if row1.trust != row2.trust:
|
||||
return -1 if row1.trust > row2.trust else 1
|
||||
return 0
|
||||
|
||||
def update(self):
|
||||
self._ui.list.foreach(self._ui.list.remove)
|
||||
self._load_fingerprints(self._own_jid)
|
||||
@@ -168,6 +192,10 @@ class KeyDialog(Gtk.Dialog):
|
||||
self._ui.qrcode.show()
|
||||
self._ui.qrinfo.hide()
|
||||
|
||||
def _on_show_inactive(self, switch, param):
|
||||
self._show_inactive = switch.get_active()
|
||||
self._ui.list.invalidate_filter()
|
||||
|
||||
def _on_destroy(self, *args):
|
||||
del self._windows['dialog']
|
||||
|
||||
|
||||
@@ -91,28 +91,7 @@ you have to install python-qrcode</property>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="direction">up</property>
|
||||
<property name="popover">popover</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Own Fingerprint</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -154,5 +133,67 @@ you have to install python-qrcode</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="direction">up</property>
|
||||
<property name="popover">popover</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Own Fingerprint</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkSwitch">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<signal name="notify::active" handler="_on_show_inactive" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Show inactive</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
padding: 10px 20px 10px 10px;
|
||||
}
|
||||
.omemo-key-dialog scrolledwindow row:last-child { border-bottom: 0px}
|
||||
|
||||
.omemo-key-dialog scrolledwindow { border: 1px solid; border-color:@unfocused_borders; }
|
||||
.omemo-key-dialog list > row { outline: none; }
|
||||
|
||||
.omemo-trust-popover row { padding: 10px 15px 10px 10px; }
|
||||
|
||||
Reference in New Issue
Block a user