[WebUi] Update gtkui from libglade to gtkbuilder

This commit is contained in:
DjLegolas 2017-08-06 13:06:03 +03:00 committed by Calum Lind
parent 24a31b1194
commit d190f149d1
2 changed files with 62 additions and 45 deletions

View File

@ -1,35 +1,44 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<glade-interface> <interface>
<!-- interface-requires gtk+ 2.16 --> <requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy toplevel-contextual --> <!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="window1"> <object class="GtkAdjustment" id="adjustment1">
<property name="upper">99999</property>
<property name="value">8112</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> <child>
<widget class="GtkVBox" id="prefs_box"> <object class="GtkVBox" id="prefs_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<child> <child>
<widget class="GtkFrame" id="settings_frame"> <object class="GtkFrame" id="settings_frame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<widget class="GtkAlignment" id="settings_alignment"> <object class="GtkAlignment" id="settings_alignment">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">10</property> <property name="top_padding">10</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkVBox" id="settings_vbox"> <object class="GtkVBox" id="settings_vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<widget class="GtkCheckButton" id="enabled_checkbutton"> <object class="GtkCheckButton" id="enabled_checkbutton">
<property name="label" translatable="yes">Enable web interface</property> <property name="label" translatable="yes">Enable web interface</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@ -37,13 +46,13 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="ssl_checkbutton"> <object class="GtkCheckButton" id="ssl_checkbutton">
<property name="label" translatable="yes">Enable SSL</property> <property name="label" translatable="yes">Enable SSL</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@ -51,14 +60,16 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="port_hbox"> <object class="GtkHBox" id="port_hbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<widget class="GtkLabel" id="port_label"> <object class="GtkLabel" id="port_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Listening port:</property> <property name="label" translatable="yes">Listening port:</property>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
@ -66,44 +77,50 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkSpinButton" id="port_spinbutton"> <object class="GtkSpinButton" id="port_spinbutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property> <property name="invisible_char">●</property>
<property name="adjustment">8112 0 99999 1 10 0</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">adjustment1</property>
<property name="numeric">True</property> <property name="numeric">True</property>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</widget> </object>
</child> </child>
</widget> </object>
</child> </child>
<child> <child type="label">
<widget class="GtkLabel" id="settings_label"> <object class="GtkLabel" id="settings_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Settings&lt;/b&gt;</property> <property name="label" translatable="yes">&lt;b&gt;Settings&lt;/b&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</widget> </object>
<packing>
<property name="type">label_item</property>
</packing>
</child> </child>
</widget> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
</widget> </object>
</child> </child>
</widget> </object>
</glade-interface> </interface>

View File

@ -16,7 +16,6 @@ from __future__ import unicode_literals
import logging import logging
import gtk import gtk
import gtk.glade
import deluge.component as component import deluge.component as component
from deluge.plugins.pluginbase import GtkPluginBase from deluge.plugins.pluginbase import GtkPluginBase
@ -29,9 +28,10 @@ log = logging.getLogger(__name__)
class GtkUI(GtkPluginBase): class GtkUI(GtkPluginBase):
def enable(self): def enable(self):
self.glade = gtk.glade.XML(get_resource('config.glade')) self.builder = gtk.Builder()
self.builder.add_from_file(get_resource('config.ui'))
component.get('Preferences').add_page(_('WebUi'), self.glade.get_widget('prefs_box')) component.get('Preferences').add_page(_('WebUi'), self.builder.get_object('prefs_box'))
component.get('PluginManager').register_hook('on_apply_prefs', self.on_apply_prefs) component.get('PluginManager').register_hook('on_apply_prefs', self.on_apply_prefs)
component.get('PluginManager').register_hook('on_show_prefs', self.on_show_prefs) component.get('PluginManager').register_hook('on_show_prefs', self.on_show_prefs)
client.webui.get_config().addCallback(self.cb_get_config) client.webui.get_config().addCallback(self.cb_get_config)
@ -47,9 +47,9 @@ class GtkUI(GtkPluginBase):
return return
log.debug('applying prefs for WebUi') log.debug('applying prefs for WebUi')
config = { config = {
'enabled': self.glade.get_widget('enabled_checkbutton').get_active(), 'enabled': self.builder.get_object('enabled_checkbutton').get_active(),
'ssl': self.glade.get_widget('ssl_checkbutton').get_active(), 'ssl': self.builder.get_object('ssl_checkbutton').get_active(),
'port': self.glade.get_widget('port_spinbutton').get_value_as_int() 'port': self.builder.get_object('port_spinbutton').get_value_as_int()
} }
client.webui.set_config(config) client.webui.set_config(config)
@ -58,17 +58,17 @@ class GtkUI(GtkPluginBase):
def cb_get_config(self, config): def cb_get_config(self, config):
'callback for on show_prefs' 'callback for on show_prefs'
self.glade.get_widget('enabled_checkbutton').set_active(config['enabled']) self.builder.get_object('enabled_checkbutton').set_active(config['enabled'])
self.glade.get_widget('ssl_checkbutton').set_active(config['ssl']) self.builder.get_object('ssl_checkbutton').set_active(config['ssl'])
self.glade.get_widget('port_spinbutton').set_value(config['port']) self.builder.get_object('port_spinbutton').set_value(config['port'])
def cb_chk_deluge_web(self, have_web): def cb_chk_deluge_web(self, have_web):
self.have_web = have_web self.have_web = have_web
if have_web: if have_web:
return return
self.glade.get_widget('settings_vbox').set_sensitive(False) self.builder.get_object('settings_vbox').set_sensitive(False)
vbox = self.glade.get_widget('prefs_box') vbox = self.builder.get_object('prefs_box')
hbox = gtk.HBox() hbox = gtk.HBox()
icon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_SMALL_TOOLBAR) icon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_SMALL_TOOLBAR)