From cba021a19e658e449652eae6171b5e8a7c3c6db2 Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Tue, 14 Oct 2008 20:04:23 +0000 Subject: [PATCH] label-plugin:fix unload --- deluge/plugins/label/label/core.py | 1 + deluge/plugins/label/label/gtkui/__init__.py | 19 ++++++++++++------- .../plugins/label/label/gtkui/sidebar_menu.py | 10 ++++++++++ deluge/plugins/label/label/gtkui/submenu.py | 10 ++-------- deluge/tests/test_filters.py | 4 ++++ 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/deluge/plugins/label/label/core.py b/deluge/plugins/label/label/core.py index e620e26f0..ff9d12430 100644 --- a/deluge/plugins/label/label/core.py +++ b/deluge/plugins/label/label/core.py @@ -125,6 +125,7 @@ class Core(CorePluginBase): self.plugin.deregister_status_field("label") self.plugin.deregister_hook("post_torrent_add", self.post_torrent_add) self.plugin.deregister_hook("post_torrent_remove", self.post_torrent_remove) + component.get("FilterManager").deregister_tree_field("label") def update(self): pass diff --git a/deluge/plugins/label/label/gtkui/__init__.py b/deluge/plugins/label/label/gtkui/__init__.py index 39a34e7aa..839741ded 100644 --- a/deluge/plugins/label/label/gtkui/__init__.py +++ b/deluge/plugins/label/label/gtkui/__init__.py @@ -64,18 +64,23 @@ class GtkUI(ui.UI): self.load_interface() def disable(self): - self.labelcfg.unload() try: + torrentmenu = component.get("MenuBar").torrentmenu + torrentmenu.remove(self.label_menu) # ok + + self.labelcfg.unload() # ok + self.sidebar_menu.unload() + del self.sidebar_menu + + + component.get("TorrentView").remove_column(_("Label")) log.debug(1.1) component.get("TorrentView").create_model_filter() #todo:improve. - except Exception, e: - log.debug(e) #fix this! - log.debug(1.2) - #disabled: - #self.sidebar_menu.unload() - log.debug(2) + except Exception, e: + log.debug(e) + def get_pixmap(self, fname): """Returns a pixmap file included with plugin""" diff --git a/deluge/plugins/label/label/gtkui/sidebar_menu.py b/deluge/plugins/label/label/gtkui/sidebar_menu.py index c04a994ed..f007d5ace 100644 --- a/deluge/plugins/label/label/gtkui/sidebar_menu.py +++ b/deluge/plugins/label/label/gtkui/sidebar_menu.py @@ -116,6 +116,16 @@ class LabelSidebarMenu(object): for item in self.items: item.hide() + def unload(self): + log.debug("disable01") + for item in list(self.items): + item.hide() + item.destroy() + log.debug("disable02") + self.items = [] + + + #dialogs: class AddDialog(object): diff --git a/deluge/plugins/label/label/gtkui/submenu.py b/deluge/plugins/label/label/gtkui/submenu.py index 9adbd829b..cfe6f6afb 100644 --- a/deluge/plugins/label/label/gtkui/submenu.py +++ b/deluge/plugins/label/label/gtkui/submenu.py @@ -45,16 +45,13 @@ config = ConfigManager("label.conf") GTK_ALFA = config.get("gtk_alfa") NO_LABEL = "No Label" -def cb_none(args): - "hack for empty callbacks." - pass - class LabelMenu(gtk.MenuItem): def __init__(self): gtk.MenuItem.__init__(self, _("Label")) self.sub_menu = gtk.Menu() self.set_submenu(self.sub_menu) + self.items = [] #attach.. torrentmenu = component.get("MenuBar").torrentmenu @@ -86,13 +83,10 @@ class LabelMenu(gtk.MenuItem): def on_select_label(self, widget=None, label_id = None): log.debug("select label:%s,%s" % (label_id ,self.get_torrent_ids()) ) for torrent_id in self.get_torrent_ids(): - aclient.label_set_torrent(cb_none, torrent_id, label_id) + aclient.label_set_torrent(None, torrent_id, label_id) #aclient.force_call(block=True) - - - diff --git a/deluge/tests/test_filters.py b/deluge/tests/test_filters.py index 51f5e64ea..fc906ab99 100644 --- a/deluge/tests/test_filters.py +++ b/deluge/tests/test_filters.py @@ -25,6 +25,10 @@ test_filter(None) if not (sclient.get_torrents_status({}, KEYS) == sclient.get_torrents_status(None, KEYS)): raise Exception("should be equal") +print "#test keyword:" +test_filter({"keyword":["keyword1","prison"]}) + + print "#torrent_id filter:" test_filter({"id":[torrent_id, torrent_id2]})