[hotssh] win: Add switch-tab action and keybindings for <Alt>0 to 9
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hotssh] win: Add switch-tab action and keybindings for <Alt>0 to 9
- Date: Fri, 3 Jan 2014 18:48:04 +0000 (UTC)
commit 850263ce1d86af0540d26d7bf80f1e59ddc02931
Author: Colin Walters <walters verbum org>
Date: Fri Jan 3 13:47:22 2014 -0500
win: Add switch-tab action and keybindings for <Alt>0 to 9
Like gnome-terminal. Hard to live without.
src/hotssh-app.c | 12 ++++++++++++
src/hotssh-win.c | 18 +++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/hotssh-app.c b/src/hotssh-app.c
index 0f4c245..56a13e6 100644
--- a/src/hotssh-app.c
+++ b/src/hotssh-app.c
@@ -108,6 +108,7 @@ hotssh_app_startup (GApplication *app)
HotSshApp *hotssh_app = HOTSSH_APP (app);
GtkBuilder *builder;
GMenuModel *app_menu;
+
G_APPLICATION_CLASS (hotssh_app_parent_class)->startup (app);
@@ -123,6 +124,17 @@ hotssh_app_startup (GApplication *app)
g_object_unref (builder);
gtk_application_add_accelerator ((GtkApplication*)app, "<Control><Shift>T", "win.new-tab", NULL);
+ {
+ guint i = 0;
+ for (i = 1; i <= 9; i++)
+ {
+ gs_free char *key = g_strdup_printf ("<Alt>%u", i);
+ gtk_application_add_accelerator ((GtkApplication*)app, key, "win.switch-tab",
+ g_variant_new_uint32 (i-1));
+ }
+ gtk_application_add_accelerator ((GtkApplication*)app, "<Alt>0", "win.switch-tab",
+ g_variant_new_uint32 (9));
+ }
}
static void
diff --git a/src/hotssh-win.c b/src/hotssh-win.c
index f1480a5..a1a56d2 100644
--- a/src/hotssh-win.c
+++ b/src/hotssh-win.c
@@ -40,6 +40,9 @@ static void copy_activated (GSimpleAction *action,
static void paste_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+static void switch_tab_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
static GActionEntry win_entries[] = {
/* For now, autotab == new channel if possible */
@@ -48,7 +51,8 @@ static GActionEntry win_entries[] = {
{ "new-channel", new_channel_activated, NULL, NULL, NULL },
{ "disconnect", disconnect_activated, NULL, NULL, NULL },
{ "copy", copy_activated, NULL, NULL, NULL },
- { "paste", paste_activated, NULL, NULL, NULL }
+ { "paste", paste_activated, NULL, NULL, NULL },
+ { "switch-tab", switch_tab_activated, "u", "uint32 0", NULL }
};
struct _HotSshWindow
@@ -361,6 +365,18 @@ paste_activated (GSimpleAction *action,
}
static void
+switch_tab_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ HotSshWindow *self = user_data;
+ HotSshWindowPrivate *priv = hotssh_window_get_instance_private (self);
+ guint32 tabnum = g_variant_get_uint32 (parameter);
+
+ gtk_notebook_set_current_page ((GtkNotebook*)priv->main_notebook, tabnum);
+}
+
+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]