Skip to content

Commit

Permalink
(optional) drag'n'drop deken files onto the result-panel to install them
Browse files Browse the repository at this point in the history
Closes: #225
  • Loading branch information
umlaeute committed Feb 25, 2021
1 parent da6f739 commit 2c073f6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions deken-plugin.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,31 @@ proc ::deken::utilities::verbose {level message} {
::pdwindow::verbose ${level} "\[deken\]: ${message}\n"
}

if { [catch {package require tkdnd} ] } {
proc :: deken::utilities::dnd_init {windowid} { }
} {
proc ::deken::utilities::dnd_init {windowid} {
::tkdnd::drop_target register $windowid DND_Files
bind $windowid <<Drop:DND_Files>> {::deken::utilities::dnd_drop_files %D}
}
proc ::deken::utilities::dnd_drop_files {files} {
foreach f $files {
if { [regexp -all -nocase "\.(zip|dek|tgz|tar\.gz)$" ${f} ] } {
set msg [format [_ "installing deken package '%s'" ] $f]
::deken::status ${msg}
::deken::utilities::verbose -1 ${msg}
::deken::install_package_from_file $f
} {
set msg [format [_ "ignoring '%s': doesn't look like a deken package" ] $f]
::deken::status ${msg}
::deken::utilities::verbose -1 ${msg}
}
}
return "link"
}
}


if { [catch {package require zipfile::decode} ] } {
proc ::deken::utilities::unzipper {zipfile {path .}} {
## this is w32 only
Expand Down Expand Up @@ -760,6 +785,7 @@ proc ::deken::open_searchui {mytoplevel} {
} else {
::deken::create_dialog $mytoplevel
::deken::bind_globalshortcuts $mytoplevel
::deken::utilities::dnd_init $mytoplevel.results
$mytoplevel.results tag configure error -foreground red
$mytoplevel.results tag configure warn -foreground orange
$mytoplevel.results tag configure info -foreground grey
Expand Down

0 comments on commit 2c073f6

Please sign in to comment.