[gnome-builder] stack: <Control><Alt>Page_Up and Page_Down to quickly move documents
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] stack: <Control><Alt>Page_Up and Page_Down to quickly move documents
- Date: Mon, 22 Dec 2014 22:15:37 +0000 (UTC)
commit 8870bb39badab36ee79479c331932a79307d85ca
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 22 14:15:31 2014 -0800
stack: <Control><Alt>Page_Up and Page_Down to quickly move documents
This still isn't my preferred way to navigate, but no reason we shouldn't
at least have it in here. We probably should add some context to what
constitutes "previous" and "next" document though.
Right now, that context is widget packing dependent.
src/documents/gb-document-stack.c | 98 +++++++++++++++++++++++++++++++++
src/resources/keybindings/default.ini | 2 +
2 files changed, 100 insertions(+), 0 deletions(-)
---
diff --git a/src/documents/gb-document-stack.c b/src/documents/gb-document-stack.c
index 70892c5..b510cad 100644
--- a/src/documents/gb-document-stack.c
+++ b/src/documents/gb-document-stack.c
@@ -686,6 +686,102 @@ gb_document_stack_focus_search (GSimpleAction *action,
}
static void
+gb_document_stack_previous_document_activate (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GbDocumentStack *stack = user_data;
+ GtkWidget *child;
+ GList *children;
+ GList *iter;
+ gint position = -1;
+
+ g_return_if_fail (GB_IS_DOCUMENT_STACK (stack));
+
+ child = gtk_stack_get_visible_child (stack->priv->stack);
+ if (!child)
+ return;
+
+ gtk_container_child_get (GTK_CONTAINER (stack->priv->stack), child,
+ "position", &position,
+ NULL);
+ if (position <= 0)
+ return;
+
+ position--;
+
+ children = gtk_container_get_children (GTK_CONTAINER (stack->priv->stack));
+
+ for (iter = children; iter; iter = iter->next)
+ {
+ gint child_pos = -1;
+
+ gtk_container_child_get (GTK_CONTAINER (stack->priv->stack), iter->data,
+ "position", &child_pos,
+ NULL);
+
+ if (child_pos == position)
+ {
+ GbDocument *document;
+
+ document = gb_document_view_get_document (iter->data);
+ gb_document_menu_button_select_document (stack->priv->document_button,
+ document);
+ break;
+ }
+ }
+
+ g_list_free (children);
+}
+
+static void
+gb_document_stack_next_document_activate (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GbDocumentStack *stack = user_data;
+ GtkWidget *child;
+ GList *children;
+ GList *iter;
+ gint position = -1;
+
+ g_return_if_fail (GB_IS_DOCUMENT_STACK (stack));
+
+ child = gtk_stack_get_visible_child (stack->priv->stack);
+ if (!child)
+ return;
+
+ gtk_container_child_get (GTK_CONTAINER (stack->priv->stack), child,
+ "position", &position,
+ NULL);
+
+ position++;
+
+ children = gtk_container_get_children (GTK_CONTAINER (stack->priv->stack));
+
+ for (iter = children; iter; iter = iter->next)
+ {
+ gint child_pos = -1;
+
+ gtk_container_child_get (GTK_CONTAINER (stack->priv->stack), iter->data,
+ "position", &child_pos,
+ NULL);
+
+ if (child_pos == position)
+ {
+ GbDocument *document;
+
+ document = gb_document_view_get_document (iter->data);
+ gb_document_menu_button_select_document (stack->priv->document_button,
+ document);
+ break;
+ }
+ }
+
+ g_list_free (children);
+}
+
+static void
gb_document_stack_finalize (GObject *object)
{
GbDocumentStackPrivate *priv = GB_DOCUMENT_STACK (object)->priv;
@@ -848,6 +944,8 @@ gb_document_stack_init (GbDocumentStack *self)
{ "preview", gb_document_stack_preview_activate },
{ "save", gb_document_stack_save_activate },
{ "save-as", gb_document_stack_save_as_activate },
+ { "previous-document", gb_document_stack_previous_document_activate },
+ { "next-document", gb_document_stack_next_document_activate },
};
self->priv = gb_document_stack_get_instance_private (self);
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index 27f39da..8740a40 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -35,3 +35,5 @@ split-document-right = <Control><Alt>L
save = <Control>S
save-as = <Control><Shift>S
preview = <Control><Alt>P
+previous-document = <Control><Alt>Page_Up
+next-document = <Control><Alt>Page_Down
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]