Philipp Hörist pushed to branch master at gajim / gajim
Commits: 4691429a by Daniel Brötzmann at 2020-01-13T09:26:36+01:00 PluginWindow: Use Gtk.ApplicationWindow and _ui scheme
- - - - - 6cfec8ba by Daniel Brötzmann at 2020-01-13T09:26:41+01:00 PluginWindow: Fix linting errors
- - - - -
4 changed files:
- gajim/app_actions.py - gajim/data/gui/plugins_window.ui - gajim/gtk/const.py - gajim/plugins/gui.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -23,8 +23,6 @@ from gajim.common.app import interface from gajim.common.exceptions import GajimGeneralException from gajim import dialogs
-import gajim.plugins.gui - from gajim.gtk.dialogs import ShortcutsWindow from gajim.gtk.single_message import SingleMessageWindow from gajim.gtk.about import AboutDialog @@ -51,10 +49,7 @@ def on_preferences(_action, _param):
def on_plugins(_action, _param): - if 'plugins' in interface.instances: - interface.instances['plugins'].window.present() - else: - interface.instances['plugins'] = gajim.plugins.gui.PluginsWindow() + open_window('PluginsWindow')
def on_accounts(_action, param):
===================================== gajim/data/gui/plugins_window.ui ===================================== @@ -2,103 +2,148 @@ <!-- Generated with glade 3.22.1 --> <interface> <requires lib="gtk+" version="3.20"/> - <object class="GtkWindow" id="plugins_window"> - <property name="width_request">650</property> - <property name="height_request">500</property> - <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="title" translatable="yes">Plugins</property> - <property name="default_width">650</property> - <property name="default_height">500</property> - <property name="type_hint">dialog</property> - <signal name="destroy" handler="on_plugins_window_destroy" swapped="no"/> - <signal name="key-press-event" handler="on_key_press_event" swapped="no"/> - <child type="titlebar"> - <placeholder/> - </child> + <object class="GtkNotebook" id="plugins_notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> <child> - <object class="GtkNotebook" id="plugins_notebook"> + <object class="GtkBox"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can_focus">False</property> + <property name="border_width">18</property> + <property name="spacing">18</property> + <child> + <object class="GtkBox"> + <property name="width_request">200</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">never</property> + <property name="shadow_type">out</property> + <child> + <object class="GtkTreeView" id="installed_plugins_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection"/> + </child> + <style> + <class name="space"/> + </style> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToolbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="show_arrow">False</property> + <property name="icon_size">1</property> + <child> + <object class="GtkToolButton" id="install_plugin_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="tooltip_text" translatable="yes">Install Plugin from ZIP-File</property> + <property name="label" translatable="yes">Install from File…</property> + <property name="use_underline">True</property> + <property name="icon_name">system-software-install-symbolic</property> + <signal name="clicked" handler="_on_install_plugin" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="uninstall_plugin_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="tooltip_text" translatable="yes">Uninstall Plugin</property> + <property name="use_underline">True</property> + <property name="icon_name">edit-delete-symbolic</property> + <signal name="clicked" handler="_on_uninstall_plugin" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <style> + <class name="inline-toolbar"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkBox"> + <property name="width_request">400</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">18</property> + <property name="hexpand">True</property> + <property name="orientation">vertical</property> <property name="spacing">18</property> <child> <object class="GtkBox"> - <property name="width_request">200</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="orientation">vertical</property> + <property name="hexpand">False</property> + <property name="spacing">18</property> <child> - <object class="GtkScrolledWindow"> + <object class="GtkLabel" id="plugin_name_label"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">out</property> - <child> - <object class="GtkTreeView" id="installed_plugins_treeview"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection"/> - </child> - <style> - <class name="space"/> - </style> - </object> - </child> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes"><Plugin Name></property> + <property name="selectable">True</property> + <style> + <class name="large-header"/> + </style> </object> <packing> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkToolbar"> + <object class="GtkButton" id="configure_plugin_button"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="show_arrow">False</property> - <property name="icon_size">1</property> - <child> - <object class="GtkToolButton" id="install_plugin_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes">Install Plugin from ZIP-File</property> - <property name="label" translatable="yes">Install from File…</property> - <property name="use_underline">True</property> - <property name="icon_name">system-software-install-symbolic</property> - <signal name="clicked" handler="on_install_plugin_button_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Plugin Settings</property> + <signal name="clicked" handler="_on_configure_plugin" swapped="no"/> <child> - <object class="GtkToolButton" id="uninstall_plugin_button"> + <object class="GtkImage"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes">Uninstall Plugin</property> - <property name="use_underline">True</property> - <property name="icon_name">edit-delete-symbolic</property> - <signal name="clicked" handler="on_uninstall_plugin_button_clicked" swapped="no"/> + <property name="icon_name">applications-system-symbolic</property> </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> </child> - <style> - <class name="inline-toolbar"/> - </style> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> + <property name="pack_type">end</property> <property name="position">1</property> </packing> </child> @@ -106,33 +151,41 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkBox"> - <property name="width_request">400</property> + <object class="GtkInfoBar" id="available_text"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="orientation">vertical</property> - <property name="spacing">18</property> - <child> + <property name="no_show_all">True</property> + <property name="message_type">error</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child internal-child="content_area"> <object class="GtkBox"> - <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="spacing">18</property> + <property name="spacing">16</property> <child> - <object class="GtkLabel" id="plugin_name_label"> + <object class="GtkLabel" id="available_text_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><Plugin Name></property> - <property name="selectable">True</property> - <style> - <class name="large-header"/> - </style> + <property name="wrap">True</property> + <property name="wrap_mode">word-char</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">False</property> @@ -140,241 +193,171 @@ <property name="position">0</property> </packing> </child> - <child> - <object class="GtkButton" id="configure_plugin_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="tooltip_text" translatable="yes">Plugin Settings</property> - <signal name="clicked" handler="on_configure_plugin_button_clicked" swapped="no"/> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">applications-system-symbolic</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">end</property> - <property name="position">1</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="description"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes"><Description></property> + <property name="wrap">True</property> + <property name="wrap_mode">word-char</property> + <property name="selectable">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</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="valign">start</property> + <property name="label" translatable="yes">Version</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="GtkInfoBar" id="available_text"> + <object class="GtkLabel" id="plugin_version_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="no_show_all">True</property> - <property name="message_type">error</property> - <child internal-child="action_area"> - <object class="GtkButtonBox"> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <property name="layout_style">end</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child internal-child="content_area"> - <object class="GtkBox"> - <property name="can_focus">False</property> - <property name="spacing">16</property> - <child> - <object class="GtkLabel" id="available_text_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="wrap">True</property> - <property name="wrap_mode">word-char</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> + <property name="halign">start</property> + <property name="label"><empty></property> + <property name="wrap">True</property> + <property name="wrap_mode">word-char</property> + <property name="selectable">True</property> + <property name="xalign">0</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkLabel" id="description"> + <object class="GtkLabel"> + <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">Authors</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="plugin_authors_label"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="label" translatable="yes"><Description></property> + <property name="label"><empty></property> <property name="wrap">True</property> <property name="wrap_mode">word-char</property> <property name="selectable">True</property> + <property name="lines">10</property> <property name="xalign">0</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> + <property name="left_attach">1</property> + <property name="top_attach">1</property> </packing> </child> <child> - <object class="GtkGrid"> + <object class="GtkLabel"> <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="valign">start</property> - <property name="label" translatable="yes">Version</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="plugin_version_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="label"><empty></property> - <property name="wrap">True</property> - <property name="wrap_mode">word-char</property> - <property name="selectable">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="valign">start</property> - <property name="label" translatable="yes">Authors</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="plugin_authors_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="label"><empty></property> - <property name="wrap">True</property> - <property name="wrap_mode">word-char</property> - <property name="selectable">True</property> - <property name="lines">10</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="valign">start</property> - <property name="label" translatable="yes">Homepage</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="plugin_homepage_linkbutton"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes"><empty></property> - <property name="wrap">True</property> - <property name="wrap_mode">word-char</property> - <property name="xalign">0</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="label" translatable="yes">Homepage</property> + <style> + <class name="dim-label"/> + </style> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="plugin_homepage_linkbutton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes"><empty></property> + <property name="wrap">True</property> + <property name="wrap_mode">word-char</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> </object> - </child> - <child type="tab"> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Installed</property> - </object> <packing> - <property name="tab_fill">False</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> </packing> </child> - <child> - <placeholder/> - </child> - <child type="tab"> - <placeholder/> - </child> </object> </child> + <child type="tab"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Installed</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child type="tab"> + <placeholder/> + </child> </object> <object class="GtkTextBuffer" id="textbuffer1"> <property name="text" translatable="yes">Plug-in decription should be displayed here. This text will be erased during PluginsWindow initialization.</property>
===================================== gajim/gtk/const.py ===================================== @@ -131,4 +131,5 @@ WINDOW_MODULES = { 'SubscriptionRequest': 'gajim.gtk.subscription_request', 'RemoveAccount': 'gajim.gtk.remove_account', 'ChangePassword': 'gajim.gtk.change_password', + 'PluginsWindow': 'gajim.plugins.gui', }
===================================== gajim/plugins/gui.py ===================================== @@ -56,74 +56,70 @@ class Column(IntEnum): ICON = 4
-class PluginsWindow(EventHelper): - +class PluginsWindow(Gtk.ApplicationWindow, EventHelper): def __init__(self): + Gtk.ApplicationWindow.__init__(self) EventHelper.__init__(self)
- builder = get_builder('plugins_window.ui') - self.window = builder.get_object('plugins_window') - self.window.set_transient_for(app.interface.roster.window) - - widgets_to_extract = ('plugins_notebook', 'plugin_name_label', - 'plugin_version_label', 'plugin_authors_label', - 'plugin_homepage_linkbutton', 'install_plugin_button', - 'uninstall_plugin_button', 'configure_plugin_button', - 'installed_plugins_treeview', 'available_text', - 'available_text_label') - - for widget_name in widgets_to_extract: - setattr(self, widget_name, builder.get_object(widget_name)) + self.set_application(app.app) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_default_size(650, 500) + self.set_show_menubar(False) + self.set_title(_('Plugins'))
- self.plugin_description_textview = builder.get_object('description') + self._ui = get_builder('plugins_window.ui') + self.add(self._ui.plugins_notebook)
# Disable 'Install from ZIP' for Flatpak installs if app.is_flatpak(): - self.install_plugin_button.set_tooltip_text( - _('Click to view Gajim's wiki page on how to install plugins in Flatpak.')) + self._ui.install_plugin_button.set_tooltip_text( + _('Click to view Gajim's wiki page on how to install plugins ' + 'in Flatpak.'))
self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool, - GdkPixbuf.Pixbuf) - self.installed_plugins_treeview.set_model(self.installed_plugins_model) + GdkPixbuf.Pixbuf) + self._ui.installed_plugins_treeview.set_model( + self.installed_plugins_model)
renderer = Gtk.CellRendererText() - col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=Column.NAME) + col = Gtk.TreeViewColumn(_('Plugin')) # , renderer, text=Column.NAME) cell = Gtk.CellRendererPixbuf() col.pack_start(cell, False) col.add_attribute(cell, 'pixbuf', Column.ICON) col.pack_start(renderer, True) col.add_attribute(renderer, 'text', Column.NAME) col.set_property('expand', True) - self.installed_plugins_treeview.append_column(col) + self._ui.installed_plugins_treeview.append_column(col)
renderer = Gtk.CellRendererToggle() - renderer.connect('toggled', self.installed_plugins_toggled_cb) + renderer.connect('toggled', self._installed_plugin_toggled) col = Gtk.TreeViewColumn(_('Active'), renderer, active=Column.ACTIVE, - activatable=Column.ACTIVATABLE) - self.installed_plugins_treeview.append_column(col) + activatable=Column.ACTIVATABLE) + self._ui.installed_plugins_treeview.append_column(col)
- self.def_icon = load_icon('preferences-desktop', - self.window, - pixbuf=True) + self.def_icon = load_icon('preferences-desktop', self, pixbuf=True)
# connect signal for selection change - selection = self.installed_plugins_treeview.get_selection() - selection.connect('changed', - self.installed_plugins_treeview_selection_changed) + selection = self._ui.installed_plugins_treeview.get_selection() + selection.connect( + 'changed', self._installed_plugins_treeview_selection_changed) selection.set_mode(Gtk.SelectionMode.SINGLE)
self._clear_installed_plugin_info()
- self.fill_installed_plugins_model() + self._fill_installed_plugins_model() root_iter = self.installed_plugins_model.get_iter_first() if root_iter: selection.select_iter(root_iter)
- builder.connect_signals(self) + self.connect('destroy', self._on_destroy) + self.connect('key-press-event', self._on_key_press) + self._ui.connect_signals(self)
- self.plugins_notebook.set_current_page(0) + self._ui.plugins_notebook.set_current_page(0)
- # Adding GUI extension point for Plugins that want to hook the Plugin Window + # Adding GUI extension point for Plugins that want to hook + # the Plugin Window app.plugin_manager.gui_extension_point('plugin_window', self)
self.register_events([ @@ -131,17 +127,21 @@ class PluginsWindow(EventHelper): ('plugin-added', ged.GUI1, self._on_plugin_added), ])
- self.window.show_all() + self.show_all()
def get_notebook(self): # Used by plugins - return self.plugins_notebook + return self._ui.plugins_notebook
- def on_key_press_event(self, widget, event): + def _on_key_press(self, _widget, event): if event.keyval == Gdk.KEY_Escape: - self.window.destroy() + self.destroy()
- def installed_plugins_treeview_selection_changed(self, treeview_selection): + def _on_destroy(self, *args): + self.unregister_events() + app.plugin_manager.remove_gui_extension_point('plugin_window', self) + + def _installed_plugins_treeview_selection_changed(self, treeview_selection): model, iter_ = treeview_selection.get_selected() if iter_: plugin = model.get_value(iter_, Column.PLUGIN) @@ -150,57 +150,62 @@ class PluginsWindow(EventHelper): self._clear_installed_plugin_info()
def _display_installed_plugin_info(self, plugin): - self.plugin_name_label.set_text(plugin.name) - self.plugin_version_label.set_text(plugin.version) - self.plugin_authors_label.set_text(plugin.authors) + self._ui.plugin_name_label.set_text(plugin.name) + self._ui.plugin_version_label.set_text(plugin.version) + self._ui.plugin_authors_label.set_text(plugin.authors) markup = '<a href="%s">%s</a>' % (plugin.homepage, plugin.homepage) - self.plugin_homepage_linkbutton.set_markup(markup) + self._ui.plugin_homepage_linkbutton.set_markup(markup)
if plugin.available_text: text = _('Warning: %s') % plugin.available_text - self.available_text_label.set_text(text) - self.available_text.show() + self._ui.available_text_label.set_text(text) + self._ui.available_text.show() # Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=710888 - self.available_text.queue_resize() + self._ui.available_text.queue_resize() else: - self.available_text.hide() + self._ui.available_text.hide()
- self.plugin_description_textview.set_text(plugin.description) + self._ui.description.set_text(plugin.description)
- self.uninstall_plugin_button.set_property( - 'sensitive', configpaths.get('PLUGINS_USER') in plugin.__path__) - self.configure_plugin_button.set_property( - 'sensitive', plugin.config_dialog is not None) + self._ui.uninstall_plugin_button.set_sensitive( + configpaths.get('PLUGINS_USER') in plugin.__path__) + self._ui.configure_plugin_button.set_sensitive( + plugin.config_dialog is not None)
def _clear_installed_plugin_info(self): - self.plugin_name_label.set_text('') - self.plugin_version_label.set_text('') - self.plugin_authors_label.set_text('') - self.plugin_homepage_linkbutton.set_markup('') + self._ui.plugin_name_label.set_text('') + self._ui.plugin_version_label.set_text('') + self._ui.plugin_authors_label.set_text('') + self._ui.plugin_homepage_linkbutton.set_markup('')
- self.plugin_description_textview.set_text('') - self.uninstall_plugin_button.set_property('sensitive', False) - self.configure_plugin_button.set_property('sensitive', False) + self._ui.description.set_text('') + self._ui.uninstall_plugin_button.set_sensitive(False) + self._ui.configure_plugin_button.set_sensitive(False)
- def fill_installed_plugins_model(self): + def _fill_installed_plugins_model(self): pm = app.plugin_manager self.installed_plugins_model.clear() - self.installed_plugins_model.set_sort_column_id(1, Gtk.SortType.ASCENDING) + self.installed_plugins_model.set_sort_column_id(1, + Gtk.SortType.ASCENDING)
for plugin in pm.plugins: - icon = self.get_plugin_icon(plugin) - self.installed_plugins_model.append([plugin, plugin.name, - plugin.active and plugin.activatable, plugin.activatable, icon]) - - def get_plugin_icon(self, plugin): + icon = self._get_plugin_icon(plugin) + self.installed_plugins_model.append( + [plugin, + plugin.name, + plugin.active and plugin.activatable, + plugin.activatable, + icon]) + + def _get_plugin_icon(self, plugin): icon_file = os.path.join(plugin.__path__, os.path.split( - plugin.__path__)[1]) + '.png' + plugin.__path__)[1]) + '.png' icon = self.def_icon if os.path.isfile(icon_file): icon = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file, 16, 16) return icon
- def installed_plugins_toggled_cb(self, cell, path): + def _installed_plugin_toggled(self, _cell, path): is_active = self.installed_plugins_model[path][Column.ACTIVE] plugin = self.installed_plugins_model[path][Column.PLUGIN]
@@ -211,27 +216,21 @@ class PluginsWindow(EventHelper): app.plugin_manager.activate_plugin(plugin) except GajimPluginActivateException as e: WarningDialog(_('Plugin failed'), str(e), - transient_for=self.window) + transient_for=self) return
self.installed_plugins_model[path][Column.ACTIVE] = not is_active
- def on_plugins_window_destroy(self, widget): - '''Close window''' - self.unregister_events() - app.plugin_manager.remove_gui_extension_point('plugin_window', self) - del app.interface.instances['plugins'] - - def on_configure_plugin_button_clicked(self, widget): - selection = self.installed_plugins_treeview.get_selection() + def _on_configure_plugin(self, _widget): + selection = self._ui.installed_plugins_treeview.get_selection() model, iter_ = selection.get_selected() if iter_: plugin = model.get_value(iter_, Column.PLUGIN)
if isinstance(plugin.config_dialog, GajimPluginConfigDialog): - plugin.config_dialog.run(self.window) + plugin.config_dialog.run(self) else: - plugin.config_dialog(self.window) + plugin.config_dialog(self)
else: # No plugin selected. this should never be reached. As configure @@ -239,8 +238,8 @@ class PluginsWindow(EventHelper): # XXX: maybe throw exception here? pass
- def on_uninstall_plugin_button_clicked(self, widget): - selection = self.installed_plugins_treeview.get_selection() + def _on_uninstall_plugin(self, _widget): + selection = self._ui.installed_plugins_treeview.get_selection() model, iter_ = selection.get_selected() if iter_: plugin = model.get_value(iter_, Column.PLUGIN) @@ -248,7 +247,7 @@ class PluginsWindow(EventHelper): app.plugin_manager.uninstall_plugin(plugin) except PluginsystemError as e: WarningDialog(_('Unable to properly remove the plugin'), - str(e), self.window) + str(e), self) return
def _on_plugin_removed(self, event): @@ -258,21 +257,21 @@ class PluginsWindow(EventHelper): break
def _on_plugin_added(self, event): - icon = self.get_plugin_icon(event.plugin) + icon = self._get_plugin_icon(event.plugin) self.installed_plugins_model.append([event.plugin, event.plugin.name, False, event.plugin.activatable, icon])
- def on_install_plugin_button_clicked(self, widget): + def _on_install_plugin(self, _widget): if app.is_flatpak(): open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/flathub') return
- def show_warn_dialog(): + def _show_warn_dialog(): text = _('Archive is malformed') - dialog = WarningDialog(text, '', transient_for=self.window) + dialog = WarningDialog(text, '', transient_for=self) dialog.set_modal(False) dialog.popup()
@@ -281,7 +280,7 @@ class PluginsWindow(EventHelper): plugin = app.plugin_manager.install_from_zip(zip_filename, True) if not plugin: - show_warn_dialog() + _show_warn_dialog() return
NewConfirmationDialog( @@ -292,7 +291,7 @@ class PluginsWindow(EventHelper): DialogButton.make('Remove', text=_('_Overwrite'), callback=_on_yes)], - transient_for=self.window).show() + transient_for=self).show()
def _try_install(zip_filename): try: @@ -303,19 +302,19 @@ class PluginsWindow(EventHelper): _on_plugin_exists(zip_filename) return
- WarningDialog(error_text, '"%s"' % zip_filename, self.window) + WarningDialog(error_text, '"%s"' % zip_filename, self) return if not plugin: - show_warn_dialog() + _show_warn_dialog() return
- ArchiveChooserDialog(_try_install, transient_for=self.window) + ArchiveChooserDialog(_try_install, transient_for=self)
class GajimPluginConfigDialog(Gtk.Dialog): def __init__(self, plugin, **kwargs): - Gtk.Dialog.__init__(self, title='%s %s'%(plugin.name, - _('Configuration')), **kwargs) + Gtk.Dialog.__init__(self, title='%s %s' % (plugin.name, + _('Configuration')), **kwargs) self.plugin = plugin button = self.add_button('gtk-close', Gtk.ResponseType.CLOSE) button.connect('clicked', self.on_close_button_clicked)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/58dac3acc62e50435c70e92b9998260920...