Problem when reparenting gtktrees
- From: Ian King <king eiffel com>
- To: gtk-list gnome org
- Subject: Problem when reparenting gtktrees
- Date: Fri, 24 Nov 2000 10:49:17 -0800
Hi all,
I have a problem with gtktree regarding reparenting. When I have a gtktree that has tree items with subtrees, if I remove the tree from its parent and then put it back, the expand/collapse pixmaps on the gtkitems completely disappear rendering the tree unusable. Is there a way around this as I need to be able to reparent a tree that has been fully initialized? I have included a sample program that illustrates this behaviour.
Thanks for your time
Ian
#include <gtk/gtk.h>
GtkWidget *but, *tree, *vbox, *subtree, *item;
gint button_clicked (GtkWidget *wid, gpointer user_data)
{
gtk_widget_ref (tree);
gtk_container_remove (GTK_CONTAINER (vbox), tree);
gtk_container_add (GTK_CONTAINER (vbox), tree);
gtk_widget_unref (tree);
}
int main( int argc, char *argv[] )
{
GtkWidget *window, *subtreeitem;
gtk_init (&argc, &argv);
/* a generic toplevel window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER(window), 5);
tree = gtk_tree_new();
but = gtk_button_new_with_label ("HELLO");
gtk_widget_show (but);
vbox = gtk_vbox_new (FALSE, FALSE);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (vbox), but);
gtk_container_add (GTK_CONTAINER (vbox), tree);
gtk_container_add (GTK_CONTAINER(window), vbox);
gtk_widget_show (tree);
item = gtk_tree_item_new_with_label ("Tree item");
gtk_tree_append (GTK_TREE(tree), item);
gtk_widget_show (item);
subtree = gtk_tree_new();
subtreeitem = gtk_tree_item_new_with_label ("Sub tree item");
gtk_tree_append (GTK_TREE(subtree), subtreeitem);
gtk_widget_show (subtreeitem);
gtk_tree_item_set_subtree (GTK_TREE_ITEM (item), subtree);
gtk_widget_show (window);
gtk_signal_connect (GTK_OBJECT (but), "clicked", GTK_SIGNAL_FUNC (button_clicked), NULL);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]