[GRASS-SVN] r53468 - in grass/branches/develbranch_6/gui/wxpython: core gui_core modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 18 08:41:03 PDT 2012


Author: martinl
Date: 2012-10-18 08:41:03 -0700 (Thu, 18 Oct 2012)
New Revision: 53468

Modified:
   grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
   grass/branches/develbranch_6/gui/wxpython/modules/extensions.py
Log:
wxGUI: update prompt when new addon is installed


Modified: grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/globalvar.py	2012-10-18 15:02:00 UTC (rev 53467)
+++ grass/branches/develbranch_6/gui/wxpython/core/globalvar.py	2012-10-18 15:41:03 UTC (rev 53468)
@@ -25,6 +25,8 @@
 ETCIMGDIR = os.path.join(ETCDIR, "gui", "images")
 ETCSYMBOLDIR = os.path.join(ETCDIR, "gui", "images", "symbols")
 
+from core.debug import Debug
+
 sys.path.append(os.path.join(ETCDIR, "python"))
 import grass.script as grass
 
@@ -145,24 +147,45 @@
             if script[-len(pattern):] != pattern: # ignore wrappers
                 cmd.append(script)
     
+    return set(cmd), scripts
+
+def UpdateGRASSAddOnCommands():
+    """!Update list of available GRASS AddOns commands to use when
+    parsing string from the command line
+    """
+    global grassCmd, grassScripts
+    
     # scan addons (path)
-    if os.getenv('GRASS_ADDON_PATH'):
-        for path in os.getenv('GRASS_ADDON_PATH').split(os.pathsep):
-            if not os.path.exists(path) or not os.path.isdir(path):
+    if not os.getenv('GRASS_ADDON_PATH'):
+        return
+    
+    nCmd = 0
+    for path in os.getenv('GRASS_ADDON_PATH').split(os.pathsep):
+        if not os.path.exists(path) or not os.path.isdir(path):
+            continue
+        for fname in os.listdir(path):
+            if fname in ['docs', 'modules.xml']:
                 continue
-            for fname in os.listdir(path):
-                if scripts: # win32
-                    name, ext = os.path.splitext(fname)
-                    cmd.append(name)
-                    if ext in scripts.keys():
-                        scripts[ext].append(name)
-                else:
-                    cmd.append(fname)
-    
-    return set(cmd), scripts
+            if grassScripts: # win32
+                name, ext = os.path.splitext(fname)
+                if name not in grassCmd:
+                    grassCmd.add(name)
+                    nCmd += 1
+                if ext in grassScripts.keys() and \
+                        name not in grassScripts[ext]:
+                    grassScripts[ext].append(name)
+                    nCmd += 1
+            else:
+                if fname not in grassCmd:
+                    grassCmd.add(fname)
+                    nCmd += 1
+                    
+    Debug.msg(1, "Number of new AddOn commands: %d", nCmd)
 
 """@brief Collected GRASS-relared binaries/scripts"""
 grassCmd, grassScripts = GetGRASSCommands()
+Debug.msg(1, "Number of GRASS commands: %d", len(grassCmd))
+UpdateGRASSAddOnCommands()
 
 """@Toolbar icon size"""
 toolbarSize = (24, 24)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py	2012-10-18 15:02:00 UTC (rev 53467)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py	2012-10-18 15:41:03 UTC (rev 53468)
@@ -985,7 +985,11 @@
     def ResetFocus(self):
         """!Reset focus"""
         self.cmdPrompt.SetFocus()
-        
+    
+    def GetPrompt(self):
+        """!Get prompt"""
+        return self.cmdPrompt
+
 class GMStdout:
     """!GMConsole standard output
 

Modified: grass/branches/develbranch_6/gui/wxpython/modules/extensions.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/modules/extensions.py	2012-10-18 15:02:00 UTC (rev 53467)
+++ grass/branches/develbranch_6/gui/wxpython/modules/extensions.py	2012-10-18 15:41:03 UTC (rev 53468)
@@ -220,15 +220,11 @@
         log.RunCmd(self._getCmd(), onDone = self.OnDone)
         
     def OnDone(self, cmd, returncode):
-        item = self.tree.GetSelected()
-        if not item or not item.IsOk() or \
-                returncode != 0 or \
-                not os.getenv('GRASS_ADDON_PATH'):
-            return
-        
-        name = self.tree.GetItemText(item)
-        globalvar.grassCmd.add(name)
-        
+        if returncode == 0:
+            globalvar.UpdateGRASSAddOnCommands()
+            log = self.parent.GetLogWindow()
+            log.GetPrompt().SetFilter(None)
+    
     def OnItemSelected(self, event):
         """!Item selected"""
         item = event.GetItem()



More information about the grass-commit mailing list