Is it possible to have a callback if any widget get is getting destroyed.
In the following code, for example, I want the callback to be executed if spin button is getting destroyed.
If you want to associate some data to a widget and free it when the widget is destroyed, you have two options:
use the GtkWidget::destroy signal, connect a callback to it, and free the data; this is similar to what you did above
use g_object_set_data_full() to store the data on the widget instance, and have it freed when the object is finalized, e.g.:
// Your use of calloc() is wrong; the second argument is the size of each element
int *int_array = calloc (10, sizeof (int));
g_object_set_data_full (G_OBJECT (spin),
"spin-data-array",
int_array,
(GDestroyNotify) free);
you can retrieve the data pointer from the instance using g_object_get_data().
(a.out:13235): GLib-GObject-WARNING **: 10:04:52.312: …/…/…/gobject/gsignal.c:2617: signal ‘destory’ is invalid for instance ‘0x55fa2a7341a0’ of type ‘GtkBox’
main 25 Unable to connect