[Spice-devel] [PATCH spice-gtk 2/2] Notify agent-connected property change

Marc-André Lureau marcandre.lureau at gmail.com
Sun Mar 18 09:34:44 PDT 2012


---
 gtk/channel-main.c    |   14 ++++++++++++--
 gtk/spice-util-priv.h |    1 +
 gtk/spice-util.c      |    6 ++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 170610a..86e6fba 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1057,6 +1057,16 @@ static void agent_clipboard_release(SpiceMainChannel *channel, guint selection)
 }
 
 /* coroutine context  */
+static void set_agent_connected(SpiceMainChannel *channel, gboolean connected)
+{
+    SpiceMainChannelPrivate *c = channel->priv;
+
+    c->agent_connected = connected;
+    SPICE_DEBUG("agent connected: %s", spice_yes_no(connected));
+    g_object_notify_main_context(G_OBJECT(channel), "agent-connected");
+}
+
+/* coroutine context  */
 static void agent_start(SpiceMainChannel *channel)
 {
     SpiceMainChannelPrivate *c = channel->priv;
@@ -1065,7 +1075,7 @@ static void agent_start(SpiceMainChannel *channel)
     };
     SpiceMsgOut *out;
 
-    c->agent_connected = true;
+    set_agent_connected(channel, TRUE);
     c->agent_caps_received = false;
     emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
 
@@ -1084,7 +1094,7 @@ static void agent_stopped(SpiceMainChannel *channel)
 {
     SpiceMainChannelPrivate *c = SPICE_MAIN_CHANNEL(channel)->priv;
 
-    c->agent_connected = false;
+    set_agent_connected(channel, FALSE);
     c->agent_caps_received = false;
     c->agent_display_config_sent = false;
     emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
diff --git a/gtk/spice-util-priv.h b/gtk/spice-util-priv.h
index 1be0edf..7449667 100644
--- a/gtk/spice-util-priv.h
+++ b/gtk/spice-util-priv.h
@@ -26,6 +26,7 @@ G_BEGIN_DECLS
 
 gboolean spice_strv_contains(const GStrv strv, const gchar *str);
 gchar* spice_uuid_to_string(const guint8 uuid[16]);
+const gchar* spice_yes_no(gboolean value);
 
 #if GLIB_CHECK_VERSION(2,32,0)
 #define STATIC_MUTEX            GMutex
diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 6092a80..1c5d10f 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -204,3 +204,9 @@ gulong spice_g_signal_connect_object (gpointer instance,
 
     return ctx->handler_id;
 }
+
+G_GNUC_INTERNAL
+const gchar* spice_yes_no(gboolean value)
+{
+    return value ? "yes" : "no";
+}
-- 
1.7.7.6



More information about the Spice-devel mailing list