Added keyboard shortcuts for switching between tabs solely within a view
This commit is contained in:
parent
f0cb8e370d
commit
5291fed278
@ -45,6 +45,8 @@
|
||||
#define MOO_EDIT_ACCEL_SWITCH_TO_TAB "<Alt>"
|
||||
#define MOO_EDIT_ACCEL_PREV_TAB "<Alt>Left"
|
||||
#define MOO_EDIT_ACCEL_NEXT_TAB "<Alt>Right"
|
||||
#define MOO_EDIT_ACCEL_PREV_TAB_IN_VIEW "<Alt>O"
|
||||
#define MOO_EDIT_ACCEL_NEXT_TAB_IN_VIEW "<Alt>P"
|
||||
|
||||
#else /* GDK_WINDOWING_QUARTZ */
|
||||
|
||||
@ -60,6 +62,8 @@
|
||||
#define MOO_EDIT_ACCEL_SWITCH_TO_TAB "<Meta>"
|
||||
#define MOO_EDIT_ACCEL_PREV_TAB "<Meta>Left"
|
||||
#define MOO_EDIT_ACCEL_NEXT_TAB "<Meta>Right"
|
||||
#define MOO_EDIT_ACCEL_PREV_TAB_IN_VIEW "<Meta>O"
|
||||
#define MOO_EDIT_ACCEL_NEXT_TAB_IN_VIEW "<Meta>P"
|
||||
|
||||
#endif /* GDK_WINDOWING_QUARTZ */
|
||||
|
||||
|
@ -263,6 +263,8 @@ static void action_close_tab (MooEditWindow *window);
|
||||
static void action_close_all (MooEditWindow *window);
|
||||
static void action_previous_tab (MooEditWindow *window);
|
||||
static void action_next_tab (MooEditWindow *window);
|
||||
static void action_previous_tab_in_view (MooEditWindow *window);
|
||||
static void action_next_tab_in_view (MooEditWindow *window);
|
||||
static void action_switch_to_tab (MooEditWindow *window,
|
||||
guint n);
|
||||
|
||||
@ -514,6 +516,24 @@ moo_edit_window_class_init (MooEditWindowClass *klass)
|
||||
"condition::sensitive", "has-open-document",
|
||||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "PreviousTabInView", NULL,
|
||||
"display-name", _("Previous Tab In View"),
|
||||
"label", _("_Previous Tab In View"),
|
||||
"tooltip", _("Previous tab in view"),
|
||||
"default-accel", MOO_EDIT_ACCEL_PREV_TAB_IN_VIEW,
|
||||
"closure-callback", action_previous_tab_in_view,
|
||||
"condition::sensitive", "has-open-document",
|
||||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "NextTabInView", NULL,
|
||||
"display-name", _("Next Tab In View"),
|
||||
"label", _("_Next Tab In View"),
|
||||
"tooltip", _("Next tab in view"),
|
||||
"default-accel", MOO_EDIT_ACCEL_NEXT_TAB_IN_VIEW,
|
||||
"closure-callback", action_next_tab_in_view,
|
||||
"condition::sensitive", "has-open-document",
|
||||
NULL);
|
||||
|
||||
moo_window_class_new_action (window_class, "Find", NULL,
|
||||
"display-name", GTK_STOCK_FIND,
|
||||
"label", GTK_STOCK_FIND,
|
||||
@ -1546,6 +1566,60 @@ action_next_tab (MooEditWindow *window)
|
||||
switch_to_tab (window, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
get_first_tab_in_notebook (MooNotebook *notebook, MooEditWindow *window)
|
||||
{
|
||||
int tab = 0;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < window->priv->notebooks->n_elms; ++i)
|
||||
{
|
||||
if (window->priv->notebooks->elms[i] == notebook)
|
||||
return tab;
|
||||
|
||||
tab += moo_notebook_get_n_pages (window->priv->notebooks->elms[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
action_previous_tab_in_view (MooEditWindow *window)
|
||||
{
|
||||
int n, tabs_in_notebook, first_tab;
|
||||
MooNotebook *notebook;
|
||||
|
||||
printf("prev in view..\n");
|
||||
|
||||
n = get_active_tab (window);
|
||||
notebook = get_active_notebook (window);
|
||||
tabs_in_notebook = moo_notebook_get_n_pages (notebook);
|
||||
first_tab = get_first_tab_in_notebook (notebook, window);
|
||||
|
||||
|
||||
if (n > first_tab)
|
||||
switch_to_tab (window, n - 1);
|
||||
else
|
||||
switch_to_tab (window, first_tab + tabs_in_notebook - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
action_next_tab_in_view (MooEditWindow *window)
|
||||
{
|
||||
int n, tabs_in_notebook, first_tab;
|
||||
MooNotebook *notebook;
|
||||
|
||||
printf("next in view..\n");
|
||||
n = get_active_tab (window);
|
||||
notebook = get_active_notebook (window);
|
||||
tabs_in_notebook = moo_notebook_get_n_pages (notebook);
|
||||
first_tab = get_first_tab_in_notebook (notebook, window);
|
||||
|
||||
if (n < (first_tab + tabs_in_notebook - 1))
|
||||
switch_to_tab (window, n + 1);
|
||||
else
|
||||
switch_to_tab (window, first_tab);
|
||||
}
|
||||
|
||||
static void
|
||||
action_switch_to_tab (MooEditWindow *window,
|
||||
|
Loading…
x
Reference in New Issue
Block a user