Mercurial > MadButterfly
changeset 1460:75ca2a66c08d
Hint user current selected component and timeline
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 17 Apr 2011 01:03:07 +0800 |
parents | 8eecaca2a125 |
children | 31189b5d832a |
files | pyink/comp_dock.py pyink/component_dock.glade |
diffstat | 2 files changed, 92 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/comp_dock.py Sat Apr 16 23:29:37 2011 +0800 +++ b/pyink/comp_dock.py Sun Apr 17 01:03:07 2011 +0800 @@ -70,13 +70,16 @@ components_model = self._components_model components_model.clear() + cur_comp_name = self._domview_ui.get_current_component() + all_comp_names = self._domview_ui.all_comp_names() for comp_name in all_comp_names: editable = False - components_model.append((comp_name, editable)) + selected = comp_name == cur_comp_name + icon = 'gtk-apply' + components_model.append((comp_name, editable, selected, icon)) pass - cur_comp_name = self._domview_ui.get_current_component() cur_comp_idx = all_comp_names.index(cur_comp_name) self._components_treeview.set_cursor((cur_comp_idx,)) pass @@ -89,12 +92,19 @@ timelines_model = self._timelines_model timelines_model.clear() + cur_tl_name = self._domview_ui.get_current_timeline() + all_timeline_names = self._domview_ui.all_timeline_names() for timeline_name in all_timeline_names: - timelines_model.append((timeline_name, False)) + if timeline_name == cur_tl_name: + timelines_model.append((timeline_name, False, + True, 'gtk-apply')) + else: + timelines_model.append((timeline_name, False, + False, 'gtk-apply')) + pass pass - cur_tl_name = self._domview_ui.get_current_timeline() cur_tl_idx = all_timeline_names.index(cur_tl_name) self._timelines_treeview.set_cursor((cur_tl_idx,)) pass @@ -108,7 +118,7 @@ def dom_add_component(self, name): model = self._components_model - model.append((name, False)) + model.append((name, False, False, 'gtk-apply')) pass def dom_rm_component(self, name): @@ -128,7 +138,7 @@ def dom_add_timeline(self, name): model = self._timelines_model - model.append((name, False)) + model.append((name, False, False, 'gtk-apply')) pass def dom_rm_timeline(self, name): @@ -221,11 +231,26 @@ model = self._components_model itr = model.get_iter(path) comp_name = model.get_value(itr, 0) - print comp_name self._domview_ui.rm_component(comp_name) pass + def _sel_component(self, comp_name): + all_comp_names = self._domview_ui.all_comp_names() + sel_idx = all_comp_names.index(comp_name) + assert sel_idx >= 0 + + for idx in range(len(all_comp_names)): + model = self._components_model + itr = model.get_iter((idx,)) + if idx == sel_idx: + model.set_value(itr, 2, True) + else: + model.set_value(itr, 2, False) + pass + pass + pass + def _switch_component(self): domview_ui = self._domview_ui @@ -235,6 +260,10 @@ group = domview_ui.get_layer_group(0) desktop = self._desktop # from comp_dock_base desktop.setCurrentLayer(group.spitem) + + self._sel_component(comp_name) + tl_name = self._current_timeline() + self._sel_timeline(tl_name) pass def _add_timeline(self): @@ -270,11 +299,29 @@ self._domview_ui.rm_timeline(tl_name) pass + def _sel_timeline(self, tl_name): + all_tl_names = self._domview_ui.all_timeline_names() + sel_idx = all_tl_names.index(tl_name) + assert sel_idx >= 0 + + for idx in range(len(all_tl_names)): + model = self._timelines_model + itr = model.get_iter((idx,)) + if idx == sel_idx: + model.set_value(itr, 2, True) + else: + model.set_value(itr, 2, False) + pass + pass + pass + def _switch_timeline(self): domview_ui = self._domview_ui timeline_name = self._current_timeline() domview_ui.switch_timeline(timeline_name) + + self._sel_timeline(timeline_name) pass def _prepare_FSM_editor(self):
--- a/pyink/component_dock.glade Sat Apr 16 23:29:37 2011 +0800 +++ b/pyink/component_dock.glade Sun Apr 17 01:03:07 2011 +0800 @@ -2,20 +2,28 @@ <interface> <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy project-wide --> + <object class="GtkListStore" id="timelines_model"> + <columns> + <!-- column-name name --> + <column type="gchararray"/> + <!-- column-name editable --> + <column type="gboolean"/> + <!-- column-name selected --> + <column type="gboolean"/> + <!-- column-name selicon --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkListStore" id="components_model"> <columns> <!-- column-name name --> <column type="gchararray"/> <!-- column-name editable --> <column type="gboolean"/> - </columns> - </object> - <object class="GtkListStore" id="timelines_model"> - <columns> - <!-- column-name name --> + <!-- column-name selected --> + <column type="gboolean"/> + <!-- column-name selicon --> <column type="gchararray"/> - <!-- column-name editable --> - <column type="gboolean"/> </columns> </object> <object class="GtkWindow" id="window1"> @@ -36,6 +44,17 @@ <signal name="button_press_event" handler="on_treeview_components_button_press_event"/> <signal name="row_activated" handler="on_treeview_components_row_activated"/> <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <child> + <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf2"/> + <attributes> + <attribute name="visible">2</attribute> + <attribute name="stock-id">3</attribute> + </attributes> + </child> + </object> + </child> + <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> <property name="sizing">autosize</property> <property name="title">Component Name</property> @@ -128,9 +147,21 @@ <property name="search_column">1</property> <property name="level_indentation">9</property> <property name="enable_grid_lines">horizontal</property> + <property name="tooltip_column">0</property> <signal name="button_press_event" handler="on_treeview_timelines_button_press_event"/> <signal name="row_activated" handler="on_treeview_timelines_row_activated"/> <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <child> + <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/> + <attributes> + <attribute name="visible">2</attribute> + <attribute name="stock-id">3</attribute> + </attributes> + </child> + </object> + </child> + <child> <object class="GtkTreeViewColumn" id="treeviewcolumn2"> <property name="title">Action/Timeline Name</property> <child>