[Tkabber-dev] r863 - in trunk/tkabber: . ifacetk

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jan 5 22:21:12 MSK 2007


Author: sergei
Date: 2007-01-05 22:21:09 +0300 (Fri, 05 Jan 2007)
New Revision: 863

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/gpgme.tcl
   trunk/tkabber/ifacetk/iface.tcl
Log:
	* ifacetk/iface.tcl, gpgme.tcl: Removed path argument from
	  ifacetk::set_toolbar_icon and ifacetk::set_toolbar_icon procedures.
	  ifacetk::set_toolbar_icon now returns current icon index, which
	  can be used in ifacetk::set_toolbar_icon.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-01-05 17:14:40 UTC (rev 862)
+++ trunk/tkabber/ChangeLog	2007-01-05 19:21:09 UTC (rev 863)
@@ -17,6 +17,11 @@
 
 	* plugins/general/tkcon.tcl: Moved Tkcon menu item to Help submenu.
 
+	* ifacetk/iface.tcl, gpgme.tcl: Removed path argument from
+	  ifacetk::set_toolbar_icon and ifacetk::set_toolbar_icon procedures.
+	  ifacetk::set_toolbar_icon now returns current icon index, which
+	  can be used in ifacetk::set_toolbar_icon.
+
 2007-01-02  Sergei Golovan  <sgolovan at nes.ru>
 
 	* userinfo.tcl, chats.tcl: Added empty item to comboboxes in show

Modified: trunk/tkabber/gpgme.tcl
===================================================================
--- trunk/tkabber/gpgme.tcl	2007-01-05 17:14:40 UTC (rev 862)
+++ trunk/tkabber/gpgme.tcl	2007-01-05 19:21:09 UTC (rev 863)
@@ -1429,25 +1429,19 @@
 ###############################################################################
 
 proc ::ssj::toolbar {} {
-    set mf .mainframe
-    set toolbar [$mf gettoolbar 0]
-    set bbox $toolbar.bbox
-
-    ifacetk::add_toolbar_button $bbox \
-	[signed:icon] \
-	::ssj::sign:toggleP \
-	[::msgcat::mc "Toggle signing"]
+    set idx [ifacetk::add_toolbar_button \
+		 [signed:icon] \
+		 ::ssj::sign:toggleP \
+		 [::msgcat::mc "Toggle signing"]]
     signed:trace \
-	[list ifacetk::set_toolbar_icon $bbox [$bbox index end] \
-	      ::ssj::signed:icon]
+	[list ifacetk::set_toolbar_icon $idx ::ssj::signed:icon]
 
-    ifacetk::add_toolbar_button $bbox \
-	[encrypted:icon] \
-	::ssj::encrypt:toggleP \
-	[::msgcat::mc "Toggle encryption (when possible)"]
+    set idx [ifacetk::add_toolbar_button \
+		 [encrypted:icon] \
+		 ::ssj::encrypt:toggleP \
+		 [::msgcat::mc "Toggle encryption (when possible)"]]
     encrypted:trace \
-	[list ifacetk::set_toolbar_icon $bbox [$bbox index end] \
-	      ::ssj::encrypted:icon]
+	[list ifacetk::set_toolbar_icon $idx ::ssj::encrypted:icon]
 }
 
 hook::add finload_hook ::ssj::toolbar

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2007-01-05 17:14:40 UTC (rev 862)
+++ trunk/tkabber/ifacetk/iface.tcl	2007-01-05 19:21:09 UTC (rev 863)
@@ -573,12 +573,38 @@
 hook::add connected_hook [namespace current]::ifacetk::update_ssl_ind
 hook::add disconnected_hook [namespace current]::ifacetk::update_ssl_ind
 
-proc ifacetk::add_toolbar_button {path icon command helptext} {
-    $path add -image $icon \
-	-highlightthickness 0 -takefocus 0 -relief link -bd $::tk_borderwidth \
-	-padx 1 -pady 1 -command $command -helptext $helptext
+###############################################################################
+
+proc ifacetk::add_toolbar_button {icon command helptext} {
+    if {[catch {set bbox [.mainframe gettoolbar 0].bbox}] || \
+	    ![winfo exists $bbox]} {
+	return 0
+    }
+    $bbox add -image $icon \
+	      -highlightthickness 0 \
+	      -takefocus 0 \
+	      -relief link \
+	      -bd $::tk_borderwidth \
+	      -padx 1 \
+	      -pady 1 \
+	      -command $command \
+	      -helptext $helptext
+    return [$bbox index end]
 }
 
+###############################################################################
+
+proc ifacetk::set_toolbar_icon {index script args} {
+    if {[catch {set bbox [.mainframe gettoolbar 0].bbox}] || \
+	    ![winfo exists $bbox]} {
+	return
+    }
+    set image [eval $script]
+    $bbox itemconfigure $index -image $image
+}
+
+###############################################################################
+
 proc ifacetk::online_icon {args} {
     if {$roster::show_only_online} {
 	return toolbar/show-online
@@ -587,14 +613,6 @@
     }
 }
 
-proc ifacetk::set_toolbar_icon {path index script args} {
-    if {![winfo exists $path]} {
-	return
-    }
-    set image [eval $script]
-    $path itemconfigure $index -image $image
-}
-
 proc ifacetk::create_main_window {} {
     global usetabbar
     global user_status_list
@@ -632,18 +650,18 @@
 
     set bbox [ButtonBox [$mf addtoolbar].bbox -spacing 0 -padx 1 -pady 1]
 
-    add_toolbar_button $bbox toolbar/add-user {message::send_subscribe_dialog ""} \
+    add_toolbar_button toolbar/add-user {message::send_subscribe_dialog ""} \
 	[::msgcat::mc "Add new user..."]
-    add_toolbar_button $bbox toolbar/disco {disco::browser::open_win ""} \
+    add_toolbar_button toolbar/disco {disco::browser::open_win ""} \
 	[::msgcat::mc "Service Discovery"]
-    add_toolbar_button $bbox toolbar/join-conference join_group_dialog \
+    add_toolbar_button toolbar/join-conference join_group_dialog \
 	[::msgcat::mc "Join group..."]
 
-    add_toolbar_button $bbox [ifacetk::online_icon] \
-	[namespace current]::roster::switch_only_online \
-	[::msgcat::mc "Toggle showing offline users"]
+    set idx [add_toolbar_button [ifacetk::online_icon] \
+		 [namespace current]::roster::switch_only_online \
+		 [::msgcat::mc "Toggle showing offline users"]]
     trace variable [namespace current]::roster::show_only_online w \
-	[list [namespace current]::set_toolbar_icon $bbox [$bbox index end] \
+	[list [namespace current]::set_toolbar_icon $idx \
 	      [namespace current]::online_icon]
 
     pack $bbox -side left -anchor w



More information about the Tkabber-dev mailing list