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



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'

Please help.

No idea how this works (well I kind of have but....), but try the
following:

   GtkWidget        *label;
    GList            *glist;


  widget = lookup_widget(window_widget_is_on, "slider_button"); /* may not
need this as long as you have a pointer to the widget you'll be okay*/

    glist = gtk_container_children( GTK_CONTAINER(widget) );
   label = GTK_WIDGET( glist->data );
    gtk_label_set( GTK_LABEL(label), "FRED");

I found this after trawling through stacks of stuff on the web, all seemed
a bit mysterious to me, as I too had similar problems in setting/changing
the label for the button.
I found the answer in a posting from 1998 from someone complaining about
the lack of useful documentation....
yet I still find myself wandering how the hell did they know to A) use a
GList, and B) that is has a member called data.  Half the time the
documentation states that the structure should only be accessed using the
functions given...  which in turn can only be used with this "extra"
knowledge.
I realise this is more of a GTK problem than glade specific, but I'm sure
there are many other relative "newbies" like myself who feel slightly lost
at times.

Jered.






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