[epiphany/gnome-3-0] Respect gtk-keynav-wrap-around in the global change-page handler



commit ec7104e2821377433837f229f77083e77407f4a9
Author: Xan Lopez <xlopez igalia com>
Date:   Mon Jun 27 21:48:44 2011 +0200

    Respect gtk-keynav-wrap-around in the global change-page handler
    
    We have a global-handler for Ctrl+Page{Up,Down} that is used in some
    situations (basically, when the notebook is not focused). It does not
    respect the wrap-around GtkSetting though, so the final experience can
    be inconsistent.

 src/ephy-window.c     |   39 +++++++++++++++++++++++++--------------
 src/window-commands.c |   20 ++++----------------
 2 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index da534b5..023a97b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2756,24 +2756,35 @@ update_tabs_menu_sensitivity (EphyWindow *window)
 	GtkActionGroup *action_group;
 	GtkAction *action;
 	GtkNotebook *notebook;
-	int page, n_pages;
-	gboolean not_first, not_last;
+	gboolean wrap_around;
+	int n_pages;
 
 	notebook = GTK_NOTEBOOK (priv->notebook);
-	page = gtk_notebook_get_current_page (notebook);
+	action_group = priv->action_group;
 	n_pages = gtk_notebook_get_n_pages (notebook);
-	not_first = page > 0;
-	not_last = page + 1 < n_pages;
 
-	action_group = priv->action_group;
-	action = gtk_action_group_get_action (action_group, "TabsPrevious");
-	gtk_action_set_sensitive (action, not_first);
-	action = gtk_action_group_get_action (action_group, "TabsNext");
-	gtk_action_set_sensitive (action, not_last);
-	action = gtk_action_group_get_action (action_group, "TabsMoveLeft");
-	gtk_action_set_sensitive (action, not_first);
-	action = gtk_action_group_get_action (action_group, "TabsMoveRight");
-	gtk_action_set_sensitive (action, not_last);
+	g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
+		      "gtk-keynav-wrap-around", &wrap_around,
+		      NULL);
+
+	if (!wrap_around)
+	{
+		int page;
+		gboolean not_first, not_last;
+
+		page = gtk_notebook_get_current_page (notebook);
+		not_first = page > 0;
+		not_last = page + 1 < n_pages;
+
+		action = gtk_action_group_get_action (action_group, "TabsPrevious");
+		gtk_action_set_sensitive (action, not_first);
+		action = gtk_action_group_get_action (action_group, "TabsNext");
+		gtk_action_set_sensitive (action, not_last);
+		action = gtk_action_group_get_action (action_group, "TabsMoveLeft");
+		gtk_action_set_sensitive (action, not_first);
+		action = gtk_action_group_get_action (action_group, "TabsMoveRight");
+		gtk_action_set_sensitive (action, not_last);
+	}
 
 	action = gtk_action_group_get_action (action_group, "TabsDetach");
 	ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, n_pages <= 1);
diff --git a/src/window-commands.c b/src/window-commands.c
index 3e4fdee..810367b 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1073,18 +1073,12 @@ window_cmd_tabs_next (GtkAction *action,
 		      EphyWindow *window)
 {
 	GtkNotebook *nb;
-	gint page;
+	gboolean handled;
 
 	nb = GTK_NOTEBOOK (ephy_window_get_notebook (window));
 	g_return_if_fail (nb != NULL);
 
-	page = gtk_notebook_get_current_page (nb);
-	g_return_if_fail (page != -1);
-
-	if (page < gtk_notebook_get_n_pages (nb) - 1)
-	{
-		gtk_notebook_set_current_page (nb, page + 1);
-	}
+	g_signal_emit_by_name (nb, "change-current-page", 1, &handled);
 }
 
 void
@@ -1092,18 +1086,12 @@ window_cmd_tabs_previous (GtkAction *action,
 			  EphyWindow *window)
 {
 	GtkNotebook *nb;
-	gint page;
+	gboolean handled;
 
 	nb = GTK_NOTEBOOK (ephy_window_get_notebook (window));
 	g_return_if_fail (nb != NULL);
 
-	page = gtk_notebook_get_current_page (nb);
-	g_return_if_fail (page != -1);
-
-	if (page > 0)
-	{
-		gtk_notebook_set_current_page (nb, page - 1);
-	}
+	g_signal_emit_by_name (nb, "change-current-page", -1, &handled);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]