diff --git a/ChangeLog b/ChangeLog index 116aba561..07cd261ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ Deluge 0.9.05 - "1.0.0_RC5" (In Development) Core: * Fix deluged running with ssh X forwarding by removing the Gnome lib import + Plugins: + * Improve the Blocklist plugin preferences page. + Deluge 0.9.04 - "1.0.0_RC4" (29 July 2008) Core: * Fix building with gcc 4.3 diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index caefb8119..87ff292e3 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -52,7 +52,11 @@ DEFAULT_PREFS = { "check_after_days": 2, "listtype": "gzmule", "timeout": 180, - "try_times": 3 + "try_times": 3, + "file_type": "", + "file_url": "", + "file_date": "", + "file_size": 0, } FORMATS = { @@ -93,14 +97,14 @@ class Core(CorePluginBase): pass ## Exported RPC methods ### - def export_download(self): + def export_download(self, _import=False): """Download the blocklist specified in the config as url""" - self.download_blocklist() + self.download_blocklist(_import) - def export_import(self, download=False): + def export_import(self, download=False, force=False): """Import the blocklist from the blocklist.cache, if load is True, then it will download the blocklist file if needed.""" - threading.Thread(target=self.import_blocklist, kwargs={"download": download}).start() + threading.Thread(target=self.import_blocklist, kwargs={"download": download, "force": force}).start() def export_get_config(self): """Returns the config dictionary""" @@ -123,6 +127,10 @@ class Core(CorePluginBase): status["num_blocked"] = self.num_blocked status["file_progress"] = self.file_progress + status["file_type"] = self.config["file_type"] + status["file_url"] = self.config["file_url"] + status["file_size"] = self.config["file_size"] + status["file_date"] = self.config["file_date"] return status @@ -134,13 +142,13 @@ class Core(CorePluginBase): if load: self.export_import() - def import_blocklist(self, download=False): + def import_blocklist(self, download=False, force=False): """Imports the downloaded blocklist into the session""" if self.is_downloading: return if download: - if self.need_new_blocklist(): + if force or self.need_new_blocklist(): self.download_blocklist(True) return @@ -191,7 +199,10 @@ class Core(CorePluginBase): return False def on_retrieve_data(count, block_size, total_blocks): - self.file_progress = float(count * block_size) / total_blocks + fp = float(count * block_size) / total_blocks + if fp > 1.0: + fp = 1.0 + self.file_progress = fp import socket socket.setdefaulttimeout(self.config["timeout"]) @@ -208,6 +219,13 @@ class Core(CorePluginBase): continue else: log.debug("Blocklist successfully downloaded..") + # Set information about the file + self.config["file_type"] = self.config["listtype"] + self.config["file_url"] = self.config["url"] + list_stats = os.stat(deluge.configmanager.get_config_dir("blocklist.cache")) + self.config["file_date"] = datetime.datetime.fromtimestamp(list_stats.st_mtime).ctime() + self.config["file_size"] = list_size = list_stats.st_size + gobject.idle_add(_call_callback, callback, load) return diff --git a/deluge/plugins/blocklist/blocklist/data/blocklist_pref.glade b/deluge/plugins/blocklist/blocklist/data/blocklist_pref.glade index 77574b2f5..44931508d 100644 --- a/deluge/plugins/blocklist/blocklist/data/blocklist_pref.glade +++ b/deluge/plugins/blocklist/blocklist/data/blocklist_pref.glade @@ -1,6 +1,6 @@ - + @@ -75,8 +75,6 @@ - False - False 1 @@ -97,7 +95,6 @@ - False False @@ -117,47 +114,19 @@ True - 3 + 1 3 5 5 - - - - + True 0 - Check for new list every: + Days - GTK_FILL - - - - - - True - 0 - Timeout to download new list: - True - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Max attempts to download list: - - - 2 - 3 + 2 + 3 GTK_FILL @@ -176,59 +145,12 @@ - - True - True - 180 0 9999 1 10 10 - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - - True - True - 3 1 100 1 10 10 - - - 1 - 2 - 2 - 3 - GTK_FILL - - - - - + True 0 - Days + Check for new list every: - 2 - 3 - GTK_FILL - - - - - - True - 0 - Seconds - - - 2 - 3 - 1 - 2 GTK_FILL @@ -270,7 +192,6 @@ - False False 1 @@ -283,92 +204,46 @@ True + 0 + 0 12 True - + True - GTK_BUTTONBOX_SPREAD + True + True + Download the blocklist file if necessary and import the file. + 0 + - + True - True - True - 0 - + 5 - + True - 5 - - - True - - - False - False - - - - - True - Download List - - - False - False - 1 - - + gtk-missing-image + + False + False + + + + + True + Check Download and Import + + + False + False + 1 + - - False - False - - - - - True - True - True - 0 - - - - True - 5 - - - True - - - False - False - - - - - True - Import List - - - False - False - 1 - - - - - - - False - False - 1 - @@ -376,6 +251,48 @@ False + + + True + True + True + Download a new blocklist file and import it. + 0 + + + + True + 5 + + + True + gtk-missing-image + + + False + False + + + + + True + Force Download and Import + + + False + False + 1 + + + + + + + False + False + 1 + + @@ -393,11 +310,154 @@ - False False 2 + + + True + 0 + GTK_SHADOW_NONE + + + True + 5 + 12 + + + True + + + True + + + + + + True + 4 + 2 + 5 + + + True + 0 + + + 1 + 2 + 3 + 4 + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + 0 + + + 1 + 2 + 1 + 2 + + + + + True + 0 + + + 1 + 2 + + + + + True + 0 + URL: + + + 3 + 4 + GTK_FILL + + + + + True + 0 + Type: + + + 2 + 3 + GTK_FILL + + + + + True + 0 + Date: + + + 1 + 2 + GTK_FILL + + + + + True + 0 + File Size: + + + GTK_FILL + + + + + False + False + 1 + + + + + + + + + True + <b>Info</b> + True + + + label_item + + + + + False + 3 + + diff --git a/deluge/plugins/blocklist/blocklist/gtkui.py b/deluge/plugins/blocklist/blocklist/gtkui.py index b90b35062..5aa8f7ea1 100644 --- a/deluge/plugins/blocklist/blocklist/gtkui.py +++ b/deluge/plugins/blocklist/blocklist/gtkui.py @@ -36,6 +36,7 @@ import gtk from deluge.log import LOG as log from deluge.ui.client import aclient as client import deluge.component as component +import deluge.common import ui from core import FORMATS @@ -75,13 +76,42 @@ class GtkUI(ui.UI): def update(self): def _on_get_status(status): if status["state"] == "Downloading": + self.table_info.hide() + self.glade.get_widget("button_check_download").set_sensitive(False) + self.glade.get_widget("button_force_download").set_sensitive(False) + self.status_item.set_text( "Downloading %.2f%%" % (status["file_progress"] * 100)) + self.progress_bar.set_text("Downloading %.2f%%" % (status["file_progress"] * 100)) + self.progress_bar.set_fraction(status["file_progress"]) + self.progress_bar.show() + elif status["state"] == "Importing": + self.table_info.hide() + self.glade.get_widget("button_check_download").set_sensitive(False) + self.glade.get_widget("button_force_download").set_sensitive(False) + self.status_item.set_text( "Importing " + str(status["num_blocked"])) + self.progress_bar.set_text("Importing %s" % (status["num_blocked"])) + self.progress_bar.pulse() + self.progress_bar.show() + elif status["state"] == "Idle": + self.progress_bar.hide() + self.glade.get_widget("button_check_download").set_sensitive(True) + self.glade.get_widget("button_force_download").set_sensitive(True) + + self.table_info.show() self.status_item.set_text(str(status["num_blocked"])) + self.glade.get_widget("label_filesize").set_text( + deluge.common.fsize(status["file_size"])) + self.glade.get_widget("label_modified").set_text( + str(status["file_date"])) + self.glade.get_widget("label_type").set_text( + FORMATS[status["file_type"]][0]) + self.glade.get_widget("label_url").set_text( + status["file_url"]) client.blocklist_get_status(_on_get_status) @@ -97,13 +127,7 @@ class GtkUI(ui.UI): self.glade.get_widget("spin_check_days").set_value( config["check_after_days"]) - - self.glade.get_widget("spin_timeout").set_value( - config["timeout"]) - - self.glade.get_widget("spin_attempts").set_value( - config["try_times"]) - + self.glade.get_widget("chk_import_on_start").set_active( config["load_on_start"]) @@ -115,16 +139,14 @@ class GtkUI(ui.UI): get_model()[self.glade.get_widget("combobox_types").get_active()][1] config["url"] = self.glade.get_widget("entry_url").get_text() config["check_after_days"] = self.glade.get_widget("spin_check_days").get_value_as_int() - config["timeout"] = self.glade.get_widget("spin_timeout").get_value_as_int() - config["try_times"] = self.glade.get_widget("spin_attempts").get_value_as_int() config["load_on_start"] = self.glade.get_widget("chk_import_on_start").get_active() client.blocklist_set_config(None, config) - def _on_button_download_clicked(self, widget): - client.blocklist_download(None) + def _on_button_check_download_clicked(self, widget): + client.blocklist_import(None, True, False) - def _on_button_import_clicked(self, widget): - client.blocklist_import(None) + def _on_button_force_download_clicked(self, widget): + client.blocklist_import(None, True, True) def _on_status_item_clicked(self, widget, event): component.get("Preferences").show("Blocklist") @@ -133,10 +155,17 @@ class GtkUI(ui.UI): """Initializes the preferences page and adds it to the preferences dialog""" # Load the preferences page self.glade = gtk.glade.XML(self.get_resource("blocklist_pref.glade")) - + + self.progress_bar = self.glade.get_widget("progressbar") + self.table_info = self.glade.get_widget("table_info") + + # Hide the progress bar initially + self.progress_bar.hide() + self.table_info.show() + self.glade.signal_autoconnect({ - "on_button_download_clicked": self._on_button_download_clicked, - "on_button_import_clicked": self._on_button_import_clicked + "on_button_check_download_clicked": self._on_button_check_download_clicked, + "on_button_force_download_clicked": self._on_button_force_download_clicked }) # Setup types combobox