Browse Source

wxGUI/toolboxes: remove Toolboxes menu item when there are no custom toolboxes in toolboxes file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57000 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 years ago
parent
commit
9e256e7aab
1 changed files with 10 additions and 6 deletions
  1. 10 6
      gui/wxpython/core/toolboxes.py

+ 10 - 6
gui/wxpython/core/toolboxes.py

@@ -168,13 +168,17 @@ def toolboxes2menudata(userDefined=True):
     else:
         mainMenu = etree.parse(mainMenuFile)
     root = mainMenu.getroot()
-
+    
+    userHasToolboxes = False
     if userDefined and userToolboxesFile:
-        userToolboxes = etree.parse(userToolboxesFile)
-        _expandUserToolboxesItem(root, userToolboxes)
-        _expandToolboxes(root, userToolboxes)
-
-    if not userToolboxesFile:
+        userToolboxes = etree.parse(userToolboxesFile)        
+        # in case user has empty toolboxes file (to avoid genereation)
+        if userToolboxes.findall('.//toolbox'):
+            _expandUserToolboxesItem(root, userToolboxes)
+            _expandToolboxes(root, userToolboxes)
+            userHasToolboxes = True
+
+    if not userHasToolboxes:
         _removeUserToolboxesItem(root)
 
     toolboxes = etree.parse(toolboxesFile)