diff --git a/gajim/adhoc_commands.py b/gajim/adhoc_commands.py index cc855e9f5..f2b78d6e0 100644 --- a/gajim/adhoc_commands.py +++ b/gajim/adhoc_commands.py @@ -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() diff --git a/gajim/data/gui/adhoc_commands_window.ui b/gajim/data/gui/adhoc_commands_window.ui index 8446cbee5..d65461b3e 100644 --- a/gajim/data/gui/adhoc_commands_window.ui +++ b/gajim/data/gui/adhoc_commands_window.ui @@ -52,33 +52,8 @@ 1 - - - - - - True - False - - - False - - - - - - - - True - False - - - 1 - False - - True @@ -88,14 +63,13 @@ True False - 0.20000000298023224 - 6 <b>Choose command to execute:</b> True False False + 5 0 @@ -103,16 +77,17 @@ True True + 1 + 1 + in - + True - False - - - True - False - 12 - vertical + True + False + + + browse @@ -121,6 +96,7 @@ True True + 5 1 @@ -128,9 +104,6 @@ True False - - - Check once more @@ -144,42 +117,21 @@ False False end - 1 + 0 False True + 2 + end 2 - 2 - - - - - True - False - - - 2 - False - - - - - - - - True - False - - - 3 - False + 1 @@ -200,9 +152,6 @@ 0 - - - True @@ -214,35 +163,12 @@ False False end - 2 + 1 - 4 - - - - - True - False - - - 4 - False - - - - - - - - True - False - - - 5 - False + 2 @@ -262,16 +188,10 @@ 0 - - - True False - - - Check once more @@ -285,7 +205,7 @@ False False end - 1 + 0 @@ -293,35 +213,12 @@ False False end - 2 + 1 - 6 - - - - - True - False - - - 6 - False - - - - - - - - True - False - - - 7 - False + 3 @@ -357,30 +254,7 @@ - 8 - - - - - True - False - - - 8 - False - - - - - - - - True - False - - - 9 - False + 4