[Tkabber-dev] r139 - trunk/plugins/singularity

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Oct 12 01:47:38 MSD 2008


Author: kostix
Date: 2008-10-12 01:47:37 +0400 (Sun, 12 Oct 2008)
New Revision: 139

Added:
   trunk/plugins/singularity/AUTHORS
   trunk/plugins/singularity/msgs/
Modified:
   trunk/plugins/singularity/README
   trunk/plugins/singularity/singularity.tcl
Log:
singularity/AUTHORS: Added the AUTHORS file.

singularity/msgs: Created message catalog directory.

singularity/singularity.tcl: Provided Customize interface
 with one option which enables or disables the plugin.

singularity/README: Minor fixes and improvements.


Added: trunk/plugins/singularity/AUTHORS
===================================================================
--- trunk/plugins/singularity/AUTHORS	                        (rev 0)
+++ trunk/plugins/singularity/AUTHORS	2008-10-11 21:47:37 UTC (rev 139)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>


Property changes on: trunk/plugins/singularity/AUTHORS
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: trunk/plugins/singularity/README
===================================================================
--- trunk/plugins/singularity/README	2008-10-11 19:53:24 UTC (rev 138)
+++ trunk/plugins/singularity/README	2008-10-11 21:47:37 UTC (rev 139)
@@ -1,5 +1,5 @@
 $Id$
-"Singularity" -- chat plugin for Tkabber.
+"Singularity" -- main interface plugin for Tkabber.
 
 
 I. The Idea
@@ -29,7 +29,7 @@
 new chat. If there are, they are closed with their conversation
 log and input history preserved, the new chat window is opened
 and then the saved data is inserted into the new window. 
-So effectively this plugin makes Tkabber to keep just one chat
+So effectively this plugin makes Tkabber keep just one chat
 window per bare JID open.
 
 The plugin does not touch MUC private chats because in them
@@ -56,5 +56,10 @@
   lost when the chat state is transferred to the newly opened
   window.
 
+* If there are several chat windows to be closed when the new
+  one is about to be opened, the order in which their
+  conversation logs and input history records are collected
+  is undefined.
 
+
 # vim:tw=64:noet

Modified: trunk/plugins/singularity/singularity.tcl
===================================================================
--- trunk/plugins/singularity/singularity.tcl	2008-10-11 19:53:24 UTC (rev 138)
+++ trunk/plugins/singularity/singularity.tcl	2008-10-11 21:47:37 UTC (rev 139)
@@ -9,56 +9,79 @@
 # See README for usage details.
 
 namespace eval singularity {
-	variable contexts
+    variable contexts
 
-	hook::add open_chat_pre_hook \
-		[namespace current]::process_new_chat_opening
-	hook::add open_chat_post_hook \
-		[namespace current]::restore_chat_context
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+
+    custom::defgroup Singularity \
+	[::msgcat::mc "Singularity main interface plugin options.\
+	    This plugin cleans up the chat windows by closing obsolete\
+	    chat windows opened for different resources of the same\
+	    contact ensuring only one chat window for a contact\
+	    is opened at any given time."] \
+	-group Plugins \
+	-group IFace
+
+    custom::defvar options(enabled) 1 \
+	[::msgcat::mc "Allow closing obsolete chat windows\
+	    for a contact when a window for the new chat\
+	    session with that contact is about to be opened."] \
+	-group Singularity \
+	-type boolean
+
+    hook::add open_chat_pre_hook \
+	[namespace current]::process_new_chat_opening
+    hook::add open_chat_post_hook \
+	[namespace current]::restore_chat_context
 }
 
 proc singularity::process_new_chat_opening {chatid type} {
-	if {![string equal $type chat]} return
+    variable options
+    if {!$options(enabled) || ![string equal $type chat]} return
 
-	set from [chat::get_jid $chatid]
-	set barejid [node_and_server_from_jid $from]
-	if {[chat::is_groupchat [chat::chatid \
-			[chat::get_connid $chatid] $barejid]]} return
+    set from [chat::get_jid $chatid]
+    set barejid [node_and_server_from_jid $from]
+    if {[chat::is_groupchat [chat::chatid \
+	[chat::get_connid $chatid] $barejid]]} return
 
-	variable contexts
-	upvar 0 contexts(input,$chatid) savedinput
-	upvar 0 contexts(history,$chatid) savedhistory
-	variable [namespace parent]::history
+    variable contexts
+    upvar 0 contexts(input,$chatid) savedinput
+    upvar 0 contexts(history,$chatid) savedhistory
+    variable [namespace parent]::history
 
-	set savedinput ""
-	set savedhistory [list]
+    set savedinput ""
+    set savedhistory [list]
 
-	foreach cid [chat::opened] {
-		set jid [chat::get_jid $cid]
-		if {![string equal $from $jid] &&
-				[string equal $barejid [node_and_server_from_jid $jid]]} {
-			if {$savedinput != ""} { append savedinput \n }
-			append savedinput [[chat::input_win $cid] get 1.0 end-1c]
-			set savedhistory [concat $savedhistory $history(stack,$cid)]
-			chat::close $cid
-		}
+    foreach cid [chat::opened] {
+	set jid [chat::get_jid $cid]
+	if {![string equal $from $jid] &&
+		[string equal $barejid [node_and_server_from_jid $jid]]} {
+	    if {$savedinput != ""} { append savedinput \n }
+	    append savedinput [[chat::input_win $cid] get 1.0 end-1c]
+	    set savedhistory [concat $savedhistory $history(stack,$cid)]
+	    chat::close $cid
 	}
+    }
 }
 
 proc singularity::restore_chat_context {chatid type} {
-	if {![string equal $type chat]} return
+    variable options
+    if {!$options(enabled) || ![string equal $type chat]} return
 
-	variable contexts
-	upvar 0 contexts(input,$chatid) savedinput
-	upvar 0 contexts(history,$chatid) savedhistory
-	if {![info exists savedinput]} return
+    variable contexts
+    upvar 0 contexts(input,$chatid) savedinput
+    upvar 0 contexts(history,$chatid) savedhistory
+    if {![info exists savedinput]} return
 
-	variable [namespace parent]::history
+    variable [namespace parent]::history
 
-	[chat::input_win $chatid] insert end $contexts(input,$chatid)
-	set history(stack,$chatid) $contexts(history,$chatid)
-	set history(pos,$chatid)   0
+    [chat::input_win $chatid] insert end $contexts(input,$chatid)
+    set history(stack,$chatid) $contexts(history,$chatid)
+    set history(pos,$chatid)   0
 
-	unset contexts(input,$chatid) contexts(history,$chatid)
+    unset contexts(input,$chatid) contexts(history,$chatid)
 }
 
+# vim:ts=8:sw=4:sts=4:noet



More information about the Tkabber-dev mailing list