From f73a6db0eedfeef79297261adb90689b48e574fe Mon Sep 17 00:00:00 2001 From: einarr Date: Mon, 26 Feb 2007 23:00:25 +0000 Subject: [PATCH] Added ctrl+arrows to navigate between plots. --- fluents/fluents.py | 17 +++++++++++++++++ fluents/plots.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/fluents/fluents.py b/fluents/fluents.py index ddc2637..5a3827f 100644 --- a/fluents/fluents.py +++ b/fluents/fluents.py @@ -189,6 +189,11 @@ class FluentApp: 'on_report_bug1_activate' : (self.on_help_report_bug), 'on_small_view1_activate' : (self.on_multiple_view), 'on_large_view1_activate' : (self.on_single_view), + + 'on_left1_activate' : (self.on_left), + 'on_right1_activate' : (self.on_right), + 'on_up1_activate' : (self.on_up), + 'on_down1_activate' : (self.on_down), } self.widget_tree.signal_autoconnect(signals) @@ -341,6 +346,18 @@ class FluentApp: def on_view_changed(self, widget, vf): self._update_toolbar(vf.get_view()) + def on_left(self, item): + self.main_view.move_focus_left() + + def on_right(self, item): + self.main_view.move_focus_right() + + def on_up(self, item): + self.main_view.move_focus_up() + + def on_down(self, item): + self.main_view.move_focus_down() + gobject.signal_new('table-size-set', TableSizeSelection, gobject.SIGNAL_RUN_LAST, diff --git a/fluents/plots.py b/fluents/plots.py index 27088c8..722d7f2 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -351,6 +351,37 @@ class MainView (gtk.Notebook): else: self._views[x, y].set_view(None) + def get_active_view_index(self): + current = self.get_active_small_view() + for i in range(self._views.xsize): + for j in range(self._views.ysize): + if self._views[i, j] == current: + return (i, j) + return None + + def set_active_view_by_index(self, x, y): + self._views[x, y].focus() + + def move_focus_left(self): + x, y = self.get_active_view_index() + if x > 0: + self.set_active_view_by_index(x-1, y) + + def move_focus_right(self): + x, y = self.get_active_view_index() + if x < self._views.xsize-1: + self.set_active_view_by_index(x+1, y) + + def move_focus_up(self): + x, y = self.get_active_view_index() + if y > 0: + self.set_active_view_by_index(x, y-1) + + def move_focus_down(self): + x, y = self.get_active_view_index() + if y < self._views.ysize-1: + self.set_active_view_by_index(x, y+1) + def _on_view_focus_changed(self, widget, vf, focused): if focused: self.emit('view-changed', vf)