aboutsummaryrefslogtreecommitdiff
path: root/ui/gtk.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2016-04-17 23:25:54 +0300
committerGerd Hoffmann <kraxel@redhat.com>2016-05-12 16:41:18 +0200
commit44b31e0bc4e32abe7bca38fa2a9d8ffbbb419764 (patch)
tree98fad327019e1953e69b1eb875bde0b8507c35dd /ui/gtk.c
parentbb732ee78cee8688e74b0f67ff8cc34290f5c9cf (diff)
ui/gtk: copy to clipboard support
This adds a menu item to copy current selection to clipboard. Seems handy for copying out guest error messages. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-id: 1460924740-24513-1-git-send-email-mst@redhat.com [ kraxel: fix build with CONFIG_VTE=n ] [ kraxel: fix build with CONFIG_VTE=n, now for real ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 2e360e3a52..2c0f20b9f2 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -139,6 +139,7 @@ struct GtkDisplayState {
GtkWidget *view_menu_item;
GtkWidget *view_menu;
GtkWidget *full_screen_item;
+ GtkWidget *copy_item;
GtkWidget *zoom_in_item;
GtkWidget *zoom_out_item;
GtkWidget *zoom_fixed_item;
@@ -1589,6 +1590,14 @@ static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
}
#if defined(CONFIG_VTE)
+static void gd_menu_copy(GtkMenuItem *item, void *opaque)
+{
+ GtkDisplayState *s = opaque;
+ VirtualConsole *vc = gd_vc_find_current(s);
+
+ vte_terminal_copy_clipboard(VTE_TERMINAL(vc->vte.terminal));
+}
+
static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
{
VirtualConsole *vc = opaque;
@@ -1825,6 +1834,10 @@ static void gd_connect_signals(GtkDisplayState *s)
G_CALLBACK(gd_menu_powerdown), s);
g_signal_connect(s->quit_item, "activate",
G_CALLBACK(gd_menu_quit), s);
+#if defined(CONFIG_VTE)
+ g_signal_connect(s->copy_item, "activate",
+ G_CALLBACK(gd_menu_copy), s);
+#endif
g_signal_connect(s->full_screen_item, "activate",
G_CALLBACK(gd_menu_full_screen), s);
g_signal_connect(s->zoom_in_item, "activate",
@@ -1958,6 +1971,11 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
s->full_screen_item = gtk_menu_item_new_with_mnemonic(_("_Fullscreen"));
+#if defined(CONFIG_VTE)
+ s->copy_item = gtk_menu_item_new_with_mnemonic(_("_Copy"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->copy_item);
+#endif
+
gtk_accel_group_connect(s->accel_group, GDK_KEY_f, HOTKEY_MODIFIERS, 0,
g_cclosure_new_swap(G_CALLBACK(gd_accel_full_screen), s, NULL));
#if GTK_CHECK_VERSION(3, 8, 0)