[Glade-users] GtkEntry
Domenico Ferrari
domfe at tiscali.it
Mon Jun 16 07:49:26 UTC 2014
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.
Cheers.
Dome
2014-06-13 21:15 GMT+02:00 Ian Chapman <ichapman at videotron.ca>:
> Hi and thanks Dome,
> I have
> void
> 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
>>
>> https://developer.gnome.org/gtk3/stable/GtkBuilder.html#gtk-builder-get-object
>>
>> have a nice day,
>> Dome
>>
>>
>> 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
>>> back
>>> to my original post, "I have In glade 3.14.2 I have window with a
>>> container
>>> box and in one of the compartments of the box I have Text Entry that
>>> shows
>>> in the inspector as GtkEntry (FileName)". I'm not able to connect what
>>> you
>>> have to what I have in glade. I can connect and service signals from
>>> glade
>>> and now I want to initiate a action on GtkEntry(FileName) so as to read
>>> and
>>> write into the test field. Please help Ian.
>>> PS
>>> I'm using old glade2 tutorials and the manual
>>> https://developer.gnome.org/gtk3/stable/GtkEntry.html which is rater
>>> terse.
>>> 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 ;
>>>>
>>>> myEntry=gtk_entry_new();
>>>>
>>>> ...
>>>>
>>>> text = gtk_entry_get_text( GTK_ENTRY(myEntry));
>>>>
>>>>
>>>> Cheers,
>>>> Dome
>>>> _______________________________________________
>>>> Glade-users maillist - Glade-users at lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/glade-users
>>>>
>
More information about the Glade-users
mailing list