Index: navcontrolplugin/navcontrol/filter.py
===================================================================
--- navcontrolplugin/navcontrol/filter.py	(revision 7)
+++ navcontrolplugin/navcontrol/filter.py	(working copy)
@@ -9,9 +9,9 @@
 except ImportError:
     from sets import Set as set
 
-__all__ = ['NavControlModule']
+__all__ = ['ClearSilverNavControlModule', 'GenshiNavControlModule']
 
-class NavControlModule(Component):
+class NavControlModule:
     """Request filter to hide entries in navigation bars."""
 
     mainnav = ListOption('navcontrol', 'mainnav',
@@ -21,30 +21,18 @@
                               doc='Items to remove from the metanav bar')
 
     main2meta = ListOption('navcontrol', 'mainnav_to_metanav',
-                              doc='Items to shift from mainnav to metanav bar')
+                              doc='Items to shift from mainnav to metanav bar, \
+                              add entries to ![trac] metanav to dictate the order they appear')
                              
     meta2main = ListOption('navcontrol', 'metanav_to_mainnav',
-                              doc='Items to shift from metanav to mainnav bar')
+                              doc='Items to shift from metanav to mainnav bar, \
+                              add entries to ![trac] mainnav to dictate the order they appear')
     
     labels = ListOption('navcontrol', 'labels',
                               doc='Labels to assign to navigation items. \
                                    They should be specified as navitem:label e.g \
                                    !wiki:My Wiki,!browser:Code')
-
-    implements(IRequestFilter)
-
-    # IRequestFilter methods
-    def pre_process_request(self, req, handler):
-        return handler
-        
-    def post_process_request(self, req, template, data, content_type):
-        self._remove_items(req, 'mainnav')
-        self._remove_items(req, 'metanav')    
-        self._move_items(req, 'main2meta')
-        self._move_items(req, 'meta2main')
-        self._relabel_items(req)
-        return template, data, content_type
-
+    
     # Internal methods
     def _remove_items(self, req, name):
         items = set(getattr(self, name))
@@ -73,7 +61,17 @@
                 if navitem['name'] == item:
                     nav_from_items.remove(navitem)
                     nav_to_items.append(navitem)
-
+        # Resort items
+        orderstr = self.env.config.get('trac', nav_to)
+        order = orderstr.replace(',', ' ').split()
+        def navcmp(x, y):
+            if x['name'] not in order:
+                return int(y['name'] in order)
+            if y['name'] not in order:
+                return -int(x['name'] in order)
+            return cmp(order.index(x['name']), order.index(y['name']))
+        nav_to_items.sort(navcmp)
+        
     def _relabel_items(self, req):
       nvp_dict = {}
       items = set(getattr(self, 'labels'))
@@ -104,5 +102,35 @@
         if item[0] in prefix_list:
           items.add(item[1:])
       return items
-
-
+    
+class ClearSilverNavControlModule(Component, NavControlModule):
+    """Request filter to hide entries in navigation bars."""
+    implements(IRequestFilter)
+            
+    # IRequestFilter methods
+    def pre_process_request(self, req, handler):
+        return handler   
+    def post_process_request(self, req, template, content_type):
+        self.log.debug("ClearSilverNavControlModule called %s" % self.meta2main)
+        self._remove_items(req, 'mainnav')
+        self._remove_items(req, 'metanav')    
+        self._move_items(req, 'main2meta')
+        self._move_items(req, 'meta2main')
+        self._relabel_items(req)
+        return template, content_type
+        
+class GenshiNavControlModule(Component, NavControlModule):        
+    """Request filter to hide entries in navigation bars."""
+    implements(IRequestFilter)    
+        
+    # IRequestFilter methods
+    def pre_process_request(self, req, handler):
+        return handler     
+    def post_process_request(self, req, template, data, content_type):
+        self.log.debug("GenshiNavControlModule called %s" % self.meta2main)
+        self._remove_items(req, 'mainnav')
+        self._remove_items(req, 'metanav')    
+        self._move_items(req, 'main2meta')
+        self._move_items(req, 'meta2main')
+        self._relabel_items(req)
+        return template, data, content_type
