Re: Tree problem
- From: "David Z. Maze" <dmaze donut mit edu>
- To: Bolliet Jerome <bolliet in2p3 fr>
- Cc: gtk-list redhat com
- Subject: Re: Tree problem
- Date: 12 Apr 1998 10:23:58 -0400
Bolliet Jerome <bolliet@in2p3.fr> writes:
BJ> I've you a piece of code that i can compil on my station and which
BJ> reproduc this problem ?
Sorry it took me so long to hack something together. I've attached a
test program I wrote that shows off some of what doesn't quite work in
GtkTree. This includes:
-- Calling gtk_tree_item_set_subtree(tree_item, subtree) before
calling gtk_tree_append(parent_tree, tree_item) causes a SIGSEGV.
-- Click on the "+" icon when gtktreetest starts; the "-" icon is
rather far off center.
-- Refresh the screen. Now the "-" is in the correct place, but the
line to the right of this also has a branch down to nothing. (It
looks like a "T" instead of a "-", even though there's nothing
beneath the "T".)
-- Press the "Append" button a few times. Each item that gets added
has a "L" line to its left, which is correct, but the previous item
also has an "L" which should change to a sideways "T". Refresh the
screen to see the correct output.
-- Pressing the "Delete" button causes a SIGSEGV on gdk_pixmap_unref()
when Gtk enters the event loop. (Why?) If you run the program in
gdb, you see that the last item has disappeared, which is correct,
but that the previous item still has a sideways "T" next to it,
which should be an "L".
--
_____________________________
/ \ "The cat's been in the box for over
| David Maze | 20 years. Nobody's feeding it. The
| dmaze@mit.edu | cat is dead."
| http://donut.mit.edu/dmaze/ | -- Grant, on Schroedinger's Cat
\_____________________________/
/*
* gtktreetest.c: Demo the brokenness in the Gtk+ tree implementation.
* David Maze <dmaze@mit.edu>
*/
#include <gtk/gtk.h>
struct itemlist
{
struct itemlist *next;
GtkWidget *item;
} *first;
/* Both of these are GtkTree objects. tree is the top-level tree; branch
* is the subtree that GtkTreeItems are being added to. */
GtkWidget *tree, *branch;
void append_item(void);
void delete_item(void);
int main(int argc, char **argv)
{
GtkWidget *window, *vbox, *widget;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "tree demo");
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
gtk_container_add(GTK_CONTAINER(window), vbox);
tree = gtk_tree_new();
gtk_widget_show(tree);
branch = gtk_tree_new();
gtk_widget_show(branch);
widget = gtk_tree_item_new_with_label("Branch");
gtk_widget_show(widget);
/* gtk_tree_item_set_subtree segv's if the tree_item isn't already part of
* a tree. Call gtk_tree_append first. */
gtk_tree_append(GTK_TREE(tree), widget);
gtk_tree_item_set_subtree(GTK_TREE_ITEM(widget), branch);
gtk_box_pack_start(GTK_BOX(vbox), tree, TRUE, FALSE, 0);
first = NULL;
widget = gtk_button_new_with_label("Append");
gtk_signal_connect(widget, "clicked", append_item, NULL);
gtk_box_pack_end(GTK_BOX(vbox), widget, TRUE, FALSE, 0);
gtk_widget_show(widget);
widget = gtk_button_new_with_label("Delete");
gtk_signal_connect(widget, "clicked", delete_item, NULL);
gtk_box_pack_end(GTK_BOX(vbox), widget, TRUE, FALSE, 0);
gtk_widget_show(widget);
gtk_widget_show(window);
gtk_main();
return 0;
}
void append_item(void)
{
struct itemlist *newitem;
newitem = malloc(sizeof(struct itemlist));
newitem->next = first;
newitem->item = gtk_tree_item_new_with_label("Item");
gtk_tree_append(GTK_TREE(branch), newitem->item);
gtk_widget_show(newitem->item);
first = newitem;
}
void delete_item(void)
{
struct itemlist *last;
if (!first)
return;
gtk_widget_hide(first->item);
gtk_container_remove(GTK_CONTAINER(branch), first->item);
last = first;
first = first->next;
free(last);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]