Re: Accessing a GtkTable's children.
- From: "Craig Pemberton" <craigpemberton gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Accessing a GtkTable's children.
- Date: Sat, 7 Apr 2007 05:15:46 -0500
I just discovered lookup_widget()! This makes life much easier. The code now
looks like the following. I'm not sure if this is best, but I used it by
getting the parent and then using lookup_widget() to look through it's
children.
I'm happy with this code now. Thanks again.
//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)
{
//We need the references to the widgets for the engage label and toggle
GtkTable* parent = (GtkTable*)
gtk_widget_get_parent((GtkWidget*)toggletoolbutton);
GtkWidget* label_engage = lookup_widget(parent,
"label_engage");
GtkWidget* toggletoolbutton_enable = lookup_widget(parent,
"toggletoolbutton_enable");
//These are the icons that show a connection and broken connecton
GtkIconSize icon_size = gtk_tool_item_get_icon_size( (GtkToolItem*)
toggletoolbutton);
GtkWidget *connect_image = gtk_image_new_from_stock ("gtk-connect",
icon_size);
GtkWidget *disconnect_image = gtk_image_new_from_stock
("gtk-disconnect", icon_size);
//If off when pressed, turn it on! The icon should indicate that it is
connected.
if (fstop_engaged == 0)
{
gtk_tool_button_set_icon_widget( (GtkToolButton*) toggletoolbutton,
connect_image);
gtk_label_set_text (label_engage, _("Enabled"));
//Redisplay the widgets
gtk_widget_show ( (GtkWidget*) toggletoolbutton);
gtk_widget_show ( (GtkWidget*) connect_image);
gtk_widget_show ( (GtkWidget*) label_engage);
fstop_engaged = 1;
}
//If on when pressed, turn it off! The icon should indicate that it is
disconnected.
else
{
gtk_tool_button_set_icon_widget( (GtkToolButton*) toggletoolbutton,
disconnect_image);
gtk_label_set_text (label_engage, _("Disabled"));
gtk_widget_show ( (GtkWidget*) toggletoolbutton);
gtk_widget_show ( (GtkWidget*) disconnect_image);
//Redisplay the widgets
gtk_widget_show ( (GtkWidget*) toggletoolbutton);
gtk_widget_show ( (GtkWidget*) connect_image);
gtk_widget_show ( (GtkWidget*) label_engage);
fstop_engaged = 0;
}
}
On 4/7/07, Craig Pemberton <craigpemberton gmail com> wrote:
Thank you so much Andrew!
It is now working beautifully. The final code is below for anyone who may
read this thread looking for the same fix.
void on_toggletoolbutton_enable_toggled( GtkToggleToolButton
*toggletoolbutton, gpointer user_data )
{
GtkTable *parent = (GtkTable*)
gtk_widget_get_parent((GtkWidget*)toggletoolbutton);
GList *children = gtk_container_get_children(parent);
int len = g_list_length(children);
int i;
for(i=0; i < len; i++)
{
GtkWidget *test = (GtkWidget*) g_list_nth_data(children,
i);
g_printf("Widget %d is %s.\n", i, gtk_widget_get_name
(test));
}
. . .
- Craig
--
View this message in context:
http://www.nabble.com/Accessing-a-GtkTable%27s-children.-tf3539983.html#a9882649
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]