[GRASS-SVN] r58642 - in grass/trunk/gui/wxpython: lmgr modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 8 09:23:47 PST 2014


Author: martinl
Date: 2014-01-08 09:23:47 -0800 (Wed, 08 Jan 2014)
New Revision: 58642

Modified:
   grass/trunk/gui/wxpython/lmgr/giface.py
   grass/trunk/gui/wxpython/modules/extensions.py
Log:
wxGUI/extension: show manual page (via contextual menu)


Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py	2014-01-08 17:16:33 UTC (rev 58641)
+++ grass/trunk/gui/wxpython/lmgr/giface.py	2014-01-08 17:23:47 UTC (rev 58642)
@@ -15,6 +15,8 @@
 @author Vaclav Petras <wenzeslaus gmail.com>
 """
 
+import os
+
 from grass.pydispatch.signal import Signal
 from core.giface import Notification
 
@@ -144,8 +146,10 @@
     def RunCmd(self, *args, **kwargs):
         self.lmgr._gconsole.RunCmd(*args, **kwargs)
 
-    def Help(self, entry):
+    def Help(self, entry, online=False):
         cmdlist = ['g.manual', 'entry=%s' % entry]
+        if online:
+            cmdlist.append('-o')
         self.RunCmd(cmdlist, compReg = False, notification=Notification.NO_NOTIFICATION)
 
     def WriteLog(self, text, wrap = None,

Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py	2014-01-08 17:16:33 UTC (rev 58641)
+++ grass/trunk/gui/wxpython/modules/extensions.py	2014-01-08 17:23:47 UTC (rev 58642)
@@ -9,7 +9,7 @@
  - extensions::UninstallExtensionWindow
  - extensions::CheckListExtension
 
-(C) 2008-2013 by the GRASS Development Team
+(C) 2008-2014 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -40,7 +40,7 @@
         self.parent = parent
         self._giface = giface
         self.options = dict() # list of options
-        
+
         wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
         
@@ -109,6 +109,7 @@
         self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
         self.tree.selectionChanged.connect(self.OnItemSelected)
         self.tree.itemActivated.connect(self.OnItemActivated)
+        self.tree.contextMenu.connect(self.OnContextMenu)
 
         wx.CallAfter(self._fetch)
         
@@ -197,6 +198,24 @@
         self.SetStatusText("", 0)
         wx.EndBusyCursor()
 
+    def OnContextMenu(self, node):
+        if not hasattr (self, "popupID"):
+            self.popupID = dict()
+            for key in ('install', 'help'):
+                self.popupID[key] = wx.NewId()
+        
+        data = node.data
+        if data and 'command' in data:
+            self.popupMenu = wx.Menu()
+            self.popupMenu.Append(self.popupID['install'], text = _("Install"))
+            self.Bind(wx.EVT_MENU, self.OnInstall, id = self.popupID['install'])
+            self.popupMenu.AppendSeparator()
+            self.popupMenu.Append(self.popupID['help'], text = _("Show manual page"))
+            self.Bind(wx.EVT_MENU, self.OnItemHelp, id = self.popupID['help'])
+            
+            self.PopupMenu(self.popupMenu)
+            self.popupMenu.Destroy()
+
     def OnItemActivated(self, node):
         data = node.data
         if data and 'command' in data:
@@ -217,6 +236,13 @@
             globalvar.UpdateGRASSAddOnCommands()
             toolboxesOutdated()
 
+    def OnItemHelp(self, event):
+        item = self.tree.GetSelected()
+        if not item or 'command' not in item[0].data:
+            return
+        
+        self._giface.Help(entry=item[0].data['command'], online=True)
+
     def OnHelp(self, event):
         self._giface.Help(entry='g.extension')
 
@@ -230,7 +256,6 @@
             self.SetStatusText(data.get('description', ''), 0)
             self.btnInstall.Enable(True)
 
-
 class ExtensionTreeModelBuilder:
     """!Tree model of available extensions."""
     def __init__(self):



More information about the grass-commit mailing list