[Tkabber-dev] r219 - trunk/plugins/bldjid

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Apr 16 05:15:40 MSD 2009


Author: bigote
Date: 2009-04-16 05:15:40 +0400 (Thu, 16 Apr 2009)
New Revision: 219

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/README
   trunk/plugins/bldjid/TODO
   trunk/plugins/bldjid/bldjid.tcl
Log:
Timeout for monitor window is removed.
Commands /showmon and /closemon are removed, too,
as <Control-m> is used to toggle between monitor window states.
Some code refactoring (unnecessary procedures deleted).


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-04-15 02:06:58 UTC (rev 218)
+++ trunk/plugins/bldjid/ChangeLog	2009-04-16 01:15:40 UTC (rev 219)
@@ -1,3 +1,15 @@
+2009-04-16  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+--- Version 0.5.16 of the plugin.
+--- Files modified:
+    bldjid.tcl, README, TODO, ChangeLog.
+
+--- Changes:
+	Timeout for monitor window is removed.
+	Commands /showmon and /closemon are removed, too,
+	as <Control-m> is used to toggle between monitor window states.
+	Some code refactoring (unnecessary procedures deleted).
+
 2009-04-15  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.5.15 of the plugin.

Modified: trunk/plugins/bldjid/README
===================================================================
--- trunk/plugins/bldjid/README	2009-04-15 02:06:58 UTC (rev 218)
+++ trunk/plugins/bldjid/README	2009-04-16 01:15:40 UTC (rev 219)
@@ -63,17 +63,13 @@
 
 where ?n? is an integer between 0 and the last item number.
 
---- There is an option that allows you to redirect /visit* and /bldhelp
-	commands output to a special monitor window. To close it manually type:
-/closemon
+--- There is a possibility to redirect /visit* and /bldhelp commands output
+	to a special monitor window. See Customize section below.
 
---- It can be opened again by the following command:
-/showmon
-
---- Please note that a hotkey <Control-m> is added to toggle between
+--- There is a hotkey <Control-m> that is added to toggle between
 	open/close states of the monitor.
 
---- To clear the currently opened monitor window (not logs, neither the last search!)
+--- To clear the current monitor window (not logs, neither the last search!)
 	use the command:
 /clearmon
 
@@ -122,9 +118,9 @@
 	Disabled by default.
 	This option allows you to display /visit* and /bldhelp commands output
 	in a special monitor window placed below the current chat input window.
-	It can be closed manually by typing /closemon command at any moment
-	but it has a timeout after which it will be closed automatically.
-	Closing this monitor window doesn't mean you lose your search result.
+	It can be closed manually and opened again by pressing <Ctrl-m>
+	at any moment.
+-	Closing this monitor window doesn't mean you lose your search result.
 	You can still use ban and unban commands with a list number
 	if you remember it or using it with JID autocompletion.
 	Even more, your search history is kept in each monitor window
@@ -132,11 +128,6 @@
 	You can scroll monitor window up and down by pressing
 	Alt-Shift-PgUp and Alt-Shift-PgDown correspondingly.
 
---- ::plugins::bldjid::options(wmon_timeout)
-	The lifetime of a currently opened monitor window. Default value is 30 seconds.
-	Zero means it won't be closed automatically. At any moment you can close it
-	by typing /closemon.
-
 --- ::plugins::bldjid::options(send_chat_messages)
 	Besides of logging user entrances, chat system messages are published.
 	Unlike usual messages that are sent by ::muc::options(gen_enter_exit_msgs)

Modified: trunk/plugins/bldjid/TODO
===================================================================
--- trunk/plugins/bldjid/TODO	2009-04-15 02:06:58 UTC (rev 218)
+++ trunk/plugins/bldjid/TODO	2009-04-16 01:15:40 UTC (rev 219)
@@ -1,12 +1,7 @@
-=== Maybe monitor timeout isn't necessary now, when a hotkey
-	for its toggling is added. So it's very likely that it will be removed.
---- The same about /showmon and /closemon commands.
+=== Some refactoring should be perfomed before releasing
+	a new major version and starting to work on the next one.
 
-=== Since there's a nice proc named toggle_monitor that handles
-	checking of monitor window existence and its creating/deleting/showing
-	depending on the result, it would be nice, too, to refactor
-	the procedures that do these check by themselves.
-
+For the next major version:
 === It seems that the plugin becomes too big ;) Most likely, it will be
 	splitted in three parts: bldjid.tcl, visits.tcl and monitor.tcl
 	Each one will be loaded if a corresponding Customize options enables it.

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-04-15 02:06:58 UTC (rev 218)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-04-16 01:15:40 UTC (rev 219)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2009-04-15 v. 0.5.15
+# "Bldjid" plugin for Tkabber. 2009-04-16 v. 0.5.16
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
@@ -22,7 +22,8 @@
 # Set plugin options.
 		set verbosity [list \
 		min [::msgcat::mc "Minimum:\
-		Log each entrance of a user only once per room (less memory used)."]\
+		Log each entrance or nick change of a unique pair nick/jid only once per room\
+		(less memory used)."]\
 		max [::msgcat::mc "Maximum: All entrances of each user will be logged."]]
 
 		set matching_rules [list \
@@ -41,7 +42,7 @@
 		custom::defvar options(filter_admin_rooms) 1 \
 			[::msgcat::mc "This option doesn't prevent logging\
 			in the rooms where you don't have admin privileges\
-			but it helps when showing results."] \
+			but it helps in not showing such results."] \
 			-type boolean -group Bldjid
 
 		custom::defvar options(verbosity_level) min \
@@ -58,23 +59,16 @@
 
 		custom::defvar options(redirect_output) 0 \
 			[::msgcat::mc "Redirect output of /visit* and /bldhelp commands\
-			to a special monitor window."] \
+			to a special monitor window. Use <Ctrl-m> to toggle between monitor states."] \
 			-type boolean -group Bldjid
 
-		custom::defvar options(wmon_timeout) 30 \
-			[::msgcat::mc "Timeout (in seconds) for monitor window described above,\
-			after which it will be closed automatically.\
-			Zero means no timeout.\
-			\nYou can still close the window at any moment by typing /closemon"] \
-			-type integer -group Bldjid
-
 		custom::defvar options(send_chat_messages) 0 \
 			[::msgcat::mc "Generate and send to chats smart system messages\
 			about user entrances (will only work with Minimum verbosity level)."] \
 			-type boolean -group Bldjid
 
 		custom::defvar options(log_length) 0 \
-			[::msgcat::mc "Max length of your JID list for each room. \
+			[::msgcat::mc "Max length of your JID list for each room.\
 			 Zero means unlimited. See README for details."] \
 			-type integer -group Bldjid
 
@@ -82,7 +76,7 @@
 
 proc bldjid::setup_bindings {chatid type} {
 	set w [::chat::input_win $chatid]
-    bind $w <<ToggleMonitor>> [list [namespace current]::toggle_monitor $chatid]
+    bind $w <<ToggleMonitor>> [list [namespace current]::toggle_monitor $chatid 1]
     bind $w <<ToggleMonitor>> +break
 }
 
@@ -162,7 +156,7 @@
 
 	if {!$wordstart} {
 		lappend comps {/bldjid } {/unbldjid } {/banjid } {/amnesty } \
-			{/visitors } {/visited } {/bldhelp } {/closemon } {/clearmon } {/showmon }
+			{/visitors } {/visited } {/bldhelp } {/clearmon }
 	}
 
 	if {$wordstart && [regexp {^/(bldjid|banjid|unban|unbldjid).*} $line]} {
@@ -202,12 +196,8 @@
 		set cmd /visited
 	} elseif {[string match {/bldhelp*} $body]} {
 		set cmd /bldhelp
-	} elseif {[string match {/closemon*} $body]} {
-		set cmd /closemon
 	} elseif {[string match {/clearmon*} $body]} {
 		set cmd /clearmon
-	} elseif {[string match {/showmon*} $body]} {
-		set cmd /showmon
 	} else return
 
 	if {$type != "groupchat"} return
@@ -236,12 +226,8 @@
 		}
 	} elseif {[string equal [string range $body 0 7] "/bldhelp"]} {
 		[namespace current]::help $chatid
-	} elseif {[string equal [string range $body 0 8] "/closemon"]} {
-		[namespace current]::close_monitor $chatid
 	} elseif {[string equal [string range $body 0 8] "/clearmon"]} {
 		[namespace current]::clear_monitor $chatid
-	} elseif {[string equal [string range $body 0 7] "/showmon"]} {
-		[namespace current]::show_monitor $chatid
 	} else {
 		return stop
 	}
@@ -365,11 +351,7 @@
 				incr n
 			}
 			if {$options(enabled) && $options(redirect_output)} {
-				if {![winfo exists [chat::winid $chatid].mon]} {
-					[namespace current]::create_monitor_window $chatid
-				} else {
-					[namespace current]::show_monitor $chatid
-				}
+				[namespace current]::toggle_monitor $chatid 0
 				[namespace current]::add_message_to_monitor $chatid $header
 				[namespace current]::add_message_to_monitor $chatid "[join $msg]\n\n"
 			} elseif {$options(enabled)} {
@@ -432,11 +414,7 @@
 				incr n
 			}
 			if {$options(redirect_output)} {
-				if {![winfo exists [chat::winid $chatid].mon]} {
-					[namespace current]::create_monitor_window $chatid
-				} else {
-					[namespace current]::show_monitor $chatid
-				}
+				[namespace current]::toggle_monitor $chatid 0
 				[namespace current]::add_message_to_monitor $chatid $header
 				[namespace current]::add_message_to_monitor $chatid "[join $msg]\n\n"
 			} else {
@@ -666,22 +644,14 @@
 	\n\nBan in the current room by a number from a list given by a /visit* command.\
 	\n/banjid ?n?\
 	\nSome reason for banning (optional).\
-	\n\nClose the currently opened monitor window:\
-	\n/closemon\
-	\n\nShow monitor window that was already opened and then closed:\
-	\n/showmon\
-	\nUse <Control-m> shortcut to toggle between show and close monitor.
-	\n\nClear the currently opened monitor window:\
+	\n\nClear the current monitor window:\
 	\n/clearmon\
+	\n\nTo toggle between Show and Close monitor states use <Control-m> shortcut.\
 	\n\nSee README file for more information.\
 	\nVisit Tkabber -> Customize -> Plugins -> Bldjid\
 	\nto tune the plugin for your needs."
 	if {$options(redirect_output)} {
-		if {![winfo exists [::chat::winid $chatid].mon]} {
-			[namespace current]::create_monitor_window $chatid
-		} else {
-			[namespace current]::show_monitor $chatid
-		}
+		[namespace current]::toggle_monitor $chatid 0
 		[namespace current]::add_message_to_monitor $chatid $header
 		[namespace current]::add_message_to_monitor $chatid "$msg\n\n"
 	} else {
@@ -749,8 +719,6 @@
 
 # These two next procs are taken from snoopstatus.tcl and modified a bit.
 proc bldjid::create_monitor_window {chatid} {
-    variable options
-
 	set ccw [::chat::winid $chatid]
 	set wmon $ccw.mon
 	frame $wmon
@@ -774,28 +742,8 @@
 	bind $ccw.input <Shift-Meta-Next> +break
 	bind $ccw.input <Shift-Alt-Prior> +break
 	bind $ccw.input <Shift-Alt-Next> +break
-
-	if {$options(wmon_timeout) > 0} {
-		after [expr {1000 * $options(wmon_timeout)}] \
-		[list [namespace current]::close_monitor $chatid]
-	}
 }
 
-proc bldjid::show_monitor {chatid} {
-	variable options
-	set ccw [::chat::winid $chatid]
-	catch {pack info $ccw.mon} res
-	if {[string match "*bad window path name*" $res]} {
-		[namespace current]::create_monitor_window $chatid
-	} elseif {[string match "*isn\'t packed*" $res]} {
-		pack $ccw.mon -side top -fill x
-		if {$options(wmon_timeout) > 0} {
-			after [expr {1000 * $options(wmon_timeout)}] \
-			[list [namespace current]::close_monitor $chatid]
-		}
-	}
-}
-
 proc bldjid::add_message_to_monitor {chatid body} {
 	set ccw [::chat::winid $chatid]
 	set t $ccw.mon.text
@@ -809,13 +757,6 @@
 	$t see end
 }
 
-proc bldjid::close_monitor {chatid} {
-	set ccw [::chat::winid $chatid]
-	if {[winfo exists $ccw.mon]} {
-		pack forget $ccw.mon $ccw.vsb
-	}
-}
-
 proc bldjid::clear_monitor {chatid} {
 	set ccw [::chat::winid $chatid]
 	set t $ccw.mon.text
@@ -826,10 +767,9 @@
 }
 
 # I have doubts if it's OK to use catch results as a condition...
-proc bldjid::toggle_monitor {chatid} {
-	variable options
+proc bldjid::toggle_monitor {chatid toggle} {
 	set ccw [::chat::winid $chatid]
-	if {![catch {pack info $ccw.mon} res]} {
+	if {![catch {pack info $ccw.mon} res] && $toggle} {
 		pack forget $ccw.mon $ccw.vsb
 	} elseif {[string match "*bad window path name*" $res]} {
 		[namespace current]::create_monitor_window $chatid



More information about the Tkabber-dev mailing list