summaryrefslogtreecommitdiffstats
path: root/library/tkdnd_unix.tcl
diff options
context:
space:
mode:
authorpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2011-01-14 22:05:38 (GMT)
committerpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2011-01-14 22:05:38 (GMT)
commit0537dcf41109ab0d500a9a958264e067e6339dc0 (patch)
treeb77ce4766a89d9f258ad52830e410ed123fc350d /library/tkdnd_unix.tcl
parent32c07a4b48e1b227b6727f7ab6b7e5ddd40d3a64 (diff)
downloadtkdnd-0537dcf41109ab0d500a9a958264e067e6339dc0.zip
tkdnd-0537dcf41109ab0d500a9a958264e067e6339dc0.tar.gz
tkdnd-0537dcf41109ab0d500a9a958264e067e6339dc0.tar.bz2
XDND fixes for TIP 370
Diffstat (limited to 'library/tkdnd_unix.tcl')
-rw-r--r--library/tkdnd_unix.tcl33
1 files changed, 31 insertions, 2 deletions
diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl
index 386dab7..2535245 100644
--- a/library/tkdnd_unix.tcl
+++ b/library/tkdnd_unix.tcl
@@ -311,9 +311,11 @@ proc xdnd::_GetDroppedData { time } {
# puts "TYPE: $type ($_drop_target)"
# _get_selection $_drop_target $time $type
if {![catch {
+ # selection get -displayof $_drop_target -selection XdndSelection \
+ # -type $type -time $time} result options]} {
selection get -displayof $_drop_target -selection XdndSelection \
-type $type} result options]} {
- return $result
+ return [_normalise_data $type $result]
}
}
return -options $options $result
@@ -364,8 +366,35 @@ proc xdnd::_platform_specific_types { types } {
# Command xdnd::_normalise_data
# ----------------------------------------------------------------------------
proc xdnd::_normalise_data { type data } {
+ # Tk knows how to interpret the following types:
+ # STRING, TEXT, COMPOUND_TEXT
+ # UTF8_STRING
+ # Else, it returns a list of 8 or 32 bit numbers...
switch $type {
- CF_HDROP {return [encoding convertfrom $data]}
+ STRING - UTF8_STRING - TEXT - COMPOUND_TEXT {return $data}
+ text/html -
+ text/plain {
+ return [encoding convertfrom utf-8 [tkdnd::bytes_to_string $data]]
+ }
+ text/uri-list {
+ set string [tkdnd::bytes_to_string $data]
+ ## Get rid of \r\n
+ set string [string map {\r\n \n} $string]
+ set files {}
+ foreach quoted_file [split $string] {
+ set file [encoding convertfrom utf-8 [tkdnd::urn_unquote $quoted_file]]
+ switch -glob $file {
+ file://* {lappend files [string range $file 7 end]}
+ ftp://* -
+ https://* -
+ http://* {lappend files $quoted_file}
+ default {lappend files $file}
+ }
+ }
+ return $files
+ }
+ text/x-moz-url -
+ application/q-iconlist -
default {return $data}
}
}; # xdnd::_normalise_data