Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-child-meta.c
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By Matthew Allum  <mallum@openedhand.com>
7  *             Jorn Baayen  <jorn@openedhand.com>
8  *             Emmanuele Bassi  <ebassi@openedhand.com>
9  *             Tomas Frydrych <tf@openedhand.com>
10  *             Øyvind Kolås <ok@openedhand.com>
11  *
12  * Copyright (C) 2008 OpenedHand
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
26  */
27
28 /**
29  * SECTION:clutter-child-meta
30  * @short_description: Wrapper for actors inside a container
31  *
32  * #ClutterChildMeta is a wrapper object created by #ClutterContainer
33  * implementations in order to store child-specific data and properties.
34  *
35  * A #ClutterChildMeta wraps a #ClutterActor inside a #ClutterContainer.
36  *
37  * #ClutterChildMeta is available since Clutter 0.8
38  */
39 #ifdef HAVE_CONFIG_H
40 #include "config.h"
41 #endif
42
43 #include "clutter-child-meta.h"
44 #include "clutter-container.h"
45 #include "clutter-debug.h"
46 #include "clutter-private.h"
47
48 G_DEFINE_ABSTRACT_TYPE (ClutterChildMeta, clutter_child_meta, G_TYPE_OBJECT);
49
50 enum
51 {
52   PROP_0,
53
54   PROP_CONTAINER,
55   PROP_ACTOR,
56
57   PROP_LAST
58 };
59
60 static GParamSpec *obj_props[PROP_LAST];
61
62 static void
63 clutter_child_meta_set_property (GObject      *object,
64                                  guint         prop_id,
65                                  const GValue *value,
66                                  GParamSpec   *pspec)
67 {
68   ClutterChildMeta *child_meta = CLUTTER_CHILD_META (object);
69
70   switch (prop_id) 
71     {
72     case PROP_CONTAINER:
73       child_meta->container = g_value_get_object (value);
74       break;
75
76     case PROP_ACTOR:
77       child_meta->actor = g_value_get_object (value);
78       break;
79
80     default:
81       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
82       break;
83     }
84 }
85
86 static void 
87 clutter_child_meta_get_property (GObject    *object,
88                                  guint       prop_id,
89                                  GValue     *value,
90                                  GParamSpec *pspec)
91 {
92   ClutterChildMeta *child_meta = CLUTTER_CHILD_META (object);
93
94   switch (prop_id) 
95     {
96     case PROP_CONTAINER:
97       g_value_set_object (value, child_meta->container);
98       break;
99
100     case PROP_ACTOR:
101       g_value_set_object (value, child_meta->actor);
102       break;
103
104     default:
105       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
106       break;
107     }
108 }
109
110 static void
111 clutter_child_meta_class_init (ClutterChildMetaClass *klass)
112 {
113   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
114
115   gobject_class->set_property = clutter_child_meta_set_property;
116   gobject_class->get_property = clutter_child_meta_get_property;
117
118   /**
119    * ClutterChildMeta:container:
120    *
121    * The #ClutterContainer that created this #ClutterChildMeta.
122    *
123    * Since: 0.8
124    */
125   obj_props[PROP_CONTAINER] =
126     g_param_spec_object ("container",
127                          P_("Container"),
128                          P_("The container that created this data"),
129                          CLUTTER_TYPE_CONTAINER,
130                          G_PARAM_CONSTRUCT_ONLY |
131                          CLUTTER_PARAM_READWRITE);
132
133   /**
134    * ClutterChildMeta:actor:
135    *
136    * The #ClutterActor being wrapped by this #ClutterChildMeta
137    *
138    * Since: 0.8
139    */
140   obj_props[PROP_ACTOR] =
141     g_param_spec_object ("actor",
142                          P_("Actor"),
143                          P_("The actor wrapped by this data"),
144                          CLUTTER_TYPE_ACTOR,
145                          G_PARAM_CONSTRUCT_ONLY |
146                          CLUTTER_PARAM_READWRITE);
147
148   g_object_class_install_properties (gobject_class,
149                                      PROP_LAST,
150                                      obj_props);
151 }
152
153 static void
154 clutter_child_meta_init (ClutterChildMeta *self)
155 {
156 }
157
158 /**
159  * clutter_child_meta_get_container:
160  * @data: a #ClutterChildMeta
161  *
162  * Retrieves the container using @data
163  *
164  * Return value: (transfer none): a #ClutterContainer
165  *
166  * Since: 0.8
167  */
168 ClutterContainer *
169 clutter_child_meta_get_container (ClutterChildMeta *data)
170 {
171   g_return_val_if_fail (CLUTTER_IS_CHILD_META (data), NULL);
172
173   return data->container;
174 }
175
176 /**
177  * clutter_child_meta_get_actor:
178  * @data: a #ClutterChildMeta
179  *
180  * Retrieves the actor wrapped by @data
181  *
182  * Return value: (transfer none): a #ClutterActor
183  *
184  * Since: 0.8
185  */
186 ClutterActor *
187 clutter_child_meta_get_actor (ClutterChildMeta *data)
188 {
189   g_return_val_if_fail (CLUTTER_IS_CHILD_META (data), NULL);
190
191   return data->actor;
192 }