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',
|
||||
'execute_button', 'finish_button', 'close_button', 'stages_notebook',
|
||||
'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',
|
||||
'error_stage_vbox', 'error_description_label'):
|
||||
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()
|
||||
|
||||
def initiate(self):
|
||||
|
@ -215,10 +221,7 @@ class CommandWindow:
|
|||
# stage 2: choosing the command to execute
|
||||
def stage2(self):
|
||||
"""
|
||||
Populate the command list vbox with radiobuttons
|
||||
|
||||
FIXME: If there is more commands, maybe some kind of list, set widgets
|
||||
state
|
||||
Populate the command list
|
||||
"""
|
||||
# close old stage
|
||||
self.stage_finish()
|
||||
|
@ -234,17 +237,11 @@ class CommandWindow:
|
|||
self.execute_button.set_sensitive(False)
|
||||
self.finish_button.set_sensitive(False)
|
||||
|
||||
# build the commands list radiobuttons
|
||||
first_radio = None
|
||||
# build the commands list
|
||||
self.command_store.clear()
|
||||
for (commandnode, commandname) in self.commandlist:
|
||||
radio = Gtk.RadioButton.new_with_label_from_widget(first_radio, commandname)
|
||||
radio.connect("toggled", self.on_command_radiobutton_toggled,
|
||||
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.command_store.append([commandname, commandnode])
|
||||
self.command_treeview.get_selection().select_iter(self.command_store.get_iter_first())
|
||||
|
||||
self.stage_finish_cb = self.stage2_finish
|
||||
self.stage_close_button_cb = self.stage2_close_button_clicked
|
||||
|
@ -254,11 +251,10 @@ class CommandWindow:
|
|||
|
||||
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):
|
||||
self.command_list_vbox.remove(widget)
|
||||
self.command_list_vbox.foreach(remove_widget, None)
|
||||
model, treeiter = self.command_treeview.get_selection().get_selected()
|
||||
self.commandnode = model[treeiter][1]
|
||||
|
||||
def stage2_close_button_clicked(self, widget):
|
||||
self.stage_finish()
|
||||
|
@ -271,9 +267,6 @@ class CommandWindow:
|
|||
def stage2_forward_button_clicked(self, widget):
|
||||
self.stage3()
|
||||
|
||||
def on_command_radiobutton_toggled(self, widget, commandnode):
|
||||
self.commandnode = commandnode
|
||||
|
||||
def on_check_commands_1_button_clicked(self, widget):
|
||||
self.stage1()
|
||||
|
||||
|
|
|
@ -52,33 +52,8 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</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>
|
||||
<object class="GtkBox" id="command_list_stage_vbox">
|
||||
<property name="visible">True</property>
|
||||
|
@ -88,14 +63,13 @@
|
|||
<object class="GtkLabel" id="label253">
|
||||
<property name="visible">True</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="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -103,16 +77,17 @@
|
|||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">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>
|
||||
<object class="GtkViewport" id="viewport1">
|
||||
<object class="GtkTreeView" id="command_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="command_list_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection">
|
||||
<property name="mode">browse</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -121,6 +96,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -128,9 +104,6 @@
|
|||
<object class="GtkBox" id="hbox2957">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="check_commands_1_button">
|
||||
<property name="label" translatable="yes">Check once more</property>
|
||||
|
@ -144,42 +117,21 @@
|
|||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">2</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</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>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -200,9 +152,6 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkProgressBar" id="sending_form_progressbar">
|
||||
<property name="visible">True</property>
|
||||
|
@ -214,35 +163,12 @@
|
|||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">4</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>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -262,16 +188,10 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox2956">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="check_commands_2_button">
|
||||
<property name="label" translatable="yes">Check once more</property>
|
||||
|
@ -285,7 +205,7 @@
|
|||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -293,35 +213,12 @@
|
|||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">6</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>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -357,30 +254,7 @@
|
|||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">8</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>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in New Issue