Back to index

unity  6.0.0
test_glib_object_utils.cpp
Go to the documentation of this file.
00001 #include "test_glib_object_utils.h"
00002 
00003 struct _TestGObjectPrivate
00004 {
00005   int private_value;
00006 };
00007 
00008 G_DEFINE_TYPE(TestGObject, test_gobject, G_TYPE_OBJECT);
00009 
00010 static void
00011 test_gobject_class_init(TestGObjectClass* klass)
00012 {
00013   g_type_class_add_private (klass, sizeof (TestGObjectPrivate));
00014 }
00015 
00016 static void
00017 test_gobject_init(TestGObject* self)
00018 {
00019   TestGObjectPrivate *priv;
00020   self->priv = TEST_GOBJECT_GET_PRIVATE(self);
00021   priv = self->priv;
00022 
00023   priv->private_value = 55;
00024 }
00025 
00026 TestGObject*
00027 test_gobject_new()
00028 {
00029   return TEST_GOBJECT(g_object_new(TEST_TYPE_GOBJECT, NULL));
00030 }
00031 
00032 void test_gobject_set_private_value(TestGObject *self, gint value)
00033 {
00034   TestGObjectPrivate *priv;
00035   g_return_if_fail(TEST_IS_GOBJECT(self));
00036 
00037   priv = TEST_GOBJECT_GET_PRIVATE(self);
00038   priv->private_value = value;
00039 }
00040 
00041 gint test_gobject_get_private_value(TestGObject *self)
00042 {
00043   TestGObjectPrivate *priv;
00044   g_return_val_if_fail(TEST_IS_GOBJECT(self), 0);
00045 
00046   priv = TEST_GOBJECT_GET_PRIVATE(self);
00047   return priv->private_value;
00048 }
00049 
00050 void test_gobject_set_public_value(TestGObject *self, gint value)
00051 {
00052   g_return_if_fail(TEST_IS_GOBJECT(self));
00053 
00054   self->public_value = value;
00055 }
00056 
00057 gint test_gobject_get_public_value(TestGObject *self)
00058 {
00059   g_return_val_if_fail(TEST_IS_GOBJECT(self), 0);
00060 
00061   return self->public_value;
00062 }