Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-layout-meta.c
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Copyright (C) 2009  Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * Author:
22  *   Emmanuele Bassi <ebassi@linux.intel.com>
23  */
24
25 /**
26  * SECTION:clutter-layout-meta
27  * @short_description: Wrapper for actors inside a layout manager
28  *
29  * #ClutterLayoutMeta is a wrapper object created by #ClutterLayoutManager
30  * implementations in order to store child-specific data and properties.
31  *
32  * A #ClutterLayoutMeta wraps a #ClutterActor inside a #ClutterContainer
33  * using a #ClutterLayoutManager.
34  *
35  * #ClutterLayoutMeta is available since Clutter 1.2
36  */
37 #ifdef HAVE_CONFIG_H
38 #include "config.h"
39 #endif
40
41 #include "clutter-layout-meta.h"
42 #include "clutter-debug.h"
43 #include "clutter-private.h"
44
45 G_DEFINE_ABSTRACT_TYPE (ClutterLayoutMeta,
46                         clutter_layout_meta,
47                         CLUTTER_TYPE_CHILD_META);
48
49 enum
50 {
51   PROP_0,
52
53   PROP_MANAGER,
54
55   PROP_LAST
56 };
57
58 static GParamSpec *obj_props[PROP_LAST];
59
60 static void
61 clutter_layout_meta_set_property (GObject      *object,
62                                   guint         prop_id,
63                                   const GValue *value,
64                                   GParamSpec   *pspec)
65 {
66   ClutterLayoutMeta *layout_meta = CLUTTER_LAYOUT_META (object);
67
68   switch (prop_id)
69     {
70     case PROP_MANAGER:
71       layout_meta->manager = g_value_get_object (value);
72       break;
73
74     default:
75       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
76       break;
77     }
78 }
79
80 static void
81 clutter_layout_meta_get_property (GObject    *object,
82                                   guint       prop_id,
83                                   GValue     *value,
84                                   GParamSpec *pspec)
85 {
86   ClutterLayoutMeta *layout_meta = CLUTTER_LAYOUT_META (object);
87
88   switch (prop_id)
89     {
90     case PROP_MANAGER:
91       g_value_set_object (value, layout_meta->manager);
92       break;
93
94     default:
95       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
96       break;
97     }
98 }
99
100 static void
101 clutter_layout_meta_class_init (ClutterLayoutMetaClass *klass)
102 {
103   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
104   GParamSpec *pspec;
105
106   gobject_class->set_property = clutter_layout_meta_set_property;
107   gobject_class->get_property = clutter_layout_meta_get_property;
108
109   /**
110    * ClutterLayoutMeta:manager:
111    *
112    * The #ClutterLayoutManager that created this #ClutterLayoutMeta.
113    *
114    * Since: 1.2
115    */
116   pspec = g_param_spec_object ("manager",
117                                P_("Manager"),
118                                P_("The manager that created this data"),
119                                CLUTTER_TYPE_LAYOUT_MANAGER,
120                                G_PARAM_CONSTRUCT_ONLY |
121                                CLUTTER_PARAM_READWRITE);
122   obj_props[PROP_MANAGER] = pspec;
123   g_object_class_install_property (gobject_class, PROP_MANAGER, pspec);
124 }
125
126 static void
127 clutter_layout_meta_init (ClutterLayoutMeta *self)
128 {
129 }
130
131 /**
132  * clutter_layout_meta_get_manager:
133  * @data: a #ClutterLayoutMeta
134  *
135  * Retrieves the actor wrapped by @data
136  *
137  * Return value: (transfer none): a #ClutterLayoutManager
138  *
139  * Since: 1.2
140  */
141 ClutterLayoutManager *
142 clutter_layout_meta_get_manager (ClutterLayoutMeta *data)
143 {
144   g_return_val_if_fail (CLUTTER_IS_LAYOUT_META (data), NULL);
145
146   return data->manager;
147 }