[Tkabber-dev] r464 - in trunk/plugins/winup: . msgs pixmaps resize

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jan 23 06:00:12 MSK 2011


Author: Rejjin
Date: 2011-01-23 06:00:12 +0300 (Sun, 23 Jan 2011)
New Revision: 464

Added:
   trunk/plugins/winup/resize/ThreadedResize.tcl
Modified:
   trunk/plugins/winup/README_ru
   trunk/plugins/winup/msgs/ru.msg
   trunk/plugins/winup/pixmaps/toolbar-disabled.gif
   trunk/plugins/winup/pixmaps/toolbar-enabled.gif
   trunk/plugins/winup/resize/pkgIndex.tcl
   trunk/plugins/winup/resize/resize.tcl
   trunk/plugins/winup/winup.tcl
Log:
1) Fixed bugs with drawing window.
2) Resize package using ThreadedResize if Thread supported (fast speed).
3) Saving transparency information in resize.
4) Added option "mark as read".
5) Added new toolbar icons.

Modified: trunk/plugins/winup/README_ru
===================================================================
--- trunk/plugins/winup/README_ru	2011-01-22 20:13:07 UTC (rev 463)
+++ trunk/plugins/winup/README_ru	2011-01-23 03:00:12 UTC (rev 464)
@@ -49,6 +49,7 @@
    config(message_font)				Tahoma 8
    config(window_minimal_size)		285 120
    config(auto_hide)				Да
+   config(auto_update_tabs)			Да
    
    <___Описание___>
    
@@ -183,6 +184,11 @@
    то окно будет ожидать команды закрытия (правая клавиша мыши).
    
    
+---config(auto_update_tabs)-----------------------:
+											Автоматически помечать все
+   отображаемые сообщения "как прочитанные".
+   
+   
 [Использование]
    После загрузки плагина на системной панеле появляется иконка
    статуса плагина. Если изображение полноцветное, то это состояние
@@ -225,8 +231,9 @@
 [TODO]
    1) Исправить глюки механизма движения.
    2) Добавить меню быстрого ответа в окно.
-   3) Пометить сообщения как "прочитанные".
+   3) Пометить сообщения как "прочитанные". (Реализовано)
    4) Переписать механизм уменьшения фото на C (с целью увеличения скорости).
+   (частично реализовано)
    
 [Автор]
    Rejjin 

Modified: trunk/plugins/winup/msgs/ru.msg
===================================================================
--- trunk/plugins/winup/msgs/ru.msg	2011-01-22 20:13:07 UTC (rev 463)
+++ trunk/plugins/winup/msgs/ru.msg	2011-01-23 03:00:12 UTC (rev 464)
@@ -39,4 +39,5 @@
 ::msgcat::mcset ru "Auto hide notify window." "Автоматически скрывать уведомляющее окно."
 ::msgcat::mcset ru "JIDs for always notyfy (with regexp)." "Список адресов, для которых не действуют игнорирования плагина (в списке можно использовать регулярные выражения)."
 ::msgcat::mcset ru "Save and load avatars." "Хранить фото локально."
-::msgcat::mcset ru "You'r black list of jids (with regexp)." "Ваш чёрный список JID'ов (в списке можно использовать регулярные выражения)."
\ No newline at end of file
+::msgcat::mcset ru "You'r black list of jids (with regexp)." "Ваш чёрный список JID'ов (в списке можно использовать регулярные выражения)."
+::msgcat::mcset ru "Automatically mark \"as read\"." "Автоматически помечать контакты как \"прочитанное\"."
\ No newline at end of file

Modified: trunk/plugins/winup/pixmaps/toolbar-disabled.gif
===================================================================
(Binary files differ)

Modified: trunk/plugins/winup/pixmaps/toolbar-enabled.gif
===================================================================
(Binary files differ)

Added: trunk/plugins/winup/resize/ThreadedResize.tcl
===================================================================
--- trunk/plugins/winup/resize/ThreadedResize.tcl	                        (rev 0)
+++ trunk/plugins/winup/resize/ThreadedResize.tcl	2011-01-23 03:00:12 UTC (rev 464)
@@ -0,0 +1,43 @@
+namespace eval ::ThreadedResize {
+global auto_path
+variable th 
+
+	package provide ThreadedResize 0.1	
+	
+	package require Thread
+	package require Img
+	
+	tsv::set application apath $auto_path
+	
+	set th [thread::create]
+	
+	thread::send $th {set auto_path [tsv::get application apath]}
+	thread::send $th {package require Tk}
+	thread::send $th {package require Img}
+	thread::send $th {package require resize}
+	thread::send $th {wm withdraw .}
+}
+
+proc ::ThreadedResize::resize { img newx newy} {
+global configdir
+variable th 
+	
+	set file_im [file join $configdir winup-image-temp]
+	$img write $file_im
+	
+	thread::send $th "set img \[image create photo\]"
+	thread::send $th "\$img read $file_im"
+	
+	thread::send -async $th "::resize::resize \$img $newx $newy" \
+		::vwait_result
+	vwait ::vwait_result
+	
+	set img $::vwait_result
+	
+	thread::send $th [list $img write $file_im]
+	
+	set result [image create photo] 
+	$result read $file_im
+	
+	return $result
+}
\ No newline at end of file

Modified: trunk/plugins/winup/resize/pkgIndex.tcl
===================================================================
--- trunk/plugins/winup/resize/pkgIndex.tcl	2011-01-22 20:13:07 UTC (rev 463)
+++ trunk/plugins/winup/resize/pkgIndex.tcl	2011-01-23 03:00:12 UTC (rev 464)
@@ -1,2 +1,3 @@
 if ![package vsatisfies [package provide Tcl] 8.4] return
-package ifneeded resize 0.1 [list source [file join $dir resize.tcl]]
\ No newline at end of file
+package ifneeded resize 0.1 [list source [file join $dir resize.tcl]]
+package ifneeded ThreadedResize 0.1 [list source [file join $dir ThreadedResize.tcl]]
\ No newline at end of file

Modified: trunk/plugins/winup/resize/resize.tcl
===================================================================
--- trunk/plugins/winup/resize/resize.tcl	2011-01-22 20:13:07 UTC (rev 463)
+++ trunk/plugins/winup/resize/resize.tcl	2011-01-23 03:00:12 UTC (rev 464)
@@ -105,13 +105,31 @@
 			 update idletasks
 		 }
 
-		 while { $ny < $newy } {
-			 $dest put -to 0 $ny [list $row]
-			 incr ny
-		 }
+		      while { $ny < $newy } {
+         $dest put -to 0 $ny [list $row]
+         incr ny
+     }
+     update idletasks
 
-		 return $dest
-	}
-}
+     # Saving transparency information
+	for {set i 0} {$i < $newx} {incr i} {
+		for {set j 0} {$j < $newy} {incr j} {
+			set ox [expr {round(($mx)*1.0/$newx*$i+0.5)}]
+			set oy [expr {round(($my)*1.0/$newy*$j+0.5)}]
+			if {[catch {set tr [$src transparency get $ox $oy ]}]} {
+			set tr 1
+			}
+			incr ox -1; incr oy -1
+			if {[catch {set tr0 [$src transparency get $ox $oy]}]} {
+			set tr 1
+			} else {
+			set tr [expr {$tr || $tr0}]
+			}
+			catch {$dest transparency set $i $j $tr}
+		}
+     }
 
+     return $dest
+ }
+
 # (c) wiki.tcl.tk
\ No newline at end of file

Modified: trunk/plugins/winup/winup.tcl
===================================================================
--- trunk/plugins/winup/winup.tcl	2011-01-22 20:13:07 UTC (rev 463)
+++ trunk/plugins/winup/winup.tcl	2011-01-23 03:00:12 UTC (rev 464)
@@ -7,6 +7,7 @@
 variable config
 variable toolbar_button
 variable photos
+variable threaded 0
 
 	set config(script_dir) [file dirname [info script]]
 	
@@ -17,7 +18,13 @@
 	package require fly
 	package require resize
 	package require base64
+	package require Img
 	
+	if {![catch {package require Thread}] && \
+		![catch {package require ThreadedResize}]} {
+			set threaded 1
+	}
+	
 	custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber	
     custom::defgroup Winup [::msgcat::mc "Winup custom options."] -group Plugins
 	
@@ -131,6 +138,10 @@
 	[::msgcat::mc "Minimal size of notifycation window."] \
 	-type string -group Winup
 		
+	custom::defvar config(auto_update_tabs) 1 \
+	[::msgcat::mc "Automatically mark \"as read\"."] \
+	-type boolean -group Winup
+		
 	# Hidden Group
 	custom::defvar toolbar_button(index) {-1} \
 	[::msgcat::mc "Last button index"] \
@@ -177,6 +188,7 @@
 			subject body err thread priority x} {
 variable config
 variable photos
+variable threaded
 	
 	set mjid 0
 	foreach majid $config(unique_jids) {
@@ -242,8 +254,13 @@
 	if {$config(show_avatars)} {
 		if {![info exist photos($from)]} {
 			if {[lsearch -exact [image names] photo_$from] >= 0} {
-			set photos($from) [resize::resize photo_$from \
-				$config(photo_width) $config(photo_height)]
+				if {$threaded} {
+					set photos($from) [ThreadedResize::resize photo_$from \
+					$config(photo_width) $config(photo_height)]
+				} else {
+					set photos($from) [resize::resize photo_$from \
+					$config(photo_width) $config(photo_height)]
+				}
 			}
 		}
 		catch {set photo $photos($from)}
@@ -266,7 +283,7 @@
 
 proc winup::create_window {xlib from type status subject photo text nick} {
 variable config
-
+	
 	if {[string equal $type "groupchat"]} {
 		set titletext [::msgcat::mc "Tkabber: message from groupchat"]
 		set chatid [chat::chatid $xlib [::xmpp::jid::stripResource $from]]
@@ -275,6 +292,10 @@
 		set chatid [chat::chatid $xlib $from]
 	}
 	
+	if {$config(auto_update_tabs)} {
+	set_updated $chatid
+	}
+	
 	if {[info exist config(topwin)] && [winfo exist $config(topwin)]} { 
 	if {[fly::state $config(topwin)] != 0} return
 	set top $config(topwin)
@@ -319,7 +340,7 @@
 		-offsetx $config(-offsetx) \
 		-offsety $config(-offsety) \
 		-keyframes $config(-keyframes) \
-		-withdraw 0
+		-withdraw 1
 	
 	if {$config(auto_hide)} {
 		fly::animate $top
@@ -365,6 +386,27 @@
 	}
 }
 
+proc winup::set_updated {chatid} {
+    global usetabbar
+    global tabcolors
+    global alert_colors
+
+    if {!$usetabbar} return
+
+    set winid [::chat::winid $chatid]
+	set page [ifacetk::nbpage $winid]
+
+	set color [lindex $alert_colors 0]
+	.nb itemconfigure $page -foreground $color -activeforeground $color
+	set tabcolors($page) 0
+ 
+	set ::ifacetk::number_msg($chatid) 0
+	set ::ifacetk::personal_msg($chatid) 0
+	
+	ifacetk::update_chat_title $chatid
+	ifacetk::update_main_window_title
+}
+
 proc winup::children_configure {top xlib from status subject text titletext photo nick} {
 variable config
 



More information about the Tkabber-dev mailing list