From d190f149d1055d5e41736c4d4ca0e2764e7791b7 Mon Sep 17 00:00:00 2001 From: DjLegolas Date: Sun, 6 Aug 2017 13:06:03 +0300 Subject: [PATCH] [WebUi] Update gtkui from libglade to gtkbuilder --- .../webui/data/{config.glade => config.ui} | 85 +++++++++++-------- .../WebUi/deluge/plugins/webui/gtkui.py | 22 ++--- 2 files changed, 62 insertions(+), 45 deletions(-) rename deluge/plugins/WebUi/deluge/plugins/webui/data/{config.glade => config.ui} (60%) diff --git a/deluge/plugins/WebUi/deluge/plugins/webui/data/config.glade b/deluge/plugins/WebUi/deluge/plugins/webui/data/config.ui similarity index 60% rename from deluge/plugins/WebUi/deluge/plugins/webui/data/config.glade rename to deluge/plugins/WebUi/deluge/plugins/webui/data/config.ui index 820053bc1..04b73ecdf 100644 --- a/deluge/plugins/WebUi/deluge/plugins/webui/data/config.glade +++ b/deluge/plugins/WebUi/deluge/plugins/webui/data/config.ui @@ -1,35 +1,44 @@ - - - + + + - + + 99999 + 8112 + 1 + 10 + + + False - + True - vertical + False - + True + False 0 none - + True + False 10 12 - + True - vertical + False 5 - + Enable web interface True True False True - + False False @@ -37,13 +46,13 @@ - + Enable SSL True True False True - + False False @@ -51,14 +60,16 @@ - + True + False 5 - + True + False Listening port: - + False False @@ -66,44 +77,50 @@ - + True True - - 8112 0 99999 1 10 0 + + False + False + True + True + adjustment1 True - + + True + True 1 - + False False 2 - + - + - - + + True + False <b>Settings</b> True - - - label_item - + - + + True + True 0 - + - - + + diff --git a/deluge/plugins/WebUi/deluge/plugins/webui/gtkui.py b/deluge/plugins/WebUi/deluge/plugins/webui/gtkui.py index dd8e500d6..b09cc4361 100644 --- a/deluge/plugins/WebUi/deluge/plugins/webui/gtkui.py +++ b/deluge/plugins/WebUi/deluge/plugins/webui/gtkui.py @@ -16,7 +16,6 @@ from __future__ import unicode_literals import logging import gtk -import gtk.glade import deluge.component as component from deluge.plugins.pluginbase import GtkPluginBase @@ -29,9 +28,10 @@ log = logging.getLogger(__name__) class GtkUI(GtkPluginBase): 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_show_prefs', self.on_show_prefs) client.webui.get_config().addCallback(self.cb_get_config) @@ -47,9 +47,9 @@ class GtkUI(GtkPluginBase): return log.debug('applying prefs for WebUi') config = { - 'enabled': self.glade.get_widget('enabled_checkbutton').get_active(), - 'ssl': self.glade.get_widget('ssl_checkbutton').get_active(), - 'port': self.glade.get_widget('port_spinbutton').get_value_as_int() + 'enabled': self.builder.get_object('enabled_checkbutton').get_active(), + 'ssl': self.builder.get_object('ssl_checkbutton').get_active(), + 'port': self.builder.get_object('port_spinbutton').get_value_as_int() } client.webui.set_config(config) @@ -58,17 +58,17 @@ class GtkUI(GtkPluginBase): def cb_get_config(self, config): 'callback for on show_prefs' - self.glade.get_widget('enabled_checkbutton').set_active(config['enabled']) - self.glade.get_widget('ssl_checkbutton').set_active(config['ssl']) - self.glade.get_widget('port_spinbutton').set_value(config['port']) + self.builder.get_object('enabled_checkbutton').set_active(config['enabled']) + self.builder.get_object('ssl_checkbutton').set_active(config['ssl']) + self.builder.get_object('port_spinbutton').set_value(config['port']) def cb_chk_deluge_web(self, have_web): self.have_web = have_web if have_web: 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() icon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_SMALL_TOOLBAR)