[gnome-builder/wip/plugins] workbench: bring back <ctrl>1..5 to focus view column



commit 61d8309c29ea06009553e6b17106db7278e267ad
Author: Christian Hergert <christian hergert me>
Date:   Thu Jun 11 01:23:53 2015 -0700

    workbench: bring back <ctrl>1..5 to focus view column

 src/app/gb-application.c             |   10 +++++-----
 src/workbench/gb-workbench-actions.c |   27 +++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 9553a1a..1c4774c 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -140,11 +140,11 @@ gb_application_load_keybindings (GbApplication *self)
     { "workbench.show-bottom-pane", "<ctrl>F9" },
     { "workbench.toggle-panels", "<ctrl><shift>F9" },
     { "workspace.focus-sidebar", "<ctrl>0" },
-    { "workspace.focus-stack(1)", "<ctrl>1" },
-    { "workspace.focus-stack(2)", "<ctrl>2" },
-    { "workspace.focus-stack(3)", "<ctrl>3" },
-    { "workspace.focus-stack(4)", "<ctrl>4" },
-    { "workspace.focus-stack(5)", "<ctrl>5" },
+    { "workbench.focus-stack(1)", "<ctrl>1" },
+    { "workbench.focus-stack(2)", "<ctrl>2" },
+    { "workbench.focus-stack(3)", "<ctrl>3" },
+    { "workbench.focus-stack(4)", "<ctrl>4" },
+    { "workbench.focus-stack(5)", "<ctrl>5" },
     { "workbench.show-gear-menu", "F10" },
     { "workbench.global-search", "<ctrl>period" },
     { "app.preferences", "<ctrl>comma" },
diff --git a/src/workbench/gb-workbench-actions.c b/src/workbench/gb-workbench-actions.c
index 6b5e792..1ede837 100644
--- a/src/workbench/gb-workbench-actions.c
+++ b/src/workbench/gb-workbench-actions.c
@@ -432,9 +432,36 @@ sync_reveal_state (GtkWidget     *child,
   g_simple_action_set_state (action, g_variant_new_boolean (reveal));
 }
 
+static void
+gb_workbench_actions_focus_stack (GSimpleAction *action,
+                                  GVariant      *variant,
+                                  gpointer       user_data)
+{
+  GbWorkbench *self = user_data;
+  GtkWidget *stack;
+  GList *stacks;
+  gint nth;
+
+  g_assert (GB_IS_WORKBENCH (self));
+  g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_INT32));
+
+  /* Our index is 1-based for the column mapping. */
+  nth = g_variant_get_int32 (variant);
+  if (nth <= 0)
+    return;
+
+  stacks = gb_view_grid_get_stacks (self->view_grid);
+  stack = g_list_nth_data (stacks, nth - 1);
+  if (stack != NULL)
+    gtk_widget_grab_focus (stack);
+  g_list_free (stacks);
+}
+
+
 static const GActionEntry GbWorkbenchActions[] = {
   { "build",            gb_workbench_actions_build },
   { "dayhack",          gb_workbench_actions_dayhack },
+  { "focus-stack",      gb_workbench_actions_focus_stack, "i" },
   { "global-search",    gb_workbench_actions_global_search },
   { "new-document",     gb_workbench_actions_new_document },
   { "nighthack",        gb_workbench_actions_nighthack },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]