[gnome-builder/wip/libide-merge] cycle through "tabs" with ctrl+pgup/down
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] cycle through "tabs" with ctrl+pgup/down
- Date: Thu, 19 Mar 2015 21:52:15 +0000 (UTC)
commit 527c8d23f73adf89a1cc5d799eea55ba0904988f
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 14:52:10 2015 -0700
cycle through "tabs" with ctrl+pgup/down
data/keybindings/default.css | 6 +++
data/keybindings/emacs.css | 12 ++++--
data/keybindings/vim.css | 6 +++
src/views/gb-view-stack-actions.c | 84 +++++++++++++++++++++++++++++++++----
src/views/gb-view-stack.c | 3 +-
5 files changed, 98 insertions(+), 13 deletions(-)
---
diff --git a/data/keybindings/default.css b/data/keybindings/default.css
index 790650c..baaf257 100644
--- a/data/keybindings/default.css
+++ b/data/keybindings/default.css
@@ -7,6 +7,12 @@
bind "<ctrl>s" { "action" ("view", "save", "") };
bind "<alt><shift>Left" { "action" ("navigation", "go-backward", "") };
bind "<alt><shift>Right" { "action" ("navigation", "go-forward", "") };
+
+ /* cycle "tabs" */
+ bind "<ctrl>Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl>KP_Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl>Page_Down" { "action" ("view-stack", "next-view", "") };
+ bind "<ctrl>KP_Page_Down" { "action" ("view-stack", "next-view", "") };
}
IdeSourceViewMode.default {
diff --git a/data/keybindings/emacs.css b/data/keybindings/emacs.css
index 6706649..fcde682 100644
--- a/data/keybindings/emacs.css
+++ b/data/keybindings/emacs.css
@@ -54,10 +54,14 @@
bind "<ctrl>comma" { "action" ("app", "preferences", "") };
bind "<alt>n" { "move-error" (down) };
bind "<alt>p" { "move-error" (up) };
- bind "<ctrl>j" { "action" ("editor-view", "switch-pane", "") };
- bind "<shift><ctrl>j" { "action" ("editor-view", "toggle-split", "") };
- bind "<ctrl><alt>Page_Up" { "action" ("stack", "previous-document", "") };
- bind "<ctrl><alt>Page_Down" { "action" ("stack", "next-document", "") };
+ bind "<ctrl>j" { "action" ("view-grid", "focus-neighbor", "3") };
+ bind "<shift><ctrl>j" { "action" ("view-stack", "split-down", "") };
+
+ /* cycle "tabs" */
+ bind "<ctrl><alt>Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl><alt>KP_Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl><alt>Page_Down" { "action" ("view-stack", "next-view", "") };
+ bind "<ctrl><alt>KP_Page_Down" { "action" ("view-stack", "next-view", "") };
bind "<alt>0" { "append-to-count" (0) };
bind "<alt>1" { "append-to-count" (1) };
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index ebc58ae..d6307c0 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -125,6 +125,12 @@
bind "colon" { "action" ("workbench", "show-command-bar", "") };
+ /* cycle "tabs" */
+ bind "<ctrl>Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl>KP_Page_Up" { "action" ("view-stack", "previous-view", "") };
+ bind "<ctrl>Page_Down" { "action" ("view-stack", "next-view", "") };
+ bind "<ctrl>KP_Page_Down" { "action" ("view-stack", "next-view", "") };
+
/* replay the last recording */
bind "period" { "replay-macro" (1) };
diff --git a/src/views/gb-view-stack-actions.c b/src/views/gb-view-stack-actions.c
index 57d4d85..1cf5a1c 100644
--- a/src/views/gb-view-stack-actions.c
+++ b/src/views/gb-view-stack-actions.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "gb-view-stack"
+#include <ide.h>
+
#include "gb-view.h"
#include "gb-view-grid.h"
#include "gb-view-stack.h"
@@ -186,15 +188,81 @@ gb_view_stack_actions_split_right (GSimpleAction *action,
g_signal_emit_by_name (self, "split", active_view, GB_VIEW_GRID_SPLIT_RIGHT);
}
+static void
+gb_view_stack_actions_next_view (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbViewStack *self = user_data;
+ GtkWidget *active_view;
+ GtkWidget *new_view;
+
+ IDE_ENTRY;
+
+ g_assert (GB_IS_VIEW_STACK (self));
+
+ active_view = gb_view_stack_get_active_view (self);
+ if (active_view == NULL || !GB_IS_VIEW (active_view))
+ return;
+
+ if (g_list_length (self->focus_history) <= 1)
+ return;
+
+ new_view = g_list_last (self->focus_history)->data;
+ g_assert (GB_IS_VIEW (new_view));
+
+ gb_view_stack_set_active_view (self, new_view);
+
+ IDE_EXIT;
+}
+
+static void
+gb_view_stack_actions_previous_view (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbViewStack *self = user_data;
+ GtkWidget *active_view;
+ GtkWidget *new_view;
+
+ IDE_ENTRY;
+
+ g_assert (GB_IS_VIEW_STACK (self));
+
+ active_view = gb_view_stack_get_active_view (self);
+ if (active_view == NULL || !GB_IS_VIEW (active_view))
+ return;
+
+ if (g_list_length (self->focus_history) <= 1)
+ return;
+
+ g_assert (active_view);
+ g_assert (self->focus_history);
+ g_assert (self->focus_history->next);
+ g_assert (active_view == self->focus_history->data);
+
+ new_view = self->focus_history->next->data;
+ g_assert (GB_IS_VIEW (new_view));
+
+ self->focus_history = g_list_remove_link (self->focus_history, self->focus_history);
+ self->focus_history = g_list_append (self->focus_history, active_view);
+
+ gb_view_stack_set_active_view (self, new_view);
+
+ IDE_EXIT;
+}
+
static const GActionEntry gGbViewStackActions[] = {
- { "close", gb_view_stack_actions_close },
- { "move-left", gb_view_stack_actions_move_left },
- { "move-right", gb_view_stack_actions_move_right },
- { "save", gb_view_stack_actions_save },
- { "save-as", gb_view_stack_actions_save_as },
- { "split-down", NULL, NULL, "false", gb_view_stack_actions_split_down },
- { "split-left", gb_view_stack_actions_split_left },
- { "split-right", gb_view_stack_actions_split_right },
+ { "close", gb_view_stack_actions_close },
+ { "move-left", gb_view_stack_actions_move_left },
+ { "move-right", gb_view_stack_actions_move_right },
+ { "next-view", gb_view_stack_actions_next_view },
+ { "previous-view", gb_view_stack_actions_previous_view},
+ { "save", gb_view_stack_actions_save },
+ { "save-as", gb_view_stack_actions_save_as },
+ { "split-down", NULL, NULL, "false", gb_view_stack_actions_split_down },
+ { "split-left", gb_view_stack_actions_split_left },
+ { "split-right", gb_view_stack_actions_split_right },
};
void
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index dd7f3a6..84ef9b4 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -281,7 +281,6 @@ gb_view_stack_set_active_view (GbViewStack *self,
{
if (self->active_view)
{
- self->focus_history = g_list_remove (self->focus_history, self->active_view);
if (self->title_binding)
g_binding_unbind (self->title_binding);
ide_clear_weak_pointer (&self->title_binding);
@@ -296,7 +295,9 @@ gb_view_stack_set_active_view (GbViewStack *self,
GBinding *binding;
GActionGroup *group;
+ self->focus_history = g_list_remove (self->focus_history, active_view);
self->focus_history = g_list_prepend (self->focus_history, active_view);
+
if (active_view != gtk_stack_get_visible_child (self->stack))
gtk_stack_set_visible_child (self->stack, active_view);
binding = g_object_bind_property (active_view, "title",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]