[Tkabber-dev] r316 - trunk/plugins/avatarcache

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Mar 12 00:02:41 MSK 2010


Author: Hermitifier
Date: 2010-03-12 00:02:41 +0300 (Fri, 12 Mar 2010)
New Revision: 316

Modified:
   trunk/plugins/avatarcache/avatarcache.tcl
Log:
Reorganise 'Avatar' context menu

Modified: trunk/plugins/avatarcache/avatarcache.tcl
===================================================================
--- trunk/plugins/avatarcache/avatarcache.tcl	2010-03-08 08:49:46 UTC (rev 315)
+++ trunk/plugins/avatarcache/avatarcache.tcl	2010-03-11 21:02:41 UTC (rev 316)
@@ -324,14 +324,26 @@
 proc avatarcache::add_assign_menu_item {m xlib jid} {
     variable assigned_hashes
     set jid [::xmpp::jid::stripResource $jid]
-    $m add command -label [::msgcat::mc "Assign custom avatar"] \
-		   -command [namespace code [list assign_by_hand $jid]]
-    set state [expr {[info exists assigned_hashes($jid)] ? "normal" : "disabled"}]
-    $m add command -label [::msgcat::mc "Unassign custom avatar"] \
-		   -command [namespace code [list unassign_by_hand $jid]] \
-		   -state $state
-    set state [expr {([info exists assigned_hashes($jid)] && $assigned_hashes($jid) == "") ? "disabled" : "normal"}]
-    $m add command -label [::msgcat::mc "Ignore avatar"] \
-		   -command [namespace code [list hide_avatar $jid]] \
-		   -state $state
+
+    set mm [menu $m.avatars -tearoff 0]
+    $m add cascade -label [::msgcat::mc "Avatar"] \
+		   -menu $mm
+
+    set ignore 1
+    $mm add command -label [::msgcat::mc "Assign custom"] \
+		    -command [namespace code [list assign_by_hand $jid]]
+    if {[info exists assigned_hashes($jid)]} {
+	if {$assigned_hashes($jid) == ""} {
+	    set unassign_label [::msgcat::mc "Unignore"]
+	    set ignore 0
+	} {
+	    set unassign_label [::msgcat::mc "Unassign custom"]
+	}
+	$mm add command -label $unassign_label \
+			-command [namespace code [list unassign_by_hand $jid]]
+    }
+    if {$ignore} {
+	$mm add command -label [::msgcat::mc "Ignore"] \
+			-command [namespace code [list hide_avatar $jid]]
+    }
 }



More information about the Tkabber-dev mailing list