allow executing XML files from GUI via File > Execute XML or Python script...
adopt filename when connecting to running session having a filename (Boeing r1793)
This commit is contained in:
parent
1e8abc4c1e
commit
acf2430dbd
4 changed files with 22 additions and 7 deletions
|
@ -998,6 +998,7 @@ proc parseRegMessage { data len flags channel } {
|
||||||
set current 0
|
set current 0
|
||||||
set str 0
|
set str 0
|
||||||
set session ""
|
set session ""
|
||||||
|
set fnhint ""
|
||||||
|
|
||||||
set plugin_cap_list {} ;# plugin capabilities list
|
set plugin_cap_list {} ;# plugin capabilities list
|
||||||
|
|
||||||
|
@ -1034,6 +1035,7 @@ proc parseRegMessage { data len flags channel } {
|
||||||
set session $str
|
set session $str
|
||||||
} else {
|
} else {
|
||||||
lappend plugin_cap_list "$plugin_type=$str"
|
lappend plugin_cap_list "$plugin_type=$str"
|
||||||
|
if { $plugin_type == "exec" } { set fnhint $str }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if { $prmsg == 1} { puts -nonewline "unknown($type)," }
|
if { $prmsg == 1} { puts -nonewline "unknown($type)," }
|
||||||
|
@ -1047,10 +1049,10 @@ proc parseRegMessage { data len flags channel } {
|
||||||
if { $prmsg == 1 } { puts ") "}
|
if { $prmsg == 1 } { puts ") "}
|
||||||
|
|
||||||
# reg message with session number indicates the sid of a session that
|
# reg message with session number indicates the sid of a session that
|
||||||
# was just started from a Python script (via reg exec=scriptfile.py)
|
# was just started from XML or Python script (via reg exec=scriptfile.py)
|
||||||
if { $session != "" } {
|
if { $session != "" } {
|
||||||
# assume session string only contains one session number
|
# assume session string only contains one session number
|
||||||
connectShutdownSession connect $channel $session
|
connectShutdownSession connect $channel $session $fnhint
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,8 @@ bind . <Control-s> "fileSaveDialogBox {}"
|
||||||
|
|
||||||
.menubar.file add separator
|
.menubar.file add separator
|
||||||
.menubar.file add command -label "Export Python script..." -command exportPython
|
.menubar.file add command -label "Export Python script..." -command exportPython
|
||||||
.menubar.file add command -label "Execute Python script..." -command execPython
|
.menubar.file add command -label "Execute XML or Python script..." \
|
||||||
|
-command execPython
|
||||||
|
|
||||||
.menubar.file add separator
|
.menubar.file add separator
|
||||||
.menubar.file add command -label "Open current file in editor..." \
|
.menubar.file add command -label "Open current file in editor..." \
|
||||||
|
|
|
@ -989,9 +989,11 @@ proc sessionConfig { cmd wi channel } {
|
||||||
|
|
||||||
# sid = 0 is new session, or the session number of an existing session
|
# sid = 0 is new session, or the session number of an existing session
|
||||||
set sid 0
|
set sid 0
|
||||||
|
set fn ""
|
||||||
foreach item [$wi.tree selection] {
|
foreach item [$wi.tree selection] {
|
||||||
array set vals [$wi.tree set $item]
|
array set vals [$wi.tree set $item]
|
||||||
set sid $vals(sid)
|
set sid $vals(sid)
|
||||||
|
set fn $vals(fn)
|
||||||
break; # TODO: loop on multiple selection for shutdown
|
break; # TODO: loop on multiple selection for shutdown
|
||||||
}
|
}
|
||||||
if { $sid == $g_current_session } {
|
if { $sid == $g_current_session } {
|
||||||
|
@ -1001,14 +1003,14 @@ proc sessionConfig { cmd wi channel } {
|
||||||
set cmd "connect"
|
set cmd "connect"
|
||||||
set sid 0
|
set sid 0
|
||||||
}
|
}
|
||||||
connectShutdownSession $cmd $channel $sid
|
connectShutdownSession $cmd $channel $sid $fn
|
||||||
}
|
}
|
||||||
|
|
||||||
# switch sessions or shutdown the specified session
|
# switch sessions or shutdown the specified session
|
||||||
# sid=0 indicates switching to a new session (disconnect from old and start a
|
# sid=0 indicates switching to a new session (disconnect from old and start a
|
||||||
# new file)
|
# new file)
|
||||||
proc connectShutdownSession { cmd channel sid } {
|
proc connectShutdownSession { cmd channel sid fn } {
|
||||||
global g_current_session CORE_USER
|
global g_current_session CORE_USER currentFile
|
||||||
|
|
||||||
switch -exact -- $cmd {
|
switch -exact -- $cmd {
|
||||||
connect {
|
connect {
|
||||||
|
@ -1020,6 +1022,7 @@ proc connectShutdownSession { cmd channel sid } {
|
||||||
set g_current_session $sid
|
set g_current_session $sid
|
||||||
}
|
}
|
||||||
# connect to an existing session
|
# connect to an existing session
|
||||||
|
set currentFile $fn
|
||||||
setOperMode exec
|
setOperMode exec
|
||||||
set flags 0x11 ;# add flag, status req flag
|
set flags 0x11 ;# add flag, status req flag
|
||||||
}
|
}
|
||||||
|
|
11
gui/util.tcl
11
gui/util.tcl
|
@ -982,7 +982,16 @@ proc exportPython { } {
|
||||||
|
|
||||||
# ask the daemon to execute the selected file
|
# ask the daemon to execute the selected file
|
||||||
proc execPython { } {
|
proc execPython { } {
|
||||||
set fn [tk_getOpenFile -filetypes {{ "CORE Python scripts" {.py} }} ]
|
global fileDialogBox_initial g_prefs
|
||||||
|
set ft {{ "CORE XML or Python scripts" {.py .xml} } { "All files" {*}}}
|
||||||
|
|
||||||
|
if { $fileDialogBox_initial == 0 } {
|
||||||
|
set fileDialogBox_initial 1
|
||||||
|
set dir $g_prefs(default_conf_path)
|
||||||
|
set fn [tk_getOpenFile -filetypes $ft -initialdir $dir]
|
||||||
|
} else {
|
||||||
|
set fn [tk_getOpenFile -filetypes $ft]
|
||||||
|
}
|
||||||
if { $fn == "" } { return }
|
if { $fn == "" } { return }
|
||||||
set flags 0x10 ;# status request flag
|
set flags 0x10 ;# status request flag
|
||||||
sendRegMessage -1 $flags [list "exec" $fn]
|
sendRegMessage -1 $flags [list "exec" $fn]
|
||||||
|
|
Loading…
Reference in a new issue