diff options
-rw-r--r-- | src/nautilus-notebook.c | 67 | ||||
-rw-r--r-- | src/nautilus-notebook.h | 8 | ||||
-rw-r--r-- | src/nautilus-window-menus.c | 4 |
3 files changed, 47 insertions, 32 deletions
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c index 6d418601a..90f00ef6c 100644 --- a/src/nautilus-notebook.c +++ b/src/nautilus-notebook.c @@ -475,26 +475,6 @@ nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook, gtk_notebook_reorder_child (gnotebook, child, page + offset); } -void -nautilus_notebook_set_current_page_relative (NautilusNotebook *notebook, - int offset) -{ - GtkNotebook *gnotebook; - int page; - - g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); - - if (!nautilus_notebook_can_set_current_page_relative (notebook, offset)) { - return; - } - - gnotebook = GTK_NOTEBOOK (notebook); - - page = gtk_notebook_get_current_page (gnotebook); - gtk_notebook_set_current_page (gnotebook, page + offset); - -} - static gboolean nautilus_notebook_is_valid_relative_position (NautilusNotebook *notebook, int offset) @@ -525,12 +505,49 @@ nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook return nautilus_notebook_is_valid_relative_position (notebook, offset); } -gboolean -nautilus_notebook_can_set_current_page_relative (NautilusNotebook *notebook, - int offset) +void +nautilus_notebook_next_page (NautilusNotebook *notebook) { - g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), FALSE); + gint current_page, n_pages; - return nautilus_notebook_is_valid_relative_position (notebook, offset); + g_return_if_fail (NAUTILUS_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); + } } +void +nautilus_notebook_prev_page (NautilusNotebook *notebook) +{ + gint current_page; + + g_return_if_fail (NAUTILUS_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/nautilus-notebook.h b/src/nautilus-notebook.h index ecfce3f8e..7dd145a16 100644 --- a/src/nautilus-notebook.h +++ b/src/nautilus-notebook.h @@ -75,13 +75,11 @@ void nautilus_notebook_sync_loading (NautilusNotebook *nb, void nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook, int offset); -void nautilus_notebook_set_current_page_relative (NautilusNotebook *notebook, - int offset); - gboolean nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook, int offset); -gboolean nautilus_notebook_can_set_current_page_relative (NautilusNotebook *notebook, - int offset); +void nautilus_notebook_prev_page (NautilusNotebook *notebook); +void nautilus_notebook_next_page (NautilusNotebook *notebook); + G_END_DECLS diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index 4eb0e7fce..d6cb25db0 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -372,7 +372,7 @@ action_tabs_previous_callback (GtkAction *action, { NautilusWindow *window = user_data; - nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->details->notebook), -1); + nautilus_notebook_prev_page (NAUTILUS_NOTEBOOK (window->details->notebook)); } static void @@ -381,7 +381,7 @@ action_tabs_next_callback (GtkAction *action, { NautilusWindow *window = user_data; - nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->details->notebook), 1); + nautilus_notebook_next_page (NAUTILUS_NOTEBOOK (window->details->notebook)); } static void |