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_add", self.post_torrent_add)
|
||||||
self.plugin.register_hook("post_torrent_remove",
|
self.plugin.register_hook("post_torrent_remove",
|
||||||
self.post_torrent_remove)
|
self.post_torrent_remove)
|
||||||
|
|
||||||
|
# Register the 'queue' status field
|
||||||
self.plugin.register_status_field("queue", self.status_field_queue)
|
self.plugin.register_status_field("queue", self.status_field_queue)
|
||||||
|
|
||||||
log.info("Queue Core plugin initialized..")
|
log.info("Queue Core plugin initialized..")
|
||||||
|
|
|
@ -46,6 +46,9 @@ try:
|
||||||
except: dbus_imported = False
|
except: dbus_imported = False
|
||||||
else: dbus_imported = True
|
else: dbus_imported = True
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
import gtk.glade
|
||||||
|
|
||||||
# Get the logger
|
# Get the logger
|
||||||
log = logging.getLogger("deluge")
|
log = logging.getLogger("deluge")
|
||||||
|
|
||||||
|
@ -59,6 +62,12 @@ class GtkUI:
|
||||||
"/org/deluge_torrent/Plugin/Queue")
|
"/org/deluge_torrent/Plugin/Queue")
|
||||||
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge.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
|
# Connect to the 'torrent_queue_changed' signal
|
||||||
self.core.connect_to_signal("torrent_queue_changed",
|
self.core.connect_to_signal("torrent_queue_changed",
|
||||||
self.torrent_queue_changed_signal)
|
self.torrent_queue_changed_signal)
|
||||||
|
@ -82,6 +91,14 @@ class GtkUI:
|
||||||
tooltip="Queue selected torrents down",
|
tooltip="Queue selected torrents down",
|
||||||
callback=self.on_queuedown_toolbutton_clicked)
|
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):
|
def on_queuedown_toolbutton_clicked(self, widget):
|
||||||
log.debug("Queue down toolbutton clicked.")
|
log.debug("Queue down toolbutton clicked.")
|
||||||
# Get the selected torrents
|
# Get the selected torrents
|
||||||
|
|
|
@ -42,6 +42,7 @@ setup(
|
||||||
description=__doc__,
|
description=__doc__,
|
||||||
author=__author__,
|
author=__author__,
|
||||||
packages=["queue"],
|
packages=["queue"],
|
||||||
|
package_data = {"queue": ["glade/*.glade"]},
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[deluge.plugin.core]
|
[deluge.plugin.core]
|
||||||
Queue = queue:CorePlugin
|
Queue = queue:CorePlugin
|
||||||
|
|
|
@ -48,13 +48,15 @@ class MenuBar:
|
||||||
log.debug("MenuBar init..")
|
log.debug("MenuBar init..")
|
||||||
self.window = window
|
self.window = window
|
||||||
# Get the torrent menu from the glade file
|
# 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",
|
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||||
"glade/torrent_menu.glade"))
|
"glade/torrent_menu.glade"))
|
||||||
|
|
||||||
|
self.torrentmenu = torrentmenu_glade.get_widget("torrent_menu")
|
||||||
|
|
||||||
# Attach the torrent_menu to the Torrent file menu
|
# Attach the torrent_menu to the Torrent file menu
|
||||||
self.window.main_glade.get_widget("menu_torrent").set_submenu(
|
self.window.main_glade.get_widget("menu_torrent").set_submenu(
|
||||||
self.torrentmenu.get_widget("torrent_menu"))
|
self.torrentmenu)
|
||||||
|
|
||||||
### Connect Signals ###
|
### Connect Signals ###
|
||||||
self.window.main_glade.signal_autoconnect({
|
self.window.main_glade.signal_autoconnect({
|
||||||
|
@ -79,7 +81,7 @@ class MenuBar:
|
||||||
"on_menuitem_about_activate": self.on_menuitem_about_activate
|
"on_menuitem_about_activate": self.on_menuitem_about_activate
|
||||||
})
|
})
|
||||||
|
|
||||||
self.torrentmenu.signal_autoconnect({
|
torrentmenu_glade.signal_autoconnect({
|
||||||
## Torrent Menu
|
## Torrent Menu
|
||||||
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
|
"on_menuitem_pause_activate": self.on_menuitem_pause_activate,
|
||||||
"on_menuitem_resume_activate": self.on_menuitem_resume_activate,
|
"on_menuitem_resume_activate": self.on_menuitem_resume_activate,
|
||||||
|
|
|
@ -52,14 +52,15 @@ class PluginManager:
|
||||||
|
|
||||||
self.plugins = {}
|
self.plugins = {}
|
||||||
for name in pkg_env:
|
for name in pkg_env:
|
||||||
egg = pkg_env[name][0]
|
egg = pkg_env[name][0]
|
||||||
egg.activate()
|
egg.activate()
|
||||||
for name in egg.get_entry_map("deluge.plugin.ui.gtk"):
|
modules = []
|
||||||
entry_point = egg.get_entry_info("deluge.plugin.ui.gtk", name)
|
for name in egg.get_entry_map("deluge.plugin.ui.gtk"):
|
||||||
cls = entry_point.load()
|
entry_point = egg.get_entry_info("deluge.plugin.ui.gtk", name)
|
||||||
instance = cls(self)
|
cls = entry_point.load()
|
||||||
self.plugins[name] = instance
|
instance = cls(self)
|
||||||
log.info("Loaded plugin %s", name)
|
self.plugins[name] = instance
|
||||||
|
log.info("Loaded plugin %s", name)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.plugins[key]
|
return self.plugins[key]
|
||||||
|
@ -72,6 +73,14 @@ class PluginManager:
|
||||||
"""Returns a reference to the toolbar component"""
|
"""Returns a reference to the toolbar component"""
|
||||||
return self._gtkui.mainwindow.toolbar
|
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):
|
def get_selected_torrents(self):
|
||||||
"""Returns a list of the selected torrent_ids"""
|
"""Returns a list of the selected torrent_ids"""
|
||||||
return self._gtkui.mainwindow.torrentview.get_selected_torrents()
|
return self._gtkui.mainwindow.torrentview.get_selected_torrents()
|
||||||
|
|
Loading…
Reference in New Issue