From 1c9e1b1da7a3ae2a5f76069e06bdc0d88767749a Mon Sep 17 00:00:00 2001 From: kostix Date: Fri, 23 Jan 2009 02:28:49 +0000 Subject: 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. git-svn-id: http://svn.xmpp.ru/repos/tkabber-3rd-party/trunk/plugins/urgent@168 cc602e41-bd33-0410-9637-a208f32f1443 --- INSTALL | 26 ++++++++++++++++++++++++++ urgent.c | 2 +- urgent.tcl | 49 +++++++++++++++++++++++++++++++++---------------- 3 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 INSTALL diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..7d7d240 --- /dev/null +++ b/INSTALL @@ -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. + diff --git a/urgent.c b/urgent.c index 42f01ad..c74192f 100644 --- a/urgent.c +++ b/urgent.c @@ -2,7 +2,7 @@ * $Id$ * * Compile with - * gcc -L/usr/X11R6/lib -lX11 urgent.c -o urgent + * gcc -lX11 -o urgent urgent.c */ #include diff --git a/urgent.tcl b/urgent.tcl index aecf9d9..d7996c1 100644 --- a/urgent.tcl +++ b/urgent.tcl @@ -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 @@ namespace eval urgent { -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::chat_message_notify {chatid from type body extras} { } 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::root_xwinid {xwinid _chatid} { } 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} { - variable options - variable xwinids - set chatid [chat::winid_to_chatid $winid] + if {$chatid == ""} return + + variable options + 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 @@ namespace eval urgent { 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 } -- cgit v1.2.3