[Execute] Update gtkui from libglade to gtkbuilder
This commit is contained in:
parent
f0316d3e31
commit
1259eca8ad
|
@ -1,122 +1,144 @@
|
|||
<?xml version="1.0"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.16 -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<widget class="GtkWindow" id="execute_window">
|
||||
<object class="GtkListStore" id="liststore1">
|
||||
<columns>
|
||||
<!-- column-name item text -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow" id="execute_window">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="execute_box">
|
||||
<object class="GtkVBox" id="execute_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkFrame" id="add_frame">
|
||||
<object class="GtkFrame" id="add_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="add_alignment">
|
||||
<object class="GtkAlignment" id="add_alignment">
|
||||
<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="GtkTable" id="add_table">
|
||||
<object class="GtkTable" id="add_table">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="event_label">
|
||||
<object class="GtkLabel" id="event_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Event</property>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="y_options"/>
|
||||
<property name="x_padding">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="command_label">
|
||||
<object class="GtkLabel" id="command_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Command</property>
|
||||
</widget>
|
||||
</object>
|
||||
<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>
|
||||
<property name="y_options"/>
|
||||
<property name="x_padding">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="command_entry">
|
||||
<object class="GtkEntry" id="command_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
</widget>
|
||||
<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>
|
||||
</object>
|
||||
<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="y_options"></property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="event_combobox">
|
||||
<object class="GtkComboBox" id="event_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes"></property>
|
||||
</widget>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="model">liststore1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext1"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<object class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_add">
|
||||
<object class="GtkButton" id="button_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_stock">True</property>
|
||||
<signal name="clicked" handler="on_add_button_clicked"/>
|
||||
</widget>
|
||||
<signal name="clicked" handler="on_add_button_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
<packing>
|
||||
<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>
|
||||
<property name="y_options"/>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="add_label">
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="add_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Add Command</b></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>
|
||||
|
@ -124,45 +146,45 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkFrame" id="commands_frame">
|
||||
<object class="GtkFrame" id="commands_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="commands_alignment">
|
||||
<object class="GtkAlignment" id="commands_alignment">
|
||||
<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="commands_vbox">
|
||||
<object class="GtkVBox" id="commands_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="commands_label">
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="commands_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes"><b>Commands</b></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>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</object>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
</object>
|
||||
</interface>
|
|
@ -12,7 +12,6 @@ from __future__ import unicode_literals
|
|||
import logging
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
import deluge.component as component
|
||||
from deluge.plugins.pluginbase import GtkPluginBase
|
||||
|
@ -43,12 +42,11 @@ class ExecutePreferences(object):
|
|||
|
||||
def load(self):
|
||||
log.debug('Adding Execute Preferences page')
|
||||
self.glade = gtk.glade.XML(common.get_resource('execute_prefs.glade'))
|
||||
self.glade.signal_autoconnect({
|
||||
'on_add_button_clicked': self.on_add_button_clicked
|
||||
})
|
||||
self.builder = gtk.Builder()
|
||||
self.builder.add_from_file(common.get_resource('execute_prefs.ui'))
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
events = self.glade.get_widget('event_combobox')
|
||||
events = self.builder.get_object('event_combobox')
|
||||
|
||||
store = gtk.ListStore(str, str)
|
||||
for event in EVENTS:
|
||||
|
@ -57,7 +55,7 @@ class ExecutePreferences(object):
|
|||
events.set_model(store)
|
||||
events.set_active(0)
|
||||
|
||||
self.plugin.add_preferences_page(_('Execute'), self.glade.get_widget('execute_box'))
|
||||
self.plugin.add_preferences_page(_('Execute'), self.builder.get_object('execute_box'))
|
||||
self.plugin.register_hook('on_show_prefs', self.load_commands)
|
||||
self.plugin.register_hook('on_apply_prefs', self.on_apply_prefs)
|
||||
|
||||
|
@ -73,7 +71,7 @@ class ExecutePreferences(object):
|
|||
|
||||
def add_command(self, command_id, event, command):
|
||||
log.debug('Adding command `%s`', command_id)
|
||||
vbox = self.glade.get_widget('commands_vbox')
|
||||
vbox = self.builder.get_object('commands_vbox')
|
||||
hbox = gtk.HBox(False, 5)
|
||||
hbox.set_name(command_id + '_' + event)
|
||||
label = gtk.Label(EVENT_MAP[event])
|
||||
|
@ -94,7 +92,7 @@ class ExecutePreferences(object):
|
|||
vbox.pack_start(hbox)
|
||||
|
||||
def remove_command(self, command_id):
|
||||
vbox = self.glade.get_widget('commands_vbox')
|
||||
vbox = self.builder.get_object('commands_vbox')
|
||||
children = vbox.get_children()
|
||||
for child in children:
|
||||
if child.get_name().split('_')[0] == command_id:
|
||||
|
@ -102,7 +100,7 @@ class ExecutePreferences(object):
|
|||
break
|
||||
|
||||
def clear_commands(self):
|
||||
vbox = self.glade.get_widget('commands_vbox')
|
||||
vbox = self.builder.get_object('commands_vbox')
|
||||
children = vbox.get_children()
|
||||
for child in children:
|
||||
vbox.remove(child)
|
||||
|
@ -118,8 +116,8 @@ class ExecutePreferences(object):
|
|||
client.execute.get_commands().addCallback(on_get_commands)
|
||||
|
||||
def on_add_button_clicked(self, *args):
|
||||
command = self.glade.get_widget('command_entry').get_text()
|
||||
events = self.glade.get_widget('event_combobox')
|
||||
command = self.builder.get_object('command_entry').get_text()
|
||||
events = self.builder.get_object('event_combobox')
|
||||
event = events.get_model()[events.get_active()][1]
|
||||
client.execute.add_command(event, command)
|
||||
|
||||
|
@ -128,7 +126,7 @@ class ExecutePreferences(object):
|
|||
client.execute.remove_command(command_id)
|
||||
|
||||
def on_apply_prefs(self):
|
||||
vbox = self.glade.get_widget('commands_vbox')
|
||||
vbox = self.builder.get_object('commands_vbox')
|
||||
children = vbox.get_children()
|
||||
for child in children:
|
||||
command_id, event = child.get_name().split('_')
|
||||
|
|
Loading…
Reference in New Issue