[gtk-vnc-devel] [patch] clipboard support



Hi, folks.

In this patch i just added support to clipboard in vncdisplay, already
done in gvnc.[hc].

I've tested in vinagre and it worked fine :)

OK to commit?

Cheers,
-- 
Jonh Wendell
jonh wendell gmail com (MSN / Google Talk)

Linux User #114432
https://launchpad.net/~wendell
diff -r 1d5e4d1f22a6 src/gvnc.c
--- a/src/gvnc.c	Wed Oct 03 12:39:50 2007 -0300
+++ b/src/gvnc.c	Wed Oct 03 21:44:45 2007 -0300
@@ -1000,6 +1000,9 @@ static void gvnc_server_cut_text(struct 
 {
 	if (gvnc->has_error || !gvnc->ops.server_cut_text)
 		return;
+
+	GVNC_DEBUG("Server cut text\n");
+
 	if (!gvnc->ops.server_cut_text(gvnc->ops_data, data, len))
 		gvnc->has_error = TRUE;
 }
diff -r 1d5e4d1f22a6 src/libgtk-vnc_sym.version
--- a/src/libgtk-vnc_sym.version	Wed Oct 03 12:39:50 2007 -0300
+++ b/src/libgtk-vnc_sym.version	Wed Oct 03 21:44:45 2007 -0300
@@ -23,6 +23,8 @@
     vnc_display_get_width;
     vnc_display_get_height;
     vnc_display_get_name;
+
+    vnc_display_client_cut_text;
 
     gvnc_new;
     gvnc_free;
diff -r 1d5e4d1f22a6 src/vncdisplay.c
--- a/src/vncdisplay.c	Wed Oct 03 12:39:50 2007 -0300
+++ b/src/vncdisplay.c	Wed Oct 03 21:44:45 2007 -0300
@@ -78,12 +78,14 @@ typedef enum
 	VNC_AUTH_FAILURE,
 	VNC_AUTH_UNSUPPORTED,
 
+	VNC_SERVER_CUT_TEXT,
+
 	LAST_SIGNAL
 } vnc_display_signals;
 
 static guint signals[LAST_SIGNAL] = { 0, 0, 0, 0,
 				      0, 0, 0, 0,
-				      0, 0, 0, };
+				      0, 0, 0, 0,};
 static GParamSpec *signalCredParam;
 
 GtkWidget *vnc_display_new(void)
@@ -615,6 +617,20 @@ static gboolean on_auth_unsupported(void
 	return TRUE;
 }
 
+static gboolean on_server_cut_text(void *opaque, const void* text, size_t len)
+{
+	VncDisplay *obj = VNC_DISPLAY(opaque);
+	GString *str = g_string_new_len ((const gchar *)text, len);
+
+	g_signal_emit (G_OBJECT (obj),
+		       signals[VNC_SERVER_CUT_TEXT],
+		       0,
+		       str->str);
+
+	g_string_free (str, TRUE);
+	return TRUE;
+}
+
 static gboolean on_local_cursor(void *opaque, int x, int y, int width, int height, uint8_t *image)
 {
 	VncDisplay *obj = VNC_DISPLAY(opaque);
@@ -656,7 +672,8 @@ static const struct gvnc_ops vnc_display
 	.pointer_type_change = on_pointer_type_change,
 	.shared_memory_rmid = on_shared_memory_rmid,
 	.local_cursor = on_local_cursor,
-	.auth_unsupported = on_auth_unsupported
+	.auth_unsupported = on_auth_unsupported,
+	.server_cut_text = on_server_cut_text
 };
 
 static void *vnc_coroutine(void *opaque)
@@ -974,6 +991,18 @@ static void vnc_display_class_init(VncDi
 			     G_TYPE_NONE,
 			     1,
 			     G_TYPE_UINT);
+
+	signals[VNC_SERVER_CUT_TEXT] =
+		g_signal_new("vnc-server-cut-text",
+			     G_TYPE_FROM_CLASS(klass),
+			     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+			     0,
+			     NULL,
+			     NULL,
+			     g_cclosure_marshal_VOID__STRING,
+			     G_TYPE_NONE,
+			     1,
+			     G_TYPE_STRING);
 
 	g_type_class_add_private(klass, sizeof(VncDisplayPrivate));
 }
@@ -1179,6 +1208,13 @@ const char * vnc_display_get_name(VncDis
 	return gvnc_get_name (obj->priv->gvnc);
 }
 
+void vnc_display_client_cut_text(VncDisplay *obj, const gchar *text)
+{
+	g_return_if_fail (VNC_IS_DISPLAY (obj));
+
+	gvnc_client_cut_text(obj->priv->gvnc, text, strlen (text));
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8
diff -r 1d5e4d1f22a6 src/vncdisplay.h
--- a/src/vncdisplay.h	Wed Oct 03 12:39:50 2007 -0300
+++ b/src/vncdisplay.h	Wed Oct 03 21:44:45 2007 -0300
@@ -87,6 +87,8 @@ int		vnc_display_get_height(VncDisplay *
 int		vnc_display_get_height(VncDisplay *obj);
 const char *	vnc_display_get_name(VncDisplay *obj);
 
+void		vnc_display_client_cut_text(VncDisplay *obj, const gchar *text);
+
 G_END_DECLS
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]