label-plugin:fix unload

This commit is contained in:
Martijn Voncken 2008-10-14 20:04:23 +00:00
parent 4e79fe3f7d
commit cba021a19e
5 changed files with 29 additions and 15 deletions

View File

@ -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

View File

@ -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"""

View File

@ -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):

View File

@ -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)

View File

@ -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]})