Philipp Hörist pushed to branch master at gajim / gajim
Commits: 8936a07e by Daniel Brötzmann at 2019-09-29T00:31:30Z ServerInfo: Rework Dialog
- Split information into different notebook tabs - Show connection information (Fixes #6096)
- - - - -
9 changed files:
- gajim/app_actions.py - gajim/common/connection.py - gajim/data/gui/account_context_menu.ui - gajim/data/gui/certificate_dialog.ui - + gajim/data/gui/server_info.ui - gajim/data/style/gajim.css - gajim/gtk/dialogs.py - gajim/gtk/server_info.py - gajim/roster_window.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -27,7 +27,7 @@ import gajim.plugins.gui
from gajim.gtk.dialogs import ShortcutsWindow from gajim.gtk.history_sync import HistorySyncAssistant -from gajim.gtk.server_info import ServerInfoDialog +from gajim.gtk.server_info import ServerInfo from gajim.gtk.mam_preferences import MamPreferences from gajim.gtk.preferences import Preferences from gajim.gtk.groupchat_creation import CreateGroupchatWindow @@ -241,11 +241,11 @@ def on_privacy_lists(action, param):
def on_server_info(action, param): account = param.get_string() - if 'server_info' in interface.instances[account]: - interface.instances[account]['server_info'].present() + window = app.get_app_window(ServerInfo, account) + if window is None: + ServerInfo(account) else: - interface.instances[account]['server_info'] = \ - ServerInfoDialog(account) + window.present()
def on_xml_console(action, param):
===================================== gajim/common/connection.py ===================================== @@ -1018,6 +1018,9 @@ class Connection(CommonConnection, ConnectionHandlers): msg = '%s over proxy %s:%s' % (msg, self._proxy['host'], self._proxy['port']) log.info(msg)
+ def get_connection_info(self): + return self._current_host, self._proxy + def _connect_failure(self, con_type=None): if not con_type: # we are not retrying, and not conecting
===================================== gajim/data/gui/account_context_menu.ui ===================================== @@ -59,10 +59,10 @@ </object> </child> <child> - <object class="GtkMenuItem" id="view_certificate_menuitem"> + <object class="GtkMenuItem" id="view_server_info_menuitem"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">_View Certificate</property> + <property name="label" translatable="yes">_View Server Info</property> <property name="use_underline">True</property> </object> </child>
===================================== gajim/data/gui/certificate_dialog.ui ===================================== @@ -79,6 +79,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -106,6 +107,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -133,6 +135,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -163,7 +166,8 @@ <property name="wrap">True</property> <property name="wrap_mode">char</property> <property name="selectable">True</property> - <property name="max_width_chars">21</property> + <property name="max_width_chars">30</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -191,6 +195,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -218,6 +223,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -245,6 +251,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -272,6 +279,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -299,6 +307,7 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="label"><></property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -347,6 +356,7 @@ <property name="wrap">True</property> <property name="wrap_mode">char</property> <property name="selectable">True</property> + <property name="max_width_chars">52</property> </object> <packing> <property name="left_attach">0</property> @@ -363,7 +373,7 @@ <property name="wrap">True</property> <property name="wrap_mode">char</property> <property name="selectable">True</property> - <property name="max_width_chars">42</property> + <property name="max_width_chars">52</property> </object> <packing> <property name="left_attach">0</property>
===================================== gajim/data/gui/server_info.ui ===================================== @@ -0,0 +1,370 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkNotebook" id="server_info_notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkGrid" id="server"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Hostname</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="server_hostname"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Server Software</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="server_software"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Server Uptime</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="server_uptime"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="selectable">True</property> + <property name="ellipsize">end</property> + <property name="single_line_mode">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="spacer1"> + <property name="width_request">160</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <style> + <class name="margin-18"/> + </style> + </object> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Server</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Type</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="connection_type"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="single_line_mode">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Security</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="connection_security"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label">-</property> + <property name="single_line_mode">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Cipher</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="connection_cipher"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label">-</property> + <property name="selectable">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="connection_proxy_header"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Proxy</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="connection_proxy"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">No proxy used</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cert_button"> + <property name="label" translatable="yes">View _Certificate</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="halign">center</property> + <property name="margin_top">12</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="_on_cert_button_clicked" swapped="no"/> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="spacer2"> + <property name="width_request">160</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <style> + <class name="margin-18"/> + </style> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Connection</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkBox" id="features"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">18</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkScrolledWindow" id="features_scrolled"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">never</property> + <property name="max_content_height">500</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="clipboard_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Copy info to clipboard</property> + <property name="halign">end</property> + <signal name="clicked" handler="_on_clipboard_button_clicked" swapped="no"/> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">edit-copy-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Features</property> + </object> + <packing> + <property name="position">2</property> + <property name="tab_fill">False</property> + </packing> + </child> + </object> +</interface>
===================================== gajim/data/style/gajim.css ===================================== @@ -66,11 +66,11 @@ popover#EmoticonPopover { padding: 5px; background-color: @theme_unfocused_base_ #FinishedLabel { font-size: 14px; font-weight: bold }
/* Server Info */ -#ServerInfoGrid > list { border: 1px solid; border-color: @borders; } -#ServerInfoGrid > list > row:first-child { border-top: 1px solid; border-color: @borders; } -#ServerInfoGrid > list > row { padding: 10px 20px 10px 10px; } -#ServerInfoGrid > list > label { padding:10px; color: @insensitive_fg_color; font-weight: bold; } -#ServerInfoGrid > list > row.activatable:active { box-shadow: none; } +#ServerInfo { border: 1px solid; border-color: @borders; } +#ServerInfo > row:first-child { border-top: 1px solid; border-color: @borders; } +#ServerInfo > row { padding: 10px 20px 10px 10px; } +#ServerInfo > label { padding:10px; color: @insensitive_fg_color; font-weight: bold; } +#ServerInfo > row.activatable:active { box-shadow: none; }
/* Features Info */ #FeaturesInfoGrid > list { border: 1px solid; border-color: @borders; } @@ -225,6 +225,7 @@ list.settings > row > box { .margin-12 { margin: 12px; } .margin-18 { margin: 18px; } .padding-18 { margin: 18px; } +.padding-left30 { padding-left: 30px; }
/* Treeview */ treeview.space { padding: 6px; }
===================================== gajim/gtk/dialogs.py ===================================== @@ -468,6 +468,7 @@ class CertificateDialog(Gtk.ApplicationWindow): self._ui = get_builder('certificate_dialog.ui') self.add(self._ui.certificate_box)
+ self.account = account self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# Get data for labels and copy button @@ -483,10 +484,10 @@ class CertificateDialog(Gtk.ApplicationWindow): self._ib_organization = issuer.organizationName or '' self._ib_org_unit = issuer.organizationalUnitName or '' issued = datetime.strptime(cert.get_notBefore().decode('ascii'), - '%Y%m%d%H%M%SZ') + '%Y%m%d%H%M%SZ') self._issued = issued.strftime('%B %d, %Y, %H:%M:%S %z') expires = datetime.strptime(cert.get_notAfter().decode('ascii'), - '%Y%m%d%H%M%SZ') + '%Y%m%d%H%M%SZ') self._expires = expires.strftime('%B %d, %Y, %H:%M:%S %z') self._sha1 = cert.digest('sha1').decode('utf-8') self._sha256 = cert.digest('sha256').decode('utf-8')
===================================== gajim/gtk/server_info.py ===================================== @@ -20,85 +20,68 @@ import nbxmpp from nbxmpp.util import is_error_result from gi.repository import Gtk from gi.repository import Gdk -from gi.repository import Pango
from gajim.common import app from gajim.common import ged from gajim.common.i18n import _
+from gajim.gtk.dialogs import CertificateDialog from gajim.gtk.util import ensure_not_destroyed +from gajim.gtk.util import get_builder
-log = logging.getLogger('gajim.gtk.serverinfo') +log = logging.getLogger('gajim.gtk.server_info')
-class ServerInfoDialog(Gtk.Dialog): +class ServerInfo(Gtk.ApplicationWindow): def __init__(self, account): - super().__init__(title=_('Server Info'), - transient_for=None, - destroy_with_parent=True) + Gtk.ApplicationWindow.__init__(self) + self.set_name('ServerInfo') + self.set_application(app.app) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_default_size(400, 600) + self.set_show_menubar(False) + self.set_title(_('Server Info'))
self.account = account self._destroyed = False - self.set_transient_for(app.interface.roster.window) - self.set_resizable(True) - self.set_size_request(300, 500)
- grid = Gtk.Grid() - grid.set_name('ServerInfoGrid') - grid.set_row_spacing(10) - grid.set_hexpand(True) + self._ui = get_builder('server_info.ui') + self.add(self._ui.server_info_notebook)
- self.info_listbox = Gtk.ListBox() - self.info_listbox.set_selection_mode(Gtk.SelectionMode.NONE) - self.info_listbox.set_header_func(self.header_func, 'Information') - grid.attach(self.info_listbox, 0, 0, 1, 1) - - self.feature_listbox = Gtk.ListBox() - self.feature_listbox.set_selection_mode(Gtk.SelectionMode.NONE) - self.feature_listbox.set_header_func(self.header_func, 'Features') - grid.attach(self.feature_listbox, 0, 1, 1, 1) - - self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) - clipboard_button = Gtk.Button(halign=Gtk.Align.END) - clp_image = Gtk.Image.new_from_icon_name('edit-copy-symbolic', - Gtk.IconSize.BUTTON) - clipboard_button.set_image(clp_image) - clipboard_button.set_tooltip_text(_('Copy info to clipboard')) - clipboard_button.connect('clicked', self.on_clipboard_button_clicked) - - box = self.get_content_area() - scrolled = Gtk.ScrolledWindow() - scrolled.set_max_content_height(500) - scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) - scrolled.add(grid) - box.pack_start(scrolled, True, True, 0) - box.pack_start(clipboard_button, False, True, 0) - box.set_property('margin', 12) - box.set_spacing(18) - - self.connect('response', self.on_response) self.connect('destroy', self.on_destroy) + self.connect('key-press-event', self._on_key_press) + self._ui.connect_signals(self)
app.ged.register_event_handler('server-disco-received', ged.GUI1, self._server_disco_received)
self.version = '' - self.uptime = '' self.hostname = app.get_hostname_from_account(account) + self._ui.server_hostname.set_text(self.hostname) con = app.connections[account] con.get_module('SoftwareVersion').request_software_version( self.hostname, callback=self._software_version_received) self.request_last_activity()
+ self.cert = con.connection.Connection.ssl_certificate + self._add_connection_info() + + self.feature_listbox = Gtk.ListBox() + self.feature_listbox.set_name('ServerInfo') + self.feature_listbox.set_selection_mode(Gtk.SelectionMode.NONE) + self.feature_listbox.set_header_func(self.header_func, 'Features') + self._ui.features_scrolled.add(self.feature_listbox) for feature in self.get_features(): self.add_feature(feature) - - for info in self.get_infos(): - self.add_info(info) + self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self.show_all()
+ def _on_key_press(self, _widget, event): + if event.keyval == Gdk.KEY_Escape: + self.destroy() + @staticmethod def header_func(row, before, user_data): if before: @@ -108,12 +91,48 @@ class ServerInfoDialog(Gtk.Dialog): label.set_halign(Gtk.Align.START) row.set_header(label)
- @staticmethod - def update(func, listbox): - for index, item in enumerate(func()): - row = listbox.get_row_at_index(index) - row.get_child().update(item) - row.set_tooltip_text(row.get_child().tooltip) + def _add_connection_info(self): + ssl_con = app.connections[self.account].connection.get_ssl_connection() + ssl_version = None + cipher_name = None + if ssl_con is not None: + ssl_version = ssl_con.get_cipher_version() + cipher_name = ssl_con.get_cipher_name() + + host, proxy = app.connections[self.account].get_connection_info() + con_type = host['type'] + + # Connection type + self._ui.connection_type.set_text(con_type.upper()) + if con_type == 'plain': + self._ui.conection_type.get_style_context().add_class( + 'error-color') + + # Connection security + if ssl_version is not None: + self._ui.connection_security.set_text(ssl_version) + + # Connection cipher + if cipher_name is not None: + self._ui.connection_cipher.set_text(cipher_name) + + # Connection proxy + if proxy: + if proxy['type'] == 'bosh': + self._ui.connection_proxy_header.set_text(_('BOSH')) + self._ui.connection_proxy.set_text(proxy['bosh_uri']) + if proxy['type'] in ['http', 'socks5'] or proxy['bosh_useproxy']: + self._ui.connection_proxy.set_text( + proxy['host'] + ':' + proxy['port']) + + self._ui.cert_button.set_sensitive(self.cert) + + def _on_cert_button_clicked(self, button_): + window = app.get_app_window(CertificateDialog, self.account) + if window is None: + CertificateDialog(self, self.account, self.cert) + else: + window.present()
def request_last_activity(self): if not app.account_is_connected(self.account): @@ -123,7 +142,7 @@ class ServerInfoDialog(Gtk.Dialog): con.connection.SendAndCallForResponse(iq, self._on_last_activity)
def _on_last_activity(self, stanza): - if 'server_info' not in app.interface.instances[self.account]: + if self._destroyed: # Window got closed in the meantime return if not nbxmpp.isResultNode(stanza): @@ -141,9 +160,9 @@ class ServerInfoDialog(Gtk.Dialog): hours = 0 if seconds >= 3600: hours = delta.seconds // 3600 - self.uptime = _('%(days)s days, %(hours)s hours') % { + uptime = _('%(days)s days, %(hours)s hours') % { 'days': delta.days, 'hours': hours} - self.update(self.get_infos, self.info_listbox) + self._ui.server_uptime.set_text(uptime)
@ensure_not_destroyed def _software_version_received(self, result): @@ -151,7 +170,14 @@ class ServerInfoDialog(Gtk.Dialog): self.version = _('Unknown') else: self.version = '%s %s' % (result.name, result.version) - self.update(self.get_infos, self.info_listbox) + self._ui.server_software.set_text(self.version) + + @staticmethod + def update(func, listbox): + for index, item in enumerate(func()): + row = listbox.get_row_at_index(index) + row.get_child().update(item) + row.set_tooltip_text(row.get_child().tooltip)
def _server_disco_received(self, obj): self.update(self.get_features, self.feature_listbox) @@ -209,18 +235,8 @@ class ServerInfoDialog(Gtk.Dialog): con.get_module('Bookmarks').conversion) ]
- def add_info(self, info): - self.info_listbox.add(ServerInfoItem(info)) - - def get_infos(self): - Info = namedtuple('Info', ['name', 'value', 'tooltip']) - return [ - Info(_('Hostname'), self.hostname, None), - Info(_('Server Software'), self.version, None), - Info(_('Server Uptime'), self.uptime, None)] - - def on_clipboard_button_clicked(self, widget): - server_software = 'Server Software: %s\n' % self.get_infos()[1].value + def _on_clipboard_button_clicked(self, widget): + server_software = 'Server Software: %s\n' % self.version server_features = ''
for feature in self.get_features(): @@ -232,18 +248,14 @@ class ServerInfoDialog(Gtk.Dialog): tooltip = '(%s)' % feature.tooltip else: tooltip = '' - server_features += '%s: %s %s\n' % (feature.name, available, tooltip) + server_features += '%s: %s %s\n' % ( + feature.name, available, tooltip)
clipboard_text = server_software + server_features self.clipboard.set_text(clipboard_text, -1)
- def on_response(self, dialog, response): - if response == Gtk.ResponseType.OK: - self.destroy() - def on_destroy(self, *args): self._destroyed = True - del app.interface.instances[self.account]['server_info'] app.ged.remove_event_handler('server-disco-received', ged.GUI1, self._server_disco_received) @@ -274,7 +286,7 @@ class FeatureItem(Gtk.Grid): elif enabled is False: self.icon.set_from_icon_name('dialog-warning-symbolic', Gtk.IconSize.MENU) - self.tooltip += _('\nDisabled in config') + self.tooltip += _('\nDisabled in preferences') self.icon.get_style_context().add_class('warning-color') else: self.icon.set_from_icon_name('emblem-ok-symbolic', @@ -284,28 +296,3 @@ class FeatureItem(Gtk.Grid): def update(self, feature): self.tooltip = feature.tooltip self.set_feature(feature.available, feature.enabled) - - -class ServerInfoItem(Gtk.Grid): - def __init__(self, info): - super().__init__() - self.tooltip = info.tooltip - self.insert_column(0) - - self.info = Gtk.Label(label=info.name) - self.info.set_halign(Gtk.Align.START) - self.info.set_xalign(0) - self.info.set_size_request(160, -1) - self.value = Gtk.Label(label=info.value) - self.value.set_halign(Gtk.Align.START) - self.value.set_ellipsize(Pango.EllipsizeMode.END) - self.value.set_width_chars(20) - self.value.set_xalign(0) - self.value.set_hexpand(True) - self.value.set_selectable(True) - - self.add(self.info) - self.add(self.value) - - def update(self, info): - self.value.set_text(info.value)
===================================== gajim/roster_window.py ===================================== @@ -72,8 +72,8 @@ from gajim.gtk.dialogs import InputDialog from gajim.gtk.dialogs import WarningDialog from gajim.gtk.dialogs import InformationDialog from gajim.gtk.dialogs import NonModalConfirmationDialog -from gajim.gtk.dialogs import CertificateDialog from gajim.gtk.dialogs import InvitationReceivedDialog +from gajim.gtk.server_info import ServerInfo from gajim.gtk.single_message import SingleMessageWindow from gajim.gtk.add_contact import AddNewContactWindow from gajim.gtk.account_wizard import AccountCreationWizard @@ -3531,10 +3531,12 @@ class RosterWindow: jid = jid + '/' + resource AdHocCommand(account, jid)
- def on_view_certificate(self, widget, account): - con = app.connections[account] - cert = con.connection.Connection.ssl_certificate - CertificateDialog(self.window, account, cert) + def on_view_server_info(self, _widget, account): + window = app.get_app_window(ServerInfo, account) + if window is None: + ServerInfo(account) + else: + window.present()
def on_roster_window_focus_in_event(self, widget, event): # roster received focus, so if we had urgency REMOVE IT @@ -4761,8 +4763,8 @@ class RosterWindow: 'service_discovery_menuitem') execute_command_menuitem = xml.get_object( 'execute_command_menuitem') - view_certificate_menuitem = xml.get_object( - 'view_certificate_menuitem') + view_server_info_menuitem = xml.get_object( + 'view_server_info_menuitem') edit_account_menuitem = xml.get_object('edit_account_menuitem') sub_menu = Gtk.Menu() status_menuitem.set_submenu(sub_menu) @@ -4840,14 +4842,14 @@ class RosterWindow: account=account) # Fake contact execute_command_menuitem.connect('activate', self.on_execute_command, contact, account) - view_certificate_menuitem.connect('activate', - self.on_view_certificate, account) + view_server_info_menuitem.connect('activate', + self.on_view_server_info, account)
# make some items insensitive if account is offline if not app.account_is_connected(account): for widget in (add_contact_menuitem, service_discovery_menuitem, - execute_command_menuitem, - view_certificate_menuitem, pep_menuitem): + execute_command_menuitem, view_server_info_menuitem, + pep_menuitem): widget.set_sensitive(False) else: xml = get_builder('zeroconf_context_menu.ui')
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/8936a07e46a0e54bb4a43dcb6cd9072862b...