for blocklist, fixes cancelling downloads and not being able to update broken configurations - tarka/steve

This commit is contained in:
Marcos Pinto 2007-06-17 14:02:17 +00:00
parent 1d6984b0ba
commit fa0a4813a6
3 changed files with 16 additions and 6 deletions

View File

@ -44,6 +44,7 @@ class BlocklistImport:
self.interface = interface self.interface = interface
self.gtkconf = GTKConfig(self) self.gtkconf = GTKConfig(self)
self.gtkprog = GTKProgress(self) self.gtkprog = GTKProgress(self)
self.cancelled = False
self.blockfile = deluge.common.CONFIG_DIR + "/blocklist.cache" self.blockfile = deluge.common.CONFIG_DIR + "/blocklist.cache"
@ -83,7 +84,7 @@ class BlocklistImport:
reader = readers[ltype][1](self.blockfile) reader = readers[ltype][1](self.blockfile)
ips = reader.next() ips = reader.next()
while ips: while ips and not self.cancelled:
self.core.add_range_to_ip_filter(*ips) self.core.add_range_to_ip_filter(*ips)
self.gtkprog.import_prog() self.gtkprog.import_prog()
ips = reader.next() ips = reader.next()

View File

@ -60,7 +60,7 @@ class GTKConfig(gtk.Dialog):
if response != gtk.RESPONSE_ACCEPT: if response != gtk.RESPONSE_ACCEPT:
self.cancel(dialog) self.cancel(dialog)
return return
ls = self.listtype.get_model() ls = self.listtype.get_model()
ltype = ls[self.listtype.get_active()][1] ltype = ls[self.listtype.get_active()][1]
url = self.url.get_text() url = self.url.get_text()
@ -68,8 +68,8 @@ class GTKConfig(gtk.Dialog):
self.plugin.setconfig(url, los, ltype) self.plugin.setconfig(url, los, ltype)
def cancel(self, dialog, response): def cancel(self, dialog):
self.hide_all() self.hide_all()
def start(self): def start(self):
@ -81,6 +81,8 @@ class GTKProgress(gtk.Dialog):
gtk.Dialog.__init__(self, title="Loading 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))
self.plugin = plugin
# Setup # Setup
self.set_border_width(12) self.set_border_width(12)
self.vbox.set_spacing(6) self.vbox.set_spacing(6)
@ -92,6 +94,7 @@ class GTKProgress(gtk.Dialog):
self.progress = gtk.ProgressBar() self.progress = gtk.ProgressBar()
self.vbox.pack_start(self.progress) self.vbox.pack_start(self.progress)
self.connect('response', self.response)
self.connect('close', self.cancel) self.connect('close', self.cancel)
self.hide_all() self.hide_all()
@ -120,7 +123,13 @@ class GTKProgress(gtk.Dialog):
self.progress.set_fraction(1.0) self.progress.set_fraction(1.0)
self.update() self.update()
def cancel(self, dialog, response):
def response(self, dialog, response):
self.cancel(dialog)
def cancel(self, dialog):
print "Cancelling"
self.plugin.cancelled = True
self.hide_all() self.hide_all()
def start(self): def start(self):

View File

@ -200,9 +200,9 @@ class PluginDlg:
plugin_value = not self.store.get_value(plugin_iter, 1) plugin_value = not self.store.get_value(plugin_iter, 1)
self.store.set_value(plugin_iter, 1, plugin_value) self.store.set_value(plugin_iter, 1, plugin_value)
if plugin_value: if plugin_value:
self.plugins.enable_plugin(plugin_name)
config = self.plugins.configurable_plugin(plugin_name) config = self.plugins.configurable_plugin(plugin_name)
self.glade.get_widget("plugin_conf").set_sensitive(config) self.glade.get_widget("plugin_conf").set_sensitive(config)
self.plugins.enable_plugin(plugin_name)
else: else:
self.plugins.disable_plugin(plugin_name) self.plugins.disable_plugin(plugin_name)
self.glade.get_widget("plugin_conf").set_sensitive(False) self.glade.get_widget("plugin_conf").set_sensitive(False)