[connections] vnc-connection: Add shared clipboard support
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [connections] vnc-connection: Add shared clipboard support
- Date: Wed, 7 Jul 2021 11:53:28 +0000 (UTC)
commit 0e909160d4920885323dc7295059df5e2770b9c3
Author: Manuel Wassermann <manuel wassermann97 gmail com>
Date: Wed Jul 7 12:49:28 2021 +0200
vnc-connection: Add shared clipboard support
Fixes: #14
src/vnc-connection.vala | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
diff --git a/src/vnc-connection.vala b/src/vnc-connection.vala
index 4befaa0..59a6f54 100644
--- a/src/vnc-connection.vala
+++ b/src/vnc-connection.vala
@@ -24,6 +24,7 @@ using Vnc;
namespace Connections {
private class VncConnection : Connection {
private Gtk.Window window;
+ private Gtk.Clipboard clipboard;
private Vnc.Display display;
public override Gtk.Widget widget {
@@ -93,10 +94,14 @@ namespace Connections {
window.add (display);
display.realize ();
+ clipboard = Gtk.Clipboard.get_default(window.get_display ());
+
display.vnc_initialized.connect (() => { show (); });
display.vnc_auth_credential.connect (on_vnc_auth_credential_cb);
display.vnc_auth_failure.connect (on_vnc_auth_failure_cb);
display.size_allocate.connect (scale);
+ display.vnc_server_cut_text.connect (on_vnc_server_cut_text_cb);
+ clipboard.owner_change.connect (on_owner_change_cb);
notify["scale-mode"].connect (scale);
}
@@ -207,6 +212,22 @@ namespace Connections {
auth_failed (reason);
}
+ private void on_vnc_server_cut_text_cb (string message) {
+ if (view_only)
+ return;
+
+ clipboard.set_text (message, message.length);
+ clipboard.store ();
+ }
+
+ private void on_owner_change_cb () {
+ if (view_only)
+ return;
+
+ string message = clipboard.wait_for_text ();
+ display.client_cut_text (message);
+ }
+
public void scale () {
if (!display.is_open ())
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]