[Tkabber-dev] r140 - in trunk/plugins: . stripes

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Oct 12 01:55:52 MSD 2008


Author: kostix
Date: 2008-10-12 01:55:52 +0400 (Sun, 12 Oct 2008)
New Revision: 140

Added:
   trunk/plugins/stripes/
   trunk/plugins/stripes/AUTHORS
   trunk/plugins/stripes/INSTALL
   trunk/plugins/stripes/README
   trunk/plugins/stripes/license.terms
   trunk/plugins/stripes/stripes.tcl
Log:
stripes: Initial import of the "stripes" chat plugin.
 Retrieved from http://ru.tkabber.jabe.ru
 at version 0.1, 07-Mar-2007.


Copied: trunk/plugins/stripes/AUTHORS (from rev 139, trunk/plugins/singularity/AUTHORS)
===================================================================
--- trunk/plugins/stripes/AUTHORS	                        (rev 0)
+++ trunk/plugins/stripes/AUTHORS	2008-10-11 21:55:52 UTC (rev 140)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>

Copied: trunk/plugins/stripes/INSTALL (from rev 139, trunk/plugins/singularity/INSTALL)
===================================================================
--- trunk/plugins/stripes/INSTALL	                        (rev 0)
+++ trunk/plugins/stripes/INSTALL	2008-10-11 21:55:52 UTC (rev 140)
@@ -0,0 +1,13 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/stripes/
+  ~/.tkabber/plugins/stripes/stripes.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Consult the README file for the details about using this plugin.
+Usually you'll want to set the stripes' color which can be done
+either via XRDB (on Unix) or using Tk option database (on any
+system).
+

Copied: trunk/plugins/stripes/README (from rev 139, trunk/plugins/singularity/README)
===================================================================
--- trunk/plugins/stripes/README	                        (rev 0)
+++ trunk/plugins/stripes/README	2008-10-11 21:55:52 UTC (rev 140)
@@ -0,0 +1,65 @@
+$Id$
+"Singularity" -- main interface plugin for Tkabber.
+
+
+I. The Idea
+
+When you chat with someone in Tkabber, the corresponding chat
+window is opened for the full JID of that person (it is a JID
+with the resource part: node at server/resource). Since your peers
+can normally log into their XMPP accounts several times at once
+(with a different resource each time) Tkabber maintains clear
+distinction between these full JIDs.
+On the other hand, most people seldom chat from several
+connections to their account at once -- quite more often they
+move between two or more XMPP clients located in places which
+are geographically quite apart, such as their home and office.
+In this case it may be convenient to maintain just one chat
+window open for each person you're chatting with -- for
+instance, you start chatting whith your peer when he/she is at
+home, then your peer moves to their office and sends a message
+from the new location; at this point it might be convenient not
+to have two chat windows -- old and new -- open, but just the
+new one.
+
+This plugin implements the described functionality: when the new
+window for a one-on-one chat is about to be opened the plugin
+checks whether there are any active chat sessions with the same
+bare JID (that is, without the "/resource" part) as that of the
+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 keep just one chat
+window per bare JID open.
+
+The plugin does not touch MUC private chats because in them
+resource part of the room JID is used to designate participants'
+nicknames.
+
+
+II. Usage
+
+Just install this plugin as usually and restart Tkabber.
+Currently there's no UI to control the plugin's behaviour.
+
+
+III. Bugs and limitations
+
+* Tkabber is currently unable to actually "switch" a chat window
+  from one JID to another, so this plugin works by closing the
+  existing window(s) and opening the new one. While in tabbed
+  mode this looks mostly OK, in windowed mode this may be
+  annoying because the new window will most probably not appear
+  at the same location and layer as the closed window.
+
+* For some unknown reason the first line of the input history is
+  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

Added: trunk/plugins/stripes/license.terms
===================================================================
--- trunk/plugins/stripes/license.terms	                        (rev 0)
+++ trunk/plugins/stripes/license.terms	2008-10-11 21:55:52 UTC (rev 140)
@@ -0,0 +1,19 @@
+Copyright (c) 2007, 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/stripes/license.terms
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/plugins/stripes/stripes.tcl
===================================================================
--- trunk/plugins/stripes/stripes.tcl	                        (rev 0)
+++ trunk/plugins/stripes/stripes.tcl	2008-10-11 21:55:52 UTC (rev 140)
@@ -0,0 +1,70 @@
+# $Id$
+# "Stripes" chat plugin for Tkabber -- colorizes background of
+# whole messages in chat windows.
+#
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for the terms of distribution.
+# See README for usage details.
+
+# Color for odd and even messages can be tuned separately
+# using the Tk option database (or XRDB) like this:
+# option add *Chat.oddBackground  gray77
+# option add *Chat.evenBackground gray84
+
+namespace eval stripes {
+	variable state
+
+	hook::add open_chat_post_hook \
+		[namespace current]::tweak_chat_window
+	hook::add draw_message_hook \
+		[namespace current]::on_draw_message 10
+}
+
+proc stripes::tweak_chat_window {chatid type} {
+	variable state
+
+	set cw [::chat::chat_win $chatid]
+
+	set mw [::chat::winid $chatid]
+	set bgodd  [option get $mw oddBackground Chat]
+	if {$bgodd != "" } {
+		$cw tag config ODD -background $bgodd
+	}
+	set bgeven [option get $mw evenBackground Chat]
+	if {$bgeven != "" } {
+		$cw tag config EVEN -background $bgeven
+	}
+
+	set state($cw,last) 1.0
+	set state($cw,tag) EVEN
+
+	bind $cw <Destroy> +[list [namespace current]::cleanup $cw %W]
+}
+
+proc stripes::cleanup {w1 w2} {
+	if {![string equal $w1 $w2]} return
+
+	variable state
+	array unset state $w1,*
+}
+
+proc stripes::on_draw_message {chatid from type body x} {
+	variable state
+	set cw [::chat::chat_win $chatid]
+
+	# Analyze previous message:
+	set last $state($cw,last)
+	set now [$cw index {end - 1 char}]
+	if {[$cw compare $last < $now]} {
+		$cw tag add $state($cw,tag) $last $now
+		if {[string equal $state($cw,tag) EVEN]} {
+			set state($cw,tag) ODD
+		} else {
+			set state($cw,tag) EVEN
+		}
+	}
+
+	# Save last pos:
+	set state($cw,last) $now
+}
+


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



More information about the Tkabber-dev mailing list