Merge lp:~spud/spud/group-view into lp:spud

Proposed by Fraser Waters
Status: Superseded
Proposed branch: lp:~spud/spud/group-view
Merge into: lp:spud
Prerequisite: lp:~spud/spud/slice-view
Diff against target: 581 lines (+191/-93)
4 files modified
diamond/diamond/choice.py (+6/-0)
diamond/diamond/interface.py (+150/-89)
diamond/diamond/tree.py (+4/-1)
diamond/gui/gui.glade (+31/-3)
To merge this branch: bzr merge lp:~spud/spud/group-view
Reviewer Review Type Date Requested Status
Patrick Farrell Pending
Review via email: mp+69242@code.launchpad.net

This proposal has been superseded by a proposal from 2011-07-26.

Description of the change

Allows nodes to be grouped together in the LHS hiding all other nodes.

To post a comment you must log in.
lp:~spud/spud/group-view updated
449. By Fraser Waters

Merge from trunk.

450. By Fraser Waters

Added edit menu options. Fixed grouping on whole tree.

451. By Fraser Waters

Changed __class__ == to isinstance

452. By Fraser Waters

Choices and optionals show in group view.

453. By Fraser Waters

__str__ on Tree and Choice returns the display name.

454. By Fraser Waters

In group mode use name paths, in normal mode use display names.

455. By Fraser Waters

Refresh fix.

456. By Fraser Waters

Select the node you group or ungroup on.

457. By Fraser Waters

Grouping bug fix for choices.

458. By Fraser Waters

Fixed long names, and more choice bugs

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'diamond/diamond/choice.py'
--- diamond/diamond/choice.py 2011-07-25 13:41:47 +0000
+++ diamond/diamond/choice.py 2011-07-26 16:14:06 +0000
@@ -196,5 +196,11 @@
196196
197 def is_sliceable(self):197 def is_sliceable(self):
198 return self.get_current_tree().is_sliceable()198 return self.get_current_tree().is_sliceable()
199
200 def __str__(self):
201 """
202 Returns the display name of the selected tree.
203 """
204 return self.get_display_name()
199205
200gobject.type_register(Choice)206gobject.type_register(Choice)
201207
=== modified file 'diamond/diamond/interface.py'
--- diamond/diamond/interface.py 2011-07-25 13:51:34 +0000
+++ diamond/diamond/interface.py 2011-07-26 16:14:06 +0000
@@ -90,7 +90,7 @@
90 treeview: the LHS tree widget90 treeview: the LHS tree widget
9191
92Important routines:92Important routines:
93 cellcombo_edited: called when a choice is selected on the left-hand pane93 cellcombo_changed: called when a choice is selected on the left-hand pane
94 init_treemodel: set up the treemodel and treeview94 init_treemodel: set up the treemodel and treeview
95 on_treeview_clicked: when a row is clicked, process the consequences (e.g. activate inactive instance)95 on_treeview_clicked: when a row is clicked, process the consequences (e.g. activate inactive instance)
96 set_treestore: stuff the treestore with a given tree.Tree96 set_treestore: stuff the treestore with a given tree.Tree
@@ -139,7 +139,10 @@
139 "on_copy_spud_path": self.on_copy_spud_path,139 "on_copy_spud_path": self.on_copy_spud_path,
140 "on_copy": self.on_copy,140 "on_copy": self.on_copy,
141 "on_paste": self.on_paste,141 "on_paste": self.on_paste,
142 "on_slice": self.on_slice}142 "on_slice": self.on_slice,
143 "on_group": self.on_group,
144 "on_ungroup": self.on_ungroup}
145
143 self.gui.signal_autoconnect(signals)146 self.gui.signal_autoconnect(signals)
144147
145 self.main_window = self.gui.get_widget("mainWindow")148 self.main_window = self.gui.get_widget("mainWindow")
@@ -157,6 +160,7 @@
157 self.suffix = suffix160 self.suffix = suffix
158161
159 self.selected_node = None162 self.selected_node = None
163 self.selected_iter = None
160 self.update_options_frame()164 self.update_options_frame()
161165
162 self.file_path = os.getcwd()166 self.file_path = os.getcwd()
@@ -668,7 +672,7 @@
668 ios = StringIO.StringIO(clipboard.wait_for_text())672 ios = StringIO.StringIO(clipboard.wait_for_text())
669 673
670 if self.selected_iter is not None: 674 if self.selected_iter is not None:
671 node = self.treestore.get_value(self.selected_iter, 3)675 node = self.treestore.get_value(self.selected_iter, 1)
672676
673 if node != None:677 if node != None:
674678
@@ -729,6 +733,80 @@
729 def _slice_destroy(self, widget):733 def _slice_destroy(self, widget):
730 self.on_select_row()734 self.on_select_row()
731735
736
737 groupmode = False
738
739 def on_group(self, widget = None):
740 """
741 Clears the treeview and then fills it with nodes
742 with the same type as the selected node.
743 """
744
745 if self.selected_node == self.tree or not self.selected_iter:
746 self.statusbar.set_statusbar("Cannot group on this element.")
747 return #Group on the entire tree... ie don't group or nothing selected
748
749 self.gui.get_widget("menuitemUngroup").show()
750 self.gui.get_widget("popupmenuitemUngroup").show()
751
752 self.groupmode = True
753 node, tree = self.treestore.get(self.selected_iter, 0, 1)
754
755 self.treeview.freeze_child_notify()
756 self.treeview.set_model(None)
757
758 def get_nodes(node, tree):
759 nodes = []
760
761 if isinstance(tree, choice.Choice):
762 child = tree.get_current_tree()
763 if child.name == node.name:
764 nodes.append(tree)
765 nodes += get_nodes(node, child)
766 else:
767 for child in tree.get_children():
768 if child.name == node.name:
769 nodes.append(child)
770 nodes += get_nodes(node, child)
771
772 return nodes
773
774 self.set_treestore(None, get_nodes(tree, self.tree), True)
775
776 self.treeview.set_model(self.treestore)
777 self.treeview.thaw_child_notify()
778
779 path = self.get_treestore_path_from_node(node)
780 self.treeview.get_selection().select_path(path)
781
782 return
783
784 def on_ungroup(self, widget = None):
785 """
786 Restores the treeview to normal.
787 """
788
789 self.gui.get_widget("menuitemUngroup").hide()
790 self.gui.get_widget("popupmenuitemUngroup").hide()
791
792 self.groupmode = False
793 node = self.treestore.get_value(self.selected_iter, 0)
794
795 self.treeview.freeze_child_notify()
796 self.treeview.set_model(None)
797
798 self.set_treestore(None, [self.tree], True)
799
800 self.treeview.set_model(self.treestore)
801 self.treeview.thaw_child_notify()
802
803 path = self.get_treestore_path_from_node(node)
804 self.treeview.expand_to_path(path)
805 self.treeview.scroll_to_cell(path)
806 self.treeview.get_selection().select_path(path)
807
808 return
809
732 ## LHS ###810 ## LHS ###
733811
734 def init_datatree(self):812 def init_datatree(self):
@@ -773,16 +851,14 @@
773 self.treeview.get_selection().set_select_function(self.options_tree_select_func)851 self.treeview.get_selection().set_select_function(self.options_tree_select_func)
774 self.options_tree_select_func_enabled = True852 self.options_tree_select_func_enabled = True
775853
776 model = gtk.ListStore(str, str, gobject.TYPE_PYOBJECT)
777 self.cellcombo = cellCombo = gtk.CellRendererCombo()854 self.cellcombo = cellCombo = gtk.CellRendererCombo()
778 cellCombo.set_property("model", model)
779 cellCombo.set_property("text-column", 0)855 cellCombo.set_property("text-column", 0)
780 cellCombo.set_property("editable", True)856 cellCombo.set_property("editable", True)
781 cellCombo.set_property("has-entry", False)857 cellCombo.set_property("has-entry", False)
782 cellCombo.connect("edited", self.cellcombo_edited)858 cellCombo.connect("changed", self.cellcombo_changed)
783859
784 # Node column860 # Node column
785 column = gtk.TreeViewColumn("Node", cellCombo, text=0)861 column = gtk.TreeViewColumn("Node", cellCombo)
786 column.set_property("expand", True)862 column.set_property("expand", True)
787 column.set_resizable(True)863 column.set_resizable(True)
788 column.set_cell_data_func(cellCombo, self.set_combobox_liststore)864 column.set_cell_data_func(cellCombo, self.set_combobox_liststore)
@@ -800,12 +876,11 @@
800 imgcolumn.set_cell_data_func(cellPicture, self.set_cellpicture_cardinality)876 imgcolumn.set_cell_data_func(cellPicture, self.set_cellpicture_cardinality)
801 optionsTree.append_column(imgcolumn)877 optionsTree.append_column(imgcolumn)
802878
803 # 0: display name, 879 # 0: pointer to node in self.tree -- a choice or a tree
804 # 1: gtk.ListStore containing the display names of possible choices880 # 1: pointer to currently active tree
805 # 2: pointer to node in self.tree -- a choice or a tree881 # 2: gtk.ListStore containing the display names of possible choices
806 # 3: pointer to currently active tree
807882
808 self.treestore = gtk.TreeStore(str, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)883 self.treestore = gtk.TreeStore(gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)
809 self.treeview.set_model(self.treestore)884 self.treeview.set_model(self.treestore)
810 self.treeview.set_enable_search(False)885 self.treeview.set_enable_search(False)
811886
@@ -820,8 +895,7 @@
820 liststore = gtk.ListStore(str, gobject.TYPE_PYOBJECT)895 liststore = gtk.ListStore(str, gobject.TYPE_PYOBJECT)
821896
822 for t in choice_or_tree.get_choices():897 for t in choice_or_tree.get_choices():
823 name = t.get_display_name()898 liststore.append([str(t), t])
824 liststore.append([name, t])
825899
826 return liststore900 return liststore
827 901
@@ -851,9 +925,9 @@
851 liststore = self.create_liststore(t)925 liststore = self.create_liststore(t)
852926
853 if replace:927 if replace:
854 child_iter = self.treestore.insert_before(iter, replacediter, [t.get_display_name(), liststore, t, t])928 child_iter = self.treestore.insert_before(iter, replacediter, [t, t, liststore])
855 else:929 else:
856 child_iter = self.treestore.append(iter, [t.get_display_name(), liststore, t, t])930 child_iter = self.treestore.append(iter, [t, t, liststore])
857931
858 attrid = t.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(child_iter))932 attrid = t.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(child_iter))
859 dataid = t.connect("on-set-data", self.on_set_data, self.treestore.get_path(child_iter))933 dataid = t.connect("on-set-data", self.on_set_data, self.treestore.get_path(child_iter))
@@ -871,9 +945,9 @@
871 continue945 continue
872946
873 if replace:947 if replace:
874 child_iter = self.treestore.insert_before(iter, replacediter, [ts_choice.get_display_name(), liststore, t, ts_choice])948 child_iter = self.treestore.insert_before(iter, replacediter, [t, ts_choice, liststore])
875 else:949 else:
876 child_iter = self.treestore.append(iter, [ts_choice.get_display_name(), liststore, t, ts_choice])950 child_iter = self.treestore.append(iter, [t, ts_choice, liststore])
877951
878 attrid = t.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(child_iter))952 attrid = t.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(child_iter))
879 dataid = t.connect("on-set-data", self.on_set_data, self.treestore.get_path(child_iter))953 dataid = t.connect("on-set-data", self.on_set_data, self.treestore.get_path(child_iter))
@@ -916,7 +990,7 @@
916 self.set_treestore(iter, [])990 self.set_treestore(iter, [])
917 return991 return
918992
919 choice_or_tree, active_tree = self.treestore.get(iter, 2, 3)993 choice_or_tree, active_tree = self.treestore.get(iter, 0, 1)
920 if active_tree.active is False or choice_or_tree.active is False:994 if active_tree.active is False or choice_or_tree.active is False:
921 return995 return
922996
@@ -927,7 +1001,7 @@
927 child_iter = self.treestore.iter_children(iter)1001 child_iter = self.treestore.iter_children(iter)
928 while child_iter is not None:1002 while child_iter is not None:
929 # fix for recursive schemata!1003 # fix for recursive schemata!
930 child_active_tree = self.treestore.get_value(child_iter, 3)1004 child_active_tree = self.treestore.get_value(child_iter, 1)
931 if child_active_tree.schemaname == active_tree.schemaname:1005 if child_active_tree.schemaname == active_tree.schemaname:
932 debug.deprint("Warning: recursive schema elements not supported: %s" % active_tree.name)1006 debug.deprint("Warning: recursive schema elements not supported: %s" % active_tree.name)
933 child_iter = self.treestore.iter_next(child_iter)1007 child_iter = self.treestore.iter_next(child_iter)
@@ -961,15 +1035,20 @@
961 foreground colour.1035 foreground colour.
962 """1036 """
9631037
964 liststore, choice_or_tree, active_tree = self.treestore.get(iter, 1, 2, 3)1038 choice_or_tree, active_tree, liststore = self.treestore.get(iter, 0, 1, 2)
9651039
966 # set the model for the cellcombo, where it gets the possible choices for the name1040 if self.groupmode and self.treestore.iter_parent(iter) is None:
1041 cellCombo.set_property("text", choice_or_tree.get_name_path())
1042 else:
1043 cellCombo.set_property("text", str(choice_or_tree))
1044
1045
967 cellCombo.set_property("model", liststore)1046 cellCombo.set_property("model", liststore)
9681047
969 # set the properties: colour, etc.1048 # set the properties: colour, etc.
970 if choice_or_tree.__class__ is tree.Tree:1049 if isinstance(choice_or_tree, tree.Tree):
971 cellCombo.set_property("editable", False)1050 cellCombo.set_property("editable", False)
972 elif choice_or_tree.__class__ is choice.Choice:1051 elif isinstance(choice_or_tree, choice.Choice):
973 cellCombo.set_property("editable", True)1052 cellCombo.set_property("editable", True)
9741053
975 if self.treestore_iter_is_active(iter):1054 if self.treestore_iter_is_active(iter):
@@ -987,8 +1066,8 @@
987 This hook function sets up the other gtk.CellRendererPixbuf, the one that gives1066 This hook function sets up the other gtk.CellRendererPixbuf, the one that gives
988 the clue to the user whether this is a choice or not.1067 the clue to the user whether this is a choice or not.
989 """1068 """
9901069
991 choice_or_tree = self.treestore.get_value(iter, 2)1070 choice_or_tree = self.treestore.get_value(iter, 0)
992 if isinstance(choice_or_tree, tree.Tree):1071 if isinstance(choice_or_tree, tree.Tree):
993 cell.set_property("stock-id", None)1072 cell.set_property("stock-id", None)
994 elif isinstance(choice_or_tree, choice.Choice):1073 elif isinstance(choice_or_tree, choice.Choice):
@@ -1003,7 +1082,7 @@
1003 something can be added or removed or has to be there.1082 something can be added or removed or has to be there.
1004 """1083 """
10051084
1006 choice_or_tree = self.treestore.get_value(iter, 2)1085 choice_or_tree = self.treestore.get_value(iter, 0)
1007 if choice_or_tree.cardinality == "":1086 if choice_or_tree.cardinality == "":
1008 cell.set_property("stock-id", None)1087 cell.set_property("stock-id", None)
1009 elif choice_or_tree.cardinality == "?" or choice_or_tree.cardinality == "*":1088 elif choice_or_tree.cardinality == "?" or choice_or_tree.cardinality == "*":
@@ -1029,7 +1108,7 @@
1029 Toggles the state of part of the tree.1108 Toggles the state of part of the tree.
1030 """1109 """
10311110
1032 choice_or_tree = self.treestore.get_value(iter, 2)1111 choice_or_tree = self.treestore.get_value(iter, 0)
10331112
1034 if choice_or_tree.active:1113 if choice_or_tree.active:
1035 self.collapse_tree(iter)1114 self.collapse_tree(iter)
@@ -1045,13 +1124,8 @@
1045 Collapses part of the tree.1124 Collapses part of the tree.
1046 """1125 """
10471126
1048 choice_or_tree, = self.treestore.get(iter, 2)1127 choice_or_tree, = self.treestore.get(iter, 0)
1049 parent_iter = self.treestore.iter_parent(iter)1128 parent_tree = choice_or_tree.parent
1050
1051 if parent_iter == None:
1052 parent_tree = None
1053 else:
1054 parent_tree = self.treestore.get_value(parent_iter, 3)
10551129
1056 if not choice_or_tree.active:1130 if not choice_or_tree.active:
1057 return1131 return
@@ -1088,16 +1162,11 @@
1088 return1162 return
10891163
1090 def delete_tree(self, iter):1164 def delete_tree(self, iter):
1091 choice_or_tree, = self.treestore.get(iter, 2)1165 choice_or_tree, = self.treestore.get(iter, 0)
1092 parent_iter = self.treestore.iter_parent(iter)1166 parent_tree = choice_or_tree.parent
1093 isSelected = self.treeview.get_selection().iter_is_selected(iter)1167 isSelected = self.treeview.get_selection().iter_is_selected(iter)
1094 sibling = self.treestore.iter_next(iter)1168 sibling = self.treestore.iter_next(iter)
10951169
1096 if parent_iter == None:
1097 parent_tree = None
1098 else:
1099 parent_tree = self.treestore.get_value(parent_iter, 3)
1100
1101 confirm = dialogs.prompt(self.main_window, "Are you sure you want to delete this node?")1170 confirm = dialogs.prompt(self.main_window, "Are you sure you want to delete this node?")
1102 if confirm == gtk.RESPONSE_YES:1171 if confirm == gtk.RESPONSE_YES:
1103 parent_tree.delete_child_by_ref(choice_or_tree)1172 parent_tree.delete_child_by_ref(choice_or_tree)
@@ -1114,13 +1183,8 @@
1114 Expands part of the tree.1183 Expands part of the tree.
1115 """1184 """
11161185
1117 choice_or_tree, active_tree = self.treestore.get(iter, 2, 3)1186 choice_or_tree, active_tree = self.treestore.get(iter, 0, 1)
1118 parent_iter = self.treestore.iter_parent(iter)1187 parent_tree = choice_or_tree.parent
1119
1120 if parent_iter == None:
1121 parent_tree = None
1122 else:
1123 parent_tree = self.treestore.get_value(parent_iter, 3)
11241188
1125 if choice_or_tree.active:1189 if choice_or_tree.active:
1126 return1190 return
@@ -1140,8 +1204,7 @@
1140 liststore = self.create_liststore(new_tree)1204 liststore = self.create_liststore(new_tree)
1141 self.expand_treestore(iter)1205 self.expand_treestore(iter)
1142 iter = self.treestore.insert_after(1206 iter = self.treestore.insert_after(
1143 parent=parent_iter, sibling=iter, 1207 None, iter, [new_tree, new_tree.get_current_tree(), liststore])
1144 row=[new_tree.get_display_name(), liststore, new_tree, new_tree.get_current_tree()])
1145 attrid = new_tree.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(iter))1208 attrid = new_tree.connect("on-set-attr", self.on_set_attr, self.treestore.get_path(iter))
1146 dataid = new_tree.connect("on-set-data", self.on_set_data, self.treestore.get_path(iter))1209 dataid = new_tree.connect("on-set-data", self.on_set_data, self.treestore.get_path(iter))
1147 self.signals[new_tree] = (attrid, dataid)1210 self.signals[new_tree] = (attrid, dataid)
@@ -1243,7 +1306,7 @@
1243 return 1306 return
12441307
1245 self.selected_iter = iter = self.treestore.get_iter(path)1308 self.selected_iter = iter = self.treestore.get_iter(path)
1246 choice_or_tree, active_tree = self.treestore.get(iter, 2, 3)1309 choice_or_tree, active_tree = self.treestore.get(iter, 0, 1)
12471310
1248 debug.dprint(active_tree)1311 debug.dprint(active_tree)
12491312
@@ -1367,26 +1430,18 @@
13671430
1368 return1431 return
13691432
1370 def cellcombo_edited(self, cellrenderertext, path, new_text):1433 def cellcombo_changed(self, combo, tree_path, combo_iter):
1371 """1434 """
1372 This is called when a cellcombo on the left-hand treeview is edited,1435 This is called when a cellcombo on the left-hand treeview is edited,
1373 i.e. the user chooses between more than one possible choice.1436 i.e. the user chooses between more than one possible choice.
1374 """1437 """
13751438
1376 iter = self.treestore.get_iter(path)1439 tree_iter = self.treestore.get_iter(tree_path)
1377 self.treestore.set(iter, 0, new_text)1440 choice = self.treestore.get_value(tree_iter, 0)
1378 choice = self.treestore.get_value(iter, 2)
13791441
1380 # get the ref to the new active choice1442 # get the ref to the new active choice
1381 liststore = self.treestore.get_value(iter, 1)1443 liststore = self.treestore.get_value(tree_iter, 2)
1382 list_iter = liststore.get_iter_first()1444 ref = liststore.get_value(combo_iter, 1)
1383 ref = None
1384 while list_iter is not None:
1385 list_text = liststore.get_value(list_iter, 0)
1386 if list_text == new_text:
1387 ref = liststore.get_value(list_iter, 1)
1388 break
1389 list_iter = liststore.iter_next(list_iter)
13901445
1391 # record the choice in the datatree1446 # record the choice in the datatree
1392 choice.set_active_choice_by_ref(ref)1447 choice.set_active_choice_by_ref(ref)
@@ -1394,7 +1449,7 @@
13941449
1395 name = self.get_spudpath(new_active_tree)1450 name = self.get_spudpath(new_active_tree)
1396 self.statusbar.set_statusbar(name)1451 self.statusbar.set_statusbar(name)
1397 self.treestore.set(iter, 3, new_active_tree)1452 self.treestore.set(tree_iter, 1, new_active_tree)
1398 self.current_spudpath = name1453 self.current_spudpath = name
1399 xpath = self.get_xpath(new_active_tree)1454 xpath = self.get_xpath(new_active_tree)
1400 self.current_xpath = xpath1455 self.current_xpath = xpath
@@ -1405,12 +1460,12 @@
1405 if plugin.matches(xpath):1460 if plugin.matches(xpath):
1406 self.add_plugin_button(plugin)1461 self.add_plugin_button(plugin)
14071462
1408 self.remove_children(iter)1463 self.remove_children(tree_iter)
1409 self.expand_treestore(iter)1464 self.expand_treestore(tree_iter)
1410 self.treeview.expand_row(path, False)1465 self.treeview.expand_row(tree_path, False)
14111466
1412 self.set_saved(False)1467 self.set_saved(False)
1413 self.selected_node = self.get_painted_tree(iter)1468 self.selected_node = self.get_painted_tree(tree_iter)
1414 self.update_options_frame()1469 self.update_options_frame()
14151470
1416 return1471 return
@@ -1435,20 +1490,7 @@
1435 if attr != "name":1490 if attr != "name":
1436 return1491 return
14371492
1438 iter = self.treestore.get_iter(path)1493 self.treeview.queue_draw()
1439 liststore = self.treestore.get_value(iter, 1)
1440 active_tree = self.treestore.get_value(iter, 3)
1441 new_name = active_tree.get_display_name()
1442 self.treestore.set_value(iter, 0, new_name)
1443
1444 # find the liststore iter corresponding to the painted choice
1445 list_iter = liststore.get_iter_first()
1446 while list_iter is not None:
1447 liststore_tree = liststore.get_value(list_iter, 1)
1448 if liststore_tree is active_tree:
1449 liststore.set_value(list_iter, 0, new_name)
1450 list_iter = liststore.iter_next(list_iter)
1451
1452 self.treeview.queue_resize()1494 self.treeview.queue_resize()
14531495
1454 def get_painted_tree(self, iter_or_tree, lock_geometry_dim = True):1496 def get_painted_tree(self, iter_or_tree, lock_geometry_dim = True):
@@ -1465,7 +1507,7 @@
1465 if isinstance(iter_or_tree, tree.Tree):1507 if isinstance(iter_or_tree, tree.Tree):
1466 active_tree = iter_or_tree1508 active_tree = iter_or_tree
1467 else:1509 else:
1468 active_tree = self.treestore.get_value(iter_or_tree, 3)1510 active_tree = self.treestore.get_value(iter_or_tree, 1)
14691511
1470 painted_tree = active_tree.get_mixed_data()1512 painted_tree = active_tree.get_mixed_data()
14711513
@@ -1505,7 +1547,26 @@
1505 return None1547 return None
15061548
1507 return iter1549 return iter
1550
1551 def get_treestore_path_from_node(self, node):
1552 """
1553 Look for the path for the given node.
1554 """
1508 1555
1556 def search(iter, node, indent=""):
1557 while iter:
1558 if self.treestore.get_value(iter, 0) is node:
1559 return iter
1560 else:
1561 child = search(self.treestore.iter_children(iter), node, indent + " ")
1562 if child: return child
1563
1564 iter = self.treestore.iter_next(iter)
1565 return iter
1566
1567 iter = search(self.treestore.get_iter_first(), node)
1568 return self.treestore.get_path(iter) if iter else None
1569
1509 def set_geometry_dim_tree(self):1570 def set_geometry_dim_tree(self):
1510 """1571 """
1511 Find the iter into the treestore corresponding to the geometry dimension, and1572 Find the iter into the treestore corresponding to the geometry dimension, and
@@ -1567,8 +1628,8 @@
1567 """1628 """
15681629
1569 while iter is not None:1630 while iter is not None:
1570 choice_or_tree = self.treestore.get_value(iter, 2)1631 choice_or_tree = self.treestore.get_value(iter, 0)
1571 active_tree = self.treestore.get_value(iter, 3)1632 active_tree = self.treestore.get_value(iter, 1)
1572 if not choice_or_tree.active or not active_tree.active:1633 if not choice_or_tree.active or not active_tree.active:
1573 return False1634 return False
1574 iter = self.treestore.iter_parent(iter)1635 iter = self.treestore.iter_parent(iter)
@@ -1629,7 +1690,7 @@
1629 iter = self.treestore.get_iter_first()1690 iter = self.treestore.get_iter_first()
1630 if iter is None:1691 if iter is None:
1631 yield None1692 yield None
1632 choice_or_tree = self.treestore.get_value(iter, 2)1693 choice_or_tree = self.treestore.get_value(iter, 0)
16331694
1634 if self.choice_or_tree_matches(text, choice_or_tree, isinstance(choice_or_tree, choice.Choice)):1695 if self.choice_or_tree_matches(text, choice_or_tree, isinstance(choice_or_tree, choice.Choice)):
1635 yield iter1696 yield iter
16361697
=== modified file 'diamond/diamond/tree.py'
--- diamond/diamond/tree.py 2011-07-25 13:41:47 +0000
+++ diamond/diamond/tree.py 2011-07-26 16:14:06 +0000
@@ -301,7 +301,7 @@
301 def unpickle(self, pick):301 def unpickle(self, pick):
302 return pickle.loads(bz2.decompress(base64.b64decode(pick)))302 return pickle.loads(bz2.decompress(base64.b64decode(pick)))
303303
304 def __str__(self):304 def print_str(self):
305 s = "name: %s at %s\n" % (self.name, hex(id(self)))305 s = "name: %s at %s\n" % (self.name, hex(id(self)))
306 s = s + "schemaname: %s\n" % self.schemaname306 s = s + "schemaname: %s\n" % self.schemaname
307 s = s + "attrs: %s\n" % self.attrs307 s = s + "attrs: %s\n" % self.attrs
@@ -538,6 +538,9 @@
538 return True538 return True
539 539
540 return (self.datatype is not None and self.datatype != "fixed") or self.attrs540 return (self.datatype is not None and self.datatype != "fixed") or self.attrs
541
542 def __str__(self):
543 return self.get_display_name()
541 544
542gobject.type_register(Tree)545gobject.type_register(Tree)
543546
544547
=== modified file 'diamond/gui/gui.glade'
--- diamond/gui/gui.glade 2011-07-22 15:46:25 +0000
+++ diamond/gui/gui.glade 2011-07-26 16:14:06 +0000
@@ -132,6 +132,20 @@
132 <accelerator key="V" signal="activate" modifiers="GDK_CONTROL_MASK"/>132 <accelerator key="V" signal="activate" modifiers="GDK_CONTROL_MASK"/>
133 </widget>133 </widget>
134 </child>134 </child>
135 <child>
136 <widget class="GtkMenuItem" id="menuitemGroup">
137 <property name="visible">True</property>
138 <property name="label" translatable="yes">Group</property>
139 <signal name="activate" handler="on_group"/>
140 </widget>
141 </child>
142 <child>
143 <widget class="GtkMenuItem" id="menuitemUngroup">
144 <property name="visible">False</property>
145 <property name="label" translatable="yes">Ungroup</property>
146 <signal name="activate" handler="on_ungroup"/>
147 </widget>
148 </child>
135 </widget>149 </widget>
136 </child>150 </child>
137 </widget>151 </widget>
@@ -488,7 +502,7 @@
488 <widget class="GtkMenu" id="popupmenu">502 <widget class="GtkMenu" id="popupmenu">
489 <property name="visible">True</property>503 <property name="visible">True</property>
490 <child>504 <child>
491 <widget class="GtkMenuItem" id="menuitemCopy">505 <widget class="GtkMenuItem" id="popupmenuitemCopy">
492 <property name="visible">True</property>506 <property name="visible">True</property>
493 <property name="label" translatable="yes">Copy</property>507 <property name="label" translatable="yes">Copy</property>
494 <property name="use_underline">True</property>508 <property name="use_underline">True</property>
@@ -496,7 +510,7 @@
496 </widget>510 </widget>
497 </child>511 </child>
498 <child>512 <child>
499 <widget class="GtkMenuItem" id="menuitemPaste">513 <widget class="GtkMenuItem" id="popupmenuitemPaste">
500 <property name="visible">True</property>514 <property name="visible">True</property>
501 <property name="label" translatable="yes">Paste</property>515 <property name="label" translatable="yes">Paste</property>
502 <property name="use_underline">True</property>516 <property name="use_underline">True</property>
@@ -504,12 +518,26 @@
504 </widget>518 </widget>
505 </child>519 </child>
506 <child>520 <child>
507 <widget class="GtkMenuItem" id="menuitemSlice">521 <widget class="GtkMenuItem" id="popupmenuitemSlice">
508 <property name="visible">True</property>522 <property name="visible">True</property>
509 <property name="label" translatable="yes">Slice</property>523 <property name="label" translatable="yes">Slice</property>
510 <property name="use_underline">True</property>524 <property name="use_underline">True</property>
511 <signal name="activate" handler="on_slice"/>525 <signal name="activate" handler="on_slice"/>
512 </widget>526 </widget>
513 </child>527 </child>
528 <child>
529 <widget class="GtkMenuItem" id="popupmenuitemGroup">
530 <property name="visible">True</property>
531 <property name="label" translatable="yes">Group</property>
532 <signal name="activate" handler="on_group"/>
533 </widget>
534 </child>
535 <child>
536 <widget class="GtkMenuItem" id="popupmenuitemUngroup">
537 <property name="visible">False</property>
538 <property name="label" translatable="yes">Ungroup</property>
539 <signal name="activate" handler="on_ungroup"/>
540 </widget>
541 </child>
514 </widget>542 </widget>
515</glade-interface>543</glade-interface>

Subscribers

People subscribed via source and target branches