Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntenore Gatta <antenore@simbiosi.org>2021-04-19 00:36:55 +0300
committerAntenore Gatta <antenore@simbiosi.org>2021-04-19 00:40:52 +0300
commite64d11ba228883d2ee358b57efe87ca7b6375fa3 (patch)
treeefbd4773740d547d6a5171cd33f88f6177c2abfd /src
parentb339fb11b8c6b17ec940905bdd46bc7f408f420c (diff)
Send text clipboard content as keystrokes
This patch add a submenu in the keystrokes tool menu "Send clipboard content as keystrokes". This is useful when the remote clipboard doesn't work Should fix #2476 Signed-off-by: Antenore Gatta <antenore@simbiosi.org>
Diffstat (limited to 'src')
-rw-r--r--src/rcw.c6
-rw-r--r--src/remmina_protocol_widget.c48
-rw-r--r--src/remmina_protocol_widget.h1
3 files changed, 55 insertions, 0 deletions
diff --git a/src/rcw.c b/src/rcw.c
index 702143139..d2190f6d6 100644
--- a/src/rcw.c
+++ b/src/rcw.c
@@ -1967,6 +1967,12 @@ static void rcw_toolbar_tools(GtkToolItem *toggle, RemminaConnectionWindow *cnnw
}
g_strfreev(keystroke_values);
}
+ menuitem = gtk_menu_item_new_with_label(_("Send clipboard content as text"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(submenu_keystrokes), menuitem);
+ g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
+ G_CALLBACK(remmina_protocol_widget_send_clipboard),
+ REMMINA_PROTOCOL_WIDGET(cnnobj->proto));
+ gtk_widget_show(menuitem);
}
g_strfreev(keystrokes);
}
diff --git a/src/remmina_protocol_widget.c b/src/remmina_protocol_widget.c
index 1655850fb..538394abb 100644
--- a/src/remmina_protocol_widget.c
+++ b/src/remmina_protocol_widget.c
@@ -579,8 +579,56 @@ void remmina_protocol_widget_send_keystrokes(RemminaProtocolWidget *gp, GtkMenuI
return;
}
+void remmina_protocol_widget_send_clip_strokes(GtkClipboard *clipboard, const gchar *text, gpointer data)
+{
+ TRACE_CALL(__func__);
+
+ guint *keyvals;
+ gunichar character;
+ guint keyval;
+ gint n_keys;
+
+ RemminaProtocolWidget *gp = REMMINA_PROTOCOL_WIDGET(data);
+ if (remmina_protocol_widget_plugin_receives_keystrokes(gp)) {
+ if(text) {
+ gchar *iter = g_strdup(text);
+ keyvals = (guint *)g_malloc(strlen(text));
+ while (TRUE) {
+ /* Process each character in the keystrokes */
+ character = g_utf8_get_char_validated(iter, -1);
+ if (character == 0)
+ break;
+ keyval = gdk_unicode_to_keyval(character);
+
+ n_keys = 0;
+ keyvals[n_keys++] = keyval;
+ /* Send keystroke to the plugin */
+ gp->priv->plugin->send_keystrokes(gp, keyvals, n_keys);
+
+ iter = g_utf8_find_next_char(iter, NULL);
+ }
+ }
+ }
+ return;
+}
+
+void remmina_protocol_widget_send_clipboard(RemminaProtocolWidget *gp, GtkMenuItem *widget)
+{
+ TRACE_CALL(__func__);
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+
+ /* Request the contents of the clipboard, contents_received will be
+ called when we do get the contents.
+ */
+ gtk_clipboard_request_text (clipboard,
+ remmina_protocol_widget_send_clip_strokes, gp);
+}
+
gboolean remmina_protocol_widget_plugin_screenshot(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd)
{
+ TRACE_CALL(__func__);
if (!gp->priv->plugin->get_plugin_screenshot) {
REMMINA_DEBUG("plugin screenshot function is not implemented, using core Remmina functionality");
return FALSE;
diff --git a/src/remmina_protocol_widget.h b/src/remmina_protocol_widget.h
index abb971159..9ad92c5fc 100644
--- a/src/remmina_protocol_widget.h
+++ b/src/remmina_protocol_widget.h
@@ -169,6 +169,7 @@ void remmina_protocol_widget_send_keys_signals(GtkWidget *widget, const guint *k
gboolean remmina_protocol_widget_plugin_receives_keystrokes(RemminaProtocolWidget *gp);
/* Send to the plugin some keystrokes */
void remmina_protocol_widget_send_keystrokes(RemminaProtocolWidget *gp, GtkMenuItem *widget);
+void remmina_protocol_widget_send_clipboard(RemminaProtocolWidget *gp, GtkMenuItem *widget);
/* Take screenshot of plugin */
gboolean remmina_protocol_widget_plugin_screenshot(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd);