[Xfce4-commits] [apps/xfce4-terminal] 01/01: Check (Ctrl+)+Shift+Ins and middle mouse button click for unsafe paste
noreply at xfce.org
noreply at xfce.org
Wed Mar 6 17:23:08 CET 2019
This is an automated email from the git hooks/post-receive script.
f 2 4 0 4 p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-terminal.
commit 193bf4a7248932c7f156ad69f1668fa183e5045b
Author: Igor <f2404 at yandex.ru>
Date: Wed Mar 6 11:21:45 2019 -0500
Check (Ctrl+)+Shift+Ins and middle mouse button click for unsafe paste
Bug #13252
---
terminal/terminal-screen.c | 2 ++
terminal/terminal-widget.c | 19 +++++++++++++++++++
terminal/terminal-window.c | 6 ++++++
3 files changed, 27 insertions(+)
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index cbaa68e..49f6ea3 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -319,6 +319,8 @@ terminal_screen_init (TerminalScreen *screen)
G_CALLBACK (terminal_screen_vte_resize_window), screen);
g_signal_connect (G_OBJECT (screen->terminal), "draw",
G_CALLBACK (terminal_screen_draw), screen);
+ g_signal_connect_swapped (G_OBJECT (screen->terminal), "paste-selection-request",
+ G_CALLBACK (terminal_screen_paste_primary), screen);
gtk_box_pack_start (GTK_BOX (screen->hbox), screen->terminal, TRUE, TRUE, 0);
screen->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL,
diff --git a/terminal/terminal-widget.c b/terminal/terminal-widget.c
index 11553af..95e2860 100644
--- a/terminal/terminal-widget.c
+++ b/terminal/terminal-widget.c
@@ -50,6 +50,7 @@
enum
{
GET_CONTEXT_MENU,
+ PASTE_SELECTION_REQUEST,
LAST_SIGNAL,
};
@@ -160,6 +161,17 @@ terminal_widget_class_init (TerminalWidgetClass *klass)
0, NULL, NULL,
_terminal_marshal_OBJECT__VOID,
GTK_TYPE_MENU, 0);
+
+ /**
+ * TerminalWidget::paste-selection-request:
+ **/
+ widget_signals[PASTE_SELECTION_REQUEST] =
+ g_signal_new (I_("paste-selection-request"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
@@ -415,6 +427,13 @@ terminal_widget_button_press_event (GtkWidget *widget,
return TRUE;
}
}
+
+ /* intercept middle button click that would paste the selection */
+ if (event->button == 2)
+ {
+ g_signal_emit (G_OBJECT (widget), widget_signals[PASTE_SELECTION_REQUEST], 0, NULL);
+ return TRUE;
+ }
else if (event->button == 3)
{
signal_id = g_signal_connect (G_OBJECT (widget), "commit",
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 4b4a2e3..99d0dba 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -446,6 +446,8 @@ terminal_window_init (TerminalWindow *window)
GtkStyleContext *context;
GClosure *toggle_menubar_closure = g_cclosure_new (G_CALLBACK (terminal_window_toggle_menubar), window, NULL);
+ GClosure *paste_closure = g_cclosure_new (G_CALLBACK (terminal_window_action_paste), window, NULL);
+ GClosure *paste_selection_closure = g_cclosure_new (G_CALLBACK (terminal_window_action_paste_selection), window, NULL);
window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, TERMINAL_TYPE_WINDOW, TerminalWindowPrivate);
@@ -504,6 +506,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_accel_group_connect_by_path (accel_group, "<Actions>/terminal-window/toggle-menubar", toggle_menubar_closure);
+ /* handle Ctrl+Shift+Ins (paste clipboard) and Shift+Ins (paste selection) as if the menu items were used */
+ gtk_accel_group_connect (accel_group, GDK_KEY_Insert, GDK_CONTROL_MASK | GDK_SHIFT_MASK, 0, paste_closure);
+ gtk_accel_group_connect (accel_group, GDK_KEY_Insert, GDK_SHIFT_MASK, 0, paste_selection_closure);
+
window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), window->priv->vbox);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list