[GRASS-SVN] r47585 - in grass/trunk: general/g.parser gui/wxpython/gui_modules include lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 11 18:14:26 EDT 2011


Author: lucadelu
Date: 2011-08-11 15:14:26 -0700 (Thu, 11 Aug 2011)
New Revision: 47585

Modified:
   grass/trunk/general/g.parser/standard_option.c
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/include/gis.h
   grass/trunk/lib/gis/parser_standard_options.c
Log:
add G_OPT_DIR data types and support it on wxpython gui

Modified: grass/trunk/general/g.parser/standard_option.c
===================================================================
--- grass/trunk/general/g.parser/standard_option.c	2011-08-11 22:04:10 UTC (rev 47584)
+++ grass/trunk/general/g.parser/standard_option.c	2011-08-11 22:14:26 UTC (rev 47585)
@@ -94,6 +94,8 @@
 	key = G_OPT_F_OUTPUT;
     else if (G_strcasecmp(name, "G_OPT_F_SEP") == 0)
 	key = G_OPT_F_SEP;
+    else if (G_strcasecmp(name, "G_OPT_DIR") == 0)
+        key = G_OPT_DIR;
     else if (G_strcasecmp(name, "G_OPT_C_FG") == 0)
 	key = G_OPT_C_FG;
     else if (G_strcasecmp(name, "G_OPT_C_BG") == 0)

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-08-11 22:04:10 UTC (rev 47584)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-08-11 22:14:26 UTC (rev 47585)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 """
 @brief Construct simple wxPython GUI from a GRASS command interface
 description.
@@ -41,6 +42,7 @@
 @author Michael Barton, Arizona State University
 @author Daniel Calvelo <dca.gis at gmail.com>
 @author Martin Landa <landa.martin at gmail.com>
+ at author Luca Delucchi <lucadeluge at gmail.com>
 """
 
 import sys
@@ -1110,7 +1112,7 @@
                                               'location',
                                               'mapset',
                                               'dbase') and \
-                       p.get('element', '') !=  'file':
+                       p.get('element', '') !=  'file' and p.get('element', '') !=  'dir':
                     multiple = p.get('multiple', False)
                     if p.get('age', '') ==  'new':
                         mapsets = [grass.gisenv()['MAPSET'],]
@@ -1375,7 +1377,26 @@
                         which_sizer.Add(item = ifbb, proportion = 1,
                                         flag = wx.EXPAND | wx.RIGHT | wx.LEFT, border = 5)
                         p['wxId'].append(ifbb.GetId())
-            
+                # directory selector
+                elif p.get('prompt','') !=  'color' and p.get('element', '') ==  'dir':
+                    fbb = filebrowse.DirBrowseButton(parent = which_panel, id = wx.ID_ANY,
+                                                      size = globalvar.DIALOG_GSELECT_SIZE, labelText = '',
+                                                      dialogTitle = _('Choose %s') % \
+                                                          p.get('description',_('Directory')),
+                                                      buttonText = _('Browse'),
+                                                      startDirectory = os.getcwd(),
+                                                      changeCallback = self.OnSetValue)
+                    value = self._getValue(p)
+                    if value:
+                        fbb.SetValue(value) # parameter previously set
+                    which_sizer.Add(item = fbb, proportion = 0,
+                                    flag = wx.EXPAND | wx.RIGHT, border = 5)
+                    
+                    # A file browse button is a combobox with two children:
+                    # a textctl and a button;
+                    # we have to target the button here
+                    p['wxId'] = [ fbb.GetChildren()[1].GetId() ]
+
             if self.parent.GetName() ==  'MainFrame' and self.parent.modeler:
                 parChk = wx.CheckBox(parent = which_panel, id = wx.ID_ANY,
                                      label = _("Parameterized in model"))

Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h	2011-08-11 22:04:10 UTC (rev 47584)
+++ grass/trunk/include/gis.h	2011-08-11 22:14:26 UTC (rev 47585)
@@ -4,6 +4,7 @@
  * MODULE:      Grass Include Files
  * AUTHOR(S):   Original author unknown - probably CERL
  *              Justin Hickey - Thailand - jhickey at hpcc.nectec.or.th
+ *              Luca Delucchi - Italy - lucadeluge at gmail.com
  * PURPOSE:     This file contains definitions of variables and data types
  *              for use with most, if not all, Grass programs. This file is
  *              usually included in every Grass program.
@@ -214,9 +215,11 @@
     G_OPT_F_OUTPUT,		/* new output file */
     G_OPT_F_SEP,		/* data field separator */
 
+    G_OPT_DIR,                  /* directory input */
+
     G_OPT_C_FG,			/* foreground color */
     G_OPT_C_BG,			/* background color */
-    
+
     G_OPT_M_UNITS,              /* units */
     G_OPT_M_DATATYPE,           /* datatype */
     G_OPT_M_MAPSET,             /* mapset */

Modified: grass/trunk/lib/gis/parser_standard_options.c
===================================================================
--- grass/trunk/lib/gis/parser_standard_options.c	2011-08-11 22:04:10 UTC (rev 47584)
+++ grass/trunk/lib/gis/parser_standard_options.c	2011-08-11 22:14:26 UTC (rev 47585)
@@ -10,6 +10,7 @@
   
   \author Original author CERL
   \author Soeren Gebbert added Dec. 2009 WPS process_description document
+  \author Luca Delucchi added Aug 2011 G_OPT_DIR
 */
 
 #include <grass/gis.h>
@@ -79,6 +80,9 @@
    - G_OPT_F_OUTPUT
    - G_OPT_F_SEP
    
+  - directory
+   - G_OPT_DIR
+   
   - colors
    - G_OPT_C_FG
    - G_OPT_C_BG
@@ -497,6 +501,16 @@
 	Opt->description = _("Special characters: newline, space, comma, tab");
 	break;
 
+        /* directory */
+    case G_OPT_DIR:
+        Opt->key = "input";
+        Opt->type = TYPE_STRING;
+        Opt->key_desc = "name";
+        Opt->required = YES;
+        Opt->gisprompt = "old,dir,input";
+        Opt->description = _("Name to input directory");
+        break;
+
 	/* colors */
     case G_OPT_C_FG:
 	Opt->key = "color";



More information about the grass-commit mailing list