Pārlūkot izejas kodu

bugfix https://trac.osgeo.org/grass/ticket/1769 + variables in CamelCase

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53530 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 gadi atpakaļ
vecāks
revīzija
4b0c7d9403
2 mainītis faili ar 32 papildinājumiem un 23 dzēšanām
  1. 2 2
      gui/wxpython/gui_core/forms.py
  2. 30 21
      gui/wxpython/gui_core/ghelp.py

+ 2 - 2
gui/wxpython/gui_core/forms.py

@@ -1626,8 +1626,8 @@ class CmdPanel(wx.Panel):
         else:
         else:
             self.goutput = None
             self.goutput = None
         
         
-        self.manualTab = HelpPanel(parent = self.notebook, grass_command = self.task.name)
-        if not self.manualTab.IsFile():
+        self.manualTab = HelpPanel(parent = self.notebook, command = self.task.name)
+        if not self.manualTab.GetFile():
             self.manualTab.Hide()
             self.manualTab.Hide()
         else:
         else:
             self.notebook.AddPage(page = self.manualTab, text = _("Manual"), name = 'manual')
             self.notebook.AddPage(page = self.manualTab, text = _("Manual"), name = 'manual')

+ 30 - 21
gui/wxpython/gui_core/ghelp.py

@@ -733,13 +733,13 @@ class HelpWindow(HtmlWindow):
     The SYNOPSIS section is skipped, since this Panel is supposed to
     The SYNOPSIS section is skipped, since this Panel is supposed to
     be integrated into the cmdPanel and options are obvious there.
     be integrated into the cmdPanel and options are obvious there.
     """
     """
-    def __init__(self, parent, grass_command, text, skip_description,
+    def __init__(self, parent, command, text, skipDescription,
                  **kwargs):
                  **kwargs):
-        """!If grass_command is given, the corresponding HTML help
+        """!If command is given, the corresponding HTML help
         file will be presented, with all links pointing to absolute
         file will be presented, with all links pointing to absolute
         paths of local files.
         paths of local files.
 
 
-        If 'skip_description' is True, the HTML corresponding to
+        If 'skipDescription' is True, the HTML corresponding to
         SYNOPSIS will be skipped, thus only presenting the help file
         SYNOPSIS will be skipped, thus only presenting the help file
         from the DESCRIPTION section onwards.
         from the DESCRIPTION section onwards.
 
 
@@ -750,25 +750,24 @@ class HelpWindow(HtmlWindow):
         wx.InitAllImageHandlers()
         wx.InitAllImageHandlers()
         HtmlWindow.__init__(self, parent = parent, **kwargs)
         HtmlWindow.__init__(self, parent = parent, **kwargs)
         
         
-        gisbase = os.getenv("GISBASE")
         self.loaded = False
         self.loaded = False
         self.history = list()
         self.history = list()
         self.historyIdx = 0
         self.historyIdx = 0
-        self.fspath = os.path.join(gisbase, "docs", "html")
+        self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html")
         
         
         self.SetStandardFonts (size = 10)
         self.SetStandardFonts (size = 10)
         self.SetBorders(10)
         self.SetBorders(10)
         
         
         if text is None:
         if text is None:
-            if skip_description:
-                url = os.path.join(self.fspath, grass_command + ".html")
+            if skipDescription:
+                url = os.path.join(self.fspath, command + ".html")
                 self.fillContentsFromFile(url,
                 self.fillContentsFromFile(url,
-                                          skip_description = skip_description)
+                                          skipDescription = skipDescription)
                 self.history.append(url)
                 self.history.append(url)
                 self.loaded = True
                 self.loaded = True
             else:
             else:
                 ### FIXME: calling LoadPage() is strangely time-consuming (only first call)
                 ### FIXME: calling LoadPage() is strangely time-consuming (only first call)
-                # self.LoadPage(self.fspath + grass_command + ".html")
+                # self.LoadPage(self.fspath + command + ".html")
                 self.loaded = False
                 self.loaded = False
         else:
         else:
             self.SetPage(text)
             self.SetPage(text)
@@ -784,7 +783,7 @@ class HelpWindow(HtmlWindow):
         
         
         super(HelpWindow, self).OnLinkClicked(linkinfo)
         super(HelpWindow, self).OnLinkClicked(linkinfo)
         
         
-    def fillContentsFromFile(self, htmlFile, skip_description = True):
+    def fillContentsFromFile(self, htmlFile, skipDescription = True):
         """!Load content from file"""
         """!Load content from file"""
         aLink = re.compile(r'(<a href="?)(.+\.html?["\s]*>)', re.IGNORECASE)
         aLink = re.compile(r'(<a href="?)(.+\.html?["\s]*>)', re.IGNORECASE)
         imgLink = re.compile(r'(<img src="?)(.+\.[png|gif])', re.IGNORECASE)
         imgLink = re.compile(r'(<img src="?)(.+\.[png|gif])', re.IGNORECASE)
@@ -797,7 +796,7 @@ class HelpWindow(HtmlWindow):
                 if not skip:
                 if not skip:
                     # do skip the options description if requested
                     # do skip the options description if requested
                     if "SYNOPSIS" in l:
                     if "SYNOPSIS" in l:
-                        skip = skip_description
+                        skip = skipDescription
                     else:
                     else:
                         # FIXME: find only first item
                         # FIXME: find only first item
                         findALink = aLink.search(l)
                         findALink = aLink.search(l)
@@ -817,13 +816,12 @@ class HelpWindow(HtmlWindow):
             self.loaded = False
             self.loaded = False
         
         
 class HelpPanel(wx.Panel):
 class HelpPanel(wx.Panel):
-    def __init__(self, parent, grass_command = "index", text = None,
-                 skip_description = False, **kwargs):
-        self.grass_command = grass_command
+    def __init__(self, parent, command = "index", text = None,
+                 skipDescription = False, **kwargs):
+        self.command = command
         wx.Panel.__init__(self, parent = parent, id = wx.ID_ANY)
         wx.Panel.__init__(self, parent = parent, id = wx.ID_ANY)
         
         
-        self.content = HelpWindow(self, grass_command, text,
-                                  skip_description)
+        self.content = HelpWindow(self, command, text, skipDescription)
         
         
         self.btnNext = wx.Button(parent = self, id = wx.ID_ANY,
         self.btnNext = wx.Button(parent = self, id = wx.ID_ANY,
                                  label = _("&Next"))
                                  label = _("&Next"))
@@ -859,14 +857,25 @@ class HelpPanel(wx.Panel):
     def LoadPage(self, path = None):
     def LoadPage(self, path = None):
         """!Load page"""
         """!Load page"""
         if not path:
         if not path:
-            path = os.path.join(self.content.fspath, self.grass_command + ".html")
+            path = self.GetFile()
         self.content.history.append(path)
         self.content.history.append(path)
         self.content.LoadPage(path)
         self.content.LoadPage(path)
         
         
-    def IsFile(self):
-        """!Check if file exists"""
-        return os.path.isfile(os.path.join(self.content.fspath, self.grass_command + ".html"))
-
+    def GetFile(self):
+        """!Get HTML file"""
+        fMan = os.path.join(self.content.fspath, self.command + ".html")
+        if os.path.isfile(fMan):
+            return fMan
+        
+        # check also addons
+        faMan = os.path.join(os.getenv('GRASS_ADDON_BASE'), "docs", "html",
+                             self.command + ".html")
+        if os.getenv('GRASS_ADDON_BASE') and \
+                os.path.isfile(faMan):
+            return faMan
+        
+        return None
+    
     def IsLoaded(self):
     def IsLoaded(self):
         return self.content.loaded
         return self.content.loaded