+static void gtk_treectrl_unselect_callback(GtkWidget *widget, gpointer data) {
+ GtkTreeItem *p;
+
+ GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree);
+
+ if (tree->selection != NULL) {
+ guint len = g_list_length(tree->selection);
+ for (guint i=0; i<len; i++) {
+ p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->selection, i)->data);
+ gtk_tree_unselect_child(tree, GTK_WIDGET(p));
+ }
+ }
+
+ if (GTK_IS_CONTAINER(widget))
+ gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_unselect_callback, data);
+}
+