2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script.[ch]: Slight API change in the clutter_script_get_objects() function: now it takes object name/object return location pairs and returns the number of objects found and returned. * tests/test-script.c: Exercise the clutter_script_get_objects() function.
This commit is contained in:
parent
ae7463cccf
commit
35132fb5de
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-script.[ch]: Slight API change in the
|
||||
clutter_script_get_objects() function: now it takes
|
||||
object name/object return location pairs and returns the
|
||||
number of objects found and returned.
|
||||
|
||||
* tests/test-script.c: Exercise the clutter_script_get_objects()
|
||||
function.
|
||||
|
||||
2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-rectangle.c (clutter_rectangle_paint): Use
|
||||
|
@ -1446,50 +1446,69 @@ clutter_script_get_object (ClutterScript *script,
|
||||
return clutter_script_construct_object (script, oinfo);
|
||||
}
|
||||
|
||||
static GList *
|
||||
static gint
|
||||
clutter_script_get_objects_valist (ClutterScript *script,
|
||||
const gchar *first_name,
|
||||
va_list args)
|
||||
{
|
||||
GList *retval = NULL;
|
||||
gint retval = 0;
|
||||
const gchar *name;
|
||||
|
||||
name = first_name;
|
||||
while (name)
|
||||
{
|
||||
retval =
|
||||
g_list_prepend (retval, clutter_script_get_object (script, name));
|
||||
GObject **obj = NULL;
|
||||
|
||||
obj = va_arg (args, GObject**);
|
||||
|
||||
*obj = clutter_script_get_object (script, name);
|
||||
if (*obj)
|
||||
retval += 1;
|
||||
|
||||
name = va_arg (args, gchar*);
|
||||
}
|
||||
|
||||
return g_list_reverse (retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_script_get_objects:
|
||||
* @script: a #ClutterScript
|
||||
* @first_name: the name of the first object to retrieve
|
||||
* @Varargs: a %NULL-terminated list of names
|
||||
* @Varargs: return location for a #GObject, then additional names, ending
|
||||
* with %NULL
|
||||
*
|
||||
* Retrieves a list of objects for the given names. This function does
|
||||
* not increment the reference count of the returned objects.
|
||||
* Retrieves a list of objects for the given names. After @script, object
|
||||
* names/return location pairs should be listed, with a %NULL pointer
|
||||
* ending the list, like:
|
||||
*
|
||||
* Return value: a newly allocated #GList containing the found objects,
|
||||
* or %NULL. Use g_list_free() when done using it.
|
||||
* <informalexample><programlisting>
|
||||
* GObject *my_label, *a_button, *main_timeline;
|
||||
*
|
||||
* clutter_script_get_objects (script,
|
||||
* "my-label", &my_label,
|
||||
* "a-button", &a_button,
|
||||
* "main-timeline", &main_timeline,
|
||||
* NULL);
|
||||
* </programlisting</informalexample>
|
||||
*
|
||||
* Note: This function does not increment the reference count of the
|
||||
* returned objects.
|
||||
*
|
||||
* Return value: the number of objects returned.
|
||||
*
|
||||
* Since: 0.6
|
||||
*/
|
||||
GList *
|
||||
gint
|
||||
clutter_script_get_objects (ClutterScript *script,
|
||||
const gchar *first_name,
|
||||
...)
|
||||
{
|
||||
GList *retval = NULL;
|
||||
gint retval;
|
||||
va_list var_args;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), NULL);
|
||||
g_return_val_if_fail (first_name != NULL, NULL);
|
||||
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), 0);
|
||||
g_return_val_if_fail (first_name != NULL, 0);
|
||||
|
||||
va_start (var_args, first_name);
|
||||
retval = clutter_script_get_objects_valist (script, first_name, var_args);
|
||||
|
@ -99,7 +99,7 @@ guint clutter_script_load_from_data (ClutterScript *script,
|
||||
GError **error);
|
||||
GObject * clutter_script_get_object (ClutterScript *script,
|
||||
const gchar *name);
|
||||
GList * clutter_script_get_objects (ClutterScript *script,
|
||||
gint clutter_script_get_objects (ClutterScript *script,
|
||||
const gchar *first_name,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void clutter_script_unmerge_objects (ClutterScript *script,
|
||||
|
@ -96,6 +96,7 @@ main (int argc, char *argv[])
|
||||
{
|
||||
GObject *stage, *timeline, *blue_button, *red_button;
|
||||
GError *error = NULL;
|
||||
gint res;
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
|
||||
@ -132,16 +133,20 @@ main (int argc, char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
stage = clutter_script_get_object (script, "main-stage");
|
||||
res = clutter_script_get_objects (script,
|
||||
"main-stage", &stage,
|
||||
"red-button", &red_button,
|
||||
"blue-button", &blue_button,
|
||||
NULL);
|
||||
g_assert (res == 3);
|
||||
|
||||
clutter_actor_show (CLUTTER_ACTOR (stage));
|
||||
|
||||
red_button = clutter_script_get_object (script, "red-button");
|
||||
g_signal_connect (red_button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (red_button_press),
|
||||
NULL);
|
||||
|
||||
blue_button = clutter_script_get_object (script, "blue-button");
|
||||
g_signal_connect (blue_button,
|
||||
"button-press-event",
|
||||
G_CALLBACK (blue_button_press),
|
||||
|
Loading…
x
Reference in New Issue
Block a user