Re: Referencing Widgets?
Owen Taylor wrote: > and switch to using libglade instead of generating code with Glade Just three things I noticed when using (lib)glade2: 1) error displaying notebooks w/ empty pages (only the last tab is displayed) 2) missing first and last page in GnomeDruid 3) sometimesbutton and user_data are swapped for "clicked" signal (IIRC if user_data is not NULL) Using Glade to generate the code does work, obv! BYtE, Diego. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Referencing Widgets?
On Mon, 2003-09-01 at 14:08, Steve Woodward wrote: > 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 directly...in 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. Please see: http://lists.ximian.com/archives/public/glade-devel/2003-February/15.html and switch to using libglade instead of generating code with Glade Regards, Owen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
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 directly...in 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 ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Referencing Widgets?
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 > > ___ > gtk-list mailing list > [EMAIL PROTECTED] > http://mail.gnome.org/mailman/listinfo/gtk-list > > ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Referencing Widgets?
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. Steve W ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: referencing widgets
John Cupitt <[EMAIL PROTECTED]> writes: > HaB balicious wrote: > > My question is this. In the function I call via the OK buttons "clicked" > > event, is there a way to reference each of the entry widgets separately? > > IOW, since they were all created with the same declared var, 'entry', is > > there a way to tell which is which once I am in another func? Or do I have > > to create them all separately, passing each one's variable out to the verify > > func? Make them global? > > Hiya, the usual way to do this is to make a struct with a member for > each of your widgets. g_new() one of your structs when you build the > dialog, set the members as you build the widgets, pass the address of > the struct to the callback, and free the struct on destroy. Another possibility is to add the widget pointers to the OK button using gtk_object_set_data (object, "some_descriptive_name, pointer) and retrieving them in the callback using gtk_object_get_data(). Salut, Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: referencing widgets
HaB balicious wrote: > My question is this. In the function I call via the OK buttons "clicked" > event, is there a way to reference each of the entry widgets separately? > IOW, since they were all created with the same declared var, 'entry', is > there a way to tell which is which once I am in another func? Or do I have > to create them all separately, passing each one's variable out to the verify > func? Make them global? Hiya, the usual way to do this is to make a struct with a member for each of your widgets. g_new() one of your structs when you build the dialog, set the members as you build the widgets, pass the address of the struct to the callback, and free the struct on destroy. HTH, John ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
referencing widgets
Greetings all... I'm fairly new to GTK and to C for that matter, but I cannot seem to find an example, or docs that describe exactly what I'm trying to do. The accepted MO I see most often for adding multiples of any object to a window seems to be something along the line of: GtkWidget *CreateWindow ( void ) { GtkWidget *window; GtkWidget *label; GtkWidget *entry; /* toplevel window creation code omitted for * space conservation purposes */ label = gtk_label_new ("First Name: "); entry = gtk_entry_new ( ); /* Pack and show the above 2 widgets, then... */ label = gtk_label_new ("Last Name: "); entry = gtk_entry_new ( ); /* pack and showrepeat as needed */ /* create, pack and show OK and cancel buttons, then: */ gtk_widget_show (window); return ( window ); } My question is this... Let's say this window is a dialog box, that contains entries for First name, last name, and phone number. After the user clicks the 'OK' button, I wish to call a sub to verify the data entered (no blank fields, no funny business with escape chars, etc). My question is this. In the function I call via the OK buttons "clicked" event, is there a way to reference each of the entry widgets separately? IOW, since they were all created with the same declared var, 'entry', is there a way to tell which is which once I am in another func? Or do I have to create them all separately, passing each one's variable out to the verify func? Make them global? My intuition was that this was what gtk_widget_set_name() was for. Like...after creating the entry, before creating another, I call gtk_widget_set_name on it, then in my verify func, I could refer to them according to parent->. Apparently this is not the case. Could someone shed some light on this for me? Thanks... -HaB _ Get your FREE download of MSN Explorer at http://explorer.msn.com ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list