[Glade-users] GtkEntry

Hi Ian.
Please post the entire code...
You don't need the reference to the build when you have the object.
The builder is used for loading and presenting the dialog and is
needed to get the object with gtk_builder_get_object.


2014-06-13 21:15 GMT+02:00 Ian Chapman <ichapman at videotron.ca>:
Hi and thanks Dome,
I have
cancel_open () {
    printf("\n Cancel button clicked. \n");

GtkWidget *entry1;
entry1 = GTK_WIDGET(gtk_builder_get_object(builder, "FileName"));
gtk_entry_set_text(GTK_ENTRY(entry1), "Hello Ian");

//        gtk_main_quit();
    return;  }
Where FileName is what I called the GtkEntry in Glade 3.14.2.  It compiles
without error using FileName or entry1 in its place, links too but when I
run I get
 Cancel button clicked.

(main:24755): Gtk-CRITICAL **: gtk_builder_get_object: assertion
`GTK_IS_BUILDER (builder)' failed

(main:24755): Gtk-CRITICAL **: gtk_entry_set_text: assertion `GTK_IS_ENTRY
(entry)' failed

        but the program does not crash in fact the rest of it is still
running.  Another thing that strikes me as odd

    gchar *cName_pt = NULL;
    cName_pt = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(fs));
    printf("\n cName_pt =  %s .\n", cName_pt);

        because I can get the selected file without any reference to
builder?  Any suggestions greatly appreciated.  Ian.

On 06/11/2014 04:00 AM, Domenico Ferrari wrote:

Hi Ian.
Some hints...

To get the entry object from GtkBuilder
GtkWidget *entry1=GTK_WIDGET(gtk_builder_get_object(builder, "entry1"));

set the text
gtk_entry_set_text(GTK_ENTRY(entry1), "some text");

and then get the text
text = gtk_entry_get_text( GTK_ENTRY(entry1));

see the manual at


have a nice day,

2014-06-11 1:26 GMT+02:00 Ian Chapman <ichapman at videotron.ca>:

Thanks Dome,
     This code you sent me compiled so that's a step forward.  As I
understand it "myEntry=gtk_entry_new(); " creates a new widget.  Going
to my original post, "I have In glade 3.14.2 I have window with a
box and in one of the compartments of the box I have Text Entry that
in the inspector as GtkEntry (FileName)". I'm not able to connect what
have to what I have in glade.  I can connect and service signals from
and now I want to initiate a action on GtkEntry(FileName) so as to read
write into the test field.  Please help Ian.
I'm using old glade2 tutorials and the manual
https://developer.gnome.org/gtk3/stable/GtkEntry.html which is rater
I need to find more on macros.

On 06/10/2014 05:22 AM, Domenico Ferrari wrote:

You should use GTK_ENTRY instead of a direct cast because GTK_ENTRY
does type checking.

GtkWidget *myEntry;
const char* text ;



text = gtk_entry_get_text( GTK_ENTRY(myEntry));

Glade-users maillist  -  Glade-users at lists.ximian.com

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