From a43b9f27f517219301433e4d36e5034810110b4d Mon Sep 17 00:00:00 2001 From: René Stadler Date: Sat, 5 Nov 2011 23:47:47 +0100 Subject: Store zoom level in state --- GstDebugViewer/GUI/app.py | 2 ++ GstDebugViewer/GUI/window.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'GstDebugViewer') diff --git a/GstDebugViewer/GUI/app.py b/GstDebugViewer/GUI/app.py index de17305..da51149 100644 --- a/GstDebugViewer/GUI/app.py +++ b/GstDebugViewer/GUI/app.py @@ -38,6 +38,8 @@ class AppStateSection (Common.GUI.StateSection): column_order = Common.GUI.StateItemList ("column-order", ViewColumnManager) columns_visible = Common.GUI.StateItemList ("columns-visible", ViewColumnManager) + zoom_level = Common.GUI.StateInt ("zoom-level") + class AppState (Common.GUI.State): def __init__ (self, *a, **kw): diff --git a/GstDebugViewer/GUI/window.py b/GstDebugViewer/GUI/window.py index 832526e..6372492 100644 --- a/GstDebugViewer/GUI/window.py +++ b/GstDebugViewer/GUI/window.py @@ -290,6 +290,10 @@ class Window (object): def attach (self): self.zoom_level = 0 + zoom_percent = self.app.state_section.zoom_level + if zoom_percent: + self.restore_zoom (float (zoom_percent) / 100.) + self.window_state.attach (window = self.gtk_window, state = self.app.state_section) @@ -593,6 +597,14 @@ class Window (object): self.update_zoom_level (-self.zoom_level) + def restore_zoom (self, scale): + + from math import log + + self.zoom_level = int (round (log (scale) / log (ZOOM_FACTOR))) + + self.column_manager.set_zoom (scale) + def update_zoom_level (self, delta_step): if not delta_step: @@ -603,6 +615,8 @@ class Window (object): self.column_manager.set_zoom (scale) + self.app.state_section.zoom_level = int (round (scale * 100.)) + def add_model_filter (self, filter): self.progress_dialog = ProgressDialog (self, _("Filtering")) -- cgit v1.2.3