Index: src/terminal-accels.h
===================================================================
--- src/terminal-accels.h	(revision 2177)
+++ src/terminal-accels.h	(working copy)
@@ -42,6 +42,7 @@
 #define ACCEL_PATH_RESET_AND_CLEAR ACCEL_PATH_ROOT"/reset_and_clear"
 #define ACCEL_PATH_PREV_TAB ACCEL_PATH_ROOT"/prev_tab"
 #define ACCEL_PATH_NEXT_TAB ACCEL_PATH_ROOT"/next_tab"
+#define ACCEL_PATH_CIRCULATE_TAB ACCEL_PATH_ROOT"/circulate_tab"
 #define ACCEL_PATH_SET_TERMINAL_TITLE ACCEL_PATH_ROOT"/set_terminal_title"
 #define ACCEL_PATH_HELP ACCEL_PATH_ROOT"/help"
 #define ACCEL_PATH_ZOOM_IN ACCEL_PATH_ROOT"/zoom_in"
Index: src/terminal-window.c
===================================================================
--- src/terminal-window.c	(revision 2177)
+++ src/terminal-window.c	(working copy)
@@ -39,6 +39,8 @@
 #define TAB_MENU_WIDTH_CHARS    35
 #define TAB_MENU_ELLIPSIZE      PANGO_ELLIPSIZE_END
 
+#define KEY_CIRCULATE_TAB CONF_GLOBAL_PREFIX"/circulate_tab"
+
 struct _TerminalWindowPrivate
 {  
   GtkWidget *main_vbox;
@@ -63,6 +65,7 @@
   GtkWidget *choose_config_menuitem;
   GtkWidget *next_tab_menuitem;
   GtkWidget *previous_tab_menuitem;
+  GtkWidget *circulate_tab_menuitem;
   GtkWidget *move_left_tab_menuitem;
   GtkWidget *move_right_tab_menuitem;
   GtkWidget *detach_tab_menuitem;
@@ -154,6 +157,8 @@
 static void reset_menubar_labels          (TerminalWindow *window);
 static void reset_tab_menuitems           (TerminalWindow *window);
 
+static void update_tab_sensitivity        (TerminalWindow *window);
+
 static void new_window                    (TerminalWindow  *window,
                                            TerminalScreen  *screen,
                                            TerminalProfile *profile,
@@ -208,6 +213,8 @@
                                            TerminalWindow *window);
 static void previous_tab_callback         (GtkWidget      *menuitem,
                                            TerminalWindow *window);
+static void circulate_tab_callback        (GtkWidget      *menuitem,
+                                           TerminalWindow *window);
 static void move_left_tab_callback        (GtkWidget      *menuitem,
                                            TerminalWindow *window);
 static void move_right_tab_callback       (GtkWidget      *menuitem,
@@ -502,6 +509,46 @@
   return g_string_free (escaped_name, FALSE);
 }
 
+static gboolean
+is_circulate_tab (TerminalWindow *window)
+{
+  GError *err = NULL;
+  gboolean circulate;
+
+  circulate = gconf_client_get_bool (window->priv->conf,
+                                     KEY_CIRCULATE_TAB,
+                                     &err);
+  if (err)
+    {
+      g_printerr (_("There was an error loading config value for whether to circulate tab. (%s)\n"),
+                  err->message);
+      g_error_free (err);
+    }
+
+  return circulate;
+}
+
+static void
+set_circulate_tab (TerminalWindow *window,
+                   gboolean        value)
+{
+  GError *err = NULL;
+
+  gconf_client_set_bool (window->priv->conf, KEY_CIRCULATE_TAB, value, &err);
+  if (err)
+    {
+      g_printerr (_("There was an error setting config value for whether to circulate tab. (%s)\n"),
+                  err->message);
+      g_error_free (err);
+    }
+}
+
+static void
+toggle_circulate_tab (TerminalWindow *window)
+{
+  set_circulate_tab (window, !is_circulate_tab (window));
+}
+
 static void
 fill_in_new_term_submenu_real(GtkWidget *menuitem, 
                               TerminalWindow *window,
@@ -1057,6 +1104,15 @@
                         G_CALLBACK (next_tab_callback), window);
   window->priv->next_tab_menuitem = mi;
 
+  mi = gtk_separator_menu_item_new ();
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+  mi = append_check_menuitem (menu, _("_Circulate Tab"),
+                              ACCEL_PATH_CIRCULATE_TAB,
+                              FALSE,
+                              G_CALLBACK (circulate_tab_callback), window);
+  window->priv->circulate_tab_menuitem = mi;
+
   /* Capture the key presses */
   g_signal_connect (G_OBJECT(window), "key-press-event",
 		    G_CALLBACK (key_press_callback), window);
@@ -1275,6 +1331,7 @@
 terminal_window_new (GConfClient *conf)
 {
   TerminalWindow *window;
+  GtkCheckMenuItem *item;
   GError *err;
   gboolean use_mnemonics;
   
@@ -1314,6 +1371,9 @@
       g_error_free (err);
     }
 
+  item = GTK_CHECK_MENU_ITEM (window->priv->circulate_tab_menuitem);
+  gtk_check_menu_item_set_active (item, is_circulate_tab (window));
+
   reset_menubar_labels (window);
   reset_tab_menuitems (window);
   
@@ -1402,13 +1462,15 @@
   GtkWidget *notebook;
   int num_pages, page_num;
   gboolean on_last_page;
+  gboolean circulate;
 
   notebook = window->priv->notebook;
   num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
   page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-  
+  circulate = is_circulate_tab (window);
+
   gtk_widget_set_sensitive (window->priv->previous_tab_menuitem,
-                            page_num > 0);
+                            page_num > 0 || (num_pages > 1 && circulate));
 
   on_last_page = (page_num >= num_pages - 1);
 
@@ -1431,7 +1493,7 @@
     }
 
   gtk_widget_set_sensitive (window->priv->next_tab_menuitem,
-                            !on_last_page);
+                            !on_last_page || (num_pages > 1 && circulate));
 }
 
 static void
@@ -2043,6 +2105,16 @@
           reset_menubar_labels (window);
         }
     }
+  else if (strcmp (gconf_entry_get_key (entry), KEY_CIRCULATE_TAB) == 0)
+    {
+      if (val && val->type == GCONF_VALUE_BOOL)
+        {
+          GtkCheckMenuItem *item;
+          item = GTK_CHECK_MENU_ITEM (window->priv->circulate_tab_menuitem);
+          gtk_check_menu_item_set_active (item, gconf_value_get_bool (val));
+          update_tab_sensitivity (window);
+        }
+    }
 }
 
 static void
@@ -2750,17 +2822,53 @@
 }
 
 static void
+switch_tab(TerminalWindow *window,
+           gboolean        direction_next)
+{
+  GtkNotebook *notebook;
+  gint current_page, n_pages, new_page;
+
+  notebook = GTK_NOTEBOOK (window->priv->notebook);
+  current_page = gtk_notebook_get_current_page (notebook);
+  n_pages = gtk_notebook_get_n_pages (notebook);
+
+  if (direction_next)
+    {
+      if (current_page == n_pages - 1)
+        gtk_notebook_set_current_page (notebook, 0);
+      else
+        gtk_notebook_next_page (notebook);
+    }
+  else
+    {
+      if (current_page == 0)
+        gtk_notebook_set_current_page (notebook, n_pages - 1);
+      else
+        gtk_notebook_prev_page (notebook);
+    }
+}
+
+static void
 next_tab_callback(GtkWidget      *menuitem,
                   TerminalWindow *window)
 {
-  gtk_notebook_next_page (GTK_NOTEBOOK (window->priv->notebook));
+  switch_tab (window, TRUE);
 }
 
 static void
 previous_tab_callback (GtkWidget      *menuitem,
                        TerminalWindow *window)
 {
-  gtk_notebook_prev_page (GTK_NOTEBOOK (window->priv->notebook));
+  switch_tab (window, FALSE);
+}
+
+static void
+circulate_tab_callback (GtkWidget      *menuitem,
+                        TerminalWindow *window)
+{
+  GtkCheckMenuItem *item;
+  item = GTK_CHECK_MENU_ITEM (window->priv->circulate_tab_menuitem);
+  set_circulate_tab (window, gtk_check_menu_item_get_active (item));
 }
 
 static void
