Re: Correct widget to report results to the user



Roger Leigh <roger whinlatter uklinux net> writes:

> Also, I was forced to use global variables due to needing to pass
> several widgets to the calculation function.  Is there any way to
> avoid this cleanly (i.e. pass them somehow through the callback)?

The standard way to do this is to allocate a block of memory and pass
a pointer to that block though the "data" parameter.

        typedef struct DataForCalculation DataForCalculation;
        struct DataForCalculation {
                ...;
        };

        DataForCalculation *data = g_new (DataForCalculation, 1);
        
        data->... = ...;

        g_signal_connect (..., data);
                
and then free the block in the callback.


Søren



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