mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-12 03:18:47 +00:00
connect queue to top
This commit is contained in:
parent
ac99ef7d26
commit
525526316c
5 changed files with 62 additions and 18 deletions
|
@ -46,6 +46,7 @@
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="label" translatable="yes">Top</property>
|
<property name="label" translatable="yes">Top</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="activate" handler="queue_top"/>
|
||||||
<child internal-child="image">
|
<child internal-child="image">
|
||||||
<widget class="GtkImage" id="menu-item-image10">
|
<widget class="GtkImage" id="menu-item-image10">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -49,30 +49,30 @@ class BlocklistImport:
|
||||||
|
|
||||||
def loadlist(self, fetch=False):
|
def loadlist(self, fetch=False):
|
||||||
# FIXME
|
# FIXME
|
||||||
#self.gtkprog.start()
|
self.gtkprog.start()
|
||||||
|
|
||||||
# Attempt initial import
|
# Attempt initial import
|
||||||
# FIXME: Make async
|
|
||||||
if fetch:
|
if fetch:
|
||||||
print "Downloading blocklist..."
|
self.gtkprog.start_download()
|
||||||
filename, headers = urllib.urlretrieve(self.config.get('url'),
|
filename, headers = urllib.urlretrieve(self.config.get('url'),
|
||||||
filename=self.blockfile,
|
filename=self.blockfile,
|
||||||
reporthook=self._download_update)
|
reporthook=self._download_update)
|
||||||
print "Done"
|
|
||||||
|
self.gtkprog.start_import()
|
||||||
|
|
||||||
self.core.reset_ip_filter()
|
self.core.reset_ip_filter()
|
||||||
reader = PGReader(self.blockfile)
|
reader = PGReader(self.blockfile)
|
||||||
|
|
||||||
ips = reader.next()
|
ips = reader.next()
|
||||||
while ips:
|
while ips:
|
||||||
print "Blocking",ips
|
|
||||||
self.core.add_range_to_ip_filter(*ips)
|
self.core.add_range_to_ip_filter(*ips)
|
||||||
|
self.gtkprog.import_prog()
|
||||||
ips = reader.next()
|
ips = reader.next()
|
||||||
|
|
||||||
reader.close()
|
reader.close()
|
||||||
|
self.gtkprog.end_import()
|
||||||
|
|
||||||
# FIXME
|
self.gtkprog.stop()
|
||||||
#self.gtkprog.stop()
|
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
self.gtkconf.start()
|
self.gtkconf.start()
|
||||||
|
@ -88,7 +88,6 @@ class BlocklistImport:
|
||||||
self.core.reset_ip_filter()
|
self.core.reset_ip_filter()
|
||||||
|
|
||||||
def unload(self):
|
def unload(self):
|
||||||
#self.config.save_to_file(self.config_file)
|
|
||||||
self.core.reset_ip_filter()
|
self.core.reset_ip_filter()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -58,7 +58,7 @@ class GTKConfig(gtk.Dialog):
|
||||||
|
|
||||||
class GTKProgress(gtk.Dialog):
|
class GTKProgress(gtk.Dialog):
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
gtk.Dialog.__init__(self, title="Setting-Up Blocklist",
|
gtk.Dialog.__init__(self, title="Loading Blocklist",
|
||||||
flags=gtk.DIALOG_MODAL,
|
flags=gtk.DIALOG_MODAL,
|
||||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
|
||||||
# Setup
|
# Setup
|
||||||
|
@ -76,17 +76,40 @@ class GTKProgress(gtk.Dialog):
|
||||||
|
|
||||||
self.hide_all()
|
self.hide_all()
|
||||||
|
|
||||||
|
def start_download(self):
|
||||||
|
self.progress.set_text("Downloading")
|
||||||
|
self.update()
|
||||||
|
|
||||||
def download_prog(self, fract):
|
def download_prog(self, fract):
|
||||||
if fract > 1.0:
|
if fract > 1.0:
|
||||||
fract = 1.0
|
fract = 1.0
|
||||||
self.progress.set_fraction(fract)
|
self.progress.set_fraction(fract)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def start_import(self):
|
||||||
|
self.progress.set_text("Importing")
|
||||||
|
self.progress.set_pulse_step(0.0075)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def import_prog(self):
|
||||||
|
self.progress.pulse()
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def end_import(self):
|
||||||
|
self.progress.set_text("Complete")
|
||||||
|
self.progress.set_fraction(1.0)
|
||||||
|
self.update()
|
||||||
|
|
||||||
def cancel(self, dialog, response):
|
def cancel(self, dialog, response):
|
||||||
self.hide_all()
|
self.hide_all()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
print "showing all"
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
self.update()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.hide_all()
|
self.hide_all()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
while gtk.events_pending():
|
||||||
|
not gtk.main_iteration(block=True)
|
||||||
|
|
|
@ -406,6 +406,9 @@ class Manager:
|
||||||
|
|
||||||
# Queueing functions
|
# Queueing functions
|
||||||
|
|
||||||
|
def queue_top(self, unique_ID, enforce_queue=True):
|
||||||
|
self.state.queue.insert(0,self.state.queue.pop(self.get_queue_index(unique_ID)))
|
||||||
|
|
||||||
def queue_up(self, unique_ID, enforce_queue=True):
|
def queue_up(self, unique_ID, enforce_queue=True):
|
||||||
curr_index = self.get_queue_index(unique_ID)
|
curr_index = self.get_queue_index(unique_ID)
|
||||||
if curr_index > 0:
|
if curr_index > 0:
|
||||||
|
|
|
@ -51,6 +51,7 @@ class DelugeGTK:
|
||||||
gettext.install(APP, DIR)
|
gettext.install(APP, DIR)
|
||||||
|
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
self.update_queue = []
|
||||||
self.ipc_manager = ipc_manager.Manager(self)
|
self.ipc_manager = ipc_manager.Manager(self)
|
||||||
self.torrent_file_queue = []
|
self.torrent_file_queue = []
|
||||||
#Start the Deluge Manager:
|
#Start the Deluge Manager:
|
||||||
|
@ -105,17 +106,13 @@ class DelugeGTK:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
enable_plugins = self.config.get('enabled_plugins', str, default="").split(':')
|
|
||||||
|
|
||||||
for plugin in enable_plugins:
|
|
||||||
try:
|
|
||||||
self.plugins.enable_plugin(plugin)
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
self.apply_prefs()
|
self.apply_prefs()
|
||||||
self.load_window_geometry()
|
self.load_window_geometry()
|
||||||
self.manager.pe_settings(self.config.get("encout_state", int, default=common.EncState.enabled), self.config.get("encin_state", int, default=common.EncState.enabled), self.config.get("enclevel_type", int, default=common.EncLevel.both), self.config.get("pref_rc4", bool, default=True))
|
self.manager.pe_settings(self.config.get("encout_state", int, default=common.EncState.enabled), self.config.get("encin_state", int, default=common.EncState.enabled), self.config.get("enclevel_type", int, default=common.EncLevel.both), self.config.get("pref_rc4", bool, default=True))
|
||||||
|
|
||||||
|
# Load plugins after GTK is initialised
|
||||||
|
self.update_queue.append(self.load_plugins)
|
||||||
|
|
||||||
def external_add_torrent(self, torrent_file):
|
def external_add_torrent(self, torrent_file):
|
||||||
print "Ding!"
|
print "Ding!"
|
||||||
print "Got torrent externally:", os.path.basename(torrent_file)
|
print "Got torrent externally:", os.path.basename(torrent_file)
|
||||||
|
@ -158,6 +155,7 @@ class DelugeGTK:
|
||||||
"queue_up": self.q_torrent_up,
|
"queue_up": self.q_torrent_up,
|
||||||
"queue_down": self.q_torrent_down,
|
"queue_down": self.q_torrent_down,
|
||||||
"queue_bottom": self.q_to_bottom,
|
"queue_bottom": self.q_to_bottom,
|
||||||
|
"queue_top": self.q_to_top,
|
||||||
})
|
})
|
||||||
|
|
||||||
def build_tray_icon(self):
|
def build_tray_icon(self):
|
||||||
|
@ -264,6 +262,7 @@ class DelugeGTK:
|
||||||
"queue_up": self.q_torrent_up,
|
"queue_up": self.q_torrent_up,
|
||||||
"queue_down": self.q_torrent_down,
|
"queue_down": self.q_torrent_down,
|
||||||
"queue_bottom": self.q_to_bottom,
|
"queue_bottom": self.q_to_bottom,
|
||||||
|
"queue_top": self.q_to_top,
|
||||||
})
|
})
|
||||||
self.torrent_menu.connect("focus", self.torrent_menu_focus)
|
self.torrent_menu.connect("focus", self.torrent_menu_focus)
|
||||||
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
|
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
|
||||||
|
@ -657,8 +656,21 @@ class DelugeGTK:
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.manager.quit()
|
self.manager.quit()
|
||||||
|
|
||||||
|
def load_plugins(self):
|
||||||
|
enable_plugins = self.config.get('enabled_plugins', str, default="").split(':')
|
||||||
|
for plugin in enable_plugins:
|
||||||
|
try:
|
||||||
|
self.plugins.enable_plugin(plugin)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
## Call via a timer to update the interface
|
## Call via a timer to update the interface
|
||||||
def update(self):
|
def update(self):
|
||||||
|
self.update_queue.reverse()
|
||||||
|
while len(self.update_queue) > 0:
|
||||||
|
f = self.update_queue.pop()
|
||||||
|
f()
|
||||||
|
|
||||||
# We need to apply the queue changes
|
# We need to apply the queue changes
|
||||||
self.manager.apply_queue()
|
self.manager.apply_queue()
|
||||||
# Make sure that the interface still exists
|
# Make sure that the interface still exists
|
||||||
|
@ -1046,6 +1058,12 @@ class DelugeGTK:
|
||||||
self.manager.queue_bottom(torrent)
|
self.manager.queue_bottom(torrent)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def q_to_top(self, widget):
|
||||||
|
torrent = self.get_selected_torrent()
|
||||||
|
if torrent is not None:
|
||||||
|
self.manager.queue_top(torrent)
|
||||||
|
self.update()
|
||||||
|
|
||||||
def toolbar_toggle(self, widget):
|
def toolbar_toggle(self, widget):
|
||||||
if widget.get_active():
|
if widget.get_active():
|
||||||
self.wtree.get_widget("tb_left").show()
|
self.wtree.get_widget("tb_left").show()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue