From c34e17163daddacddfc33315420fd35daf605ed3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 27 Aug 2008 12:16:56 +0000 Subject: [PATCH] 2008-08-27 Emmanuele Bassi Bug 1099 - No ClutterScript API to get a list of IDs in a given file * clutter/clutter-script.[ch]: Add clutter_script_list_objects(), a function for retrieving all the objects built by a ClutterScript instance. (Based on a patch by Noah Gibbs) --- ChangeLog | 8 +++++ clutter/clutter-script.c | 41 ++++++++++++++++++++++ clutter/clutter-script.h | 3 ++ doc/reference/ChangeLog | 5 +++ doc/reference/clutter/clutter-sections.txt | 1 + 5 files changed, 58 insertions(+) diff --git a/ChangeLog b/ChangeLog index c10a4a5af..df78dbc9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-27 Emmanuele Bassi + + Bug 1099 - No ClutterScript API to get a list of IDs in a given file + + * clutter/clutter-script.[ch]: Add clutter_script_list_objects(), + a function for retrieving all the objects built by a ClutterScript + instance. (Based on a patch by Noah Gibbs) + 2008-08-26 Emmanuele Bassi Bug 1090 - Label somtimes returns natural_width < min_width diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c index 55a9b9bdb..1a8fc9898 100644 --- a/clutter/clutter-script.c +++ b/clutter/clutter-script.c @@ -2424,3 +2424,44 @@ clutter_script_lookup_filename (ClutterScript *script, return retval; } +/** + * clutter_script_list_objects: + * @script: a #ClutterScript + * + * Retrieves all the objects created by @script. + * + * Note: this function does not increment the reference count of the + * objects it returns. + * + * Return value: a list of #GObjects, or %NULL. The objects are + * owned by the #ClutterScript instance. Use g_list_free() on the + * returned value when done. + * + * Since: 0.8.2 + */ +GList * +clutter_script_list_objects (ClutterScript *script) +{ + GList *objects, *l; + GList *retval; + + g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), NULL); + + clutter_script_ensure_objects (script); + if (!script->priv->objects) + return NULL; + + retval = NULL; + objects = g_hash_table_get_values (script->priv->objects); + for (l = objects; l != NULL; l = l->next) + { + ObjectInfo *oinfo = l->data; + + if (oinfo->object) + retval = g_list_prepend (retval, oinfo->object); + } + + g_list_free (objects); + + return retval; +} diff --git a/clutter/clutter-script.h b/clutter/clutter-script.h index 29ad3888e..d53fcef8f 100644 --- a/clutter/clutter-script.h +++ b/clutter/clutter-script.h @@ -125,11 +125,14 @@ guint clutter_script_load_from_data (ClutterScript *script, const gchar *data, gssize length, GError **error); + GObject * clutter_script_get_object (ClutterScript *script, const gchar *name); gint clutter_script_get_objects (ClutterScript *script, const gchar *first_name, ...) G_GNUC_NULL_TERMINATED; +GList * clutter_script_list_objects (ClutterScript *script); + void clutter_script_unmerge_objects (ClutterScript *script, guint merge_id); void clutter_script_ensure_objects (ClutterScript *script); diff --git a/doc/reference/ChangeLog b/doc/reference/ChangeLog index 7c6082ee4..b0f9252cc 100644 --- a/doc/reference/ChangeLog +++ b/doc/reference/ChangeLog @@ -1,3 +1,8 @@ +2008-08-27 Emmanuele Bassi + + * doc/reference/clutter/clutter-sections.txt: Add + clutter_script_list_objects(). + 2008-07-30 Ross Burton * clutter/version.xml.in: diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index f168a2cb1..2af107067 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1288,6 +1288,7 @@ clutter_script_get_object clutter_script_get_objects clutter_script_unmerge_objects clutter_script_ensure_objects +clutter_script_list_objects ClutterScriptConnectFunc