[GRASS-SVN] r46771 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 23 18:25:18 EDT 2011


Author: martinl
Date: 2011-06-23 15:25:18 -0700 (Thu, 23 Jun 2011)
New Revision: 46771

Modified:
   grass/trunk/gui/wxpython/gui_modules/layertree.py
   grass/trunk/gui/wxpython/gui_modules/workspace.py
Log:
wxGUI: attemt to fix #1330


Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py	2011-06-23 20:16:52 UTC (rev 46770)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py	2011-06-23 22:25:18 UTC (rev 46771)
@@ -907,7 +907,7 @@
             elif ltype == 'command':
                 ctrl.SetValue(lname)
             else:
-                self.SetItemText(layer, self._getLayerName(layer))
+                self.SetItemText(layer, self._getLayerName(layer, lname))
         
         # updated progress bar range (mapwindow statusbar)
         if checked is True:
@@ -1373,21 +1373,27 @@
         
         return newItem
 
-    def _getLayerName(self, item):
-        """!Get layer name string"""
+    def _getLayerName(self, item, lname = ''):
+        """!Get layer name string
+
+        @param lname optional layer name
+        """
         mapLayer = self.GetPyData(item)[0]['maplayer']
-        mapname  = self.GetPyData(item)[0]['label']
+        if not lname:
+            lname  = self.GetPyData(item)[0]['label']
         opacity  = int(mapLayer.GetOpacity(float = True) * 100)
-        if not mapname:
+        if not lname:
             dcmd    = self.GetPyData(item)[0]['cmd']
-            mapname, found = utils.GetLayerNameFromCmd(dcmd, layerType = mapLayer.GetType(),
+            lname, found = utils.GetLayerNameFromCmd(dcmd, layerType = mapLayer.GetType(),
                                                        fullyQualified = True)
-        if not found:
-            return None
+            if not found:
+                return None
         
-        return mapname + ' (%s %d' % (_('opacity:'), opacity) + '%)'
+        if opacity < 100:
+            return lname + ' (%s %d' % (_('opacity:'), opacity) + '%)'
         
-        
+        return lname
+                
     def GetOptData(self, dcmd, layer, params, propwin):
         """!Process layer data (when changes in properties dialog are applied)
         """

Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py	2011-06-23 20:16:52 UTC (rev 46770)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py	2011-06-23 22:25:18 UTC (rev 46771)
@@ -771,7 +771,7 @@
             elif type == 'group':
                 name = mapTree.GetItemText(item)
                 self.file.write('%s<group name="%s" checked="%d">\n' % \
-                               (' ' * self.indent, name, checked));
+                               (' ' * self.indent, name.encode('utf8'), checked));
                 self.indent += 4
                 subItem = mapTree.GetFirstChild(item)[0]
                 self.__writeLayer(mapTree, subItem)
@@ -780,13 +780,13 @@
             else:
                 cmd = mapTree.GetPyData(item)[0]['maplayer'].GetCmd(string=False)
                 name = mapTree.GetItemText(item)
+                opacity = maplayer.GetOpacity(float = True)
                 # remove 'opacity' part
-                if '(opacity' in name:
+                if opacity < 1:
                     name = name.split('(', -1)[0].strip()
-                opacity = maplayer.GetOpacity(float=True)
                 self.file.write('%s<layer type="%s" name="%s" checked="%d" opacity="%f">\n' % \
-                               (' ' * self.indent, type, name, checked, opacity));
-
+                                    (' ' * self.indent, type, name.encode('utf8'), checked, opacity));
+                
                 self.indent += 4
                 # selected ?
                 if item in itemSelected:



More information about the grass-commit mailing list