aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkostix <kostix@cc602e41-bd33-0410-9637-a208f32f1443>2009-01-22 01:50:53 +0000
committerkostix <kostix@cc602e41-bd33-0410-9637-a208f32f1443>2009-01-22 01:50:53 +0000
commite6955f3fb7cfbfb288fced60b6395bbf4e4a5c1f (patch)
treea1c1fdfe3665383a0f57c29acd46aab7daa9c2cd
parentcf928a9b4091b18ecf76aeaa4d2c4baed6364acd (diff)
downloadurgent-e6955f3fb7cfbfb288fced60b6395bbf4e4a5c1f.tar.gz
urgent-e6955f3fb7cfbfb288fced60b6395bbf4e4a5c1f.tar.xz
urgent-e6955f3fb7cfbfb288fced60b6395bbf4e4a5c1f.zip
urgent/urgent.tcl:
* Checking of tabbed UI mode is moved to finload hook. * Implemented cleanup of xwinids on closing of chat windows. * Misc. renaming and rearranging of functions. * Failure to parse `xwininfo` output now triggers an error. * Changed getting of X Window id for chat windows in non-tabbed UI mode. Now it doesn't pick up the root window but the id anyway seems wrong. git-svn-id: http://svn.xmpp.ru/repos/tkabber-3rd-party/trunk/plugins/urgent@167 cc602e41-bd33-0410-9637-a208f32f1443
-rw-r--r--urgent.tcl66
1 files changed, 39 insertions, 27 deletions
diff --git a/urgent.tcl b/urgent.tcl
index af59ecc..aecf9d9 100644
--- a/urgent.tcl
+++ b/urgent.tcl
@@ -1,6 +1,8 @@
# $Id$
namespace eval urgent {
+ variable options
+
custom::defgroup Urgent [::msgcat::mc "Urgency hinting."] -group Plugins
custom::defvar options(enabled) 1 \
@@ -38,18 +40,18 @@ proc urgent::chat_message_notify {chatid from type body extras} {
groupchat {
if {[string equal [chat::get_jid $chatid] $from]} {
if {$options(handle_server_messages)} {
- notify $chatid
+ set_urgency_hint $chatid
}
} else {
set mynick [chat::get_nick [chat::get_xlib $chatid] \
[chat::our_jid $chatid] $type]
if {[check_message $mynick $body]} {
if {$options(handle_personal_messages)} {
- notify $chatid
+ set_urgency_hint $chatid
}
} else {
if {$options(handle_normal_messages)} {
- notify $chatid
+ set_urgency_hint $chatid
}
}
}
@@ -66,42 +68,49 @@ proc urgent::chat_message_notify {chatid from type body extras} {
}
if {$from == "" && $options(handle_server_messages)} {
- notify $chatid
+ set_urgency_hint $chatid
} elseif {$options(handle_personal_messages)} {
- notify $chatid
+ set_urgency_hint $chatid
}
}
}
}
-proc urgent::notify {chatid} {
- variable options
- variable xwinids
-
- exec $options(program) -set $xwinids($chatid)
-}
-
-proc urgent::xwinid {win} {
+proc urgent::xclientwinid {tkwin} {
# Parent window id: 0x2e0001e "Tkabber"
- set data [exec xwininfo -children -id [winfo id $win]]
+ set data [exec xwininfo -children -id [winfo id $tkwin]]
if {[regexp {Parent window id: (\S+)} $data -> id]} {
return $id
} else {
- return ""
+ error [format "Failed to parse `xwininfo` output\
+ for Tk window \"%s\"" $tkwin]
}
}
-proc urgent::root_winid {xwinid _chatid} {
+proc urgent::root_xwinid {xwinid _chatid} {
return $xwinid
}
-proc urgent::chat_winid {chatid} {
- xwinid [winfo id [chat::winid $chatid]]
+proc urgent::chat_xwinid {chatid} {
+ #xclientwinid [chat::winid $chatid]
+ winfo id [chat::winid $chatid]
}
proc urgent::record_xwinid {chatid _type} {
variable xwinids
- set xwinids($chatid) [winid $chatid]
+ set xwinids($chatid) [xwinid $chatid]
+}
+
+proc urgent::forget_xwinid {chatid} {
+ variable xwinids
+ unset xwinids($chatid)
+}
+
+proc urgent::set_urgency_hint {chatid} {
+ variable options
+ variable xwinids
+
+ exec $options(program) -set $xwinids($chatid)
}
proc urgent::clear_urgency_hint {winid} {
@@ -122,21 +131,24 @@ namespace eval urgent {
}
if {![file executable $options(program)]} {
puts stderr [::msgcat::mc "Urgency hint setting program \"%s\"\
- is not available or not executed by the current user.\
+ is not available or not executable by the current user.\
The \"urgent\" plugin is disabled. Consult its README file."
$options(program)]
set options(enabled) 0
}
- if {$::ifacetk::options(use_tabbar)} {
- interp alias {} [namespace current]::winid \
- {} [namespace current]::root_winid [xwinid .]
- } else {
- interp alias {} [namespace current]::winid \
- {} [namespace current]::chat_winid
- }
+ hook::add finload_hook [namespace code {
+ if {$::ifacetk::options(use_tabbar)} {
+ interp alias {} [namespace current]::xwinid \
+ {} [namespace current]::root_xwinid [xclientwinid .]
+ } else {
+ interp alias {} [namespace current]::xwinid \
+ {} [namespace current]::chat_xwinid
+ }
+ }]
hook::add open_chat_post_hook [namespace current]::record_xwinid 40
+ hook::add close_chat_post_hook [namespace current]::forget_xwinid
hook::add draw_message_hook [namespace current]::chat_message_notify 19
hook::add got_focus_hook [namespace current]::clear_urgency_hint
}