Accessing a GtkTable's children.




Hello everyone,

I hope this is the proper place to post this! I am developing a graphical
front-end for a
diagnostics panel for an autonomous vehicle. I am fairly new to C++ and GTK.
I've
searched all over for the solution but maybe I'm looking for the wrong
things.

I cobbled together the widgets using Glade-2. I have a GtkTable that lays
out all the needed
widgets in a grid.  Now I am working in callbacks.c and need to be able to
alter a label when
a toggle button is pressed.

I have gotten fairly far but am now stuck:

//Callback function, the stub of which was automatically generated by
Glade-2
//It is called when ever the toggle button "enable" is clicked.
//This event is called when you press the enable/disable toggle button for
the estop.

void on_toggletoolbutton_enable_toggled( GtkToggleToolButton
*toggletoolbutton,  gpointer user_data )
{

//Getting the parent of the toggle button, my table
GtkTable *parent = (GtkTable*) gtk_widget_get_parent( (GtkWidget*)
toggletoolbutton);
//Getting the list of children widgets from the table. I checked and it has
the correct number of children.
GList *children = g_list_first(parent->children);
//Iterate through and print the name of each child widget
while (children)
{
        //Get the first widget from the list
        GtkWidget *test = (GtkWidget*) (g_list_first(children)->data);
        //Print the name of this widget
        g_print(gtk_widget_get_name (test));
        //Knock the first widget off of the list
        children = g_list_next(children);
}

This code does not work. I get the following errors 16 times (the number of
children in my table):

(dash:10933): Gtk-CRITICAL **: gtk_widget_get_name: assertion `GTK_IS_WIDGET
(widget)' failed
(dash:10933): GLib-CRITICAL **: g_print: assertion `format != NULL' failed

What am I doing wrong? If anyone could help me it would be greatly
appreciated. I have been fighting with this all day.

- Craig

-- 
View this message in context: http://www.nabble.com/Accessing-a-GtkTable%27s-children.-tf3539983.html#a9881778
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]