summaryrefslogtreecommitdiffstats
path: root/generic/ttk
diff options
context:
space:
mode:
Diffstat (limited to 'generic/ttk')
-rw-r--r--generic/ttk/ttkEntry.c18
-rw-r--r--generic/ttk/ttkFrame.c7
-rw-r--r--generic/ttk/ttkImage.c19
-rw-r--r--generic/ttk/ttkLayout.c37
-rw-r--r--generic/ttk/ttkManager.c32
-rw-r--r--generic/ttk/ttkNotebook.c20
-rw-r--r--generic/ttk/ttkPanedwindow.c16
-rw-r--r--generic/ttk/ttkState.c13
-rw-r--r--generic/ttk/ttkTheme.c38
-rw-r--r--generic/ttk/ttkTreeview.c86
10 files changed, 157 insertions, 129 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index ed779dd..c85751e 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1322,9 +1322,10 @@ EntryIndex(
*indexPtr = entryPtr->entry.xscroll.last;
} else if (strncmp(string, "sel.", 4) == 0) {
if (entryPtr->entry.selectFirst < 0) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "selection isn't in widget ",
- Tk_PathName(entryPtr->core.tkwin), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "selection isn't in widget %s",
+ Tk_PathName(entryPtr->core.tkwin)));
+ Tcl_SetErrorCode(interp, "TTK", "ENTRY", "NO_SELECTION", NULL);
return TCL_ERROR;
}
if (strncmp(string, "sel.first", length) == 0) {
@@ -1376,8 +1377,9 @@ EntryIndex(
return TCL_OK;
badIndex:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad entry index \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad entry index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TTK", "ENTRY", "INDEX", NULL);
return TCL_ERROR;
}
@@ -1782,9 +1784,9 @@ static int ComboboxCurrentCommand(
return TCL_ERROR;
}
if (currentIndex < 0 || currentIndex >= nValues) {
- Tcl_AppendResult(interp,
- "Index ", Tcl_GetString(objv[2]), " out of range",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Index %s out of range", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
return TCL_ERROR;
}
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 7860024..3e50a7f 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -206,10 +206,9 @@ int TtkGetLabelAnchorFromObj(
error:
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Bad label anchor specification ", Tcl_GetString(objPtr),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Bad label anchor specification %s", Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "LABEL", "ANCHOR", NULL);
}
return TCL_ERROR;
}
diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c
index 3363e4c..1d455d9 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -62,6 +62,7 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr)
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"image specification must contain an odd number of elements",
-1));
+ Tcl_SetErrorCode(interp, "TTK", "IMAGE", "SPEC", NULL);
}
goto error;
}
@@ -324,7 +325,9 @@ Ttk_CreateImageElement(
int i;
if (objc <= 0) {
- Tcl_AppendResult(interp, "Must supply a base image", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Must supply a base image", -1));
+ Tcl_SetErrorCode(interp, "TTK", "IMAGE", "BASE", NULL);
return TCL_ERROR;
}
@@ -347,9 +350,9 @@ Ttk_CreateImageElement(
int option;
if (i == objc - 1) {
- Tcl_AppendResult(interp,
- "Value for ", Tcl_GetString(objv[i]), " missing",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Value for %s missing", Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TTK", "IMAGE", "VALUE", NULL);
goto error;
}
@@ -362,12 +365,16 @@ Ttk_CreateImageElement(
#endif
if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
- "option", 0, &option) != TCL_OK) { goto error; }
+ "option", 0, &option) != TCL_OK) {
+ goto error;
+ }
switch (option) {
case O_BORDER:
if (Ttk_GetBorderFromObj(interp, objv[i+1], &imageData->border)
- != TCL_OK) { goto error; }
+ != TCL_OK) {
+ goto error;
+ }
if (!padding_specified) {
imageData->padding = imageData->border;
}
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c
index d248dcb..559d5d9 100644
--- a/generic/ttk/ttkLayout.c
+++ b/generic/ttk/ttkLayout.c
@@ -326,8 +326,9 @@ int Ttk_GetPaddingFromObj(
if (padc > 4) {
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Wrong #elements in padding spec", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Wrong #elements in padding spec", -1));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "PADDING", NULL);
}
goto error;
}
@@ -363,8 +364,9 @@ int Ttk_GetBorderFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Padding *pad)
if (padc > 4) {
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Wrong #elements in border spec", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Wrong #elements in padding spec", -1));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "BORDER", NULL);
}
goto error;
}
@@ -476,11 +478,10 @@ int Ttk_GetStickyFromObj(
case 's': case 'S': sticky |= TTK_STICK_S; break;
default:
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Bad -sticky specification ",
- Tcl_GetString(objPtr),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Bad -sticky specification %s",
+ Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "STICKY", NULL);
}
return TCL_ERROR;
}
@@ -643,10 +644,10 @@ Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *interp, Tcl_Obj *objPtr)
}
if (++i >= objc) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Missing value for option ",Tcl_GetString(objv[i-1]),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Missing value for option %s",
+ Tcl_GetString(objv[i-1])));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "LAYOUT", NULL);
goto error;
}
@@ -875,8 +876,9 @@ Ttk_Layout Ttk_CreateLayout(
Ttk_LayoutNode *bgnode;
if (!layoutTemplate) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Layout ", styleName, " not found", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Layout %s not found", styleName));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", NULL);
return 0;
}
@@ -915,8 +917,9 @@ Ttk_CreateSublayout(
layoutTemplate = Ttk_FindLayoutTemplate(themePtr, styleName);
if (!layoutTemplate) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Layout ", styleName, " not found", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Layout %s not found", styleName));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", NULL);
return 0;
}
diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c
index 256573f..cf98a6d 100644
--- a/generic/ttk/ttkManager.c
+++ b/generic/ttk/ttkManager.c
@@ -455,10 +455,9 @@ int Ttk_GetSlaveIndexFromObj(
*/
if (Tcl_GetIntFromObj(NULL, objPtr, &slaveIndex) == TCL_OK) {
if (slaveIndex < 0 || slaveIndex >= mgr->nSlaves) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Slave index ", Tcl_GetString(objPtr), " out of bounds",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Slave index %d out of bounds", slaveIndex));
+ Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
return TCL_ERROR;
}
*indexPtr = slaveIndex;
@@ -467,23 +466,23 @@ int Ttk_GetSlaveIndexFromObj(
/* Try interpreting as a slave window name;
*/
- if ( (*string == '.')
- && (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow)))
- {
+ if ((*string == '.') &&
+ (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow))) {
slaveIndex = Ttk_SlaveIndex(mgr, tkwin);
if (slaveIndex < 0) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- string, " is not managed by ", Tk_PathName(mgr->masterWindow),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s is not managed by %s", string,
+ Tk_PathName(mgr->masterWindow)));
+ Tcl_SetErrorCode(interp, "TTK", "SLAVE", "MANAGER", NULL);
return TCL_ERROR;
}
*indexPtr = slaveIndex;
return TCL_OK;
}
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Invalid slave specification ", string, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid slave specification %s", string));
+ Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL);
return TCL_ERROR;
}
@@ -542,10 +541,9 @@ int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window slave, Tk_Window master)
return 1;
badWindow:
- Tcl_AppendResult(interp,
- "can't add ", Tk_PathName(slave),
- " as slave of ", Tk_PathName(master),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s",
+ Tk_PathName(slave), Tk_PathName(master)));
+ Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL);
return 0;
}
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 551f4a6..6849135 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -727,9 +727,9 @@ static int AddTab(
}
#if 0 /* can't happen */
if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) {
- Tcl_AppendResult(interp,
- Tk_PathName(slaveWindow), " already added",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added",
+ Tk_PathName(slaveWindow)));
+ Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL);
return TCL_ERROR;
}
#endif
@@ -859,10 +859,9 @@ static int GetTabIndex(
int status = FindTabIndex(interp, nb, objPtr, index_rtn);
if (status == TCL_OK && *index_rtn < 0) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "tab '", Tcl_GetString(objPtr), "' not found",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "tab '%s' not found", Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "TAB", NULL);
status = TCL_ERROR;
}
return status;
@@ -1082,7 +1081,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:
@@ -1173,10 +1173,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;
}
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index b301372..12d481f 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -157,7 +157,9 @@ static int ConfigurePane(
/* Sanity-check:
*/
if (pane->weight < 0) {
- Tcl_AppendResult(interp, "-weight must be nonnegative", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-weight must be nonnegative", -1));
+ Tcl_SetErrorCode(interp, "TTK", "PANE", "WEIGHT", NULL);
goto error;
}
@@ -419,9 +421,9 @@ static int AddPane(
return TCL_ERROR;
}
if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) {
- Tcl_AppendResult(interp,
- Tk_PathName(slaveWindow), " already added",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s already added", Tk_PathName(slaveWindow)));
+ Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL);
return TCL_ERROR;
}
@@ -844,9 +846,9 @@ static int PanedSashposCommand(
return TCL_ERROR;
}
if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) {
- Tcl_AppendResult(interp,
- "sash index ", Tcl_GetString(objv[2]), " out of range",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "sash index %d out of range", sashIndex));
+ Tcl_SetErrorCode(interp, "TTK", "PANE", "SASHIDX", NULL);
return TCL_ERROR;
}
diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c
index ab2b7ed..151dc4d 100644
--- a/generic/ttk/ttkState.c
+++ b/generic/ttk/ttkState.c
@@ -98,8 +98,9 @@ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr)
if (stateNames[j] == 0) {
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Invalid state name ", stateName,NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid state name %s", stateName));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "STATE", NULL);
}
return TCL_ERROR;
}
@@ -216,8 +217,8 @@ Tcl_Obj *Ttk_StateMapLookup(
return specs[j+1];
}
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "No match in state map", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("No match in state map", -1));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "STATE", NULL);
}
return NULL;
}
@@ -240,9 +241,11 @@ Ttk_StateMap Ttk_GetStateMapFromObj(
return NULL;
if (nSpecs % 2 != 0) {
- if (interp)
+ if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"State map must have an even number of elements", -1));
+ Tcl_SetErrorCode(interp, "TTK", "VALUE", "STATEMAP", NULL);
+ }
return 0;
}
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index b0e9171..6e7b477 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -548,8 +548,9 @@ Ttk_CreateTheme(
entryPtr = Tcl_CreateHashEntry(&pkgPtr->themeTable, name, &newEntry);
if (!newEntry) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Theme ", name, " already exists", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Theme %s already exists", name));
+ Tcl_SetErrorCode(interp, "TTK", "THEME", "EXISTS", NULL);
return NULL;
}
@@ -591,8 +592,9 @@ static Ttk_Theme LookupTheme(
entryPtr = Tcl_FindHashEntry(&pkgPtr->themeTable, name);
if (!entryPtr) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "theme \"", name, "\" doesn't exist", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "theme \"%s\" doesn't exist", name));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "THEME", NULL);
return NULL;
}
@@ -875,9 +877,10 @@ Ttk_ElementClass *Ttk_RegisterElement(
if (specPtr->version != TK_STYLE_VERSION_2) {
/* Version mismatch */
if (interp) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Internal error: Ttk_RegisterElement (",
- name, "): invalid version",
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Internal error: Ttk_RegisterElement (%s): invalid version",
+ name));
+ Tcl_SetErrorCode(interp, "TTK", "REGISTER_ELEMENT", "VERSION",
NULL);
}
return 0;
@@ -887,7 +890,9 @@ Ttk_ElementClass *Ttk_RegisterElement(
if (!newEntry) {
if (interp) {
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Duplicate element ", name, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Duplicate element %s", name));
+ Tcl_SetErrorCode(interp, "TTK", "REGISTER_ELEMENT", "DUPE", NULL);
}
return 0;
}
@@ -1355,8 +1360,9 @@ static int StyleThemeCurrentCmd(
}
if (name == NULL) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("error: failed to get theme name", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error: failed to get theme name", -1));
+ Tcl_SetErrorCode(interp, "TTK", "THEME", "NAMELESS", NULL);
return TCL_ERROR;
}
@@ -1491,7 +1497,9 @@ static int StyleElementCreateCmd(
entryPtr = Tcl_FindHashEntry(&pkgPtr->factoryTable, factoryName);
if (!entryPtr) {
- Tcl_AppendResult(interp, "No such element type ", factoryName, NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "No such element type %s", factoryName));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "ELEMENT_TYPE", NULL);
return TCL_ERROR;
}
@@ -1550,7 +1558,9 @@ static int StyleElementOptionsCmd(
return TCL_OK;
}
- Tcl_AppendResult(interp, "element ", elementName, " not found", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "element %s not found", elementName));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "ELEMENT", NULL);
return TCL_ERROR;
}
@@ -1574,7 +1584,9 @@ static int StyleLayoutCmd(
if (objc == 3) {
layoutTemplate = Ttk_FindLayoutTemplate(theme, layoutName);
if (!layoutTemplate) {
- Tcl_AppendResult(interp, "Layout ", layoutName, " not found", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Layout %s not found", layoutName));
+ Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Ttk_UnparseLayoutTemplate(layoutTemplate));
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 1ed2742..dc0206c 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -534,21 +534,18 @@ static TreeColumn *GetColumn(
*/
if (Tcl_GetIntFromObj(NULL, columnIDObj, &columnIndex) == TCL_OK) {
if (columnIndex < 0 || columnIndex >= tv->tree.nColumns) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Column index ",
- Tcl_GetString(columnIDObj),
- " out of bounds",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Column index %s out of bounds",
+ Tcl_GetString(columnIDObj)));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "COLBOUND", NULL);
return NULL;
}
return tv->tree.columns + columnIndex;
}
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Invalid column index ", Tcl_GetString(columnIDObj),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid column index %s", Tcl_GetString(columnIDObj)));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL);
return NULL;
}
@@ -566,10 +563,9 @@ static TreeColumn *FindColumn(
return tv->tree.displayColumns[colno];
}
/* else */
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Column ", Tcl_GetString(columnIDObj), " out of range",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Column %s out of range", Tcl_GetString(columnIDObj)));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL);
return NULL;
}
@@ -587,8 +583,9 @@ static TreeItem *FindItem(
Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&tv->tree.items, itemName);
if (!entryPtr) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Item ", itemName, " not found", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Item %s not found", itemName));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM", NULL);
return 0;
}
return Tcl_GetHashValue(entryPtr);
@@ -1222,8 +1219,9 @@ static int ConfigureColumn(
}
if (mask & READONLY_OPTION) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "Attempt to change read-only option", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Attempt to change read-only option", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "READONLY", NULL);
goto error;
}
@@ -1912,11 +1910,10 @@ static int AncestryCheck(
TreeItem *p = parent;
while (p) {
if (p == item) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "Cannot insert ", ItemName(tv, item),
- " as a descendant of ", ItemName(tv, parent),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Cannot insert %s as descendant of %s",
+ ItemName(tv, item), ItemName(tv, parent)));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "ANCESTRY", NULL);
return 0;
}
p = p->parent;
@@ -2318,9 +2315,7 @@ static int TreeviewIdentifyCommand(
case I_COLUMN :
if (colno >= 0) {
- char dcolbuf[16];
- sprintf(dcolbuf, "#%d", colno);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(dcolbuf, -1));
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%d", colno));
}
break;
@@ -2488,9 +2483,9 @@ static int TreeviewSetCommand(
for (columnNumber=0; columnNumber<tv->tree.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);
@@ -2504,7 +2499,9 @@ static int TreeviewSetCommand(
if (column == &tv->tree.column0) {
/* @@@ Maybe set -text here instead? */
- Tcl_AppendResult(interp, "Display column #0 cannot be set", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Display column #0 cannot be set", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN_0", NULL);
return TCL_ERROR;
}
@@ -2587,9 +2584,12 @@ 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);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Item %s already exists", itemName));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM_EXISTS", NULL);
return TCL_ERROR;
}
objc -= 2; objv += 2;
@@ -2646,7 +2646,9 @@ static int TreeviewDetachCommand(
/* Sanity-check */
for (i = 0; items[i]; ++i) {
if (items[i] == tv->tree.root) {
- Tcl_AppendResult(interp, "Cannot detach root item", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Cannot detach root item", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL);
ckfree(items);
return TCL_ERROR;
}
@@ -2694,7 +2696,9 @@ static int TreeviewDeleteCommand(
for (i=0; items[i]; ++i) {
if (items[i] == tv->tree.root) {
ckfree(items);
- Tcl_AppendResult(interp, "Cannot delete root item", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Cannot delete root item", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL);
return TCL_ERROR;
}
}
@@ -2885,10 +2889,9 @@ static int TreeviewDragCommand(
left = right;
}
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "column ", Tcl_GetString(objv[2]), " is not displayed",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "column %s is not displayed", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN_INVISIBLE", NULL);
return TCL_ERROR;
}
@@ -2953,8 +2956,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;
}
@@ -3040,10 +3042,10 @@ static int TreeviewTagBindCommand(
*/
if (mask & (~TreeviewBindEventMask)) {
Tk_DeleteBinding(interp, bindingTable, tag, sequence);
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "unsupported event ", sequence,
- "\nonly key, button, motion, and virtual events supported",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unsupported event %s\nonly key, button, motion, and"
+ " virtual events supported", sequence));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "BIND_EVENTS", NULL);
return TCL_ERROR;
}
}