Re: [gtk-list] setting/getting the text of button



Sami Juhani Kallio wrote:
> This might be a stupid question, but is there a way to access the
> label element of a button, if it was created by gtk_button_new_with_label?

Well, it's somewhat inelegant, but I'd use something like:

    GtkWidget        *button;
    GtkWidget        *label;
    GList            *glist;
    gchar            *labeltext;

     ...

    glist = gtk_container_children( GTK_CONTAINER(button) );
    label = GTK_WIDGET( glist->data );
    gtk_label_get( GTK_LABEL(label), &labeltext );
    
    printf( "Label: %s\n", labeltext );

     ...

Of course this assumes that you didn't put anything else
into the button.  If you did, you just have to loop through
the children until you find the label, I think.



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