From 2130b783d0d6792df2714ba0184d7314b635968c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 5 Mar 2021 14:21:43 +0000 Subject: Attempt to make more ttk testcases pass on github actions, by backporting some textual changes from 8.6 --- .github/workflows/mac-build.yml | 4 +- generic/ttk/ttkNotebook.c | 240 ++++++++++++++++++++-------------------- generic/ttk/ttkTreeview.c | 28 ++--- generic/ttk/ttkWidget.c | 4 +- tests/ttk/notebook.test | 2 +- tests/ttk/treeview.test | 4 +- tests/ttk/ttk.test | 4 +- 7 files changed, 145 insertions(+), 141 deletions(-) diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 70d31f2..bc6ffc7 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -28,7 +28,7 @@ jobs: USE_XVFB: ${{ contains(matrix.options, '--disable-aqua') }} - name: Add Tcl run: | - brew install tcl-tk + brew install tcl-tk - name: Add X11 if: ${{ env.USE_XVFB }} # This involves black magic @@ -38,7 +38,7 @@ jobs: - name: Configure (symbols=${{ matrix.symbols }} ${{matrix.options }}) # Note that macOS is always a 64 bit platform run: | - ./configure --enable-64bit --with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include ${CFGOPT} "--prefix=$HOME/install" || { + ./configure --enable-64bit --enable-framework --with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include ${CFGOPT} "--prefix=$HOME/install" || { cat config.log echo "::error::Failure during Configure" exit 1 diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index dd757cb..1dc0ec0 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -57,20 +57,20 @@ typedef struct * relevant to the tab. * * PaneOptionSpecs includes additional options for child window placement - * and is used to configure the slave. + * and is used to configure the content window. */ static Tk_OptionSpec TabOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-state", "", "", "normal", -1,Tk_Offset(Tab,state), - 0,(ClientData)TabStateStrings,0 }, + 0, (void *)TabStateStrings, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", Tk_Offset(Tab,textObj), -1, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/, Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - "none", Tk_Offset(Tab,compoundObj), -1, - 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED }, + NULL, Tk_Offset(Tab,compoundObj), -1, + TK_OPTION_NULL_OK, (void *)ttkCompoundStrings, GEOMETRY_CHANGED }, {TK_OPTION_INT, "-underline", "underline", "Underline", "-1", Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } @@ -102,7 +102,7 @@ typedef struct int activeIndex; /* index of currently active tab */ Ttk_Layout tabLayout; /* Sublayout for tabs */ - Ttk_Box clientArea; /* Where to pack slave widgets */ + Ttk_Box clientArea; /* Where to pack content widgets */ } NotebookPart; typedef struct @@ -191,14 +191,14 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle) * +++ Tab management. */ -static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow) +static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window window) { Tk_OptionTable optionTable = nb->notebook.paneOptionTable; - void *record = ckalloc(sizeof(Tab)); + Tab *record = (Tab *)ckalloc(sizeof(Tab)); memset(record, 0, sizeof(Tab)); - if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) { - ckfree(record); + if (Tk_InitOptions(interp, (char *)record, optionTable, window) != TCL_OK) { + ckfree((ClientData)record); return NULL; } @@ -213,7 +213,7 @@ static void DestroyTab(Notebook *nb, Tab *tab) } static int ConfigureTab( - Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window slaveWindow, + Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Ttk_Sticky sticky = tab->sticky; @@ -221,8 +221,8 @@ static int ConfigureTab( Tk_SavedOptions savedOptions; int mask = 0; - if (Tk_SetOptions(interp, (ClientData)tab, nb->notebook.paneOptionTable, - objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) + if (Tk_SetOptions(interp, (void *)tab, nb->notebook.paneOptionTable, + objc, objv, window, &savedOptions, &mask) != TCL_OK) { return TCL_ERROR; } @@ -234,7 +234,7 @@ static int ConfigureTab( { goto error; } - if (Ttk_GetPaddingFromObj(interp, slaveWindow, tab->paddingObj, &padding) + if (Ttk_GetPaddingFromObj(interp, window, tab->paddingObj, &padding) != TCL_OK) { goto error; @@ -262,7 +262,7 @@ static int IdentifyTab(Notebook *nb, int x, int y) { int index; for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,index); if ( tab->state != TAB_STATE_HIDDEN && Ttk_BoxContains(tab->parcel, x,y)) { @@ -294,7 +294,7 @@ static void ActivateTab(Notebook *nb, int index) static Ttk_State TabState(Notebook *nb, int index) { Ttk_State state = nb->core.state; - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); + Tab *itab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); if (index == nb->notebook.currentIndex) { state |= TTK_STATE_SELECTED; @@ -306,12 +306,12 @@ static Ttk_State TabState(Notebook *nb, int index) state |= TTK_STATE_ACTIVE; } if (index == 0) { - state |= TTK_STATE_USER1; + state |= TTK_STATE_USER1; } if (index == Ttk_NumberSlaves(nb->notebook.mgr) - 1) { - state |= TTK_STATE_USER2; + state |= TTK_STATE_USER2; } - if (tab->state == TAB_STATE_DISABLED) { + if (itab->state == TAB_STATE_DISABLED) { state |= TTK_STATE_DISABLED; } @@ -341,7 +341,7 @@ static void TabrowSize( int i; for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); Ttk_State tabState = TabState(nb,i); Ttk_RebindSublayout(tabLayout, tab); @@ -364,13 +364,13 @@ static void TabrowSize( * * Total height is tab height + client area height + pane internal padding * Total width is max(client width, tab width) + pane internal padding - * Client area size determined by max size of slaves, + * Client area size determined by max size of content windows, * overridden by -width and/or -height if nonzero. */ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) { - Notebook *nb = clientData; + Notebook *nb = (Notebook *)clientData; NotebookStyle nbstyle; Ttk_Padding padding; Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client"); @@ -381,18 +381,18 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) NotebookStyleOptions(nb, &nbstyle); - /* Compute max requested size of all slaves: + /* Compute max requested size of all content windows: */ for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { - Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, i); - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); - int slaveWidth - = Tk_ReqWidth(slaveWindow) + Ttk_PaddingWidth(tab->padding); - int slaveHeight - = Tk_ReqHeight(slaveWindow) + Ttk_PaddingHeight(tab->padding); + Tk_Window window = Ttk_SlaveWindow(nb->notebook.mgr, i); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); + int width + = Tk_ReqWidth(window) + Ttk_PaddingWidth(tab->padding); + int height + = Tk_ReqHeight(window) + Ttk_PaddingHeight(tab->padding); - clientWidth = MAX(clientWidth, slaveWidth); - clientHeight = MAX(clientHeight, slaveHeight); + clientWidth = MAX(clientWidth, width); + clientHeight = MAX(clientHeight, height); } /* Client width/height overridable by widget options: @@ -467,7 +467,7 @@ static void SqueezeTabs( if (remainder < 0) { remainder += nTabs; --delta; } for (i = 0; i < nTabs; ++i) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,i); int adj = delta + (i < remainder) + slack; if (tab->width + adj >= minTabWidth) { @@ -492,7 +492,7 @@ static void PlaceTabs( int i; for (i = 0; i < nTabs; ++i) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i); Ttk_State tabState = TabState(nb, i); if (tab->state != TAB_STATE_HIDDEN) { @@ -516,11 +516,11 @@ static void PlaceTabs( * Computes notebook layout and places tabs. * * Side effects: - * Sets clientArea, used to place slave panes. + * Sets clientArea, used to place panes. */ static void NotebookDoLayout(void *recordPtr) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Tk_Window nbwin = nb->core.tkwin; Ttk_Box cavity = Ttk_WinBox(nbwin); int tabrowWidth = 0, tabrowHeight = 0; @@ -567,18 +567,18 @@ static void NotebookDoLayout(void *recordPtr) /* * NotebookPlaceSlave -- * Set the position and size of a child widget - * based on the current client area and slave options: + * based on the current client area and content window options: */ -static void NotebookPlaceSlave(Notebook *nb, int slaveIndex) +static void NotebookPlaceSlave(Notebook *nb, int index) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex); - Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, slaveIndex); - Ttk_Box slaveBox = + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); + Tk_Window window = Ttk_SlaveWindow(nb->notebook.mgr, index); + Ttk_Box box = Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding), - Tk_ReqWidth(slaveWindow), Tk_ReqHeight(slaveWindow),tab->sticky); + Tk_ReqWidth(window), Tk_ReqHeight(window),tab->sticky); - Ttk_PlaceSlave(nb->notebook.mgr, slaveIndex, - slaveBox.x, slaveBox.y, slaveBox.width, slaveBox.height); + Ttk_PlaceSlave(nb->notebook.mgr, index, + box.x, box.y, box.width, box.height); } /* NotebookPlaceSlaves -- @@ -586,7 +586,7 @@ static void NotebookPlaceSlave(Notebook *nb, int slaveIndex) */ static void NotebookPlaceSlaves(void *recordPtr) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; int currentIndex = nb->notebook.currentIndex; if (currentIndex >= 0) { NotebookDoLayout(nb); @@ -600,7 +600,7 @@ static void NotebookPlaceSlaves(void *recordPtr) */ static void SelectTab(Notebook *nb, int index) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); int currentIndex = nb->notebook.currentIndex; if (index == currentIndex) { @@ -621,9 +621,12 @@ static void SelectTab(Notebook *nb, int index) Ttk_UnmapSlave(nb->notebook.mgr, currentIndex); } - NotebookPlaceSlave(nb, index); - + /* Must be set before calling NotebookPlaceSlave(), otherwise it may + * happen that NotebookPlaceSlaves(), triggered by an interveaning + * geometry request, will swap to old index. */ nb->notebook.currentIndex = index; + + NotebookPlaceSlave(nb, index); TtkRedisplayWidget(&nb->core); TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged"); @@ -642,7 +645,7 @@ static int NextTab(Notebook *nb, int index) /* Scan forward for following usable tab: */ for (nextIndex = index + 1; nextIndex < nTabs; ++nextIndex) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex); if (tab->state == TAB_STATE_NORMAL) { return nextIndex; } @@ -651,7 +654,7 @@ static int NextTab(Notebook *nb, int index) /* Not found -- scan backwards. */ for (nextIndex = index - 1; nextIndex >= 0; --nextIndex) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex); if (tab->state == TAB_STATE_NORMAL) { return nextIndex; } @@ -688,12 +691,12 @@ static void SelectNearestTab(Notebook *nb) /* TabRemoved -- GM SlaveRemoved hook. * Select the next tab if the current one is being removed. - * Adjust currentIndex to account for removed slave. + * Adjust currentIndex to account for removed content window. */ static void TabRemoved(void *managerData, int index) { - Notebook *nb = managerData; - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); + Notebook *nb = (Notebook *)managerData; + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); @@ -718,15 +721,15 @@ static int TabRequest(void *managerData, int index, int width, int height) */ static int AddTab( Tcl_Interp *interp, Notebook *nb, - int destIndex, Tk_Window slaveWindow, + int destIndex, Tk_Window window, int objc, Tcl_Obj *const objv[]) { Tab *tab; - if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) { + if (!Ttk_Maintainable(interp, window, nb->core.tkwin)) { return TCL_ERROR; } #if 0 /* can't happen */ - if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) { + if (Ttk_SlaveIndex(nb->notebook.mgr, window) >= 0) { Tcl_AppendResult(interp, Tk_PathName(slaveWindow), " already added", NULL); @@ -736,16 +739,16 @@ static int AddTab( /* Create and insert tab. */ - tab = CreateTab(interp, nb, slaveWindow); + tab = CreateTab(interp, nb, window); if (!tab) { return TCL_ERROR; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc, objv) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc, objv) != TCL_OK) { DestroyTab(nb, tab); return TCL_ERROR; } - Ttk_InsertSlave(nb->notebook.mgr, destIndex, slaveWindow, tab); + Ttk_InsertSlave(nb->notebook.mgr, destIndex, window, tab); /* Adjust indices and/or autoselect first tab: */ @@ -780,7 +783,7 @@ static const int NotebookEventMask ; static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr) { - Notebook *nb = clientData; + Notebook *nb = (Notebook *)clientData; if (eventPtr->type == DestroyNotify) { /* Remove self */ Tk_DeleteEventHandler(nb->core.tkwin, @@ -804,7 +807,7 @@ static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr) * + positional specifications @x,y, * + "current", * + numeric indices [0..nTabs], - * + slave window names + * + content window names * * Stores index of specified tab in *index_rtn, -1 if not found. * @@ -835,7 +838,7 @@ static int FindTabIndex( return TCL_OK; } - /* ... or integer index or slave window name: + /* ... or integer index or content window name: */ if (Ttk_GetSlaveIndexFromObj( interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK) @@ -877,10 +880,9 @@ static int GetTabIndex( static int NotebookAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; - int index = Ttk_NumberSlaves(nb->notebook.mgr); - Tk_Window slaveWindow; - int slaveIndex; + Notebook *nb = (Notebook *)recordPtr; + Tk_Window window; + int index; Tab *tab; if (objc <= 2 || objc % 2 != 1) { @@ -888,21 +890,21 @@ static int NotebookAddCommand( return TCL_ERROR; } - slaveWindow = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin); - if (!slaveWindow) { + window = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin); + if (!window) { return TCL_ERROR; } - slaveIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow); + index = Ttk_SlaveIndex(nb->notebook.mgr, window); - if (slaveIndex < 0) { /* New tab */ - return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3); + if (index < 0) { /* New tab */ + return AddTab(interp, nb, Ttk_NumberSlaves(nb->notebook.mgr), window, objc-3,objv+3); } - tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex); + tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } @@ -917,9 +919,9 @@ static int NotebookAddCommand( static int NotebookInsertCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; int current = nb->notebook.currentIndex; - int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + int nContent = Ttk_NumberSlaves(nb->notebook.mgr); int srcIndex, destIndex; if (objc < 4) { @@ -935,18 +937,18 @@ static int NotebookInsertCommand( } if (Tcl_GetString(objv[3])[0] == '.') { - /* Window name -- could be new or existing slave. + /* Window name -- could be new or existing content window. */ - Tk_Window slaveWindow = + Tk_Window window = Tk_NameToWindow(interp,Tcl_GetString(objv[3]),nb->core.tkwin); - if (!slaveWindow) { + if (!window) { return TCL_ERROR; } - srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow); - if (srcIndex < 0) { /* New slave */ - return AddTab(interp, nb, destIndex, slaveWindow, objc-4,objv+4); + srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, window); + if (srcIndex < 0) { /* New content window */ + return AddTab(interp, nb, destIndex, window, objc-4,objv+4); } } else if (Ttk_GetSlaveIndexFromObj( interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK) @@ -954,18 +956,18 @@ static int NotebookInsertCommand( return TCL_ERROR; } - /* Move existing slave: + /* Move existing content window: */ if (ConfigureTab(interp, nb, - Ttk_SlaveData(nb->notebook.mgr,srcIndex), - Ttk_SlaveWindow(nb->notebook.mgr,srcIndex), + (Tab *)Ttk_SlaveData(nb->notebook.mgr, srcIndex), + Ttk_SlaveWindow(nb->notebook.mgr, srcIndex), objc-4,objv+4) != TCL_OK) { return TCL_ERROR; } - if (destIndex >= nSlaves) { - destIndex = nSlaves - 1; + if (destIndex >= nContent) { + destIndex = nContent - 1; } Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex); @@ -991,7 +993,7 @@ static int NotebookInsertCommand( static int NotebookForgetCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; int index; if (objc != 3) { @@ -1015,7 +1017,7 @@ static int NotebookForgetCommand( static int NotebookHideCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; int index; Tab *tab; @@ -1028,7 +1030,7 @@ static int NotebookHideCommand( return TCL_ERROR; } - tab = Ttk_SlaveData(nb->notebook.mgr, index); + tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); tab->state = TAB_STATE_HIDDEN; if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); @@ -1048,27 +1050,27 @@ static int NotebookIdentifyCommand( static const char *whatTable[] = { "element", "tab", NULL }; enum { IDENTIFY_ELEMENT, IDENTIFY_TAB }; int what = IDENTIFY_ELEMENT; - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Ttk_Element element = NULL; - int x, y, tabIndex; + int x, y; + int tabIndex; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2,objv, "?what? x y"); return TCL_ERROR; } - if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK + if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK - || (objc == 5 && - Tcl_GetIndexFromObj(interp, objv[2], whatTable, "option", 0, &what) - != TCL_OK) + || (objc == 5 && Tcl_GetIndexFromObj(interp, objv[2], whatTable, + "option", 0, &what) != TCL_OK) ) { return TCL_ERROR; } tabIndex = IdentifyTab(nb, x, y); if (tabIndex >= 0) { - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, tabIndex); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, tabIndex); Ttk_State state = TabState(nb, tabIndex); Ttk_Layout tabLayout = nb->notebook.tabLayout; @@ -1082,7 +1084,8 @@ static int NotebookIdentifyCommand( case IDENTIFY_ELEMENT: if (element) { const char *elementName = Ttk_ElementName(element); - Tcl_SetObjResult(interp,Tcl_NewStringObj(elementName,-1)); + + Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; case IDENTIFY_TAB: @@ -1102,8 +1105,9 @@ static int NotebookIdentifyCommand( static int NotebookIndexCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; - int index, status; + Notebook *nb = (Notebook *)recordPtr; + int index; + int status; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "tab"); @@ -1114,8 +1118,8 @@ static int NotebookIndexCommand( * Special-case for "end": */ if (!strcmp("end", Tcl_GetString(objv[2]))) { - int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); - Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves)); + int nContent = Ttk_NumberSlaves(nb->notebook.mgr); + Tcl_SetObjResult(interp, Tcl_NewIntObj(nContent)); return TCL_OK; } @@ -1134,7 +1138,7 @@ static int NotebookIndexCommand( static int NotebookSelectCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; if (objc == 2) { if (nb->notebook.currentIndex >= 0) { @@ -1160,7 +1164,7 @@ static int NotebookSelectCommand( static int NotebookTabsCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; Tcl_Obj *result; int i; @@ -1173,10 +1177,10 @@ static int NotebookTabsCommand( result = Tcl_NewListObj(0, NULL); for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); - Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(pathName,-1)); + + Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(pathName,-1)); } Tcl_SetObjResult(interp, result); - return TCL_OK; } @@ -1185,10 +1189,10 @@ static int NotebookTabsCommand( static int NotebookTabCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; int index; - Tk_Window slaveWindow; + Tk_Window window; Tab *tab; if (objc < 3) { @@ -1200,18 +1204,18 @@ static int NotebookTabCommand( return TCL_ERROR; } - tab = Ttk_SlaveData(mgr, index); - slaveWindow = Ttk_SlaveWindow(mgr, index); + tab = (Tab *)Ttk_SlaveData(mgr, index); + window = Ttk_SlaveWindow(mgr, index); if (objc == 3) { return TtkEnumerateOptions(interp, tab, - PaneOptionSpecs, nb->notebook.paneOptionTable, slaveWindow); + PaneOptionSpecs, nb->notebook.paneOptionTable, window); } else if (objc == 4) { return TtkGetOptionValue(interp, tab, objv[3], - nb->notebook.paneOptionTable, slaveWindow); + nb->notebook.paneOptionTable, window); } /* else */ - if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) { + if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) { return TCL_ERROR; } @@ -1250,7 +1254,7 @@ static const Ttk_Ensemble NotebookCommands[] = { static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; nb->notebook.mgr = Ttk_CreateManager( &NotebookManagerSpec, recordPtr, nb->core.tkwin); @@ -1270,7 +1274,7 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr) static void NotebookCleanup(void *recordPtr) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Ttk_DeleteManager(nb->notebook.mgr); if (nb->notebook.tabLayout) @@ -1279,7 +1283,7 @@ static void NotebookCleanup(void *recordPtr) static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask) { - Notebook *nb = clientData; + Notebook *nb = (Notebook *)clientData; /* * Error-checks: @@ -1303,7 +1307,7 @@ static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask) static Ttk_Layout NotebookGetLayout( Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr) { - Notebook *nb = recordPtr; + Notebook *nb = (Notebook *)recordPtr; Ttk_Layout notebookLayout = TtkWidgetGetLayout(interp, theme, recordPtr); Ttk_Layout tabLayout; @@ -1331,7 +1335,7 @@ static Ttk_Layout NotebookGetLayout( static void DisplayTab(Notebook *nb, int index, Drawable d) { Ttk_Layout tabLayout = nb->notebook.tabLayout; - Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); + Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index); Ttk_State state = TabState(nb, index); if (tab->state != TAB_STATE_HIDDEN) { @@ -1343,8 +1347,8 @@ static void DisplayTab(Notebook *nb, int index, Drawable d) static void NotebookDisplay(void *clientData, Drawable d) { - Notebook *nb = clientData; - int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + Notebook *nb = (Notebook *)clientData; + int nContent = Ttk_NumberSlaves(nb->notebook.mgr); int index; /* Draw notebook background (base layout): @@ -1354,7 +1358,7 @@ static void NotebookDisplay(void *clientData, Drawable d) /* Draw tabs from left to right, but draw the current tab last * so it will overwrite its neighbors. */ - for (index = 0; index < nSlaves; ++index) { + for (index = 0; index < nContent; ++index) { if (index != nb->notebook.currentIndex) { DisplayTab(nb, index, d); } diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 473d1e6..366e27d 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -340,8 +340,8 @@ static int GetEnumSetFromObj( for (i = 0; i < objc; ++i) { int index; - if (TCL_OK != Tcl_GetIndexFromObj( - interp, objv[i], table, "value", TCL_EXACT, &index)) + if (TCL_OK != Tcl_GetIndexFromObj(interp, objv[i], table, + "value", TCL_EXACT, &index)) { return TCL_ERROR; } @@ -688,7 +688,7 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv) */ tv->tree.nColumns = ncols; tv->tree.columns = - (TreeColumn*)ckalloc(tv->tree.nColumns * sizeof(TreeColumn)); + (TreeColumn*)ckalloc(tv->tree.nColumns * sizeof(TreeColumn)); for (i = 0; i < ncols; ++i) { int isNew; @@ -733,12 +733,12 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv) if (!strcmp(Tcl_GetString(tv->tree.displayColumnsObj), "#all")) { ndcols = tv->tree.nColumns; - displayColumns = (TreeColumn**)ckalloc((ndcols+1)*sizeof(TreeColumn*)); + displayColumns = (TreeColumn**)ckalloc((ndcols+1) * sizeof(TreeColumn*)); for (index = 0; index < ndcols; ++index) { displayColumns[index+1] = tv->tree.columns + index; } } else { - displayColumns = (TreeColumn**)ckalloc((ndcols+1)*sizeof(TreeColumn*)); + displayColumns = (TreeColumn**)ckalloc((ndcols+1) * sizeof(TreeColumn*)); for (index = 0; index < ndcols; ++index) { displayColumns[index+1] = GetColumn(interp, tv, dcolumns[index]); if (!displayColumns[index+1]) { @@ -1785,7 +1785,7 @@ static void DrawItem( x+indent, y, colwidth-indent, rowHeight); if (item->textObj) { displayItem.textObj = item->textObj; } if (item->imageObj) { displayItem.imageObj = item->imageObj; } - /* ??? displayItem.anchorObj = 0; <> */ + displayItem.anchorObj = tv->tree.column0.anchorObj; DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d); x += colwidth; } @@ -1828,7 +1828,7 @@ static int DrawSubtree( static int DrawForest( Treeview *tv, TreeItem *item, Drawable d, int depth, int row) { - while (item && row <= tv->tree.yscroll.last) { + while (item && row < tv->tree.yscroll.last) { row = DrawSubtree(tv, item, d, depth, row); item = item->next; } @@ -1916,7 +1916,7 @@ static int AncestryCheck( Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Cannot insert ", ItemName(tv, item), - " as a descendant of ", ItemName(tv, parent), + " as descendant of ", ItemName(tv, parent), NULL); return 0; } @@ -2291,8 +2291,8 @@ static int TreeviewIdentifyCommand( return TCL_ERROR; } - if ( Tcl_GetIndexFromObj(interp, objv[2], - submethodStrings, "command", TCL_EXACT, &submethod) != TCL_OK + if (Tcl_GetIndexFromObj(interp, objv[2], submethodStrings, + "command", TCL_EXACT, &submethod) != TCL_OK || Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK ) { @@ -2489,9 +2489,9 @@ static int TreeviewSetCommand( for (columnNumber=0; columnNumbertree.nColumns; ++columnNumber) { Tcl_ListObjIndex(interp, item->valuesObj, columnNumber, &value); if (value) { - Tcl_ListObjAppendElement(interp, result, + Tcl_ListObjAppendElement(NULL, result, tv->tree.columns[columnNumber].idObj); - Tcl_ListObjAppendElement(interp, result, value); + Tcl_ListObjAppendElement(NULL, result, value); } } Tcl_SetObjResult(interp, result); @@ -2588,6 +2588,7 @@ static int TreeviewInsertCommand( objc -= 4; objv += 4; if (objc >= 2 && !strcmp("-id", Tcl_GetString(objv[0]))) { const char *itemName = Tcl_GetString(objv[1]); + entryPtr = Tcl_CreateHashEntry(&tv->tree.items, itemName, &isNew); if (!isNew) { Tcl_AppendResult(interp, "Item ",itemName," already exists",NULL); @@ -2954,8 +2955,7 @@ static int TreeviewSelectionCommand( } if (Tcl_GetIndexFromObj(interp, objv[2], selopStrings, - "selection operation", 0, &selop) != TCL_OK) - { + "selection operation", 0, &selop) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index 557ca8f..0915063 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -440,7 +440,7 @@ int TtkWidgetConstructorObjCmd( error: if (WidgetDestroyed(corePtr)) { - Tcl_SetResult(interp, "Widget has been destroyed", TCL_STATIC); + Tcl_SetResult(interp, "widget has been destroyed", TCL_STATIC); } else { Tk_DestroyWindow(tkwin); } @@ -649,7 +649,7 @@ int TtkWidgetConfigureCommand( status = corePtr->widgetSpec->postConfigureProc(interp,recordPtr,mask); if (WidgetDestroyed(corePtr)) { - Tcl_SetResult(interp, "Widget has been destroyed", TCL_STATIC); + Tcl_SetResult(interp, "widget has been destroyed", TCL_STATIC); status = TCL_ERROR; } if (status != TCL_OK) { diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index 9b75978..8239e20 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -69,7 +69,7 @@ test notebook-2.5 "tab - get all options" -body { .nb tab .nb.foo } -result [list \ -padding 0 -sticky nsew \ - -state normal -text "Changed Foo" -image "" -compound none -underline -1] + -state normal -text "Changed Foo" -image "" -compound {} -underline -1] test notebook-4.1 "Test .nb index end" -body { .nb index end diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index c8f1556..1db53ee 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -405,7 +405,7 @@ test treeview-7.1 "move" -body { test treeview-7.2 "illegal move" -body { .tv move d d2 end -} -returnCodes error -result "Cannot insert d as a descendant of d2" +} -returnCodes error -result "Cannot insert d as descendant of d2" test treeview-7.3 "illegal move has no effect" -body { consistencyCheck .tv @@ -426,7 +426,7 @@ test treeview-7.5 "replace children - precondition" -body { test treeview-7.6 "Replace children - illegal move" -body { .tv children newnode.n1 [list newnode.n1 newnode.n2 newnode.n3] -} -returnCodes error -result "Cannot insert newnode.n1 as a descendant of newnode.n1" +} -returnCodes error -result "Cannot insert newnode.n1 as descendant of newnode.n1" consistencyCheck .tv diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 8ad7887..0f69944 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -48,7 +48,7 @@ test ttk-6.4 "Destroy widget in configure" -setup { pack [ttk::checkbutton .b] set rc [catch { .b configure -variable OUCH } msg] list $rc $msg [winfo exists .b] [info commands .b] -} -result [list 1 "Widget has been destroyed" 0 {}] +} -result [list 1 "widget has been destroyed" 0 {}] test ttk-6.5 "Clean up -textvariable traces" -body { foreach class {ttk::button ttk::checkbutton ttk::radiobutton} { @@ -121,7 +121,7 @@ test ttk-construction-failure-2 "Destroy widget in constructor" -setup { [winfo exists .b] \ [info commands .b] \ ; -} -result [list 1 "Widget has been destroyed" 0 {}] +} -result [list 1 "widget has been destroyed" 0 {}] test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # see #2298720 -- cgit v0.12