summaryrefslogtreecommitdiff
path: root/getxbookgui.tcl
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2012-08-18 18:34:53 +0100
committerNick White <git@njw.me.uk>2012-08-18 18:34:53 +0100
commit85b7e521c312bdd0291b1f3ea9b22aaefba2c08d (patch)
tree12ea54c17863d3b021f38c91a0b287ec7c463a61 /getxbookgui.tcl
parentd018b3d5034035caadb2f9ed1084bc44bda17620 (diff)
Allow pasting of URLs to getxbookgui, and hide status bar at startup
Diffstat (limited to 'getxbookgui.tcl')
-rwxr-xr-xgetxbookgui.tcl25
1 files changed, 17 insertions, 8 deletions
diff --git a/getxbookgui.tcl b/getxbookgui.tcl
index f7135df..eddefd9 100755
--- a/getxbookgui.tcl
+++ b/getxbookgui.tcl
@@ -2,9 +2,9 @@
# See COPYING file for copyright and license details.
package require Tk
-set cmds {{getgbook "Google Book ID" "Google\nBook Preview" \
+set cmds {{getgbook "Google Book ID / URL" "Google\nBook Preview" \
"http*://books.google.*/*" {[&?]id=([^&]*)}} \
- {getabook "ISBN 10" "Amazon Look\nInside The Book" \
+ {getabook "ISBN 10 / URL" "Amazon Look\nInside The Book" \
"http*://*amazon*/*" {/([0-9]{10})/}} \
{getbnbook "ISBN 13" "Barnes & Noble\nBook Viewer" \
"http*://www.barnesandnoble.com/*" ""}}
@@ -45,6 +45,8 @@ proc go {} {
.dl configure -state disabled -text "Downloading"
.input.id configure -state readonly
.st configure -text ""
+ .prog configure -bd 1
+ .prog itemconfigure bar -state normal
.prog coords bar 0 0 0 20
set out [open "|$cmd 2>@1" "r"]
fileevent $out readable [list updateStatus $out]
@@ -60,14 +62,20 @@ proc parseurl {url} {
set cmdregex [lindex $b 4]
if {"$cmdregex" != "" && [regexp "$cmdregex" $url m sub]} {
set newid "$sub"
+ .input.id delete 0 end
+ .input.id insert 0 "$newid"
}
- .input.id delete 0 end
- .input.id insert 0 "$newid"
}
incr i
}
}
+proc checkinput {} {
+ if { [string match "http*" [.input.id get]] } {
+ parseurl [.input.id get]
+ }
+}
+
proc watchsel {} {
global dling manual
@@ -112,8 +120,8 @@ foreach b $cmds {
button .dl -text "Download" -command go
label .st
-canvas .prog -width 200 -height 20 -relief sunken -bd 1
-.prog create rectangle 0 0 0 20 -tags bar -fill black
+canvas .prog -width 200 -height 20 -relief sunken
+.prog create rectangle 0 0 0 20 -tags bar -fill black -state hidden
pack .input.lab -side left
pack .input.id
@@ -121,6 +129,7 @@ pack .input.id
pack .cmdfr .input .dl .prog .st
bind . <Return> go
-bind .input.id <Key> {set manual 1}
-bind .input.id <Button> {set manual 1}
+bind .input.id <Key> {set manual 1; checkinput}
+bind .input.id <Button> {set manual 1; checkinput}
+bind .input.id <Motion> {checkinput} ;# needed as middle-click pasting isn't passed with <Button>
watchsel