]> git.entuzijast.net Git - imunes.git/commitdiff
Initial implementation of a checkbutton menu to choose among currently
authormarko <marko>
Tue, 8 Jan 2008 14:21:00 +0000 (14:21 +0000)
committermarko <marko>
Tue, 8 Jan 2008 14:21:00 +0000 (14:21 +0000)
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:

filemgmt.tcl
imunes.tcl
initgui.tcl

index c34be5a0cab863327f49d0a1f0db298b537d37a3..03e8566d050bae1a6741a7f976901661535c1923 100755 (executable)
@@ -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
     }
index ddf1fd90648ba94d741f4e085f35cd2a6fc38b6d..f86e900a1525c0bee31c0ac7ccbf1399b6bee7d9 100755 (executable)
@@ -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 {
index 28c5fe6f5f29d57d6d70fad069933db752afe3ac..a11adea395378cb93ff6e5205ad13b30f474e043 100755 (executable)
@@ -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 . <Control-s> "fileSaveDialogBox"
 
 .menubar.file add separator
 .menubar.file add command -label Quit -underline 0 -command { exit }
+.menubar.file add separator
 
 
 #