From 51aba4b82c68e06076af8ec57406ae4693cb48e3 Mon Sep 17 00:00:00 2001 From: tgoff0 Date: Mon, 15 Dec 2014 18:22:59 +0000 Subject: [PATCH] gui: Pass a filename to openFile as an argument rather than using the currentFile global variable. --- gui/filemgmt.tcl | 25 +++++++++++-------------- gui/initgui.tcl | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/gui/filemgmt.tcl b/gui/filemgmt.tcl index af82a13b..d756c820 100755 --- a/gui/filemgmt.tcl +++ b/gui/filemgmt.tcl @@ -52,8 +52,8 @@ # newFile # - creates an empty project # -# openFile -# - loads configuration from currentFile +# openFile {filename} +# - loads configuration from filename # # saveFile {selectedFile} # - saves current configuration to a file named selectedFile @@ -138,11 +138,11 @@ proc newFile {} { # NAME # openFile -- open file # SYNOPSIS -# openFile +# openFile $filename # FUNCTION -# Loads the configuration from the file named currentFile. +# Loads the configuration from the file named $filename. #**** -proc openFile {} { +proc openFile { filename } { global currentFile global undolog activetool global canvas_list curcanvas systype @@ -152,6 +152,8 @@ proc openFile {} { return } + set currentFile $filename + if { [lindex [file extension $currentFile] 0] == ".py" } { set flags 0x10 ;# status request flag sendRegMessage -1 $flags [list "exec" $currentFile] @@ -261,13 +263,11 @@ proc saveFile { selectedFile } { #**** proc fileOpenStartUp {} { global argv - global currentFile # Boeing foreach arg $argv { if { $arg != "" && $arg != "--start" && $arg != "--batch" } { - set currentFile [argAbsPathname $arg] - openFile + openFile [argAbsPathname $arg] break } } @@ -310,7 +310,7 @@ proc fileNewDialogBox {} { #**** set fileDialogBox_initial 0; # static flag proc fileOpenDialogBox {} { - global currentFile fileTypes g_prefs fileDialogBox_initial + global fileTypes g_prefs fileDialogBox_initial # use default conf file path upon first run if { $fileDialogBox_initial == 0} { @@ -322,8 +322,7 @@ proc fileOpenDialogBox {} { set selectedFile [tk_getOpenFile -filetypes $fileTypes] } if { $selectedFile != ""} { - set currentFile $selectedFile - openFile + openFile $selectedFile } } @@ -470,9 +469,7 @@ proc savePrefsFile { } { # helper for most-recently-used file list menu items proc mrufile { f args } { - global currentFile - set currentFile [string trim "$f $args"] - openFile + openFile [string trim "$f $args"] } # add filename to the most-recently-used file list diff --git a/gui/initgui.tcl b/gui/initgui.tcl index 8eb72e11..ed1a428b 100755 --- a/gui/initgui.tcl +++ b/gui/initgui.tcl @@ -229,7 +229,7 @@ bind . "fileNewDialogBox" bind . "fileOpenDialogBox" .menubar.file add command -label "Reload" -underline 0 \ - -command { openFile } + -command { openFile $currentFile } .menubar.file add command -label Save -underline 0 \ -accelerator "Ctrl+S" -command { fileSaveDialogBox "" }