summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2007-12-13 23:13:51 (GMT)
committerhobbs <hobbs>2007-12-13 23:13:51 (GMT)
commit19a521ebeeae4be336fe451eee6da677114ecc8a (patch)
tree453f8a4c1e37ddb4dc0b46975cbe4518959269c6 /generic
parentc99cffa817d24768f82f157cfe08df35925c7f37 (diff)
downloadtk-19a521ebeeae4be336fe451eee6da677114ecc8a.zip
tk-19a521ebeeae4be336fe451eee6da677114ecc8a.tar.gz
tk-19a521ebeeae4be336fe451eee6da677114ecc8a.tar.bz2
* generic/tkMenubutton.c (ConfigureMenuButton): trace the
-textvariable even if an image exists as it may use -compound.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkMenubutton.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index 000b4f9..6ee966e 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMenubutton.c,v 1.12.2.1 2003/11/17 23:29:36 hobbs Exp $
+ * RCS: @(#) $Id: tkMenubutton.c,v 1.12.2.2 2007/12/13 23:13:52 hobbs Exp $
*/
#include "tkMenubutton.h"
@@ -620,32 +620,28 @@ ConfigureMenuButton(interp, mbPtr, objc, objv)
Tk_FreeSavedOptions(&savedOptions);
}
- if ((mbPtr->image == NULL) && (mbPtr->bitmap == None)
- && (mbPtr->textVarName != NULL)) {
-
- /*
- * The menubutton displays the value of a variable.
- * Set up a trace to watch for any changes in it, create
- * the variable if it doesn't exist, and fetch its
- * current value.
- */
-
- CONST char *value;
-
- value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
- TCL_GLOBAL_ONLY);
- } else {
- if (mbPtr->text != NULL) {
- ckfree(mbPtr->text);
- }
- mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(mbPtr->text, value);
- }
- Tcl_TraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
+ if (mbPtr->textVarName != NULL) {
+ /*
+ * If no image or -compound is used, display the value of a variable.
+ * Set up a trace to watch for any changes in it, create the variable
+ * if it doesn't exist, and fetch its current value.
+ */
+ CONST char *value;
+
+ value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
+ if (value == NULL) {
+ Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
+ TCL_GLOBAL_ONLY);
+ } else {
+ if (mbPtr->text != NULL) {
+ ckfree(mbPtr->text);
+ }
+ mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
+ strcpy(mbPtr->text, value);
+ }
+ Tcl_TraceVar(interp, mbPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuButtonTextVarProc, (ClientData) mbPtr);
}
TkMenuButtonWorldChanged((ClientData) mbPtr);