2007-11-14 Emmanuele Bassi <ebassi@openedhand.com>
+ * clutter/clutter-scriptable.[ch]: Rename ::set_name and ::get_name
+ to ::set_id and ::get_id, to avoid potential confusion with the
+ ClutterActor:name property.
+
+ * clutter/clutter-script.h:
+ * clutter/clutter-script.c (clutter_script_construct_object): Use
+ clutter_scriptable_set_id().
+
+ (clutter_get_script_id): Add a public function to retrieve the ID
+ used in the UI definition files from an object.
+
+ * clutter/clutter-actor.c: Do not set the name of the actor with
+ the ID set in the UI definition files.
+
+ * tests/test-script.c: Test clutter_get_script_id().
+
+ * clutter.symbols: Update with the new symbols.
+
+2007-11-14 Emmanuele Bassi <ebassi@openedhand.com>
+
* clutter/cutter-deprecated.h: Don't let everyone know from where
we have stolen^Wtaken inspiration for the deprecation warnings.
clutter_script_unmerge_objects
clutter_script_ensure_objects
clutter_script_get_type_from_name
+clutter_get_script_id
clutter_scriptable_get_type
-clutter_scriptable_set_name
-clutter_scriptable_get_name
+clutter_scriptable_set_id
+clutter_scriptable_get_id
clutter_scriptable_parse_custom_node
clutter_scriptable_set_custom_property
#include "clutter-units.h"
#include "cogl.h"
-static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
-
-G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterActor,
- clutter_actor,
- G_TYPE_INITIALLY_UNOWNED,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
- clutter_scriptable_iface_init));
+G_DEFINE_ABSTRACT_TYPE (ClutterActor,
+ clutter_actor,
+ G_TYPE_INITIALLY_UNOWNED);
static guint32 __id = 0;
static guint actor_signals[LAST_SIGNAL] = { 0, };
static void
-clutter_actor_scriptable_set_name (ClutterScriptable *scriptable,
- const gchar *name)
-{
- clutter_actor_set_name (CLUTTER_ACTOR (scriptable), name);
-}
-
-static const gchar *
-clutter_actor_scriptable_get_name (ClutterScriptable *scriptable)
-{
- return clutter_actor_get_name (CLUTTER_ACTOR (scriptable));
-}
-
-static void
-clutter_scriptable_iface_init (ClutterScriptableIface *iface)
-{
- iface->set_name = clutter_actor_scriptable_set_name;
- iface->get_name = clutter_actor_scriptable_get_name;
-}
-
-static void
_clutter_actor_apply_modelview_transform (ClutterActor * self);
static void
oinfo->has_unresolved = FALSE;
if (scriptable)
- clutter_scriptable_set_name (scriptable, oinfo->id);
+ clutter_scriptable_set_id (scriptable, oinfo->id);
else
- g_object_set_data_full (object, "clutter-script-name",
+ g_object_set_data_full (object, "clutter-script-id",
g_strdup (oinfo->id),
g_free);
return CLUTTER_SCRIPT_GET_CLASS (script)->get_type_from_name (script, type_name);
}
+/**
+ * clutter_get_script_id:
+ * @gobject: a #GObject
+ *
+ * Retrieves the Clutter script id, if any.
+ *
+ * Return value: the script id, or %NULL if @object was not defined inside
+ * a UI definition file. The returned string is owned by the object and
+ * should never be modified or freed.
+ *
+ * Since: 0.6
+ */
+G_CONST_RETURN gchar *
+clutter_get_script_id (GObject *gobject)
+{
+ g_return_val_if_fail (G_IS_OBJECT (gobject), NULL);
+
+ if (CLUTTER_IS_SCRIPTABLE (gobject))
+ return clutter_scriptable_get_id (CLUTTER_SCRIPTABLE (gobject));
+ else
+ return g_object_get_data (gobject, "clutter-script-id");
+}
+
GQuark
clutter_script_error_quark (void)
{
GType clutter_script_get_type_from_name (ClutterScript *script,
const gchar *type_name);
+G_CONST_RETURN gchar *clutter_get_script_id (GObject *object);
+
G_END_DECLS
#endif /* __CLUTTER_SCRIPT_H__ */
}
/**
- * clutter_scriptable_set_name:
+ * clutter_scriptable_set_id:
* @scriptable: a #ClutterScriptable
- * @name: the name of the object
+ * @id: the #ClutterScript id of the object
*
- * Sets @name as the name for this instance of #ClutterScriptableIface.
- * This name can be used by user interface designer applications.
+ * Sets @id as the unique Clutter script it for this instance of
+ * #ClutterScriptableIface.
+ *
+ * This name can be used by user interface designer applications to
+ * define a unique name for an object constructable using the UI
+ * definition language parsed by #ClutterScript.
*
* Since: 0.6
*/
void
-clutter_scriptable_set_name (ClutterScriptable *scriptable,
- const gchar *name)
+clutter_scriptable_set_id (ClutterScriptable *scriptable,
+ const gchar *id)
{
ClutterScriptableIface *iface;
g_return_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable));
- g_return_if_fail (name != NULL);
+ g_return_if_fail (id != NULL);
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
- if (iface->set_name)
- iface->set_name (scriptable, name);
+ if (iface->set_id)
+ iface->set_id (scriptable, id);
else
g_object_set_data_full (G_OBJECT (scriptable),
- "clutter-script-name",
- g_strdup (name),
+ "clutter-script-id",
+ g_strdup (id),
g_free);
}
/**
- * clutter_scriptable_get_name:
+ * clutter_scriptable_get_id:
* @scriptable: a #ClutterScriptable
*
- * Retrieves the name of @scriptable set using clutter_scriptable_set_name().
+ * Retrieves the id of @scriptable set using clutter_scriptable_set_id().
*
- * Return value: the name of the object. The returned string is owned by
+ * Return value: the id of the object. The returned string is owned by
* the scriptable object and should never be modified of freed
*
* Since: 0.6
*/
G_CONST_RETURN gchar *
-clutter_scriptable_get_name (ClutterScriptable *scriptable)
+clutter_scriptable_get_id (ClutterScriptable *scriptable)
{
ClutterScriptableIface *iface;
g_return_val_if_fail (CLUTTER_IS_SCRIPTABLE (scriptable), NULL);
iface = CLUTTER_SCRIPTABLE_GET_IFACE (scriptable);
- if (iface->get_name)
- return iface->get_name (scriptable);
+ if (iface->get_id)
+ return iface->get_id (scriptable);
else
- return g_object_get_data (G_OBJECT (scriptable), "clutter-script-name");
+ return g_object_get_data (G_OBJECT (scriptable), "clutter-script-id");
}
/**
/**
* ClutterScriptableIface:
- * @set_name: virtual function for setting the name of a scriptable object
- * @get_name: virtual function for getting the name of a scriptable object
+ * @set_id: virtual function for setting the id of a scriptable object
+ * @get_id: virtual function for getting the id of a scriptable object
* @parse_custom_node: virtual function for parsing complex data containers
* into GObject properties
* @set_custom_property: virtual function for setting a custom property
{
GTypeInterface g_iface;
- void (* set_name) (ClutterScriptable *scriptable,
+ void (* set_id) (ClutterScriptable *scriptable,
const gchar *name);
- const gchar *(* get_name) (ClutterScriptable *scriptable);
+ const gchar *(* get_id) (ClutterScriptable *scriptable);
gboolean (* parse_custom_node) (ClutterScriptable *scriptable,
ClutterScript *script,
GType clutter_scriptable_get_type (void) G_GNUC_CONST;
-void clutter_scriptable_set_name (ClutterScriptable *scriptable,
- const gchar *name);
-G_CONST_RETURN gchar *clutter_scriptable_get_name (ClutterScriptable *scriptable);
+void clutter_scriptable_set_id (ClutterScriptable *scriptable,
+ const gchar *id);
+G_CONST_RETURN gchar *clutter_scriptable_get_id (ClutterScriptable *scriptable);
gboolean clutter_scriptable_parse_custom_node (ClutterScriptable *scriptable,
ClutterScript *script,
GValue *value,
+2007-11-14 Emmanuele Bassi <ebassi@openedhand.com>
+
+ * clutter-sections.txt: Update with the ClutterScriptable changes
+ and add clutter_get_script_id().
+
2007-10-28 Matthew Allum <mallum@openedhand.com>
* clutter-animation.sgml:
clutter_script_unmerge_objects
clutter_script_ensure_objects
clutter_script_get_type_from_name
+clutter_get_script_id
<SUBSECTION Standard>
CLUTTER_TYPE_SCRIPT
CLUTTER_SCRIPT
<FILE>clutter-scriptable</FILE>
<TITLE>ClutterScriptable</TITLE>
ClutterScriptableIface
-clutter_scriptable_set_name
-clutter_scriptable_get_name
+clutter_scriptable_set_id
+clutter_scriptable_get_id
clutter_scriptable_parse_custom_node
clutter_scriptable_set_custom_property
<SUBSECTION Standard>
ClutterButtonEvent *event,
gpointer data)
{
+ g_print ("[*] Pressed `%s'\n", clutter_get_script_id (G_OBJECT (actor)));
g_print ("[*] Unmerging objects with merge id: %d\n", merge_id);
clutter_script_unmerge_objects (script, merge_id);
{
GObject *timeline;
+ g_print ("[*] Pressed `%s'\n", clutter_get_script_id (G_OBJECT (actor)));
+
timeline = clutter_script_get_object (script, "main-timeline");
g_assert (CLUTTER_IS_TIMELINE (timeline));