Commit f19c134a authored by Daniel Brötzmann's avatar Daniel Brötzmann

[plugin_installer] Replace progressbar by spinner, code cleanup

parent 204743e4
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<property name="halign">start</property> <property name="halign">start</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_auto_update_feedback_toggled" swapped="no"/> <signal name="toggled" handler="_on_auto_update_feedback_toggled" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<property name="halign">start</property> <property name="halign">start</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_auto_update_toggled" swapped="no"/> <signal name="toggled" handler="_on_auto_update_toggled" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<property name="halign">start</property> <property name="halign">start</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_check_update_toggled" swapped="no"/> <signal name="toggled" handler="_on_check_update_toggled" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
......
...@@ -24,23 +24,18 @@ ...@@ -24,23 +24,18 @@
<column type="gchararray"/> <column type="gchararray"/>
</columns> </columns>
</object> </object>
<object class="GtkWindow" id="AvailablePlugins"> <object class="GtkBox" id="available_plugins_box">
<property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">18</property>
<property name="spacing">18</property>
<child> <child>
<placeholder/> <object class="GtkOverlay">
</child>
<child>
<object class="GtkBox" id="available_plugins_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="spacing">18</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox" id="plugins_box">
<property name="width_request">200</property> <property name="width_request">180</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
...@@ -56,20 +51,23 @@ ...@@ -56,20 +51,23 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="model">plugin_store</property> <property name="model">plugin_store</property>
<property name="search_column">2</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"> <object class="GtkTreeSelection" id="treeview-selection">
<signal name="changed" handler="available_plugins_treeview_selection_changed" swapped="no"/> <signal name="changed" handler="_available_plugins_treeview_selection_changed" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn">
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="sizing">fixed</property> <property name="sizing">fixed</property>
<property name="fixed_width">200</property> <property name="fixed_width">180</property>
<property name="min_width">150</property> <property name="min_width">150</property>
<property name="max_width">300</property> <property name="max_width">300</property>
<property name="title" translatable="yes">Plugin</property> <property name="title" translatable="yes">Plugin</property>
<property name="expand">True</property> <property name="clickable">True</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf" id="pixbufrenderer"/> <object class="GtkCellRendererPixbuf" id="pixbufrenderer"/>
<attributes> <attributes>
...@@ -77,7 +75,9 @@ ...@@ -77,7 +75,9 @@
</attributes> </attributes>
</child> </child>
<child> <child>
<object class="GtkCellRendererText" id="plugintextrenderer"/> <object class="GtkCellRendererText" id="plugintextrenderer">
<property name="ellipsize">end</property>
</object>
<attributes> <attributes>
<attribute name="text">2</attribute> <attribute name="text">2</attribute>
</attributes> </attributes>
...@@ -108,12 +108,14 @@ ...@@ -108,12 +108,14 @@
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Install / <property name="title" translatable="yes">Install</property>
Update</property> <property name="clickable">True</property>
<property name="alignment">0.5</property> <property name="alignment">0.5</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">5</property>
<child> <child>
<object class="GtkCellRendererToggle" id="togglerenderer"> <object class="GtkCellRendererToggle" id="togglerenderer">
<signal name="toggled" handler="available_plugins_toggled_cb" swapped="no"/> <signal name="toggled" handler="_available_plugin_toggled" swapped="no"/>
</object> </object>
<attributes> <attributes>
<attribute name="active">5</attribute> <attribute name="active">5</attribute>
...@@ -146,7 +148,7 @@ Update</property> ...@@ -146,7 +148,7 @@ Update</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Install/Update Plugin</property> <property name="tooltip_text" translatable="yes">Install/Update Plugin</property>
<property name="icon_name">software-update-available-symbolic</property> <property name="icon_name">software-update-available-symbolic</property>
<signal name="clicked" handler="on_install_upgrade_clicked" swapped="no"/> <signal name="clicked" handler="_on_install_upgrade_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -163,18 +165,43 @@ Update</property> ...@@ -163,18 +165,43 @@ Update</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> </object>
<object class="GtkProgressBar" id="progressbar"> <packing>
<property name="can_focus">False</property> <property name="index">-1</property>
<property name="no_show_all">True</property> </packing>
<property name="ellipsize">end</property> </child>
</object> <child type="overlay">
<packing> <object class="GtkSpinner" id="spinner">
<property name="expand">False</property> <property name="visible">True</property>
<property name="fill">True</property> <property name="can_focus">False</property>
<property name="position">2</property> <property name="active">True</property>
</packing> </object>
</child> </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</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="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel" id="plugin_name_label">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;Plugin Name&gt;</property>
<property name="selectable">True</property>
<style>
<class name="large-header"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -183,162 +210,135 @@ Update</property> ...@@ -183,162 +210,135 @@ Update</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkLabel" id="plugin_description_label">
<property name="width_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="halign">start</property>
<property name="orientation">vertical</property> <property name="label" translatable="yes">&lt;Description&gt;</property>
<property name="spacing">18</property> <property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</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> <child>
<object class="GtkLabel" id="plugin_name_label"> <object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="halign">end</property>
<property name="halign">start</property> <property name="valign">start</property>
<property name="label" translatable="yes">&lt;Plugin Name&gt;</property> <property name="label" translatable="yes">Version</property>
<property name="selectable">True</property>
<style> <style>
<class name="large-header"/> <class name="dim-label"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">0</property>
<property name="fill">True</property> <property name="top_attach">0</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="plugin_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">
<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_version_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">&lt;Description&gt;</property> <property name="label" translatable="yes">&lt;empty&gt;</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="wrap_mode">word-char</property> <property name="wrap_mode">word-char</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">1</property>
<property name="fill">True</property> <property name="top_attach">0</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkGrid"> <object class="GtkLabel" id="plugin_authors_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">6</property> <property name="halign">start</property>
<property name="column_spacing">12</property> <property name="label" translatable="yes">&lt;empty&gt;</property>
<child> <property name="wrap">True</property>
<object class="GtkLabel"> <property name="wrap_mode">word-char</property>
<property name="visible">True</property> <property name="selectable">True</property>
<property name="can_focus">False</property> <property name="xalign">0</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">
<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">
<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_version_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;empty&gt;</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" 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">&lt;empty&gt;</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">1</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">&lt;empty&gt;</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> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">1</property>
<property name="fill">True</property> <property name="top_attach">1</property>
<property name="position">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">&lt;empty&gt;</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> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</interface> </interface>
...@@ -118,7 +118,7 @@ class PluginInstaller(GajimPlugin): ...@@ -118,7 +118,7 @@ class PluginInstaller(GajimPlugin):
'auto_update_feedback': (True, '')} 'auto_update_feedback': (True, '')}
self.gui_extension_points = {'plugin_window': (self.on_activate, None)} self.gui_extension_points = {'plugin_window': (self.on_activate, None)}
self.window = None self.window = None
self.progressbar = None self.spinner = None
self.available_plugins_model = None self.available_plugins_model = None
self.timeout_id = 0 self.timeout_id = 0
self.connected_ids = {} self.connected_ids = {}
...@@ -134,7 +134,7 @@ class PluginInstaller(GajimPlugin): ...@@ -134,7 +134,7 @@ class PluginInstaller(GajimPlugin):
if is_checked: if is_checked:
self.config['auto_update'] = True self.config['auto_update'] = True
get_action('plugins').activate() get_action('plugins').activate()
page = self.notebook.page_num(self.available_plugins_box) page = self.notebook.page_num(self._ui.available_plugins_box)
self.notebook.set_current_page(page) self.notebook.set_current_page(page)
if plugins: if plugins:
plugins_str = '\n' + '\n'.join(plugins) plugins_str = '\n' + '\n'.join(plugins)
...@@ -163,7 +163,7 @@ class PluginInstaller(GajimPlugin): ...@@ -163,7 +163,7 @@ class PluginInstaller(GajimPlugin):
def deactivate(self): def deactivate(self):
if hasattr(self, 'available_page'): if hasattr(self, 'available_page'):
self.notebook.remove_page( self.notebook.remove_page(
self.notebook.page_num(self.available_plugins_box)) self.notebook.page_num(self._ui.available_plugins_box))
self.notebook.set_current_page(0) self.notebook.set_current_page(0)
for id_, widget in list(self.connected_ids.items()): for id_, widget in list(self.connected_ids.items()):
widget.disconnect(id_) widget.disconnect(id_)
...@@ -183,52 +183,41 @@ class PluginInstaller(GajimPlugin): ...@@ -183,52 +183,41 @@ class PluginInstaller(GajimPlugin):
self.installed_plugins_model = plugin_win.installed_plugins_model self.installed_plugins_model = plugin_win.installed_plugins_model
self.notebook = plugin_win.plugins_notebook self.notebook = plugin_win.plugins_notebook
id_ = self.notebook.connect( id_ = self.notebook.connect(
'switch-page', self.on_notebook_switch_page) 'switch-page', self._on_notebook_switch_page)
self.connected_ids[id_] = self.notebook self.connected_ids[id_] = self.notebook
self.window = plugin_win.window self.window = plugin_win.window
id_ = self.window.connect('destroy', self.on_win_destroy) id_ = self.window.connect('destroy', self._on_destroy)
self.connected_ids[id_] = self.window self.connected_ids[id_] = self.window
path = self.local_file_path('installer.ui')
self._ui = get_builder(
path, widgets=['refresh', 'available_plugins_box', 'plugin_store'])
widgets_to_extract = ( self._ui = get_builder(self.local_file_path('installer.ui'))
'available_plugins_box', 'install_plugin_button',
'plugin_name_label', 'plugin_version_label',
'plugin_authors_label', 'plugin_description',
'plugin_homepage_linkbutton', 'progressbar',
'available_plugins_treeview', 'available_text',
'available_text_label')
for widget_name in widgets_to_extract:
setattr(self, widget_name, self._ui.get_object(widget_name))
self.available_page = self.notebook.append_page(
self.available_plugins_box, Gtk.Label.new(_('Available')))
self.spinner = self._ui.spinner
self.available_plugins_model = self._ui.plugin_store self.available_plugins_model = self._ui.plugin_store
self.available_plugins_model.set_sort_column_id( self.available_plugins_model.set_sort_column_id(
2, Gtk.SortType.ASCENDING) 2, Gtk.SortType.ASCENDING)
self.available_page = self.notebook.append_page(
self._ui.available_plugins_box, Gtk.Label.new(_('Available')))
self._ui.connect_signals(self) self._ui.connect_signals(self)
self.window.show_all() self.window.show_all()
def on_win_destroy(self, widget): def _on_destroy(self, widget):