From 6e45bec38cc6696c2cc789403082368fcdbcd68f Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Mon, 16 Apr 2012 14:03:19 +0200 Subject: window-commands: switch pages using the EphyNotebook API The signal we were using does not work when the tabs bar is hidden, and we'll want the shortcuts to work in that state. Add new EphyNotebooks methods that do the right thing and use them. --- src/ephy-notebook.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'src/ephy-notebook.c') diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index 22465ad43..5614ca707 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -396,7 +396,6 @@ static void update_tabs_visibility (EphyNotebook *nb, gboolean before_inserting) { - EphyNotebookPrivate *priv = nb->priv; EphyEmbedShellMode mode; gboolean show_tabs; guint num; @@ -777,3 +776,66 @@ ephy_notebook_remove (GtkContainer *container, update_tabs_visibility (notebook, FALSE); } + +/** + * ephy_notebook_next_page: + * @notebook: an #EphyNotebook + * + * Advances to the next page in the @notebook. Note that unlike + * gtk_notebook_next_page() this method will wrap around if + * #GtkSettings:gtk-keynav-wrap-around is set. + **/ +void +ephy_notebook_next_page (EphyNotebook *notebook) +{ + gint current_page, n_pages; + + g_return_if_fail (EPHY_IS_NOTEBOOK (notebook)); + + current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); + + if (current_page < n_pages - 1) + gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); + else { + gboolean wrap_around; + + g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)), + "gtk-keynav-wrap-around", &wrap_around, + NULL); + + if (wrap_around) + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); + } +} + +/** + * ephy_notebook_prev_page: + * @notebook: an #EphyNotebook + * + * Advances to the previous page in the @notebook. Note that unlike + * gtk_notebook_next_page() this method will wrap around if + * #GtkSettings:gtk-keynav-wrap-around is set. + **/ +void +ephy_notebook_prev_page (EphyNotebook *notebook) +{ + gint current_page; + + g_return_if_fail (EPHY_IS_NOTEBOOK (notebook)); + + current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + + if (current_page > 0) + gtk_notebook_prev_page (GTK_NOTEBOOK (notebook)); + else { + gboolean wrap_around; + + g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)), + "gtk-keynav-wrap-around", &wrap_around, + NULL); + + if (wrap_around) + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1); + } +} -- cgit v1.2.3