Re: gtk custom widgets



On Thu, Oct 21, 2004 at 04:08:46PM +0800, Daniel Piccoli wrote:
the main reason I'm creating a new widget is to enable me to store a
struct that contains info about a sound file that is displayed by this
widget. I don't see any other way to do it. If I don't create a
composite widget, this struct data will be lost once the signal handler
function which creates it completes.

If you only need to attach pointer to some data to a widget,
you can use something like

    g_object_set_data(G_OBJECT(widget), "sound-file-info", whatever);

where whatever is the data pointer, and retrieve it with
g_object_get_data() later.  If whatever can be destroyed
sooner than the widget, g_object_get_data() with NULL as the
data arg will unset it.

However, if the widget itself should care about the info
subclassing is a much better solution.

Yeti


--
Dynamic IP address is not a crime.



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