mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 20:14:13 +00:00
Improve Blocklist preferences page
This commit is contained in:
parent
48ab9d7522
commit
dd4fc26877
@ -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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.5 on Fri Jul 18 11:06:25 2008 -->
|
||||
<!--Generated with glade3 3.4.5 on Tue Jul 29 00:52:51 2008 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="window1">
|
||||
<child>
|
||||
@ -75,8 +75,6 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
@ -97,7 +95,6 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
@ -117,47 +114,19 @@
|
||||
<child>
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_rows">1</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="column_spacing">5</property>
|
||||
<property name="row_spacing">5</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<property name="visible">True</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>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Timeout to download new list:</property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Max attempts to download list:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@ -176,59 +145,12 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkSpinButton" id="spin_timeout">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">180 0 9999 1 10 10</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>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkSpinButton" id="spin_attempts">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">3 1 100 1 10 10</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>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</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>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Seconds</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
@ -270,7 +192,6 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
@ -283,92 +204,46 @@
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment3">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="xscale">0</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox3">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<widget class="GtkButton" id="button_check_download">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip" translatable="yes">Download the blocklist file if necessary and import the file.</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_button_check_download_clicked"/>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_download">
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_button_download_clicked"/>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<widget class="GtkImage" id="image_download">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image_download">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Download List</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Check Download and Import</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_import">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_button_import_clicked"/>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image_import">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label7">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Import List</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -376,6 +251,48 @@
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_force_download">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip" translatable="yes">Download a new blocklist file and import it.</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_button_force_download_clicked"/>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image_import">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label7">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Force Download and Import</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
@ -393,11 +310,154 @@
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkFrame" id="frame4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment4">
|
||||
<property name="visible">True</property>
|
||||
<property name="top_padding">5</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox4">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkProgressBar" id="progressbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table_info">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">5</property>
|
||||
<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>
|
||||
</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_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_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>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label16">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Type:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label15">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Date:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">File Size:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Info</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user