[installer] Use get_builder()

This commit is contained in:
Philipp Hörist
2018-10-13 00:36:23 +02:00
parent 3e2abc58c0
commit d7884afc97
3 changed files with 42 additions and 58 deletions

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkGrid" id="config_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<child>
<object class="GtkCheckButton" id="check_update">
<property name="label" translatable="yes">Check update after start</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</interface>

View File

@@ -2,37 +2,6 @@
<!-- Generated with glade 3.22.1 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="ConfigWindow">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid" id="config_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<child>
<object class="GtkCheckButton" id="check_update">
<property name="label" translatable="yes">Check update after start</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_check_update_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="plugin_store"> <object class="GtkListStore" id="plugin_store">
<columns> <columns>
<!-- column-name icon --> <!-- column-name icon -->

View File

@@ -36,22 +36,18 @@ from urllib.request import urlopen
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GdkPixbuf from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GLib from gi.repository import GLib
try: from gajim.common import app
from common import gajim as app from gajim.common import configpaths
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
from dialogs import WarningDialog, HigDialog, YesNoDialog from gajim.plugins.plugins_i18n import _
from gtkgui_helpers import get_action from gajim.plugins.helpers import get_builder
except ImportError: from gajim.gtk.dialogs import WarningDialog
from gajim.common import app from gajim.gtk.dialogs import HigDialog
from gajim.common import configpaths from gajim.gtk.dialogs import YesNoDialog
from gajim.plugins import GajimPlugin from gajim.gtkgui_helpers import get_action
from gajim.plugins.gui import GajimPluginConfigDialog
from gajim.dialogs import WarningDialog, HigDialog, YesNoDialog
from gajim.gtkgui_helpers import get_action
log = logging.getLogger('gajim.plugin_system.plugin_installer') log = logging.getLogger('gajim.plugin_system.plugin_installer')
@@ -176,11 +172,9 @@ class PluginInstaller(GajimPlugin):
self.window = plugin_win.window self.window = plugin_win.window
id_ = self.window.connect('destroy', self.on_win_destroy) id_ = self.window.connect('destroy', self.on_win_destroy)
self.connected_ids[id_] = self.window self.connected_ids[id_] = self.window
self.Gtk_BUILDER_FILE_PATH = self.local_file_path('config_dialog.ui') path = self.local_file_path('installer.ui')
self.xml = Gtk.Builder() self.xml = get_builder(
self.xml.set_translation_domain('gajim_plugins') path, widgets=['refresh', 'available_plugins_box', 'plugin_store'])
self.xml.add_objects_from_file(self.Gtk_BUILDER_FILE_PATH,
['refresh', 'available_plugins_box', 'plugin_store'])
widgets_to_extract = ( widgets_to_extract = (
'available_plugins_box', 'install_plugin_button', 'plugin_name_label', 'available_plugins_box', 'install_plugin_button', 'plugin_name_label',
@@ -511,18 +505,14 @@ class DownloadAsync(threading.Thread):
class PluginInstallerPluginConfigDialog(GajimPluginConfigDialog): class PluginInstallerPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
glade_file_path = self.plugin.local_file_path('config_dialog.ui') glade_file_path = self.plugin.local_file_path('config.ui')
self.xml = Gtk.Builder() self.xml = get_builder(glade_file_path)
self.xml.set_translation_domain('gajim_plugins') self.get_child().pack_start(self.xml.config_grid, True, True, 0)
self.xml.add_objects_from_file(glade_file_path, ['config_grid'])
grid = self.xml.get_object('config_grid')
self.get_child().pack_start(grid, True, True, 0)
self.xml.connect_signals(self) self.xml.connect_signals(self)
def on_run(self): def on_run(self):
self.xml.get_object('check_update').set_active( self.xml.check_update.set_active(self.plugin.config['check_update'])
self.plugin.config['check_update'])
def on_check_update_toggled(self, widget): def on_check_update_toggled(self, widget):
self.plugin.config['check_update'] = widget.get_active() self.plugin.config['check_update'] = widget.get_active()