diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-04-23 17:38:48 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-04-23 19:41:30 +0200 |
commit | 9add68bf442bf8c2b62534d5be8cf5586288e0a5 (patch) | |
tree | f78b812915fb947492266a54960c1bd3f2eb28ae | |
parent | f0a423db8e98cab914871eb3eb2a8af252a371d8 (diff) |
option: Allow multiple options in --disable-effects
Commit 82c367 added checks that the value passed to --disable-effects
is valid, but it does not take into account that it's perfectly valid
to pass multiple values separated by commas. This commit splits
the value passed to --disable-effects and checks each component separatey.
Fixes rhbz#955277
-rw-r--r-- | gtk/spice-option.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/gtk/spice-option.c b/gtk/spice-option.c index 4bda520..5f7c803 100644 --- a/gtk/spice-option.c +++ b/gtk/spice-option.c @@ -27,7 +27,7 @@ #include "spice-channel-priv.h" #include "usb-device-manager.h" -static gchar *disable_effects = NULL; +static GStrv disable_effects = NULL; static gint color_depth = 0; static char *ca_file = NULL; static char *host_subject = NULL; @@ -85,22 +85,26 @@ error: static gboolean parse_disable_effects(const gchar *option_name, const gchar *value, gpointer data, GError **error) { - - if ((g_strcmp0(value, "wallpaper") != 0) - && (g_strcmp0(value, "font-smooth") != 0) - && (g_strcmp0(value, "animation") != 0) - && (g_strcmp0(value, "all") != 0)) { - /* Translators: do not translate 'wallpaper', 'font-smooth', - * 'animation', 'all' as the user must use these values with the - * --spice-disable-effects command line option - */ - g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, - _("invalid effect name (%s), must be 'wallpaper', 'font-smooth', 'animation' or 'all'"), value); - return FALSE; + GStrv it; + + disable_effects = g_strsplit(value, ",", -1); + for (it = disable_effects; *it != NULL; it++) { + if ((g_strcmp0(*it, "wallpaper") != 0) + && (g_strcmp0(*it, "font-smooth") != 0) + && (g_strcmp0(*it, "animation") != 0) + && (g_strcmp0(*it, "all") != 0)) { + /* Translators: do not translate 'wallpaper', 'font-smooth', + * 'animation', 'all' as the user must use these values with the + * --spice-disable-effects command line option + */ + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, + _("invalid effect name (%s), must be 'wallpaper', 'font-smooth', 'animation' or 'all'"), *it); + g_strfreev(disable_effects); + disable_effects = NULL; + return FALSE; + } } - disable_effects = g_strdup(value); - return TRUE; } @@ -222,11 +226,7 @@ void spice_set_session_option(SpiceSession *session) } if (disable_effects) { - GStrv effects; - effects = g_strsplit(disable_effects, ",", -1); - if (effects) - g_object_set(session, "disable-effects", effects, NULL); - g_strfreev(effects); + g_object_set(session, "disable-effects", disable_effects, NULL); } if (secure_channels) { |