[epiphany] Allow wrap around during tab move



commit 52399be9227016babe2a425fdd62a370d0c4298f
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Thu Dec 27 00:50:06 2018 +0100

    Allow wrap around during tab move
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/399

 src/window-commands.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index a725d9863..acda6cb5f 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2251,15 +2251,22 @@ window_cmd_tabs_move_left (GSimpleAction *action,
 {
   GtkWidget *child;
   GtkNotebook *notebook;
-  int page;
+  int page, n_pages, to;
 
   notebook = GTK_NOTEBOOK (ephy_window_get_notebook (EPHY_WINDOW (user_data)));
   page = gtk_notebook_get_current_page (notebook);
-  if (page < 1)
+  n_pages = gtk_notebook_get_n_pages (notebook) - 1;
+
+  if (!n_pages)
     return;
 
+  if (page < 1)
+    to = n_pages;
+  else
+    to = page - 1;
+
   child = gtk_notebook_get_nth_page (notebook, page);
-  gtk_notebook_reorder_child (notebook, child, page - 1);
+  gtk_notebook_reorder_child (notebook, child, to);
 }
 
 void window_cmd_tabs_move_right (GSimpleAction *action,
@@ -2268,16 +2275,22 @@ void window_cmd_tabs_move_right (GSimpleAction *action,
 {
   GtkWidget *child;
   GtkNotebook *notebook;
-  int page, n_pages;
+  int page, n_pages, to;
 
   notebook = GTK_NOTEBOOK (ephy_window_get_notebook (EPHY_WINDOW (user_data)));
   page = gtk_notebook_get_current_page (notebook);
   n_pages = gtk_notebook_get_n_pages (notebook) - 1;
-  if (page > n_pages - 1)
+
+  if (!n_pages)
     return;
 
+  if (page > n_pages - 1)
+    to = 0;
+  else
+    to = page + 1;
+
   child = gtk_notebook_get_nth_page (notebook, page);
-  gtk_notebook_reorder_child (notebook, child, page + 1);
+  gtk_notebook_reorder_child (notebook, child, to);
 }
 
 void


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