From 250fd53a1c8c046d9c883fe72e849c1b02adf476 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 21 Sep 2011 05:24:30 +0000 Subject: at pob's request, here is a 'New from template' plugin svn path=/trunk/scripts/guiplugins/new-from-template-plugin/; revision=15325 --- new-from-template-plugin.tcl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 new-from-template-plugin.tcl (limited to 'new-from-template-plugin.tcl') 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 -- cgit v1.2.1