Re: Quick newbie question



Hello Ben!

Tue, 04 Mar 2003 21:12:33 +0000, you wrote: 

 > Hey everyone,
 > I am just starting to get into GTK+ programming, So far I am doing
 > pretty well but I am stuck at a certain point. I want to have a text
 > entry and then a button to submit the information - lets just say when
 > you hit submit, it pops up a new window that shows the information you
 > had in the box. My problem is that I can't find out how to access the
 > data from the text entry, once the "clicked" signal is received from
 > the button. Can anyone help me out here?

Sure. There are two ways to do that: either give the address of the entry
as the user parameter of the callback (the gpointer data), or use the
g_object_set_data on the button, like 
g_object_set_data (G_OBJECT (button), "text-entry", entry); and then gets
the data via g_object_get_data.

The first one is a bit faster, but can be hard to use if you need more
than one parameter in the button's callback (you'll have then to you a
struct, malloc it and then free it...). That's why I often tend to use
the second solution if it's not on a perf-critical part of the program
(usually, something that happens only once when an user clicks is not).

-- 
Gael Le Mignot "Kilobug" - kilobug nerim net - http://kilobug.free.fr
GSM         : 06.71.47.18.22 (in France)   ICQ UIN   : 7299959
Fingerprint : 1F2C 9804 7505 79DF 95E6 7323 B66B F67B 7103 C5DA

Member of HurdFr: http://hurdfr.org - The GNU Hurd: http://hurd.gnu.org



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