[GRASS-SVN] r36093 - in grass/branches/releasebranch_6_4: general/g.gui gui/scripts gui/tcltk/d.m gui/tcltk/gis.m gui/wxpython/xml

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 25 07:28:06 EST 2009


Author: hamish
Date: 2009-02-25 07:28:06 -0500 (Wed, 25 Feb 2009)
New Revision: 36093

Added:
   grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.py
   grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.sh
Modified:
   grass/branches/releasebranch_6_4/general/g.gui/main.c
   grass/branches/releasebranch_6_4/gui/tcltk/d.m/menu.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
   grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml
Log:
backport GUI changing tools from devbr6 r35972, r36027, r36030. works from gis.m, untested for wxPy, non-functional from d.m/CLI --ui (??)

Modified: grass/branches/releasebranch_6_4/general/g.gui/main.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.gui/main.c	2009-02-25 11:09:47 UTC (rev 36092)
+++ grass/branches/releasebranch_6_4/general/g.gui/main.c	2009-02-25 12:28:06 UTC (rev 36093)
@@ -25,7 +25,7 @@
 int main(int argc, char *argv[])
 {
     struct Option *type, *rc_file;
-    struct Flag *oneoff;
+    struct Flag *update, *nolaunch;
     struct GModule *module;
     char *gui_type_env;
     char progname[GPATH_MAX];
@@ -44,23 +44,37 @@
     type->description = _("Default value: GRASS_GUI if defined otherwise tcltk");
     type->descriptions = _("tcltk;Tcl/Tk based GUI - GIS Manager (gis.m);"
 			   "oldtcltk;Old Tcl/Tk based GUI - Display Manager (d.m);"
-			   "wxpython;wxPython based next generation GUI");
-    type->options = "tcltk,oldtcltk,wxpython";
+			   "wxpython;wxPython based next generation GUI;"
+			   "text;command line interface only");
+    type->options = "tcltk,oldtcltk,wxpython,text";
 
     rc_file = G_define_standard_option(G_OPT_F_INPUT);
     rc_file->key = "workspace";
     rc_file->required = NO;
     rc_file->description = _("Name of workspace file");
 
-    oneoff = G_define_flag();
-    oneoff->key = 'u';
-    oneoff->description = _("Update default GUI setting");
+    update = G_define_flag();
+    update->key = 'u';
+    update->description = _("Update default GUI setting");
 
+    nolaunch = G_define_flag();
+    nolaunch->key = 'n';
+    nolaunch->description =
+	_("Do not launch GUI after updating the default GUI setting");
+
     if (argc > 1 && 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("GRASS_GUI");
-    
+
     if (!type->answer) {
 	if (gui_type_env && strcmp(gui_type_env, "text")) {
 	    type->answer = G_store(gui_type_env);
@@ -70,13 +84,17 @@
 	}
     }
 
-    if (((gui_type_env && oneoff->answer) &&
+    if (((gui_type_env && update->answer) &&
 	 strcmp(gui_type_env, type->answer) != 0) || !gui_type_env) {
 	G_message(_("<%s> is now the default GUI"), type->answer);
 	G_setenv("GRASS_GUI", type->answer);
 
     }
 
+    if(nolaunch->answer)
+	exit(EXIT_SUCCESS);
+
+
     if (strcmp(type->answer, "oldtcltk") == 0) {
 	sprintf(progname, "%s/etc/dm/d.m.tcl", G_gisbase());
 	if (rc_file->answer) {

Copied: grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.py (from rev 36092, grass/branches/develbranch_6/gui/scripts/g.change.gui.py)
===================================================================
--- grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.py	                        (rev 0)
+++ grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.py	2009-02-25 12:28:06 UTC (rev 36093)
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       g.change.gui
+# AUTHOR(S):    Hamish Bowman
+# PURPOSE:      
+# COPYRIGHT:    (C) 2009 GRASS Development Team
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+############################################################################
+#%Module
+#% description: Changes the default GRASS graphical user interface (GUI) setting.
+#% keywords: general, gui
+#%End
+#%Option
+#% key: gui
+#% type: string
+#% required: yes
+#% multiple: no
+#% options: tcltk,oldtcltk,wxpython,text
+#% label: GUI type
+#% description: Default value: GRASS_GUI if defined otherwise tcltk
+#% descriptions: tcltk;Tcl/Tk based GUI - GIS Manager (gis.m);oldtcltk;Old Tcl/Tk based GUI - Display Manager (d.m);wxpython;wxPython based next generation GUI;text;command line interface only
+#%End
+
+# simple front end to g.gui to be used from within the GUI.
+
+import grass
+import sys
+
+def main():
+    grass.exec_command("g.gui", flags = 'nu', gui = options['gui'])
+    sys.exit(ret)
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    sys.exit(main())

Copied: grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.sh (from rev 36092, grass/branches/develbranch_6/gui/scripts/g.change.gui.sh)
===================================================================
--- grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.sh	                        (rev 0)
+++ grass/branches/releasebranch_6_4/gui/scripts/g.change.gui.sh	2009-02-25 12:28:06 UTC (rev 36093)
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE:       g.change.gui
+# AUTHOR(S):    Hamish Bowman
+# PURPOSE:      
+# COPYRIGHT:    (C) 2009 GRASS Development Team
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+############################################################################
+#%Module
+#% description: Changes the default GRASS graphical user interface (GUI) setting.
+#% keywords: general, gui
+#%End
+#%Option
+#% key: gui
+#% type: string
+#% required: yes
+#% multiple: no
+#% options: tcltk,oldtcltk,wxpython,text
+#% label: GUI type
+#% description: Default value: GRASS_GUI if defined otherwise tcltk
+#% descriptions: tcltk;Tcl/Tk based GUI - GIS Manager (gis.m);oldtcltk;Old Tcl/Tk based GUI - Display Manager (d.m);wxpython;wxPython based next generation GUI;text;command line interface only
+#%End
+
+# simple front end to g.gui to be used from within the GUI.
+
+
+if [ -z "$GISBASE" ] ; then
+    echo "You must be in GRASS GIS to run this program." 1>&2
+    exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+    exec g.parser "$0" "$@"
+fi
+
+g.gui -nu gui="$GIS_OPT_GUI"
+

Modified: grass/branches/releasebranch_6_4/gui/tcltk/d.m/menu.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/d.m/menu.tcl	2009-02-25 11:09:47 UTC (rev 36092)
+++ grass/branches/releasebranch_6_4/gui/tcltk/d.m/menu.tcl	2009-02-25 12:28:06 UTC (rev 36093)
@@ -197,6 +197,7 @@
 		{command {[G_msg "Modify access by other users to current mapset"]} {} "g.access" {} -command {execute g.access }}
 		{command {[G_msg "Show current GRASS environment settings"]} {} "g.gisenv" {} -command {run_panel g.gisenv }}
 		{command {[G_msg "Set GRASS environment settings"]} {} "g.gisenv" {} -command {execute g.gisenv }}
+		{command {[G_msg "Change default GUI"]} {} "g.change.gui" {} -command {execute "$env(GISBASE)/etc/gui/scripts/g.change.gui.sh" }}
 		{command {[G_msg "Show current GRASS version"]} {} "g.version -c" {} -command {run_panel "g.version -c" }}
 	}}
 	{cascad {[G_msg "Manage projections"]} {} "" $tmenu {			

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl	2009-02-25 11:09:47 UTC (rev 36092)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl	2009-02-25 12:28:06 UTC (rev 36093)
@@ -214,6 +214,7 @@
 		{command {[G_msg "User access"]} {} "g.access: Modify access by other users to current mapset" {} -command {execute g.access }}
 		{command {[G_msg "Show settings"]} {} "g.gisenv: Show current GRASS environment settings" {} -command {run_panel g.gisenv }}
 		{command {[G_msg "Change settings"]} {} "g.gisenv: Set GRASS environment settings" {} -command {execute g.gisenv }}
+		{command {[G_msg "Change default GUI"]} {} "g.change.gui: Change the default GUI setting" {} -command {execute "$env(GISBASE)/etc/gui/scripts/g.change.gui.sh" }}
 		{command {[G_msg "Show current GRASS version"]} {} "g.version -c: Show current GRASS version" {} -command {run_panel "g.version -c" }}
 	}}
 	{cascad {[G_msg "Manage projections"]} {} "" $tmenu {

Modified: grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml	2009-02-25 11:09:47 UTC (rev 36092)
+++ grass/branches/releasebranch_6_4/gui/wxpython/xml/menudata.xml	2009-02-25 12:28:06 UTC (rev 36093)
@@ -607,6 +607,12 @@
 	      <command>g.gisenv</command>
 	    </menuitem>
 	    <menuitem>
+	      <label>Change default GUI</label>
+	      <help>Changes the default GRASS graphical user interface (GUI) setting.</help>
+	      <handler>self.OnMenuCmd</handler>
+	      <command>g.change.gui.py</command>
+	    </menuitem>
+	    <menuitem>
 	      <label>Version</label>
 	      <help>Displays version and copyright information.</help>
 	      <handler>self.RunMenuCmd</handler>



More information about the grass-commit mailing list