From d5c93f6d550980f75534fdaa8f24db50f490e874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 14 Jun 2010 15:45:07 +0100 Subject: [PATCH] state: make null source state encounterd in json treated as wildcard To be properly useful the state machine needs to be able to specify the default transitions to a target state with no specified source state. --- clutter/clutter-state.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-state.c b/clutter/clutter-state.c index 2821aef13..bb9c3014e 100644 --- a/clutter/clutter-state.c +++ b/clutter/clutter-state.c @@ -1680,7 +1680,26 @@ parse_state_transition (JsonArray *array, } source_name = json_object_get_string_member (object, "source"); - source_state = clutter_state_get_state (clos->state, source_name, FALSE); + if (source_name) + { + source_name = g_intern_string (source_name); + source_state = g_hash_table_lookup (clos->state->priv->states, + source_name); + if (source_state == NULL) + { + source_state = state_new (clos->state, source_name); + g_hash_table_insert (clos->state->priv->states, + (gpointer) source_name, source_state); + } + } + else + { + /* the parsed transition is to be the default transition to + * the specified target state if no other more specific transition + * exist with both source_name and target_name specified. + */ + source_state = NULL; + } target_name = json_object_get_string_member (object, "target"); target_state = clutter_state_get_state (clos->state, target_name, TRUE);