aboutsummaryrefslogtreecommitdiff
path: root/packages/darwin_app
diff options
context:
space:
mode:
authorN.N. <g_roma@users.sourceforge.net>2004-08-31 22:11:49 +0000
committerN.N. <g_roma@users.sourceforge.net>2004-08-31 22:11:49 +0000
commitd516fa59986400af12882f7e6406df60ce201005 (patch)
tree27cec8f19e857d78b40edabbb46d7830d35d3a7a /packages/darwin_app
parentf44fcf8d3333336fe61dcb6f5305165a710720b0 (diff)
macosx style app
svn path=/trunk/; revision=1987
Diffstat (limited to 'packages/darwin_app')
-rw-r--r--packages/darwin_app/AppMain.tcl93
-rwxr-xr-xpackages/darwin_app/mkdocs34
2 files changed, 111 insertions, 16 deletions
diff --git a/packages/darwin_app/AppMain.tcl b/packages/darwin_app/AppMain.tcl
index fc4347a6..b4bbac17 100644
--- a/packages/darwin_app/AppMain.tcl
+++ b/packages/darwin_app/AppMain.tcl
@@ -1,30 +1,91 @@
-# from http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2115298
-# tk::mac::OpenDocument is called when docs are dropped
-# on the Dock icon with the filenames put into the var args
-proc tk::mac::OpenDocument {args} {
- foreach file $args {
- puts $file
- }
+proc log {message} {
+ exec sh -c "/bin/echo $message" >/dev/stderr
+}
+
+proc alert {message} {
+ tk_messageBox -message $message -type ok -icon question
}
proc default_keybindings {} {
- return { exit CMD-q }
+ return { exit CMD-q }
}
-#console show
+proc checkPort { port } {
+ if {
+ [catch {set result [exec sh -c "/usr/sbin/netstat -an |grep $port"] } errn] } {
+ # the command returns no result, so the port is not used
+ return true
+ } else {
+ return false
+ }
+}
+
+proc waitForPort { port } {
+ for {set x 0} {$x<30} {incr x} {
+ after 100
+ if {![checkPort $port]} {
+ return true
+ }
+ }
+ return false
+}
+
+
+
+proc loadpdtcl { } {
+ global pd_guidir
+ # wait for pd to start
+ if {[waitForPort 5400]} {
+ if {
+ [catch {load $pd_guidir/bin/pdtcl } errmsg] } {
+ alert "can't connect to pd : $errmsg"
+ exit(1)
+ }
+ } else {
+ alert "Couldn't start Pd"
+ }
+}
+
+
+
+##### startup ##################################################################
+
+global pd_guidir
+global pd_port
# get the path to the Wish Shell so a relative path can be
# used to launch Pd
-regsub -- "Wish Shell" [info nameofexecutable] "" wish_path
-exec open $wish_path/../Resources/Pd.term
+regsub -- "Pd" [info nameofexecutable] "" wish_path
+puts "$wish_path/../Resources/lib/pd/bin/pd.tk"
+
+# set paths
+set pd_guidir [file join [file dirname [file dirname [info script]]] lib pd]
+set pd_exec_path [file join [file dirname [file dirname [info script]]] bin]
+
+# launch pd -a dummy guicmd prevents starting the wish shell
+if {[checkPort 5400]} {
+ exec sh -c "cd $pd_exec_path;./pd -guicmd /bin/echo" >&/dev/stderr &
+} else {
+ alert "Can't start pd because the port 5400 is in use"
+ exit(1)
+}
-puts "wish_path $wish_path"
-#if {[string first "-psn" [lindex $argv 0]] == 0} {
-# set argv [lrange $argv 1 end]
-#}
+# open gui
+source [file join $pd_guidir bin pd.tk]
+################################################################################
-exit
+
+# depends on pd.tk
+# tk::mac::OpenDocument is called when docs are dropped
+# on the Dock icon with the filenames put into the var args
+proc tk::mac::OpenDocument {args} {
+ foreach file $args {
+ pd [concat pd open [pdtk_enquote [file tail $file]] \
+ [pdtk_enquote [file dirname $file]] \;]
+ menu_doc_open [file dirname $file] [file tail $file]
+ }
+}
diff --git a/packages/darwin_app/mkdocs b/packages/darwin_app/mkdocs
new file mode 100755
index 00000000..111b0a36
--- /dev/null
+++ b/packages/darwin_app/mkdocs
@@ -0,0 +1,34 @@
+#!/bin/bash
+dir=`basename "$1"`
+y=0
+count=0
+
+echo "#N canvas 200 22 300 500 10;"
+
+for eachitem in $1/*.pd
+do
+ let count=$count+1
+done
+
+let y=$count*25+50
+
+echo "#N canvas 0 22 454 304 opendoc 0;"
+echo "#X obj 35 66 symbol;"
+echo "#X obj 34 38 inlet;"
+echo "#X msg 35 90 \; pd open \\\$1 ../lib/pd/doc/$dir/ \;;"
+echo "#X connect 0 0 2 0;"
+echo "#X connect 1 0 0 0;"
+echo "#X restore 50 $y pd opendoc;"
+
+count=0
+
+for eachitem in $1/*.pd
+do
+ name=`basename $eachitem`
+ let y=25+$count*25
+ msg="#X msg 50 $y $name;"
+ let count=$count+1
+ con="#X connect $count 0 0 0;"
+ echo $msg
+ echo $con
+done