[GRASS-SVN] r46773 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

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


Author: martinl
Date: 2011-06-23 15:30:34 -0700 (Thu, 23 Jun 2011)
New Revision: 46773

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py
Log:
wxGUI: attemt to fix #1330
       (merge r46771 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py	2011-06-23 22:27:37 UTC (rev 46772)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/layertree.py	2011-06-23 22:30:34 UTC (rev 46773)
@@ -869,7 +869,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:
@@ -1336,21 +1336,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 propertiesdialog are applied)"""
         # set layer text to map name

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py	2011-06-23 22:27:37 UTC (rev 46772)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/workspace.py	2011-06-23 22:30:34 UTC (rev 46773)
@@ -764,7 +764,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)
@@ -773,13 +773,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