Blocklist now displays a tick when up to date

This commit is contained in:
John Garland 2009-02-14 03:26:33 +00:00
parent b73e26344c
commit 5bd5db4f16
3 changed files with 150 additions and 121 deletions

View File

@ -68,6 +68,7 @@ class Core(CorePluginBase):
self.is_downloading = False self.is_downloading = False
self.is_importing = False self.is_importing = False
self.has_imported = False self.has_imported = False
self.up_to_date = False
self.num_blocked = 0 self.num_blocked = 0
self.file_progress = 0.0 self.file_progress = 0.0
@ -126,6 +127,7 @@ class Core(CorePluginBase):
else: else:
status["state"] = "Idle" status["state"] = "Idle"
status["up_to_date"] = self.up_to_date
status["num_blocked"] = self.num_blocked status["num_blocked"] = self.num_blocked
status["file_progress"] = self.file_progress status["file_progress"] = self.file_progress
status["file_type"] = self.config["file_type"] status["file_type"] = self.config["file_type"]
@ -248,6 +250,10 @@ class Core(CorePluginBase):
def need_new_blocklist(self): def need_new_blocklist(self):
"""Returns True if a new blocklist file should be downloaded""" """Returns True if a new blocklist file should be downloaded"""
# Assume blocklist is not up to date
self.up_to_date = False
# Check to see if we've just downloaded a new blocklist # Check to see if we've just downloaded a new blocklist
if os.path.exists(deluge.configmanager.get_config_dir("blocklist.download")): if os.path.exists(deluge.configmanager.get_config_dir("blocklist.download")):
log.debug("New blocklist waiting to be imported") log.debug("New blocklist waiting to be imported")
@ -296,5 +302,6 @@ class Core(CorePluginBase):
# Update last modified time of blocklist # Update last modified time of blocklist
os.utime(deluge.configmanager.get_config_dir("blocklist.cache"), None) os.utime(deluge.configmanager.get_config_dir("blocklist.cache"), None)
self.up_to_date = True
log.debug("Blocklist is up to date") log.debug("Blocklist is up to date")
return False return False

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Fri Nov 28 19:28:02 2008 --> <!--Generated with glade3 3.4.5 on Sat Feb 14 14:23:56 2009 -->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<child> <child>
@ -118,12 +118,14 @@
<property name="column_spacing">5</property> <property name="column_spacing">5</property>
<property name="row_spacing">5</property> <property name="row_spacing">5</property>
<child> <child>
<widget class="GtkLabel" id="label4"> <widget class="GtkLabel" id="label8">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Check for new list every:</property> <property name="label" translatable="yes">Days</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -142,14 +144,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label8"> <widget class="GtkLabel" id="label4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Days</property> <property name="label" translatable="yes">Check for new list every:</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -206,6 +206,9 @@
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xscale">0</property> <property name="xscale">0</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child> <child>
<widget class="GtkVBox" id="vbox3"> <widget class="GtkVBox" id="vbox3">
<property name="visible">True</property> <property name="visible">True</property>
@ -218,7 +221,7 @@
<property name="response_id">0</property> <property name="response_id">0</property>
<signal name="clicked" handler="on_button_check_download_clicked"/> <signal name="clicked" handler="on_button_check_download_clicked"/>
<child> <child>
<widget class="GtkHBox" id="hbox3"> <widget class="GtkHBox" id="hbox4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
@ -259,7 +262,7 @@
<property name="response_id">0</property> <property name="response_id">0</property>
<signal name="clicked" handler="on_button_force_download_clicked"/> <signal name="clicked" handler="on_button_force_download_clicked"/>
<child> <child>
<widget class="GtkHBox" id="hbox4"> <widget class="GtkHBox" id="hbox5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
@ -294,6 +297,19 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkImage" id="image_up_to_date">
<property name="tooltip" translatable="yes">Blocklist is up to date</property>
<property name="yalign">0.15000000596046448</property>
<property name="xpad">2</property>
<property name="stock">gtk-yes</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget> </widget>
</child> </child>
<child> <child>
@ -338,24 +354,60 @@
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">5</property> <property name="column_spacing">5</property>
<child> <child>
<widget class="GtkLabel" id="label14"> <widget class="GtkLabel" id="label_url">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">File Size:</property>
</widget> </widget>
<packing> <packing>
<property name="x_options">GTK_FILL</property> <property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label15"> <widget class="GtkLabel" id="label_type">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Date:</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_modified">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_filesize">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">URL:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
@ -372,61 +424,25 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label17"> <widget class="GtkLabel" id="label15">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">URL:</property> <property name="label" translatable="yes">Date:</property>
</widget> </widget>
<packing> <packing>
<property name="top_attach">3</property> <property name="top_attach">1</property>
<property name="bottom_attach">4</property> <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label_filesize"> <widget class="GtkLabel" id="label14">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">File Size:</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="x_options">GTK_FILL</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_modified">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_type">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_url">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing> </packing>
</child> </child>
</widget> </widget>

View File

@ -70,6 +70,7 @@ class GtkUI(ui.UI):
self.table_info.hide() self.table_info.hide()
self.glade.get_widget("button_check_download").set_sensitive(False) self.glade.get_widget("button_check_download").set_sensitive(False)
self.glade.get_widget("button_force_download").set_sensitive(False) self.glade.get_widget("button_force_download").set_sensitive(False)
self.glade.get_widget("image_up_to_date").hide()
self.status_item.set_text( self.status_item.set_text(
"Downloading %.2f%%" % (status["file_progress"] * 100)) "Downloading %.2f%%" % (status["file_progress"] * 100))
@ -81,6 +82,7 @@ class GtkUI(ui.UI):
self.table_info.hide() self.table_info.hide()
self.glade.get_widget("button_check_download").set_sensitive(False) self.glade.get_widget("button_check_download").set_sensitive(False)
self.glade.get_widget("button_force_download").set_sensitive(False) self.glade.get_widget("button_force_download").set_sensitive(False)
self.glade.get_widget("image_up_to_date").hide()
self.status_item.set_text( self.status_item.set_text(
"Importing " + str(status["num_blocked"])) "Importing " + str(status["num_blocked"]))
@ -92,6 +94,10 @@ class GtkUI(ui.UI):
self.progress_bar.hide() self.progress_bar.hide()
self.glade.get_widget("button_check_download").set_sensitive(True) self.glade.get_widget("button_check_download").set_sensitive(True)
self.glade.get_widget("button_force_download").set_sensitive(True) self.glade.get_widget("button_force_download").set_sensitive(True)
if status["up_to_date"]:
self.glade.get_widget("image_up_to_date").show()
else:
self.glade.get_widget("image_up_to_date").hide()
self.table_info.show() self.table_info.show()
self.status_item.set_text(str(status["num_blocked"])) self.status_item.set_text(str(status["num_blocked"]))