Re: Is it possible to share a callback function in order to detect which a button is clicked?



On Fri, Feb 05, 2010 at 03:34:08AM -0800, Ken Resander wrote:
> I cannot see the dm userdata parameter being initialised.
> 
> Insert dm->clicked = num; before g_signal_connect in the double-nested  loop. 
> Then you can test on dm->clicked in the callback to check which
> button is clicked.

There is only one instance of dm in the entire program so this won't
work, you will always get whatever was last assigned to dm->clicked.

To make it work you need one dm (or whatever kind of data) per widget.
g_object_set_data() is the mechanism to attach arbitrary data to
objects.

Yeti



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