[Glade-users] GtkEntry



Hi Ian,
cancel_open is a callback function called during the gtk_main loop.
In the openfile code you unref the builder hence you can't use the
builder instance anymore.

You could take two solutions:
1. move g_object_unref (G_OBJECT (builder)) after gtk_main
2. use the same approach on Open variable: declare entry1 outside
cancel_open and get the "FileName" object before g_object_unref
(G_OBJECT (builder))

When the callback on_filechooserwidget2_confirm_overwrite get fired the object
GtkFileChooser is valid and is automatically passed to the function.

Hope you will have your program running soon.
Bye



2014-06-17 1:53 GMT+02:00 Ian Chapman <ichapman at videotron.ca>:
Hi Dome,
    Thanks for all your help getting me going with Glade.  (3.14.2 by the
way)  I have attached the file, just extract to a directory and run make
then ./main then File/Open and hit the cancel button that's modified to work
on the problem.  The code is in open.c and open.glade so you will be able to
see all the errors that I have made.  What I find odd is code in line 42 of
open is able to get the file's name without any reference to builder.  I
have much to learn.  Thanks Ian.


On 06/16/2014 03:49 AM, Domenico Ferrari wrote:

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






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