Re: Referencing Widgets?

On Mon, 2003-09-01 at 13:24, Mikoyan wrote:
> On Mon, 2003-09-01 at 18:48, Steve Woodward wrote:
> > I'm sure this is an FAQ but I've been unable to find the right answer.
> > I'm new to GTK and Linux programming, my background is C programming in
> > Windows and a little for the Mac. I'm using Glade to build an interface
> > to a simple one window conversion type app. The confusion I am facing
> > revolves around referencing widgets. Let's say I want to get the
> > contents of an entry field. It seems that I cannot reference the entry
> > field directly as in:
> > 
> > temp = gtk_editable_get_chars(GTK_EDITABLE(entryStartNum), 0, -1);
> > 
> > The above results in a seg fault. I've seen something about
> > lookup_widget, but you have to specify some other widget as the first
> > parameter.
> > So I guess what I am ultimately asking is how to reference
> > widgets...many thanks in advance.
> First of all, questions about gtk programming or gtk app programming
> belong in gtk-app-devel list.
> To answer your question. Glade-2 produces an interface.h file. In this
> file several *create functions are declared. E.g. create_window1().
> This function creates obviously a window and returns it as a GtkWidget*.
> E.g:
> GtkWidget *myWindow = create_window1();
> Make sure the widgets you want to reference are proper named via the
> glade-2 editor. I assume your entryStartNum has the name "entryStartNum"
> :-)
> Use lookup_widget as in the next example:
> GtkWidget *myEntry = lookup_widget(myWindow, "entryStartNum");
> It's that simple. Btw, it may proof usefull to look at libglade2 where
> the glade files (which are xml files) are used to create your UI.
> 	Steven
> > Steve W
> > 

My apologies for grabbing the wrong list, will be sure to subscribe to
the appropriate list. 
Thanks for the reply, that helps to clear things up. I was under the
impression that by having the widgets defined in interface.h I could
reference them other words, if entryStartNum is defined in
interface.h I could just refer to it by that name without having to
declare another variable. But I get it now, and I'm past that hurdle and
on to the next! Many, many thanks.

Steve W

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