[Tkabber-dev] r119 - in trunk/plugins: . singularity

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Aug 19 01:56:03 MSD 2008


Author: kostix
Date: 2008-08-19 01:56:02 +0400 (Tue, 19 Aug 2008)
New Revision: 119

Added:
   trunk/plugins/singularity/
   trunk/plugins/singularity/INSTALL
   trunk/plugins/singularity/license.terms
   trunk/plugins/singularity/singularity.tcl
Log:
Added new Tkabber plugin "singularity" -- it ensures that only
one chat tab per entity bare JID is opened at the any given time.


Added: trunk/plugins/singularity/INSTALL
===================================================================
--- trunk/plugins/singularity/INSTALL	                        (rev 0)
+++ trunk/plugins/singularity/INSTALL	2008-08-18 21:56:02 UTC (rev 119)
@@ -0,0 +1,10 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/singularity/
+  ~/.tkabber/plugins/singularity/singularity.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Consult the README file for the details about using this plugin.
+


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

Added: trunk/plugins/singularity/license.terms
===================================================================
--- trunk/plugins/singularity/license.terms	                        (rev 0)
+++ trunk/plugins/singularity/license.terms	2008-08-18 21:56:02 UTC (rev 119)
@@ -0,0 +1,19 @@
+Copyright (c) 2008 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.


Property changes on: trunk/plugins/singularity/license.terms
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/plugins/singularity/singularity.tcl
===================================================================
--- trunk/plugins/singularity/singularity.tcl	                        (rev 0)
+++ trunk/plugins/singularity/singularity.tcl	2008-08-18 21:56:02 UTC (rev 119)
@@ -0,0 +1,43 @@
+# $Id$
+# When a message arrives which will create a new chat window,
+# this plugin checks whether any chats with the message originator's
+# other full JIDs are currently opened and closes them all, if any.
+# In other words, it ensures that only one chat window per bare
+# JID is opened.
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for the terms of distribution.
+# See README for usage details.
+
+namespace eval singularity {
+	# Must be run after code processing chat events and stuff
+	# but before default message handler.
+	hook::add process_message_hook \
+		[namespace current]::process_message 55
+}
+
+proc singularity::process_message {connid from id type
+		is_subject subject body err thread priority x} {
+	if {![string equal $type chat]} return
+
+	set chatid [chat::chatid $connid $from]
+	if {[chat::is_opened $chatid] || $body == ""} return
+
+	set barejid [node_and_server_from_jid $from]
+
+	if {$ifacetk::options(use_tabbar)} {
+		foreach page [.nb pages] {
+			upvar #0 chat::chat_id([ifacetk::nbpath $page]) cid 
+			if {![info exists cid] || [chat::is_groupchat $cid]} continue
+			set jid [chat::get_jid $cid]
+			if {![string equal $from $jid] &&
+					[string equal $barejid [node_and_server_from_jid $jid]]} {
+				eval destroy [pack slaves [.nb getframe $page]]
+				.nb delete $page 1
+				ifacetk::tab_move .nb 0
+			}
+		}
+	} else {
+		# TODO implement this for windowed interface
+	}
+}
+


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



More information about the Tkabber-dev mailing list