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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Patrick Farrell | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2011-07-26.
Commit message
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
1 | === modified file 'diamond/diamond/choice.py' | |||
2 | --- diamond/diamond/choice.py 2011-07-25 13:41:47 +0000 | |||
3 | +++ diamond/diamond/choice.py 2011-07-26 16:14:06 +0000 | |||
4 | @@ -196,5 +196,11 @@ | |||
5 | 196 | 196 | ||
6 | 197 | def is_sliceable(self): | 197 | def is_sliceable(self): |
7 | 198 | return self.get_current_tree().is_sliceable() | 198 | return self.get_current_tree().is_sliceable() |
8 | 199 | |||
9 | 200 | def __str__(self): | ||
10 | 201 | """ | ||
11 | 202 | Returns the display name of the selected tree. | ||
12 | 203 | """ | ||
13 | 204 | return self.get_display_name() | ||
14 | 199 | 205 | ||
15 | 200 | gobject.type_register(Choice) | 206 | gobject.type_register(Choice) |
16 | 201 | 207 | ||
17 | === modified file 'diamond/diamond/interface.py' | |||
18 | --- diamond/diamond/interface.py 2011-07-25 13:51:34 +0000 | |||
19 | +++ diamond/diamond/interface.py 2011-07-26 16:14:06 +0000 | |||
20 | @@ -90,7 +90,7 @@ | |||
21 | 90 | treeview: the LHS tree widget | 90 | treeview: the LHS tree widget |
22 | 91 | 91 | ||
23 | 92 | Important routines: | 92 | Important routines: |
25 | 93 | cellcombo_edited: called when a choice is selected on the left-hand pane | 93 | cellcombo_changed: called when a choice is selected on the left-hand pane |
26 | 94 | init_treemodel: set up the treemodel and treeview | 94 | init_treemodel: set up the treemodel and treeview |
27 | 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) |
28 | 96 | set_treestore: stuff the treestore with a given tree.Tree | 96 | set_treestore: stuff the treestore with a given tree.Tree |
29 | @@ -139,7 +139,10 @@ | |||
30 | 139 | "on_copy_spud_path": self.on_copy_spud_path, | 139 | "on_copy_spud_path": self.on_copy_spud_path, |
31 | 140 | "on_copy": self.on_copy, | 140 | "on_copy": self.on_copy, |
32 | 141 | "on_paste": self.on_paste, | 141 | "on_paste": self.on_paste, |
34 | 142 | "on_slice": self.on_slice} | 142 | "on_slice": self.on_slice, |
35 | 143 | "on_group": self.on_group, | ||
36 | 144 | "on_ungroup": self.on_ungroup} | ||
37 | 145 | |||
38 | 143 | self.gui.signal_autoconnect(signals) | 146 | self.gui.signal_autoconnect(signals) |
39 | 144 | 147 | ||
40 | 145 | self.main_window = self.gui.get_widget("mainWindow") | 148 | self.main_window = self.gui.get_widget("mainWindow") |
41 | @@ -157,6 +160,7 @@ | |||
42 | 157 | self.suffix = suffix | 160 | self.suffix = suffix |
43 | 158 | 161 | ||
44 | 159 | self.selected_node = None | 162 | self.selected_node = None |
45 | 163 | self.selected_iter = None | ||
46 | 160 | self.update_options_frame() | 164 | self.update_options_frame() |
47 | 161 | 165 | ||
48 | 162 | self.file_path = os.getcwd() | 166 | self.file_path = os.getcwd() |
49 | @@ -668,7 +672,7 @@ | |||
50 | 668 | ios = StringIO.StringIO(clipboard.wait_for_text()) | 672 | ios = StringIO.StringIO(clipboard.wait_for_text()) |
51 | 669 | 673 | ||
52 | 670 | if self.selected_iter is not None: | 674 | if self.selected_iter is not None: |
54 | 671 | node = self.treestore.get_value(self.selected_iter, 3) | 675 | node = self.treestore.get_value(self.selected_iter, 1) |
55 | 672 | 676 | ||
56 | 673 | if node != None: | 677 | if node != None: |
57 | 674 | 678 | ||
58 | @@ -729,6 +733,80 @@ | |||
59 | 729 | def _slice_destroy(self, widget): | 733 | def _slice_destroy(self, widget): |
60 | 730 | self.on_select_row() | 734 | self.on_select_row() |
61 | 731 | 735 | ||
62 | 736 | |||
63 | 737 | groupmode = False | ||
64 | 738 | |||
65 | 739 | def on_group(self, widget = None): | ||
66 | 740 | """ | ||
67 | 741 | Clears the treeview and then fills it with nodes | ||
68 | 742 | with the same type as the selected node. | ||
69 | 743 | """ | ||
70 | 744 | |||
71 | 745 | if self.selected_node == self.tree or not self.selected_iter: | ||
72 | 746 | self.statusbar.set_statusbar("Cannot group on this element.") | ||
73 | 747 | return #Group on the entire tree... ie don't group or nothing selected | ||
74 | 748 | |||
75 | 749 | self.gui.get_widget("menuitemUngroup").show() | ||
76 | 750 | self.gui.get_widget("popupmenuitemUngroup").show() | ||
77 | 751 | |||
78 | 752 | self.groupmode = True | ||
79 | 753 | node, tree = self.treestore.get(self.selected_iter, 0, 1) | ||
80 | 754 | |||
81 | 755 | self.treeview.freeze_child_notify() | ||
82 | 756 | self.treeview.set_model(None) | ||
83 | 757 | |||
84 | 758 | def get_nodes(node, tree): | ||
85 | 759 | nodes = [] | ||
86 | 760 | |||
87 | 761 | if isinstance(tree, choice.Choice): | ||
88 | 762 | child = tree.get_current_tree() | ||
89 | 763 | if child.name == node.name: | ||
90 | 764 | nodes.append(tree) | ||
91 | 765 | nodes += get_nodes(node, child) | ||
92 | 766 | else: | ||
93 | 767 | for child in tree.get_children(): | ||
94 | 768 | if child.name == node.name: | ||
95 | 769 | nodes.append(child) | ||
96 | 770 | nodes += get_nodes(node, child) | ||
97 | 771 | |||
98 | 772 | return nodes | ||
99 | 773 | |||
100 | 774 | self.set_treestore(None, get_nodes(tree, self.tree), True) | ||
101 | 775 | |||
102 | 776 | self.treeview.set_model(self.treestore) | ||
103 | 777 | self.treeview.thaw_child_notify() | ||
104 | 778 | |||
105 | 779 | path = self.get_treestore_path_from_node(node) | ||
106 | 780 | self.treeview.get_selection().select_path(path) | ||
107 | 781 | |||
108 | 782 | return | ||
109 | 783 | |||
110 | 784 | def on_ungroup(self, widget = None): | ||
111 | 785 | """ | ||
112 | 786 | Restores the treeview to normal. | ||
113 | 787 | """ | ||
114 | 788 | |||
115 | 789 | self.gui.get_widget("menuitemUngroup").hide() | ||
116 | 790 | self.gui.get_widget("popupmenuitemUngroup").hide() | ||
117 | 791 | |||
118 | 792 | self.groupmode = False | ||
119 | 793 | node = self.treestore.get_value(self.selected_iter, 0) | ||
120 | 794 | |||
121 | 795 | self.treeview.freeze_child_notify() | ||
122 | 796 | self.treeview.set_model(None) | ||
123 | 797 | |||
124 | 798 | self.set_treestore(None, [self.tree], True) | ||
125 | 799 | |||
126 | 800 | self.treeview.set_model(self.treestore) | ||
127 | 801 | self.treeview.thaw_child_notify() | ||
128 | 802 | |||
129 | 803 | path = self.get_treestore_path_from_node(node) | ||
130 | 804 | self.treeview.expand_to_path(path) | ||
131 | 805 | self.treeview.scroll_to_cell(path) | ||
132 | 806 | self.treeview.get_selection().select_path(path) | ||
133 | 807 | |||
134 | 808 | return | ||
135 | 809 | |||
136 | 732 | ## LHS ### | 810 | ## LHS ### |
137 | 733 | 811 | ||
138 | 734 | def init_datatree(self): | 812 | def init_datatree(self): |
139 | @@ -773,16 +851,14 @@ | |||
140 | 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) |
141 | 774 | self.options_tree_select_func_enabled = True | 852 | self.options_tree_select_func_enabled = True |
142 | 775 | 853 | ||
143 | 776 | model = gtk.ListStore(str, str, gobject.TYPE_PYOBJECT) | ||
144 | 777 | self.cellcombo = cellCombo = gtk.CellRendererCombo() | 854 | self.cellcombo = cellCombo = gtk.CellRendererCombo() |
145 | 778 | cellCombo.set_property("model", model) | ||
146 | 779 | cellCombo.set_property("text-column", 0) | 855 | cellCombo.set_property("text-column", 0) |
147 | 780 | cellCombo.set_property("editable", True) | 856 | cellCombo.set_property("editable", True) |
148 | 781 | cellCombo.set_property("has-entry", False) | 857 | cellCombo.set_property("has-entry", False) |
150 | 782 | cellCombo.connect("edited", self.cellcombo_edited) | 858 | cellCombo.connect("changed", self.cellcombo_changed) |
151 | 783 | 859 | ||
152 | 784 | # Node column | 860 | # Node column |
154 | 785 | column = gtk.TreeViewColumn("Node", cellCombo, text=0) | 861 | column = gtk.TreeViewColumn("Node", cellCombo) |
155 | 786 | column.set_property("expand", True) | 862 | column.set_property("expand", True) |
156 | 787 | column.set_resizable(True) | 863 | column.set_resizable(True) |
157 | 788 | column.set_cell_data_func(cellCombo, self.set_combobox_liststore) | 864 | column.set_cell_data_func(cellCombo, self.set_combobox_liststore) |
158 | @@ -800,12 +876,11 @@ | |||
159 | 800 | imgcolumn.set_cell_data_func(cellPicture, self.set_cellpicture_cardinality) | 876 | imgcolumn.set_cell_data_func(cellPicture, self.set_cellpicture_cardinality) |
160 | 801 | optionsTree.append_column(imgcolumn) | 877 | optionsTree.append_column(imgcolumn) |
161 | 802 | 878 | ||
166 | 803 | # 0: display name, | 879 | # 0: pointer to node in self.tree -- a choice or a tree |
167 | 804 | # 1: gtk.ListStore containing the display names of possible choices | 880 | # 1: pointer to currently active tree |
168 | 805 | # 2: pointer to node in self.tree -- a choice or a tree | 881 | # 2: gtk.ListStore containing the display names of possible choices |
165 | 806 | # 3: pointer to currently active tree | ||
169 | 807 | 882 | ||
171 | 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) |
172 | 809 | self.treeview.set_model(self.treestore) | 884 | self.treeview.set_model(self.treestore) |
173 | 810 | self.treeview.set_enable_search(False) | 885 | self.treeview.set_enable_search(False) |
174 | 811 | 886 | ||
175 | @@ -820,8 +895,7 @@ | |||
176 | 820 | liststore = gtk.ListStore(str, gobject.TYPE_PYOBJECT) | 895 | liststore = gtk.ListStore(str, gobject.TYPE_PYOBJECT) |
177 | 821 | 896 | ||
178 | 822 | for t in choice_or_tree.get_choices(): | 897 | for t in choice_or_tree.get_choices(): |
181 | 823 | name = t.get_display_name() | 898 | liststore.append([str(t), t]) |
180 | 824 | liststore.append([name, t]) | ||
182 | 825 | 899 | ||
183 | 826 | return liststore | 900 | return liststore |
184 | 827 | 901 | ||
185 | @@ -851,9 +925,9 @@ | |||
186 | 851 | liststore = self.create_liststore(t) | 925 | liststore = self.create_liststore(t) |
187 | 852 | 926 | ||
188 | 853 | if replace: | 927 | if replace: |
190 | 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]) |
191 | 855 | else: | 929 | else: |
193 | 856 | child_iter = self.treestore.append(iter, [t.get_display_name(), liststore, t, t]) | 930 | child_iter = self.treestore.append(iter, [t, t, liststore]) |
194 | 857 | 931 | ||
195 | 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)) |
196 | 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)) |
197 | @@ -871,9 +945,9 @@ | |||
198 | 871 | continue | 945 | continue |
199 | 872 | 946 | ||
200 | 873 | if replace: | 947 | if replace: |
202 | 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]) |
203 | 875 | else: | 949 | else: |
205 | 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]) |
206 | 877 | 951 | ||
207 | 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)) |
208 | 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)) |
209 | @@ -916,7 +990,7 @@ | |||
210 | 916 | self.set_treestore(iter, []) | 990 | self.set_treestore(iter, []) |
211 | 917 | return | 991 | return |
212 | 918 | 992 | ||
214 | 919 | choice_or_tree, active_tree = self.treestore.get(iter, 2, 3) | 993 | choice_or_tree, active_tree = self.treestore.get(iter, 0, 1) |
215 | 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: |
216 | 921 | return | 995 | return |
217 | 922 | 996 | ||
218 | @@ -927,7 +1001,7 @@ | |||
219 | 927 | child_iter = self.treestore.iter_children(iter) | 1001 | child_iter = self.treestore.iter_children(iter) |
220 | 928 | while child_iter is not None: | 1002 | while child_iter is not None: |
221 | 929 | # fix for recursive schemata! | 1003 | # fix for recursive schemata! |
223 | 930 | child_active_tree = self.treestore.get_value(child_iter, 3) | 1004 | child_active_tree = self.treestore.get_value(child_iter, 1) |
224 | 931 | if child_active_tree.schemaname == active_tree.schemaname: | 1005 | if child_active_tree.schemaname == active_tree.schemaname: |
225 | 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) |
226 | 933 | child_iter = self.treestore.iter_next(child_iter) | 1007 | child_iter = self.treestore.iter_next(child_iter) |
227 | @@ -961,15 +1035,20 @@ | |||
228 | 961 | foreground colour. | 1035 | foreground colour. |
229 | 962 | """ | 1036 | """ |
230 | 963 | 1037 | ||
234 | 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) |
235 | 965 | 1039 | ||
236 | 966 | # set the model for the cellcombo, where it gets the possible choices for the name | 1040 | if self.groupmode and self.treestore.iter_parent(iter) is None: |
237 | 1041 | cellCombo.set_property("text", choice_or_tree.get_name_path()) | ||
238 | 1042 | else: | ||
239 | 1043 | cellCombo.set_property("text", str(choice_or_tree)) | ||
240 | 1044 | |||
241 | 1045 | |||
242 | 967 | cellCombo.set_property("model", liststore) | 1046 | cellCombo.set_property("model", liststore) |
243 | 968 | 1047 | ||
244 | 969 | # set the properties: colour, etc. | 1048 | # set the properties: colour, etc. |
246 | 970 | if choice_or_tree.__class__ is tree.Tree: | 1049 | if isinstance(choice_or_tree, tree.Tree): |
247 | 971 | cellCombo.set_property("editable", False) | 1050 | cellCombo.set_property("editable", False) |
249 | 972 | elif choice_or_tree.__class__ is choice.Choice: | 1051 | elif isinstance(choice_or_tree, choice.Choice): |
250 | 973 | cellCombo.set_property("editable", True) | 1052 | cellCombo.set_property("editable", True) |
251 | 974 | 1053 | ||
252 | 975 | if self.treestore_iter_is_active(iter): | 1054 | if self.treestore_iter_is_active(iter): |
253 | @@ -987,8 +1066,8 @@ | |||
254 | 987 | This hook function sets up the other gtk.CellRendererPixbuf, the one that gives | 1066 | This hook function sets up the other gtk.CellRendererPixbuf, the one that gives |
255 | 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. |
256 | 989 | """ | 1068 | """ |
259 | 990 | 1069 | ||
260 | 991 | choice_or_tree = self.treestore.get_value(iter, 2) | 1070 | choice_or_tree = self.treestore.get_value(iter, 0) |
261 | 992 | if isinstance(choice_or_tree, tree.Tree): | 1071 | if isinstance(choice_or_tree, tree.Tree): |
262 | 993 | cell.set_property("stock-id", None) | 1072 | cell.set_property("stock-id", None) |
263 | 994 | elif isinstance(choice_or_tree, choice.Choice): | 1073 | elif isinstance(choice_or_tree, choice.Choice): |
264 | @@ -1003,7 +1082,7 @@ | |||
265 | 1003 | something can be added or removed or has to be there. | 1082 | something can be added or removed or has to be there. |
266 | 1004 | """ | 1083 | """ |
267 | 1005 | 1084 | ||
269 | 1006 | choice_or_tree = self.treestore.get_value(iter, 2) | 1085 | choice_or_tree = self.treestore.get_value(iter, 0) |
270 | 1007 | if choice_or_tree.cardinality == "": | 1086 | if choice_or_tree.cardinality == "": |
271 | 1008 | cell.set_property("stock-id", None) | 1087 | cell.set_property("stock-id", None) |
272 | 1009 | elif choice_or_tree.cardinality == "?" or choice_or_tree.cardinality == "*": | 1088 | elif choice_or_tree.cardinality == "?" or choice_or_tree.cardinality == "*": |
273 | @@ -1029,7 +1108,7 @@ | |||
274 | 1029 | Toggles the state of part of the tree. | 1108 | Toggles the state of part of the tree. |
275 | 1030 | """ | 1109 | """ |
276 | 1031 | 1110 | ||
278 | 1032 | choice_or_tree = self.treestore.get_value(iter, 2) | 1111 | choice_or_tree = self.treestore.get_value(iter, 0) |
279 | 1033 | 1112 | ||
280 | 1034 | if choice_or_tree.active: | 1113 | if choice_or_tree.active: |
281 | 1035 | self.collapse_tree(iter) | 1114 | self.collapse_tree(iter) |
282 | @@ -1045,13 +1124,8 @@ | |||
283 | 1045 | Collapses part of the tree. | 1124 | Collapses part of the tree. |
284 | 1046 | """ | 1125 | """ |
285 | 1047 | 1126 | ||
293 | 1048 | choice_or_tree, = self.treestore.get(iter, 2) | 1127 | choice_or_tree, = self.treestore.get(iter, 0) |
294 | 1049 | parent_iter = self.treestore.iter_parent(iter) | 1128 | parent_tree = choice_or_tree.parent |
288 | 1050 | |||
289 | 1051 | if parent_iter == None: | ||
290 | 1052 | parent_tree = None | ||
291 | 1053 | else: | ||
292 | 1054 | parent_tree = self.treestore.get_value(parent_iter, 3) | ||
295 | 1055 | 1129 | ||
296 | 1056 | if not choice_or_tree.active: | 1130 | if not choice_or_tree.active: |
297 | 1057 | return | 1131 | return |
298 | @@ -1088,16 +1162,11 @@ | |||
299 | 1088 | return | 1162 | return |
300 | 1089 | 1163 | ||
301 | 1090 | def delete_tree(self, iter): | 1164 | def delete_tree(self, iter): |
304 | 1091 | choice_or_tree, = self.treestore.get(iter, 2) | 1165 | choice_or_tree, = self.treestore.get(iter, 0) |
305 | 1092 | parent_iter = self.treestore.iter_parent(iter) | 1166 | parent_tree = choice_or_tree.parent |
306 | 1093 | isSelected = self.treeview.get_selection().iter_is_selected(iter) | 1167 | isSelected = self.treeview.get_selection().iter_is_selected(iter) |
307 | 1094 | sibling = self.treestore.iter_next(iter) | 1168 | sibling = self.treestore.iter_next(iter) |
308 | 1095 | 1169 | ||
309 | 1096 | if parent_iter == None: | ||
310 | 1097 | parent_tree = None | ||
311 | 1098 | else: | ||
312 | 1099 | parent_tree = self.treestore.get_value(parent_iter, 3) | ||
313 | 1100 | |||
314 | 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?") |
315 | 1102 | if confirm == gtk.RESPONSE_YES: | 1171 | if confirm == gtk.RESPONSE_YES: |
316 | 1103 | parent_tree.delete_child_by_ref(choice_or_tree) | 1172 | parent_tree.delete_child_by_ref(choice_or_tree) |
317 | @@ -1114,13 +1183,8 @@ | |||
318 | 1114 | Expands part of the tree. | 1183 | Expands part of the tree. |
319 | 1115 | """ | 1184 | """ |
320 | 1116 | 1185 | ||
328 | 1117 | choice_or_tree, active_tree = self.treestore.get(iter, 2, 3) | 1186 | choice_or_tree, active_tree = self.treestore.get(iter, 0, 1) |
329 | 1118 | parent_iter = self.treestore.iter_parent(iter) | 1187 | parent_tree = choice_or_tree.parent |
323 | 1119 | |||
324 | 1120 | if parent_iter == None: | ||
325 | 1121 | parent_tree = None | ||
326 | 1122 | else: | ||
327 | 1123 | parent_tree = self.treestore.get_value(parent_iter, 3) | ||
330 | 1124 | 1188 | ||
331 | 1125 | if choice_or_tree.active: | 1189 | if choice_or_tree.active: |
332 | 1126 | return | 1190 | return |
333 | @@ -1140,8 +1204,7 @@ | |||
334 | 1140 | liststore = self.create_liststore(new_tree) | 1204 | liststore = self.create_liststore(new_tree) |
335 | 1141 | self.expand_treestore(iter) | 1205 | self.expand_treestore(iter) |
336 | 1142 | iter = self.treestore.insert_after( | 1206 | iter = self.treestore.insert_after( |
339 | 1143 | parent=parent_iter, sibling=iter, | 1207 | None, iter, [new_tree, new_tree.get_current_tree(), liststore]) |
338 | 1144 | row=[new_tree.get_display_name(), liststore, new_tree, new_tree.get_current_tree()]) | ||
340 | 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)) |
341 | 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)) |
342 | 1147 | self.signals[new_tree] = (attrid, dataid) | 1210 | self.signals[new_tree] = (attrid, dataid) |
343 | @@ -1243,7 +1306,7 @@ | |||
344 | 1243 | return | 1306 | return |
345 | 1244 | 1307 | ||
346 | 1245 | self.selected_iter = iter = self.treestore.get_iter(path) | 1308 | self.selected_iter = iter = self.treestore.get_iter(path) |
348 | 1246 | choice_or_tree, active_tree = self.treestore.get(iter, 2, 3) | 1309 | choice_or_tree, active_tree = self.treestore.get(iter, 0, 1) |
349 | 1247 | 1310 | ||
350 | 1248 | debug.dprint(active_tree) | 1311 | debug.dprint(active_tree) |
351 | 1249 | 1312 | ||
352 | @@ -1367,26 +1430,18 @@ | |||
353 | 1367 | 1430 | ||
354 | 1368 | return | 1431 | return |
355 | 1369 | 1432 | ||
357 | 1370 | def cellcombo_edited(self, cellrenderertext, path, new_text): | 1433 | def cellcombo_changed(self, combo, tree_path, combo_iter): |
358 | 1371 | """ | 1434 | """ |
359 | 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, |
360 | 1373 | i.e. the user chooses between more than one possible choice. | 1436 | i.e. the user chooses between more than one possible choice. |
361 | 1374 | """ | 1437 | """ |
362 | 1375 | 1438 | ||
366 | 1376 | iter = self.treestore.get_iter(path) | 1439 | tree_iter = self.treestore.get_iter(tree_path) |
367 | 1377 | self.treestore.set(iter, 0, new_text) | 1440 | choice = self.treestore.get_value(tree_iter, 0) |
365 | 1378 | choice = self.treestore.get_value(iter, 2) | ||
368 | 1379 | 1441 | ||
369 | 1380 | # get the ref to the new active choice | 1442 | # get the ref to the new active choice |
379 | 1381 | liststore = self.treestore.get_value(iter, 1) | 1443 | liststore = self.treestore.get_value(tree_iter, 2) |
380 | 1382 | list_iter = liststore.get_iter_first() | 1444 | ref = liststore.get_value(combo_iter, 1) |
372 | 1383 | ref = None | ||
373 | 1384 | while list_iter is not None: | ||
374 | 1385 | list_text = liststore.get_value(list_iter, 0) | ||
375 | 1386 | if list_text == new_text: | ||
376 | 1387 | ref = liststore.get_value(list_iter, 1) | ||
377 | 1388 | break | ||
378 | 1389 | list_iter = liststore.iter_next(list_iter) | ||
381 | 1390 | 1445 | ||
382 | 1391 | # record the choice in the datatree | 1446 | # record the choice in the datatree |
383 | 1392 | choice.set_active_choice_by_ref(ref) | 1447 | choice.set_active_choice_by_ref(ref) |
384 | @@ -1394,7 +1449,7 @@ | |||
385 | 1394 | 1449 | ||
386 | 1395 | name = self.get_spudpath(new_active_tree) | 1450 | name = self.get_spudpath(new_active_tree) |
387 | 1396 | self.statusbar.set_statusbar(name) | 1451 | self.statusbar.set_statusbar(name) |
389 | 1397 | self.treestore.set(iter, 3, new_active_tree) | 1452 | self.treestore.set(tree_iter, 1, new_active_tree) |
390 | 1398 | self.current_spudpath = name | 1453 | self.current_spudpath = name |
391 | 1399 | xpath = self.get_xpath(new_active_tree) | 1454 | xpath = self.get_xpath(new_active_tree) |
392 | 1400 | self.current_xpath = xpath | 1455 | self.current_xpath = xpath |
393 | @@ -1405,12 +1460,12 @@ | |||
394 | 1405 | if plugin.matches(xpath): | 1460 | if plugin.matches(xpath): |
395 | 1406 | self.add_plugin_button(plugin) | 1461 | self.add_plugin_button(plugin) |
396 | 1407 | 1462 | ||
400 | 1408 | self.remove_children(iter) | 1463 | self.remove_children(tree_iter) |
401 | 1409 | self.expand_treestore(iter) | 1464 | self.expand_treestore(tree_iter) |
402 | 1410 | self.treeview.expand_row(path, False) | 1465 | self.treeview.expand_row(tree_path, False) |
403 | 1411 | 1466 | ||
404 | 1412 | self.set_saved(False) | 1467 | self.set_saved(False) |
406 | 1413 | self.selected_node = self.get_painted_tree(iter) | 1468 | self.selected_node = self.get_painted_tree(tree_iter) |
407 | 1414 | self.update_options_frame() | 1469 | self.update_options_frame() |
408 | 1415 | 1470 | ||
409 | 1416 | return | 1471 | return |
410 | @@ -1435,20 +1490,7 @@ | |||
411 | 1435 | if attr != "name": | 1490 | if attr != "name": |
412 | 1436 | return | 1491 | return |
413 | 1437 | 1492 | ||
428 | 1438 | iter = self.treestore.get_iter(path) | 1493 | self.treeview.queue_draw() |
415 | 1439 | liststore = self.treestore.get_value(iter, 1) | ||
416 | 1440 | active_tree = self.treestore.get_value(iter, 3) | ||
417 | 1441 | new_name = active_tree.get_display_name() | ||
418 | 1442 | self.treestore.set_value(iter, 0, new_name) | ||
419 | 1443 | |||
420 | 1444 | # find the liststore iter corresponding to the painted choice | ||
421 | 1445 | list_iter = liststore.get_iter_first() | ||
422 | 1446 | while list_iter is not None: | ||
423 | 1447 | liststore_tree = liststore.get_value(list_iter, 1) | ||
424 | 1448 | if liststore_tree is active_tree: | ||
425 | 1449 | liststore.set_value(list_iter, 0, new_name) | ||
426 | 1450 | list_iter = liststore.iter_next(list_iter) | ||
427 | 1451 | |||
429 | 1452 | self.treeview.queue_resize() | 1494 | self.treeview.queue_resize() |
430 | 1453 | 1495 | ||
431 | 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): |
432 | @@ -1465,7 +1507,7 @@ | |||
433 | 1465 | if isinstance(iter_or_tree, tree.Tree): | 1507 | if isinstance(iter_or_tree, tree.Tree): |
434 | 1466 | active_tree = iter_or_tree | 1508 | active_tree = iter_or_tree |
435 | 1467 | else: | 1509 | else: |
437 | 1468 | active_tree = self.treestore.get_value(iter_or_tree, 3) | 1510 | active_tree = self.treestore.get_value(iter_or_tree, 1) |
438 | 1469 | 1511 | ||
439 | 1470 | painted_tree = active_tree.get_mixed_data() | 1512 | painted_tree = active_tree.get_mixed_data() |
440 | 1471 | 1513 | ||
441 | @@ -1505,7 +1547,26 @@ | |||
442 | 1505 | return None | 1547 | return None |
443 | 1506 | 1548 | ||
444 | 1507 | return iter | 1549 | return iter |
445 | 1550 | |||
446 | 1551 | def get_treestore_path_from_node(self, node): | ||
447 | 1552 | """ | ||
448 | 1553 | Look for the path for the given node. | ||
449 | 1554 | """ | ||
450 | 1508 | 1555 | ||
451 | 1556 | def search(iter, node, indent=""): | ||
452 | 1557 | while iter: | ||
453 | 1558 | if self.treestore.get_value(iter, 0) is node: | ||
454 | 1559 | return iter | ||
455 | 1560 | else: | ||
456 | 1561 | child = search(self.treestore.iter_children(iter), node, indent + " ") | ||
457 | 1562 | if child: return child | ||
458 | 1563 | |||
459 | 1564 | iter = self.treestore.iter_next(iter) | ||
460 | 1565 | return iter | ||
461 | 1566 | |||
462 | 1567 | iter = search(self.treestore.get_iter_first(), node) | ||
463 | 1568 | return self.treestore.get_path(iter) if iter else None | ||
464 | 1569 | |||
465 | 1509 | def set_geometry_dim_tree(self): | 1570 | def set_geometry_dim_tree(self): |
466 | 1510 | """ | 1571 | """ |
467 | 1511 | Find the iter into the treestore corresponding to the geometry dimension, and | 1572 | Find the iter into the treestore corresponding to the geometry dimension, and |
468 | @@ -1567,8 +1628,8 @@ | |||
469 | 1567 | """ | 1628 | """ |
470 | 1568 | 1629 | ||
471 | 1569 | while iter is not None: | 1630 | while iter is not None: |
474 | 1570 | choice_or_tree = self.treestore.get_value(iter, 2) | 1631 | choice_or_tree = self.treestore.get_value(iter, 0) |
475 | 1571 | active_tree = self.treestore.get_value(iter, 3) | 1632 | active_tree = self.treestore.get_value(iter, 1) |
476 | 1572 | if not choice_or_tree.active or not active_tree.active: | 1633 | if not choice_or_tree.active or not active_tree.active: |
477 | 1573 | return False | 1634 | return False |
478 | 1574 | iter = self.treestore.iter_parent(iter) | 1635 | iter = self.treestore.iter_parent(iter) |
479 | @@ -1629,7 +1690,7 @@ | |||
480 | 1629 | iter = self.treestore.get_iter_first() | 1690 | iter = self.treestore.get_iter_first() |
481 | 1630 | if iter is None: | 1691 | if iter is None: |
482 | 1631 | yield None | 1692 | yield None |
484 | 1632 | choice_or_tree = self.treestore.get_value(iter, 2) | 1693 | choice_or_tree = self.treestore.get_value(iter, 0) |
485 | 1633 | 1694 | ||
486 | 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)): |
487 | 1635 | yield iter | 1696 | yield iter |
488 | 1636 | 1697 | ||
489 | === modified file 'diamond/diamond/tree.py' | |||
490 | --- diamond/diamond/tree.py 2011-07-25 13:41:47 +0000 | |||
491 | +++ diamond/diamond/tree.py 2011-07-26 16:14:06 +0000 | |||
492 | @@ -301,7 +301,7 @@ | |||
493 | 301 | def unpickle(self, pick): | 301 | def unpickle(self, pick): |
494 | 302 | return pickle.loads(bz2.decompress(base64.b64decode(pick))) | 302 | return pickle.loads(bz2.decompress(base64.b64decode(pick))) |
495 | 303 | 303 | ||
497 | 304 | def __str__(self): | 304 | def print_str(self): |
498 | 305 | s = "name: %s at %s\n" % (self.name, hex(id(self))) | 305 | s = "name: %s at %s\n" % (self.name, hex(id(self))) |
499 | 306 | s = s + "schemaname: %s\n" % self.schemaname | 306 | s = s + "schemaname: %s\n" % self.schemaname |
500 | 307 | s = s + "attrs: %s\n" % self.attrs | 307 | s = s + "attrs: %s\n" % self.attrs |
501 | @@ -538,6 +538,9 @@ | |||
502 | 538 | return True | 538 | return True |
503 | 539 | 539 | ||
504 | 540 | return (self.datatype is not None and self.datatype != "fixed") or self.attrs | 540 | return (self.datatype is not None and self.datatype != "fixed") or self.attrs |
505 | 541 | |||
506 | 542 | def __str__(self): | ||
507 | 543 | return self.get_display_name() | ||
508 | 541 | 544 | ||
509 | 542 | gobject.type_register(Tree) | 545 | gobject.type_register(Tree) |
510 | 543 | 546 | ||
511 | 544 | 547 | ||
512 | === modified file 'diamond/gui/gui.glade' | |||
513 | --- diamond/gui/gui.glade 2011-07-22 15:46:25 +0000 | |||
514 | +++ diamond/gui/gui.glade 2011-07-26 16:14:06 +0000 | |||
515 | @@ -132,6 +132,20 @@ | |||
516 | 132 | <accelerator key="V" signal="activate" modifiers="GDK_CONTROL_MASK"/> | 132 | <accelerator key="V" signal="activate" modifiers="GDK_CONTROL_MASK"/> |
517 | 133 | </widget> | 133 | </widget> |
518 | 134 | </child> | 134 | </child> |
519 | 135 | <child> | ||
520 | 136 | <widget class="GtkMenuItem" id="menuitemGroup"> | ||
521 | 137 | <property name="visible">True</property> | ||
522 | 138 | <property name="label" translatable="yes">Group</property> | ||
523 | 139 | <signal name="activate" handler="on_group"/> | ||
524 | 140 | </widget> | ||
525 | 141 | </child> | ||
526 | 142 | <child> | ||
527 | 143 | <widget class="GtkMenuItem" id="menuitemUngroup"> | ||
528 | 144 | <property name="visible">False</property> | ||
529 | 145 | <property name="label" translatable="yes">Ungroup</property> | ||
530 | 146 | <signal name="activate" handler="on_ungroup"/> | ||
531 | 147 | </widget> | ||
532 | 148 | </child> | ||
533 | 135 | </widget> | 149 | </widget> |
534 | 136 | </child> | 150 | </child> |
535 | 137 | </widget> | 151 | </widget> |
536 | @@ -488,7 +502,7 @@ | |||
537 | 488 | <widget class="GtkMenu" id="popupmenu"> | 502 | <widget class="GtkMenu" id="popupmenu"> |
538 | 489 | <property name="visible">True</property> | 503 | <property name="visible">True</property> |
539 | 490 | <child> | 504 | <child> |
541 | 491 | <widget class="GtkMenuItem" id="menuitemCopy"> | 505 | <widget class="GtkMenuItem" id="popupmenuitemCopy"> |
542 | 492 | <property name="visible">True</property> | 506 | <property name="visible">True</property> |
543 | 493 | <property name="label" translatable="yes">Copy</property> | 507 | <property name="label" translatable="yes">Copy</property> |
544 | 494 | <property name="use_underline">True</property> | 508 | <property name="use_underline">True</property> |
545 | @@ -496,7 +510,7 @@ | |||
546 | 496 | </widget> | 510 | </widget> |
547 | 497 | </child> | 511 | </child> |
548 | 498 | <child> | 512 | <child> |
550 | 499 | <widget class="GtkMenuItem" id="menuitemPaste"> | 513 | <widget class="GtkMenuItem" id="popupmenuitemPaste"> |
551 | 500 | <property name="visible">True</property> | 514 | <property name="visible">True</property> |
552 | 501 | <property name="label" translatable="yes">Paste</property> | 515 | <property name="label" translatable="yes">Paste</property> |
553 | 502 | <property name="use_underline">True</property> | 516 | <property name="use_underline">True</property> |
554 | @@ -504,12 +518,26 @@ | |||
555 | 504 | </widget> | 518 | </widget> |
556 | 505 | </child> | 519 | </child> |
557 | 506 | <child> | 520 | <child> |
559 | 507 | <widget class="GtkMenuItem" id="menuitemSlice"> | 521 | <widget class="GtkMenuItem" id="popupmenuitemSlice"> |
560 | 508 | <property name="visible">True</property> | 522 | <property name="visible">True</property> |
561 | 509 | <property name="label" translatable="yes">Slice</property> | 523 | <property name="label" translatable="yes">Slice</property> |
562 | 510 | <property name="use_underline">True</property> | 524 | <property name="use_underline">True</property> |
563 | 511 | <signal name="activate" handler="on_slice"/> | 525 | <signal name="activate" handler="on_slice"/> |
564 | 512 | </widget> | 526 | </widget> |
565 | 513 | </child> | 527 | </child> |
566 | 528 | <child> | ||
567 | 529 | <widget class="GtkMenuItem" id="popupmenuitemGroup"> | ||
568 | 530 | <property name="visible">True</property> | ||
569 | 531 | <property name="label" translatable="yes">Group</property> | ||
570 | 532 | <signal name="activate" handler="on_group"/> | ||
571 | 533 | </widget> | ||
572 | 534 | </child> | ||
573 | 535 | <child> | ||
574 | 536 | <widget class="GtkMenuItem" id="popupmenuitemUngroup"> | ||
575 | 537 | <property name="visible">False</property> | ||
576 | 538 | <property name="label" translatable="yes">Ungroup</property> | ||
577 | 539 | <signal name="activate" handler="on_ungroup"/> | ||
578 | 540 | </widget> | ||
579 | 541 | </child> | ||
580 | 514 | </widget> | 542 | </widget> |
581 | 515 | </glade-interface> | 543 | </glade-interface> |