[Glade-users] How to get to the label field of a button

Damon Chaplin damon@ximian.com
Mon, 14 May 2001 16:19:59 -0400


Ed Winchester wrote:
> 
> Hi again, all,
> 
> I've been trying to get my glade-generated app to compile.  I know, from
> something I read, but can't remember where, that Glade itself will not
> generate code to change the label for a button.  I remember seeing
> somewhere an example, but can't for the life of me remember where I read
> that.
> 
> What I tried last was:
>     gtk_label_set_text (GTK_LABEL(button->label),"New button label");
> 
> I got the error:
>     structure has no member named `label'

A GtkButton is a subclass of GtkBin, which only has one child widget.

So to get the label you use:

 GTK_BIN (button)->child

To set the label you can do:

   gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), "New button label");



Damon