TorrentQueue plugin now diplays menu in TorrentMenu.
This commit is contained in:
parent
7296920731
commit
623c34b349
|
@ -69,6 +69,8 @@ class Core(dbus.service.Object):
|
|||
self.plugin.register_hook("post_torrent_add", self.post_torrent_add)
|
||||
self.plugin.register_hook("post_torrent_remove",
|
||||
self.post_torrent_remove)
|
||||
|
||||
# Register the 'queue' status field
|
||||
self.plugin.register_status_field("queue", self.status_field_queue)
|
||||
|
||||
log.info("Queue Core plugin initialized..")
|
||||
|
|
|
@ -46,6 +46,9 @@ try:
|
|||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
import pkg_resources
|
||||
import gtk.glade
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
|
@ -59,6 +62,12 @@ class GtkUI:
|
|||
"/org/deluge_torrent/Plugin/Queue")
|
||||
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge.Queue")
|
||||
|
||||
# Get the queue menu from the glade file
|
||||
menu_glade = gtk.glade.XML(pkg_resources.resource_filename("queue",
|
||||
"glade/queuemenu.glade"))
|
||||
|
||||
menu = menu_glade.get_widget("menu_queue")
|
||||
|
||||
# Connect to the 'torrent_queue_changed' signal
|
||||
self.core.connect_to_signal("torrent_queue_changed",
|
||||
self.torrent_queue_changed_signal)
|
||||
|
@ -81,6 +90,14 @@ class GtkUI:
|
|||
label="Queue Down",
|
||||
tooltip="Queue selected torrents down",
|
||||
callback=self.on_queuedown_toolbutton_clicked)
|
||||
|
||||
# Add the queue menu to the torrent menu
|
||||
queue_menuitem = gtk.ImageMenuItem("Queue")
|
||||
queue_image = gtk.Image()
|
||||
queue_image.set_from_stock(gtk.STOCK_SORT_ASCENDING, gtk.ICON_SIZE_MENU)
|
||||
queue_menuitem.set_image(queue_image)
|
||||
queue_menuitem.set_submenu(menu)
|
||||
self.plugin.get_torrentmenu().append(queue_menuitem)
|
||||
|
||||
def on_queuedown_toolbutton_clicked(self, widget):
|
||||
log.debug("Queue down toolbutton clicked.")
|
||||
|
|
|
@ -42,6 +42,7 @@ setup(
|
|||
description=__doc__,
|
||||
author=__author__,
|
||||
packages=["queue"],
|
||||
package_data = {"queue": ["glade/*.glade"]},
|
||||
entry_points="""
|
||||
[deluge.plugin.core]
|
||||
Queue = queue:CorePlugin
|
||||
|
|
|
@ -48,13 +48,15 @@ class MenuBar:
|
|||
log.debug("MenuBar init..")
|
||||
self.window = window
|
||||
# Get the torrent menu from the glade file
|
||||
self.torrentmenu = gtk.glade.XML(
|
||||
torrentmenu_glade = gtk.glade.XML(
|
||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||
"glade/torrent_menu.glade"))
|
||||
|
||||
self.torrentmenu = torrentmenu_glade.get_widget("torrent_menu")
|
||||
|
||||
# Attach the torrent_menu to the Torrent file menu
|
||||
self.window.main_glade.get_widget("menu_torrent").set_submenu(
|
||||
self.torrentmenu.get_widget("torrent_menu"))
|
||||
self.torrentmenu)
|
||||
|
||||
### Connect Signals ###
|
||||
self.window.main_glade.signal_autoconnect({
|
||||
|
@ -79,7 +81,7 @@ class MenuBar:
|
|||
"on_menuitem_about_activate": self.on_menuitem_about_activate
|
||||
})
|
||||
|
||||
self.torrentmenu.signal_autoconnect({
|
||||
torrentmenu_glade.signal_autoconnect({
|
||||
## Torrent Menu
|
||||
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
|
||||
"on_menuitem_resume_activate": self.on_menuitem_resume_activate,
|
||||
|
|
|
@ -52,14 +52,15 @@ class PluginManager:
|
|||
|
||||
self.plugins = {}
|
||||
for name in pkg_env:
|
||||
egg = pkg_env[name][0]
|
||||
egg.activate()
|
||||
for name in egg.get_entry_map("deluge.plugin.ui.gtk"):
|
||||
entry_point = egg.get_entry_info("deluge.plugin.ui.gtk", name)
|
||||
cls = entry_point.load()
|
||||
instance = cls(self)
|
||||
self.plugins[name] = instance
|
||||
log.info("Loaded plugin %s", name)
|
||||
egg = pkg_env[name][0]
|
||||
egg.activate()
|
||||
modules = []
|
||||
for name in egg.get_entry_map("deluge.plugin.ui.gtk"):
|
||||
entry_point = egg.get_entry_info("deluge.plugin.ui.gtk", name)
|
||||
cls = entry_point.load()
|
||||
instance = cls(self)
|
||||
self.plugins[name] = instance
|
||||
log.info("Loaded plugin %s", name)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.plugins[key]
|
||||
|
@ -71,7 +72,15 @@ class PluginManager:
|
|||
def get_toolbar(self):
|
||||
"""Returns a reference to the toolbar component"""
|
||||
return self._gtkui.mainwindow.toolbar
|
||||
|
||||
def get_menubar(self):
|
||||
"""Returns a reference to the menubar component"""
|
||||
return self._gtkui.mainwindow.menubar
|
||||
|
||||
def get_torrentmenu(self):
|
||||
"""Returns a reference to the torrentmenu component"""
|
||||
return self._gtkui.mainwindow.menubar.torrentmenu
|
||||
|
||||
def get_selected_torrents(self):
|
||||
"""Returns a list of the selected torrent_ids"""
|
||||
return self._gtkui.mainwindow.torrentview.get_selected_torrents()
|
||||
|
|
Loading…
Reference in New Issue