aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-notebook.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-04-16 20:03:19 +0800
committerXan Lopez <xan@igalia.com>2012-04-16 21:53:16 +0800
commit6e45bec38cc6696c2cc789403082368fcdbcd68f (patch)
tree2e7e6d90a530a6bf55e1827109a7e29c2514c97b /src/ephy-notebook.c
parent954fd17d06fe9453c355223d66207b23f359665b (diff)
downloadgsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar.gz
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar.bz2
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar.lz
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar.xz
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.tar.zst
gsoc2013-epiphany-6e45bec38cc6696c2cc789403082368fcdbcd68f.zip
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.
Diffstat (limited to 'src/ephy-notebook.c')
-rw-r--r--src/ephy-notebook.c64
1 files changed, 63 insertions, 1 deletions
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);
+ }
+}