Question
Can someone tell me how I can tell GObject, which function my destructor function is?
Code
For reference, I post example skeleton code for a widget.
header
#ifndef __MY_WIDGET_H__
#define __MY_WIDGET_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define TYPE_MY_WIDGET my_widget_get_type ()
// note: member vars of derivable classes go into MyWidgetPrivate (see c file)
G_DECLARE_DERIVABLE_TYPE(MyWidget, my_widget, MY, WIDGET, GtkButton)
struct _MyWidgetClass
{
GtkButtonClass parent_class;
};
GtkWidget* my_widget_new (void);
G_END_DECLS
#endif /* include-protector */
c-file
#include "mywidget.h"
typedef struct _MyWidgetPrivate MyWidgetPrivate;
struct _MyWidgetPrivate
{
char dummy; // we need at least one elem within our class
};
G_DEFINE_TYPE_WITH_PRIVATE(MyWidget, my_widget, GTK_TYPE_BUTTON)
// @brief: class constructor
static void
my_widget_class_init (MyWidgetClass* klass)
{
// override class methods from GtkButton:
// GtkButtonClass * parent = GTK_BUTTON_CLASS(klass);
}
// object constructor
static void
my_widget_init (MyWidget* self)
{
// init variables
// init private variables:
// MyWidgetPrivate * priv = my_widget_get_instance_private(self);
}
// object destructor: How do I announce it?
stattic void
my_widget_uninit (MyWidget *self)
{
}
GtkWidget*
my_widget_new ()
{
GtkWidget * self = g_object_new (my_widget_get_type(), NULL);
// stuff that doesn't work within init can be done here
return self;
}