2016-05-16 17:34:04 +03:00
|
|
|
/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html
|
|
|
|
*/
|
2013-08-06 13:33:59 +04:00
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define MAMAN_TYPE_BAR (maman_bar_get_type())
|
|
|
|
#define MAMAN_BAR(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), MAMAN_TYPE_BAR, MamanBar))
|
|
|
|
#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MAMAN_TYPE_BAR))
|
|
|
|
#define MAMAN_BAR_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), MAMAN_TYPE_BAR, MamanBarClass))
|
|
|
|
#define MAMAN_IS_BAR_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), MAMAN_TYPE_BAR))
|
|
|
|
#define MAMAN_BAR_GET_CLASS(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS((obj), MAMAN_TYPE_BAR, MamanBarClass))
|
2013-08-06 13:33:59 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
typedef struct _MamanBar MamanBar;
|
|
|
|
typedef struct _MamanBarClass MamanBarClass;
|
2013-08-06 13:33:59 +04:00
|
|
|
|
|
|
|
struct _MamanBar
|
|
|
|
{
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
|
|
/* instance members */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _MamanBarClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
|
|
|
/* class members */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* will create maman_bar_get_type and set maman_bar_parent_class */
|
2016-05-16 17:34:04 +03:00
|
|
|
G_DEFINE_TYPE(MamanBar, maman_bar, G_TYPE_OBJECT);
|
2013-08-06 13:33:59 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static GObject* maman_bar_constructor(GType gtype, guint n_properties,
|
|
|
|
GObjectConstructParam* properties)
|
2013-08-06 13:33:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
GObject* obj;
|
2013-08-06 13:33:59 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
/* Always chain up to the parent constructor */
|
2016-05-16 17:34:04 +03:00
|
|
|
obj = G_OBJECT_CLASS(maman_bar_parent_class)
|
|
|
|
->constructor(gtype, n_properties, properties);
|
2013-08-06 13:33:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update the object state depending on constructor properties */
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void maman_bar_class_init(MamanBarClass* klass)
|
2013-08-06 13:33:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
|
2013-08-06 13:33:59 +04:00
|
|
|
|
|
|
|
gobject_class->constructor = maman_bar_constructor;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void maman_bar_init(MamanBar* self)
|
2013-08-06 13:33:59 +04:00
|
|
|
{
|
|
|
|
/* initialize the object */
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int main(int argc, char* argv[])
|
2013-08-06 13:33:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
MamanBar* bar = g_object_new(MAMAN_TYPE_BAR, NULL);
|
|
|
|
g_object_unref(bar);
|
|
|
|
return 0;
|
2013-08-06 13:33:59 +04:00
|
|
|
}
|