Index: gtk/gtkmenushell.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenushell.c,v
retrieving revision 1.101
diff -u -p -r1.101 gtkmenushell.c
--- gtk/gtkmenushell.c	14 May 2006 04:25:29 -0000	1.101
+++ gtk/gtkmenushell.c	1 Sep 2006 09:56:04 -0000
@@ -346,6 +346,12 @@ gtk_menu_shell_class_init (GtkMenuShellC
 							 TRUE,
 							 GTK_PARAM_READWRITE));
 
+  gtk_settings_install_property (g_param_spec_boolean ("gtk-menu-shell-wrap-around",
+                                                       P_("Wrap around"),
+                                                       P_("Whether to wrap around when keyboard-navigating the menu"),
+                                                       TRUE,
+                                                       GTK_PARAM_READWRITE));
+
   g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
 }
 
@@ -1044,17 +1050,24 @@ gtk_menu_shell_move_selected (GtkMenuShe
       GList *node = g_list_find (menu_shell->children,
 				 menu_shell->active_menu_item);
       GList *start_node = node;
-      
+      gboolean wrap_around;
+
+      g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
+                    "gtk-menu-shell-wrap-around", &wrap_around,
+                    NULL);
+
       if (distance > 0)
 	{
 	  node = node->next;
 	  while (node != start_node && 
 		 (!node || !_gtk_menu_item_is_selectable (node->data)))
 	    {
-	      if (!node)
-		node = menu_shell->children;
-	      else
+	      if (node)
 		node = node->next;
+              else if (wrap_around)
+		node = menu_shell->children;
+              else
+                break;
 	    }
 	}
       else
@@ -1063,10 +1076,12 @@ gtk_menu_shell_move_selected (GtkMenuShe
 	  while (node != start_node &&
 		 (!node || !_gtk_menu_item_is_selectable (node->data)))
 	    {
-	      if (!node)
-		node = g_list_last (menu_shell->children);
-	      else
+	      if (node)
 		node = node->prev;
+              else if (wrap_around)
+		node = g_list_last (menu_shell->children);
+              else
+                break;
 	    }
 	}
       
