[Tkabber-dev] r92 - trunk/plugins/recentstatus

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Jan 9 02:12:01 MSK 2008


Author: kostix
Date: 2008-01-09 02:12:00 +0300 (Wed, 09 Jan 2008)
New Revision: 92

Modified:
   trunk/plugins/recentstatus/README
   trunk/plugins/recentstatus/TODO
   trunk/plugins/recentstatus/recentstatus.tcl
Log:
recentstatus/recentstatus.tcl:
 * Status message applied via changing availability status is now recorded
   to the history.
 * When the user enters a message which is already present in the history,
   this message is moved to the most recent position in the history instead
   of just being ignored.

recentstatus/README: Added a note about prevention of duplicate values in the history.

recentstatus/TODO: Tasks updated.


Modified: trunk/plugins/recentstatus/README
===================================================================
--- trunk/plugins/recentstatus/README	2008-01-08 22:29:25 UTC (rev 91)
+++ trunk/plugins/recentstatus/README	2008-01-08 23:12:00 UTC (rev 92)
@@ -2,7 +2,7 @@
 "Recent Status" -- plugin for Tkabber.
 
 
-I. The idea
+I. The Idea
 
 This plugin replaces the standard Tkabber's widget for managing
 the user's availability status message (this is an entry box to
@@ -32,6 +32,11 @@
 NOTE that when you select a message using the drop-down list you
 still need to "apply" it (see above).
 
+NOTE that if the message you entered is already present in the
+history, it's not recorded, instead, it's moved to the most
+recent position in the history. Thus the history prevents
+duplicates.
+
 You can clear the history of status messages by using the "Clear
 history" command from the context menu of the combobox entry
 (invoked by the right mouse button). This operation is

Modified: trunk/plugins/recentstatus/TODO
===================================================================
--- trunk/plugins/recentstatus/TODO	2008-01-08 22:29:25 UTC (rev 91)
+++ trunk/plugins/recentstatus/TODO	2008-01-08 23:12:00 UTC (rev 92)
@@ -1,8 +1,5 @@
 $Id$
 
-* Status message isn't recorded in the history if it's applied
-  by changing the status.
-
 * Implement editing of history messages.
   Deletion of arbitrary history messages also would be cool.
 

Modified: trunk/plugins/recentstatus/recentstatus.tcl
===================================================================
--- trunk/plugins/recentstatus/recentstatus.tcl	2008-01-08 22:29:25 UTC (rev 91)
+++ trunk/plugins/recentstatus/recentstatus.tcl	2008-01-08 23:12:00 UTC (rev 92)
@@ -58,19 +58,22 @@
 	$w bind <Button-3> [list [namespace current]::show_context_menu $w]
 
 	eval [concat [list pack $w] $pinfo]
+
+	trace add variable ::userstatus write \
+		[list [namespace current]::on_status_change $w]
 }
 
 proc recentstatus::save_availability_status {w} {
 	variable history
 	variable options
 
-	set ix [$w getvalue]
-	if {$ix >= 0} return
-
 	set avstatus [$w cget -text]
 	if {$avstatus == ""} return
 
-	if {[llength $history] < $options(maxhistorysize)} {
+	set ix [$w getvalue]
+	if {$ix >= 0} {
+		set history [linsert [lreplace $history $ix $ix] end $avstatus]
+	} elseif {[llength $history] < $options(maxhistorysize)} {
 		lappend history $avstatus
 	} else {
 		set history [linsert [lrange $history 1 end] end $avstatus]
@@ -79,6 +82,10 @@
 	$w configure -values $history
 }
 
+proc recentstatus::on_status_change {w n1 n2 op} {
+	save_availability_status $w
+}
+
 proc recentstatus::show_context_menu {w} {
 	set m $w.menu
 



More information about the Tkabber-dev mailing list