summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2009-09-07 11:36:05 +0100
committerNeil Roberts <neil@linux.intel.com>2009-09-07 12:44:06 +0100
commitc69209a253c7ccbfe5d2c91e6972fa3dc1deb50c (patch)
tree02cca8b07b2710167fa7807e3d096afda6685ffc
parent7783635af3c78cf65fcb62ccb03478f1a9556b05 (diff)
downloadclutter-c69209a253c7ccbfe5d2c91e6972fa3dc1deb50c.tar.gz
[animation] Move the check for the 'signal::' prefix into a separate function
The old code checked whether the property began with 'signal-' and then checked for 'signal-swapped' and 'signal-after'. This prevented you from animating a property called for example 'signal-strength'. The check for the prefix is now in a separate function which also adds a 'signal-swapped-after' prefix for completeness. Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1798
-rw-r--r--clutter/clutter-animation.c75
1 files changed, 41 insertions, 34 deletions
diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c
index fbbecb59c..b31445610 100644
--- a/clutter/clutter-animation.c
+++ b/clutter/clutter-animation.c
@@ -1616,6 +1616,39 @@ clutter_animation_setupv (ClutterAnimation *animation,
}
}
+static const struct
+{
+ const gchar *name;
+ GConnectFlags flags;
+} signal_prefixes[] =
+ {
+ { "::", 0 },
+ { "-swapped::", G_CONNECT_SWAPPED },
+ { "-after::", G_CONNECT_AFTER },
+ { "-swapped-after::", G_CONNECT_SWAPPED | G_CONNECT_AFTER }
+ };
+
+static gboolean
+clutter_animation_has_signal_prefix (const gchar *property_name,
+ GConnectFlags *flags,
+ int *offset)
+{
+ int i;
+
+ if (!g_str_has_prefix (property_name, "signal"))
+ return FALSE;
+
+ for (i = 0; i < G_N_ELEMENTS (signal_prefixes); i++)
+ if (g_str_has_prefix (property_name + 6, signal_prefixes[i].name))
+ {
+ *offset = strlen (signal_prefixes[i].name) + 6;
+ *flags = signal_prefixes[i].flags;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
clutter_animation_setup_valist (ClutterAnimation *animation,
const gchar *first_property_name,
@@ -1634,46 +1667,20 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
GValue final = { 0, };
gchar *error = NULL;
gboolean is_fixed = FALSE;
+ GConnectFlags flags;
+ int offset;
- if (g_str_has_prefix (property_name, "signal::"))
- {
- const gchar *signal_name = property_name + 8;
- GCallback callback = va_arg (var_args, GCallback);
- gpointer userdata = va_arg (var_args, gpointer);
-
- g_signal_connect (animation, signal_name, callback, userdata);
- }
- else if (g_str_has_prefix (property_name, "signal-"))
+ if (clutter_animation_has_signal_prefix (property_name,
+ &flags,
+ &offset))
{
+ const gchar *signal_name = property_name + offset;
GCallback callback = va_arg (var_args, GCallback);
gpointer userdata = va_arg (var_args, gpointer);
- const gchar *signal_name;
- GConnectFlags flags;
-
- if (g_str_has_prefix (property_name, "signal-after::"))
- {
- signal_name = property_name + 14;
- flags = G_CONNECT_AFTER;
- }
- else if (g_str_has_prefix (property_name, "signal-swapped::"))
- {
- signal_name = property_name + 16;
- flags = G_CONNECT_SWAPPED;
- }
- else
- {
- g_warning ("Unable to connect to '%s': the valid signal "
- "modifiers are 'signal-swapped::' and "
- "'signal-swapped::'",
- property_name);
- break;
- }
g_signal_connect_data (animation, signal_name,
- callback,
- userdata,
- NULL,
- flags);
+ callback, userdata,
+ NULL, flags);
}
else
{