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