[Tkabber-dev] r11 - trunk/plugins/attline

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Jul 11 02:13:17 MSD 2007


Author: kostix
Date: 2007-07-11 02:13:16 +0400 (Wed, 11 Jul 2007)
New Revision: 11

Modified:
   trunk/plugins/attline/TODO
   trunk/plugins/attline/attline.tcl
Log:
attline:
* attline.tcl:
  * non-UI settings moved to Customize;
  * atteention line is now repositioned to the bottom of the buffer is that buffer loses focus and it's read;
* TODO: updated.


Modified: trunk/plugins/attline/TODO
===================================================================
--- trunk/plugins/attline/TODO	2007-06-28 10:32:31 UTC (rev 10)
+++ trunk/plugins/attline/TODO	2007-07-10 22:13:16 UTC (rev 11)
@@ -4,7 +4,7 @@
 
 * Test and re-test the code after various conditions.
 
-* Virtual event "see the attention line"?
+* Test virtual event "see the attention line".
 
 * Move exp. timeout and removal cond. to Customize vars.
 

Modified: trunk/plugins/attline/attline.tcl
===================================================================
--- trunk/plugins/attline/attline.tcl	2007-06-28 10:32:31 UTC (rev 10)
+++ trunk/plugins/attline/attline.tcl	2007-07-10 22:13:16 UTC (rev 11)
@@ -2,14 +2,12 @@
 # "Attention line" -- chat plugin for Tkabber.
 # Draws horizontal line in chat windows separating read and unread messages.
 # Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
-# See licence.terms for the terms of distribution.
+# See license.terms for the terms of distribution.
 
 option add *Chat.attentionLineHeight        1     widgetDefault
 option add *Chat.attentionLineColor         red   widgetDefault
 option add *Chat.attentionLinePadX          5     widgetDefault
 option add *Chat.attentionLinePadY          0     widgetDefault
-option add *Chat.attentionLineExpiresAfter  1000  widgetDefault
-option add *Chat.attentionLineRemoveExpired no    widgetDefault
 
 namespace eval atline {
 	package require control
@@ -17,6 +15,7 @@
 	control::control assert enabled yes
 
 	variable state
+	variable options
 
 	proc my what {
 		return [uplevel 1 namespace current]::$what
@@ -25,6 +24,28 @@
 		lreplace $args 0 0 [my [lindex $args 0]]
 	}
 
+	custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+
+	custom::defgroup {Attention Line} \
+		[::msgcat::mc "Attention Line chat plugin options.\
+			This plugin draws horizontal line separating\
+			read and unread messages in chat windows."] \
+		-group Plugins \
+		-group Chat
+
+	custom::defvar options(expires_after) 1000 \
+		[::msgcat::mc "Time (in milliseconds) after which unread messages\
+			in the currently active chat window are considered read and\
+			the attention line is considered expired."] \
+		-group {Attention Line} \
+		-type integer
+
+	custom::defvar options(remove_expired) false \
+		[::msgcat::mc "Remove the attention line after it was expired\
+			from its chat window."] \
+		-group {Attention Line} \
+		-type boolean
+
 	hook::add open_chat_post_hook [my 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
@@ -223,7 +244,12 @@
 
 	set cw [chat::chat_win $chatid]
 	debugmsg atline "lost focus; unread? [unread $cw]"
-	cancel_atline_expiration [chat::chat_win $chatid]
+	if {[unread $cw]} {
+		cancel_atline_expiration $cw
+	} elseif {[drawn $cw]} {
+		delete_attention_line $cw
+		draw_attention_line $cw
+	}
 }
 
 proc atline::active_chatid w {
@@ -248,8 +274,10 @@
 
 proc atline::schedule_atline_expiration cw {
 	variable state
-	set exptime [getopt $cw attentionLineExpiresAfter]
+	variable options
 
+	set exptime $options(expires_after)
+
 	if {$exptime <= 0} {
 		# Immediate expiration:
 		unread $cw false
@@ -272,9 +300,11 @@
 
 proc atline::expire_attention_line cw {
 	variable state
+	variable options
+
 	unread $cw false
 	unset state($cw,expiring)
-	if {[getopt $cw attentionLineRemoveExpired]} {
+	if {$options(remove_expired)} {
 		delete_attention_line $cw
 	}
 	debugmsg atline "expired"



More information about the Tkabber-dev mailing list