[Spice-commits] 5 commits - doc/reference gtk/Makefile.am gtk/map-file gtk/snappy.c gtk/spice-cmdline.c gtk/spice-option.c gtk/spice-option.h gtk/spice-session.c gtk/spice-util.c gtk/spice-util-priv.h gtk/spicy.c gtk/spicy-stats.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Sun Jul 17 07:53:44 PDT 2011


 doc/reference/.gitignore             |    2 
 doc/reference/Makefile.am            |    1 
 doc/reference/spice-gtk-sections.txt |    4 -
 gtk/Makefile.am                      |    4 +
 gtk/map-file                         |    4 -
 gtk/snappy.c                         |    2 
 gtk/spice-cmdline.c                  |   79 ++-------------------
 gtk/spice-option.c                   |  129 +++++++++++++++++++++++++++++++++++
 gtk/spice-option.h                   |   31 ++++++++
 gtk/spice-session.c                  |   73 +++++++++++++++++++
 gtk/spice-util-priv.h                |   29 +++++++
 gtk/spice-util.c                     |   17 ++++
 gtk/spicy-stats.c                    |    2 
 gtk/spicy.c                          |   61 ++--------------
 14 files changed, 311 insertions(+), 127 deletions(-)

New commits:
commit 28f71863de5980e3136189a2d27cc10d4281df43
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sun Jul 17 12:24:04 2011 +0200

    gtk: snappy/spicy-stats move connection option to main group

diff --git a/gtk/snappy.c b/gtk/snappy.c
index 4a26569..32bd0fb 100644
--- a/gtk/snappy.c
+++ b/gtk/snappy.c
@@ -148,8 +148,8 @@ int main(int argc, char *argv[])
     context = g_option_context_new(_(" - make screen shots"));
     g_option_context_set_summary(context, _("A Spice server client to take screenshots in ppm format."));
     g_option_context_set_description(context, _("Report bugs to " PACKAGE_BUGREPORT "."));
+    g_option_context_set_main_group(context, spice_cmdline_get_option_group());
     g_option_context_add_main_entries(context, app_entries, NULL);
-    g_option_context_add_group(context, spice_cmdline_get_option_group());
     if (!g_option_context_parse (context, &argc, &argv, &error)) {
         g_print(_("option parsing failed: %s\n"), error->message);
         exit(1);
diff --git a/gtk/spicy-stats.c b/gtk/spicy-stats.c
index 79c5f99..331e5e2 100644
--- a/gtk/spicy-stats.c
+++ b/gtk/spicy-stats.c
@@ -98,8 +98,8 @@ int main(int argc, char *argv[])
     context = g_option_context_new(_(" - make screen shots"));
     g_option_context_set_summary(context, _("A Spice client used for testing and measurements."));
     g_option_context_set_description(context, _("Report bugs to " PACKAGE_BUGREPORT "."));
+    g_option_context_set_main_group(context, spice_cmdline_get_option_group());
     g_option_context_add_main_entries(context, app_entries, NULL);
-    g_option_context_add_group(context, spice_cmdline_get_option_group());
     if (!g_option_context_parse (context, &argc, &argv, &error)) {
         g_print(_("option parsing failed: %s\n"), error->message);
         exit(1);
commit 58e3974c735e4bed442a169d2f58867042707ddb
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sun Jul 17 12:16:54 2011 +0200

    gtk: update spicy to use new option API

diff --git a/gtk/spice-cmdline.c b/gtk/spice-cmdline.c
index 352a922..bb4b630 100644
--- a/gtk/spice-cmdline.c
+++ b/gtk/spice-cmdline.c
@@ -29,11 +29,6 @@ static char *port;
 static char *tls_port;
 static char *password;
 static char *uri;
-static char *ca_file;
-static char *host_subject;
-static char *smartcard_db;
-static char *smartcard_certificates;
-static gboolean smartcard = FALSE;
 
 static GOptionEntry spice_entries[] = {
     {
@@ -64,12 +59,6 @@ static GOptionEntry spice_entries[] = {
         .description      = N_("Spice server secure port"),
         .arg_description  = N_("<port>"),
     },{
-        .long_name        = "ca-file",
-        .arg              = G_OPTION_ARG_FILENAME,
-        .arg_data         = &ca_file,
-        .description      = N_("Truststore file for secure connections"),
-        .arg_description  = N_("<file>"),
-    },{
         .long_name        = "password",
         .short_name       = 'w',
         .arg              = G_OPTION_ARG_STRING,
@@ -77,58 +66,26 @@ static GOptionEntry spice_entries[] = {
         .description      = N_("Server password"),
         .arg_description  = N_("<password>"),
     },{
-        .long_name        = "host-subject",
-        .arg              = G_OPTION_ARG_STRING,
-        .arg_data         = &host_subject,
-        .description      = N_("Subject of the host certificate (field=value pairs separated by commas)"),
-        .arg_description  = N_("<host-subject>"),
-    },{
-#ifdef USE_SMARTCARD
-        .long_name        = "smartcard",
-        .arg              = G_OPTION_ARG_NONE,
-        .arg_data         = &smartcard,
-        .description      = N_("Enable smartcard support"),
-        .arg_description  = NULL,
-    },{
-        .long_name        = "smartcard-certificates",
-        .arg              = G_OPTION_ARG_STRING,
-        .arg_data         = &smartcard_certificates,
-        .description      = N_("Certificates to use for software smartcards (field=values separated by commas)"),
-        .arg_description  = N_("<certificates>"),
-    },{
-        .long_name        = "smartcard-db",
-        .arg              = G_OPTION_ARG_STRING,
-        .arg_data         = &smartcard_db,
-        .description      = N_("Path to the local certificate database to use for software smartcard certificates"),
-        .arg_description  = N_("<certificate-db>"),
-    },{
-#endif
         /* end of list */
     }
 };
 
-static GOptionGroup *spice_group;
-
 GOptionGroup *spice_cmdline_get_option_group(void)
 {
-    if (spice_group == NULL) {
-        spice_group = g_option_group_new("spice",
-                                         _("Spice Options:"),
-                                         _("Show spice Options"),
-                                         NULL, NULL);
-        g_option_group_add_entries(spice_group, spice_entries);
-    }
-    return spice_group;
+    GOptionGroup *grp;
+
+    grp = g_option_group_new("spice",
+                             _("Spice connection options:"),
+                             _("Show Spice options"),
+                             NULL, NULL);
+    g_option_group_add_entries(grp, spice_entries);
+
+    return grp;
 }
 
 void spice_cmdline_session_setup(SpiceSession *session)
 {
-    if (ca_file == NULL) {
-        const char *homedir = g_getenv("HOME");
-        if (!homedir)
-            homedir = g_get_home_dir();
-        ca_file = g_strdup_printf("%s/.spicec/spice_truststore.pem", homedir);
-    }
+    g_return_if_fail(SPICE_IS_SESSION(session));
 
     if (uri)
         g_object_set(session, "uri", uri, NULL);
@@ -140,20 +97,4 @@ void spice_cmdline_session_setup(SpiceSession *session)
         g_object_set(session, "tls-port", tls_port, NULL);
     if (password)
         g_object_set(session, "password", password, NULL);
-    if (ca_file)
-        g_object_set(session, "ca-file", ca_file, NULL);
-    if (host_subject)
-        g_object_set(session, "cert-subject", host_subject, NULL);
-    if (smartcard) {
-        g_object_set(session, "enable-smartcard", smartcard, NULL);
-        if (smartcard_certificates) {
-            GStrv certs_strv;
-            certs_strv = g_strsplit(smartcard_certificates, ",", -1);
-            if (certs_strv)
-                g_object_set(session, "smartcard-certificates", certs_strv, NULL);
-            g_strfreev(certs_strv);
-        }
-        if (smartcard_db)
-            g_object_set(session, "smartcard-db", smartcard_db, NULL);
-    }
 }
diff --git a/gtk/spicy.c b/gtk/spicy.c
index 62a1732..a954085 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -36,6 +36,7 @@
 #include "spice-audio.h"
 #include "spice-common.h"
 #include "spice-cmdline.h"
+#include "spice-option.h"
 
 /* config */
 static gboolean fullscreen = false;
@@ -88,8 +89,6 @@ static GKeyFile      *keyfile = NULL;
 static GnomeRRScreen *rrscreen = NULL;
 static GnomeRRConfig *rrsaved = NULL;
 static GnomeRRConfig *rrcurrent = NULL;
-static GStrv         disable_effects = NULL;
-static gint          color_depth = 0;
 
 static spice_connection *connection_new(void);
 static void connection_connect(spice_connection *conn);
@@ -444,7 +443,7 @@ static void menu_cb_statusbar(GtkToggleAction *action, gpointer data)
 
 static void menu_cb_about(GtkAction *action, void *data)
 {
-    char *comments = _("gtk client app for the\n"
+    char *comments = _("gtk test client app for the\n"
         "spice remote desktop protocol");
     static char *copyright = "(c) 2010 Red Hat";
     static char *website = "http://www.spice-space.org";
@@ -1305,21 +1304,6 @@ static void display_mark(SpiceChannel *channel, gint mark, spice_window *win)
     }
 }
 
-static gboolean strv_contains(const GStrv strv, gchar *str)
-{
-    int i = 0;
-
-    if (strv == NULL)
-        return FALSE;
-
-    while (strv[i] != NULL) {
-        if (g_str_equal(strv[i], str))
-            return TRUE;
-        i++;
-    }
-    return FALSE;
-}
-
 static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
 {
     spice_connection *conn = data;
@@ -1339,20 +1323,6 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
                          G_CALLBACK(main_agent_update), conn);
         main_mouse_update(channel, conn);
         main_agent_update(channel, conn);
-        {
-            gboolean all = strv_contains(disable_effects, "all");
-
-            g_object_set(channel,
-                         "disable-wallpaper", all || strv_contains(disable_effects, "wallpaper"),
-                         "disable-font-smooth", all || strv_contains(disable_effects, "font-smooth"),
-                         "disable-animation", all || strv_contains(disable_effects, "animation"),
-                         NULL);
-            if (color_depth != 0)
-                g_object_set(channel,
-                             "color-depth", color_depth,
-                             NULL);
-
-        }
     }
 
     if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
@@ -1480,28 +1450,12 @@ static GOptionEntry cmd_entries[] = {
         .arg              = G_OPTION_ARG_NONE,
         .arg_data         = &fullscreen,
         .description      = N_("Open in full screen mode"),
-    },
-    {
+    },{
         .long_name        = "version",
         .arg              = G_OPTION_ARG_NONE,
         .arg_data         = &version,
         .description      = N_("Display version and quit"),
-    },
-    {
-        .long_name        = "disable-effects",
-        .arg              = G_OPTION_ARG_STRING_ARRAY,
-        .arg_data         = &disable_effects,
-        .description      = N_("Disable guest display effects"),
-        .arg_description  = N_("<wallpaper,font-smooth,animation,all>"),
-    },
-    {
-        .long_name        = "color-depth",
-        .arg              = G_OPTION_ARG_INT,
-        .arg_data         = &color_depth,
-        .description      = N_("Guest display color depth"),
-        .arg_description  = N_("<16,32>"),
-    },
-    {
+    },{
         /* end of list */
     }
 };
@@ -1580,9 +1534,10 @@ int main(int argc, char *argv[])
 
     /* parse opts */
     gtk_init(&argc, &argv);
-    context = g_option_context_new(_("- spice client application"));
-    g_option_context_set_summary(context, _("A Gtk client to connect to Spice servers."));
+    context = g_option_context_new(_("- spice client test application"));
+    g_option_context_set_summary(context, _("Gtk+ test client to connect to Spice servers."));
     g_option_context_set_description(context, _("Report bugs to " PACKAGE_BUGREPORT "."));
+    g_option_context_add_group(context, spice_get_option_group());
     g_option_context_set_main_group(context, spice_cmdline_get_option_group());
     g_option_context_add_main_entries(context, cmd_entries, NULL);
     g_option_context_add_group(context, gtk_get_option_group(TRUE));
@@ -1604,7 +1559,9 @@ int main(int argc, char *argv[])
     if (rrscreen)
         g_signal_connect(rrscreen, "changed", G_CALLBACK(on_screen_changed), NULL);
     on_screen_changed(rrscreen, NULL);
+
     conn = connection_new();
+    spice_set_session_option(conn->session);
     spice_cmdline_session_setup(conn->session);
     connection_connect(conn);
 
commit 8d1d79d29b20af5f86a70e4515de0e7d60a47f97
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sun Jul 17 12:06:44 2011 +0200

    gtk: add spice_get_option_group()

diff --git a/doc/reference/.gitignore b/doc/reference/.gitignore
index 34eb965..37508df 100644
--- a/doc/reference/.gitignore
+++ b/doc/reference/.gitignore
@@ -24,6 +24,8 @@
 /pdf-build.stamp
 /pdf.stamp
 /scan-build.stamp
+/setup-build.stamp
+/setup.stamp
 /sgml-build.stamp
 /sgml.stamp
 /so_locations
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index dc906b6..4007ba4 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -71,6 +71,7 @@ IGNORE_HFILES= \
 	spice-pulse.h				\
 	spice-session-priv.h			\
 	spice-types.h				\
+	spice-cmdline.h				\
 	tcp.h					\
 	vncdisplaykeymap.h
 
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 9467faa..e463991 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -26,8 +26,8 @@ spice_session_open_fd
 spice_session_disconnect
 spice_session_get_channels
 <SUBSECTION>
-spice_cmdline_get_option_group
-spice_cmdline_session_setup
+spice_get_option_group
+spice_set_session_option
 <SUBSECTION Standard>
 SPICE_SESSION
 SPICE_IS_SESSION
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 541d451..35e39c2 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -152,6 +152,8 @@ libspice_client_glib_2_0_la_SOURCES =	\
 	spice-common.h			\
 	spice-util.c			\
 	spice-util-priv.h		\
+	spice-option.h			\
+	spice-option.c			\
 	\
 	spice-client.c			\
 	spice-session.c			\
@@ -222,6 +224,7 @@ libspice_client_glibinclude_HEADERS =	\
 	spice-channel.h			\
 	spice-glib-enums.h		\
 	spice-util.h			\
+	spice-option.h			\
 	channel-cursor.h		\
 	channel-display.h		\
 	channel-inputs.h		\
diff --git a/gtk/map-file b/gtk/map-file
index 6aca103..f358066 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -26,6 +26,7 @@ spice_display_new;
 spice_display_paste_from_guest;
 spice_display_send_keys;
 spice_display_set_grab_keys;
+spice_get_option_group;
 spice_grab_sequence_as_string;
 spice_grab_sequence_copy;
 spice_grab_sequence_free;
@@ -65,13 +66,14 @@ spice_session_migration_get_type;
 spice_session_new;
 spice_session_open_fd;
 spice_session_verify_get_type;
+spice_set_session_option;
 spice_smartcard_channel_get_type;
 spice_smartcard_manager_get;
 spice_smartcard_manager_get_type;
 spice_smartcard_manager_insert_card;
 spice_smartcard_manager_remove_card;
-spice_smartcard_reader_is_software;
 spice_smartcard_reader_get_type;
+spice_smartcard_reader_is_software;
 spice_util_get_debug;
 spice_util_get_version_string;
 spice_util_set_debug;
diff --git a/gtk/spice-option.c b/gtk/spice-option.c
new file mode 100644
index 0000000..8f2088a
--- /dev/null
+++ b/gtk/spice-option.c
@@ -0,0 +1,129 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2010 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include "spice-session.h"
+#include "spice-util.h"
+
+static gchar *disable_effects = NULL;
+static gint color_depth = 0;
+static char *ca_file = NULL;
+static char *host_subject = NULL;
+static char *smartcard_db = NULL;
+static char *smartcard_certificates = NULL;
+static gboolean smartcard = FALSE;
+
+static void option_version(void)
+{
+    g_print(PACKAGE_STRING "\n");
+    exit(0);
+}
+
+static void option_debug(void)
+{
+    spice_util_set_debug(TRUE);
+}
+
+/**
+ * spice_get_option_group:
+ *
+ * Returns: a #GOptionGroup for the commandline arguments specific to
+ * Spice.  You have to call spice_set_session_option() after to set
+ * the options on a #SpiceSession.
+ **/
+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,
+          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>") },
+        { "spice-host-subject", '\0', 0, G_OPTION_ARG_STRING, &host_subject,
+          N_("Subject of the host certificate (field=value pairs separated by commas)"), N_("<host-subject>") },
+        { "spice-smartcard", '\0', 0, G_OPTION_ARG_NONE, &smartcard,
+          N_("Enable smartcard support"), NULL },
+        { "spice-smartcard-certificates", '\0', 0, G_OPTION_ARG_STRING, &smartcard_certificates,
+          N_("Certificates to use for software smartcards (field=values separated by commas)"), N_("<certificates>") },
+        { "spice-smartcard-db", '\0', 0, G_OPTION_ARG_STRING, &smartcard_db,
+          N_("Path to the local certificate database to use for software smartcard certificates"), N_("<certificate-db>") },
+
+        { "spice-debug", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_debug,
+          N_("Enable Spice-GTK debugging"), NULL },
+        { "spice-gtk-version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version,
+          N_("Display Spice-GTK version information"), NULL },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+    };
+    GOptionGroup *grp;
+
+    grp = g_option_group_new("spice", _("Spice Options:"), _("Show Spice Options"), NULL, NULL);
+    g_option_group_add_entries(grp, entries);
+
+    return grp;
+}
+
+/**
+ * spice_set_session_option:
+ * @session: a #SpiceSession to set option upon
+ *
+ * Set various properties on @session, according to the commandline
+ * arguments given to spice_get_option_group() option group.
+ **/
+void spice_set_session_option(SpiceSession *session)
+{
+    g_return_if_fail(SPICE_IS_SESSION(session));
+
+    if (ca_file == NULL) {
+        const char *homedir = g_getenv("HOME");
+        if (!homedir)
+            homedir = g_get_home_dir();
+        ca_file = g_strdup_printf("%s/.spicec/spice_truststore.pem", homedir);
+    }
+
+    if (disable_effects) {
+            GStrv effects;
+            effects = g_strsplit(disable_effects, ",", -1);
+            if (effects)
+                g_object_set(session, "disable-effects", effects, NULL);
+            g_strfreev(effects);
+    }
+    if (color_depth)
+        g_object_set(session, "color-depth", color_depth, NULL);
+    if (ca_file)
+        g_object_set(session, "ca-file", ca_file, NULL);
+    if (host_subject)
+        g_object_set(session, "cert-subject", host_subject, NULL);
+    if (smartcard) {
+        g_object_set(session, "enable-smartcard", smartcard, NULL);
+        if (smartcard_certificates) {
+            GStrv certs_strv;
+            certs_strv = g_strsplit(smartcard_certificates, ",", -1);
+            if (certs_strv)
+                g_object_set(session, "smartcard-certificates", certs_strv, NULL);
+            g_strfreev(certs_strv);
+        }
+        if (smartcard_db)
+            g_object_set(session, "smartcard-db", smartcard_db, NULL);
+    }
+}
diff --git a/gtk/spice-option.h b/gtk/spice-option.h
new file mode 100644
index 0000000..69351d3
--- /dev/null
+++ b/gtk/spice-option.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2010 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef SPICE_OPTION_H
+#define SPICE_OPTION_H
+
+#include <glib.h>
+#include <spice-session.h>
+
+G_BEGIN_DECLS
+
+GOptionGroup* spice_get_option_group(void);
+void spice_set_session_option(SpiceSession *session);
+
+G_END_DECLS
+
+#endif /* SPICE_OPTION_H */
commit cd9ddaad11832bcbfd8db20c00d90071588b5e06
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sat Jul 16 20:10:07 2011 +0200

    gtk: add color-depth and disable-effects options

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 38dad34..d4ac0a3 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -20,6 +20,7 @@
 #include "spice-client.h"
 #include "spice-common.h"
 #include "spice-channel-priv.h"
+#include "spice-util-priv.h"
 
 #include "spice-session-priv.h"
 
@@ -58,6 +59,8 @@ struct spice_session {
      * fallback to using a default database.
      */
     char *            smartcard_db;
+    GStrv             disable_effects;
+    gint              color_depth;
 
     int               connection_id;
     int               protocol;
@@ -136,6 +139,8 @@ enum {
     PROP_SMARTCARD,
     PROP_SMARTCARD_CERTIFICATES,
     PROP_SMARTCARD_DB,
+    PROP_DISABLE_EFFECTS,
+    PROP_COLOR_DEPTH,
 };
 
 /* signals */
@@ -233,6 +238,7 @@ spice_session_finalize(GObject *gobject)
     g_free(s->cert_subject);
     g_strfreev(s->smartcard_certificates);
     g_free(s->smartcard_db);
+    g_strfreev(s->disable_effects);
 
     spice_session_palettes_clear(session);
     spice_session_images_clear(session);
@@ -387,6 +393,12 @@ static void spice_session_get_property(GObject    *gobject,
     case PROP_SMARTCARD_DB:
         g_value_set_string(value, s->smartcard_db);
         break;
+    case PROP_DISABLE_EFFECTS:
+        g_value_set_boxed(value, s->disable_effects);
+        break;
+    case PROP_COLOR_DEPTH:
+        g_value_set_int(value, s->color_depth);
+        break;
     default:
 	G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
 	break;
@@ -467,6 +479,13 @@ static void spice_session_set_property(GObject      *gobject,
         g_free(s->smartcard_db);
         s->smartcard_db = g_value_dup_string(value);
         break;
+    case PROP_DISABLE_EFFECTS:
+        g_strfreev(s->disable_effects);
+        s->disable_effects = g_value_dup_boxed(value);
+        break;
+    case PROP_COLOR_DEPTH:
+        s->color_depth = g_value_get_int(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -678,10 +697,47 @@ static void spice_session_class_init(SpiceSessionClass *klass)
                            G_PARAM_STATIC_STRINGS));
 
     /**
+     * SpiceSession:disable-effects:
+     *
+     * A comma-separated list of effects to disable. The settings will
+     * be applied on new display channels. The following effets can be
+     * disabled "wallpaper", "font-smooth", "animation", and "all",
+     * which will disable all the effects. If NULL, don't apply changes.
+     *
+     * Since: 0.7
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_DISABLE_EFFECTS,
+         g_param_spec_boxed ("disable-effects",
+                             "Disable effects",
+                             "Comma-separated effects to disable",
+                             G_TYPE_STRV,
+                             G_PARAM_READWRITE |
+                             G_PARAM_STATIC_STRINGS));
+
+    /**
+     * SpiceSession:color-depth:
+     *
+     * Display color depth to set on new display channels. If 0, don't set.
+     *
+     * Since: 0.7
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_COLOR_DEPTH,
+         g_param_spec_int("color-depth",
+                          "Color depth",
+                          "Display channel color depth",
+                          0, 32, 0,
+                          G_PARAM_READWRITE |
+                          G_PARAM_STATIC_STRINGS));
+
+    /**
      * SpiceSession:enable-smartcard:
      *
      * If set to TRUE, the smartcard channel will be enabled and smartcard
      * events will be forwarded to the guest
+     *
+     * Since: 0.7
      **/
     g_object_class_install_property
         (gobject_class, PROP_SMARTCARD,
@@ -700,6 +756,8 @@ static void spice_session_class_init(SpiceSessionClass *klass)
      * array containing the names of 3 valid certificates, these will be
      * used to simulate a smartcard in the guest
      * @see_also: spice_smartcard_manager_insert_card()
+     *
+     * Since: 0.7
      **/
     g_object_class_install_property
         (gobject_class, PROP_SMARTCARD_CERTIFICATES,
@@ -716,6 +774,8 @@ static void spice_session_class_init(SpiceSessionClass *klass)
      *
      * Path to the NSS certificate database containing the certificates to
      * use to simulate a software smartcard
+     *
+     * Since: 0.7
      **/
     g_object_class_install_property
         (gobject_class, PROP_SMARTCARD_DB,
@@ -1176,6 +1236,19 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
     item = spice_new0(struct channel, 1);
     item->channel = channel;
     ring_add(&s->channels, &item->link);
+
+    if (SPICE_IS_MAIN_CHANNEL(channel)) {
+        gboolean all = spice_strv_contains(s->disable_effects, "all");
+
+        g_object_set(channel,
+                     "disable-wallpaper", all || spice_strv_contains(s->disable_effects, "wallpaper"),
+                     "disable-font-smooth", all || spice_strv_contains(s->disable_effects, "font-smooth"),
+                     "disable-animation", all || spice_strv_contains(s->disable_effects, "animation"),
+                     NULL);
+        if (s->color_depth != 0)
+            g_object_set(channel, "color-depth", s->color_depth, NULL);
+    }
+
     g_signal_emit(session, signals[SPICE_SESSION_CHANNEL_NEW], 0, channel);
 }
 
commit 78a00cf25e4a15a6525c7a13875d9911c1d12378
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sat Jul 16 20:00:18 2011 +0200

    gtk: add spice_strv_contains in util-priv.h

diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index e45cded..541d451 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -151,6 +151,7 @@ libspice_client_glib_2_0_la_SOURCES =	\
 	spice-audio.c			\
 	spice-common.h			\
 	spice-util.c			\
+	spice-util-priv.h		\
 	\
 	spice-client.c			\
 	spice-session.c			\
diff --git a/gtk/spice-util-priv.h b/gtk/spice-util-priv.h
new file mode 100644
index 0000000..90b437c
--- /dev/null
+++ b/gtk/spice-util-priv.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2010 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef SPICE_UTIL_PRIV_H
+#define SPICE_UTIL_PRIV_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean spice_strv_contains(const GStrv strv, const gchar *str);
+
+G_END_DECLS
+
+#endif /* SPICE_UTIL_PRIV_H */
diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index e75cc2e..d3097ca 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -18,7 +18,7 @@
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
-
+#include <glib-object.h>
 #include "spice-util.h"
 
 /**
@@ -59,3 +59,18 @@ const gchar *spice_util_get_version_string(void)
 {
     return VERSION;
 }
+
+G_GNUC_INTERNAL
+gboolean spice_strv_contains(const GStrv strv, const gchar *str)
+{
+    int i;
+
+    if (strv == NULL)
+        return FALSE;
+
+    for (i = 0; strv[i] != NULL; i++)
+        if (g_str_equal(strv[i], str))
+            return TRUE;
+
+    return FALSE;
+}


More information about the Spice-commits mailing list