~cmiller/ubuntu/quantal/deluge/fix-parameter-move-storage

« back to all changes in this revision

Viewing changes to deluge/plugins/label/label/gtkui/submenu.py

  • Committer: Bazaar Package Importer
  • Author(s): Cristian Greco
  • Date: 2009-11-13 02:39:45 UTC
  • mfrom: (4.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091113023945-te1bybo2912ejzuc
Tags: 1.2.0~rc3-4
* debian/control: bump build-dep on python-setuptools to (>= 0.6c9).
* debian/patches:
  - 25_r5921_fastresume_files.patch
    new, should fix problems with fresh configs;
  - 30_r5931_ipc_lockfile.patch:
    new, should fix an issue where Deluge will fail to start if there is a
    stale ipc lockfile. (Closes: #555849)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#    this exception statement from your version. If you delete this exception
32
32
#    statement from all source files in the program, then also delete it here.
33
33
#
34
 
 
35
34
#
36
35
 
37
36
 
39
38
import pkg_resources    # access plugin egg
40
39
from deluge.log import LOG as log
41
40
from deluge import component    # for systray
42
 
import ui
43
41
import gtk, gobject
44
 
from deluge.ui.client import aclient
 
42
from deluge.ui.client import client
45
43
 
46
44
from deluge.configmanager import ConfigManager
47
45
config  = ConfigManager("label.conf")
58
56
        #attach..
59
57
        torrentmenu = component.get("MenuBar").torrentmenu
60
58
        self.sub_menu.connect("show", self.on_show, None)
61
 
        aclient.connect_on_new_core(self._on_new_core)
62
 
 
63
 
 
64
 
    def _on_new_core(self, data = None):
65
 
        self.on_show()
66
59
 
67
60
    def get_torrent_ids(self):
68
61
        return component.get("TorrentView").get_selected_torrents()
69
62
 
70
 
 
71
63
    def on_show(self, widget=None, data=None):
72
64
        log.debug("label-on-show")
73
 
        aclient.label_get_labels(self.cb_labels)
74
 
        aclient.force_call(block=True)
 
65
        client.label.get_labels().addCallback(self.cb_labels)
75
66
 
76
 
    def cb_labels(self , labels):
 
67
    def cb_labels(self, labels):
77
68
        for child in self.sub_menu.get_children():
78
69
            self.sub_menu.remove(child)
79
 
        for label in [NO_LABEL] + labels:
 
70
        for label in [NO_LABEL] + list(labels):
80
71
            item = gtk.MenuItem(label.replace("_","__"))
81
72
            item.connect("activate", self.on_select_label, label)
82
73
            self.sub_menu.append(item)
83
74
        self.show_all()
84
75
 
85
 
    def on_select_label(self, widget=None, label_id = None):
 
76
    def on_select_label(self, widget=None, label_id=None):
86
77
        log.debug("select label:%s,%s" % (label_id ,self.get_torrent_ids()) )
87
78
        for torrent_id in self.get_torrent_ids():
88
 
            aclient.label_set_torrent(None, torrent_id, label_id)
89
 
        #aclient.force_call(block=True)
 
79
            client.label.set_torrent(torrent_id, label_id)