[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Huge GtkTree and expanded nodes
- From: Michael Vance <briareos lokigames com>
- To: gtk-app-devel-list redhat com
- Subject: Huge GtkTree and expanded nodes
- Date: Tue, 22 Jun 1999 16:18:02 -0700
Hello,
I have a tree with about 24 nodes, each of which can have from 10 to 500
children. When I create the tree, for some reason the entire tree is expanded
when it is displayed. However, the components don't THINK they are expanded.
The parent node is not drawn as connected (even though it's children are all
displayed), so I have to click to "expand" it (and the connecting line is
drawn), then click a second time to "really" collapse it.
I'm explicitly calling gtk_tree_item_collapse() in my code as a result of this,
but it doesn't appear to help.
I have other tree code that doesn't do this--it displays properly. Here's a
snippet of my code. It assumes a global GtkTree* tree.
void add_subgroups_to_group( GtkWidget* item, file_tag tag )
{
int i = 0;
GtkWidget* sub_tree = 0;
int num_subgroups = tag_file_count_subgroup_headers( tag );
if( num_subgroups <= 0 ) {
return;
}
sub_tree = gtk_tree_new( );
gtk_tree_item_set_subtree( GTK_TREE_ITEM( item ), sub_tree );
gtk_widget_show( sub_tree );
for( i = 0; i < num_subgroups; ++i ) {
long header = tag_file_get_indexed_header( tag, i );
char* name = tag_file_name_get( header );
GtkWidget* sub_item = gtk_tree_item_new_with_label( name );
gtk_signal_connect( GTK_OBJECT( sub_item ), "select",
GTK_SIGNAL_FUNC( tree_item_selected ), NULL );
gtk_signal_connect( GTK_OBJECT( sub_item ), "expand",
GTK_SIGNAL_FUNC( tree_item_expanded ), NULL );
gtk_signal_connect( GTK_OBJECT( sub_item ), "collapse",
GTK_SIGNAL_FUNC( tree_item_collapsed ), NULL );
gtk_tree_append( GTK_TREE( sub_tree ), sub_item );
gtk_widget_show( sub_item );
/* PENDING */
gtk_tree_item_collapse( GTK_TREE_ITEM( sub_item ) );
}
}
void build_tree( void )
{
int num_groups = 0;
int i = 0;
file_tag* groups = 0;
clear_tree( );
num_groups = tag_group_count_headers( );
groups = (file_tag*) malloc( num_groups * sizeof( file_tag ) );
if( groups == NULL ) {
fprintf( stderr, "fear: could not allocate memory at %s:%d\n", __FILE__, __LINE__ );
exit( 1 );
}
/* Fill in the groups structure. */
tag_group_get_group_tags( groups );
/* Add the groups to the tree. */
for( i = 0; i < num_groups; ++i ) {
char* name = tag_group_get_name( groups[i] );
GtkWidget* item = gtk_tree_item_new_with_label( name );
gtk_signal_connect( GTK_OBJECT( item ), "select",
GTK_SIGNAL_FUNC( tree_item_selected ), NULL );
gtk_signal_connect( GTK_OBJECT( item ), "expand",
GTK_SIGNAL_FUNC( tree_item_expanded ), NULL );
gtk_signal_connect( GTK_OBJECT( item ), "collapse",
GTK_SIGNAL_FUNC( tree_item_collapsed ), NULL );
gtk_tree_append( GTK_TREE( tree ), item );
gtk_widget_show( item );
gtk_tree_item_collapse( GTK_TREE_ITEM( item ) );
add_subgroups_to_group( item, groups[i] );
}
}
Any help is appreciated. I can post some screenshots of the aberrant behaviour,
if interested.
Thanks,
m.
--
"How wonderful! How mysterious Programmer
I carry wood! I draw water!" Loki Entertainment Software
- Anonymous Tao poet
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]