From cc9d9e1162ff74f12db1b9f0243b2c38895f1cbd Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Sun, 2 Mar 2008 16:16:14 +0000 Subject: [PATCH] 2008-03-02 Gary Burton * src/plugins/RelCalc.py: Allow the tree view to be navigated via the keyboard. Bug #1777 svn: r10156 --- ChangeLog | 4 ++++ src/plugins/RelCalc.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 015dffb32..04bb263c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-03-02 Gary Burton + * src/plugins/RelCalc.py: Allow the tree view to be navigated via the + keyboard. Bug #1777 + 2008-03-02 Jerome Rapinat * src/plugins/AgeOnDate.py : minor change for better translations diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 76c47fbdc..034675036 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -106,6 +106,10 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow): self.model = PeopleModel(self.db,None) self.tree.set_model(self.model) + self.tree.connect('key-press-event', self._key_press) + self.selection = self.tree.get_selection() + self.selection.set_mode(gtk.SELECTION_SINGLE) + column = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(),text=0) column.set_resizable(True) column.set_min_width(225) @@ -223,6 +227,18 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow): textval += "%s %s\n" % (val[0], val[1]) self.textbuffer.set_text(textval) + def _key_press(self, obj, event): + if not event.state or event.state in (gtk.gdk.MOD2_MASK, ): + if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter): + store, paths = self.selection.get_selected_rows() + if paths and len(paths[0]) == 1 : + if self.tree.row_expanded(paths[0]): + self.tree.collapse_row(paths[0]) + else: + self.tree.expand_row(paths[0], 0) + return True + return False + #------------------------------------------------------------------------ # #