[GRASS-SVN] r30615 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Mar 18 08:13:36 EDT 2008
Author: martinl
Date: 2008-03-18 08:13:35 -0400 (Tue, 18 Mar 2008)
New Revision: 30615
Modified:
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: MapsetsAccess dialog improved (owner/group in the list)
TODO: get name of gid
FIXME: pwd not available on MS Windows
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-03-18 09:34:07 UTC (rev 30614)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-03-18 12:13:35 UTC (rev 30615)
@@ -22,10 +22,13 @@
import os
import sys
import copy
+import stat
+import pwd
import wx
import wx.lib.filebrowsebutton as filebrowse
import wx.lib.colourselect as csel
+import wx.lib.mixins.listctrl as listmix
from wx.lib.wordwrap import wordwrap
import gcmd
@@ -952,8 +955,9 @@
Controls setting options and displaying/hiding map overlay decorations
"""
def __init__(self, parent, id, title=_('Set/unset access to mapsets in current location'),
- pos=wx.DefaultPosition, size=(-1, -1),
+ pos=wx.DefaultPosition, size=(350, 400),
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
+
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
self.all_mapsets, self.accessible_mapsets = utils.ListOfMapsets()
@@ -968,9 +972,8 @@
sizer.Add(item=label, proportion=0,
flag=wx.ALL, border=5)
- self.mapsetlb = wx.CheckListBox(parent=self, id=wx.ID_ANY, pos=wx.DefaultPosition,
- size=(350,200), choices=self.all_mapsets)
- self.mapsetlb.Bind(wx.EVT_CHECKLISTBOX, self.OnCheckMapset)
+ self.mapsetlb = CheckListMapset(parent=self)
+ self.mapsetlb.LoadData(self.all_mapsets)
sizer.Add(item=self.mapsetlb, proportion=1,
flag=wx.ALL | wx.EXPAND, border=5)
@@ -978,10 +981,11 @@
# check all accessible mapsets
if globalSettings.Get(group='general', key='mapsetPath', subkey='selection') == 1:
for mset in self.all_mapsets:
- self.mapsetlb.Check(self.all_mapsets.index(mset), True)
+ self.mapsetlb.CheckItem(self.all_mapsets.index(mset), True)
else:
for mset in self.accessible_mapsets:
- self.mapsetlb.Check(self.all_mapsets.index(mset), True)
+ self.mapsetlb.CheckItem(self.all_mapsets.index(mset), True)
+ pass
# dialog buttons
line = wx.StaticLine(parent=self, id=wx.ID_ANY,
@@ -1006,14 +1010,8 @@
self.SetSizer(sizer)
sizer.Fit(self)
- self.SetMinSize(self.GetBestSize())
+ self.SetMinSize(size)
- def OnCheckMapset(self, event):
- """Mapset checked/unchecked"""
- mapset = self.mapsetlb.GetString(event.GetSelection())
- if mapset == 'PERMANENT' or mapset == self.curr_mapset:
- self.mapsetlb.Check(event.GetSelection(), True)
-
def GetMapsets(self):
"""Get list of checked mapsets"""
ms = []
@@ -1024,3 +1022,42 @@
i += 1
return ms
+
+class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
+ """List of mapset/owner/group"""
+ def __init__(self, parent, pos=wx.DefaultPosition,
+ log=None):
+ self.parent = parent
+
+ wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
+ style=wx.LC_REPORT)
+ listmix.CheckListCtrlMixin.__init__(self)
+ self.log = log
+
+ # setup mixins
+ listmix.ListCtrlAutoWidthMixin.__init__(self)
+
+ def LoadData(self, mapsets):
+ """Load data into list"""
+ self.InsertColumn(0, _('Mapset'))
+ self.InsertColumn(1, _('Owner'))
+ self.InsertColumn(2, _('Group'))
+ locationPath = os.path.join(grassenv.GetGRASSVariable('GISDBASE'),
+ grassenv.GetGRASSVariable('LOCATION_NAME'))
+ for mapset in mapsets:
+ index = self.InsertStringItem(sys.maxint, mapset)
+ mapsetPath = os.path.join(locationPath,
+ mapset)
+ stat_info = os.stat(mapsetPath)
+ # FIXME: pwd is only Unix-related
+ self.SetStringItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
+ self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid) # FIXME
+
+ self.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE)
+ self.SetColumnWidth(col=1, width=wx.LIST_AUTOSIZE)
+
+ def OnCheckItem(self, index, flag):
+ """Mapset checked/unchecked"""
+ mapset = self.parent.all_mapsets[index]
+ if mapset == 'PERMANENT' or mapset == self.parent.curr_mapset:
+ self.CheckItem(index, True)
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-03-18 09:34:07 UTC (rev 30614)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-03-18 12:13:35 UTC (rev 30615)
@@ -1233,7 +1233,7 @@
dlg = wx.MessageDialog (parent=self, message=message,
caption=_("Remove map layer"),
- style=wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
+ style=wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
dlg.Destroy()
More information about the grass-commit
mailing list