[clutter/wip/clutter-1.99: 19/28] 1.99: Remove deprecated API from ClutterScript
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/clutter-1.99: 19/28] 1.99: Remove deprecated API from ClutterScript
- Date: Thu, 21 Jun 2012 20:09:40 +0000 (UTC)
commit ef4bf7155ac3dcb9ea801ede89496c6b8ba856b8
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Jun 21 18:12:29 2012 +0100
1.99: Remove deprecated API from ClutterScript
clutter/clutter-script-parser.c | 192 +-----------------------
clutter/clutter-script-private.h | 2 -
clutter/clutter-script.c | 301 +-------------------------------------
clutter/clutter-script.h | 9 -
4 files changed, 6 insertions(+), 498 deletions(-)
---
diff --git a/clutter/clutter-script-parser.c b/clutter/clutter-script-parser.c
index 6eb6b2b..1848ee2 100644
--- a/clutter/clutter-script-parser.c
+++ b/clutter/clutter-script-parser.c
@@ -34,11 +34,8 @@
#include <glib.h>
#include <gmodule.h>
-#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
-#include "deprecated/clutter-container.h"
-#include "deprecated/clutter-alpha.h"
-
#include "clutter-actor.h"
+#include "clutter-container.h"
#include "clutter-debug.h"
#include "clutter-enum-types.h"
@@ -707,42 +704,8 @@ parse_signals (ClutterScript *script,
}
}
- /* mandatory: "target-state" or "handler" */
- if (json_object_has_member (object, "target-state"))
- {
- const gchar *state = NULL;
- const gchar *target = NULL;
- gboolean warp_to = FALSE;
-
- target = json_object_get_string_member (object, "target-state");
- if (target == NULL)
- {
- _clutter_script_warn_invalid_value (script,
- "target-state", "string",
- val);
- continue;
- }
-
- if (json_object_has_member (object, "states"))
- state = json_object_get_string_member (object, "states");
-
- if (json_object_has_member (object, "warp"))
- warp_to = json_object_get_boolean_member (object, "warp");
-
- CLUTTER_NOTE (SCRIPT,
- "Added signal '%s' (states:%s, target-state:%s, warp:%s)",
- name,
- state != NULL ? state : "<default>", target,
- warp_to ? "true" : "false");
-
- sinfo = g_slice_new0 (SignalInfo);
- sinfo->is_handler = FALSE;
- sinfo->name = g_strdup (name);
- sinfo->state = g_strdup (state);
- sinfo->target = g_strdup (target);
- sinfo->warp_to = warp_to;
- }
- else if (json_object_has_member (object, "handler"))
+ /* mandatory: "handler" */
+ if (json_object_has_member (object, "handler"))
{
const gchar *handler;
const gchar *connect;
@@ -792,7 +755,7 @@ parse_signals (ClutterScript *script,
else
_clutter_script_warn_missing_attribute (script,
NULL,
- "handler or state");
+ "handler");
if (sinfo != NULL)
retval = g_list_prepend (retval, sinfo);
}
@@ -800,51 +763,6 @@ parse_signals (ClutterScript *script,
return retval;
}
-static ClutterTimeline *
-construct_timeline (ClutterScript *script,
- JsonObject *object)
-{
- ClutterTimeline *retval = NULL;
- ObjectInfo *oinfo;
- GList *members, *l;
-
- /* we fake an ObjectInfo so we can reuse clutter_script_construct_object()
- * here; we do not save it inside the hash table, because if this had
- * been a named object then we wouldn't have ended up here in the first
- * place
- */
- oinfo = g_slice_new0 (ObjectInfo);
- oinfo->gtype = CLUTTER_TYPE_TIMELINE;
- oinfo->id = g_strdup ("dummy");
-
- members = json_object_get_members (object);
- for (l = members; l != NULL; l = l->next)
- {
- const gchar *name = l->data;
- JsonNode *node = json_object_get_member (object, name);
- PropertyInfo *pinfo = g_slice_new0 (PropertyInfo);
-
- pinfo->name = g_strdelimit (g_strdup (name), G_STR_DELIMITERS, '-');
- pinfo->node = json_node_copy (node);
-
- oinfo->properties = g_list_prepend (oinfo->properties, pinfo);
- }
-
- g_list_free (members);
-
- _clutter_script_construct_object (script, oinfo);
- _clutter_script_apply_properties (script, oinfo);
- retval = CLUTTER_TIMELINE (oinfo->object);
-
- /* we transfer ownership to the alpha function, so we ref before
- * destroying the ObjectInfo to avoid the timeline going away
- */
- g_object_ref (retval);
- object_info_free (oinfo);
-
- return retval;
-}
-
/* define the names of the animation modes to match the ones
* that developers might be more accustomed to
*/
@@ -926,106 +844,6 @@ _clutter_script_resolve_animation_mode (JsonNode *node)
return CLUTTER_CUSTOM_MODE;
}
-static ClutterAlphaFunc
-resolve_alpha_func (const gchar *name)
-{
- static GModule *module = NULL;
- ClutterAlphaFunc func;
-
- CLUTTER_NOTE (SCRIPT, "Looking up '%s' alpha function", name);
-
- if (G_UNLIKELY (!module))
- module = g_module_open (NULL, 0);
-
- if (g_module_symbol (module, name, (gpointer) &func))
- {
- CLUTTER_NOTE (SCRIPT, "Found '%s' alpha function in the symbols table",
- name);
- return func;
- }
-
- return NULL;
-}
-
-GObject *
-_clutter_script_parse_alpha (ClutterScript *script,
- JsonNode *node)
-{
- GObject *retval = NULL;
- JsonObject *object;
- ClutterTimeline *timeline = NULL;
- ClutterAlphaFunc alpha_func = NULL;
- ClutterAnimationMode mode = CLUTTER_CUSTOM_MODE;
- JsonNode *val;
- gboolean unref_timeline = FALSE;
-
- if (JSON_NODE_TYPE (node) != JSON_NODE_OBJECT)
- return NULL;
-
- object = json_node_get_object (node);
-
- val = json_object_get_member (object, "timeline");
- if (val)
- {
- if (JSON_NODE_TYPE (val) == JSON_NODE_VALUE &&
- json_node_get_string (val) != NULL)
- {
- const gchar *id_ = json_node_get_string (val);
-
- timeline =
- CLUTTER_TIMELINE (clutter_script_get_object (script, id_));
- }
- else if (JSON_NODE_TYPE (val) == JSON_NODE_OBJECT)
- {
- timeline = construct_timeline (script, json_node_get_object (val));
- unref_timeline = TRUE;
- }
- }
-
- val = json_object_get_member (object, "mode");
- if (val != NULL)
- mode = _clutter_script_resolve_animation_mode (val);
-
- if (mode == CLUTTER_CUSTOM_MODE)
- {
- val = json_object_get_member (object, "function");
- if (val && json_node_get_string (val) != NULL)
- {
- alpha_func = resolve_alpha_func (json_node_get_string (val));
- if (!alpha_func)
- {
- g_warning ("Unable to find the function '%s' in the "
- "Clutter alpha functions or the symbols table",
- json_node_get_string (val));
- }
- }
- }
-
- CLUTTER_NOTE (SCRIPT, "Parsed alpha: %s timeline (%p) (mode:%d, func:%p)",
- unref_timeline ? "implicit" : "explicit",
- timeline ? timeline : 0x0,
- mode != CLUTTER_CUSTOM_MODE ? mode : 0,
- alpha_func ? alpha_func : 0x0);
-
- retval = g_object_new (CLUTTER_TYPE_ALPHA, NULL);
-
- if (mode != CLUTTER_CUSTOM_MODE)
- clutter_alpha_set_mode (CLUTTER_ALPHA (retval), mode);
-
- if (alpha_func != NULL)
- clutter_alpha_set_func (CLUTTER_ALPHA (retval), alpha_func, NULL, NULL);
-
- clutter_alpha_set_timeline (CLUTTER_ALPHA (retval), timeline);
-
- /* if we created an implicit timeline, the Alpha has full ownership
- * of it now, since it won't be accessible from ClutterScript
- */
- if (unref_timeline)
- g_object_unref (timeline);
-
- return retval;
-}
-
static void
clutter_script_parser_object_end (JsonParser *json_parser,
JsonObject *object)
@@ -2023,7 +1841,7 @@ add_children (ClutterScript *script,
name,
g_type_name (G_OBJECT_TYPE (container)));
- clutter_container_add_actor (container, CLUTTER_ACTOR (object));
+ clutter_actor_add_child (CLUTTER_ACTOR (container), CLUTTER_ACTOR (object));
}
g_list_foreach (oinfo->children, (GFunc) g_free, NULL);
diff --git a/clutter/clutter-script-private.h b/clutter/clutter-script-private.h
index 52a67bc..33959f9 100644
--- a/clutter/clutter-script-private.h
+++ b/clutter/clutter-script-private.h
@@ -128,8 +128,6 @@ gboolean _clutter_script_parse_geometry (ClutterScript *script,
gboolean _clutter_script_parse_color (ClutterScript *script,
JsonNode *node,
ClutterColor *color);
-GObject *_clutter_script_parse_alpha (ClutterScript *script,
- JsonNode *node);
gboolean _clutter_script_parse_point (ClutterScript *script,
JsonNode *node,
ClutterPoint *point);
diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c
index 6d0b607..7c3d247 100644
--- a/clutter/clutter-script.c
+++ b/clutter/clutter-script.c
@@ -75,66 +75,6 @@
* packing rules of Clutter still apply, and an actor cannot be packed
* in multiple containers without unparenting it in between).
*
- * Behaviours and timelines can also be defined inside a UI definition
- * buffer:
- *
- * <informalexample><programlisting><![CDATA[
- * {
- * "id" : "rotate-behaviour",
- * "type" : "ClutterBehaviourRotate",
- * "angle-start" : 0.0,
- * "angle-end" : 360.0,
- * "axis" : "z-axis",
- * "alpha" : {
- * "timeline" : { "duration" : 4000, "loop" : true },
- * "mode" : "easeInSine"
- * }
- * }
- * ]]></programlisting></informalexample>
- *
- * And then to apply a defined behaviour to an actor defined inside the
- * definition of an actor, the "behaviour" member can be used:
- *
- * <informalexample><programlisting><![CDATA[
- * {
- * "id" : "my-rotating-actor",
- * "type" : "ClutterTexture",
- * ...
- * "behaviours" : [ "rotate-behaviour" ]
- * }
- * ]]></programlisting></informalexample>
- *
- * A #ClutterAlpha belonging to a #ClutterBehaviour can only be defined
- * implicitly like in the example above, or explicitly by setting the
- * "alpha" property to point to a previously defined #ClutterAlpha, e.g.:
- *
- * <informalexample><programlisting><![CDATA[
- * {
- * "id" : "rotate-behaviour",
- * "type" : "ClutterBehaviourRotate",
- * "angle-start" : 0.0,
- * "angle-end" : 360.0,
- * "axis" : "z-axis",
- * "alpha" : {
- * "id" : "rotate-alpha",
- * "type" : "ClutterAlpha",
- * "timeline" : {
- * "id" : "rotate-timeline",
- * "type : "ClutterTimeline",
- * "duration" : 4000,
- * "loop" : true
- * },
- * "function" : "custom_sine_alpha"
- * }
- * }
- * ]]></programlisting></informalexample>
- *
- * Implicitely defined #ClutterAlpha<!-- -->s and #ClutterTimeline<!-- -->s
- * can omit the <varname>id</varname> member, as well as the
- * <varname>type</varname> member, but will not be available using
- * clutter_script_get_object() (they can, however, be extracted using the
- * #ClutterBehaviour and #ClutterAlpha API respectively).
- *
* Signal handlers can be defined inside a Clutter UI definition file and
* then autoconnected to their respective signals using the
* clutter_script_connect_signals() function:
@@ -158,49 +98,6 @@
* respectively) and the "object" string member for calling
* g_signal_connect_object() instead of g_signal_connect().
*
- * Signals can also be directly attached to a specific state defined
- * inside a #ClutterState instance, for instance:
- *
- * |[
- * ...
- * "signals" : [
- * {
- * "name" : "enter-event",
- * "states" : "button-states",
- * "target-state" : "hover"
- * },
- * {
- * "name" : "leave-event",
- * "states" : "button-states",
- * "target-state" : "base"
- * },
- * {
- * "name" : "button-press-event",
- * "states" : "button-states",
- * "target-state" : "active",
- * },
- * {
- * "name" : "key-press-event",
- * "states" : "button-states",
- * "target-state" : "key-focus",
- * "warp" : true
- * }
- * ],
- * ...
- * ]|
- *
- * The "states" key defines the #ClutterState instance to be used to
- * resolve the "target-state" key; it can be either a script id for a
- * #ClutterState built by the same #ClutterScript instance, or to a
- * #ClutterState built in code and associated to the #ClutterScript
- * instance through the clutter_script_add_states() function. If no
- * "states" key is present, then the default #ClutterState associated to
- * the #ClutterScript instance will be used; the default #ClutterState
- * can be set using clutter_script_add_states() using a %NULL name. The
- * "warp" key can be used to warp to a specific state instead of
- * animating to it. State changes on signal emission will not affect
- * the signal emission chain.
- *
* Clutter reserves the following names, so classes defining properties
* through the usual GObject registration process should avoid using these
* names to avoid collisions:
@@ -211,7 +108,6 @@
* function
* "type_func" := the GType function name, for non-standard classes
* "children" := an array of names or objects to add as children
- * "behaviours" := an array of names or objects to apply to an actor
* "signals" := an array of signal definitions to connect to an object
* "is-default" := a boolean flag used when defining the #ClutterStage;
* if set to "true" the default stage will be used instead
@@ -234,8 +130,6 @@
#include <glib-object.h>
#include <gmodule.h>
-#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
-
#include "clutter-actor.h"
#include "clutter-stage.h"
#include "clutter-texture.h"
@@ -248,11 +142,6 @@
#include "clutter-private.h"
#include "clutter-debug.h"
-#include "deprecated/clutter-alpha.h"
-#include "deprecated/clutter-behaviour.h"
-#include "deprecated/clutter-container.h"
-#include "deprecated/clutter-state.h"
-
enum
{
PROP_0,
@@ -277,8 +166,6 @@ struct _ClutterScriptPrivate
ClutterScriptParser *parser;
- GHashTable *states;
-
gchar **search_paths;
gchar *translation_domain;
@@ -331,7 +218,6 @@ signal_info_free (gpointer data)
g_free (sinfo->name);
g_free (sinfo->handler);
g_free (sinfo->object);
- g_free (sinfo->state);
g_free (sinfo->target);
g_slice_free (SignalInfo, sinfo);
@@ -389,7 +275,6 @@ clutter_script_finalize (GObject *gobject)
g_hash_table_destroy (priv->objects);
g_strfreev (priv->search_paths);
g_free (priv->filename);
- g_hash_table_destroy (priv->states);
g_free (priv->translation_domain);
G_OBJECT_CLASS (clutter_script_parent_class)->finalize (gobject);
@@ -526,9 +411,6 @@ clutter_script_init (ClutterScript *script)
priv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL,
object_info_free);
- priv->states = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- (GDestroyNotify) g_object_unref);
}
/**
@@ -874,8 +756,7 @@ construct_each_objects (gpointer key,
if (oinfo->object == NULL)
_clutter_script_construct_object (script, oinfo);
- /* this will take care of setting up properties,
- * adding children and applying behaviours
+ /* this will take care of setting up properties
*/
_clutter_script_apply_properties (script, oinfo);
}
@@ -1049,65 +930,12 @@ clutter_script_connect_signals (ClutterScript *script,
}
typedef struct {
- ClutterState *state;
- GObject *emitter;
- gchar *target;
- gulong signal_id;
- gulong hook_id;
- gboolean warp_to;
-} HookData;
-
-typedef struct {
ClutterScript *script;
ClutterScriptConnectFunc func;
gpointer user_data;
} SignalConnectData;
static void
-hook_data_free (gpointer data)
-{
- if (G_LIKELY (data != NULL))
- {
- HookData *hook_data = data;
-
- g_free (hook_data->target);
- g_slice_free (HookData, hook_data);
- }
-}
-
-static gboolean
-clutter_script_state_change_hook (GSignalInvocationHint *ihint,
- guint n_params,
- const GValue *params,
- gpointer user_data)
-{
- HookData *hook_data = user_data;
- GObject *emitter;
-
- emitter = g_value_get_object (¶ms[0]);
-
- if (emitter == hook_data->emitter)
- {
- if (hook_data->warp_to)
- clutter_state_warp_to_state (hook_data->state, hook_data->target);
- else
- clutter_state_set_state (hook_data->state, hook_data->target);
- }
-
- return TRUE;
-}
-
-static void
-clutter_script_remove_state_change_hook (gpointer user_data,
- GObject *object_p)
-{
- HookData *hook_data = user_data;
-
- g_signal_remove_emission_hook (hook_data->signal_id,
- hook_data->hook_id);
-}
-
-static void
connect_each_object (gpointer key,
gpointer value,
gpointer data)
@@ -1144,67 +972,6 @@ connect_each_object (gpointer key,
connect_data->user_data);
}
}
- else
- {
- GObject *state_object = NULL;
- const gchar *signal_name, *signal_detail;
- gchar **components;
- GQuark signal_quark;
- guint signal_id;
- HookData *hook_data;
-
- if (sinfo->state == NULL)
- state_object = (GObject *) clutter_script_get_states (script, NULL);
- else
- {
- state_object = clutter_script_get_object (script, sinfo->state);
- if (state_object == NULL)
- state_object = (GObject *) clutter_script_get_states (script, sinfo->state);
- }
-
- if (state_object == NULL)
- continue;
-
- components = g_strsplit (sinfo->name, "::", 2);
- if (g_strv_length (components) == 2)
- {
- signal_name = components[0];
- signal_detail = components[1];
- }
- else
- {
- signal_name = components[0];
- signal_detail = NULL;
- }
-
- signal_id = g_signal_lookup (signal_name, G_OBJECT_TYPE (object));
- if (signal_id == 0)
- {
- g_strfreev (components);
- continue;
- }
-
- if (signal_detail != NULL)
- signal_quark = g_quark_from_string (signal_detail);
- else
- signal_quark = 0;
-
- hook_data = g_slice_new (HookData);
- hook_data->emitter = object;
- hook_data->state = CLUTTER_STATE (state_object);
- hook_data->target = g_strdup (sinfo->target);
- hook_data->warp_to = sinfo->warp_to;
- hook_data->signal_id = signal_id;
- hook_data->hook_id =
- g_signal_add_emission_hook (signal_id, signal_quark,
- clutter_script_state_change_hook,
- hook_data,
- hook_data_free);
-
- g_object_weak_ref (hook_data->emitter,
- clutter_script_remove_state_change_hook,
- hook_data);
- }
signal_info_free (sinfo);
}
@@ -1429,72 +1196,6 @@ clutter_script_list_objects (ClutterScript *script)
}
/**
- * clutter_script_add_states:
- * @script: a #ClutterScript
- * @name: (allow-none): a name for the @state, or %NULL to
- * set the default #ClutterState
- * @state: a #ClutterState
- *
- * Associates a #ClutterState to the #ClutterScript instance using the given
- * name.
- *
- * The #ClutterScript instance will use @state to resolve target states when
- * connecting signal handlers.
- *
- * The #ClutterScript instance will take a reference on the #ClutterState
- * passed to this function.
- *
- * Since: 1.8
- *
- * Deprecated: 1.12
- */
-void
-clutter_script_add_states (ClutterScript *script,
- const gchar *name,
- ClutterState *state)
-{
- g_return_if_fail (CLUTTER_IS_SCRIPT (script));
- g_return_if_fail (CLUTTER_IS_STATE (state));
-
- if (name == NULL || *name == '\0')
- name = "__clutter_script_default_state";
-
- g_hash_table_replace (script->priv->states,
- g_strdup (name),
- g_object_ref (state));
-}
-
-/**
- * clutter_script_get_states:
- * @script: a #ClutterScript
- * @name: (allow-none): the name of the #ClutterState, or %NULL
- *
- * Retrieves the #ClutterState for the given @state_name.
- *
- * If @name is %NULL, this function will return the default
- * #ClutterState instance.
- *
- * Return value: (transfer none): a pointer to the #ClutterState for the
- * given name. The #ClutterState is owned by the #ClutterScript instance
- * and it should not be unreferenced
- *
- * Since: 1.8
- *
- * Deprecated: 1.12
- */
-ClutterState *
-clutter_script_get_states (ClutterScript *script,
- const gchar *name)
-{
- g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), NULL);
-
- if (name == NULL || *name == '\0')
- name = "__clutter_script_default_state";
-
- return g_hash_table_lookup (script->priv->states, name);
-}
-
-/**
* clutter_script_set_translation_domain:
* @script: a #ClutterScript
* @domain: (allow-none): the translation domain, or %NULL
diff --git a/clutter/clutter-script.h b/clutter/clutter-script.h
index f2b6222..5cf2062 100644
--- a/clutter/clutter-script.h
+++ b/clutter/clutter-script.h
@@ -168,15 +168,6 @@ void clutter_script_unmerge_objects (ClutterScript
guint merge_id);
void clutter_script_ensure_objects (ClutterScript *script);
-CLUTTER_DEPRECATED_IN_1_12
-void clutter_script_add_states (ClutterScript *script,
- const gchar *name,
- ClutterState *state);
-
-CLUTTER_DEPRECATED_IN_1_12
-ClutterState * clutter_script_get_states (ClutterScript *script,
- const gchar *name);
-
void clutter_script_connect_signals (ClutterScript *script,
gpointer user_data);
void clutter_script_connect_signals_full (ClutterScript *script,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]