update to 1.10.4
[profile/ivi/clutter.git] / clutter / clutter-script-private.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By Matthew Allum  <mallum@openedhand.com>
7  *
8  * Copyright (C) 2006 OpenedHand
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22  *
23  *
24  */
25
26 #ifndef __CLUTTER_SCRIPT_PRIVATE_H__
27 #define __CLUTTER_SCRIPT_PRIVATE_H__
28
29 #include <glib-object.h>
30 #include <json-glib/json-glib.h>
31
32 #include "clutter-color.h"
33 #include "clutter-types.h"
34 #include "clutter-script.h"
35
36 G_BEGIN_DECLS
37
38 #define CLUTTER_TYPE_SCRIPT_PARSER      (_clutter_script_parser_get_type ())
39 #define CLUTTER_SCRIPT_PARSER(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SCRIPT_PARSER, ClutterScriptParser))
40 #define CLUTTER_IS_SCRIPT_PARSER(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SCRIPT_PARSER))
41
42 typedef struct _ClutterScriptParser     ClutterScriptParser;
43 typedef struct _JsonParserClass         ClutterScriptParserClass;
44
45 struct _ClutterScriptParser
46 {
47   JsonParser parent_instance;
48
49   /* back reference */
50   ClutterScript *script;
51 };
52
53 typedef GType (* GTypeGetFunc) (void);
54
55 typedef struct {
56   gchar *id;
57   gchar *class_name;
58   gchar *type_func;
59
60   GList *properties;
61   GList *children;
62   GList *signals;
63
64   GType gtype;
65   GObject *object;
66
67   guint merge_id;
68
69   guint is_actor         : 1;
70   guint is_stage         : 1;
71   guint is_stage_default : 1;
72   guint has_unresolved   : 1;
73   guint is_unmerged      : 1;
74 } ObjectInfo;
75
76 void object_info_free (gpointer data);
77
78 typedef struct {
79   gchar *name;
80   JsonNode *node;
81   GParamSpec *pspec;
82
83   guint is_child : 1;
84   guint is_layout : 1;
85 } PropertyInfo;
86
87 typedef struct {
88   gchar *name;
89   gchar *handler;
90   gchar *object;
91   gchar *state;
92   gchar *target;
93
94   GConnectFlags flags;
95
96   guint is_handler : 1;
97   guint warp_to    : 1;
98 } SignalInfo;
99
100 void property_info_free (gpointer data);
101
102 GType _clutter_script_parser_get_type (void) G_GNUC_CONST;
103
104 gboolean _clutter_script_parse_node        (ClutterScript *script,
105                                             GValue        *value,
106                                             const gchar   *name,
107                                             JsonNode      *node,
108                                             GParamSpec    *pspec);
109
110 GType    _clutter_script_get_type_from_symbol (const gchar *symbol);
111 GType    _clutter_script_get_type_from_class  (const gchar *name);
112
113 gulong   _clutter_script_resolve_animation_mode (JsonNode *node);
114
115 gboolean _clutter_script_enum_from_string  (GType          gtype,
116                                             const gchar   *string,
117                                             gint          *enum_value);
118 gboolean _clutter_script_flags_from_string (GType          gtype,
119                                             const gchar   *string,
120                                             gint          *flags_value);
121
122 gboolean _clutter_script_parse_knot        (ClutterScript   *script,
123                                             JsonNode        *node,
124                                             ClutterKnot     *knot);
125 gboolean _clutter_script_parse_geometry    (ClutterScript   *script,
126                                             JsonNode        *node,
127                                             ClutterGeometry *geometry);
128 gboolean _clutter_script_parse_color       (ClutterScript   *script,
129                                             JsonNode        *node,
130                                             ClutterColor    *color);
131 GObject *_clutter_script_parse_alpha       (ClutterScript   *script,
132                                             JsonNode        *node);
133 gboolean _clutter_script_parse_translatable_string (ClutterScript *script,
134                                                     JsonNode      *node,
135                                                     char         **str);
136
137 void _clutter_script_construct_object (ClutterScript *script,
138                                        ObjectInfo    *oinfo);
139 void _clutter_script_apply_properties (ClutterScript *script,
140                                        ObjectInfo    *oinfo);
141
142 gchar *_clutter_script_generate_fake_id (ClutterScript *script);
143
144 void _clutter_script_warn_missing_attribute (ClutterScript *script,
145                                              const gchar   *id,
146                                              const gchar   *attribute);
147
148 void _clutter_script_warn_invalid_value (ClutterScript *script,
149                                          const gchar   *attribute,
150                                          const gchar   *expected,
151                                          JsonNode      *node);
152
153 ObjectInfo *_clutter_script_get_object_info (ClutterScript *script,
154                                              const gchar   *script_id);
155
156 guint _clutter_script_get_last_merge_id (ClutterScript *script);
157
158 void _clutter_script_add_object_info (ClutterScript *script,
159                                       ObjectInfo    *oinfo);
160
161 const gchar *_clutter_script_get_id_from_node (JsonNode *node);
162
163 G_END_DECLS
164
165 #endif /* __CLUTTER_SCRIPT_PRIVATE_H__ */