Replace ad-hoc command radio buttons with a list
Radio buttons are more suitable for static lists of options. GNOME seems to be using lists in similar situations, for example to show a list of network printers. This also makes it possible to search a command by typing.
This commit is contained in:
parent
78ebaefaec
commit
bd4aa0f40f
|
@ -75,11 +75,17 @@ class CommandWindow:
|
||||||
for name in ('restart_button', 'back_button', 'forward_button',
|
for name in ('restart_button', 'back_button', 'forward_button',
|
||||||
'execute_button', 'finish_button', 'close_button', 'stages_notebook',
|
'execute_button', 'finish_button', 'close_button', 'stages_notebook',
|
||||||
'retrieving_commands_stage_vbox', 'command_list_stage_vbox',
|
'retrieving_commands_stage_vbox', 'command_list_stage_vbox',
|
||||||
'command_list_vbox', 'sending_form_stage_vbox',
|
'command_treeview', 'sending_form_stage_vbox',
|
||||||
'sending_form_progressbar', 'notes_label', 'no_commands_stage_vbox',
|
'sending_form_progressbar', 'notes_label', 'no_commands_stage_vbox',
|
||||||
'error_stage_vbox', 'error_description_label'):
|
'error_stage_vbox', 'error_description_label'):
|
||||||
setattr(self, name, self.xml.get_object(name))
|
setattr(self, name, self.xml.get_object(name))
|
||||||
|
|
||||||
|
self.command_store = Gtk.ListStore(str, str)
|
||||||
|
self.command_treeview.set_model(self.command_store)
|
||||||
|
renderer = Gtk.CellRendererText()
|
||||||
|
column = Gtk.TreeViewColumn("Command", renderer, text=0)
|
||||||
|
self.command_treeview.append_column(column)
|
||||||
|
|
||||||
self.initiate()
|
self.initiate()
|
||||||
|
|
||||||
def initiate(self):
|
def initiate(self):
|
||||||
|
@ -215,10 +221,7 @@ class CommandWindow:
|
||||||
# stage 2: choosing the command to execute
|
# stage 2: choosing the command to execute
|
||||||
def stage2(self):
|
def stage2(self):
|
||||||
"""
|
"""
|
||||||
Populate the command list vbox with radiobuttons
|
Populate the command list
|
||||||
|
|
||||||
FIXME: If there is more commands, maybe some kind of list, set widgets
|
|
||||||
state
|
|
||||||
"""
|
"""
|
||||||
# close old stage
|
# close old stage
|
||||||
self.stage_finish()
|
self.stage_finish()
|
||||||
|
@ -234,17 +237,11 @@ class CommandWindow:
|
||||||
self.execute_button.set_sensitive(False)
|
self.execute_button.set_sensitive(False)
|
||||||
self.finish_button.set_sensitive(False)
|
self.finish_button.set_sensitive(False)
|
||||||
|
|
||||||
# build the commands list radiobuttons
|
# build the commands list
|
||||||
first_radio = None
|
self.command_store.clear()
|
||||||
for (commandnode, commandname) in self.commandlist:
|
for (commandnode, commandname) in self.commandlist:
|
||||||
radio = Gtk.RadioButton.new_with_label_from_widget(first_radio, commandname)
|
self.command_store.append([commandname, commandnode])
|
||||||
radio.connect("toggled", self.on_command_radiobutton_toggled,
|
self.command_treeview.get_selection().select_iter(self.command_store.get_iter_first())
|
||||||
commandnode)
|
|
||||||
if not first_radio:
|
|
||||||
first_radio = radio
|
|
||||||
self.commandnode = commandnode
|
|
||||||
self.command_list_vbox.pack_start(radio, False, True, 0)
|
|
||||||
self.command_list_vbox.show_all()
|
|
||||||
|
|
||||||
self.stage_finish_cb = self.stage2_finish
|
self.stage_finish_cb = self.stage2_finish
|
||||||
self.stage_close_button_cb = self.stage2_close_button_clicked
|
self.stage_close_button_cb = self.stage2_close_button_clicked
|
||||||
|
@ -254,11 +251,10 @@ class CommandWindow:
|
||||||
|
|
||||||
def stage2_finish(self):
|
def stage2_finish(self):
|
||||||
"""
|
"""
|
||||||
Remove widgets we created. Not needed when the window is destroyed
|
Save selected command to self.commandnode
|
||||||
"""
|
"""
|
||||||
def remove_widget(widget, param):
|
model, treeiter = self.command_treeview.get_selection().get_selected()
|
||||||
self.command_list_vbox.remove(widget)
|
self.commandnode = model[treeiter][1]
|
||||||
self.command_list_vbox.foreach(remove_widget, None)
|
|
||||||
|
|
||||||
def stage2_close_button_clicked(self, widget):
|
def stage2_close_button_clicked(self, widget):
|
||||||
self.stage_finish()
|
self.stage_finish()
|
||||||
|
@ -271,9 +267,6 @@ class CommandWindow:
|
||||||
def stage2_forward_button_clicked(self, widget):
|
def stage2_forward_button_clicked(self, widget):
|
||||||
self.stage3()
|
self.stage3()
|
||||||
|
|
||||||
def on_command_radiobutton_toggled(self, widget, commandnode):
|
|
||||||
self.commandnode = commandnode
|
|
||||||
|
|
||||||
def on_check_commands_1_button_clicked(self, widget):
|
def on_check_commands_1_button_clicked(self, widget):
|
||||||
self.stage1()
|
self.stage1()
|
||||||
|
|
||||||
|
|
|
@ -52,33 +52,8 @@
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label264">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label265">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">1</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="command_list_stage_vbox">
|
<object class="GtkBox" id="command_list_stage_vbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -88,14 +63,13 @@
|
||||||
<object class="GtkLabel" id="label253">
|
<object class="GtkLabel" id="label253">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0.20000000298023224</property>
|
|
||||||
<property name="ypad">6</property>
|
|
||||||
<property name="label" translatable="yes"><b>Choose command to execute:</b></property>
|
<property name="label" translatable="yes"><b>Choose command to execute:</b></property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
</object>
|
</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="padding">5</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -103,16 +77,17 @@
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="margin_left">1</property>
|
||||||
|
<property name="margin_right">1</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkViewport" id="viewport1">
|
<object class="GtkTreeView" id="command_treeview">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">True</property>
|
||||||
<child>
|
<property name="headers_visible">False</property>
|
||||||
<object class="GtkBox" id="command_list_vbox">
|
<child internal-child="selection">
|
||||||
<property name="visible">True</property>
|
<object class="GtkTreeSelection" id="treeview-selection">
|
||||||
<property name="can_focus">False</property>
|
<property name="mode">browse</property>
|
||||||
<property name="border_width">12</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -121,6 +96,7 @@
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="padding">5</property>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -128,9 +104,6 @@
|
||||||
<object class="GtkBox" id="hbox2957">
|
<object class="GtkBox" id="hbox2957">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="check_commands_1_button">
|
<object class="GtkButton" id="check_commands_1_button">
|
||||||
<property name="label" translatable="yes">Check once more</property>
|
<property name="label" translatable="yes">Check once more</property>
|
||||||
|
@ -144,42 +117,21 @@
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
<property name="position">1</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="padding">2</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">2</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label266">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">2</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label267">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">3</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -200,9 +152,6 @@
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkProgressBar" id="sending_form_progressbar">
|
<object class="GtkProgressBar" id="sending_form_progressbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -214,35 +163,12 @@
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
<property name="position">2</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">4</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label268">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">4</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label269">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">5</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -262,16 +188,10 @@
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="hbox2956">
|
<object class="GtkBox" id="hbox2956">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="check_commands_2_button">
|
<object class="GtkButton" id="check_commands_2_button">
|
||||||
<property name="label" translatable="yes">Check once more</property>
|
<property name="label" translatable="yes">Check once more</property>
|
||||||
|
@ -285,7 +205,7 @@
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
<property name="position">1</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -293,35 +213,12 @@
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
<property name="position">2</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">6</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label270">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">6</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label271">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">7</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -357,30 +254,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">8</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label272">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">8</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child type="tab">
|
|
||||||
<object class="GtkLabel" id="label273">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">9</property>
|
|
||||||
<property name="tab_fill">False</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue