Commit 8870bb39 authored by Christian Hergert's avatar Christian Hergert
Browse files

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.
parent 63abd3a5
......@@ -685,6 +685,102 @@ gb_document_stack_focus_search (GSimpleAction *action,
gb_document_menu_button_focus_search (stack->priv->document_button);
}
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)
{
......@@ -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);
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment