Re: regarding signals!!!



vikram_dravid_sr ha scritto lo scorso 30/06/04 13.17:
hi will this work for text entered by the user too and not just a fixed or specified string.Thanks for sparing your time....

vik

I'm not sure to have well understood what you wish to say here, but the code snippet does exactly what you want:

/* This widget has only a GtkEntry, named entry1,
 * and a GtkButton, named button1
 * when you click on button1 the event
 * on_button1_clicked is fired
 */
void on_button1_clicked (GtkButton * button,
                         gpointer    user_data) {
    GtkWidget     * in,
                  * out;
    G_CONST_RETURN
            gchar * text;

    /* widget pointer *in* is retrieved by a commodity
     * function lookup_widget, which is generated by
     * Glade (yes, I know, I should begin using
     * libglade :-) )
     */
    in = lookup_widget (GTK_WIDGET (button), "entry1");

    /* text-entry content
     */
    text = (gchar *)gtk_entry_get_text (GTK_ENTRY (in));
    /* after this, text contains what you entered, before
     * clicking on button1, in entry1, and then...
     * printout to console
     */
    g_print ("> %s\n", text);
}




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