Store zoom level in state

This commit is contained in:
René Stadler 2011-11-05 23:47:47 +01:00 committed by Stefan Sauer
parent 5b07a1fc39
commit d7c5942403
2 changed files with 16 additions and 0 deletions

View file

@ -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):

View file

@ -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"))