summaryrefslogtreecommitdiffstats
path: root/generic/tkMenubutton.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-08-29 23:22:24 (GMT)
committerhobbs <hobbs>2001-08-29 23:22:24 (GMT)
commit00c37b69abf98dc5d13eb125c8b3fea81ff4818b (patch)
treeb404a0f0e067dd1a6d688e026ad74d4ead531b81 /generic/tkMenubutton.c
parentb9f65c470bb6ee61b61c544c6480560787b6edaf (diff)
downloadtk-00c37b69abf98dc5d13eb125c8b3fea81ff4818b.zip
tk-00c37b69abf98dc5d13eb125c8b3fea81ff4818b.tar.gz
tk-00c37b69abf98dc5d13eb125c8b3fea81ff4818b.tar.bz2
* tests/config.test: added config-14.1 to test namespace import
evaluation of widgets. * generic/tkButton.c (ButtonCreate): * generic/tkFrame.c (CreateFrame): * generic/tkMenubutton.c (Tk_MenubuttonObjCmd): * generic/tkPlace.c (Tk_PlaceObjCmd): * generic/tkScale.c (Tk_ScaleObjCmd): * generic/tkMessage.c (Tk_MessageObjCmd): * generic/tkEntry.c (Tk_EntryObjCmd, Tk_SpinboxObjCmd): * generic/tkSquare.c (SquareObjCmd): redid the handling of optionTables in widgets to allow them to be imported into other namespaces. [Bug #456632]
Diffstat (limited to 'generic/tkMenubutton.c')
-rw-r--r--generic/tkMenubutton.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index a685f9d..815837f 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.6 2001/05/21 14:07:33 tmh Exp $
+ * RCS: @(#) $Id: tkMenubutton.c,v 1.7 2001/08/29 23:22:24 hobbs Exp $
*/
#include "tkMenubutton.h"
@@ -205,8 +205,7 @@ static void DestroyMenuButton _ANSI_ARGS_((char *memPtr));
int
Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Either NULL or pointer to
- * option table. */
+ ClientData clientData; /* NULL. */
Tcl_Interp *interp; /* Current interpreter. */
int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument objects. */
@@ -215,25 +214,6 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
Tk_OptionTable optionTable;
Tk_Window tkwin;
- optionTable = (Tk_OptionTable) clientData;
- if (optionTable == NULL) {
- Tcl_CmdInfo info;
- char *name;
-
- /*
- * We haven't created the option table for this widget class
- * yet. Do it now and save the table as the clientData for
- * the command, so we'll have access to it in future
- * invocations of the command.
- */
-
- optionTable = Tk_CreateOptionTable(interp, optionSpecs);
- name = Tcl_GetString(objv[0]);
- Tcl_GetCommandInfo(interp, name, &info);
- info.objClientData = (ClientData) optionTable;
- Tcl_SetCommandInfo(interp, name, &info);
- }
-
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?");
return TCL_ERROR;
@@ -243,12 +223,19 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
* Create the new window.
*/
- tkwin = Tk_CreateWindowFromPath(interp,
- Tk_MainWindow(interp), Tcl_GetString(objv[1]), (char *) NULL);
+ tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
+ Tcl_GetString(objv[1]), (char *) NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
+ /*
+ * Create the option table for this widget class. If it has already
+ * been created, the cached pointer will be returned.
+ */
+
+ optionTable = Tk_CreateOptionTable(interp, optionSpecs);
+
Tk_SetClass(tkwin, "Menubutton");
mbPtr = TkpCreateMenuButton(tkwin);
@@ -313,8 +300,7 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
ExposureMask|StructureNotifyMask|FocusChangeMask,
MenuButtonEventProc, (ClientData) mbPtr);
- if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin)
- != TCL_OK) {
+ if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(mbPtr->tkwin);
return TCL_ERROR;
}
@@ -324,8 +310,7 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv)
return TCL_ERROR;
}
- Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(mbPtr->tkwin),
- -1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(mbPtr->tkwin), -1);
return TCL_OK;
}