[GRASS-SVN] r41627 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 30 11:21:56 EDT 2010


Author: martinl
Date: 2010-03-30 11:21:56 -0400 (Tue, 30 Mar 2010)
New Revision: 41627

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: track changes in workspace
(merge r41625 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-03-30 15:13:37 UTC (rev 41626)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-03-30 15:21:56 UTC (rev 41627)
@@ -176,10 +176,6 @@
         
         self.AssignImageList(il)
         
-        # use when groups implemented
-        ## self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal)
-        ## self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded)
-        
         self.Bind(wx.EVT_TREE_ITEM_EXPANDING,   self.OnExpandNode)
         self.Bind(wx.EVT_TREE_ITEM_COLLAPSED,   self.OnCollapseNode)
         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED,   self.OnActivateLayer)
@@ -187,11 +183,8 @@
         self.Bind(CT.EVT_TREE_ITEM_CHECKED,     self.OnLayerChecked)
         self.Bind(wx.EVT_TREE_DELETE_ITEM,      self.OnDeleteLayer)
         self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnLayerContextMenu)
-        #self.Bind(wx.EVT_TREE_BEGIN_DRAG,       self.OnDrag)
         self.Bind(wx.EVT_TREE_END_DRAG,         self.OnEndDrag)
-        #self.Bind(wx.EVT_TREE_END_LABEL_EDIT,   self.OnChangeLayerName)
         self.Bind(wx.EVT_KEY_UP,                self.OnKeyUp)
-        # self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
         self.Bind(wx.EVT_IDLE,                  self.OnIdle)
         
     def GetMap(self):
@@ -916,24 +909,25 @@
         
     def OnActivateLayer(self, event):
         """!Double click on the layer item.
-        Launch property dialog, or expand/collapse group of items, etc."""
-        
+        Launch property dialog, or expand/collapse group of items, etc.
+        """
+        self.lmgr.WorkspaceChanged()
         layer = event.GetItem()
         self.layer_selected = layer
-
+        
         self.PropertiesDialog (layer)
-
+        
         if self.GetPyData(layer)[0]['type'] == 'group':
             if self.IsExpanded(layer):
                 self.Collapse(layer)
             else:
                 self.Expand(layer)
-
+        
     def OnDeleteLayer(self, event):
         """!Remove selected layer item from the layer tree"""
-
+        self.lmgr.WorkspaceChanged()
         item = event.GetItem()
-
+        
         try:
             item.properties.Close(True)
         except:
@@ -972,6 +966,8 @@
 
     def OnLayerChecked(self, event):
         """!Enable/disable data layer"""
+        self.lmgr.WorkspaceChanged()
+        
         item    = event.GetItem()
         checked = item.IsChecked()
 
@@ -1137,16 +1133,14 @@
                         self.mapdisplay.nvizToolWin.page['settings']['id'] = 1 
 
     def OnCollapseNode(self, event):
+        """!Collapse node
         """
-        Collapse node
-        """
         if self.GetPyData(self.layer_selected)[0]['type'] == 'group':
             self.SetItemImage(self.layer_selected, self.folder)
 
     def OnExpandNode(self, event):
+        """!Expand node
         """
-        Expand node
-        """
         self.layer_selected = event.GetItem()
         if self.GetPyData(self.layer_selected)[0]['type'] == 'group':
             self.SetItemImage(self.layer_selected, self.folder_open)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-30 15:13:37 UTC (rev 41626)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-30 15:21:56 UTC (rev 41627)
@@ -355,7 +355,11 @@
         """
         Set param value/values.
         """
-        param = self.get_param(aParam)
+        try:
+            param = self.get_param(aParam)
+        except ValueError:
+            return
+        
         param['value'] = aValue
             
     def get_flag(self, aFlag):
@@ -371,7 +375,11 @@
         """
         Enable / disable flag.
         """
-        param = self.get_flag(aFlag)
+        try:
+            param = self.get_flag(aFlag)
+        except ValueError:
+            return
+        
         param['value'] = aValue
                 
     def getCmd(self, ignoreErrors = False):

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-03-30 15:13:37 UTC (rev 41626)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-03-30 15:21:56 UTC (rev 41627)
@@ -22,7 +22,6 @@
 import sys
 import os
 import time
-import traceback
 import re
 import string
 import getopt
@@ -98,10 +97,9 @@
 UserSettings = preferences.globalSettings
 
 class GMFrame(wx.Frame):
-    """!
-    GIS Manager frame with notebook widget for controlling
-    GRASS GIS. Includes command console page for typing GRASS
-    (and other) commands, tree widget page for managing map layers.
+    """!Layer Manager frame with notebook widget for controlling GRASS
+    GIS. Includes command console page for typing GRASS (and other)
+    commands, tree widget page for managing map layers.
     """
     def __init__(self, parent, id=wx.ID_ANY, title=_("GRASS GIS Layer Manager"),
                  workspace=None):
@@ -124,6 +122,7 @@
         self.curr_page     = ''           # currently selected page for layer tree notebook
         self.curr_pagenum  = ''           # currently selected page number for layer tree notebook
         self.workspaceFile = workspace    # workspace file
+        self.workspaceChanged = False     # track changes in workspace
         self.georectifying = None         # reference to GCP class or None
         # list of open dialogs
         self.dialogs        = dict()
@@ -188,11 +187,13 @@
         self.goutput.Redirect()
         # fix goutput's pane size
         self.goutput.SetSashPosition(int(self.GetSize()[1] * .45))
+
+        self.workspaceChanged = False
         
         # start with layer manager on top
         self.curr_page.maptree.mapdisplay.Raise()
         self.Raise()
-            
+
     def __createNoteBook(self):
         """!Creates notebook widgets"""
 
@@ -244,6 +245,14 @@
 
         return self.toolbar
 
+    def WorkspaceChanged(self):
+        """!Update window title"""
+        if not self.workspaceChanged:
+            self.workspaceChanged = True
+        
+        if self.workspaceFile:
+            self.SetTitle(self.baseTitle + " - " +  os.path.basename(self.workspaceFile) + '*')
+        
     def OnGeorectify(self, event):
         """
         Launch georectifier module
@@ -674,7 +683,7 @@
         if maptree:
             # reverse list of map layers
             maptree.Map.ReverseListOfLayers()
-
+            
         for mdisp in mapdisplay:
             mdisp.MapWindow2D.UpdateMap()
 
@@ -748,7 +757,6 @@
 
     def OnWorkspaceSaveAs(self, event=None):
         """!Save workspace definition to selected file"""
-
         dlg = wx.FileDialog(parent=self, message=_("Choose file to save current workspace"),
                             defaultDir=os.getcwd(), wildcard=_("GRASS Workspace File (*.gxw)|*.gxw"), style=wx.FD_SAVE)
 
@@ -1502,7 +1510,8 @@
             return
         
         maptree = self.curr_page.maptree
-        if UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
+        if self.workspaceChanged and \
+                UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
             if self.workspaceFile:
                 message = _("Do you want to save changes in the workspace?")
             else:

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2010-03-30 15:13:37 UTC (rev 41626)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2010-03-30 15:21:56 UTC (rev 41627)
@@ -661,7 +661,7 @@
 	  <label>Exit GUI</label>
 	  <help>Quit wxGUI session</help>
 	  <handler>OnCloseWindow</handler>
-	  <shortcut>Ctrl+E</shortcut>
+	  <shortcut>Ctrl+W</shortcut>
 	</menuitem>
 	<menuitem>
 	  <label>Quit GRASS GIS</label>



More information about the grass-commit mailing list