#include <gtk/gtk.h>


GQuark quark_test = 0;

void initialize_quark()
{
  if(!quark_test)
  {
    g_warning("initializing quark.");
    quark_test = g_quark_from_static_string("quarktestmurrayc");
  }
}

void on_object_destroyed(GObject* object, gpointer data)
{
  g_warning("on_object_destroyed():  c instance=%10X", object);
}

void on_object_qdata_destroyed(gpointer data)
{
  //This doesn't seem to be called:
  g_warning("on_object_qdata_destroyed():  c instance=%10X", data);
}

int main(int argc, char**argv)
{
  gtk_init(&argc, &argv);

  GtkWidget* object = gtk_button_new();

  //Set a quark and a callback:
  initialize_quark();
  int a = 0;
  g_object_set_qdata_full((GObject*)object, quark_test, &a, &on_object_qdata_destroyed);
 
  //Set a normal destroy notification callback.
  g_signal_connect(G_OBJECT(object), "destroy",
		      G_CALLBACK(on_object_destroyed), 0);
 
  //This causes on_object_destroyed() to be called,
  //but not on_object_qdata_destroyed():
  gtk_widget_destroy( (GtkWidget*)object );

  return 0;
}

