[Spice-devel] [PATCH spice-gtk 3/5] main: use self for main channel variable

Marc-André Lureau marcandre.lureau at gmail.com
Wed Nov 6 13:25:10 PST 2013


From: Marc-André Lureau <marcandre.lureau at redhat.com>

This simplifies the following commit which uses even more
SPICE_MAIN_CHANNEL macro, and makes the code unnecessarily heavy.
---
 gtk/channel-main.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 75d0281..cc64274 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1803,7 +1803,8 @@ static void file_xfer_handle_status(SpiceMainChannel *channel,
 static void main_agent_handle_msg(SpiceChannel *channel,
                                   VDAgentMessage *msg, gpointer payload)
 {
-    SpiceMainChannelPrivate *c = SPICE_MAIN_CHANNEL(channel)->priv;
+    SpiceMainChannel *self = SPICE_MAIN_CHANNEL(channel);
+    SpiceMainChannelPrivate *c = self->priv;
     guint8 selection = VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD;
 
     g_return_if_fail(msg->protocol == VD_AGENT_PROTOCOL);
@@ -1841,15 +1842,15 @@ static void main_agent_handle_msg(SpiceChannel *channel,
             VD_AGENT_SET_CAPABILITY(c->agent_caps, i);
         }
         c->agent_caps_received = true;
-        emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
+        emit_main_context(self, SPICE_MAIN_AGENT_UPDATE);
 
         if (caps->request)
-            agent_announce_caps(SPICE_MAIN_CHANNEL(channel));
+            agent_announce_caps(self);
 
         if (VD_AGENT_HAS_CAPABILITY(caps->caps, G_N_ELEMENTS(c->agent_caps), VD_AGENT_CAP_DISPLAY_CONFIG) &&
             !c->agent_display_config_sent) {
-            agent_display_config(SPICE_MAIN_CHANNEL(channel));
-            agent_send_msg_queue(SPICE_MAIN_CHANNEL(channel));
+            agent_display_config(self);
+            agent_send_msg_queue(self);
             c->agent_display_config_sent = true;
         }
         break;
@@ -1857,21 +1858,21 @@ static void main_agent_handle_msg(SpiceChannel *channel,
     case VD_AGENT_CLIPBOARD:
     {
         VDAgentClipboard *cb = payload;
-        emit_main_context(channel, SPICE_MAIN_CLIPBOARD_SELECTION, selection,
+        emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION, selection,
                           cb->type, cb->data, msg->size - sizeof(VDAgentClipboard));
 
        if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
-            emit_main_context(channel, SPICE_MAIN_CLIPBOARD,
+            emit_main_context(self, SPICE_MAIN_CLIPBOARD,
                               cb->type, cb->data, msg->size - sizeof(VDAgentClipboard));
         break;
     }
     case VD_AGENT_CLIPBOARD_GRAB:
     {
         gboolean ret;
-        emit_main_context(channel, SPICE_MAIN_CLIPBOARD_SELECTION_GRAB, selection,
+        emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_GRAB, selection,
                           (guint8*)payload, msg->size / sizeof(uint32_t), &ret);
         if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
-            emit_main_context(channel, SPICE_MAIN_CLIPBOARD_GRAB,
+            emit_main_context(self, SPICE_MAIN_CLIPBOARD_GRAB,
                               payload, msg->size / sizeof(uint32_t), &ret);
         break;
     }
@@ -1879,20 +1880,20 @@ static void main_agent_handle_msg(SpiceChannel *channel,
     {
         gboolean ret;
         VDAgentClipboardRequest *req = payload;
-        emit_main_context(channel, SPICE_MAIN_CLIPBOARD_SELECTION_REQUEST, selection,
+        emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_REQUEST, selection,
                           req->type, &ret);
 
         if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
-            emit_main_context(channel, SPICE_MAIN_CLIPBOARD_REQUEST,
+            emit_main_context(self, SPICE_MAIN_CLIPBOARD_REQUEST,
                               req->type, &ret);
         break;
     }
     case VD_AGENT_CLIPBOARD_RELEASE:
     {
-        emit_main_context(channel, SPICE_MAIN_CLIPBOARD_SELECTION_RELEASE, selection);
+        emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_RELEASE, selection);
 
         if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
-            emit_main_context(channel, SPICE_MAIN_CLIPBOARD_RELEASE);
+            emit_main_context(self, SPICE_MAIN_CLIPBOARD_RELEASE);
         break;
     }
     case VD_AGENT_REPLY:
@@ -1903,7 +1904,7 @@ static void main_agent_handle_msg(SpiceChannel *channel,
         break;
     }
     case VD_AGENT_FILE_XFER_STATUS:
-        file_xfer_handle_status(SPICE_MAIN_CHANNEL(channel), payload);
+        file_xfer_handle_status(self, payload);
         break;
     default:
         g_warning("unhandled agent message type: %u (%s), size %u",
-- 
1.8.3.1



More information about the Spice-devel mailing list