[Tkabber-dev] r1274 - in trunk/tkabber-plugins: . attline attline/msgs debug

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Oct 14 18:58:33 MSD 2007


Author: sergei
Date: 2007-10-14 18:58:32 +0400 (Sun, 14 Oct 2007)
New Revision: 1274

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/attline/attline.tcl
   trunk/tkabber-plugins/attline/msgs/ru.msg
   trunk/tkabber-plugins/debug/debug.tcl
Log:
	* attline/attline.tcl: Changed atline namespace to attline, the same
	  for debug type. Switched to chat::winid_to_chatid. Bound cleanup
	  procedure to Chat window class instead of specific windows (thanks
	  to Konstantin Khomoutov).

	* attline/msgs/ru.msg: Fixed Russian translation (thanks to
	  Konstantin Khomoutov).

	* debug/debug.tcl: Added attline and tclchat debug types. Reorganized
	  debug types menu into two-level menu.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-10-14 14:48:51 UTC (rev 1273)
+++ trunk/tkabber-plugins/ChangeLog	2007-10-14 14:58:32 UTC (rev 1274)
@@ -1,3 +1,16 @@
+2007-10-14  Sergei Golovan <sgolovan at nes.ru>
+
+	* attline/attline.tcl: Changed atline namespace to attline, the same
+	  for debug type. Switched to chat::winid_to_chatid. Bound cleanup
+	  procedure to Chat window class instead of specific windows (thanks
+	  to Konstantin Khomoutov).
+
+	* attline/msgs/ru.msg: Fixed Russian translation (thanks to
+	  Konstantin Khomoutov).
+
+	* debug/debug.tcl: Added attline and tclchat debug types. Reorganized
+	  debug types menu into two-level menu.
+
 2007-10-10  Sergei Golovan <sgolovan at nes.ru>
 
 	* floatinglog/floatinglog.tcl: Added new options which allow to show

Modified: trunk/tkabber-plugins/attline/attline.tcl
===================================================================
--- trunk/tkabber-plugins/attline/attline.tcl	2007-10-14 14:48:51 UTC (rev 1273)
+++ trunk/tkabber-plugins/attline/attline.tcl	2007-10-14 14:58:32 UTC (rev 1274)
@@ -11,7 +11,7 @@
 option add *Chat.attentionLinePadX          5     widgetDefault
 option add *Chat.attentionLinePadY          0     widgetDefault
 
-namespace eval atline {
+namespace eval attline {
     variable state
     variable options
 
@@ -19,7 +19,7 @@
 	return [uplevel 1 namespace current]::$what
     }
     proc mycmd args {
-	lreplace $args 0 0 [my [lindex $args 0]]
+	lset args 0 [uplevel 1 namespace current]::[lindex $args 0]
     }
 
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
@@ -46,18 +46,20 @@
 	-group {Attention Line} \
 	-type boolean
 
-    hook::add open_chat_post_hook [my setup_chat_win]
+    hook::add open_chat_post_hook [mycmd setup_chat_win]
     # must perform after the hook from 'log on open' plugin:
-    hook::add open_chat_post_hook [my draw_chat_history_separator] 101
+    hook::add open_chat_post_hook [mycmd draw_chat_history_separator] 101
 
     # must perform earlier than drawing of timestamp:
-    hook::add draw_message_hook [my on_draw_message] 5.5
+    hook::add draw_message_hook [mycmd on_draw_message] 5.5
 
-    hook::add got_focus_hook  [my on_focused]
-    hook::add lost_focus_hook [my on_lost_focus]
+    hook::add got_focus_hook  [mycmd on_focused]
+    hook::add lost_focus_hook [mycmd on_lost_focus]
+
+    bind Chat <Destroy> +[mycmd cleanup %W]
 }
 
-proc atline::unread {cw {val ""}} {
+proc attline::unread {cw {val ""}} {
     variable state
     if {$val == ""} {
 	return $state($cw,unread)
@@ -66,7 +68,7 @@
     }
 }
 
-proc atline::setup_chat_win {chatid type} {
+proc attline::setup_chat_win {chatid type} {
     variable state
     set cw [chat::chat_win $chatid]
     set iw [chat::input_win $chatid]
@@ -76,29 +78,25 @@
     #unread $cw [expr {![has_focus $chatid]}]
     unread $cw false
 
-    bind $cw <Destroy> +[mycmd cleanup $cw %W]
-
     bind $iw <<ChatSeeAttentionLine>> +[mycmd see_attention_line $cw]
 
     return
 }
 
-proc atline::cleanup {w1 w2} {
-    if {![string equal $w1 $w2]} return
+proc attline::cleanup w {
+    cancel_atline_expiration $w
 
-    cancel_atline_expiration $w1
-
     variable state
-    array unset state $w1,*
+    array unset state $w,*
 }
 
-proc atline::getopt {cw opt} {
+proc attline::getopt {cw opt} {
     variable state
 
     chat::query_optiondb $state($cw,mainwindow) $opt
 }
 
-proc atline::on_draw_message {chatid from type body x} {
+proc attline::on_draw_message {chatid from type body x} {
     if {[is_delayed $x]} return
 
     set cw [chat::chat_win $chatid]
@@ -107,17 +105,17 @@
 	unread $cw true
 	# TODO implement [redraw_...]
 	if {[drawn $cw]} {
-	    debugmsg atline "deleting old"
+	    debugmsg attline "deleting old"
 	    delete_attention_line $cw
 	}
-	debugmsg atline "drawing"
+	debugmsg attline "drawing"
 	draw_attention_line $cw
     }
 
     return
 }
 
-proc atline::is_delayed {xml} {
+proc attline::is_delayed {xml} {
     foreach xelem $xml {
 	::jlib::wrapper:splitxml $xelem tag vars isempty chdata children
 	switch -- [::jlib::wrapper:getattr $vars xmlns] {
@@ -130,11 +128,11 @@
     return 0
 }
 
-proc atline::drawn {cw} {
+proc attline::drawn {cw} {
     expr {[$cw tag ranges ATLINE] != {}}
 }
 
-proc atline::draw_chat_history_separator {chatid type} {
+proc attline::draw_chat_history_separator {chatid type} {
     if {[string equal $type chat]} {
 	set cw [chat::chat_win $chatid]
 	# Draw only if text widget isn't empty (has some history lines):
@@ -146,7 +144,7 @@
     return
 }
 
-proc atline::draw_attention_line {cw} {
+proc attline::draw_attention_line {cw} {
     variable state
 
     if {[drawn $cw]} return
@@ -168,10 +166,10 @@
 
     reconfigure_attention_line $cw $al
 
-    debugmsg atline "drawn"
+    debugmsg attline "drawn"
 }
 
-proc atline::delete_attention_line {cw} {
+proc attline::delete_attention_line {cw} {
     if {![drawn $cw]} return
 
     set state [$cw cget -state]
@@ -179,21 +177,21 @@
     $cw delete ATLINE.first ATLINE.last
     $cw configure -state $state
 
-    debugmsg atline "deleted"
+    debugmsg attline "deleted"
 }
 
-proc atline::see_attention_line {cw} {
+proc attline::see_attention_line {cw} {
     if {![drawn $cw]} return
 
     $cw see ATLINE.first
 }
 
-proc atline::internal_width {cw} {
+proc attline::internal_width {cw} {
     # We assume $cw is mapped...
     expr { [winfo width $cw] - 2 * [$cw cget -borderwidth] }
 }
 
-proc atline::reconfigure_attention_line {cw al} {
+proc attline::reconfigure_attention_line {cw al} {
     if {![winfo exists $al]} return
 
     set padx [getopt $cw attentionLinePadX]
@@ -206,7 +204,7 @@
 	-pady       [getopt $cw attentionLinePadY] \
 }
 
-proc atline::has_focus {chatid} {
+proc attline::has_focus {chatid} {
     global usetabbar
 
     if {$usetabbar} {
@@ -219,24 +217,24 @@
     }
 }
 
-proc atline::on_focused {w} {
-    set chatid [active_chatid $w]
+proc attline::on_focused {w} {
+    set chatid [chat::winid_to_chatid $w]
     if {$chatid == ""} return
 
     set cw [chat::chat_win $chatid]
-    debugmsg atline "focused; unread? [unread $cw]"
+    debugmsg attline "focused; unread? [unread $cw]"
     if {[unread $cw]} {
 	see_attention_line $cw
 	schedule_atline_expiration $cw
     }
 }
 
-proc atline::on_lost_focus {w} {
-    set chatid [active_chatid $w]
+proc attline::on_lost_focus {w} {
+    set chatid [chat::winid_to_chatid $w]
     if {$chatid == ""} return
 
     set cw [chat::chat_win $chatid]
-    debugmsg atline "lost focus; unread? [unread $cw]"
+    debugmsg attline "lost focus; unread? [unread $cw]"
     if {[unread $cw]} {
 	cancel_atline_expiration $cw
     } elseif {[drawn $cw]} {
@@ -245,23 +243,7 @@
     }
 }
 
-proc atline::active_chatid {w} {
-    global usetabbar
-    variable ::chat::chat_id
-
-    if {$usetabbar} {
-	# $w is always "." here...
-	set tab [.nb raise]
-	if {[string equal $tab ""]} return
-	set winid [ifacetk::nbpath $tab]
-    } else {
-	set winid $w
-    }
-
-    expr {[info exists chat_id($winid)] ? $chat_id($winid) : ""}
-}
-
-proc atline::schedule_atline_expiration {cw} {
+proc attline::schedule_atline_expiration {cw} {
     variable state
     variable options
 
@@ -270,24 +252,24 @@
     if {$exptime <= 0} {
 	# Immediate expiration:
 	unread $cw false
-	debugmsg atline "expired immediately"
+	debugmsg attline "expired immediately"
 	return
     }
 
     set state($cw,expiring) [after $exptime [mycmd expire_attention_line $cw]]
-    debugmsg atline "expiration scheduled for after $exptime"
+    debugmsg attline "expiration scheduled for after $exptime"
 }
 
-proc atline::cancel_atline_expiration {cw} {
+proc attline::cancel_atline_expiration {cw} {
     variable state
     if {[info exists state($cw,expiring)]} {
 	after cancel $state($cw,expiring)
 	unset state($cw,expiring)
-	debugmsg atline "expiration cancelled"
+	debugmsg attline "expiration cancelled"
     }
 }
 
-proc atline::expire_attention_line {cw} {
+proc attline::expire_attention_line {cw} {
     variable state
     variable options
 
@@ -297,7 +279,7 @@
 	if {$options(remove_expired)} {
 	    delete_attention_line $cw
 	}
-	debugmsg atline "expired"
+	debugmsg attline "expired"
     }
 }
 

Modified: trunk/tkabber-plugins/attline/msgs/ru.msg
===================================================================
--- trunk/tkabber-plugins/attline/msgs/ru.msg	2007-10-14 14:48:51 UTC (rev 1273)
+++ trunk/tkabber-plugins/attline/msgs/ru.msg	2007-10-14 14:58:32 UTC (rev 1274)
@@ -5,7 +5,7 @@
      сообщения в окнах разговора от прочитанных горизонтальной линией."
 ::msgcat::mcset ru "Plugins options." "Параметры расширений."
 ::msgcat::mcset ru "Remove the attention line after it was expired from its chat window." \
-    "Удалять линию, разделяющую сообщения по истечению времени действия."
+    "Удалять линию, разделяющую сообщения по истечении времени её действия."
 ::msgcat::mcset ru \
     "Time (in milliseconds) after which unread messages in the currently\
      active chat window are considered read and the attention line is considered expired." \

Modified: trunk/tkabber-plugins/debug/debug.tcl
===================================================================
--- trunk/tkabber-plugins/debug/debug.tcl	2007-10-14 14:48:51 UTC (rev 1273)
+++ trunk/tkabber-plugins/debug/debug.tcl	2007-10-14 14:58:32 UTC (rev 1274)
@@ -27,7 +27,8 @@
 	-group Debug \
 	-type boolean
 
-    variable modules [list avatar       \
+    variable modules [list attline      \
+			   avatar       \
 			   browser      \
 			   browseurl    \
 			   chat         \
@@ -65,6 +66,7 @@
 			   si           \
 			   ssj          \
 			   sw           \
+			   tclchat      \
 			   tkabber      \
 			   userinfo     \
 			   utils        \
@@ -96,9 +98,26 @@
 
     $buttons add separator
 
+    set n 0
     foreach module $modules {
-	$buttons add checkbutton -label $module \
-	    -variable [namespace current]::debug($module)
+	if {$n == 0} {
+	    set submodules [list $module]
+	} else {
+	    lappend submodules $module
+	}
+	incr n
+	if {$n == 8 || $module == [lindex $modules end]} {
+	    set n 0
+	    set me [menu $buttons.[lindex $submodules 0] \
+			 -tearoff $::ifacetk::options(show_tearoffs)]
+	    $buttons add cascade \
+		     -label [lindex $submodules 0]-[lindex $submodules end] \
+		     -menu $me
+	    foreach mod $submodules {
+		$me add checkbutton -label $mod \
+		    -variable [namespace current]::debug($mod)
+	    }
+	}
     }
 
     $m add cascade -label [::msgcat::mc "Debug"] -menu $buttons 



More information about the Tkabber-dev mailing list