Mercurial > MadButterfly
changeset 1523:66c672d8f267
Add action_picker on UI for transition editor.
Pick an action from a list for a transition instead of typing.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Aug 2011 14:28:12 +0800 |
parents | 73837e189039 |
children | d46ba9e7f837 |
files | pyink/FSM_window.glade pyink/FSM_window.py |
diffstat | 2 files changed, 226 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/FSM_window.glade Sat Aug 20 16:17:56 2011 +0800 +++ b/pyink/FSM_window.glade Mon Aug 22 14:28:12 2011 +0800 @@ -528,6 +528,7 @@ <property name="default_height">200</property> <property name="type_hint">normal</property> <property name="transient_for">FSM_main_win</property> + <signal name="delete_event" handler="gtk_widget_hide"/> <child internal-child="vbox"> <object class="GtkVBox" id="dialog-vbox3"> <property name="visible">True</property> @@ -568,10 +569,32 @@ </packing> </child> <child> - <object class="GtkEntry" id="transition_action"> + <object class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> + <child> + <object class="GtkEntry" id="transition_action"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="transition_pick_act"> + <property name="label">gtk-find</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_transition_pick_act_clicked"/> + </object> + <packing> + <property name="padding">5</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="left_attach">1</property> @@ -636,6 +659,7 @@ </object> <object class="GtkMenu" id="transition_menu"> <property name="visible">True</property> + <signal name="delete_event" handler="gtk_widget_hide"/> <child> <object class="GtkMenuItem" id="del_transition"> <property name="visible">True</property> @@ -655,4 +679,156 @@ </object> </child> </object> + <object class="GtkListStore" id="action_store"> + <columns> + <!-- column-name action_name --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">action1</col> + </row> + <row> + <col id="0" translatable="yes">action2</col> + </row> + </data> + </object> + <object class="GtkDialog" id="action_picker"> + <property name="border_width">5</property> + <property name="modal">True</property> + <property name="window_position">center-always</property> + <property name="default_width">320</property> + <property name="default_height">260</property> + <property name="type_hint">normal</property> + <property name="transient_for">transition_editor</property> + <signal name="delete_event" handler="gtk_widget_hide"/> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox4"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkTreeView" id="action_list"> + <property name="height_request">200</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">action_store</property> + <property name="headers_visible">False</property> + <property name="search_column">0</property> + <property name="enable_grid_lines">horizontal</property> + <signal name="row_activated" handler="on_action_list_row_activated"/> + <child> + <object class="GtkTreeViewColumn" id="action_name_col"> + <property name="title">Actions</property> + <property name="clickable">True</property> + <child> + <object class="GtkCellRendererText" id="action_name_col_item"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">Action:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="picked_action"> + <property name="visible">True</property> + <property name="xpad">5</property> + <property name="label" translatable="yes">picked</property> + <attributes> + <attribute name="style" value="normal"/> + <attribute name="foreground" value="#2022292aecfa"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area4"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="action_ok"> + <property name="label">gtk-ok</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_action_ok_clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="action_cancel"> + <property name="label">gtk-cancel</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_action_cancel_clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">action_ok</action-widget> + <action-widget response="0">action_cancel</action-widget> + </action-widgets> + </object> </interface>
--- a/pyink/FSM_window.py Sat Aug 20 16:17:56 2011 +0800 +++ b/pyink/FSM_window.py Mon Aug 22 14:28:12 2011 +0800 @@ -197,6 +197,11 @@ _error_dialog_label = None _state_menu = None + + _action_picker = None + _picked_action = None + _picked_action_txt = None + _action_store = None def __init__(self): super(FSM_window_base, self).__init__() @@ -228,6 +233,10 @@ state_menu = builder.get_object('state_menu') transition_menu = builder.get_object('transition_menu') + action_picker = builder.get_object('action_picker') + picked_action = builder.get_object('picked_action') + action_store = builder.get_object('action_store') + builder.connect_signals(self) self._builder = builder @@ -251,6 +260,10 @@ self._state_menu = state_menu self._transition_menu = transition_menu self._comp_name_label = comp_name_label + + self._action_picker = action_picker + self._picked_action = picked_action + self._action_store = action_store pass def show_error(self, msg): @@ -308,6 +321,16 @@ menu.popup(None, None, None, 0, 0) pass + def show_action_picker(self): + self._picked_action.set_text('') + self._picked_action_txt = None + self._action_picker.show() + pass + + def hide_action_picker(self): + self._action_picker.hide() + pass + def show(self): self._main_win.show() self._add_state_button.set_active(True) @@ -378,11 +401,35 @@ transition_editor.hide() pass + def on_transition_pick_act_clicked(self, *args): + self.show_action_picker() + pass + def on_del_transition_activate(self, *args): pass def on_edit_transition_activate(self, *args): pass + + def on_action_cancel_clicked(self, *args): + action_picker = self._action_picker + action_picker.hide() + pass + + def on_action_ok_clicked(self, *args): + if self._picked_action_txt: + self._transition_action.set_text(self._picked_action_txt) + pass + self.hide_action_picker() + pass + + def on_action_list_row_activated(self, view, path, col): + action_store = self._action_store + action_iter = action_store.get_iter(path) + action_text = action_store.get_value(action_iter, 0) + self._picked_action_txt = action_text + self._picked_action.set_text(action_text) + pass pass