How do I pass multiple variables as data with gtk signals

后端 未结 3 1897
再見小時候
再見小時候 2021-02-14 02:01

I have a small program where a gtk signal callback function needs 2 or 3 variables.

I don\'t want to make these global variables (The entire goal of the project is to be

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 02:26

    Expanding on H2CO3's answer, you can also set the data (and I strongly recommend using a struct, by the way) to be freed automatically when the signal handler is disconnected:

    g_signal_connect_data(save, "clicked", callback, data, (GClosureNotify)free, 0);
    

提交回复
热议问题