connect queue to top
This commit is contained in:
parent
ac99ef7d26
commit
525526316c
|
@ -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="label" translatable="yes">Top</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="queue_top"/>
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="menu-item-image10">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -49,30 +49,30 @@ class BlocklistImport:
|
|||
|
||||
def loadlist(self, fetch=False):
|
||||
# FIXME
|
||||
#self.gtkprog.start()
|
||||
self.gtkprog.start()
|
||||
|
||||
# Attempt initial import
|
||||
# FIXME: Make async
|
||||
if fetch:
|
||||
print "Downloading blocklist..."
|
||||
self.gtkprog.start_download()
|
||||
filename, headers = urllib.urlretrieve(self.config.get('url'),
|
||||
filename=self.blockfile,
|
||||
reporthook=self._download_update)
|
||||
print "Done"
|
||||
|
||||
self.gtkprog.start_import()
|
||||
|
||||
self.core.reset_ip_filter()
|
||||
reader = PGReader(self.blockfile)
|
||||
|
||||
ips = reader.next()
|
||||
while ips:
|
||||
print "Blocking",ips
|
||||
self.core.add_range_to_ip_filter(*ips)
|
||||
self.gtkprog.import_prog()
|
||||
ips = reader.next()
|
||||
|
||||
reader.close()
|
||||
self.gtkprog.end_import()
|
||||
|
||||
# FIXME
|
||||
#self.gtkprog.stop()
|
||||
self.gtkprog.stop()
|
||||
|
||||
def configure(self):
|
||||
self.gtkconf.start()
|
||||
|
@ -88,7 +88,6 @@ class BlocklistImport:
|
|||
self.core.reset_ip_filter()
|
||||
|
||||
def unload(self):
|
||||
#self.config.save_to_file(self.config_file)
|
||||
self.core.reset_ip_filter()
|
||||
|
||||
def update(self):
|
||||
|
|
|
@ -58,7 +58,7 @@ class GTKConfig(gtk.Dialog):
|
|||
|
||||
class GTKProgress(gtk.Dialog):
|
||||
def __init__(self, plugin):
|
||||
gtk.Dialog.__init__(self, title="Setting-Up Blocklist",
|
||||
gtk.Dialog.__init__(self, title="Loading Blocklist",
|
||||
flags=gtk.DIALOG_MODAL,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
|
||||
# Setup
|
||||
|
@ -76,17 +76,40 @@ class GTKProgress(gtk.Dialog):
|
|||
|
||||
self.hide_all()
|
||||
|
||||
def start_download(self):
|
||||
self.progress.set_text("Downloading")
|
||||
self.update()
|
||||
|
||||
def download_prog(self, fract):
|
||||
if fract > 1.0:
|
||||
fract = 1.0
|
||||
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):
|
||||
self.hide_all()
|
||||
|
||||
def start(self):
|
||||
print "showing all"
|
||||
self.show_all()
|
||||
self.update()
|
||||
|
||||
def stop(self):
|
||||
self.hide_all()
|
||||
|
||||
def update(self):
|
||||
while gtk.events_pending():
|
||||
not gtk.main_iteration(block=True)
|
||||
|
|
|
@ -406,6 +406,9 @@ class Manager:
|
|||
|
||||
# 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):
|
||||
curr_index = self.get_queue_index(unique_ID)
|
||||
if curr_index > 0:
|
||||
|
|
|
@ -51,6 +51,7 @@ class DelugeGTK:
|
|||
gettext.install(APP, DIR)
|
||||
|
||||
self.is_running = False
|
||||
self.update_queue = []
|
||||
self.ipc_manager = ipc_manager.Manager(self)
|
||||
self.torrent_file_queue = []
|
||||
#Start the Deluge Manager:
|
||||
|
@ -105,17 +106,13 @@ class DelugeGTK:
|
|||
except KeyError:
|
||||
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.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))
|
||||
|
||||
# Load plugins after GTK is initialised
|
||||
self.update_queue.append(self.load_plugins)
|
||||
|
||||
def external_add_torrent(self, torrent_file):
|
||||
print "Ding!"
|
||||
print "Got torrent externally:", os.path.basename(torrent_file)
|
||||
|
@ -158,6 +155,7 @@ class DelugeGTK:
|
|||
"queue_up": self.q_torrent_up,
|
||||
"queue_down": self.q_torrent_down,
|
||||
"queue_bottom": self.q_to_bottom,
|
||||
"queue_top": self.q_to_top,
|
||||
})
|
||||
|
||||
def build_tray_icon(self):
|
||||
|
@ -264,6 +262,7 @@ class DelugeGTK:
|
|||
"queue_up": self.q_torrent_up,
|
||||
"queue_down": self.q_torrent_down,
|
||||
"queue_bottom": self.q_to_bottom,
|
||||
"queue_top": self.q_to_top,
|
||||
})
|
||||
self.torrent_menu.connect("focus", self.torrent_menu_focus)
|
||||
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
|
||||
|
@ -656,9 +655,22 @@ class DelugeGTK:
|
|||
gtk.main()
|
||||
except KeyboardInterrupt:
|
||||
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
|
||||
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
|
||||
self.manager.apply_queue()
|
||||
# Make sure that the interface still exists
|
||||
|
@ -1045,6 +1057,12 @@ class DelugeGTK:
|
|||
if torrent is not None:
|
||||
self.manager.queue_bottom(torrent)
|
||||
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):
|
||||
if widget.get_active():
|
||||
|
|
Loading…
Reference in New Issue