[GRASS-SVN] r49722 - in grass/branches/develbranch_6/gui: scripts
wxpython wxpython/lmgr wxpython/modules wxpython/xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 13 16:06:35 EST 2011
Author: martinl
Date: 2011-12-13 13:06:35 -0800 (Tue, 13 Dec 2011)
New Revision: 49722
Modified:
grass/branches/develbranch_6/gui/scripts/g.extension.py
grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
grass/branches/develbranch_6/gui/wxpython/modules/extensions.py
grass/branches/develbranch_6/gui/wxpython/wxpythonlib.dox
grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: new tool for uninstalling extensions
(merge r49721 from trunk)
Modified: grass/branches/develbranch_6/gui/scripts/g.extension.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.py 2011-12-13 20:59:35 UTC (rev 49721)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.py 2011-12-13 21:06:35 UTC (rev 49722)
@@ -753,7 +753,9 @@
return 0
elif flags['a']:
grass.message(_("List of installed extensions:"))
- print os.linesep.join(get_installed_extensions())
+ elist = get_installed_extensions()
+ if elist:
+ print os.linesep.join(elist)
return 0
else:
if not options['extension']:
Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py 2011-12-13 20:59:35 UTC (rev 49721)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py 2011-12-13 21:06:35 UTC (rev 49722)
@@ -59,7 +59,7 @@
from psmap.frame import PsMapFrame
from core.debug import Debug
from gui_core.ghelp import MenuTreeWindow, AboutWindow
-from modules.extensions import InstallExtensionWindow
+from modules.extensions import InstallExtensionWindow, UninstallExtensionWindow
from lmgr.toolbars import LMWorkspaceToolbar, LMDataToolbar, LMToolsToolbar
from lmgr.toolbars import LMMiscToolbar, LMVectorToolbar, LMNvizToolbar
from lmgr.pyshell import PyShellWindow
@@ -1122,6 +1122,12 @@
win.CentreOnScreen()
win.Show()
+ def OnUninstallExtension(self, event):
+ """!Uninstall extension"""
+ win = UninstallExtensionWindow(self, size = (650, 300))
+ win.CentreOnScreen()
+ win.Show()
+
def OnPreferences(self, event):
"""!General GUI preferences/settings
"""
Modified: grass/branches/develbranch_6/gui/wxpython/modules/extensions.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/modules/extensions.py 2011-12-13 20:59:35 UTC (rev 49721)
+++ grass/branches/develbranch_6/gui/wxpython/modules/extensions.py 2011-12-13 21:06:35 UTC (rev 49722)
@@ -6,6 +6,8 @@
Classes:
- extensions::InstallExtensionWindow
- extensions::ExtensionTree
+ - extensions::UninstallExtensionWindow
+ - extensions::CheckListExtension
(C) 2008-2011 by the GRASS Development Team
@@ -19,6 +21,7 @@
import sys
import wx
+import wx.lib.mixins.listctrl as listmix
try:
import wx.lib.agw.customtreectrl as CT
except ImportError:
@@ -65,7 +68,7 @@
task = gtask.parse_interface('g.extension.py')
- ignoreFlags = ['l', 'c', 'g', 'f', 'quiet', 'verbose']
+ ignoreFlags = ['l', 'c', 'g', 'a', 'f', 'quiet', 'verbose']
if sys.platform == 'win32':
ignoreFlags.append('d')
ignoreFlags.append('i')
@@ -372,3 +375,128 @@
def IsLoaded(self):
"""Check if items are loaded"""
return self._loaded
+
+class UninstallExtensionWindow(wx.Frame):
+ def __init__(self, parent, id = wx.ID_ANY,
+ title = _("Uninstall GRASS Addons extensions"), **kwargs):
+ self.parent = parent
+
+ 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))
+
+ self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
+
+ self.extBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+ label = " %s " % _("List of installed extensions"))
+
+ self.extList = CheckListExtension(parent = self.panel)
+
+ # buttons
+ self.btnUninstall = wx.Button(parent = self.panel, id = wx.ID_ANY,
+ label = _("&Uninstall"))
+ self.btnUninstall.SetToolTipString(_("Uninstall selected AddOns extensions"))
+ self.btnCmd = wx.Button(parent = self.panel, id = wx.ID_ANY,
+ label = _("Command dialog"))
+ self.btnCmd.SetToolTipString(_('Open %s dialog') % 'g.extension')
+ self.btnClose = wx.Button(parent = self.panel, id = wx.ID_CLOSE)
+
+ self.btnUninstall.Bind(wx.EVT_BUTTON, self.OnUninstall)
+ self.btnCmd.Bind(wx.EVT_BUTTON, self.OnCmdDialog)
+ self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
+
+ self._layout()
+
+ def _layout(self):
+ """!Do layout"""
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ extSizer = wx.StaticBoxSizer(self.extBox, wx.HORIZONTAL)
+ extSizer.Add(item = self.extList, proportion = 1,
+ flag = wx.ALL | wx.EXPAND, border = 1)
+
+ btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+ btnSizer.Add(item = self.btnCmd, proportion = 0,
+ flag = wx.RIGHT, border = 5)
+ btnSizer.AddSpacer(10)
+ btnSizer.Add(item = self.btnClose, proportion = 0,
+ flag = wx.RIGHT, border = 5)
+ btnSizer.Add(item = self.btnUninstall, proportion = 0)
+
+ sizer.Add(item = extSizer, proportion = 1,
+ flag = wx.ALL | wx.EXPAND, border = 3)
+ sizer.Add(item = btnSizer, proportion = 0,
+ flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+
+ self.panel.SetSizer(sizer)
+ sizer.Fit(self.panel)
+
+ self.Layout()
+
+ def OnCloseWindow(self, event):
+ """!Close window"""
+ self.Destroy()
+
+ def OnUninstall(self, event):
+ """!Uninstall selected extensions"""
+ log = self.parent.GetLogWindow()
+ eList = self.extList.GetExtensions()
+ if not eList:
+ GError(_("No extension selected for removal. "
+ "Operation canceled."),
+ parent = self)
+ return
+
+ for ext in eList:
+ files = RunCommand('g.extension.py', parent = self, read = True, quiet = True,
+ extension = ext, operation = 'remove').splitlines()
+ dlg = wx.MessageDialog(parent = self,
+ message = _("List of files to be removed:\n%(files)s\n\n"
+ "Do you want really to remove <%(ext)s> extension?") % \
+ { 'files' : os.linesep.join(files), 'ext' : ext },
+ caption = _("Remove extension"),
+ style = wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
+
+ if dlg.ShowModal() == wx.ID_YES:
+ RunCommand('g.extension.py', flags = 'f', parent = self, quiet = True,
+ extension = ext, operation = 'remove')
+
+ self.extList.LoadData()
+
+ def OnCmdDialog(self, event):
+ """!Shows command dialog"""
+ GUI(parent = self).ParseCommand(cmd = ['g.extension.py'])
+
+class CheckListExtension(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
+ """!List of mapset/owner/group"""
+ def __init__(self, parent):
+ self.parent = parent
+
+ wx.ListCtrl.__init__(self, parent, id = wx.ID_ANY,
+ style = wx.LC_REPORT)
+ listmix.CheckListCtrlMixin.__init__(self)
+
+ # setup mixins
+ listmix.ListCtrlAutoWidthMixin.__init__(self)
+
+ self.InsertColumn(0, _('Extension'))
+ self.LoadData()
+
+ def LoadData(self):
+ """!Load data into list"""
+ self.DeleteAllItems()
+ for ext in RunCommand('g.extension.py',
+ quiet = True, parent = self, read = True,
+ flags = 'a').splitlines():
+ self.InsertStringItem(sys.maxint, ext)
+
+ def GetExtensions(self):
+ """!Get extensions to be un-installed
+ """
+ extList = list()
+ for i in range(self.GetItemCount()):
+ if self.IsChecked(i):
+ name = self.GetItemText(i)
+ if name:
+ extList.append(name)
+
+ return extList
Modified: grass/branches/develbranch_6/gui/wxpython/wxpythonlib.dox
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxpythonlib.dox 2011-12-13 20:59:35 UTC (rev 49721)
+++ grass/branches/develbranch_6/gui/wxpython/wxpythonlib.dox 2011-12-13 21:06:35 UTC (rev 49722)
@@ -448,6 +448,8 @@
- modules::extensions
- extensions::InstallExtensionWindow
- extensions::ExtensionTree
+ - extensions::UninstallExtensionWindow
+ - extensions::CheckListExtension
- modules::histogram
- histogram::BufferedWindow
- histogram::HistogramFrame
Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml 2011-12-13 20:59:35 UTC (rev 49721)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml 2011-12-13 21:06:35 UTC (rev 49722)
@@ -856,11 +856,18 @@
<separator />
<menuitem>
<label>Install extension from add-ons</label>
- <help>Install new extension from GRASS AddOns SVN repository.</help>
+ <help>Installs new extension from GRASS AddOns SVN repository.</help>
<keywords>general,extensions</keywords>
<handler>OnInstallExtension</handler>
<command>g.extension</command>
</menuitem>
+ <menuitem>
+ <label>Remove extension</label>
+ <help>Removes installed GRASS AddOns extension.</help>
+ <keywords>general,installation,extensions</keywords>
+ <handler>OnUninstallExtension</handler>
+ <command>g.extension</command>
+ </menuitem>
<separator />
<menuitem>
<label>Preferences</label>
More information about the grass-commit
mailing list