[Tkabber-dev] r2163 - in trunk/tkabber-plugins: . otr

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Nov 2 10:08:57 MSK 2014


Author: sergei
Date: 2014-11-02 09:08:56 +0300 (Sun, 02 Nov 2014)
New Revision: 2163

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/auth.tcl
   trunk/tkabber-plugins/otr/otr.tcl
Log:
	* otr/otr.tcl, otr/auth.tcl: Got rid of avoidable [eval] calls,
	  deduplicated setting properties for chat and message OTR buttons.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-10-29 13:41:48 UTC (rev 2162)
+++ trunk/tkabber-plugins/ChangeLog	2014-11-02 06:08:56 UTC (rev 2163)
@@ -1,3 +1,8 @@
+2014-11-02  Sergei Golovan <sgolovan at nes.ru>
+
+	* otr/otr.tcl, otr/auth.tcl: Got rid of avoidable [eval] calls,
+	  deduplicated setting properties for chat and message OTR buttons.
+
 2014-07-16  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/otr.tcl: Added scrollbar for the OTR userinfo page. It helps

Modified: trunk/tkabber-plugins/otr/auth.tcl
===================================================================
--- trunk/tkabber-plugins/otr/auth.tcl	2014-10-29 13:41:48 UTC (rev 2162)
+++ trunk/tkabber-plugins/otr/auth.tcl	2014-11-02 06:08:56 UTC (rev 2163)
@@ -299,7 +299,7 @@
 	lappend result1 [lreplace $row 0 0 " [incr i] "]
     }
     $w delete 0 end
-    eval $w insert end $result1
+    $w insert end {*}$result1
 }
 
 proc auth::select_and_popup_menu {w l index} {

Modified: trunk/tkabber-plugins/otr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/otr.tcl	2014-10-29 13:41:48 UTC (rev 2162)
+++ trunk/tkabber-plugins/otr/otr.tcl	2014-11-02 06:08:56 UTC (rev 2163)
@@ -555,8 +555,8 @@
 			 [::msgcat::mc "Question and answer"] \
 			 [::msgcat::mc "Shared secret"] \
 			 [::msgcat::mc "Manual fingerprint verification"]
-    ::trace add variable [namespace current]::ctx(authmethod,$xlib,$jid) \
-	    write [namespace code [list smp_dialog_switch_page $w $xlib $jid]]
+    trace add variable [namespace current]::ctx(authmethod,$xlib,$jid) \
+	  write [namespace code [list smp_dialog_switch_page $w $xlib $jid]]
 	  
     grid $f.choice -row 2 -column 0 -sticky nswe
 
@@ -1158,9 +1158,9 @@
     }
 
     if {[list write [namespace current]::trace] ni
-	    [::trace info variable [namespace current]::ctx(msgstate,$xlib,$jid)]} {
-        ::trace add variable [namespace current]::ctx(msgstate,$xlib,$jid) write \
-			     [namespace current]::trace
+	    [trace info variable [namespace current]::ctx(msgstate,$xlib,$jid)]} {
+        trace add variable [namespace current]::ctx(msgstate,$xlib,$jid) write \
+			   [namespace current]::tracevar
     }
 
     if {$script ne {} && ($script ni $trace(msgstate,$xlib,$jid))} {
@@ -1168,12 +1168,12 @@
     }
 }
 
-proc otr::trace {name1 name2 op} {
+proc otr::tracevar {name1 name2 op} {
     variable trace
 
     set new {}
     foreach script $trace($name2) {
-        if {[catch {eval $script} result]} {
+        if {[catch { {*}$script } result]} {
             debugmsg otr "$result -- $script"
         } else {
             lappend new $script
@@ -1197,12 +1197,10 @@
 		 -bd $::tk_borderwidth \
 		 -state [msgstate:enabled $xlib $jid] \
 		 -command [namespace code [list toggle_session $xlib $jid ""]]]
-    msgstate:trace \
-	"$b configure -image \[[namespace current]::msgstate:icon [list $xlib] [list $jid]\] \
-		      -helptext \[[namespace current]::msgstate:helptext [list $xlib] [list $jid]\] \
-		      -state \[[namespace current]::msgstate:enabled [list $xlib] [list $jid]\]" \
-	$xlib $jid
 
+    msgstate:trace [list [namespace current]::msgstate:button_conf $b $xlib $jid] \
+		   $xlib $jid
+
     pack $bbox -side left -fill x -padx 2m -pady 2m
 }
 
@@ -1219,26 +1217,30 @@
     set jid [chat::get_jid $chatid]
     set cw [chat::winid $chatid]
 
-    Button $cw.status.otrmsgstate \
-	   -relief flat \
-           -image [msgstate:icon $xlib $jid] \
-           -helptype balloon \
-           -helptext [msgstate:helptext $xlib $jid] \
-	   -state [msgstate:enabled $xlib $jid] \
-	   -command [namespace code [list toggle_session $xlib $jid $type]]
+    set b [Button $cw.status.otrmsgstate \
+		  -relief flat \
+		  -image [msgstate:icon $xlib $jid] \
+		  -helptype balloon \
+		  -helptext [msgstate:helptext $xlib $jid] \
+		  -state [msgstate:enabled $xlib $jid] \
+		  -command [namespace code [list toggle_session $xlib $jid $type]]]
 
-    msgstate:trace "$cw.status.otrmsgstate configure \
-		-image \[[namespace current]::msgstate:icon [list $xlib] [list $jid]\] \
-		-helptext \[[namespace current]::msgstate:helptext [list $xlib] [list $jid]\] \
-		-state \[[namespace current]::msgstate:enabled [list $xlib] [list $jid]\]" \
-        $xlib $jid
-    pack $cw.status.otrmsgstate -side left -before $cw.status.mb
+    msgstate:trace [list [namespace current]::msgstate:button_conf $b $xlib $jid] \
+		   $xlib $jid
+
+    pack $b -side left -before $cw.status.mb
 }
 
 hook::add open_chat_post_hook [namespace current]::otr::chat_window_button 55
 
 #############################################################################
 
+proc otr::msgstate:button_conf {b xlib jid} {
+    $b configure -image [msgstate:icon $xlib $jid] \
+		 -helptext [msgstate:helptext $xlib $jid] \
+		 -state [msgstate:enabled $xlib $jid]
+}
+
 proc otr::msgstate:icon {xlib jid} {
     lindex [list otr/notprivate \
 		 otr/unverified \



More information about the Tkabber-dev mailing list