[hotssh] Add copy/paste actions
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hotssh] Add copy/paste actions
- Date: Thu, 2 Jan 2014 01:37:10 +0000 (UTC)
commit 82d02470788bdfa8086d658f3df62ac4da90ac1a
Author: Colin Walters <walters verbum org>
Date: Wed Jan 1 20:36:32 2014 -0500
Add copy/paste actions
Kind of annoying not to have them...
src/gears-menu.ui | 8 ++++++++
src/hotssh-tab.c | 7 +++++++
src/hotssh-tab.h | 4 +++-
src/hotssh-win.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 61 insertions(+), 2 deletions(-)
---
diff --git a/src/gears-menu.ui b/src/gears-menu.ui
index 62b5c55..a280846 100644
--- a/src/gears-menu.ui
+++ b/src/gears-menu.ui
@@ -11,6 +11,14 @@
<attribute name="label" translatable="yes">_Disconnect</attribute>
<attribute name="action">win.disconnect</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Copy</attribute>
+ <attribute name="action">win.copy</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Paste</attribute>
+ <attribute name="action">win.paste</attribute>
+ </item>
</section>
</menu>
</interface>
diff --git a/src/hotssh-tab.c b/src/hotssh-tab.c
index 3138474..97c7711 100644
--- a/src/hotssh-tab.c
+++ b/src/hotssh-tab.c
@@ -1209,3 +1209,10 @@ hotssh_tab_get_hostname (HotSshTab *self)
HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);
return priv->hostname;
}
+
+VteTerminal *
+hotssh_tab_get_terminal (HotSshTab *self)
+{
+ HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);
+ return (VteTerminal*)priv->terminal;
+}
diff --git a/src/hotssh-tab.h b/src/hotssh-tab.h
index 5d31760..9151771 100644
--- a/src/hotssh-tab.h
+++ b/src/hotssh-tab.h
@@ -20,7 +20,7 @@
#pragma once
-#include <gtk/gtk.h>
+#include <vte/vte.h>
#define HOTSSH_TYPE_TAB (hotssh_tab_get_type ())
#define HOTSSH_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HOTSSH_TYPE_TAB, HotSshTab))
@@ -36,3 +36,5 @@ HotSshTab *hotssh_tab_new_channel (HotSshTab *source);
void hotssh_tab_disconnect (HotSshTab *source);
const char * hotssh_tab_get_hostname (HotSshTab *self);
+
+VteTerminal *hotssh_tab_get_terminal (HotSshTab *self);
diff --git a/src/hotssh-win.c b/src/hotssh-win.c
index 8d824c2..2b13aa5 100644
--- a/src/hotssh-win.c
+++ b/src/hotssh-win.c
@@ -35,11 +35,19 @@ static void new_channel_activated (GSimpleAction *action,
static void disconnect_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+static void copy_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void paste_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
static GActionEntry win_entries[] = {
{ "new-tab", new_tab_activated, NULL, NULL, NULL },
{ "new-channel", new_channel_activated, NULL, NULL, NULL },
- { "disconnect", disconnect_activated, NULL, NULL, NULL }
+ { "disconnect", disconnect_activated, NULL, NULL, NULL },
+ { "copy", copy_activated, NULL, NULL, NULL },
+ { "paste", paste_activated, NULL, NULL, NULL }
};
struct _HotSshWindow
@@ -209,6 +217,40 @@ new_channel_activated (GSimpleAction *action,
}
static void
+copy_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ HotSshWindow *self = user_data;
+ GtkWidget *focus = gtk_window_get_focus ((GtkWindow*)self);
+
+ if (!focus)
+ return;
+
+ if (GTK_IS_EDITABLE (focus))
+ gtk_editable_paste_clipboard ((GtkEditable*) focus);
+ else if (VTE_IS_TERMINAL (focus))
+ vte_terminal_copy_clipboard ((VteTerminal*) focus);
+}
+
+static void
+paste_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ HotSshWindow *self = user_data;
+ GtkWidget *focus = gtk_window_get_focus ((GtkWindow*)self);
+
+ if (!focus)
+ return;
+
+ if (GTK_IS_EDITABLE (focus))
+ gtk_editable_paste_clipboard ((GtkEditable*) focus);
+ else if (VTE_IS_TERMINAL (focus))
+ vte_terminal_paste_clipboard ((VteTerminal*) focus);
+}
+
+static void
hotssh_window_init (HotSshWindow *self)
{
HotSshWindowPrivate *priv = hotssh_window_get_instance_private (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]