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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Jan 8 17:37:37 MSK 2008


Author: kostix
Date: 2008-01-08 17:37:37 +0300 (Tue, 08 Jan 2008)
New Revision: 90

Modified:
   trunk/plugins/recentstatus/TODO
   trunk/plugins/recentstatus/recentstatus.tcl
Log:
recentstatus/recentstatus.tcl: Implemented limiting of the maximum history length
 with auto-expunging of the oldest messages.

recentstatus/TODO: Tasks updated.


Modified: trunk/plugins/recentstatus/TODO
===================================================================
--- trunk/plugins/recentstatus/TODO	2008-01-08 02:37:09 UTC (rev 89)
+++ trunk/plugins/recentstatus/TODO	2008-01-08 14:37:37 UTC (rev 90)
@@ -1,20 +1,6 @@
 $Id$
 
-* Looks like when Tkabber starts up and the history isn't empty,
-  the combobox receives the first history item as it's text
-  value and when Tkabber connects it becomes the availability
-  message.
-  Probably we need to forcibly set there the current value of
-  textvariabled obtained before the combobox is populated or
-  take another route to fetch the saved availability status
-  message, if any.
-
-* Implement configuration option for limiting the maximum
-  number of history messages (old messages above the threshold
-  should be removed when the new message is added).
-
 * Implement editing of history messages.
   Deletion of arbitrary history messages also would be cool.
 
-
 # vim:tw=64:noet

Modified: trunk/plugins/recentstatus/recentstatus.tcl
===================================================================
--- trunk/plugins/recentstatus/recentstatus.tcl	2008-01-08 02:37:09 UTC (rev 89)
+++ trunk/plugins/recentstatus/recentstatus.tcl	2008-01-08 14:37:37 UTC (rev 90)
@@ -11,12 +11,30 @@
 
 namespace eval recentstatus {
 	variable history
+	variable options
 
 	custom::defvar history [list] \
 		[::msgcat::mc "History of availability status messages"] \
 		-type list \
 		-group Hidden
 
+	custom::defgroup Plugins [::msgcat::mc "Plugins options."] \
+		-group Tkabber
+	custom::defgroup {Recent Status} \
+		[::msgcat::mc "Recent Status plugin options.\
+			This plugin records all availability status messages\
+			manually set by the user and allows to select them\
+			via the drop down menu. The recorded messages are\
+			preserved across restarts."] \
+		-group Plugins
+
+	custom::defvar options(maxhistorysize) 5 \
+		[::msgcat::mc "Maximum number of status messages to record.\
+			If the history size grows beyond this threshold,\
+			the oldest message will be deleted automatically\
+			when a new one is recorded."] \
+		-type integer -group {Recent Status}
+
 	hook::add finload_hook [namespace current]::subvert_presence_widget
 }
 
@@ -41,6 +59,7 @@
 
 proc recentstatus::save_availability_status {w} {
 	variable history
+	variable options
 
 	set ix [$w getvalue]
 	if {$ix >= 0} return
@@ -48,7 +67,12 @@
 	set avstatus [$w cget -text]
 	if {$avstatus == ""} return
 
-	lappend history $avstatus
+	if {[llength $history] < $options(maxhistorysize)} {
+		lappend history $avstatus
+	} else {
+		set history [linsert [lrange $history 1 end] end $avstatus]
+	}
+
 	$w configure -values $history
 }
 



More information about the Tkabber-dev mailing list