[PD-cvs] SF.net SVN: pure-data:[10614] branches/pd-devel/0.41.4/src

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Sat Jan 24 06:50:17 CET 2009


Revision: 10614
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10614&view=rev
Author:   eighthave
Date:     2009-01-24 05:50:16 +0000 (Sat, 24 Jan 2009)

Log Message:
-----------
- rewrote pdtk_canvas_saveas to fully handle different cases in the file
  extensions, as well as the Max patch format file extensions .pat and .mxt 

- cleaned up pdtk_canvas_sendkey and renamed it pdsend_key to appropriately
  label how it is used.  

Modified Paths:
--------------
    branches/pd-devel/0.41.4/src/pd.tk
    branches/pd-devel/0.41.4/src/pd_bindings.tcl
    branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
    branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl

Modified: branches/pd-devel/0.41.4/src/pd.tk
===================================================================
--- branches/pd-devel/0.41.4/src/pd.tk	2009-01-24 05:26:58 UTC (rev 10613)
+++ branches/pd-devel/0.41.4/src/pd.tk	2009-01-24 05:50:16 UTC (rev 10614)
@@ -70,11 +70,14 @@
 #   $canvasitem = 'canvas' item
 #
 #
-## Prefix Names for Procs
+## Prefix Names for procs
 #----------------------------
 # pdtk      called from 'pd'
+# pdsend    sends a message to 'pd' using pdsend
 # canvas    manipulates a canvas
+# text      manipulates a Tk 'text' widget
 
+
 # ------------------------------------------------------------------------------
 # quoting functions
 
@@ -105,14 +108,16 @@
 			# set file types that open/save recognize
 			set ::filetypes {
 				{{pd files}         {.pd}  }
-				{{max text files}   {.pat} }
+				{{max patch files}  {.pat} }
+				{{max text files}   {.mxt} }
 			}
 		}
 		"aqua" {
 			# set file types that open/save recognize
 			set ::filetypes {
 				{{Pd Files}               {.pd}  }
-				{{Max Text Files (.pat)}  {.pat} }
+				{{Max Patch Files (.pat)} {.pat} }
+				{{Max Text Files (.mxt)}  {.mxt} }
 			}
 		}
 		"win32" {
@@ -120,7 +125,8 @@
 			# set file types that open/save recognize
 			set ::filetypes {
 				{{Pd Files}         {.pd}  }
-				{{Max Text Files}   {.pat} }
+				{{Max Patch Files}  {.pat} }
+				{{Max Text Files}   {.mxt} }
 			}
 		}
 	}
@@ -150,6 +156,11 @@
 	}
 }
 
+proc pdtk_undomenu {args} {
+	# TODO
+	puts "pdtk_undomenu $args"
+}
+
 # TODO it probably makes sense to add a new function for for "Save, Discard,
 # Cancel" dialogs using tk_dialog
 proc pdtk_check_modified {message reply_to_pd default} {
@@ -187,8 +198,9 @@
 
 	# TODO move this to its own proc for clarity
 	wm title . "Pd-devel"
+	wm geometry . +500+50
 	frame .placeholder
-	label .placeholder.label -text "Pd window placeholder" -width 80 -height 15
+	label .placeholder.label -text "Pd window placeholder" -width 50 -height 15
 	pack .placeholder.label .placeholder -side top -expand yes -fill both
 
 	if { $argc == 1 && [string is int [lindex $argv 0]]} {

Modified: branches/pd-devel/0.41.4/src/pd_bindings.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_bindings.tcl	2009-01-24 05:26:58 UTC (rev 10613)
+++ branches/pd-devel/0.41.4/src/pd_bindings.tcl	2009-01-24 05:50:16 UTC (rev 10614)
@@ -120,9 +120,9 @@
 		bind $mytoplevel <$modifier-Key-t>    "menu_texteditor"
 	}
 
-    bind $mycanvas <Key>        "pdtk_canvas_sendkey %W 1 %K %A 0"
-    bind $mycanvas <Shift-Key>  "pdtk_canvas_sendkey %W 1 %K %A 1"
-    bind $mycanvas <KeyRelease> "pdtk_canvas_sendkey %W 0 %K %A 0"
+    bind $mycanvas <Key>        "pdsend_key %W 1 %K %A 0"
+    bind $mycanvas <Shift-Key>  "pdsend_key %W 1 %K %A 1"
+    bind $mycanvas <KeyRelease> "pdsend_key %W 0 %K %A 0"
 
 	# mouse bindings -----------------------------------------------------------
 	# these need to be bound to $mytoplevel.c because %W will return $mytoplevel for

Modified: branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-24 05:26:58 UTC (rev 10613)
+++ branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-24 05:50:16 UTC (rev 10614)
@@ -43,7 +43,27 @@
 	focus $mycanvas
 }
 
-proc pdtk_canvas_saveas {name initfile initdir} {
+proc pdtk_canvas_saveas {name initialfile initialdir} {
+    set filename [tk_getSaveFile -initialfile $initialfile -initialdir $initialdir \
+					  -defaultextension .pd -filetypes $::filetypes]
+    if {$filename eq ""} return; # they clicked cancel
+
+	set extension [file extension $filename]
+	set filename [regsub -- "$extension$" $filename [string tolower $extension]]
+	if { ! [regexp -- "\.(pd|pat|mxt)$" $filename]} {
+		# we need the file extention even on Mac OS X
+		set filename $filename.pd
+	}
+	# test again after downcasing and maybe adding a ".pd" on the end
+	if {[file exists $filename]} {
+		set answer [tk_messageBox -type okcancel -icon question -default cancel\
+						-message "\"$filename\" already exists. Do you want to replace it?"]
+		if {$answer eq "cancel"} return; # they clicked cancel
+	}
+	set dirname [file dirname $filename]
+	set basename [file tail $filename]
+	pdsend "$name savetofile [pdtk_enquote $basename] [pdtk_enquote $dirname] ;"
+	set ::untitled_directory $dirname
 }
 
 #------------------------------------------------------------------------------#
@@ -79,36 +99,6 @@
 }
 
 #------------------------------------------------------------------------------#
-# key usage
-
-proc pdtk_canvas_sendkey {mycanvas state key iso shift} {
-	if {$key == "BackSpace"} {
-		set iso ""
-		set key 8
-	} elseif {$key == "Tab"} {
-       set iso ""
-		set key 9
-	} elseif {$key == "Return"} {
-        set iso ""
-		set key 10
-	} elseif {$key == "Escape"} {
-        set iso ""
-		set key 27
-	} elseif {$key == "Space"} {
-        set iso ""
-		set key 32
-	} elseif {$key == "Delete" || $key == "KP_Delete"} {
-        set iso ""
-		set key 127
-    }
-    if {$iso != ""} {
-        scan $iso %c key
-    }
-	puts "pdtk_canvas_sendkey $key"
-	pdsend "[winfo toplevel $mycanvas] key $state $key $shift ;"
-}
-
-#------------------------------------------------------------------------------#
 # procs for canvas events
 
 # "map" event tells us when the canvas becomes visible (arg is "0") or

Modified: branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl	2009-01-24 05:26:58 UTC (rev 10613)
+++ branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl	2009-01-24 05:50:16 UTC (rev 10614)
@@ -31,6 +31,25 @@
 }
 
 
+#------------------------------------------------------------------------------#
+# key usage
+
+proc pdsend_key {mycanvas state key iso shift} {
+	switch -- $key {
+		"BackSpace" { set iso ""; set key 8	}
+		"Tab"       { set iso ""; set key 9 }
+		"Return"    { set iso ""; set key 10 }
+		"Escape"    { set iso ""; set key 27 }
+		"Space"     { set iso ""; set key 32 }
+		"Delete"    { set iso ""; set key 127 }
+		"KP_Delete" { set iso ""; set key 127 }
+	}
+	if {$iso != ""} {
+		scan $iso %c key
+	}
+	pdsend "[winfo toplevel $mycanvas] key $state $key $shift ;"
+}
+
 #array set cmd_ops {}
 
 # the only arg for pd.tk is the port number to connect to 'pd' on, but this


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list