Philipp Hörist pushed to branch master at gajim / gajim
Commits: a8ccbb4b by Daniel Brötzmann at 2020-03-15T23:03:34+01:00 CertificateDialog: Format numbers
- - - - -
2 changed files:
- gajim/data/gui/certificate_dialog.ui - gajim/gtk/dialogs.py
Changes:
===================================== gajim/data/gui/certificate_dialog.ui ===================================== @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.22.2 --> <interface> <requires lib="gtk+" version="3.20"/> <object class="GtkBox" id="certificate_box"> @@ -32,7 +32,6 @@ <object class="GtkLabel" id="label_cert_for_account"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label"><Certificate for account %s></property> <property name="justify">center</property> <style> <class name="large-header"/> @@ -63,6 +62,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Common Name (CN)</property> <style> <class name="dim-label"/> @@ -91,6 +91,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Organization (O)</property> <style> <class name="dim-label"/> @@ -119,6 +120,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Organizational Unit (OU)</property> <style> <class name="dim-label"/> @@ -147,6 +149,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Serial Number</property> <style> <class name="dim-label"/> @@ -164,10 +167,12 @@ <property name="halign">start</property> <property name="label"><></property> <property name="wrap">True</property> - <property name="wrap_mode">char</property> + <property name="wrap_mode">word-char</property> <property name="selectable">True</property> - <property name="max_width_chars">30</property> <property name="xalign">0</property> + <attributes> + <attribute name="font-desc" value="Monospace 8"/> + </attributes> </object> <packing> <property name="left_attach">1</property> @@ -179,6 +184,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Common Name (CN)</property> <style> <class name="dim-label"/> @@ -207,6 +213,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Organization (O)</property> <style> <class name="dim-label"/> @@ -235,6 +242,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Organizational Unit (OU)</property> <style> <class name="dim-label"/> @@ -263,6 +271,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Issued on</property> <style> <class name="dim-label"/> @@ -291,6 +300,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">Expires on</property> <style> <class name="dim-label"/> @@ -318,7 +328,8 @@ <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> + <property name="halign">end</property> + <property name="valign">start</property> <property name="label" translatable="yes">SHA-1</property> <style> <class name="dim-label"/> @@ -327,57 +338,53 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">13</property> - <property name="width">2</property> </packing> </child> <child> <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> <property name="margin_top">6</property> - <property name="label" translatable="yes">SHA-256</property> + <property name="label" translatable="yes">Issued to</property> <style> - <class name="dim-label"/> + <class name="bold"/> </style> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">15</property> + <property name="top_attach">0</property> <property name="width">2</property> </packing> </child> <child> - <object class="GtkLabel" id="data_sha1"> + <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="label"><></property> - <property name="wrap">True</property> - <property name="wrap_mode">char</property> - <property name="selectable">True</property> - <property name="max_width_chars">52</property> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Issued by</property> + <style> + <class name="bold"/> + </style> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">14</property> + <property name="top_attach">5</property> <property name="width">2</property> </packing> </child> <child> - <object class="GtkLabel" id="data_sha256"> + <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="label"><></property> - <property name="wrap">True</property> - <property name="wrap_mode">char</property> - <property name="selectable">True</property> - <property name="max_width_chars">52</property> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Validity</property> + <style> + <class name="bold"/> + </style> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">16</property> + <property name="top_attach">9</property> <property name="width">2</property> </packing> </child> @@ -385,68 +392,68 @@ <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> - <property name="margin_top">6</property> - <property name="label" translatable="yes">Issued to</property> + <property name="margin_top">12</property> + <property name="label" translatable="yes">Fingerprints</property> <style> <class name="bold"/> </style> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="top_attach">12</property> <property name="width">2</property> </packing> </child> <child> - <object class="GtkLabel"> + <object class="GtkLabel" id="data_sha1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Issued by</property> - <style> - <class name="bold"/> - </style> + <property name="halign">start</property> + <property name="label"><></property> + <property name="wrap">True</property> + <property name="wrap_mode">char</property> + <property name="selectable">True</property> + <attributes> + <attribute name="font-desc" value="Monospace 8"/> + </attributes> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">2</property> + <property name="left_attach">1</property> + <property name="top_attach">13</property> </packing> </child> <child> <object class="GtkLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Validity</property> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="label" translatable="yes">SHA-256</property> <style> - <class name="bold"/> + <class name="dim-label"/> </style> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">9</property> - <property name="width">2</property> + <property name="top_attach">14</property> </packing> </child> <child> - <object class="GtkLabel"> + <object class="GtkLabel" id="data_sha256"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">baseline</property> - <property name="margin_top">12</property> - <property name="label" translatable="yes">Fingerprints</property> - <style> - <class name="bold"/> - </style> + <property name="halign">start</property> + <property name="label"><></property> + <property name="wrap">True</property> + <property name="wrap_mode">char</property> + <property name="selectable">True</property> + <attributes> + <attribute name="font-desc" value="Monospace 8"/> + </attributes> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">12</property> - <property name="width">2</property> + <property name="left_attach">1</property> + <property name="top_attach">14</property> </packing> </child> <child> @@ -468,7 +475,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">17</property> + <property name="top_attach">15</property> </packing> </child> <child>
===================================== gajim/gtk/dialogs.py ===================================== @@ -215,20 +215,19 @@ class ErrorDialog(HigDialog): class CertificateDialog(Gtk.ApplicationWindow): def __init__(self, transient_for, account, cert): Gtk.ApplicationWindow.__init__(self) + self.account = account self.set_name('CertificateDialog') self.set_application(app.app) self.set_show_menubar(False) self.set_resizable(False) self.set_position(Gtk.WindowPosition.CENTER) self.set_title(_('Certificate')) - self.account = account
self._ui = get_builder('certificate_dialog.ui') self.add(self._ui.certificate_box)
self.connect('key-press-event', self._on_key_press)
- self.account = account self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
cert = convert_gio_to_openssl_cert(cert) @@ -236,11 +235,15 @@ class CertificateDialog(Gtk.ApplicationWindow): issuer = cert.get_issuer() subject = cert.get_subject()
- self._headline = _('Certificate for account\n%s') % account + self._headline = _('Certificate for \n%s') % self.account self._it_common_name = subject.commonName or '' self._it_organization = subject.organizationName or '' self._it_org_unit = subject.organizationalUnitName or '' - self._it_serial_number = str(cert.get_serial_number()) + it_serial_no = str(cert.get_serial_number()) + it_serial_no_half = int(len(it_serial_no) / 2) + self._it_serial_number = '%s\n%s' % ( + it_serial_no[:it_serial_no_half], + it_serial_no[it_serial_no_half:]) self._ib_common_name = issuer.commonName or '' self._ib_organization = issuer.organizationName or '' self._ib_org_unit = issuer.organizationalUnitName or '' @@ -250,8 +253,11 @@ class CertificateDialog(Gtk.ApplicationWindow): expires = datetime.strptime(cert.get_notAfter().decode('ascii'), '%Y%m%d%H%M%SZ') self._expires = expires.strftime('%c %Z') - self._sha1 = cert.digest('sha1').decode('utf-8') - self._sha256 = cert.digest('sha256').decode('utf-8') + sha1 = cert.digest('sha1').decode('utf-8') + self._sha1 = '%s\n%s' % (sha1[:29], sha1[30:]) + sha256 = cert.digest('sha256').decode('utf-8') + self._sha256 = '%s\n%s\n%s\n%s' % ( + sha256[:23], sha256[24:47], sha256[48:71], sha256[72:])
# Set labels self._ui.label_cert_for_account.set_text(self._headline)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/a8ccbb4b2acc604fdbccb965eb704055b...