[Tkabber-dev] r1320 - in trunk/tkabber-plugins: . latex tclchat

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Nov 25 14:23:38 MSK 2007


Author: sergei
Date: 2007-11-25 14:23:37 +0300 (Sun, 25 Nov 2007)
New Revision: 1320

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/latex/latex.tcl
   trunk/tkabber-plugins/tclchat/tclchat.tcl
   trunk/tkabber-plugins/tclchat/tclchat_messages.tcl
Log:
	* latex/latex.tcl: use [winfo rgb] to get RGB color instead of
	  creating temporary image.

	* tclchat/tclchat.tcl: Fixed plugins::nickcolors::get_color call.

	* tclchat/tclchat_messages.tcl: Fixed processing Tkchat colors.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-11-25 11:14:38 UTC (rev 1319)
+++ trunk/tkabber-plugins/ChangeLog	2007-11-25 11:23:37 UTC (rev 1320)
@@ -1,3 +1,12 @@
+2007-11-25  Sergei Golovan <sgolovan at nes.ru>
+
+	* latex/latex.tcl: use [winfo rgb] to get RGB color instead of
+	  creating temporary image.
+
+	* tclchat/tclchat.tcl: Fixed plugins::nickcolors::get_color call.
+
+	* tclchat/tclchat_messages.tcl: Fixed processing Tkchat colors.
+
 2007-11-14  Sergei Golovan <sgolovan at nes.ru>
 
 	* ctcomp/README: Added info about keybindings (thanks to Konstantin

Modified: trunk/tkabber-plugins/latex/latex.tcl
===================================================================
--- trunk/tkabber-plugins/latex/latex.tcl	2007-11-25 11:14:38 UTC (rev 1319)
+++ trunk/tkabber-plugins/latex/latex.tcl	2007-11-25 11:23:37 UTC (rev 1320)
@@ -159,20 +159,20 @@
     if {$bgopt == ""} {
 	set bgopt white
     }
-    set bg [get_rgb_color $bgopt]
+    set bg [get_rgb_color $chatw $bgopt]
     
     set fgopt [option get $chatw foreground Chat]
     if {$fgopt == ""} {
 	set fgopt black
     }
-    set fg [get_rgb_color $fgopt]
+    set fg [get_rgb_color $chatw $fgopt]
 }
 
-proc latex::get_rgb_color {color} {
-    set img [image create photo -height 1 -width 1]
-    $img put $color -to 0 0
-    lassign [$img get 0 0] r g b
-    image delete $img
-    return [expr {$r/256.}],[expr {$g/256.}],[expr {$b/256.}]
+proc latex::get_rgb_color {w color} {
+    lassign [winfo rgb $w $color] r g b
+    set r [expr {($r % 256)/256.}]
+    set g [expr {($g % 256)/256.}]
+    set b [expr {($b % 256)/256.}]
+    return $r,$g,$b
 }
 

Modified: trunk/tkabber-plugins/tclchat/tclchat.tcl
===================================================================
--- trunk/tkabber-plugins/tclchat/tclchat.tcl	2007-11-25 11:14:38 UTC (rev 1319)
+++ trunk/tkabber-plugins/tclchat/tclchat.tcl	2007-11-25 11:23:37 UTC (rev 1320)
@@ -359,13 +359,9 @@
 }
 
 proc tclchat::color_to_hex {color} {
-    if {[string match "#*" $color]} {
-        return [string trim $color "#"]
-    } else {
-        foreach {r g b} [winfo rgb . $color] break
-        return [format "%02x%02x%02x" \
-                    [expr {$r % 256}] [expr {$g % 256}] [expr {$b % 256}]]
-    }
+    lassign [winfo rgb . $color] r g b
+    return [format "%02x%02x%02x" \
+                   [expr {$r % 256}] [expr {$g % 256}] [expr {$b % 256}]]
 }
 
 # tclchat::add_color --
@@ -382,7 +378,7 @@
             [cequal $type "groupchat"] && \
             [string match "*@tach.tclers.tk" $jid]} {
 
-	set color [plugins::nickcolors::get_nick_color $user]
+	set color [plugins::nickcolors::get_color $user]
         if {[string length $color] > 0} {
             lappend var [jlib::wrapper:createtag x \
                              -vars [list xmlns urn:tkchat:chat \

Modified: trunk/tkabber-plugins/tclchat/tclchat_messages.tcl
===================================================================
--- trunk/tkabber-plugins/tclchat/tclchat_messages.tcl	2007-11-25 11:14:38 UTC (rev 1319)
+++ trunk/tkabber-plugins/tclchat/tclchat_messages.tcl	2007-11-25 11:23:37 UTC (rev 1320)
@@ -32,9 +32,10 @@
 		       corresponding IRC user nickname."] \
         -group Tclchat -type string
     
-    hook::add presence_xlist_hook [namespace current]::request_users_list
+    hook::add presence_xlist_hook  [namespace current]::request_users_list
     hook::add process_message_hook [namespace current]::fill_irc_users 30
     hook::add process_message_hook [namespace current]::process_ijchain_message 30
+    hook::add draw_message_hook    [namespace current]::check_color 62
 }
 
 # VERY DIRTY HACK. Tkabber doesn't have appropriate hook, so using inappropriate
@@ -283,17 +284,18 @@
 #	we check that our idea of their color agrees. If not we'll update
 #	and refresh.
 #
-proc tclchat::check_color {nick x} {
+proc tclchat::check_color {chatid from type body x} {
+    set connid [chat::get_connid $chatid]
+    set nick [chat::get_nick $connid $from $type]
     foreach node $x {
         jlib::wrapper:splitxml $node tag attr isempty body children
-        if {[cequal [jlib::wrapper:getattr $attr xmlns] "urn:tkchat:chat"]} {
+        if {[jlib::wrapper:getattr $attr xmlns] == "urn:tkchat:chat"} {
             set color [string trim [jlib::wrapper:getattr $attr "color"] "#"]
             if {[string length $color] > 0} {
-                set orig [::plugins::nickcolors::get_nick_color $nick]
+                set orig [::plugins::nickcolors::get_color $nick]
                 debugmsg chat "Checking color for $nick ('$orig' eq '#$color')"
-                if {![cequal "$orig" "#$color"]} {
-                    set ::plugins::nickcolors::NickColors($nick) "#$color"
-                    ::plugins::nickcolors::change_options
+                if {"$orig" != "#$color"} {
+                    ::plugins::nickcolors::set_color $chatid $nick "#$color"
                 }
             }
         }



More information about the Tkabber-dev mailing list