Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-script.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 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
25 #error "Only <clutter/clutter.h> can be included directly."
26 #endif
27
28 #ifndef __CLUTTER_SCRIPT_H__
29 #define __CLUTTER_SCRIPT_H__
30
31 #include <clutter/clutter-types.h>
32
33 G_BEGIN_DECLS
34
35 #define CLUTTER_TYPE_SCRIPT             (clutter_script_get_type ())
36 #define CLUTTER_SCRIPT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SCRIPT, ClutterScript))
37 #define CLUTTER_IS_SCRIPT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SCRIPT))
38 #define CLUTTER_SCRIPT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_SCRIPT, ClutterScriptClass))
39 #define CLUTTER_IS_SCRIPT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_SCRIPT))
40 #define CLUTTER_SCRIPT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_SCRIPT, ClutterScriptClass))
41
42 typedef struct _ClutterScript           ClutterScript;
43 typedef struct _ClutterScriptPrivate    ClutterScriptPrivate;
44 typedef struct _ClutterScriptClass      ClutterScriptClass;
45
46 /**
47  * ClutterScriptConnectFunc:
48  * @script: a #ClutterScript
49  * @object: the object to connect
50  * @signal_name: the name of the signal
51  * @handler_name: the name of the signal handler
52  * @connect_object: the object to connect the signal to, or %NULL
53  * @flags: signal connection flags
54  * @user_data: user data to pass to the signal handler
55  *
56  * This is the signature of a function used to connect signals.  It is used
57  * by the clutter_script_connect_signals_full() function.  It is mainly
58  * intended for interpreted language bindings, but could be useful where the
59  * programmer wants more control over the signal connection process.
60  *
61  * Since: 0.6
62  */
63 typedef void (* ClutterScriptConnectFunc) (ClutterScript *script,
64                                            GObject       *object,
65                                            const gchar   *signal_name,
66                                            const gchar   *handler_name,
67                                            GObject       *connect_object,
68                                            GConnectFlags  flags,
69                                            gpointer       user_data);
70
71 /**
72  * ClutterScriptError:
73  * @CLUTTER_SCRIPT_ERROR_INVALID_TYPE_FUNCTION: Type function not found
74  *   or invalid
75  * @CLUTTER_SCRIPT_ERROR_INVALID_PROPERTY: Property not found or invalid
76  * @CLUTTER_SCRIPT_ERROR_INVALID_VALUE: Invalid value
77  *
78  * #ClutterScript error enumeration.
79  *
80  * Since: 0.6
81  */
82 typedef enum {
83   CLUTTER_SCRIPT_ERROR_INVALID_TYPE_FUNCTION,
84   CLUTTER_SCRIPT_ERROR_INVALID_PROPERTY,
85   CLUTTER_SCRIPT_ERROR_INVALID_VALUE
86 } ClutterScriptError;
87
88 /**
89  * CLUTTER_SCRIPT_ERROR:
90  *
91  * Error domain for the #ClutterScript errors
92  *
93  * Since: 0.6
94  */
95 #define CLUTTER_SCRIPT_ERROR    (clutter_script_error_quark ())
96 GQuark clutter_script_error_quark (void);
97
98 /**
99  * ClutterScript:
100  *
101  * The #ClutterScript structure contains only private data
102  * and should be accessed using the provided API
103  *
104  * Since: 0.6
105  */
106 struct _ClutterScript
107 {
108   /*< private >*/
109   GObject parent_instance;
110
111   ClutterScriptPrivate *priv;
112 };
113
114 /**
115  * ClutterScriptClass:
116  * @get_type_from_name: virtual function used to map a type name
117  *   to a #GType. This function should only be overridden by
118  *   language bindings in order to map native types to #GType.
119  *   The default implementation is equivalent to g_type_from_name()
120  *
121  * The #ClutterScriptClass structure contains only private data
122  *
123  * Since: 0.6
124  */
125 struct _ClutterScriptClass
126 {
127   /*< private >*/
128   GObjectClass parent_class;
129
130   /*< public >*/
131   GType (* get_type_from_name) (ClutterScript *script,
132                                 const gchar   *type_name);
133
134   /*< private >*/
135   /* padding, for future expansion */
136   void (*_clutter_reserved1) (void);
137   void (*_clutter_reserved2) (void);
138   void (*_clutter_reserved3) (void);
139   void (*_clutter_reserved4) (void);
140   void (*_clutter_reserved5) (void);
141   void (*_clutter_reserved6) (void);
142   void (*_clutter_reserved7) (void);
143   void (*_clutter_reserved8) (void);
144 };
145
146 GType clutter_script_get_type (void) G_GNUC_CONST;
147
148 ClutterScript * clutter_script_new                      (void);
149 guint           clutter_script_load_from_file           (ClutterScript             *script,
150                                                          const gchar               *filename,
151                                                          GError                   **error);
152 guint           clutter_script_load_from_data           (ClutterScript             *script,
153                                                          const gchar               *data,
154                                                          gssize                     length,
155                                                          GError                   **error);
156 CLUTTER_AVAILABLE_IN_1_10
157 guint           clutter_script_load_from_resource       (ClutterScript             *script,
158                                                          const gchar               *resource_path,
159                                                          GError                   **error);
160
161 GObject *       clutter_script_get_object               (ClutterScript             *script,
162                                                          const gchar               *name);
163 gint            clutter_script_get_objects              (ClutterScript             *script,
164                                                          const gchar               *first_name,
165                                                          ...) G_GNUC_NULL_TERMINATED;
166 GList *         clutter_script_list_objects             (ClutterScript             *script);
167 void            clutter_script_unmerge_objects          (ClutterScript             *script,
168                                                          guint                      merge_id);
169 void            clutter_script_ensure_objects           (ClutterScript             *script);
170
171 CLUTTER_DEPRECATED_IN_1_12
172 void            clutter_script_add_states               (ClutterScript             *script,
173                                                          const gchar               *name,
174                                                          ClutterState              *state);
175
176 CLUTTER_DEPRECATED_IN_1_12
177 ClutterState *  clutter_script_get_states               (ClutterScript             *script,
178                                                          const gchar               *name);
179
180 void            clutter_script_connect_signals          (ClutterScript             *script,
181                                                          gpointer                   user_data);
182 void            clutter_script_connect_signals_full     (ClutterScript             *script,
183                                                          ClutterScriptConnectFunc   func,
184                                                          gpointer                   user_data);
185
186 void            clutter_script_add_search_paths         (ClutterScript             *script,
187                                                          const gchar * const        paths[],
188                                                          gsize                      n_paths);
189 gchar *         clutter_script_lookup_filename          (ClutterScript             *script,
190                                                          const gchar               *filename) G_GNUC_MALLOC;
191 GType           clutter_script_get_type_from_name       (ClutterScript             *script,
192                                                          const gchar               *type_name);
193
194 CLUTTER_AVAILABLE_IN_1_10
195 void            clutter_script_set_translation_domain   (ClutterScript             *script,
196                                                          const gchar               *domain);
197 CLUTTER_AVAILABLE_IN_1_10
198 const gchar *   clutter_script_get_translation_domain   (ClutterScript             *script);
199
200 const gchar *   clutter_get_script_id                   (GObject                   *gobject);
201
202 G_END_DECLS
203
204 #endif /* __CLUTTER_SCRIPT_H__ */