[GRASS-SVN] r64714 - grass/branches/releasebranch_7_0/general/g.gui

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 21 06:17:02 PST 2015


Author: martinl
Date: 2015-02-21 06:17:02 -0800 (Sat, 21 Feb 2015)
New Revision: 64714

Modified:
   grass/branches/releasebranch_7_0/general/g.gui/main.c
Log:
g.gui: improve logic
       (merge r64689 from trunk)


Modified: grass/branches/releasebranch_7_0/general/g.gui/main.c
===================================================================
--- grass/branches/releasebranch_7_0/general/g.gui/main.c	2015-02-21 10:01:10 UTC (rev 64713)
+++ grass/branches/releasebranch_7_0/general/g.gui/main.c	2015-02-21 14:17:02 UTC (rev 64714)
@@ -8,7 +8,7 @@
  *
  * PURPOSE:      Start GRASS GUI from command line.
  *
- * COPYRIGHT:    (C) 2008-2014 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2008-2015 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -25,7 +25,7 @@
 int main(int argc, char *argv[])
 {
     struct Option *type, *rc_file;
-    struct Flag *update, *nolaunch;
+    struct Flag *update_ui, *nolaunch;
     struct GModule *module;
     const char *gui_type_env;
     char progname[GPATH_MAX];
@@ -40,20 +40,21 @@
         
     module->label =
 	_("Launches a GRASS graphical user interface (GUI) session.");
-    module->description = _("And updates default user interface settings.");
+    module->description = _("Optionally updates default user interface settings.");
 
     type = G_define_option();
     type->key = "ui";
     type->type = TYPE_STRING;
-    type->label = _("User interface");
-    type->description = _("Default value: GRASS_GUI if defined otherwise wxpython");
+    type->description = _("User interface");
     desc = NULL;
     G_asprintf(&desc,
-	        "wxpython;%s;text;%s",
-	        _("wxPython based GUI (wxGUI)"),
-	        _("command line interface only"));
+               "wxpython;%s;text;%s;gtext;%s;",
+               _("wxPython based GUI (wxGUI)"),
+               _("command line interface only"),
+               _("command line interface with GUI startup screen"));
     type->descriptions = desc;
-    type->options = "wxpython,text";
+    type->options = "wxpython,text,gtext";
+    type->answer = "wxpython";
     type->guisection = _("Type");
     
     rc_file = G_define_standard_option(G_OPT_F_INPUT);
@@ -62,10 +63,10 @@
     rc_file->key_desc = "name.gxw";
     rc_file->description = _("Name of workspace file to load on start-up (valid only for wxGUI)");
 
-    update = G_define_flag();
-    update->key = 'd';
-    update->description = _("Update default user interface settings");
-    update->guisection = _("Default");
+    update_ui = G_define_flag();
+    update_ui->key = 'd';
+    update_ui->description = _("Update default user interface settings");
+    update_ui->guisection = _("Default");
 
     nolaunch = G_define_flag();
     nolaunch->key = 'n';
@@ -76,58 +77,35 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-
-    if (type->answer && strcmp(type->answer, "text") == 0 &&
-	!nolaunch->answer)
-	nolaunch->answer = TRUE;
-    
-    if (nolaunch->answer && !update->answer)
-	update->answer = TRUE;
-    
     gui_type_env = G_getenv_nofatal("GUI");
-
-    if (!type->answer) {
-	if (gui_type_env && strcmp(gui_type_env, "text")) {
-	    type->answer = G_store(gui_type_env);
-	}
-	else {
-	    type->answer = "wxpython";
-	}
+    G_debug(1, "GUI: %s", gui_type_env ? gui_type_env : "unset");
+    if (update_ui->answer) {
+        if (!gui_type_env || strcmp(type->answer, gui_type_env)) {
+            G_setenv("GUI", type->answer);
+            G_message(_("<%s> is now the default GUI"), type->answer);
+        }
     }
 
-    if (((gui_type_env && update->answer) &&
-	 strcmp(gui_type_env, type->answer) != 0) || !gui_type_env) {
-	G_setenv("GUI", type->answer);
-	G_message(_("<%s> is now the default GUI"), type->answer);
+    if(strcmp(type->answer, "wxpython") != 0 || nolaunch->answer) {
+        if (!update_ui->answer)
+            G_warning(_("Nothing to do. For setting up <%s> as default UI use -%c flag."),
+                      type->answer, update_ui->key);
+	exit(EXIT_SUCCESS);
     }
-    else {
-	if(update->answer)
-	    if(gui_type_env) {
-		G_debug(1, "No change: old gui_type_env=[%s], new type->ans=[%s]",
-			gui_type_env, type->answer);
-	    }
-    }
 
-    if(nolaunch->answer)
-	exit(EXIT_SUCCESS);
-
-
     G_message(_("Launching <%s> GUI in the background, please wait..."), type->answer);
-
-    if (strcmp(type->answer, "wxpython") == 0) {
-	sprintf(progname, "%s/gui/wxpython/wxgui.py", G_gisbase());
-	if (rc_file->answer) {
-	    G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-		    "--workspace", rc_file->answer, SF_BACKGROUND, NULL);
-	}
-	else {
-	    G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
-		    SF_BACKGROUND, NULL);
-	}
+    sprintf(progname, "%s/gui/wxpython/wxgui.py", G_gisbase());
+    if (rc_file->answer) {
+        G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
+                   "--workspace", rc_file->answer, SF_BACKGROUND, NULL);
     }
-
+    else {
+        G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname,
+                   SF_BACKGROUND, NULL);
+    }
+    
     /* stop the impatient from starting it again
-        before the splash screen comes up */
+       before the splash screen comes up */
     G_sleep(3);
 
     exit(EXIT_SUCCESS);



More information about the grass-commit mailing list