+ GtkLabel *m_label_widget = GTK_LABEL(gtk_label_new ((char *)(const char *)text));
+ gtk_misc_set_alignment (GTK_MISC (m_label_widget), 0.5, 0.5);
+ gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_label_widget), FALSE, FALSE, 0);
+ gtk_object_set_data(GTK_OBJECT(item), "w_label", m_label_widget);
+ gtk_widget_show (GTK_WIDGET(m_label_widget));
+
+ gtk_widget_show(GTK_WIDGET(m_box));
+
+ gtk_object_set_data(GTK_OBJECT(item), "owner", this);
+ gtk_object_set_data(GTK_OBJECT(item), "data", data);
+ gtk_object_set_data(GTK_OBJECT(item), "parent", p);
+
+ if (p != 0) {
+ if (p->subtree == NULL) {
+ GtkTree *tree = GTK_TREE(gtk_tree_new());
+ gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree));
+ gtk_widget_show(GTK_WIDGET(tree));
+ p->expanded = 1;
+ }
+
+ gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item));
+ } else {
+printf("Adding root\n");
+printf("m_tree = %p\n", m_tree);
+ m_anchor = item;
+ gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item));
+ }
+
+ gtk_widget_show(GTK_WIDGET(item));
+
+ gtk_signal_connect(GTK_OBJECT(item), "select",
+ GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this );
+
+ gtk_signal_connect(GTK_OBJECT(item), "deselect",
+ GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this );
+
+ gtk_signal_connect(GTK_OBJECT(item), "expand",
+ GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this );
+ gtk_signal_connect(GTK_OBJECT(item), "collapse",
+ GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this );
+
+ return item;
+}
+
+void wxTreeCtrl::Delete(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return;
+
+ GtkTreeItem *parent = GTK_TREE_ITEM(GTK_WIDGET((GtkTreeItem *)item)->parent);
+ if (parent == NULL)
+ return;
+
+ gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET((GtkTreeItem *)item));
+
+ return;
+}
+
+void wxTreeCtrl::DeleteAllItems() {
+ gtk_tree_item_remove_subtree(m_anchor);
+}
+
+void wxTreeCtrl::Expand(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return;
+
+ gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item));
+}
+
+void wxTreeCtrl::Collapse(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return;
+
+ gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item));
+}
+
+void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return;
+
+ gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item));
+ gtk_tree_item_remove_subtree(GTK_TREE_ITEM((GtkTreeItem *)item));
+}
+
+void wxTreeCtrl::Toggle(const wxTreeItemId& item) {
+ if (!item.IsOk())
+ return;
+
+ if (((GtkTreeItem *)item)->expanded)
+ gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item));
+ else
+ gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item));
+}
+
+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));