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