Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2135)
+++ ChangeLog	(working copy)
@@ -11,6 +11,17 @@
           Fixed bug #404052 – Say something to let the user know the 
           Preferences dialog is loading.
 
+        * src/orca/scripts/gedit.py:
+          src/orca/scripts/gaim.py:
+          src/orca/scripts/Evolution.py:
+          src/orca/scripts/StarOffice.py:
+          src/orca/default.py:
+          src/orca/J2SE-access-bridge.py:
+          src/orca/where_am_I.py:
+          src/orca/hierarchical_presenter.py:
+          src/orca/keybindings.py:
+          Fixed bug #402494 – For statement refactoring.
+
 2007-03-06  Lynn Monsanto <lynn.monsanto@sun.com>
 
         * test/harness/runone.sh, test/harness/runall.sh: Partial 
Index: src/orca/scripts/gedit.py
===================================================================
--- src/orca/scripts/gedit.py	(revision 2135)
+++ src/orca/scripts/gedit.py	(working copy)
@@ -133,12 +133,12 @@
         # another component.
         #
         allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
-        for i in range(0, len(allLabels)):
-            if allLabels[i].name.startswith(_("Change to:")) or \
-               allLabels[i].name.startswith(_("Misspelled word:")):
+        for label in allLabels:
+            if label.name.startswith(_("Change to:")) or \
+               label.name.startswith(_("Misspelled word:")):
                 continue
             else:
-                badWord = allLabels[i].name
+                badWord = label.name
                 break
 
         # Note that we often get two or more of these focus or property-change
Index: src/orca/scripts/gaim.py
===================================================================
--- src/orca/scripts/gaim.py	(revision 2135)
+++ src/orca/scripts/gaim.py	(working copy)
@@ -172,10 +172,10 @@
                 self.inputEventHandlers["togglePrefixHandler"]))
 
         messageKeys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
-        for i in range(0, len(messageKeys)):
+        for messageKey in messageKeys:
             keyBindings.add(
                 keybindings.KeyBinding(
-                    messageKeys[i],
+                    messageKey,
                     1 << settings.MODIFIER_ORCA,
                     1 << settings.MODIFIER_ORCA,
                     self.inputEventHandlers["readPreviousMessageHandler"]))
Index: src/orca/scripts/Evolution.py
===================================================================
--- src/orca/scripts/Evolution.py	(revision 2135)
+++ src/orca/scripts/Evolution.py	(working copy)
@@ -239,8 +239,8 @@
         """
 
         allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
-        for i in range(0, len(allLabels)):
-            self.speakSetupAssistantLabel(allLabels[i])
+        for label in allLabels:
+            self.speakSetupAssistantLabel(label)
 
     def readPageTab(self, tab):
         """Speak/Braille the given page tab. The speech verbosity is set
@@ -915,16 +915,16 @@
             panel = event.source.parent.parent
             allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
             found = False
-            for i in range(0, len(allLabels)):
+            for label in allLabels:
                 if not found:
-                    text = self.getDisplayedText(allLabels[i])
+                    text = self.getDisplayedText(label)
                     if text:
                         tokens = text.split()
                     else:
                         tokens = []
-                    for j in range(0, len(tokens)):
-                        if tokens[j].startswith("'"):
-                            badWord = tokens[j]
+                    for token in tokens:
+                        if token.startswith("'"):
+                            badWord = token
                             badWord = badWord[1:len(badWord)-1]
                             found = True
                             break
Index: src/orca/scripts/StarOffice.py
===================================================================
--- src/orca/scripts/StarOffice.py	(revision 2135)
+++ src/orca/scripts/StarOffice.py	(working copy)
@@ -1054,9 +1054,9 @@
         for i in range(0, nLinks):
             links.append(obj.hypertext.getLink(i))
 
-        for i in range(0, len(links)):
-            if links[i].endIndex > startOffset and \
-               links[i].endIndex <= endOffset:
+        for link in links:
+            if link.endIndex > startOffset and \
+               link.endIndex <= endOffset:
                 return True
 
         return False
@@ -1133,8 +1133,8 @@
         """
 
         allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
-        for i in range(0, len(allLabels)):
-            self.speakSetupLabel(allLabels[i])
+        for label in allLabels:
+            self.speakSetupLabel(label)
 
     # This method tries to detect and handle the following cases:
     # 0) Writer: find command.
@@ -1335,15 +1335,15 @@
                 #
                 panel = event.source.parent
                 allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
-                for i in range(0, len(allLabels)):
-                    relations = allLabels[i].relations
+                for label in allLabels:
+                    relations = label.relations
                     hasLabelFor = False
                     for relation in relations:
                         if relation.getRelationType() \
                                == atspi.Accessibility.RELATION_LABEL_FOR:
                             hasLabelFor = True
                     if not hasLabelFor:
-                        self.speakSetupLabel(allLabels[i])
+                        self.speakSetupLabel(label)
 
             # Check for 5. Registration: Register Now radio button.
             #
@@ -1431,12 +1431,11 @@
 
             allPanels = self.findByRole(event.source.parent,
                                         rolenames.ROLE_PANEL)
-            for i in range(0, len(allPanels)):
-                if not allPanels[i].name:
-                    allLabels = self.findByRole(allPanels[i],
-                                                rolenames.ROLE_LABEL)
-                    for i in range(0, len(allLabels)):
-                        self.speakSetupLabel(allLabels[i])
+            for panel in allPanels:
+                if not panel.name:
+                    allLabels = self.findByRole(panel, rolenames.ROLE_LABEL)
+                    for label in allLabels:
+                        self.speakSetupLabel(label)
         else:
             # Pass the event onto the parent class to be handled in the
             # default way.
Index: src/orca/default.py
===================================================================
--- src/orca/default.py	(revision 2135)
+++ src/orca/default.py	(working copy)
@@ -2610,8 +2610,8 @@
         list = []
         dictionary = {}
         allTokens = str.split(";")
-        for i in range(0, len(allTokens)):
-            item = allTokens[i].split(":")
+        for token in allTokens:
+            item = token.split(":")
             if len(item) == 2:
                 key = item[0].strip()
                 attribute = item[1].strip()
@@ -2627,8 +2627,7 @@
         - attributes: a dictionary of text attributes to speak.
         """
 
-        for i in range(0, len(keys)):
-            key = keys[i]
+        for key in keys:
             if attributes.has_key(key):
                 attribute = attributes[key]
                 if attribute:
@@ -2693,8 +2692,7 @@
             # value is the default, then ignore it.
             #
             attributes = {}
-            for i in range(0, len(userAttrList)):
-                key = userAttrList[i]
+            for key in userAttrList:
                 if allAttributes.has_key(key):
                     textAttr = allAttributes.get(key)
                     userAttr = userAttrDict.get(key)
@@ -3941,8 +3939,8 @@
         """
 
         current = obj
-        for i in range(0, len(rolesList)):
-            if (current == None) or (current.role != rolesList[i]):
+        for role in rolesList:
+            if (current == None) or (current.role != role):
                 return False
             current = current.parent
 
@@ -3961,8 +3959,8 @@
         # word plus the context where it is used (upto five words
         # to either side of it).
         #
-        for i in range(0, len(allTokens)):
-            if allTokens[i].startswith(badWord):
+        for token in allTokens:
+            if token.startswith(badWord):
                 min = i - 5
                 if min < 0:
                     min = 0
Index: src/orca/J2SE-access-bridge.py
===================================================================
--- src/orca/J2SE-access-bridge.py	(revision 2135)
+++ src/orca/J2SE-access-bridge.py	(working copy)
@@ -170,10 +170,10 @@
                     popup = self.findByRole(child, rolenames.ROLE_POPUP_MENU, False)
                     if len(popup) > 0:
                         # set the locus of focus to the armed menu item
-                        item = self.findByRole(popup[0], rolenames.ROLE_MENU_ITEM, False)
-                        for j in range(0, len(item)):
-                            if item[j].state.count(Accessibility.STATE_ARMED):
-                                orca.setLocusOfFocus(event, item[j])
+                        items = self.findByRole(popup[0], rolenames.ROLE_MENU_ITEM, False)
+                        for item in items:
+                            if item.state.count(Accessibility.STATE_ARMED):
+                                orca.setLocusOfFocus(event, item)
                                 return
         
 
Index: src/orca/where_am_I.py
===================================================================
--- src/orca/where_am_I.py	(revision 2135)
+++ src/orca/where_am_I.py	(working copy)
@@ -1036,8 +1036,7 @@
         debug.println(_debugLevel,
                       "charDict: %s" % (charDict))
 
-        for i in range(0, len(keys)):
-            key = keys[i]
+        for key in keys:
             if charDict.has_key(key):
                 attribute = charDict[key]
                 if attribute:
@@ -1081,8 +1080,8 @@
     """
     dictionary = {}
     allTokens = str.split(";")
-    for i in range(0, len(allTokens)):
-        item = allTokens[i].split(":")
+    for token in allTokens:
+        item = token.split(":")
         if len(item) == 2:
             item[0] = _removeLeadingSpaces(item[0])
             item[1] = _removeLeadingSpaces(item[1])
Index: src/orca/hierarchical_presenter.py
===================================================================
--- src/orca/hierarchical_presenter.py	(revision 2135)
+++ src/orca/hierarchical_presenter.py	(working copy)
@@ -107,8 +107,8 @@
         """
 
         apps = orca_state.activeScript.getKnownApplications()
-        for i in range(0, len(apps)):
-            if accessible.app == apps[i]:
+        for app in apps:
+            if accessible.app == app:
                 return i
 
         return -1
Index: src/orca/keybindings.py
===================================================================
--- src/orca/keybindings.py	(revision 2135)
+++ src/orca/keybindings.py	(working copy)
@@ -186,9 +186,9 @@
         """Removes the given KeyBinding instance from this set of keybindings.
         """
 
-        for i in range(0, len(self.keyBindings)):
-            if keyBinding == self.keyBindings[i]:
-                del self.keyBindings[i]
+        for item in self.keyBindings:
+            if keyBinding == item:
+                del item
 
     def removeByHandler(self, handler):
         """Removes the given KeyBinding instance from this set of keybindings.
