[gnome-builder/wip/libide-merge: 23/35] focus movements
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge: 23/35] focus movements
- Date: Thu, 19 Mar 2015 08:56:29 +0000 (UTC)
commit 08bc493ac866eba4ab268359ed5352e0ff263ec5
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 18 23:52:24 2015 -0700
focus movements
data/keybindings/vim.css | 5 +++++
src/views/gb-view-grid.c | 24 ++++++++++++++++++++++++
src/views/gb-view-stack.c | 16 ++++++++++++++++
3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index 4f96c30..8ec911f 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -903,6 +903,11 @@
bind "<ctrl>c" { "action" ("view", "close", "") };
bind "s" { "action" ("view", "toggle-split", "") };
+
+ bind "l" { "action" ("view-grid", "focus-neighbor", "5") };
+ bind "h" { "action" ("view-grid", "focus-neighbor", "4") };
+ bind "j" { "action" ("view-grid", "focus-neighbor", "3") };
+ bind "k" { "action" ("view-grid", "focus-neighbor", "2") };
}
@binding-set builder-vim-source-view-visual-line-g
diff --git a/src/views/gb-view-grid.c b/src/views/gb-view-grid.c
index fc659d5..ff3204e 100644
--- a/src/views/gb-view-grid.c
+++ b/src/views/gb-view-grid.c
@@ -209,6 +209,22 @@ gb_view_grid_focus_neighbor (GbViewGrid *self,
}
static void
+gb_view_grid_focus_neighbor_action (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbViewGrid *self = user_data;
+ GtkDirectionType dir;
+
+ g_assert (GB_IS_VIEW_GRID (self));
+
+ dir = g_variant_get_int32 (param);
+
+ if (self->last_focus)
+ gb_view_grid_focus_neighbor (self, dir, self->last_focus);
+}
+
+static void
gb_view_grid_stack_empty (GbViewGrid *self,
GbViewStack *stack)
{
@@ -734,6 +750,10 @@ gb_view_grid_class_init (GbViewGridClass *klass)
static void
gb_view_grid_init (GbViewGrid *self)
{
+ g_autoptr(GSimpleActionGroup) actions = NULL;
+ static const GActionEntry entries[] = {
+ { "focus-neighbor", gb_view_grid_focus_neighbor_action, "i" },
+ };
GbViewStack *stack;
GtkPaned *paned;
@@ -746,6 +766,10 @@ gb_view_grid_init (GbViewGrid *self)
NULL);
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (paned));
+
+ actions = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), self);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "view-grid", G_ACTION_GROUP (actions));
}
GType
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 3e70b9d..dd7f3a6 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -118,6 +118,19 @@ gb_view_stack__notify_visible_child (GbViewStack *self,
}
static void
+gb_view_stack_grab_focus (GtkWidget *widget)
+{
+ GbViewStack *self = (GbViewStack *)widget;
+ GtkWidget *visible_child;
+
+ g_assert (GB_IS_VIEW_STACK (self));
+
+ visible_child = gtk_stack_get_visible_child (self->stack);
+ if (visible_child)
+ gtk_widget_grab_focus (visible_child);
+}
+
+static void
gb_view_stack_constructed (GObject *object)
{
GbViewStack *self = (GbViewStack *)object;
@@ -181,6 +194,7 @@ static void
gb_view_stack_class_init (GbViewStackClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->constructed = gb_view_stack_constructed;
@@ -188,6 +202,8 @@ gb_view_stack_class_init (GbViewStackClass *klass)
object_class->get_property = gb_view_stack_get_property;
object_class->set_property = gb_view_stack_set_property;
+ widget_class->grab_focus = gb_view_stack_grab_focus;
+
container_class->add = gb_view_stack_add;
container_class->remove = gb_view_stack_real_remove;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]