[Blocklist] Update gtkui from libglade to gtkbuilder

This commit is contained in:
DjLegolas 2017-08-06 13:03:55 +03:00 committed by Calum Lind
parent 9b580a87fa
commit f0316d3e31
2 changed files with 168 additions and 181 deletions

View File

@ -1,36 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="window1">
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<widget class="GtkVBox" id="blocklist_prefs_box">
<object class="GtkVBox" id="blocklist_prefs_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkFrame" id="frame1">
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkHBox" id="hbox2">
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label3">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">URL:</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -38,7 +45,7 @@
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_url">
<object class="GtkEntry" id="entry_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
@ -46,30 +53,27 @@
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label1">
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">5</property>
<property name="label" translatable="yes">&lt;b&gt;General&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -77,72 +81,72 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox1">
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkTable" id="table1">
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">3</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkLabel" id="label8">
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Days</property>
</widget>
</object>
<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>
<property name="y_options"/>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_check_days">
<object class="GtkSpinButton" id="spin_check_days">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<property name="adjustment">1 1 100 1 10 0</property>
</widget>
<property name="adjustment">adjustment1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_options"/>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Check for new list every:</property>
</widget>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
<property name="y_options"/>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -150,37 +154,33 @@
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_import_on_start">
<object class="GtkCheckButton" id="chk_import_on_start">
<property name="label" translatable="yes">Import blocklist on startup</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label10">
<child type="label">
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">5</property>
<property name="label" translatable="yes">&lt;b&gt;Settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -188,45 +188,44 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkHBox" id="hbox3">
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkVBox" id="vbox3">
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkButton" id="button_check_download">
<object class="GtkButton" id="button_check_download">
<property name="visible">True</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="use_action_appearance">False</property>
<signal name="clicked" handler="on_button_check_download_clicked" />
<property name="tooltip_text" translatable="yes">Download the blocklist file if necessary and import the file.</property>
<signal name="clicked" handler="on_button_check_download_clicked" swapped="no"/>
<child>
<widget class="GtkHBox" id="hbox4">
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image_download">
<object class="GtkImage" id="image_download">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -234,20 +233,20 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Check Download and Import</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -255,24 +254,23 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="button_force_download">
<object 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="use_action_appearance">False</property>
<signal name="clicked" handler="on_button_force_download_clicked" />
<property name="tooltip_text" translatable="yes">Download a new blocklist file and import it.</property>
<signal name="clicked" handler="on_button_force_download_clicked" swapped="no"/>
<child>
<widget class="GtkHBox" id="hbox5">
<object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkImage" id="image_import">
<object class="GtkImage" id="image_import">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -280,27 +278,27 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label7">
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Force Download and Import</property>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
@ -308,36 +306,33 @@
</packing>
</child>
<child>
<widget class="GtkImage" id="image_up_to_date">
<object class="GtkImage" id="image_up_to_date">
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Blocklist is up to date</property>
<property name="tooltip_text" 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>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label11">
<child type="label">
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">5</property>
<property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -345,26 +340,26 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame4">
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox4">
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkProgressBar" id="progressbar">
<object class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
@ -372,18 +367,18 @@
</packing>
</child>
<child>
<widget class="GtkTable" id="table_info">
<object class="GtkTable" id="table_info">
<property name="visible">True</property>
<property name="can_focus">False</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">
<object class="GtkLabel" id="label_url">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</widget>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
@ -392,11 +387,11 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_type">
<object class="GtkLabel" id="label_type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</widget>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
@ -405,11 +400,11 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_modified">
<object class="GtkLabel" id="label_modified">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</widget>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
@ -418,23 +413,23 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_filesize">
<object class="GtkLabel" id="label_filesize">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</widget>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<object class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">URL:</property>
</widget>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
@ -442,12 +437,12 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Type:</property>
</widget>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
@ -455,12 +450,12 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Date:</property>
</widget>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
@ -468,39 +463,36 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">File Size:</property>
</widget>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label13">
<child type="label">
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Info&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -508,35 +500,35 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="whitelist_frame">
<object class="GtkFrame" id="whitelist_frame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkHBox" id="hbox1">
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<widget class="GtkTreeView" id="whitelist_treeview">
<object class="GtkTreeView" id="whitelist_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
</widget>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
@ -544,21 +536,20 @@
</packing>
</child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox1">
<object class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<property name="layout_style">start</property>
<child>
<widget class="GtkButton" id="whitelist_add">
<object class="GtkButton" id="whitelist_add">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_whitelist_add_clicked" />
</widget>
<signal name="clicked" handler="on_whitelist_add_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@ -566,51 +557,47 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="whitelist_delete">
<object class="GtkButton" id="whitelist_delete">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_whitelist_remove_clicked" />
</widget>
<signal name="clicked" handler="on_whitelist_remove_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</object>
</child>
<child>
<widget class="GtkLabel" id="label2">
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Whitelist&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</object>
</child>
</widget>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</widget>
</object>
</child>
</widget>
</glade-interface>
</object>
</interface>

View File

@ -13,7 +13,6 @@ import logging
from datetime import datetime
import gtk
import gtk.glade
import deluge.common
import deluge.component as component
@ -63,9 +62,9 @@ class GtkUI(GtkPluginBase):
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.glade.get_widget('image_up_to_date').hide()
self.builder.get_object('button_check_download').set_sensitive(False)
self.builder.get_object('button_force_download').set_sensitive(False)
self.builder.get_object('image_up_to_date').hide()
self.status_item.set_text(
'Downloading %.2f%%' % (status['file_progress'] * 100))
@ -75,9 +74,9 @@ class GtkUI(GtkPluginBase):
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.glade.get_widget('image_up_to_date').hide()
self.builder.get_object('button_check_download').set_sensitive(False)
self.builder.get_object('button_force_download').set_sensitive(False)
self.builder.get_object('image_up_to_date').hide()
self.status_item.set_text(
'Importing ' + str(status['num_blocked']))
@ -87,22 +86,22 @@ class GtkUI(GtkPluginBase):
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.builder.get_object('button_check_download').set_sensitive(True)
self.builder.get_object('button_force_download').set_sensitive(True)
if status['up_to_date']:
self.glade.get_widget('image_up_to_date').show()
self.builder.get_object('image_up_to_date').show()
else:
self.glade.get_widget('image_up_to_date').hide()
self.builder.get_object('image_up_to_date').hide()
self.table_info.show()
self.status_item.set_text('%(num_blocked)s/%(num_whited)s' % status)
self.glade.get_widget('label_filesize').set_text(
self.builder.get_object('label_filesize').set_text(
deluge.common.fsize(status['file_size']))
self.glade.get_widget('label_modified').set_text(
self.builder.get_object('label_modified').set_text(
datetime.fromtimestamp(status['file_date']).strftime('%c'))
self.glade.get_widget('label_type').set_text(status['file_type'])
self.glade.get_widget('label_url').set_text(
self.builder.get_object('label_type').set_text(status['file_type'])
self.builder.get_object('label_url').set_text(
status['file_url'])
client.blocklist.get_status().addCallback(_on_get_status)
@ -110,18 +109,18 @@ class GtkUI(GtkPluginBase):
def _on_show_prefs(self):
def _on_get_config(config):
log.trace('Loaded config: %s', config)
self.glade.get_widget('entry_url').set_text(config['url'])
self.glade.get_widget('spin_check_days').set_value(config['check_after_days'])
self.glade.get_widget('chk_import_on_start').set_active(config['load_on_start'])
self.builder.get_object('entry_url').set_text(config['url'])
self.builder.get_object('spin_check_days').set_value(config['check_after_days'])
self.builder.get_object('chk_import_on_start').set_active(config['load_on_start'])
self.populate_whitelist(config['whitelisted'])
client.blocklist.get_config().addCallback(_on_get_config)
def _on_apply_prefs(self):
config = {}
config['url'] = self.glade.get_widget('entry_url').get_text().strip()
config['check_after_days'] = self.glade.get_widget('spin_check_days').get_value_as_int()
config['load_on_start'] = self.glade.get_widget('chk_import_on_start').get_active()
config['url'] = self.builder.get_object('entry_url').get_text().strip()
config['check_after_days'] = self.builder.get_object('spin_check_days').get_value_as_int()
config['load_on_start'] = self.builder.get_object('chk_import_on_start').get_active()
config['whitelisted'] = [ip[0] for ip in self.whitelist_model if ip[0] != 'IP HERE']
client.blocklist.set_config(config)
@ -139,11 +138,12 @@ class GtkUI(GtkPluginBase):
def load_preferences_page(self):
"""Initializes the preferences page and adds it to the preferences dialog"""
# Load the preferences page
self.glade = gtk.glade.XML(common.get_resource('blocklist_pref.glade'))
self.builder = gtk.Builder()
self.builder.add_from_file(common.get_resource('blocklist_pref.ui'))
self.whitelist_frame = self.glade.get_widget('whitelist_frame')
self.progress_bar = self.glade.get_widget('progressbar')
self.table_info = self.glade.get_widget('table_info')
self.whitelist_frame = self.builder.get_object('whitelist_frame')
self.progress_bar = self.builder.get_object('progressbar')
self.table_info = self.builder.get_object('table_info')
# Hide the progress bar initially
self.progress_bar.hide()
@ -152,7 +152,7 @@ class GtkUI(GtkPluginBase):
# Create the whitelisted model
self.build_whitelist_model_treeview()
self.glade.signal_autoconnect({
self.builder.connect_signals({
'on_button_check_download_clicked': self._on_button_check_download_clicked,
'on_button_force_download_clicked': self._on_button_force_download_clicked,
'on_whitelist_add_clicked': (self.on_add_button_clicked,
@ -162,10 +162,10 @@ class GtkUI(GtkPluginBase):
})
# Set button icons
self.glade.get_widget('image_download').set_from_file(
self.builder.get_object('image_download').set_from_file(
common.get_resource('blocklist_download24.png'))
self.glade.get_widget('image_import').set_from_file(
self.builder.get_object('image_import').set_from_file(
common.get_resource('blocklist_import24.png'))
# Update the preferences page with config values from the core
@ -174,10 +174,10 @@ class GtkUI(GtkPluginBase):
# Add the page to the preferences dialog
self.plugin.add_preferences_page(
_('Blocklist'),
self.glade.get_widget('blocklist_prefs_box'))
self.builder.get_object('blocklist_prefs_box'))
def build_whitelist_model_treeview(self):
self.whitelist_treeview = self.glade.get_widget('whitelist_treeview')
self.whitelist_treeview = self.builder.get_object('whitelist_treeview')
treeview_selection = self.whitelist_treeview.get_selection()
treeview_selection.connect(
'changed', self.on_whitelist_treeview_selection_changed
@ -207,11 +207,11 @@ class GtkUI(GtkPluginBase):
def on_whitelist_treeview_selection_changed(self, selection):
model, selected_connection_iter = selection.get_selected()
if selected_connection_iter:
self.glade.get_widget('whitelist_delete').set_property('sensitive',
True)
self.builder.get_object('whitelist_delete').set_property('sensitive',
True)
else:
self.glade.get_widget('whitelist_delete').set_property('sensitive',
False)
self.builder.get_object('whitelist_delete').set_property('sensitive',
False)
def on_add_button_clicked(self, widget, treeview):
model = treeview.get_model()