From e4e5935361544f811b996928630b1c3d50cea7fa Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Sun, 22 Jul 2012 13:31:37 +0400 Subject: [PATCH] PluginInstaller.prevent adding multiple 'Available' tabs. --- plugin_installer/manifest.ini | 2 +- plugin_installer/plugin_installer.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugin_installer/manifest.ini b/plugin_installer/manifest.ini index 6a9f21e..cc8b3c4 100644 --- a/plugin_installer/manifest.ini +++ b/plugin_installer/manifest.ini @@ -1,7 +1,7 @@ [info] name: Plugin Installer short_name: plugin_installer -version: 0.8 +version: 0.8.1 description: Install and upgrade plugins from ftp authors: Denis Fomin Yann Leboulanger diff --git a/plugin_installer/plugin_installer.py b/plugin_installer/plugin_installer.py index 30cac1d..30b9623 100644 --- a/plugin_installer/plugin_installer.py +++ b/plugin_installer/plugin_installer.py @@ -142,8 +142,9 @@ class PluginInstaller(GajimPlugin): self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['hpaned2']) hpaned = self.xml.get_object('hpaned2') - self.page_num = self.notebook.append_page(hpaned, - gtk.Label(_('Available'))) + if not hasattr(self, 'page_num'): + self.page_num = self.notebook.append_page(hpaned, + gtk.Label(_('Available'))) widgets_to_extract = ('plugin_name_label1', 'available_treeview', 'progressbar', 'inslall_upgrade_button', @@ -205,6 +206,8 @@ class PluginInstaller(GajimPlugin): def on_win_destroy(self, widget): if hasattr(self, 'ftp'): del self.ftp + if hasattr(self, 'page_num'): + del self.page_num def available_plugins_toggled_cb(self, cell, path): is_active = self.available_plugins_model[path][4] @@ -373,9 +376,12 @@ class PluginInstaller(GajimPlugin): return plugins_found def select_root_iter(self): - selection = self.available_treeview.get_selection() - if selection.count_selected_rows() == 0: - selection.select_iter(self.available_plugins_model.get_iter_root()) + try: + selection = self.available_treeview.get_selection() + if selection.count_selected_rows() == 0: + selection.select_iter(self.available_plugins_model.get_iter_root()) + except Exception, error: + pass class Ftp(threading.Thread):