File: clutter-child-meta.c

package info (click to toggle)
clutter-1.0 1.26.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,352 kB
  • sloc: ansic: 128,533; sh: 5,580; xml: 1,641; makefile: 1,613; ruby: 149; perl: 142; sed: 16
file content (192 lines) | stat: -rw-r--r-- 5,068 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
 * Clutter.
 *
 * An OpenGL based 'interactive canvas' library.
 *
 * Authored By Matthew Allum  <mallum@openedhand.com>
 *             Jorn Baayen  <jorn@openedhand.com>
 *             Emmanuele Bassi  <ebassi@openedhand.com>
 *             Tomas Frydrych <tf@openedhand.com>
 *             Øyvind Kolås <ok@openedhand.com>
 *
 * Copyright (C) 2008 OpenedHand
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * SECTION:clutter-child-meta
 * @short_description: Wrapper for actors inside a container
 *
 * #ClutterChildMeta is a wrapper object created by #ClutterContainer
 * implementations in order to store child-specific data and properties.
 *
 * A #ClutterChildMeta wraps a #ClutterActor inside a #ClutterContainer.
 *
 * #ClutterChildMeta is available since Clutter 0.8
 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "clutter-child-meta.h"
#include "clutter-container.h"
#include "clutter-debug.h"
#include "clutter-private.h"

G_DEFINE_ABSTRACT_TYPE (ClutterChildMeta, clutter_child_meta, G_TYPE_OBJECT);

enum
{
  PROP_0,

  PROP_CONTAINER,
  PROP_ACTOR,

  PROP_LAST
};

static GParamSpec *obj_props[PROP_LAST];

static void
clutter_child_meta_set_property (GObject      *object,
                                 guint         prop_id,
                                 const GValue *value,
                                 GParamSpec   *pspec)
{
  ClutterChildMeta *child_meta = CLUTTER_CHILD_META (object);

  switch (prop_id) 
    {
    case PROP_CONTAINER:
      child_meta->container = g_value_get_object (value);
      break;

    case PROP_ACTOR:
      child_meta->actor = g_value_get_object (value);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void 
clutter_child_meta_get_property (GObject    *object,
                                 guint       prop_id,
                                 GValue     *value,
                                 GParamSpec *pspec)
{
  ClutterChildMeta *child_meta = CLUTTER_CHILD_META (object);

  switch (prop_id) 
    {
    case PROP_CONTAINER:
      g_value_set_object (value, child_meta->container);
      break;

    case PROP_ACTOR:
      g_value_set_object (value, child_meta->actor);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
clutter_child_meta_class_init (ClutterChildMetaClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

  gobject_class->set_property = clutter_child_meta_set_property;
  gobject_class->get_property = clutter_child_meta_get_property;

  /**
   * ClutterChildMeta:container:
   *
   * The #ClutterContainer that created this #ClutterChildMeta.
   *
   * Since: 0.8
   */
  obj_props[PROP_CONTAINER] =
    g_param_spec_object ("container",
                         P_("Container"),
                         P_("The container that created this data"),
                         CLUTTER_TYPE_CONTAINER,
                         G_PARAM_CONSTRUCT_ONLY |
                         CLUTTER_PARAM_READWRITE);

  /**
   * ClutterChildMeta:actor:
   *
   * The #ClutterActor being wrapped by this #ClutterChildMeta
   *
   * Since: 0.8
   */
  obj_props[PROP_ACTOR] =
    g_param_spec_object ("actor",
                         P_("Actor"),
                         P_("The actor wrapped by this data"),
                         CLUTTER_TYPE_ACTOR,
                         G_PARAM_CONSTRUCT_ONLY |
                         CLUTTER_PARAM_READWRITE);

  g_object_class_install_properties (gobject_class,
                                     PROP_LAST,
                                     obj_props);
}

static void
clutter_child_meta_init (ClutterChildMeta *self)
{
}

/**
 * clutter_child_meta_get_container:
 * @data: a #ClutterChildMeta
 *
 * Retrieves the container using @data
 *
 * Return value: (transfer none): a #ClutterContainer
 *
 * Since: 0.8
 */
ClutterContainer *
clutter_child_meta_get_container (ClutterChildMeta *data)
{
  g_return_val_if_fail (CLUTTER_IS_CHILD_META (data), NULL);

  return data->container;
}

/**
 * clutter_child_meta_get_actor:
 * @data: a #ClutterChildMeta
 *
 * Retrieves the actor wrapped by @data
 *
 * Return value: (transfer none): a #ClutterActor
 *
 * Since: 0.8
 */
ClutterActor *
clutter_child_meta_get_actor (ClutterChildMeta *data)
{
  g_return_val_if_fail (CLUTTER_IS_CHILD_META (data), NULL);

  return data->actor;
}