diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-09-21 05:24:30 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-09-21 05:24:30 +0000 |
commit | 250fd53a1c8c046d9c883fe72e849c1b02adf476 (patch) | |
tree | 8e5a1e37bd56cd2e78ce9ff7b7b4cc4e295f5be7 /new-from-template-plugin.tcl |
at pob's request, here is a 'New from template' pluginHEADsvn2git-rootsvn2git-headscripts/guiplugins/new-from-template-plugin
svn path=/trunk/scripts/guiplugins/new-from-template-plugin/; revision=15325
Diffstat (limited to 'new-from-template-plugin.tcl')
-rw-r--r-- | new-from-template-plugin.tcl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/new-from-template-plugin.tcl b/new-from-template-plugin.tcl new file mode 100644 index 0000000..5d819ef --- /dev/null +++ b/new-from-template-plugin.tcl @@ -0,0 +1,30 @@ + +package require pd_menucommands + +namespace eval new-from-template { + variable template + variable defaultfolder [file join $::env(HOME) Documents] +} + +proc ::new-from-template::paste_template {} { + variable template + variable defaultfolder + + if { ! [file isdirectory $defaultfolder]} {set defaultfolder $::env(HOME)} + pdsend "pd filename [_ "new-from-template"] [enquote_path $defaultfolder]" + foreach line [split [read [open $template r]] "\n"] { + pdsend $line + } + pdsend "#X pop 1" +} + +proc ::new-from-template::create {mymenu} { + variable template + set inserthere [$mymenu index [_ "Open"]] + $mymenu insert $inserthere command -label [_ "New from template"] \ + -command {::new-from-template::paste_template} + set template \ + [file join $::current_plugin_loadpath template.pd] +} + +::new-from-template::create .menubar.file |