[Tkabber-dev] r405 - in trunk/plugins/vimage: . pixmaps

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Sep 27 19:09:06 MSD 2010


Author: Rejjin
Date: 2010-09-27 19:09:06 +0400 (Mon, 27 Sep 2010)
New Revision: 405

Removed:
   trunk/plugins/vimage/pixmaps/stop.gif
Modified:
   trunk/plugins/vimage/vimage.tcl
Log:
+++ Support redirect (Location) for url-content.
+++ New stop button (without image)

Deleted: trunk/plugins/vimage/pixmaps/stop.gif
===================================================================
(Binary files differ)

Modified: trunk/plugins/vimage/vimage.tcl
===================================================================
--- trunk/plugins/vimage/vimage.tcl	2010-09-27 12:03:10 UTC (rev 404)
+++ trunk/plugins/vimage/vimage.tcl	2010-09-27 15:09:06 UTC (rev 405)
@@ -18,7 +18,7 @@
 	}	
 
 #	+++	( Default images )
-	foreach name {large normal process error stop} {
+	foreach name {large normal process error} {
 		image create photo plugins/vimage/$name \
 		-file [file join $script_dir pixmaps ${name}.gif]
 	}
@@ -57,7 +57,7 @@
 	if { [::xmpp::delay::exists $extras] } {
 	return
 	}
-	
+
 	set map [format {http://[^\s]+\.(%s)} $extensions]
 	set matched [regexp -inline -nocase -all -- $map $body]
 	set chatwin [chat::chat_win $chatid]
@@ -105,7 +105,9 @@
 	set ns [namespace current]
 	change_state_url $url $chatwin process
 	
-	if {[catch {set token [http::geturl $url -binary 0 \
+	set url_located [Location_handle $url]
+	
+	if {[catch {set token [http::geturl $url_located -binary 0 \
 		-command [list ${ns}::image_get_end $chatwin $url] \
 		-blocksize 1024 \
 		-progress [list ${ns}::image_get_process $chatwin $url]]
@@ -119,7 +121,16 @@
 	http::wait $token
 }
 
+proc vimage::Location_handle { url } {
 
+	set token [http::geturl $url -validate 1]
+	foreach {type value} [http::meta $token] {
+	if {$type eq "Location"} { return $value }
+	}
+	
+	return $url
+}
+
 proc vimage::image_get_end { chatwin url token } {
 	variable images
 	
@@ -160,10 +171,11 @@
 	
 	if { ![info exist images($url,full)] } {
 		set images($url,data) [base64::encode $images($url,data)]
-		if { [catch {set images($url,full) [image create photo -data $images($url,data)]}] } {
-			set images($url,full) error
-			change_state_url $url $chatwin error
-			return
+		if { [catch {set images($url,full) [image create photo \
+			plugins/vimage/${url}/image -data $images($url,data)]}] } {
+				set images($url,full) error
+				change_state_url $url $chatwin error
+				return
 		}
 		if { $options(auto_show_image) } {
 			image_full_show $url
@@ -397,7 +409,6 @@
 	ProgressBar $win.prb \
 		-type nonincremental_infinite \
 		-variable $varname \
-		-foreground yellow \
 		-relief groove
 		
 	if {$max != 0} {
@@ -406,7 +417,10 @@
 			-type normal
 	}
 	
-	button $win.cancel -image plugins/vimage/stop -relief flat \
+	button $win.cancel -font ChatBoldFont -text X -foreground red \
+	-background [$win cget -background] -relief flat \
+	-activebackground [$win cget -background] \
+	-activeforeground black \
 	-command [list set [namespace current]::options(_download) 0]
 		
 	pack $win.cancel $win.prb -padx 2 -side left
@@ -414,7 +428,7 @@
 
 proc vimage::del_progressbar { } {
 	catch { destroy .mainframe.status.prgf.prb \
-	.mainframe.status.prgf.cancel }
+		.mainframe.status.prgf.cancel }
 }
 
 #################################################



More information about the Tkabber-dev mailing list