aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/ephy-notebook.c64
-rw-r--r--src/ephy-notebook.h4
-rw-r--r--src/window-commands.c14
3 files changed, 73 insertions, 9 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);
+ }
+}
diff --git a/src/ephy-notebook.h b/src/ephy-notebook.h
index 19e07ed8c..609b0f9a5 100644
--- a/src/ephy-notebook.h
+++ b/src/ephy-notebook.h
@@ -71,6 +71,10 @@ int ephy_notebook_add_tab (EphyNotebook *nb,
void ephy_notebook_set_show_tabs (EphyNotebook *nb,
gboolean show_tabs);
+void ephy_notebook_next_page (EphyNotebook *notebook);
+
+void ephy_notebook_prev_page (EphyNotebook *notebook);
+
G_END_DECLS
#endif /* EPHY_NOTEBOOK_H */
diff --git a/src/window-commands.c b/src/window-commands.c
index 1443e5d74..e32bd5be0 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1244,26 +1244,24 @@ void
window_cmd_tabs_next (GtkAction *action,
EphyWindow *window)
{
- GtkNotebook *nb;
- gboolean handled;
+ GtkWidget *nb;
- nb = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ nb = ephy_window_get_notebook (window);
g_return_if_fail (nb != NULL);
- g_signal_emit_by_name (nb, "change-current-page", 1, &handled);
+ ephy_notebook_next_page (EPHY_NOTEBOOK (nb));
}
void
window_cmd_tabs_previous (GtkAction *action,
EphyWindow *window)
{
- GtkNotebook *nb;
- gboolean handled;
+ GtkWidget *nb;
- nb = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ nb = ephy_window_get_notebook (window);
g_return_if_fail (nb != NULL);
- g_signal_emit_by_name (nb, "change-current-page", -1, &handled);
+ ephy_notebook_prev_page (EPHY_NOTEBOOK (nb));
}
void