gui: Pass a filename to openFile as an argument rather than using the
currentFile global variable.
This commit is contained in:
parent
104e68a712
commit
51aba4b82c
2 changed files with 12 additions and 15 deletions
|
@ -52,8 +52,8 @@
|
||||||
# newFile
|
# newFile
|
||||||
# - creates an empty project
|
# - creates an empty project
|
||||||
#
|
#
|
||||||
# openFile
|
# openFile {filename}
|
||||||
# - loads configuration from currentFile
|
# - loads configuration from filename
|
||||||
#
|
#
|
||||||
# saveFile {selectedFile}
|
# saveFile {selectedFile}
|
||||||
# - saves current configuration to a file named selectedFile
|
# - saves current configuration to a file named selectedFile
|
||||||
|
@ -138,11 +138,11 @@ proc newFile {} {
|
||||||
# NAME
|
# NAME
|
||||||
# openFile -- open file
|
# openFile -- open file
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
# openFile
|
# openFile $filename
|
||||||
# FUNCTION
|
# 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 currentFile
|
||||||
global undolog activetool
|
global undolog activetool
|
||||||
global canvas_list curcanvas systype
|
global canvas_list curcanvas systype
|
||||||
|
@ -152,6 +152,8 @@ proc openFile {} {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set currentFile $filename
|
||||||
|
|
||||||
if { [lindex [file extension $currentFile] 0] == ".py" } {
|
if { [lindex [file extension $currentFile] 0] == ".py" } {
|
||||||
set flags 0x10 ;# status request flag
|
set flags 0x10 ;# status request flag
|
||||||
sendRegMessage -1 $flags [list "exec" $currentFile]
|
sendRegMessage -1 $flags [list "exec" $currentFile]
|
||||||
|
@ -261,13 +263,11 @@ proc saveFile { selectedFile } {
|
||||||
#****
|
#****
|
||||||
proc fileOpenStartUp {} {
|
proc fileOpenStartUp {} {
|
||||||
global argv
|
global argv
|
||||||
global currentFile
|
|
||||||
|
|
||||||
# Boeing
|
# Boeing
|
||||||
foreach arg $argv {
|
foreach arg $argv {
|
||||||
if { $arg != "" && $arg != "--start" && $arg != "--batch" } {
|
if { $arg != "" && $arg != "--start" && $arg != "--batch" } {
|
||||||
set currentFile [argAbsPathname $arg]
|
openFile [argAbsPathname $arg]
|
||||||
openFile
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ proc fileNewDialogBox {} {
|
||||||
#****
|
#****
|
||||||
set fileDialogBox_initial 0; # static flag
|
set fileDialogBox_initial 0; # static flag
|
||||||
proc fileOpenDialogBox {} {
|
proc fileOpenDialogBox {} {
|
||||||
global currentFile fileTypes g_prefs fileDialogBox_initial
|
global fileTypes g_prefs fileDialogBox_initial
|
||||||
|
|
||||||
# use default conf file path upon first run
|
# use default conf file path upon first run
|
||||||
if { $fileDialogBox_initial == 0} {
|
if { $fileDialogBox_initial == 0} {
|
||||||
|
@ -322,8 +322,7 @@ proc fileOpenDialogBox {} {
|
||||||
set selectedFile [tk_getOpenFile -filetypes $fileTypes]
|
set selectedFile [tk_getOpenFile -filetypes $fileTypes]
|
||||||
}
|
}
|
||||||
if { $selectedFile != ""} {
|
if { $selectedFile != ""} {
|
||||||
set currentFile $selectedFile
|
openFile $selectedFile
|
||||||
openFile
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,9 +469,7 @@ proc savePrefsFile { } {
|
||||||
|
|
||||||
# helper for most-recently-used file list menu items
|
# helper for most-recently-used file list menu items
|
||||||
proc mrufile { f args } {
|
proc mrufile { f args } {
|
||||||
global currentFile
|
openFile [string trim "$f $args"]
|
||||||
set currentFile [string trim "$f $args"]
|
|
||||||
openFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# add filename to the most-recently-used file list
|
# add filename to the most-recently-used file list
|
||||||
|
|
|
@ -229,7 +229,7 @@ bind . <Control-n> "fileNewDialogBox"
|
||||||
bind . <Control-o> "fileOpenDialogBox"
|
bind . <Control-o> "fileOpenDialogBox"
|
||||||
|
|
||||||
.menubar.file add command -label "Reload" -underline 0 \
|
.menubar.file add command -label "Reload" -underline 0 \
|
||||||
-command { openFile }
|
-command { openFile $currentFile }
|
||||||
|
|
||||||
.menubar.file add command -label Save -underline 0 \
|
.menubar.file add command -label Save -underline 0 \
|
||||||
-accelerator "Ctrl+S" -command { fileSaveDialogBox "" }
|
-accelerator "Ctrl+S" -command { fileSaveDialogBox "" }
|
||||||
|
|
Loading…
Reference in a new issue