From: marko Date: Tue, 8 Jan 2008 14:21:00 +0000 (+0000) Subject: Initial implementation of a checkbutton menu to choose among currently X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=62638502401abf86e0bec45d792db39afc495f41;p=imunes.git Initial implementation of a checkbutton menu to choose among currently open projects. Selecting a desired project at the bottom of the File menu switches to that particular project. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- diff --git a/filemgmt.tcl b/filemgmt.tcl index c34be5a..03e8566 100755 --- a/filemgmt.tcl +++ b/filemgmt.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: filemgmt.tcl,v 1.17 2008/01/08 12:35:30 marko Exp $ +# $Id: filemgmt.tcl,v 1.18 2008/01/08 14:21:00 marko Exp $ ##****h* imunes/filemgmt.tcl @@ -79,7 +79,7 @@ set fileTypes { proc newProject {} { - global curcfg cfg_list sizex sizey + global curcfg cfg_list set curcfg [newObjectId cfg] lappend cfg_list $curcfg @@ -104,11 +104,34 @@ proc newProject {} { set canvas_list {} newCanvas "" set curcanvas [lindex $canvas_list 0] - set sizex [lindex [getCanvasSize $curcanvas] 0] - set sizey [lindex [getCanvasSize $curcanvas] 1] + set currentFile "" + updateProjectMenu + switchProject +} + + +proc updateProjectMenu {} { + global curcfg cfg_list + + .menubar.file delete 8 end + .menubar.file add separator + + foreach cfg $cfg_list { + set fname [set ::cf::[set cfg]::currentFile] + if { $fname == "" } { + set fname "untitled[string range $cfg 1 end]" + } + .menubar.file add checkbutton -label $fname -variable curcfg \ + -onvalue $cfg -command switchProject + } +} + + +proc switchProject {} { + upvar 0 ::cf::[set ::curcfg]::currentFile currentFile + switchCanvas none redrawAll - set currentFile "" setWmTitle $currentFile } @@ -117,10 +140,9 @@ proc setWmTitle { fname } { global curcfg if { $fname == "" } { - wm title . "IMUNES - untitled[string range $curcfg 1 end]" - } else { - wm title . "IMUNES - $fname" + set fname "untitled[string range $curcfg 1 end]" } + wm title . "IMUNES - $fname" } @@ -156,7 +178,7 @@ proc openFile {} { set redolevel 0 set undolog(0) $cfg set activetool select - setWmTitle $fileName + updateProjectMenu } @@ -181,7 +203,7 @@ proc saveFile { selectedFile } { dumpCfg file $fileId close $fileId .bottom.textbox config -text "Saved $fileName" - setWmTitle $fileName + updateProjectMenu } } @@ -195,11 +217,12 @@ proc saveFile { selectedFile } { # Opens a open file dialog box. #**** proc fileOpenDialogBox {} { - upvar 0 ::cf::[set ::curcfg]::currentFile currentFile global fileTypes set selectedFile [tk_getOpenFile -filetypes $fileTypes] if { $selectedFile != ""} { + newProject + upvar 0 ::cf::[set ::curcfg]::currentFile currentFile set currentFile $selectedFile openFile } diff --git a/imunes.tcl b/imunes.tcl index ddf1fd9..f86e900 100755 --- a/imunes.tcl +++ b/imunes.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: imunes.tcl,v 1.35 2008/01/08 12:35:30 marko Exp $ +# $Id: imunes.tcl,v 1.36 2008/01/08 14:21:00 marko Exp $ #****h* imunes/imunes.tcl @@ -250,6 +250,7 @@ if {$execMode == "interactive"} { set ::cf::[set curcfg]::currentFile $argv openFile } + updateProjectMenu # Fire up the animation loop animate } else { diff --git a/initgui.tcl b/initgui.tcl index 28c5fe6..a11adea 100755 --- a/initgui.tcl +++ b/initgui.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: initgui.tcl,v 1.46 2008/01/08 12:35:30 marko Exp $ +# $Id: initgui.tcl,v 1.47 2008/01/08 14:21:00 marko Exp $ #****h* imunes/initgui.tcl @@ -208,6 +208,7 @@ bind . "fileSaveDialogBox" .menubar.file add separator .menubar.file add command -label Quit -underline 0 -command { exit } +.menubar.file add separator #