preferences.py 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583
  1. """!
  2. @package gui_core.preferences
  3. @brief User preferences dialog
  4. Sets default display font, etc. If you want to add some value to
  5. settings you have to add default value to defaultSettings and set
  6. constraints in internalSettings in Settings class. Everything can be
  7. used in PreferencesDialog.
  8. Classes:
  9. - preferences::PreferencesBaseDialog
  10. - preferences::PreferencesDialog
  11. - preferences::DefaultFontDialog
  12. - preferences::MapsetAccess
  13. - preferences::CheckListMapset
  14. (C) 2007-2011 by the GRASS Development Team
  15. This program is free software under the GNU General Public License
  16. (>=v2). Read the file COPYING that comes with GRASS for details.
  17. @author Michael Barton (Arizona State University)
  18. @author Martin Landa <landa.martin gmail.com>
  19. @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
  20. @author Luca Delucchi <lucadeluge gmail.com> (language choice)
  21. """
  22. import os
  23. import sys
  24. import copy
  25. import locale
  26. try:
  27. import pwd
  28. havePwd = True
  29. except ImportError:
  30. havePwd = False
  31. import wx
  32. import wx.lib.colourselect as csel
  33. import wx.lib.mixins.listctrl as listmix
  34. from wx.lib.newevent import NewEvent
  35. from grass.script import core as grass
  36. from core import globalvar
  37. from core.gcmd import RunCommand
  38. from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
  39. from core.settings import UserSettings
  40. wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
  41. class PreferencesBaseDialog(wx.Dialog):
  42. """!Base preferences dialog"""
  43. def __init__(self, parent, settings, title = _("User settings"),
  44. size = (500, 375),
  45. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
  46. self.parent = parent # ModelerFrame
  47. self.title = title
  48. self.size = size
  49. self.settings = settings
  50. wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
  51. style = style)
  52. # notebook
  53. self.notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
  54. # dict for window ids
  55. self.winId = {}
  56. # create notebook pages
  57. # buttons
  58. self.btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
  59. self.btnSave = wx.Button(self, wx.ID_SAVE)
  60. self.btnApply = wx.Button(self, wx.ID_APPLY)
  61. self.btnCancel = wx.Button(self, wx.ID_CANCEL)
  62. self.btnSave.SetDefault()
  63. # bindigs
  64. self.btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
  65. self.btnDefault.SetToolTipString(_("Revert settings to default and apply changes"))
  66. self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
  67. self.btnApply.SetToolTipString(_("Apply changes for the current session"))
  68. self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
  69. self.btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
  70. self.btnSave.SetDefault()
  71. self.btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
  72. self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
  73. self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
  74. self._layout()
  75. def _layout(self):
  76. """!Layout window"""
  77. # sizers
  78. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  79. btnSizer.Add(item = self.btnDefault, proportion = 1,
  80. flag = wx.ALL, border = 5)
  81. btnStdSizer = wx.StdDialogButtonSizer()
  82. btnStdSizer.AddButton(self.btnCancel)
  83. btnStdSizer.AddButton(self.btnSave)
  84. btnStdSizer.AddButton(self.btnApply)
  85. btnStdSizer.Realize()
  86. mainSizer = wx.BoxSizer(wx.VERTICAL)
  87. mainSizer.Add(item = self.notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
  88. mainSizer.Add(item = btnSizer, proportion = 0,
  89. flag = wx.EXPAND, border = 0)
  90. mainSizer.Add(item = btnStdSizer, proportion = 0,
  91. flag = wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border = 5)
  92. self.SetSizer(mainSizer)
  93. mainSizer.Fit(self)
  94. def OnDefault(self, event):
  95. """!Button 'Set to default' pressed"""
  96. self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
  97. # update widgets
  98. for gks in self.winId.keys():
  99. try:
  100. group, key, subkey = gks.split(':')
  101. value = self.settings.Get(group, key, subkey)
  102. except ValueError:
  103. group, key, subkey, subkey1 = gks.split(':')
  104. value = self.settings.Get(group, key, [subkey, subkey1])
  105. win = self.FindWindowById(self.winId[gks])
  106. if win.GetName() in ('GetValue', 'IsChecked'):
  107. value = win.SetValue(value)
  108. elif win.GetName() == 'GetSelection':
  109. value = win.SetSelection(value)
  110. elif win.GetName() == 'GetStringSelection':
  111. value = win.SetStringSelection(value)
  112. else:
  113. value = win.SetValue(value)
  114. def OnApply(self, event):
  115. """!Button 'Apply' pressed
  116. Posts event EVT_SETTINGS_CHANGED.
  117. """
  118. if self._updateSettings():
  119. self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
  120. event = wxSettingsChanged()
  121. wx.PostEvent(self, event)
  122. self.Close()
  123. def OnCloseWindow(self, event):
  124. self.Hide()
  125. def OnCancel(self, event):
  126. """!Button 'Cancel' pressed"""
  127. self.Close()
  128. def OnSave(self, event):
  129. """!Button 'Save' pressed
  130. Posts event EVT_SETTINGS_CHANGED.
  131. """
  132. if self._updateSettings():
  133. self.settings.SaveToFile()
  134. self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
  135. lang = UserSettings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
  136. if lang:
  137. RunCommand('g.gisenv', set = 'LANG=%s' % lang)
  138. event = wxSettingsChanged()
  139. wx.PostEvent(self, event)
  140. self.Close()
  141. def _updateSettings(self):
  142. """!Update user settings"""
  143. for item in self.winId.keys():
  144. try:
  145. group, key, subkey = item.split(':')
  146. subkey1 = None
  147. except ValueError:
  148. group, key, subkey, subkey1 = item.split(':')
  149. id = self.winId[item]
  150. win = self.FindWindowById(id)
  151. if win.GetName() == 'GetValue':
  152. value = win.GetValue()
  153. elif win.GetName() == 'GetSelection':
  154. value = win.GetSelection()
  155. elif win.GetName() == 'IsChecked':
  156. value = win.IsChecked()
  157. elif win.GetName() == 'GetStringSelection':
  158. value = win.GetStringSelection()
  159. elif win.GetName() == 'GetColour':
  160. value = tuple(win.GetValue())
  161. else:
  162. value = win.GetValue()
  163. if key == 'keycolumn' and value == '':
  164. wx.MessageBox(parent = self,
  165. message = _("Key column cannot be empty string."),
  166. caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
  167. win.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
  168. return False
  169. if subkey1:
  170. self.settings.Set(group, value, key, [subkey, subkey1])
  171. else:
  172. self.settings.Set(group, value, key, subkey)
  173. if self.parent.GetName() == 'Modeler':
  174. return True
  175. #
  176. # update default window dimension
  177. #
  178. if self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled') is True:
  179. dim = ''
  180. # layer manager
  181. pos = self.parent.GetPosition()
  182. size = self.parent.GetSize()
  183. dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
  184. # opened displays
  185. for page in range(0, self.parent.gm_cb.GetPageCount()):
  186. pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
  187. size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
  188. dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
  189. self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
  190. else:
  191. self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
  192. return True
  193. class PreferencesDialog(PreferencesBaseDialog):
  194. """!User preferences dialog"""
  195. def __init__(self, parent, title = _("GUI Settings"),
  196. settings = UserSettings):
  197. PreferencesBaseDialog.__init__(self, parent = parent, title = title,
  198. settings = settings)
  199. # create notebook pages
  200. self._createGeneralPage(self.notebook)
  201. self._createAppearancePage(self.notebook)
  202. self._createDisplayPage(self.notebook)
  203. self._createCmdPage(self.notebook)
  204. self._createAttributeManagerPage(self.notebook)
  205. self._createProjectionPage(self.notebook)
  206. self.SetMinSize(self.GetBestSize())
  207. self.SetSize(self.size)
  208. def _createGeneralPage(self, notebook):
  209. """!Create notebook page for general settings"""
  210. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  211. notebook.AddPage(page = panel, text = _("General"))
  212. border = wx.BoxSizer(wx.VERTICAL)
  213. #
  214. # Layer Manager settings
  215. #
  216. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Layer Manager settings"))
  217. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  218. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  219. gridSizer.AddGrowableCol(0)
  220. #
  221. # ask when removing map layer from layer tree
  222. #
  223. row = 0
  224. askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  225. label = _("Ask when removing map layer from layer tree"),
  226. name = 'IsChecked')
  227. askOnRemoveLayer.SetValue(self.settings.Get(group = 'manager', key = 'askOnRemoveLayer', subkey = 'enabled'))
  228. self.winId['manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
  229. gridSizer.Add(item = askOnRemoveLayer,
  230. pos = (row, 0), span = (1, 2))
  231. row += 1
  232. askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  233. label = _("Ask when quiting wxGUI or closing display"),
  234. name = 'IsChecked')
  235. askOnQuit.SetValue(self.settings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'))
  236. self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
  237. gridSizer.Add(item = askOnQuit,
  238. pos = (row, 0), span = (1, 2))
  239. row += 1
  240. hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  241. label = _("Hide '%s' tab (requires GUI restart)") % _("Search module"),
  242. name = 'IsChecked')
  243. hideSearch.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'))
  244. self.winId['manager:hideTabs:search'] = hideSearch.GetId()
  245. gridSizer.Add(item = hideSearch,
  246. pos = (row, 0), span = (1, 2))
  247. row += 1
  248. hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  249. label = _("Hide '%s' tab (requires GUI restart)") % _("Python shell"),
  250. name = 'IsChecked')
  251. hidePyShell.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'))
  252. self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
  253. gridSizer.Add(item = hidePyShell,
  254. pos = (row, 0), span = (1, 2))
  255. #
  256. # Selected text is copied to clipboard
  257. #
  258. row += 1
  259. copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  260. label = _("Automatically copy selected text to clipboard (in Command console)"),
  261. name = 'IsChecked')
  262. copySelectedTextToClipboard.SetValue(self.settings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled'))
  263. self.winId['manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
  264. gridSizer.Add(item = copySelectedTextToClipboard,
  265. pos = (row, 0), span = (1, 2))
  266. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  267. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  268. #
  269. # workspace
  270. #
  271. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Workspace settings"))
  272. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  273. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  274. gridSizer.AddGrowableCol(0)
  275. row = 0
  276. posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  277. label = _("Suppress positioning Map Display Window(s)"),
  278. name = 'IsChecked')
  279. posDisplay.SetValue(self.settings.Get(group = 'general', key = 'workspace',
  280. subkey = ['posDisplay', 'enabled']))
  281. self.winId['general:workspace:posDisplay:enabled'] = posDisplay.GetId()
  282. gridSizer.Add(item = posDisplay,
  283. pos = (row, 0), span = (1, 2))
  284. row += 1
  285. posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  286. label = _("Suppress positioning Layer Manager window"),
  287. name = 'IsChecked')
  288. posManager.SetValue(self.settings.Get(group = 'general', key = 'workspace',
  289. subkey = ['posManager', 'enabled']))
  290. self.winId['general:workspace:posManager:enabled'] = posManager.GetId()
  291. gridSizer.Add(item = posManager,
  292. pos = (row, 0), span = (1, 2))
  293. row += 1
  294. defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  295. label = _("Save current window layout as default"),
  296. name = 'IsChecked')
  297. defaultPos.SetValue(self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'))
  298. defaultPos.SetToolTip(wx.ToolTip (_("Save current position and size of Layer Manager window and opened "
  299. "Map Display window(s) and use as default for next sessions.")))
  300. self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
  301. gridSizer.Add(item = defaultPos,
  302. pos = (row, 0), span = (1, 2))
  303. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  304. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  305. panel.SetSizer(border)
  306. return panel
  307. panel.SetSizer(border)
  308. return panel
  309. def _createAppearancePage(self, notebook):
  310. """!Create notebook page for display settings"""
  311. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  312. notebook.AddPage(page = panel, text = _("Appearance"))
  313. border = wx.BoxSizer(wx.VERTICAL)
  314. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  315. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  316. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  317. gridSizer.AddGrowableCol(0)
  318. #
  319. # font settings
  320. #
  321. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  322. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  323. row = 0
  324. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  325. label = _("Font for command output:")),
  326. flag = wx.ALIGN_LEFT |
  327. wx.ALIGN_CENTER_VERTICAL,
  328. pos = (row, 0))
  329. outfontButton = wx.Button(parent = panel, id = wx.ID_ANY,
  330. label = _("Set font"), size = (100, -1))
  331. gridSizer.Add(item = outfontButton,
  332. flag = wx.ALIGN_RIGHT |
  333. wx.ALIGN_CENTER_VERTICAL,
  334. pos = (row, 1))
  335. #
  336. # languages
  337. #
  338. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Language settings"))
  339. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  340. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  341. gridSizer.AddGrowableCol(0)
  342. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  343. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  344. row = 0
  345. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  346. label = _("Choose language (requires to save and GRASS restart):")),
  347. flag = wx.ALIGN_LEFT |
  348. wx.ALIGN_CENTER_VERTICAL,
  349. pos = (row, 0))
  350. locales = self.settings.Get(group = 'language', key = 'locale',
  351. subkey = 'choices', internal = True)
  352. loc = self.settings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
  353. elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  354. choices = locales, name = "GetStringSelection")
  355. if loc in locales:
  356. elementList.SetStringSelection(loc)
  357. self.winId['language:locale:lc_all'] = elementList.GetId()
  358. gridSizer.Add(item = elementList,
  359. flag = wx.ALIGN_RIGHT |
  360. wx.ALIGN_CENTER_VERTICAL,
  361. pos = (row, 1))
  362. #
  363. # appearence
  364. #
  365. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Appearance settings"))
  366. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  367. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  368. gridSizer.AddGrowableCol(0)
  369. #
  370. # element list
  371. #
  372. row = 0
  373. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  374. label = _("Element list:")),
  375. flag = wx.ALIGN_LEFT |
  376. wx.ALIGN_CENTER_VERTICAL,
  377. pos = (row, 0))
  378. elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  379. choices = self.settings.Get(group = 'appearance', key = 'elementListExpand',
  380. subkey = 'choices', internal = True),
  381. name = "GetSelection")
  382. elementList.SetSelection(self.settings.Get(group = 'appearance', key = 'elementListExpand',
  383. subkey = 'selection'))
  384. self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
  385. gridSizer.Add(item = elementList,
  386. flag = wx.ALIGN_RIGHT |
  387. wx.ALIGN_CENTER_VERTICAL,
  388. pos = (row, 1))
  389. #
  390. # menu style
  391. #
  392. row += 1
  393. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  394. label = _("Menu style (requires to save and GUI restart):")),
  395. flag = wx.ALIGN_LEFT |
  396. wx.ALIGN_CENTER_VERTICAL,
  397. pos = (row, 0))
  398. listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
  399. subkey = 'choices', internal = True)
  400. menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  401. choices = listOfStyles,
  402. name = "GetSelection")
  403. menuItemText.SetSelection(self.settings.Get(group = 'appearance', key = 'menustyle', subkey = 'selection'))
  404. self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
  405. gridSizer.Add(item = menuItemText,
  406. flag = wx.ALIGN_RIGHT,
  407. pos = (row, 1))
  408. #
  409. # gselect.TreeCtrlComboPopup height
  410. #
  411. row += 1
  412. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  413. label = _("Height of map selection popup window (in pixels):")),
  414. flag = wx.ALIGN_LEFT |
  415. wx.ALIGN_CENTER_VERTICAL,
  416. pos = (row, 0))
  417. min = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'min', internal = True)
  418. max = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'max', internal = True)
  419. value = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
  420. popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
  421. popupHeightSpin.SetRange(min,max)
  422. popupHeightSpin.SetValue(value)
  423. self.winId['appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
  424. gridSizer.Add(item = popupHeightSpin,
  425. flag = wx.ALIGN_RIGHT,
  426. pos = (row, 1))
  427. #
  428. # icon theme
  429. #
  430. row += 1
  431. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  432. label = _("Icon theme (requires GUI restart):")),
  433. flag = wx.ALIGN_LEFT |
  434. wx.ALIGN_CENTER_VERTICAL,
  435. pos = (row, 0))
  436. iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
  437. choices = self.settings.Get(group = 'appearance', key = 'iconTheme',
  438. subkey = 'choices', internal = True),
  439. name = "GetStringSelection")
  440. iconTheme.SetStringSelection(self.settings.Get(group = 'appearance', key = 'iconTheme', subkey = 'type'))
  441. self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
  442. gridSizer.Add(item = iconTheme,
  443. flag = wx.ALIGN_RIGHT |
  444. wx.ALIGN_CENTER_VERTICAL,
  445. pos = (row, 1))
  446. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  447. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  448. panel.SetSizer(border)
  449. # bindings
  450. outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
  451. return panel
  452. def _createDisplayPage(self, notebook):
  453. """!Create notebook page for display settings"""
  454. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  455. notebook.AddPage(page = panel, text = _("Map Display"))
  456. border = wx.BoxSizer(wx.VERTICAL)
  457. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  458. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  459. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  460. gridSizer.AddGrowableCol(0)
  461. #
  462. # font settings
  463. #
  464. row = 0
  465. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  466. label = _("Default font for GRASS displays:")),
  467. flag = wx.ALIGN_LEFT |
  468. wx.ALIGN_CENTER_VERTICAL,
  469. pos = (row, 0))
  470. fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
  471. label = _("Set font"), size = (100, -1))
  472. gridSizer.Add(item = fontButton,
  473. flag = wx.ALIGN_RIGHT |
  474. wx.ALIGN_CENTER_VERTICAL,
  475. pos = (row, 1))
  476. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  477. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  478. #
  479. # display settings
  480. #
  481. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Default display settings"))
  482. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  483. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  484. gridSizer.AddGrowableCol(0)
  485. #
  486. # display driver
  487. #
  488. row = 0
  489. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  490. label = _("Display driver:")),
  491. flag = wx.ALIGN_LEFT |
  492. wx.ALIGN_CENTER_VERTICAL,
  493. pos = (row, 0))
  494. listOfDrivers = self.settings.Get(group = 'display', key = 'driver', subkey = 'choices', internal = True)
  495. driver = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
  496. choices = listOfDrivers,
  497. name = "GetStringSelection")
  498. driver.SetStringSelection(self.settings.Get(group = 'display', key = 'driver', subkey = 'type'))
  499. self.winId['display:driver:type'] = driver.GetId()
  500. gridSizer.Add(item = driver,
  501. flag = wx.ALIGN_RIGHT,
  502. pos = (row, 1))
  503. #
  504. # Statusbar mode
  505. #
  506. row += 1
  507. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  508. label = _("Statusbar mode:")),
  509. flag = wx.ALIGN_LEFT |
  510. wx.ALIGN_CENTER_VERTICAL,
  511. pos = (row, 0))
  512. listOfModes = self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'choices', internal = True)
  513. statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
  514. choices = listOfModes,
  515. name = "GetSelection")
  516. statusbarMode.SetSelection(self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'selection'))
  517. self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
  518. gridSizer.Add(item = statusbarMode,
  519. flag = wx.ALIGN_RIGHT,
  520. pos = (row, 1))
  521. #
  522. # Background color
  523. #
  524. row += 1
  525. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  526. label = _("Background color:")),
  527. flag = wx.ALIGN_LEFT |
  528. wx.ALIGN_CENTER_VERTICAL,
  529. pos = (row, 0))
  530. bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  531. colour = self.settings.Get(group = 'display', key = 'bgcolor', subkey = 'color'),
  532. size = globalvar.DIALOG_COLOR_SIZE)
  533. bgColor.SetName('GetColour')
  534. self.winId['display:bgcolor:color'] = bgColor.GetId()
  535. gridSizer.Add(item = bgColor,
  536. flag = wx.ALIGN_RIGHT,
  537. pos = (row, 1))
  538. #
  539. # Align extent to display size
  540. #
  541. row += 1
  542. alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  543. label = _("Align region extent based on display size"),
  544. name = "IsChecked")
  545. alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
  546. self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
  547. gridSizer.Add(item = alignExtent,
  548. pos = (row, 0), span = (1, 2))
  549. #
  550. # Use computation resolution
  551. #
  552. row += 1
  553. compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  554. label = _("Constrain display resolution to computational settings"),
  555. name = "IsChecked")
  556. compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
  557. self.winId['display:compResolution:enabled'] = compResolution.GetId()
  558. gridSizer.Add(item = compResolution,
  559. pos = (row, 0), span = (1, 2))
  560. #
  561. # auto-rendering
  562. #
  563. row += 1
  564. autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  565. label = _("Enable auto-rendering"),
  566. name = "IsChecked")
  567. autoRendering.SetValue(self.settings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled'))
  568. self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
  569. gridSizer.Add(item = autoRendering,
  570. pos = (row, 0), span = (1, 2))
  571. #
  572. # auto-zoom
  573. #
  574. row += 1
  575. autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  576. label = _("Enable auto-zooming to selected map layer"),
  577. name = "IsChecked")
  578. autoZooming.SetValue(self.settings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'))
  579. self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
  580. gridSizer.Add(item = autoZooming,
  581. pos = (row, 0), span = (1, 2))
  582. #
  583. # mouse wheel zoom
  584. #
  585. row += 1
  586. wheelZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  587. label = _("Enable zooming by mouse wheel"),
  588. name = "IsChecked")
  589. wheelZooming.SetValue(self.settings.Get(group = 'display', key = 'mouseWheelZoom',
  590. subkey = 'enabled'))
  591. self.winId['display:mouseWheelZoom:enabled'] = wheelZooming.GetId()
  592. gridSizer.Add(item = wheelZooming,
  593. pos = (row, 0), flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
  594. listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
  595. zoomMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
  596. choices = listOfModes,
  597. name = "GetSelection")
  598. zoomMode.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
  599. self.winId['display:mouseWheelZoom:selection'] = zoomMode.GetId()
  600. gridSizer.Add(item = zoomMode,
  601. flag = wx.ALIGN_RIGHT,
  602. pos = (row, 1))
  603. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  604. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  605. panel.SetSizer(border)
  606. # bindings
  607. fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
  608. wheelZooming.Bind(wx.EVT_CHECKBOX, self.OnEnableWheelZoom)
  609. # enable/disable controls according to settings
  610. self.OnEnableWheelZoom(None)
  611. return panel
  612. def _createCmdPage(self, notebook):
  613. """!Create notebook page for commad dialog settings"""
  614. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  615. notebook.AddPage(page = panel, text = _("Command"))
  616. border = wx.BoxSizer(wx.VERTICAL)
  617. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Command dialog settings"))
  618. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  619. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  620. gridSizer.AddGrowableCol(0)
  621. #
  622. # command dialog settings
  623. #
  624. row = 0
  625. # overwrite
  626. overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  627. label = _("Allow output files to overwrite existing files"),
  628. name = "IsChecked")
  629. overwrite.SetValue(self.settings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled'))
  630. self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
  631. gridSizer.Add(item = overwrite,
  632. pos = (row, 0), span = (1, 2))
  633. row += 1
  634. # close
  635. close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  636. label = _("Close dialog when command is successfully finished"),
  637. name = "IsChecked")
  638. close.SetValue(self.settings.Get(group = 'cmd', key = 'closeDlg', subkey = 'enabled'))
  639. self.winId['cmd:closeDlg:enabled'] = close.GetId()
  640. gridSizer.Add(item = close,
  641. pos = (row, 0), span = (1, 2))
  642. row += 1
  643. # add layer
  644. add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  645. label = _("Add created map into layer tree"),
  646. name = "IsChecked")
  647. add.SetValue(self.settings.Get(group = 'cmd', key = 'addNewLayer', subkey = 'enabled'))
  648. self.winId['cmd:addNewLayer:enabled'] = add.GetId()
  649. gridSizer.Add(item = add,
  650. pos = (row, 0), span = (1, 2))
  651. row += 1
  652. # interactive input
  653. interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  654. label = _("Allow interactive input"),
  655. name = "IsChecked")
  656. interactive.SetValue(self.settings.Get(group = 'cmd', key = 'interactiveInput', subkey = 'enabled'))
  657. self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
  658. gridSizer.Add(item = interactive,
  659. pos = (row, 0), span = (1, 2))
  660. row += 1
  661. # verbosity
  662. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  663. label = _("Verbosity level:")),
  664. flag = wx.ALIGN_LEFT |
  665. wx.ALIGN_CENTER_VERTICAL,
  666. pos = (row, 0))
  667. verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
  668. choices = self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'choices', internal = True),
  669. name = "GetStringSelection")
  670. verbosity.SetStringSelection(self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'selection'))
  671. self.winId['cmd:verbosity:selection'] = verbosity.GetId()
  672. gridSizer.Add(item = verbosity,
  673. pos = (row, 1), flag = wx.ALIGN_RIGHT)
  674. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  675. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  676. #
  677. # raster settings
  678. #
  679. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Raster settings"))
  680. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  681. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  682. gridSizer.AddGrowableCol(0)
  683. #
  684. # raster overlay
  685. #
  686. row = 0
  687. rasterOpaque = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  688. label = _("Make null cells opaque"),
  689. name = 'IsChecked')
  690. rasterOpaque.SetValue(self.settings.Get(group = 'cmd', key = 'rasterOpaque', subkey = 'enabled'))
  691. self.winId['cmd:rasterOpaque:enabled'] = rasterOpaque.GetId()
  692. gridSizer.Add(item = rasterOpaque,
  693. pos = (row, 0), span = (1, 2))
  694. # default color table
  695. row += 1
  696. rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  697. label = _("Default color table"),
  698. name = 'IsChecked')
  699. rasterCTCheck.SetValue(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'enabled'))
  700. self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
  701. rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
  702. gridSizer.Add(item = rasterCTCheck,
  703. pos = (row, 0))
  704. rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
  705. choices = GetColorTables(),
  706. name = "GetStringSelection")
  707. rasterCTName.SetStringSelection(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'selection'))
  708. self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
  709. if not rasterCTCheck.IsChecked():
  710. rasterCTName.Enable(False)
  711. gridSizer.Add(item = rasterCTName,
  712. pos = (row, 1))
  713. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  714. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  715. #
  716. # vector settings
  717. #
  718. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Vector settings"))
  719. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  720. gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
  721. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  722. label = _("Display:")),
  723. flag = wx.ALIGN_CENTER_VERTICAL)
  724. for type in ('point', 'line', 'centroid', 'boundary',
  725. 'area', 'face'):
  726. chkbox = wx.CheckBox(parent = panel, label = type)
  727. checked = self.settings.Get(group = 'cmd', key = 'showType',
  728. subkey = [type, 'enabled'])
  729. chkbox.SetValue(checked)
  730. self.winId['cmd:showType:%s:enabled' % type] = chkbox.GetId()
  731. gridSizer.Add(item = chkbox)
  732. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  733. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  734. panel.SetSizer(border)
  735. return panel
  736. def _createAttributeManagerPage(self, notebook):
  737. """!Create notebook page for 'Attribute Table Manager' settings"""
  738. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  739. notebook.AddPage(page = panel, text = _("Attributes"))
  740. pageSizer = wx.BoxSizer(wx.VERTICAL)
  741. #
  742. # highlighting
  743. #
  744. highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  745. label = " %s " % _("Highlighting"))
  746. highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
  747. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  748. flexSizer.AddGrowableCol(0)
  749. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
  750. hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  751. colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
  752. size = globalvar.DIALOG_COLOR_SIZE)
  753. hlColor.SetName('GetColour')
  754. self.winId['atm:highlight:color'] = hlColor.GetId()
  755. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  756. flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  757. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
  758. hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
  759. initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
  760. min = 1, max = 1e6)
  761. self.winId['atm:highlight:width'] = hlWidth.GetId()
  762. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  763. flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  764. highlightSizer.Add(item = flexSizer,
  765. proportion = 0,
  766. flag = wx.ALL | wx.EXPAND,
  767. border = 5)
  768. pageSizer.Add(item = highlightSizer,
  769. proportion = 0,
  770. flag = wx.ALL | wx.EXPAND,
  771. border = 5)
  772. #
  773. # data browser related settings
  774. #
  775. dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  776. label = " %s " % _("Data browser"))
  777. dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
  778. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  779. flexSizer.AddGrowableCol(0)
  780. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Left mouse double click:"))
  781. leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
  782. choices = self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'choices', internal = True),
  783. name = "GetSelection")
  784. leftDbClick.SetSelection(self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'selection'))
  785. self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
  786. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  787. flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  788. # encoding
  789. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  790. label = _("Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
  791. encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  792. value = self.settings.Get(group = 'atm', key = 'encoding', subkey = 'value'),
  793. name = "GetValue", size = (200, -1))
  794. self.winId['atm:encoding:value'] = encoding.GetId()
  795. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  796. flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  797. # ask on delete record
  798. askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  799. label = _("Ask when deleting data record(s) from table"),
  800. name = 'IsChecked')
  801. askOnDeleteRec.SetValue(self.settings.Get(group = 'atm', key = 'askOnDeleteRec', subkey = 'enabled'))
  802. self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
  803. flexSizer.Add(askOnDeleteRec, proportion = 0)
  804. dataBrowserSizer.Add(item = flexSizer,
  805. proportion = 0,
  806. flag = wx.ALL | wx.EXPAND,
  807. border = 5)
  808. pageSizer.Add(item = dataBrowserSizer,
  809. proportion = 0,
  810. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
  811. border = 3)
  812. #
  813. # create table
  814. #
  815. createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  816. label = " %s " % _("Create table"))
  817. createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
  818. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  819. flexSizer.AddGrowableCol(0)
  820. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  821. label = _("Key column:"))
  822. keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  823. size = (250, -1))
  824. keyColumn.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
  825. self.winId['atm:keycolumn:value'] = keyColumn.GetId()
  826. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  827. flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  828. createTableSizer.Add(item = flexSizer,
  829. proportion = 0,
  830. flag = wx.ALL | wx.EXPAND,
  831. border = 5)
  832. pageSizer.Add(item = createTableSizer,
  833. proportion = 0,
  834. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
  835. border = 3)
  836. panel.SetSizer(pageSizer)
  837. return panel
  838. def _createProjectionPage(self, notebook):
  839. """!Create notebook page for workspace settings"""
  840. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  841. notebook.AddPage(page = panel, text = _("Projection"))
  842. border = wx.BoxSizer(wx.VERTICAL)
  843. #
  844. # projections statusbar settings
  845. #
  846. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Projection statusbar settings"))
  847. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  848. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  849. gridSizer.AddGrowableCol(1)
  850. # epsg
  851. row = 0
  852. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  853. label = _("EPSG code:"))
  854. epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
  855. name = "GetValue",
  856. size = (150, -1))
  857. self.epsgCodeDict = dict()
  858. epsgCode.SetValue(str(self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')))
  859. self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
  860. gridSizer.Add(item = label,
  861. pos = (row, 0),
  862. flag = wx.ALIGN_CENTER_VERTICAL)
  863. gridSizer.Add(item = epsgCode,
  864. pos = (row, 1), span = (1, 2))
  865. # proj
  866. row += 1
  867. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  868. label = _("Proj.4 string (required):"))
  869. projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  870. value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'),
  871. name = "GetValue", size = (400, -1))
  872. self.winId['projection:statusbar:proj4'] = projString.GetId()
  873. gridSizer.Add(item = label,
  874. pos = (row, 0),
  875. flag = wx.ALIGN_CENTER_VERTICAL)
  876. gridSizer.Add(item = projString,
  877. pos = (row, 1), span = (1, 2),
  878. flag = wx.ALIGN_CENTER_VERTICAL)
  879. # epsg file
  880. row += 1
  881. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  882. label = _("EPSG file:"))
  883. projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  884. value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'projFile'),
  885. name = "GetValue", size = (400, -1))
  886. self.winId['projection:statusbar:projFile'] = projFile.GetId()
  887. gridSizer.Add(item = label,
  888. pos = (row, 0),
  889. flag = wx.ALIGN_CENTER_VERTICAL)
  890. gridSizer.Add(item = projFile,
  891. pos = (row, 1),
  892. flag = wx.ALIGN_CENTER_VERTICAL)
  893. # note + button
  894. row += 1
  895. note = wx.StaticText(parent = panel, id = wx.ID_ANY,
  896. label = _("Load EPSG codes (be patient), enter EPSG code or "
  897. "insert Proj.4 string directly."))
  898. gridSizer.Add(item = note,
  899. span = (1, 2),
  900. pos = (row, 0))
  901. row += 1
  902. epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
  903. label = _("&Load EPSG codes"))
  904. gridSizer.Add(item = epsgLoad,
  905. flag = wx.ALIGN_RIGHT,
  906. pos = (row, 1))
  907. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  908. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  909. #
  910. # format
  911. #
  912. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Coordinates format"))
  913. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  914. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  915. gridSizer.AddGrowableCol(2)
  916. row = 0
  917. # ll format
  918. ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
  919. label = " %s " % _("LL projections"),
  920. choices = ["DMS", "DEG"],
  921. name = "GetStringSelection")
  922. self.winId['projection:format:ll'] = ll.GetId()
  923. if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
  924. ll.SetSelection(0)
  925. else:
  926. ll.SetSelection(1)
  927. # precision
  928. precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  929. min = 0, max = 12,
  930. name = "GetValue")
  931. precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
  932. self.winId['projection:format:precision'] = precision.GetId()
  933. gridSizer.Add(item = ll,
  934. pos = (row, 0))
  935. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  936. label = _("Precision:")),
  937. flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
  938. border = 20,
  939. pos = (row, 1))
  940. gridSizer.Add(item = precision,
  941. flag = wx.ALIGN_CENTER_VERTICAL,
  942. pos = (row, 2))
  943. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  944. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  945. panel.SetSizer(border)
  946. # bindings
  947. epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
  948. epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
  949. epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
  950. return panel
  951. def OnCheckColorTable(self, event):
  952. """!Set/unset default color table"""
  953. win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
  954. if event.IsChecked():
  955. win.Enable()
  956. else:
  957. win.Enable(False)
  958. def OnLoadEpsgCodes(self, event):
  959. """!Load EPSG codes from the file"""
  960. win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
  961. path = win.GetValue()
  962. self.epsgCodeDict = ReadEpsgCodes(path)
  963. list = self.FindWindowById(self.winId['projection:statusbar:epsg'])
  964. if type(self.epsgCodeDict) == type(''):
  965. wx.MessageBox(parent = self,
  966. message = _("Unable to read EPSG codes: %s") % self.epsgCodeDict,
  967. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  968. self.epsgCodeDict = dict()
  969. list.SetItems([])
  970. list.SetValue('')
  971. self.FindWindowById(self.winId['projection:statusbar:proj4']).SetValue('')
  972. return
  973. choices = map(str, self.epsgCodeDict.keys())
  974. list.SetItems(choices)
  975. try:
  976. code = int(list.GetValue())
  977. except ValueError:
  978. code = -1
  979. win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
  980. if code in self.epsgCodeDict:
  981. win.SetValue(self.epsgCodeDict[code][1])
  982. else:
  983. list.SetSelection(0)
  984. code = int(list.GetStringSelection())
  985. win.SetValue(self.epsgCodeDict[code][1])
  986. def OnSetEpsgCode(self, event):
  987. """!EPSG code selected"""
  988. winCode = self.FindWindowById(event.GetId())
  989. win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
  990. if not self.epsgCodeDict:
  991. wx.MessageBox(parent = self,
  992. message = _("EPSG code %s not found") % event.GetString(),
  993. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  994. winCode.SetValue('')
  995. win.SetValue('')
  996. try:
  997. code = int(event.GetString())
  998. except ValueError:
  999. wx.MessageBox(parent = self,
  1000. message = _("EPSG code %s not found") % str(code),
  1001. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  1002. winCode.SetValue('')
  1003. win.SetValue('')
  1004. try:
  1005. win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
  1006. except KeyError:
  1007. wx.MessageBox(parent = self,
  1008. message = _("EPSG code %s not found") % str(code),
  1009. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  1010. winCode.SetValue('')
  1011. win.SetValue('')
  1012. def OnSetFont(self, event):
  1013. """'Set font' button pressed"""
  1014. dlg = DefaultFontDialog(parent = self,
  1015. title = _('Select default display font'),
  1016. style = wx.DEFAULT_DIALOG_STYLE,
  1017. type = 'font')
  1018. if dlg.ShowModal() == wx.ID_OK:
  1019. # set default font and encoding environmental variables
  1020. if dlg.font:
  1021. os.environ["GRASS_FONT"] = dlg.font
  1022. self.settings.Set(group = 'display', value = dlg.font,
  1023. key = 'font', subkey = 'type')
  1024. if dlg.encoding and \
  1025. dlg.encoding != "ISO-8859-1":
  1026. os.environ["GRASS_ENCODING"] = dlg.encoding
  1027. self.settings.Set(group = 'display', value = dlg.encoding,
  1028. key = 'font', subkey = 'encoding')
  1029. dlg.Destroy()
  1030. event.Skip()
  1031. def OnSetOutputFont(self, event):
  1032. """'Set output font' button pressed
  1033. """
  1034. type = self.settings.Get(group = 'appearance', key = 'outputfont', subkey = 'type')
  1035. size = self.settings.Get(group = 'appearance', key = 'outputfont', subkey = 'size')
  1036. if size == None or size == 0: size = 11
  1037. size = float(size)
  1038. if type == None or type == '': type = 'Courier'
  1039. outfont = wx.Font(size, wx.FONTFAMILY_MODERN, wx.NORMAL, 0, faceName = type)
  1040. fontdata = wx.FontData()
  1041. fontdata.EnableEffects(True)
  1042. fontdata.SetColour('black')
  1043. fontdata.SetInitialFont(outfont)
  1044. dlg = wx.FontDialog(self, fontdata)
  1045. 'FIXME: native font dialog does not initialize with current font'
  1046. if dlg.ShowModal() == wx.ID_OK:
  1047. outdata = dlg.GetFontData()
  1048. font = outdata.GetChosenFont()
  1049. self.settings.Set(group = 'appearance', value = font.GetFaceName(),
  1050. key = 'outputfont', subkey = 'type')
  1051. self.settings.Set(group = 'appearance', value = font.GetPointSize(),
  1052. key = 'outputfont', subkey = 'size')
  1053. dlg.Destroy()
  1054. event.Skip()
  1055. def OnEnableWheelZoom(self, event):
  1056. """!Enable/disable wheel zoom mode control"""
  1057. checkId = self.winId['display:mouseWheelZoom:enabled']
  1058. choiceId = self.winId['display:mouseWheelZoom:selection']
  1059. enable = self.FindWindowById(checkId).IsChecked()
  1060. self.FindWindowById(choiceId).Enable(enable)
  1061. class DefaultFontDialog(wx.Dialog):
  1062. """
  1063. Opens a file selection dialog to select default font
  1064. to use in all GRASS displays
  1065. """
  1066. def __init__(self, parent, title, id = wx.ID_ANY,
  1067. style = wx.DEFAULT_DIALOG_STYLE |
  1068. wx.RESIZE_BORDER,
  1069. settings = UserSettings,
  1070. type = 'font'):
  1071. self.settings = settings
  1072. self.type = type
  1073. wx.Dialog.__init__(self, parent, id, title, style = style)
  1074. panel = wx.Panel(parent = self, id = wx.ID_ANY)
  1075. self.fontlist = self.GetFonts()
  1076. border = wx.BoxSizer(wx.VERTICAL)
  1077. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  1078. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  1079. gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
  1080. gridSizer.AddGrowableCol(0)
  1081. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1082. label = _("Select font:"))
  1083. gridSizer.Add(item = label,
  1084. flag = wx.ALIGN_TOP,
  1085. pos = (0,0))
  1086. self.fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
  1087. choices = self.fontlist,
  1088. style = wx.LB_SINGLE|wx.LB_SORT)
  1089. self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.fontlb)
  1090. self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.fontlb)
  1091. gridSizer.Add(item = self.fontlb,
  1092. flag = wx.EXPAND, pos = (1, 0))
  1093. if self.type == 'font':
  1094. if "GRASS_FONT" in os.environ:
  1095. self.font = os.environ["GRASS_FONT"]
  1096. else:
  1097. self.font = self.settings.Get(group = 'display',
  1098. key = 'font', subkey = 'type')
  1099. self.encoding = self.settings.Get(group = 'display',
  1100. key = 'font', subkey = 'encoding')
  1101. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1102. label = _("Character encoding:"))
  1103. gridSizer.Add(item = label,
  1104. flag = wx.ALIGN_CENTER_VERTICAL,
  1105. pos = (2, 0))
  1106. self.textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  1107. value = self.encoding)
  1108. gridSizer.Add(item = self.textentry,
  1109. flag = wx.EXPAND, pos = (3, 0))
  1110. self.textentry.Bind(wx.EVT_TEXT, self.OnEncoding)
  1111. elif self.type == 'outputfont':
  1112. self.font = self.settings.Get(group = 'appearance',
  1113. key = 'outputfont', subkey = 'type')
  1114. self.fontsize = self.settings.Get(group = 'appearance',
  1115. key = 'outputfont', subkey = 'size')
  1116. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1117. label = _("Font size:"))
  1118. gridSizer.Add(item = label,
  1119. flag = wx.ALIGN_CENTER_VERTICAL,
  1120. pos = (2, 0))
  1121. self.spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
  1122. if self.fontsize:
  1123. self.spin.SetValue(int(self.fontsize))
  1124. self.spin.Bind(wx.EVT_SPINCTRL, self.OnSizeSpin)
  1125. self.spin.Bind(wx.EVT_TEXT, self.OnSizeSpin)
  1126. gridSizer.Add(item = self.spin,
  1127. flag = wx.ALIGN_CENTER_VERTICAL,
  1128. pos = (3, 0))
  1129. else:
  1130. return
  1131. if self.font:
  1132. self.fontlb.SetStringSelection(self.font, True)
  1133. sizer.Add(item = gridSizer, proportion = 1,
  1134. flag = wx.EXPAND | wx.ALL,
  1135. border = 5)
  1136. border.Add(item = sizer, proportion = 1,
  1137. flag = wx.ALL | wx.EXPAND, border = 3)
  1138. btnsizer = wx.StdDialogButtonSizer()
  1139. btn = wx.Button(parent = panel, id = wx.ID_OK)
  1140. btn.SetDefault()
  1141. btnsizer.AddButton(btn)
  1142. btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
  1143. btnsizer.AddButton(btn)
  1144. btnsizer.Realize()
  1145. border.Add(item = btnsizer, proportion = 0,
  1146. flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
  1147. panel.SetAutoLayout(True)
  1148. panel.SetSizer(border)
  1149. border.Fit(self)
  1150. self.Layout()
  1151. def EvtRadioBox(self, event):
  1152. if event.GetInt() == 0:
  1153. self.fonttype = 'grassfont'
  1154. elif event.GetInt() == 1:
  1155. self.fonttype = 'truetype'
  1156. self.fontlist = self.GetFonts(self.fonttype)
  1157. self.fontlb.SetItems(self.fontlist)
  1158. def OnEncoding(self, event):
  1159. self.encoding = event.GetString()
  1160. def EvtListBox(self, event):
  1161. self.font = event.GetString()
  1162. event.Skip()
  1163. def EvtListBoxDClick(self, event):
  1164. self.font = event.GetString()
  1165. event.Skip()
  1166. def OnSizeSpin(self, event):
  1167. self.fontsize = self.spin.GetValue()
  1168. event.Skip()
  1169. def GetFonts(self):
  1170. """
  1171. parses fonts directory or fretypecap file to get a list of fonts for the listbox
  1172. """
  1173. fontlist = []
  1174. cmd = ["d.font", "-l"]
  1175. ret = RunCommand('d.font',
  1176. read = True,
  1177. flags = 'l')
  1178. if not ret:
  1179. return fontlist
  1180. dfonts = ret.splitlines()
  1181. dfonts.sort(lambda x,y: cmp(x.lower(), y.lower()))
  1182. for item in range(len(dfonts)):
  1183. # ignore duplicate fonts and those starting with #
  1184. if not dfonts[item].startswith('#') and \
  1185. dfonts[item] != dfonts[item-1]:
  1186. fontlist.append(dfonts[item])
  1187. return fontlist
  1188. class MapsetAccess(wx.Dialog):
  1189. """!Controls setting options and displaying/hiding map overlay
  1190. decorations
  1191. """
  1192. def __init__(self, parent, id = wx.ID_ANY,
  1193. title = _('Manage access to mapsets'),
  1194. size = (350, 400),
  1195. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
  1196. wx.Dialog.__init__(self, parent, id, title, size = size, style = style)
  1197. self.all_mapsets_ordered = ListOfMapsets(get = 'ordered')
  1198. self.accessible_mapsets = ListOfMapsets(get = 'accessible')
  1199. self.curr_mapset = grass.gisenv()['MAPSET']
  1200. # make a checklistbox from available mapsets and check those that are active
  1201. sizer = wx.BoxSizer(wx.VERTICAL)
  1202. label = wx.StaticText(parent = self, id = wx.ID_ANY,
  1203. label = _("Check a mapset to make it accessible, uncheck it to hide it.\n"
  1204. " Notes:\n"
  1205. " - The current mapset is always accessible.\n"
  1206. " - You may only write to the current mapset.\n"
  1207. " - You may only write to mapsets which you own."))
  1208. sizer.Add(item = label, proportion = 0,
  1209. flag = wx.ALL, border = 5)
  1210. self.mapsetlb = CheckListMapset(parent = self)
  1211. self.mapsetlb.LoadData()
  1212. sizer.Add(item = self.mapsetlb, proportion = 1,
  1213. flag = wx.ALL | wx.EXPAND, border = 5)
  1214. # check all accessible mapsets
  1215. for mset in self.accessible_mapsets:
  1216. self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset), True)
  1217. # FIXME (howto?): grey-out current mapset
  1218. #self.mapsetlb.Enable(0, False)
  1219. # dialog buttons
  1220. line = wx.StaticLine(parent = self, id = wx.ID_ANY,
  1221. style = wx.LI_HORIZONTAL)
  1222. sizer.Add(item = line, proportion = 0,
  1223. flag = wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border = 5)
  1224. btnsizer = wx.StdDialogButtonSizer()
  1225. okbtn = wx.Button(self, wx.ID_OK)
  1226. okbtn.SetDefault()
  1227. btnsizer.AddButton(okbtn)
  1228. cancelbtn = wx.Button(self, wx.ID_CANCEL)
  1229. btnsizer.AddButton(cancelbtn)
  1230. btnsizer.Realize()
  1231. sizer.Add(item = btnsizer, proportion = 0,
  1232. flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
  1233. # do layout
  1234. self.Layout()
  1235. self.SetSizer(sizer)
  1236. sizer.Fit(self)
  1237. self.SetMinSize(size)
  1238. def GetMapsets(self):
  1239. """!Get list of checked mapsets"""
  1240. ms = []
  1241. i = 0
  1242. for mset in self.all_mapsets_ordered:
  1243. if self.mapsetlb.IsChecked(i):
  1244. ms.append(mset)
  1245. i += 1
  1246. return ms
  1247. class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
  1248. """!List of mapset/owner/group"""
  1249. def __init__(self, parent, pos = wx.DefaultPosition,
  1250. log = None):
  1251. self.parent = parent
  1252. wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
  1253. style = wx.LC_REPORT)
  1254. listmix.CheckListCtrlMixin.__init__(self)
  1255. self.log = log
  1256. # setup mixins
  1257. listmix.ListCtrlAutoWidthMixin.__init__(self)
  1258. def LoadData(self):
  1259. """!Load data into list"""
  1260. self.InsertColumn(0, _('Mapset'))
  1261. self.InsertColumn(1, _('Owner'))
  1262. ### self.InsertColumn(2, _('Group'))
  1263. gisenv = grass.gisenv()
  1264. locationPath = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
  1265. for mapset in self.parent.all_mapsets_ordered:
  1266. index = self.InsertStringItem(sys.maxint, mapset)
  1267. mapsetPath = os.path.join(locationPath,
  1268. mapset)
  1269. stat_info = os.stat(mapsetPath)
  1270. if havePwd:
  1271. self.SetStringItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
  1272. # FIXME: get group name
  1273. ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
  1274. else:
  1275. # FIXME: no pwd under MS Windows (owner: 0, group: 0)
  1276. self.SetStringItem(index, 1, "%-8s" % stat_info.st_uid)
  1277. ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
  1278. self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
  1279. ### self.SetColumnWidth(col = 1, width = wx.LIST_AUTOSIZE)
  1280. def OnCheckItem(self, index, flag):
  1281. """!Mapset checked/unchecked"""
  1282. mapset = self.parent.all_mapsets_ordered[index]
  1283. if mapset == self.parent.curr_mapset:
  1284. self.CheckItem(index, True)