Merge lp:~fraser-waters08/spud/subtree-expand-collapse into lp:spud

Proposed by Fraser Waters
Status: Merged
Approved by: Patrick Farrell
Approved revision: 401
Merged at revision: 402
Proposed branch: lp:~fraser-waters08/spud/subtree-expand-collapse
Merge into: lp:spud
Diff against target: 32 lines (+15/-0)
1 file modified
diamond/diamond/interface.py (+15/-0)
To merge this branch: bzr merge lp:~fraser-waters08/spud/subtree-expand-collapse
Reviewer Review Type Date Requested Status
Patrick Farrell Pending
Review via email: mp+66795@code.launchpad.net

Description of the change

Pressing the left or right arrow keys while a row in the LHS treeview is selected and has focus will collapse or expand that subtree node.

To post a comment you must log in.
Revision history for this message
Patrick Farrell (pefarrell) wrote :

That works beautifully.

Expanding on the idea of the original bug report: maybe can you add more keyboard interaction
functionality? Use your common sense, but I am thinking it would be handy if

Enter -- activate inactive option / add a new instance of a zero-or-more/one-or-more
Delete -- deactivate active option / delete instance of ^^^^^^^^^^^^^^^^^^^^^^^^

Can you think of any more?

That being said, I'm very happy for this to be merged as-is; it fixes the existing bug report

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diamond/diamond/interface.py'
2--- diamond/diamond/interface.py 2011-07-04 09:57:05 +0000
3+++ diamond/diamond/interface.py 2011-07-04 14:02:31 +0000
4@@ -667,6 +667,7 @@
5
6 self.treeview = optionsTree = self.gui.get_widget("optionsTree")
7 self.treeview.connect("row-collapsed", self.on_treeview_row_collapsed)
8+ self.treeview.connect("key_press_event", self.on_treeview_key_press)
9 try: # allow for possibility of no tooltips (like elsewhere)
10 self.treeview.connect("query-tooltip", self.on_tooltip)
11 self.treeview.set_property("has-tooltip", False)
12@@ -1168,6 +1169,20 @@
13
14 return True
15
16+ def on_treeview_key_press(self, treeview, event):
17+ """
18+ Called when treeview intercepts a key press. Collapse and expand rows.
19+ """
20+
21+ if event.keyval == gtk.keysyms.Right:
22+ self.treeview.expand_row(self.get_selected_row(), open_all = False)
23+
24+ if event.keyval == gtk.keysyms.Left:
25+ self.treeview.collapse_row(self.get_selected_row())
26+
27+ return
28+
29+
30 def on_select_row(self, selection=None):
31 """
32 Called when a row is selected. Update the options frame.

Subscribers

People subscribed via source and target branches