Everything: add a boxed property to TestObj
authorAndreas Rottmann <a.rottmann@gmx.at>
Wed, 17 Jun 2009 16:11:16 +0000 (18:11 +0200)
committerAndreas Rottmann <a.rottmann@gmx.at>
Wed, 17 Jun 2009 16:11:16 +0000 (18:11 +0200)
.topdeps [new file with mode: 0644]
.topmsg [new file with mode: 0644]
gir/Everything-1.0-expected.gir
gir/everything.c
gir/everything.h

diff --git a/.topdeps b/.topdeps
new file mode 100644 (file)
index 0000000..1f7391f
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+master
diff --git a/.topmsg b/.topmsg
new file mode 100644 (file)
index 0000000..33a72a5
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,2 @@
+From: Andreas Rottmann <a.rottmann@gmx.at>
+Subject: [PATCH] Everything: add a boxed property to TestObj
index daad5e2..e3b352d 100644 (file)
@@ -176,12 +176,18 @@ case.">
       <property name="bare" writable="1">
         <type name="GObject.Object" c:type="GObject"/>
       </property>
+      <property name="boxed" writable="1">
+        <type name="TestBoxed" c:type="TestBoxed"/>
+      </property>
       <field name="parent_instance">
         <type name="GObject.Object" c:type="GObject"/>
       </field>
       <field name="bare">
         <type name="GObject.Object" c:type="GObject*"/>
       </field>
+      <field name="boxed">
+        <type name="TestBoxed" c:type="TestBoxed*"/>
+      </field>
       <glib:signal name="test">
         <return-value transfer-ownership="full">
           <type name="none" c:type="void"/>
index 705f8db..8b0d0fb 100644 (file)
@@ -1159,7 +1159,8 @@ G_DEFINE_TYPE(TestObj, test_obj, G_TYPE_OBJECT);
 
 enum
 {
-  PROP_TEST_OBJ_BARE = 1
+  PROP_TEST_OBJ_BARE = 1,
+  PROP_TEST_OBJ_BOXED
 };
 
 static void
@@ -1176,6 +1177,12 @@ test_obj_set_property (GObject      *object,
       test_obj_set_bare (self, g_value_get_object (value));
       break;
 
+    case PROP_TEST_OBJ_BOXED:
+      if (self->boxed)
+        test_boxed_free (self->boxed);
+      self->boxed = g_value_dup_boxed (value);
+      break;
+      
     default:
       /* We don't have any other property... */
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1197,6 +1204,10 @@ test_obj_get_property (GObject    *object,
       g_value_set_object (value, self->bare);
       break;
 
+    case PROP_TEST_OBJ_BOXED:
+      g_value_set_boxed (value, self->boxed);
+      break;
+      
     default:
       /* We don't have any other property... */
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1216,6 +1227,12 @@ test_obj_dispose (GObject *gobject)
       self->bare = NULL;
     }
 
+  if (self->boxed)
+    {
+      test_boxed_free (self->boxed);
+      self->boxed = NULL;
+    }
+  
   /* Chain up to the parent class */
   G_OBJECT_CLASS (test_obj_parent_class)->dispose (gobject);
 }
@@ -1271,6 +1288,15 @@ test_obj_class_init (TestObjClass *klass)
                                    PROP_TEST_OBJ_BARE,
                                    pspec);
 
+  pspec = g_param_spec_boxed ("boxed",
+                              "Boxed property",
+                              "A contained boxed struct",
+                              TEST_TYPE_BOXED,
+                              G_PARAM_READWRITE);
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEST_OBJ_BOXED,
+                                   pspec);
+  
   klass->matrix = test_obj_default_matrix;
 }
 
@@ -1278,6 +1304,7 @@ static void
 test_obj_init (TestObj *obj)
 {
   obj->bare = NULL;
+  obj->boxed = NULL;
 }
 
 TestObj *
index 186d219..2bbcf9e 100644 (file)
@@ -186,6 +186,8 @@ GType             test_simple_boxed_b_get_type (void);
 TestSimpleBoxedB *test_simple_boxed_b_copy     (TestSimpleBoxedB *b);
 
 /* opaque boxed */
+#define TEST_TYPE_BOXED (test_boxed_get_type())
+
 typedef struct _TestBoxed TestBoxed;
 typedef struct _TestBoxedPrivate TestBoxedPrivate;
 
@@ -221,6 +223,7 @@ struct _TestObj
   GObject parent_instance;
 
   GObject *bare;
+  TestBoxed *boxed;
 };
 
 struct _TestObjClass