[Spice-commits] 2 commits - gtk/spice-option.c

Christophe Fergau teuf at kemper.freedesktop.org
Mon Aug 13 01:01:52 PDT 2012


 gtk/spice-option.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

New commits:
commit 82c367bdd543a01fa2f7f39113f51272f4f7a9e0
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Aug 10 17:17:00 2012 +0200

    Check --spice-disable-effects parameter validity
    
    When --spice-disable-effects is used, error out unless this is
    the name of one of the effects we can disable.
    
    Fixes rhbz#818848

diff --git a/gtk/spice-option.c b/gtk/spice-option.c
index c65397a..715e84a 100644
--- a/gtk/spice-option.c
+++ b/gtk/spice-option.c
@@ -79,6 +79,29 @@ error:
     return FALSE;
 }
 
+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;
+    }
+
+    disable_effects = g_strdup(value);
+
+    return TRUE;
+}
+
+
 /**
  * spice_get_option_group:
  *
@@ -90,7 +113,7 @@ error:
 GOptionGroup* spice_get_option_group(void)
 {
     const GOptionEntry entries[] = {
-        { "spice-disable-effects", '\0', 0, G_OPTION_ARG_STRING, &disable_effects,
+        { "spice-disable-effects", '\0', 0, G_OPTION_ARG_CALLBACK, parse_disable_effects,
           N_("Disable guest display effects"), N_("<wallpaper,font-smooth,animation,all>") },
         { "spice-color-depth", '\0', 0, G_OPTION_ARG_CALLBACK, parse_color_depth,
           N_("Guest display color depth"), N_("<16,32>") },
commit 36df67347770c596c8d9e1a23b023beab2d31c38
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Aug 10 17:17:00 2012 +0200

    Check --spice-color-depth parameter validity
    
    When --spice-color-depth is used, error out unless the color depth
    is 16 or 32.
    
    Fixes rhbz#818847

diff --git a/gtk/spice-option.c b/gtk/spice-option.c
index ea5d226..c65397a 100644
--- a/gtk/spice-option.c
+++ b/gtk/spice-option.c
@@ -52,6 +52,33 @@ static gboolean option_debug(void)
     return TRUE;
 }
 
+static gboolean parse_color_depth(const gchar *option_name, const gchar *value,
+                                  gpointer data, GError **error)
+{
+    unsigned long parsed_depth;
+    char *end;
+
+    if (option_name == NULL) {
+        g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, _("missing color depth, must be 16 or 32"));
+        return FALSE;
+    }
+
+    parsed_depth = strtoul(value, &end, 0);
+    if (*end != '\0')
+        goto error;
+
+    if ((parsed_depth != 16) && (parsed_depth != 32))
+        goto error;
+
+    color_depth = parsed_depth;
+
+    return TRUE;
+
+error:
+    g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, _("invalid color depth (%s), must be 16 or 32"), value);
+    return FALSE;
+}
+
 /**
  * spice_get_option_group:
  *
@@ -65,7 +92,7 @@ GOptionGroup* spice_get_option_group(void)
     const GOptionEntry entries[] = {
         { "spice-disable-effects", '\0', 0, G_OPTION_ARG_STRING, &disable_effects,
           N_("Disable guest display effects"), N_("<wallpaper,font-smooth,animation,all>") },
-        { "spice-color-depth", '\0', 0, G_OPTION_ARG_INT, &color_depth,
+        { "spice-color-depth", '\0', 0, G_OPTION_ARG_CALLBACK, parse_color_depth,
           N_("Guest display color depth"), N_("<16,32>") },
         { "spice-ca-file", '\0', 0, G_OPTION_ARG_FILENAME, &ca_file,
           N_("Truststore file for secure connections"), N_("<file>") },


More information about the Spice-commits mailing list