? gnome-terminal.schemas.in.MM
Index: gnome-terminal.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/gnome-terminal.schemas.in,v
retrieving revision 1.39
diff -u -p -r1.39 gnome-terminal.schemas.in
--- gnome-terminal.schemas.in	17 Aug 2004 14:41:35 -0000	1.39
+++ gnome-terminal.schemas.in	4 Mar 2005 15:03:23 -0000
@@ -111,7 +111,20 @@
       </locale>
     </schema>
  
-
+    <schema>
+      <key>/schemas/apps/gnome-terminal/global/wrap_tabs</key>
+      <applyto>/apps/gnome-terminal/global/wrap_tabs</applyto>
+      <owner>gnome-terminal</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>Whether to wrap movement around tabs.</short>
+         <long>
+	 Whether to move to first tab or stop when move right is used on the last tab and there are
+	 more than one open tab.
+         </long>
+      </locale>
+    </schema>
 
 
     <!-- Per-profile settings -->
Index: terminal-accels.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-accels.c,v
retrieving revision 1.29
diff -u -p -r1.29 terminal-accels.c
--- terminal-accels.c	26 Apr 2004 05:46:24 -0000	1.29
+++ terminal-accels.c	4 Mar 2005 15:03:24 -0000
@@ -43,6 +43,8 @@
 #define KEY_RESET_AND_CLEAR CONF_KEYS_PREFIX"/reset_and_clear"
 #define KEY_PREV_TAB CONF_KEYS_PREFIX"/prev_tab"
 #define KEY_NEXT_TAB CONF_KEYS_PREFIX"/next_tab"
+#define KEY_MOVE_TAB_LEFT CONF_KEYS_PREFIX"/move_tab_left"
+#define KEY_MOVE_TAB_RIGHT CONF_KEYS_PREFIX"/move_tab_right"
 #define KEY_SET_TERMINAL_TITLE CONF_KEYS_PREFIX"/set_window_title"
 #define PREFIX_KEY_SWITCH_TO_TAB CONF_KEYS_PREFIX"/switch_to_tab_"
 #define KEY_HELP CONF_KEYS_PREFIX"/help"
@@ -122,6 +124,10 @@ static KeyEntry go_entries[] =
     KEY_PREV_TAB, ACCEL_PATH_PREV_TAB, 0, 0, NULL, FALSE },
   { N_("Switch to Next Tab"),
     KEY_NEXT_TAB, ACCEL_PATH_NEXT_TAB, 0, 0, NULL, FALSE },
+  { N_("Move Tab Left"),
+    KEY_MOVE_TAB_LEFT, ACCEL_PATH_MOVE_TAB_LEFT, 0, 0, NULL, FALSE },
+  { N_("Move Tab Right"),
+    KEY_MOVE_TAB_RIGHT, ACCEL_PATH_MOVE_TAB_RIGHT, 0, 0, NULL, FALSE },
   { N_("Switch to Tab 1"),
     PREFIX_KEY_SWITCH_TO_TAB"1",
     PREFIX_ACCEL_PATH_SWITCH_TO_TAB"1", 0, 0, NULL, FALSE },
Index: terminal-accels.h
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-accels.h,v
retrieving revision 1.9
diff -u -p -r1.9 terminal-accels.h
--- terminal-accels.h	4 Oct 2002 22:29:01 -0000	1.9
+++ terminal-accels.h	4 Mar 2005 15:03:24 -0000
@@ -47,6 +47,8 @@ GtkAccelGroup* terminal_accels_get_group
 #define ACCEL_PATH_ZOOM_IN ACCEL_PATH_ROOT"/zoom_in"
 #define ACCEL_PATH_ZOOM_OUT ACCEL_PATH_ROOT"/zoom_out"
 #define ACCEL_PATH_ZOOM_NORMAL ACCEL_PATH_ROOT"/zoom_normal"
+#define ACCEL_PATH_MOVE_TAB_LEFT ACCEL_PATH_ROOT"/move_tab_left"
+#define ACCEL_PATH_MOVE_TAB_RIGHT ACCEL_PATH_ROOT"/move_tab_right"
 
 #define FORMAT_ACCEL_PATH_SWITCH_TO_TAB ACCEL_PATH_ROOT"/switch_to_tab_%d"
 #define PREFIX_ACCEL_PATH_SWITCH_TO_TAB ACCEL_PATH_ROOT"/switch_to_tab_"
Index: terminal-window.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-window.c,v
retrieving revision 1.106
diff -u -p -r1.106 terminal-window.c
--- terminal-window.c	28 Feb 2005 23:27:11 -0000	1.106
+++ terminal-window.c	4 Mar 2005 15:03:27 -0000
@@ -59,6 +59,8 @@ struct _TerminalWindowPrivate
   GtkWidget *choose_config_menuitem;
   GtkWidget *next_tab_menuitem;
   GtkWidget *previous_tab_menuitem;
+  GtkWidget *moveleft_tab_menuitem;
+  GtkWidget *moveright_tab_menuitem;
   GtkWidget *go_menu;
   GtkWidget *encoding_menuitem;
   GList *tab_menuitems;
@@ -76,6 +78,7 @@ struct _TerminalWindowPrivate
   guint use_default_menubar_visibility : 1;
   guint use_mnemonics : 1;   /* config key value */
   guint using_mnemonics : 1; /* current menubar state */
+  guint wrap_tabs : 1;
 
   /* FIXME we brokenly maintain this flag here instead of
    * being event-driven, because it's too annoying to be
@@ -184,6 +187,10 @@ static void next_tab_callback           
                                            TerminalWindow *window);
 static void previous_tab_callback         (GtkWidget      *menuitem,
                                            TerminalWindow *window);
+static void moveleft_tab_callback         (GtkWidget      *menuitem,
+                                           TerminalWindow *window);
+static void moveright_tab_callback         (GtkWidget      *menuitem,
+                                           TerminalWindow *window);
 static void change_tab_callback           (GtkWidget      *menuitem,
                                            TerminalWindow *window);
 static void help_callback                 (GtkWidget      *menuitem,
@@ -1018,6 +1025,14 @@ terminal_window_init (TerminalWindow *wi
                         G_CALLBACK (next_tab_callback), window);
   window->priv->next_tab_menuitem = mi;
 
+  mi = append_menuitem (menu, _("Move Tab _Left"), ACCEL_PATH_MOVE_TAB_LEFT,
+                        G_CALLBACK (moveleft_tab_callback), window);
+  window->priv->moveleft_tab_menuitem = mi;
+  
+  mi = append_menuitem (menu, _("Move Tab _Right"), ACCEL_PATH_MOVE_TAB_RIGHT,
+                        G_CALLBACK (moveright_tab_callback), window);
+  window->priv->moveright_tab_menuitem = mi;
+
   mi = gtk_separator_menu_item_new ();
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
   
@@ -1218,7 +1233,7 @@ terminal_window_new (GConfClient *conf)
 {
   TerminalWindow *window;
   GError *err;
-  gboolean use_mnemonics;
+  gboolean use_mnemonics, wrap_tabs;
   
   window = g_object_new (TERMINAL_TYPE_WINDOW, NULL);
   g_signal_connect (G_OBJECT (window), "realize", G_CALLBACK (terminal_window_realized_callback), NULL);
@@ -1242,6 +1257,21 @@ terminal_window_new (GConfClient *conf)
     }
   
   err = NULL;
+  wrap_tabs = gconf_client_get_bool (window->priv->conf,
+                                         CONF_GLOBAL_PREFIX"/wrap_tabs",
+                                         &err);
+  if (err)
+    {
+      g_printerr (_("There was an error loading config value for whether to wrap tabs. (%s)\n"),
+                  err->message);
+      g_error_free (err);
+    }
+  else
+    {
+      window->priv->wrap_tabs = wrap_tabs;
+    }
+
+  err = NULL;
   window->priv->notify_id =
     gconf_client_notify_add (window->priv->conf,
                              CONF_GLOBAL_PREFIX,
@@ -1335,30 +1365,40 @@ static void
 update_tab_sensitivity (TerminalWindow *window)
 {
   int page_num;
+  gint last_page;
   GtkWidget *notebook;
   gboolean on_last_page;
 
   notebook = window->priv->notebook;
+  last_page = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) - 1;
   page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-  
-  gtk_widget_set_sensitive (window->priv->previous_tab_menuitem,
-                            page_num > 0);
+  on_last_page = last_page == page_num;
 
-
-  /* FIXME
-   * http://bugzilla.gnome.org/show_bug.cgi?id=73229
-   */
-  on_last_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
-                                            page_num + 1) == NULL;
+  /* If this is the last or first tab set corresponding menut items insensitiv */
+  if (! window->priv->wrap_tabs)
+  {
+    gtk_widget_set_sensitive (window->priv->previous_tab_menuitem,
+                              page_num > 0);
+    gtk_widget_set_sensitive (window->priv->moveleft_tab_menuitem,
+                              page_num > 0);
+    gtk_widget_set_sensitive (window->priv->next_tab_menuitem,
+                            !on_last_page);
+    gtk_widget_set_sensitive (window->priv->moveright_tab_menuitem,
+                            !on_last_page);
+  }
 
   /* If there's only one tab, Close Tab is insensitive */
-  if (page_num == 0 && on_last_page)
+  if (last_page == 0) 
+  {
     gtk_widget_set_sensitive (window->priv->close_tab_menuitem, FALSE);
+    //gtk_widget_set_sensitive (window->priv->go_menuitem, FALSE);
+  }
   else
+  {
     gtk_widget_set_sensitive (window->priv->close_tab_menuitem, TRUE);
-  
-  gtk_widget_set_sensitive (window->priv->next_tab_menuitem,
-                            !on_last_page);
+    //gtk_widget_set_sensitive (window->priv->go_menuitem, TRUE);
+  }
+
 }
 
 static void
@@ -2678,14 +2718,86 @@ static void
 next_tab_callback(GtkWidget      *menuitem,
                   TerminalWindow *window)
 {
-  gtk_notebook_next_page (GTK_NOTEBOOK (window->priv->notebook));
+  GtkNotebook *notebook;
+  gint page_num,last_page;
+
+  notebook = GTK_NOTEBOOK (window->priv->notebook);
+  last_page = gtk_notebook_get_n_pages (notebook) - 1;
+  page_num = gtk_notebook_get_current_page (notebook);
+
+  if (page_num == last_page && window->priv->wrap_tabs)
+    gtk_notebook_set_current_page(notebook, 0);
+  else
+    gtk_notebook_next_page (notebook);
 }
 
 static void
 previous_tab_callback (GtkWidget      *menuitem,
                        TerminalWindow *window)
 {
-  gtk_notebook_prev_page (GTK_NOTEBOOK (window->priv->notebook));
+  GtkNotebook *notebook;
+  gint page_num,last_page;
+
+  notebook = GTK_NOTEBOOK (window->priv->notebook);
+  last_page = gtk_notebook_get_n_pages (notebook) - 1;
+  page_num = gtk_notebook_get_current_page (notebook);
+
+  if (page_num == 0 && window->priv->wrap_tabs)
+    gtk_notebook_set_current_page(notebook, last_page);
+  else
+    gtk_notebook_prev_page (notebook);
+}
+
+static void
+moveleft_tab_callback(GtkWidget      *menuitem,
+            	      TerminalWindow *window)
+{
+  GtkNotebook *notebook;
+  gint page_num,last_page;
+  GtkWidget *page; 
+
+  notebook = GTK_NOTEBOOK (window->priv->notebook);
+  page_num = gtk_notebook_get_current_page(notebook);
+  last_page = gtk_notebook_get_n_pages (notebook) - 1;
+  page = gtk_notebook_get_nth_page(notebook, page_num);
+  
+  if (page_num == 0 && window->priv->wrap_tabs)
+    gtk_notebook_reorder_child(notebook, 
+            page,
+            last_page);
+  else
+    gtk_notebook_reorder_child(notebook, 
+            page,
+            page_num-1);
+
+  update_tab_sensitivity (window);
+  reset_tab_menuitems (window);
+}
+
+static void
+moveright_tab_callback(GtkWidget      *menuitem,
+            	       TerminalWindow *window)
+{
+  GtkNotebook *notebook;
+  gint page_num,last_page;
+  GtkWidget *page; 
+
+  notebook = GTK_NOTEBOOK (window->priv->notebook);
+  page_num = gtk_notebook_get_current_page(notebook);
+  last_page = gtk_notebook_get_n_pages (notebook) - 1;
+  page = gtk_notebook_get_nth_page(notebook, page_num);
+
+  if (page_num == last_page && window->priv->wrap_tabs)
+    gtk_notebook_reorder_child(notebook,
+            page,
+            0);
+  else
+    gtk_notebook_reorder_child(notebook,
+            page,
+            page_num+1);
+
+  update_tab_sensitivity (window);
+  reset_tab_menuitems (window);
 }
 
 static void
