Index: src/gnome-terminal.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/gnome-terminal.schemas.in,v
retrieving revision 1.43
diff -u -p -r1.43 gnome-terminal.schemas.in
--- src/gnome-terminal.schemas.in	5 Jan 2006 15:39:17 -0000	1.43
+++ src/gnome-terminal.schemas.in	9 Jan 2006 13:45:47 -0000
@@ -918,6 +918,21 @@
     </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 on the last tab. 
+     If enabled tabs will be navigated like a ring instead of a chain.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_1</key>
       <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_1</applyto>
       <owner>gnome-terminal</owner>
Index: src/terminal-window.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-window.c,v
retrieving revision 1.120
diff -u -p -r1.120 terminal-window.c
--- src/terminal-window.c	9 Jan 2006 02:16:31 -0000	1.120
+++ src/terminal-window.c	9 Jan 2006 13:45:48 -0000
@@ -79,6 +79,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;       /* use tabs as chain or ring */
 
   /* FIXME we brokenly maintain this flag here instead of
    * being event-driven, because it's too annoying to be
@@ -1243,6 +1244,7 @@ terminal_window_new (GConfClient *conf)
   TerminalWindow *window;
   GError *err;
   gboolean use_mnemonics;
+  gboolean  wrap_tabs;
   
   window = g_object_new (TERMINAL_TYPE_WINDOW, NULL);
   g_signal_connect (G_OBJECT (window), "realize", G_CALLBACK (terminal_window_realized_callback), NULL);
@@ -1266,6 +1268,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,
@@ -1361,9 +1378,6 @@ update_tab_sensitivity (TerminalWindow *
   num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
   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 = (page_num >= num_pages - 1);
 
   /* If there's only one tab, Close Tab is insensitive */
@@ -1384,8 +1398,13 @@ update_tab_sensitivity (TerminalWindow *
       gtk_widget_set_sensitive (window->priv->move_right_tab_menuitem, TRUE);
     }
 
-  gtk_widget_set_sensitive (window->priv->next_tab_menuitem,
-                            !on_last_page);
+  if (! window->priv->wrap_tabs)
+  {
+    gtk_widget_set_sensitive (window->priv->previous_tab_menuitem,
+                              page_num > 0);
+    gtk_widget_set_sensitive (window->priv->next_tab_menuitem,
+                           !on_last_page);
+  }
 }
 
 static void
@@ -2680,14 +2699,34 @@ 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
