[Tkabber-dev] r168 - trunk/plugins/urgent

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jan 23 05:28:50 MSK 2009


Author: kostix
Date: 2009-01-23 05:28:49 +0300 (Fri, 23 Jan 2009)
New Revision: 168

Added:
   trunk/plugins/urgent/INSTALL
Modified:
   trunk/plugins/urgent/
   trunk/plugins/urgent/urgent.c
   trunk/plugins/urgent/urgent.tcl
Log:
urgent/urgent.tcl:
 * Really fixed getting the right X Window ids for the
   chat windows in the non-tabbed UI mode.
 * Fixed an error in formatting the error message for the
   case of unusable helper program.
 * We now hold the urgency flag status in the per-chat-window
   state to eliminate excessive calls to the helper program
   on message floods and focus flipping (in WMs using
   focus-follows-mouse/sloppy focus policy).
 * The helper program is now called in background.
 * "xwinids" array renamed to "state".
 * Improved descriptions of Customize options.

urgent/urgent.c: Fixed build command example.

urgent/INSTALL: Added installation/building instructions.

Added "urgent" to the list of ignored files.



Property changes on: trunk/plugins/urgent
___________________________________________________________________
Added: svn:ignore
   + urgent


Copied: trunk/plugins/urgent/INSTALL (from rev 166, trunk/plugins/green/INSTALL)
===================================================================
--- trunk/plugins/urgent/INSTALL	                        (rev 0)
+++ trunk/plugins/urgent/INSTALL	2009-01-23 02:28:49 UTC (rev 168)
@@ -0,0 +1,26 @@
+To use this plugin you will need to build the provided
+helper C program, see below.
+
+To install the plugin, as usually, copy this directory
+under the Tkabber's plugins directory ~/.tkabber/plugins
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/urgent/
+  ~/.tkabber/plugins/urgent/urgent.tcl
+
+Ensure you have a C compiler and X11 development files installed
+("gcc" and "libx11-dev" packages on Debian systems),
+then change to the plugin's directory:
+$ cd ~/.tkabber/plugins/urgent/
+and build the helper C program:
+$ gcc -lX11 -o urgent -urgent.c
+
+On older systems you might need to add an appropriate library
+path to the gcc's search path using the -L command line
+parameter, something like
+$ gcc -L/usr/X11R6/lib -lX11 -o urgent -urgent.c
+
+Restart Tkabber, to get the plugin loaded.
+Visit the Cutsomize->Plugins->Urgent group of settings.
+Consult the README file for the details about using this plugin.
+


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

Modified: trunk/plugins/urgent/urgent.c
===================================================================
--- trunk/plugins/urgent/urgent.c	2009-01-22 01:50:53 UTC (rev 167)
+++ trunk/plugins/urgent/urgent.c	2009-01-23 02:28:49 UTC (rev 168)
@@ -2,7 +2,7 @@
  * $Id$
  *
  * Compile with
- *     gcc -L/usr/X11R6/lib -lX11 urgent.c -o urgent
+ *     gcc -lX11 -o urgent urgent.c
  */
 
 #include <stdio.h>

Modified: trunk/plugins/urgent/urgent.tcl
===================================================================
--- trunk/plugins/urgent/urgent.tcl	2009-01-22 01:50:53 UTC (rev 167)
+++ trunk/plugins/urgent/urgent.tcl	2009-01-23 02:28:49 UTC (rev 168)
@@ -2,8 +2,16 @@
 
 namespace eval urgent {
     variable options
+    variable state
 
-    custom::defgroup Urgent [::msgcat::mc "Urgency hinting."] -group Plugins
+    custom::defgroup Urgent \
+	[::msgcat::mc "Urgency hinting.\
+	    This plugin provides an ability to set the so called\
+	    \"urgency flag\" as a special hint to the window manager\
+	    on Tkabber's chat windows when new messages arrive.\
+	    ICCCM compliant window managers may use this hint\
+	    to somehow draw the user's attention to such a window."] \
+	-group Plugins
 
     custom::defvar options(enabled) 1 \
 	[::msgcat::mc "Set the urgency hint on Tkabber's chat\
@@ -23,7 +31,7 @@
 	-group Urgent
 
     custom::defvar options(handle_server_messages) 0 \
-	[::msgcat::mc "React on messages generated by the server"] \
+	[::msgcat::mc "React on messages generated by the server."] \
 	-type boolean \
 	-group Urgent
 }
@@ -77,7 +85,7 @@
 }
 
 proc urgent::xclientwinid {tkwin} {
-    # Parent window id: 0x2e0001e "Tkabber"
+    tkwait visibility $tkwin ;# seems to be needed by xwininfo
     set data [exec xwininfo -children -id [winfo id $tkwin]]
     if {[regexp {Parent window id: (\S+)} $data -> id]} {
 	return $id
@@ -92,34 +100,43 @@
 }
 
 proc urgent::chat_xwinid {chatid} {
-    #xclientwinid [chat::winid $chatid]
-    winfo id [chat::winid $chatid]
+    xclientwinid [chat::winid $chatid]
 }
 
 proc urgent::record_xwinid {chatid _type} {
-    variable xwinids
-    set xwinids($chatid) [xwinid $chatid]
+    variable state
+    set state(xwinid,$chatid) [xwinid $chatid]
+    set state(active,$chatid) false
 }
 
 proc urgent::forget_xwinid {chatid} {
-    variable xwinids
-    unset xwinids($chatid)
+    variable state
+
+    unset state(xwinid,$chatid)
+    unset state(active,$chatid)
 }
 
 proc urgent::set_urgency_hint {chatid} {
     variable options
-    variable xwinids
+    variable state
 
-    exec $options(program) -set $xwinids($chatid)
+    if {!$state(active,$chatid)} {
+	exec $options(program) -set $state(xwinid,$chatid) &
+	set state(active,$chatid) true
+    }
 }
 
 proc urgent::clear_urgency_hint {winid} {
+    set chatid [chat::winid_to_chatid $winid]
+    if {$chatid == ""} return
+
     variable options
-    variable xwinids
-
-    set chatid [chat::winid_to_chatid $winid]
+    variable state
     
-    exec $options(program) -clear $xwinids($chatid)
+    if {$state(active,$chatid)} {
+	set state(active,$chatid) false
+	exec $options(program) -clear $state(xwinid,$chatid) &
+    }
 }
 
 namespace eval urgent {
@@ -132,7 +149,7 @@
     if {![file executable $options(program)]} {
 	puts stderr [::msgcat::mc "Urgency hint setting program \"%s\"\
 	    is not available or not executable by the current user.\
-	    The \"urgent\" plugin is disabled. Consult its README file."
+	    The \"urgent\" plugin is disabled. Consult its README file." \
 	    $options(program)]
 	set options(enabled) 0
     }



More information about the Tkabber-dev mailing list