[GRASS-SVN] r30191 - grass/branches/releasebranch_6_3/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 16 13:28:52 EST 2008


Author: martinl
Date: 2008-02-16 13:28:52 -0500 (Sat, 16 Feb 2008)
New Revision: 30191

Modified:
   grass/branches/releasebranch_6_3/lib/gis/parser.c
Log:
Parser merged from trunk (especially wxPython GUI-related code)

Modified: grass/branches/releasebranch_6_3/lib/gis/parser.c
===================================================================
--- grass/branches/releasebranch_6_3/lib/gis/parser.c	2008-02-16 18:03:07 UTC (rev 30190)
+++ grass/branches/releasebranch_6_3/lib/gis/parser.c	2008-02-16 18:28:52 UTC (rev 30191)
@@ -1,14 +1,14 @@
 /**
  * \file parser.c
  *
- * \brief Argument parsing functions.
+ * \brief GIS library - Argument parsing functions.
  *
+ * \author Radim Blazek
+ *
+ * \date 2003-2008 (C) 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.
- *
- * \author Radim Blazek
- *
- * \date 2003-2006
  */
 
 /***************************************************************************
@@ -336,6 +336,7 @@
     Opt = G_define_option();
 
     switch ( opt ) {
+	/* Database options (change to G_OPT_DB_*?) */
 	case G_OPT_WHERE:
 	    Opt->key          = "where";
 	    Opt->type         = TYPE_STRING;
@@ -384,6 +385,7 @@
 	    Opt->multiple     = YES;
 	    Opt->description  = _("Name of attribute column(s)");
 	    break;
+
         /* imagery group */
         case G_OPT_I_GROUP:
 	    Opt->key          = "group";
@@ -393,6 +395,7 @@
 	    Opt->gisprompt    = "old,group,group";
 	    Opt->description  = _("Name of input imagery group");
             break;
+
 	/* raster maps */    
 	case G_OPT_R_INPUT:
 	    Opt->key          = "input";
@@ -781,8 +784,8 @@
 				j++;
 			    }
 			    if ( !found ) {
-				G_warning ( "BUG in descriptions, option %s in %s does not exist",
-				             tokens[i], opt->key );
+				G_warning (_("BUG in descriptions, option %s in %s does not exist"),
+					   tokens[i], opt->key );
 			    } else {
 				opt->descs[j] = G_store ( tokens[i+1] );
 			    }
@@ -889,10 +892,14 @@
                         else if ( strcmp(ptr,"--v") == 0 || strcmp(ptr,"--verbose") == 0 )
 			{
                             char buff[32];
-                            /* print everything: verbosity level 2 */
+                            /* print everything: max verbosity level */
 			    module_info.verbose = G_verbose_max();
                             sprintf(buff,"GRASS_VERBOSE=%d",G_verbose_max()) ;
                             putenv(G_store(buff));
+			    if (quiet == 1) {
+				G_warning(_("Use either --quiet or --verbose flag, not both. Assuming --verbose."));
+			    }
+			    quiet = -1;
 			}
 
 			/* Quiet option */
@@ -903,11 +910,12 @@
 			    module_info.verbose = G_verbose_min();
                             sprintf(buff,"GRASS_VERBOSE=%d",G_verbose_min()) ;
                             putenv(G_store(buff));
+			    if (quiet == -1) {
+				G_warning(_("Use either --quiet or --verbose flag, not both. Assuming --quiet."));
+			    }
 			    quiet = 1; /* for passing to gui init */
 			}
 
-
-
 			/* Force gui to come up */
 			else if ( strcmp(ptr,"--ui") == 0 )
 			{
@@ -1256,6 +1264,9 @@
 }
 #undef do_escape
 
+/**
+   \brief Print module usage description in XML format.
+**/
 static void G_usage_xml (void)
 {
 	struct Option *opt ;
@@ -1264,7 +1275,10 @@
 	char *s, *top;
 	int i;
 	char *encoding;
+	int new_prompt = 0;
 
+	new_prompt = uses_new_gisprompt();
+
 /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
 
 #if defined(HAVE_LANGINFO_H)
@@ -1389,9 +1403,9 @@
 			}
 
 			if(opt->def) {
-				fprintf(stdout, "\t\t\t<default>\n\t\t\t");
+				fprintf(stdout, "\t\t<default>\n\t\t\t");
 				print_escaped_for_xml(stdout, opt->def);
-				fprintf(stdout, "\n\t\t\t</default>\n");
+				fprintf(stdout, "\n\t\t</default>\n");
 			}
 
 			if(opt->options) {
@@ -1469,9 +1483,35 @@
 	 *****
 	 *****/
 
+	if (new_prompt) {
+	        /* overwrite */
+	        fprintf(stdout, "\t<flag name=\"%s\">\n", "overwrite");
+		fprintf(stdout, "\t\t<description>\n\t\t\t");
+		print_escaped_for_xml(stdout, "Allow output files to overwrite existing files");
+		fprintf(stdout, "\n\t\t</description>\n");
+		fprintf (stdout, "\t</flag>\n");
+	}
+	
+	/* verbose */
+	fprintf(stdout, "\t<flag name=\"%s\">\n", "verbose");
+	fprintf(stdout, "\t\t<description>\n\t\t\t");
+	print_escaped_for_xml(stdout, "Verbose module output");
+	fprintf(stdout, "\n\t\t</description>\n");
+	fprintf (stdout, "\t</flag>\n");
+	
+	/* quiet */
+	fprintf(stdout, "\t<flag name=\"%s\">\n", "quiet");
+	fprintf(stdout, "\t\t<description>\n\t\t\t");
+	print_escaped_for_xml(stdout, "Quiet module output");
+	fprintf(stdout, "\n\t\t</description>\n");
+	fprintf (stdout, "\t</flag>\n");
+
 	fprintf(stdout, "</task>\n");
 }
 
+/**
+   \brief Print module usage description in HTML format.
+**/
 static void G_usage_html (void)
 {
 	struct Option *opt ;
@@ -1699,6 +1739,9 @@
     fprintf(stdout, "</body>\n</html>\n");
 }
 
+/**
+   \brief Print module usage description used in shell scripts.
+**/
 static void G_script(void)
 {
 	FILE *fp = stdout;
@@ -1812,6 +1855,11 @@
 		);
 }
 
+/**
+  \brief Generates tcltk dialog.
+
+  \param[out] fp File to store tcltk code
+**/
 static void generate_tcl(FILE *fp)
 {
 	int new_prompt = uses_new_gisprompt();
@@ -1909,7 +1957,9 @@
 	fprintf(fp, "end_dialog %d\n", optn - 1);
 }
 
-/* Build Tcl/Tk gui */
+/**
+   \brief Build Tcl/Tk GUI dialog
+**/
 static void G_gui_tcltk (void)
 {
 	FILE *fp;
@@ -1932,7 +1982,7 @@
 #endif
 
 	if (!fp)
-		G_fatal_error("unable to spawn wish");
+	    G_fatal_error(_("Unable to spawn wish"));
 
 	fprintf(fp, "source $env(GISBASE)/etc/gui.tcl\n");
 
@@ -1941,32 +1991,48 @@
 	G_pclose(fp);
 }
 
-/* Build wxPython gui */
+/**
+   \brief Build wxPython GUI dialog
+**/
 static void G_gui_wx (void)
 {
 	char script[GPATH_MAX];
 
 	if (!pgm_name)
-		pgm_name = G_program_name ();
+	    pgm_name = G_program_name ();
 	if (!pgm_name)
-		G_fatal_error("unable to determine program name");
+	    G_fatal_error(_("Unable to determine program name"));
 
-	sprintf(script, "%s/etc/wx/gui_modules/menuform.py", getenv("GISBASE"));
+	sprintf(script, "%s/etc/wxpython/gui_modules/menuform.py", getenv("GISBASE"));
 	G_spawn("python", "menuform.py", script, pgm_name, NULL);
 }
 
-/* Invoke gui */
+/**
+   \brief Invoke GUI dialog 
+
+   Use G_gui_wx() or G_gui_tcltk() to generate GUI dialog.
+
+   G_gui_tcltk() is called by default (if GRASS_GUI is not defined)
+**/
 static void G_gui (void)
 {
-	char *gui = getenv("GRASS_GUI");
+    /* read environment variables first then internal GRASS variable */
+    char *gui = getenv("GRASS_GUI");
+    if (!gui) {
+	gui = G_getenv("GRASS_GUI");
+    }
 
-	if (gui && strcmp(gui, "wx") == 0)
-		G_gui_wx();
-	else
-		G_gui_tcltk();
+    if (gui && strcmp(gui, "wxpython") == 0)
+	G_gui_wx();
+    else
+	G_gui_tcltk();
+
+    return;
 }
 
-/* Send Tcl/Tk code to tcltkgrass */
+/**
+   \brief Send Tcl/Tk code to tcltkgrass 
+**/
 static void G_tcltk (void)
 {
 	if (!pgm_name)
@@ -2533,7 +2599,7 @@
 			    if ( G_find_file (element, opt->answer, G_mapset()) ) /* found */
 			    {
 				if ( !overwrite && !over ) { 
-				    fprintf(stderr,_("ERROR: option <%s>: <%s> exists.\n"), 
+				    fprintf(stderr, _("ERROR: option <%s>: <%s> exists.\n"), 
 						   opt->key, opt->answer );
 
 				    error = 1;
@@ -2758,7 +2824,6 @@
 	return 0;
 }
 
-
 /**
  * \fn char *G_recreate_command (void)
  *
@@ -2769,7 +2834,6 @@
  *
  * \retval char * Pointer to a char string
  */
-
 char *G_recreate_command (void)
 {
 	static char *buff;
@@ -2873,4 +2937,3 @@
 
 	return(buff) ;
 }
-



More information about the grass-commit mailing list