Re: gtk custom widgets



Daniel Piccoli wrote:

If I don't create a
composite widget, this struct data will be lost once the signal handler
function which creates it completes.

Does this sound reasonable?

You can simply do

    extra_data = g_malloc (sizeof (DataStructure));
    extra_data->... = ...;
    ...

    g_signal_connect (widget, "some-signal",
                      G_CALLBACK (some_callback), extra_data);
    g_signal_connect_swapped (widget, "destrory",
                              G_CALLBACK (g_free), extra_data);

If you data is statically scoped, you don't even need to hook up the
g_free() call.  I typically go onto subclassing when the required
functionality is complicated enough to justify breaking it out into
a separate file.

Paul






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