Changeset 39350


Ignore:
Timestamp:
Sep 30, 2009, 3:57:05 AM (15 years ago)
Author:
marisn
Message:

Close gis.m on exit; Provide exit from GRASS in gis.m

Location:
grass/branches/develbranch_6
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • grass/branches/develbranch_6/gui/tcltk/gis.m/gm.tcl

    r38296 r39350  
    514514};
    515515
     516# Provides remote exit call. Used by GRASS exit to close all session's gis.m instances.
     517# Argument session_id is exit caller's GIS_LOCK variable.
     518proc Gm::remoteExit { session_id } {
     519        global env
     520        if {$env(GIS_LOCK) == $session_id} Gm::quit
     521}
     522
     523# Provides exit from gis.m. May also do some clean-up, save-settings et.al.
     524proc Gm::quit { {full_exit false} } {
     525        global env
     526       
     527        if { $full_exit } {
     528                if { [catch {set spid $env(GRASS_SHELL_PID)}] == 0 } {
     529                        set leave [tk_dialog .leave [G_msg "End current GRASS session"] \
     530                        [G_msg "Do You really want to terminate current\
     531GRASS session?\n\nThis action will colse all sessions gis.m instances.\n\nIf You have running some \
     532GRASS module from comandline, GRASS will terminate after it\
     533finishes to run."] warning 1 [G_msg "Terminate current GRASS sesion"] [G_msg "Cancel"]]
     534                        if { $leave == 0 } {
     535                                exec kill -SIGINT $env(GRASS_SHELL_PID)
     536                        } else {
     537                                return
     538                        }
     539                } else {
     540                        tk_messageBox -type ok -title [G_msg "Not supported"] -message \
     541                        [G_msg "We sorry. Your shell does not support this feature. \n\
     542You have to type 'exit' in terminal manualy."]
     543                }
     544        }
     545
     546        exit
     547}
     548
    516549###############################################################################
    517550
     
    539572    }
    540573    bind . <$keycontrol-Key-q> {
    541                 exit
     574                Gm::quit
    542575        }
    543576    bind . <$keycontrol-Key-w> {
     
    563596}
    564597
     598wm protocol . WM_DELETE_WINDOW {
     599        Gm::quit
     600}
    565601
    566602main $argc $argv
  • grass/branches/develbranch_6/gui/tcltk/gis.m/gmmenu.tcl

    r38427 r39350  
    202202        {command {[G_msg "PostScript plot"]} {} "ps.map: Create cartographic PostScript plot" {} -command { execute ps.map }}
    203203        {separator}
    204         {command {[G_msg "E&xit"]} {} "Exit GIS Manager" {} -accelerator $keyctrl-Q -command { exit } }
     204        {command {[G_msg "Exit &GRASS"]} {} "End current GRASS session" {} -command { Gm::quit true } }
     205        {command {[G_msg "&Quit GIS Manager"]} {} "Exit GIS Manager" {} -accelerator $keyctrl-Q -command { Gm::quit } }
    205206 }
    206207 {[G_msg "&Config"]} all options $tmenu {
  • grass/branches/develbranch_6/lib/init/grass.src

    r39326 r39350  
    4141        else
    4242                # Returning user may have preffered GRASS terminal application
    43                 GRASS_XTERM=`awk '/GRASS_XTERM/ {print $2}' "$GISRCRC"  2>/dev/null`
     43                if [ -z "$GRASS_XTERM" ]; then
     44                        GRASS_XTERM=`awk '/GRASS_XTERM/ {print $2}' "$GISRCRC"  2>/dev/null`
     45                fi;
    4446                if [ -n "$GRASS_XTERM" ]; then
    4547                        # User has preffered GRASS terminal app
  • grass/branches/develbranch_6/lib/init/init.sh

    r39278 r39350  
    818818    # Check for tcltk interface
    819819    tcltk | gis.m)
    820         "$GISBASE/scripts/gis.m"
     820        if [ $sh -ne bash ] || [ $sh -ne msh ] || [ $sh -ne cygwin ]; then
     821                # trap is not supported by csh/tcsh and rc
     822                "$GISBASE/scripts/gis.m"
     823        fi;
    821824        ;;
    822825    oldtcltk | d.m)
     
    967970    echo "export PATH=\"$PATH\"" >> "$bashrc"
    968971    echo "export HOME=\"$USERHOME\"" >> "$bashrc" # restore user home path
     972    echo 'export GRASS_SHELL_PID=$$' >> "$bashrc" # can be used to terminate GRASS session from GUI
     973    if [ "$GRASS_GUI" == tcltk ] || [ "$GRASS_GUI" == gis.m ]; then
     974        echo '$GISBASE/scripts/gis.m' >> "$bashrc" # Start gis.m
     975    fi;
     976    echo 'trap "echo \"GUI issued an exit\"; exit" SIGINT' >> "$bashrc"
    969977
    970978    "$ETC/run" "$SHELL"
     
    10131021done
    10141022
     1023# Attempt to close any open gis.m instances.
     1024# Will work only on some systems, still has no harm to others
     1025if [ $TCLTKGRASSBASE ] ; then
     1026        echo "Closing open gis.m sessions....."
     1027        echo 'foreach gwin [lsearch -all -inline [winfo interps] gm_tcl*] {
     1028                catch {send -async $gwin Gm::remoteExit $env(GIS_LOCK)}
     1029        }
     1030        exit' | $GRASS_WISH >/dev/null 2>&1
     1031fi
     1032
    10151033echo "Cleaning up temporary files ..."
    10161034
Note: See TracChangeset for help on using the changeset viewer.