summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-05-08 14:43:42 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-05-08 14:43:42 (GMT)
commitccd9d0da0d8c66ba25b5a49a4f5d0d77c83408d7 (patch)
tree6a41860088e8da5be307793b893797f7cefd559b
parent45d782e1e6091d7f6a048d18a993b9e70e905151 (diff)
downloadtk-ccd9d0da0d8c66ba25b5a49a4f5d0d77c83408d7.zip
tk-ccd9d0da0d8c66ba25b5a49a4f5d0d77c83408d7.tar.gz
tk-ccd9d0da0d8c66ba25b5a49a4f5d0d77c83408d7.tar.bz2
Fix [1bb2f1d7ab]: ttk::treeview doesn't delete tags. Patch from Emiliano Gavilan.
-rw-r--r--doc/ttk_treeview.n7
-rw-r--r--generic/ttk/ttkTagSet.c11
-rw-r--r--generic/ttk/ttkTreeview.c32
-rw-r--r--generic/ttk/ttkWidget.h2
4 files changed, 52 insertions, 0 deletions
diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n
index bcd995b..aa7b87f 100644
--- a/doc/ttk_treeview.n
+++ b/doc/ttk_treeview.n
@@ -372,6 +372,13 @@ With no additional arguments,
returns a dictionary of the option settings for \fItagName\fR.
See \fBTAG OPTIONS\fR for the list of available options.
.TP
+\fIpathName \fBtag delete \fItagName\fR
+.
+Deletes all tag information for the \fItagName\fR argument. The
+command removes the tag from all items in the widget and also deletes any
+other information associated with the tag, such as bindings and display
+information. The command returns an empty string.
+.TP
\fIpathName \fBtag has \fItagName\fR ?\fIitem\fR?
If \fIitem\fR is specified, returns 1 or 0
depending on whether the specified item has the named tag.
diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c
index e923d77..96e6c4e 100644
--- a/generic/ttk/ttkTagSet.c
+++ b/generic/ttk/ttkTagSet.c
@@ -80,6 +80,17 @@ void Ttk_DeleteTagTable(Ttk_TagTable tagTable)
ckfree(tagTable);
}
+void Ttk_DeleteTagFromTable(Ttk_TagTable tagTable, Ttk_Tag tag)
+{
+ Tcl_HashEntry *entryPtr;
+
+ entryPtr = Tcl_FindHashEntry(&tagTable->tags, tag->tagName);
+ if (entryPtr != NULL) {
+ DeleteTag(tagTable, tag);
+ Tcl_DeleteHashEntry(entryPtr);
+ }
+}
+
Ttk_Tag Ttk_GetTag(Ttk_TagTable tagTable, const char *tagName)
{
int isNew = 0;
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 7bf9388..05c58f1 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -79,6 +79,9 @@ static const Tk_OptionSpec ItemOptionSpecs[] = {
{TK_OPTION_END, 0,0,0, NULL, TCL_AUTO_LENGTH,TCL_AUTO_LENGTH, 0,0,0}
};
+/* Forward declaration */
+static void RemoveTag(TreeItem *, Ttk_Tag);
+
/* + NewItem --
* Allocate a new, uninitialized, unlinked item
*/
@@ -3102,6 +3105,34 @@ static int TreeviewTagConfigureCommand(
return Ttk_ConfigureTag(interp, tagTable, tag, objc - 4, objv + 4);
}
+/* + $tv tag delete $tag
+ */
+static int TreeviewTagDeleteCommand(
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_TagTable tagTable = tv->tree.tagTable;
+ TreeItem *item = tv->tree.root;
+ Ttk_Tag tag;
+
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "tagName");
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tagTable, objv[3]);
+ /* remove the tag from all items */
+ while (item) {
+ RemoveTag(item, tag);
+ item=NextPreorder(item);
+ }
+ /* then remove the tag from the tag table */
+ Ttk_DeleteTagFromTable(tagTable, tag);
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
/* + $tv tag has $tag ?$item?
*/
static int TreeviewTagHasCommand(
@@ -3244,6 +3275,7 @@ static const Ttk_Ensemble TreeviewTagCommands[] = {
{ "add", TreeviewTagAddCommand,0 },
{ "bind", TreeviewTagBindCommand,0 },
{ "configure", TreeviewTagConfigureCommand,0 },
+ { "delete", TreeviewTagDeleteCommand,0 },
{ "has", TreeviewTagHasCommand,0 },
{ "names", TreeviewTagNamesCommand,0 },
{ "remove", TreeviewTagRemoveCommand,0 },
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
index e6d17a1..b72f88a 100644
--- a/generic/ttk/ttkWidget.h
+++ b/generic/ttk/ttkWidget.h
@@ -226,6 +226,8 @@ MODULE_SCOPE int Ttk_EnumerateTagOptions(
MODULE_SCOPE int Ttk_EnumerateTags(Tcl_Interp *, Ttk_TagTable);
+MODULE_SCOPE void Ttk_DeleteTagFromTable(Ttk_TagTable, Ttk_Tag);
+
MODULE_SCOPE int Ttk_ConfigureTag(
Tcl_Interp *interp, Ttk_TagTable tagTable, Ttk_Tag tag,
int objc, Tcl_Obj *const objv[]);