diff --git a/plugins/BlocklistImport/__init__.py b/plugins/BlocklistImport/__init__.py index ee4ad5060..a693c9b43 100644 --- a/plugins/BlocklistImport/__init__.py +++ b/plugins/BlocklistImport/__init__.py @@ -44,6 +44,7 @@ class BlocklistImport: self.interface = interface self.gtkconf = GTKConfig(self) self.gtkprog = GTKProgress(self) + self.cancelled = False self.blockfile = deluge.common.CONFIG_DIR + "/blocklist.cache" @@ -83,7 +84,7 @@ class BlocklistImport: reader = readers[ltype][1](self.blockfile) ips = reader.next() - while ips: + while ips and not self.cancelled: self.core.add_range_to_ip_filter(*ips) self.gtkprog.import_prog() ips = reader.next() diff --git a/plugins/BlocklistImport/ui.py b/plugins/BlocklistImport/ui.py index 6495aa293..164e3fc65 100644 --- a/plugins/BlocklistImport/ui.py +++ b/plugins/BlocklistImport/ui.py @@ -60,7 +60,7 @@ class GTKConfig(gtk.Dialog): if response != gtk.RESPONSE_ACCEPT: self.cancel(dialog) return - + ls = self.listtype.get_model() ltype = ls[self.listtype.get_active()][1] url = self.url.get_text() @@ -68,8 +68,8 @@ class GTKConfig(gtk.Dialog): self.plugin.setconfig(url, los, ltype) - - def cancel(self, dialog, response): + + def cancel(self, dialog): self.hide_all() def start(self): @@ -81,6 +81,8 @@ class GTKProgress(gtk.Dialog): gtk.Dialog.__init__(self, title="Loading Blocklist", flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) + self.plugin = plugin + # Setup self.set_border_width(12) self.vbox.set_spacing(6) @@ -92,6 +94,7 @@ class GTKProgress(gtk.Dialog): self.progress = gtk.ProgressBar() self.vbox.pack_start(self.progress) + self.connect('response', self.response) self.connect('close', self.cancel) self.hide_all() @@ -120,7 +123,13 @@ class GTKProgress(gtk.Dialog): self.progress.set_fraction(1.0) 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() def start(self): diff --git a/src/dialogs.py b/src/dialogs.py index e8a8af3e1..d8776ceac 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -200,9 +200,9 @@ class PluginDlg: plugin_value = not self.store.get_value(plugin_iter, 1) self.store.set_value(plugin_iter, 1, plugin_value) if plugin_value: - self.plugins.enable_plugin(plugin_name) config = self.plugins.configurable_plugin(plugin_name) self.glade.get_widget("plugin_conf").set_sensitive(config) + self.plugins.enable_plugin(plugin_name) else: self.plugins.disable_plugin(plugin_name) self.glade.get_widget("plugin_conf").set_sensitive(False)