Unable to get all child widgets
- From: "Dugas, Alan" <alan dugas analog com>
- To: gtk-app-devel-list gnome org, gtk-list gnome org
- Subject: Unable to get all child widgets
- Date: Wed, 20 Sep 2000 20:47:38 -0400
I am trying to retrieve the pointer of each widget contained within a window.
The wigets are packed as follows: the window contains a gtkvbox, the gtkvbox
contains a gtkhbox, gtktable, & gtkcombo, the gtkhbox contains 2 gtklabels and 2
gtkcombos. So far I get all but those which are contained within an hbox using
the code snippet below. It is failing the GTK_IS_COMBO test in the for loop
which sets "histogram_bins_combo". I know this because I get the following
error when I later try to use "histogram_bins_combo" as I discovered while using
ddd/gdb:
Gtk-WARNING **: invalid cast from (NULL) pointer to 'GtkCombo'
segmentation fault
Can anyone see where I've gone wrong? Is it possible to retrieve widgets
contained within a container that are themselves within a container (i.e.
retrieve a gtkcombo contained within a gtkhbox, which in turn is contained
within a gtkvbox, which in turn is contained within a gtkwindow)? If so, is
there a limit to the depth of the hierarchy? Any and all help would be
appreciated.
GtkWidget *vbox = (GtkWidget *) NULL,
*hbox = (GtkWidget *) NULL,
*table = (GtkWidget *) NULL,
*drawing_area = (GtkWidget *) NULL,
*test_list_combo = (GtkWidget *) NULL,
*histogram_bins_combo = (GtkWidget *) NULL,
*vruler = (GtkWidget *) NULL,
*hruler = (GtkWidget *) NULL;
GList *widget_list;
/* Setting widget address' to local variable names */
for ( widget_list = gtk_container_children(GTK_CONTAINER(histogram_window)) ;
widget_list != NULL ; widget_list = widget_list->next )
{
if ( GTK_IS_VBOX(GTK_OBJECT(widget_list->data)) )
vbox = GTK_WIDGET(widget_list->data);
}
g_free(widget_list);
for ( widget_list = gtk_container_children(GTK_CONTAINER(vbox)) ; widget_list !=
NULL ; widget_list = widget_list->next )
{
if ( GTK_IS_HBOX(GTK_OBJECT(widget_list->data)) )
hbox = GTK_WIDGET(widget_list->data);
if ( GTK_IS_TABLE(GTK_OBJECT(widget_list->data)) )
table = GTK_WIDGET(widget_list->data);
if ( GTK_IS_COMBO(GTK_OBJECT(widget_list->data)) )
test_list_combo = GTK_WIDGET(widget_list->data);
}
g_free(widget_list);
for ( widget_list = gtk_container_children(GTK_CONTAINER(hbox)) ; widget_list !=
NULL ; widget_list = widget_list->next )
{
if ( GTK_IS_COMBO(GTK_OBJECT(widget_list->data)) )
histogram_bins_combo = GTK_WIDGET(widget_list->data);
}
g_free(widget_list);
for ( widget_list = gtk_container_children(GTK_CONTAINER(table)) ; widget_list
!= NULL ; widget_list = widget_list->next )
{
if ( GTK_IS_DRAWING_AREA(GTK_OBJECT(widget_list->data)) )
drawing_area = GTK_WIDGET(widget_list->data);
if ( GTK_IS_HRULER(GTK_OBJECT(widget_list->data)) )
hruler = GTK_WIDGET(widget_list->data);
if ( GTK_IS_VRULER(GTK_OBJECT(widget_list->data)) )
vruler = GTK_WIDGET(widget_list->data);
}
g_free(widget_list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]