[GRASS-SVN] r57929 - in grass/trunk/gui/wxpython: core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 3 16:01:29 PDT 2013


Author: martinl
Date: 2013-10-03 16:01:29 -0700 (Thu, 03 Oct 2013)
New Revision: 57929

Modified:
   grass/trunk/gui/wxpython/core/workspace.py
   grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI: store current working directory (if set up) in the workspace file


Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py	2013-10-03 22:17:13 UTC (rev 57928)
+++ grass/trunk/gui/wxpython/core/workspace.py	2013-10-03 23:01:29 UTC (rev 57929)
@@ -36,9 +36,9 @@
         #
         # layer manager properties
         #
-        self.layerManager = {}
-        self.layerManager['pos']  = None # window position
-        self.layerManager['size'] = None # window size
+        self.layerManager = { 'pos' : None,  # window position
+                              'size' : None, # window size
+                              'cwd' : None } # current working directory
         
         #
         # list of mapdisplays
@@ -100,6 +100,10 @@
                     self.layerManager['size'] = (posVal[2], posVal[3])
                 except:
                     pass
+            # current working directory
+            cwdPath = self.__getNodeText(node_lm, 'cwd')
+            if cwdPath:
+               self.layerManager['cwd'] = cwdPath 
         
         #
         # displays
@@ -582,7 +586,11 @@
                                                               windowSize[0],
                                                               windowSize[1]
                                                               ))
-        
+        self.indent += 4
+        cwdPath = self.lmgr.GetCwdPath()
+        if cwdPath:
+            file.write('%s<cwd>%s</cwd>\n' % (' ' * self.indent, cwdPath))
+        self.indent -= 4
         file.write('%s</layer_manager>\n' % (' ' * self.indent))
         
         # list of displays

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2013-10-03 22:17:13 UTC (rev 57928)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2013-10-03 23:01:29 UTC (rev 57929)
@@ -94,6 +94,7 @@
         self.currentPageNum  = None       # currently selected page number for layer tree notebook
         self.workspaceFile = workspace    # workspace file
         self.workspaceChanged = False     # track changes in workspace
+        self.cwdPath = None               # current working directory
 
         wx.Frame.__init__(self, parent = parent, id = id, size = size,
                           style = style, **kwargs)
@@ -939,12 +940,13 @@
         dlg = wx.DirDialog(parent = self, message = _("Choose a working directory"),
                             defaultPath = os.getcwd(), style = wx.DD_CHANGE_DIR)
 
-        cwd_path = ''
         if dlg.ShowModal() == wx.ID_OK:
-            cwd_path = dlg.GetPath()
+            self.cwdPath = dlg.GetPath() # is saved in the workspace
 
-        # save path to somewhere ?
-
+    def GetCwdPath(self):
+        """!Get current working directory or None"""
+        return self.cwdPath
+    
     def OnNewVector(self, event):
         """!Create new vector map layer"""
         dlg = CreateNewVector(self, giface=self._giface,
@@ -1132,6 +1134,10 @@
                 self.SetPosition(gxwXml.layerManager['pos'])
             if gxwXml.layerManager['size']:
                 self.SetSize(gxwXml.layerManager['size'])
+            if gxwXml.layerManager['cwd']:
+                self.cwdPath = gxwXml.layerManager['cwd']
+                if os.path.isdir(self.cwdPath):
+                    os.chdir(self.cwdPath)
         
         #
         # start map displays first (list of layers can be empty)



More information about the grass-commit mailing list