[GRASS-SVN] r31041 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 19 13:02:47 EDT 2008
Author: martinl
Date: 2008-04-19 13:02:47 -0400 (Sat, 19 Apr 2008)
New Revision: 31041
Modified:
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI (preferences): remember the position of gui windows on save, trac #130
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-04-19 14:52:02 UTC (rev 31040)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-04-19 17:02:47 UTC (rev 31041)
@@ -54,8 +54,12 @@
# general
#
'general': {
- 'mapsetPath' : { 'selection' : 0 }, # current mapset search path
- 'changeOpacityLevel' : { 'enabled' : False }, # show opacity level widget
+ # current mapset search path
+ 'mapsetPath' : { 'selection' : 0 },
+ # show opacity level widget
+ 'changeOpacityLevel' : { 'enabled' : False },
+ # use default window layout (layer manager, displays, ...)
+ 'defWindowPos' : { 'enabled' : False, 'dim' : '' },
},
#
# display
@@ -441,12 +445,28 @@
name="GetSelection")
mapsetPath.SetSelection(self.settings.Get(group='general', key='mapsetPath', subkey='selection'))
self.winId['general:mapsetPath:selection'] = mapsetPath.GetId()
-
+
gridSizer.Add(item=mapsetPath,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
pos=(row, 1))
+
+ #
+ # default window layout
+ #
+ row += 1
+ defaultPos = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Save current window layout as default"),
+ name='IsChecked')
+ defaultPos.SetValue(self.settings.Get(group='general', key='defWindowPos', subkey='enabled'))
+ defaultPos.SetToolTip(wx.ToolTip (_("Save current position and size of Layer Manager window and opened "
+ "Map Display window(s) and use as default for next sessions.")))
+ self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
+
+ gridSizer.Add(item=defaultPos,
+ pos=(row, 0), span=(1, 2))
+
sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
@@ -972,6 +992,26 @@
value = win.GetValue()
self.settings.Set(group, key, subkey, value)
+ #
+ # update default window dimension
+ #
+ if self.settings.Get(group='general', key='defWindowPos', subkey='enabled') is True:
+ dim = ''
+ # layer manager
+ pos = self.parent.GetPosition()
+ size = self.parent.GetSize()
+ dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
+ # opened displays
+ for page in range(0, self.parent.gm_cb.GetPageCount()):
+ pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
+ size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
+
+ dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
+
+ self.settings.Set(group='general', key='defWindowPos', subkey='dim', value=dim)
+ else:
+ self.settings.Set(group='general', key='defWindowPos', subkey='dim', value='')
+
class SetDefaultFont(wx.Dialog):
"""
Opens a file selection dialog to select default font
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-04-19 14:52:02 UTC (rev 31040)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-04-19 17:02:47 UTC (rev 31041)
@@ -152,6 +152,17 @@
wx.CallAfter(self.notebook.SetSelection, 0)
+ # use default window layout ?
+ if UserSettings.Get(group='general', key='defWindowPos', subkey='enabled') is True:
+ dim = UserSettings.Get(group='general', key='defWindowPos', subkey='dim')
+ try:
+ x, y = map(int, dim.split(',')[0:2])
+ w, h = map(int, dim.split(',')[2:4])
+ self.SetPosition((x, y))
+ self.SetSize((w, h))
+ except:
+ pass
+
# load workspace file if requested
if (self.workspaceFile):
# load given workspace file
@@ -883,8 +894,6 @@
displayPos = mapTree.mapdisplay.GetPosition()
displaySize = mapTree.mapdisplay.GetSize()
-
-
file.write('%s<display render="%d" '
'mode="%d" showCompExtent="%d" '
'dim="%d,%d,%d,%d">\n' % (' ' * self.indent,
@@ -1182,8 +1191,6 @@
self.curr_page.Layout()
self.curr_page.maptree.Layout()
- self.disp_idx += 1
-
# self._auimgr.SetManagedWindow(self.curr_page.maptree.testframe)
#
# self._auimgr.AddPane(self.curr_page.maptree.testframe,
@@ -1194,6 +1201,20 @@
#
# self._auimgr.Update()
+ # use default window layout
+ if UserSettings.Get(group='general', key='defWindowPos', subkey='enabled') is True:
+ dim = UserSettings.Get(group='general', key='defWindowPos', subkey='dim')
+ idx = 4 + self.disp_idx * 4
+ try:
+ x, y = map(int, dim.split(',')[idx:idx + 2])
+ w, h = map(int, dim.split(',')[idx + 2:idx + 4])
+ self.curr_page.maptree.mapdisplay.SetPosition((x, y))
+ self.curr_page.maptree.mapdisplay.SetSize((w, h))
+ except:
+ pass
+
+ self.disp_idx += 1
+
return self.curr_page.maptree.mapdisplay
# toolBar button handlers
More information about the grass-commit
mailing list