[Tkabber-dev] r1730 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Mar 14 18:59:30 MSK 2009


Author: sergei
Date: 2009-03-14 18:59:30 +0300 (Sat, 14 Mar 2009)
New Revision: 1730

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/general/xcommands.tcl
Log:
	* plugins/general/xcommands.tcl: Added ad-hoc commands submenu to all
	  popup menus.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-03-14 15:30:03 UTC (rev 1729)
+++ trunk/tkabber/ChangeLog	2009-03-14 15:59:30 UTC (rev 1730)
@@ -9,6 +9,9 @@
 	  chat::options(default_message_type) option because messages with no
 	  type attribute must be treated as normal.
 
+	* plugins/general/xcommands.tcl: Added ad-hoc commands submenu to all
+	  popup menus.
+
 2009-03-13  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/captcha.tcl: Renamed from challenge.tcl and added

Modified: trunk/tkabber/plugins/general/xcommands.tcl
===================================================================
--- trunk/tkabber/plugins/general/xcommands.tcl	2009-03-14 15:30:03 UTC (rev 1729)
+++ trunk/tkabber/plugins/general/xcommands.tcl	2009-03-14 15:59:30 UTC (rev 1730)
@@ -458,3 +458,52 @@
 
 ##########################################################################
 
+proc xcommands::add_menu_item {m xlib jid} {
+    set mm [menu $m.commands -tearoff 0]
+
+    $m add cascade -label [::msgcat::mc "Commands"] \
+		   -menu $mm \
+		   -state disabled
+
+    disco::request_items $xlib $jid \
+	-node $::NS(commands) \
+	-cache yes \
+	-command [namespace code [list recv_commands $m $xlib $jid $mm]]
+}
+
+proc xcommands::recv_commands {m xlib jid mm status items} {
+    if {![string equal $status ok]} return
+    if {![winfo exists $m] || ![winfo exists $mm]} return
+
+    set q 0
+    foreach item $items {
+	set jid [::xmpp::xml::getAttr $item jid]
+	if {[string equal $jid ""]} continue
+
+	set node [::xmpp::xml::getAttr $item node]
+	if {[string equal $node ""]} continue
+
+	set name [::xmpp::xml::getAttr $item name]
+	if {[string equal $name ""]} {
+	    set name $node
+	}
+
+	$mm add command -label $name \
+			-command [namespace code [list execute $xlib $jid $node]]
+	set q 1
+    }
+
+    if {$q} {
+	$m entryconfigure [::msgcat::mc "Commands"] -state normal
+    }
+}
+
+hook::add chat_create_user_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add chat_create_conference_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add roster_create_groupchat_user_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add roster_conference_popup_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add roster_service_popup_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add roster_jid_popup_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add message_dialog_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+hook::add search_popup_menu_hook [namespace current]::xcommands::add_menu_item 43.5
+



More information about the Tkabber-dev mailing list