Index: src/orca/settings.py
===================================================================
--- src/orca/settings.py	(revision 4004)
+++ src/orca/settings.py	(working copy)
@@ -154,6 +154,7 @@
     "showMainWindow",
     "quitOrcaNoConfirmation",
     "presentToolTips",
+    "wrappedStructureNavigation",
     "sayAllStyle",
     "keyboardLayout",
     "speakBlankLines",
@@ -217,6 +218,9 @@
 #
 MODIFIER_ORCA = 8
 
+# weather to wrap around the document when structure navigation is used
+wrappedStructureNavigation = True
+
 # Verbosity levels (see setBrailleVerbosityLevel and
 # setSpeechVerbosityLevel).  These will have an impact on the various
 # individual verbosity levels for rolenames, accelerators, etc.
Index: src/orca/orca-setup.glade
===================================================================
--- src/orca/orca-setup.glade	(revision 4004)
+++ src/orca/orca-setup.glade	(working copy)
@@ -321,6 +321,26 @@
 		  </child>
 
 		  <child>
+		    <widget class="GtkCheckButton" id="wrappedStructureNavigation">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes">_Wrapped structure navigation</property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		      <signal name="toggled" handler="wrappedStructureNavigationChanged" last_modification_time="Wed, 25 Jun 2008 20:32:20 GMT"/>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
 		    <widget class="GtkCheckButton" id="autostartOrcaCheckbutton">
 		      <property name="visible">True</property>
 		      <property name="can_focus">True</property>
Index: src/orca/structural_navigation.py
===================================================================
--- src/orca/structural_navigation.py	(revision 4004)
+++ src/orca/structural_navigation.py	(working copy)
@@ -827,13 +827,11 @@
                 if not next:
                     [obj, wrapped] = self._findPrevByMatchRule(collection,
                                                                rule,
-                                                               True,
                                                                obj,
                                                                predicate)
                 else:
                     [obj, wrapped] = self._findNextByMatchRule(collection,
                                                                rule,
-                                                               True,
                                                                obj,
                                                                predicate)
                 success = True
@@ -850,11 +848,9 @@
         if not success:
             pred = structuralNavigationObject.predicate
             if not next:
-                [obj, wrapped] = self._findPrevByPredicate(pred, True,
-                                                           obj, arg)
+                [obj, wrapped] = self._findPrevByPredicate(pred, obj, arg)
             else:
-                [obj, wrapped] = self._findNextByPredicate(pred, True,
-                                                           obj, arg)
+                [obj, wrapped] = self._findNextByPredicate(pred, obj, arg)
             # print "predicate", structuralNavigationObject.objType
         if wrapped:
             if not next:
@@ -889,7 +885,7 @@
 
         return orca_state.locusOfFocus
 
-    def _findPrevByMatchRule(self, collection, matchRule, wrap, currentObj,
+    def _findPrevByMatchRule(self, collection, matchRule, currentObj,
                              predicate=None):
         """Finds the previous object using the given match rule as a
         pattern to match or not match.
@@ -897,8 +893,6 @@
         Arguments:
         -collection: the accessible collection interface
         -matchRule: the collections match rule to use
-        -wrap: if True and the bottom of the document is reached, move
-         to the top and keep looking.
         -currentObj: the object from which the search should begin
         -predicate: an optional predicate to further test if the item
          found via collection is indeed a match.
@@ -926,6 +920,9 @@
                                           True,
                                           1,
                                           True)
+	wrap = settings.wrappedStructureNavigation
+        debug.println(debug.LEVEL_SEVERE, 
+"_findPrevByMatchRule, wrap=%s\n" % wrap)
         while not match:
             if len(results) == 0:
                 if wrapped or not wrap:
@@ -975,7 +972,7 @@
 
         return [match, wrapped]
 
-    def _findNextByMatchRule(self, collection, matchRule, wrap, currentObj,
+    def _findNextByMatchRule(self, collection, matchRule, currentObj,
                              predicate=None):
         """Finds the next object using the given match rule as a pattern
         to match or not match.
@@ -983,8 +980,6 @@
         Arguments:
         -collection:  the accessible collection interface
         -matchRule: the collections match rule to use
-        -wrap: if True and the bottom of the document is reached, move
-         to the top and keep looking.
         -currentObj: the object from which the search should begin
         -predicate: an optional predicate to further test if the item
          found via collection is indeed a match.
@@ -1002,6 +997,7 @@
             obj = obj.parent
 
         match, wrapped = None, False
+        wrap = settings.wrappedStructureNavigation
         while not match:
             results = collection.getMatchesFrom(\
                 currentObj,
@@ -1023,15 +1019,13 @@
 
         return [match, wrapped]
 
-    def _findPrevByPredicate(self, pred, wrap, currentObj=None, arg=None):
+    def _findPrevByPredicate(self, pred, currentObj=None, arg=None):
         """Finds the caret offset at the beginning of the previous object
         using the given predicate as a pattern to match.
 
         Arguments:
         -pred: a python callable that takes an accessible argument and
                returns true/false based on some match criteria
-        -wrap: if True and the top of the document is reached, move
-               to the bottom and keep looking.
         -currentObj: the object from which the search should begin
         -arg:  an additional value to be passed to the predicate
 
@@ -1051,7 +1045,10 @@
         obj = self._findPreviousObject(currentObj, document)
         wrapped = obj is None
         match = None
-
+	wrap = settings.wrappedStructureNavigation
+        debug.println(debug.LEVEL_SEVERE,
+        "_findPrevByPredicate, wrap=%s\n" % wrap)
+	
         if wrapped:
             obj = self._findLastObject(document)
 
@@ -1072,15 +1069,13 @@
 
         return [match, wrapped]
 
-    def _findNextByPredicate(self, pred, wrap, currentObj=None, arg=None):
+    def _findNextByPredicate(self, pred, currentObj=None, arg=None):
         """Finds the caret offset at the beginning of the next object
         using the given predicate as a pattern to match or not match.
 
         Arguments:
         -pred: a python callable that takes an accessible argument and
                returns true/false based on some match criteria
-        -wrap: if True and the bottom of the document is reached, move
-               to the top and keep looking.
         -currentObj: the object from which the search should begin
         -arg:  an additional value to be passed to the predicate
 
@@ -1098,7 +1093,9 @@
         obj = self._findNextObject(currentObj, document)
         wrapped = obj is None
         match = None
-
+       	wrap = settings.wrappedStructureNavigation
+        debug.println(debug.LEVEL_SEVERE, 
+	"_findNextByPredicate, wrap=%s\n" % wrap)
         if wrapped:
             [obj, offset] = self._getCaretPosition(document)
 
Index: src/orca/orca_gui_prefs.py
===================================================================
--- src/orca/orca_gui_prefs.py	(revision 4004)
+++ src/orca/orca_gui_prefs.py	(working copy)
@@ -1465,6 +1465,9 @@
 
         self.get_widget("sayAllStyle").set_active(prefs["sayAllStyle"])
 
+	self.get_widget("wrappedStructureNavigation").set_active(\
+            prefs["wrappedStructureNavigation"])
+
         # Set the sensitivity of the "Update Interval" items, depending
         # upon whether the "Speak progress bar updates" checkbox is checked.
         #
@@ -2798,6 +2801,17 @@
         self.prefsDict["progressBarUpdateInterval"] = widget.get_value_as_int()
 
 
+    def wrappedStructureNavigationChanged(self, widget):
+        """Toggled Signal handler for the 
+           wrappedStructureNavigation GtkCheckButton widget.
+           Set the preference to the new value.
+           
+        Arguments:
+        - widget: the component that generated the signal.
+        """
+ 
+        self.prefsDict["wrappedStructureNavigation"] = widget.get_active()
+
     def speakUnderMouseChecked(self, widget):
         """Signal handler for the "toggled" signal for the
            speakUnderMouseCheckButton GtkCheckButton widget.
