diff Gtk/gui.py @ 7:0359329a1c26

Navigation buttons. Version of the data structure.
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Thu, 11 Nov 2010 23:22:35 +0100
parents 2fc6b47dbe70
children 55df0b15706b
line wrap: on
line diff
--- a/Gtk/gui.py	Sat Nov 06 22:33:32 2010 +0100
+++ b/Gtk/gui.py	Thu Nov 11 23:22:35 2010 +0100
@@ -31,7 +31,7 @@
 viewes or more gtk.Paned.
 The view can have diferente type of widgets to show the budget information.
 The DecompositionList class show the decompositon list information of a record
-The Measure class show de measure information of a record
+The Measure class show the measure information of a record
 The TextWindow class show the long description of a record
 The Sheet class class show the sheet of condition information of a record
 
@@ -82,30 +82,17 @@
         Creates and shows the main window.
         This is the interface base class.
     Constructor:
-        gui.MainWindow(): Returns the newly created main window instance
+        gui.MainWindow()
     Ancestry:
     +-- object
       +-- MainWindow
     Atributes:
         "window": Main window widget ("gtk.Window" object)
-        "__budget_temp_list": Temporal list of budgets
-        "__budget_list": List of budgets ("base.Budget" objects)
-        "__page_list": List of pages ("Page" object)
-        "__notebook": Notebook widget ("gtk.Notebook" object)
-        "__general_action_group": the "General" action group
     Methods:
-        __init__(self)
-        _main(self)
-        _addBudget(self, budget)
-        _appendPage(self)
-        _testBudgetList(self)
-        _menuitemImportFiebdc(self, widget)
-        _menuitemImportPriceDatabase(self, widget)
-        _menuitemOpenPriceDatabase(self, widget)
-        _menuitemOpen
-        _menuitemClose(self, widget)
-        _delete_event(self, widget, event)
-        _destroy(self, widget)
+        removePage
+        getNotebook
+        getPageList
+        getBudgetList
     """
     # TODO:* Can choose open budget in new window
     # TODO:* gtk.Action for menu and toolbar
@@ -119,6 +106,13 @@
       </menu>
       <menu action="View">
       </menu>
+      <menu action="Go">
+        <menuitem action="GoUp"/>
+        <menuitem action="GoDown"/>
+        <menuitem action="GoPrevious"/>
+        <menuitem action="GoPosterior"/>
+        <menuitem action="GoToRoot"/>
+      </menu>
       <menu action="Test">
         <menuitem action="ImportFiebdcPriceDatabase"/>
         <menuitem action="OpenPriceDatabase"/>
@@ -126,9 +120,13 @@
     </menubar>
     <toolbar name="ToolBar">
       <toolitem action="ImportFiebdc"/>
-      <separator/>
       <toolitem action="Close"/>
       <separator name="sep1"/>
+      <toolitem action="GoUp"/>
+      <toolitem action="GoDown"/>
+      <toolitem action="GoPrevious"/>
+      <toolitem action="GoPosterior"/>
+      <toolitem action="GoToRoot"/>
     </toolbar>
     </ui>'''
 
@@ -137,7 +135,14 @@
         
         Initialize the atributes "__budget_list" and "__page_list" without data.
         Creates the widgets "window" and "__notebook".
+        
+        self.__budget_temp_list: Temporal list of budgets
+        self.__budget_list: List of budgets ("base.Budget" objects)
+        self.__page_list: List of pages ("Page" object)
+        self.__notebook: Notebook widget ("gtk.Notebook" object)
+        self.__general_action_group: "General" action group
         """
+        #TODO: action group for Navigation buttons
         self.__budget_temp_list = []
         self.__budget_list = []
         self.__page_list = []
@@ -165,6 +170,17 @@
              ("Close", gtk.STOCK_CLOSE, _("_Close"), None, _('Close'),
                 self._menuitemClose),
              ("View", None, _("_View")),
+             ("Go", None, _("_Go")),
+             ("GoUp", gtk.STOCK_GO_UP, _("_Up Record"),"",
+                _("Go up record"), self._menuitemGoUp),
+             ("GoDown", gtk.STOCK_GO_DOWN, _("_Down Record"),"",
+                _("Go down record"), self._menuitemGoDown),
+             ("GoPrevious", gtk.STOCK_GO_BACK, _("_Previous Record"),"",
+                _("Go Previous record"), self._menuitemGoPrevious),
+             ("GoPosterior", gtk.STOCK_GO_FORWARD, _("_Posterior Record"),"",
+                _("Go posterior record"), self._menuitemGoPosterior),
+             ("GoToRoot", gtk.STOCK_GOTO_TOP, _("_Root"),"",
+                _("Go to root"), self._menuitemGoToRoot),
              ("Test", None, _("_Test")),
              ('ImportFiebdcPriceDatabase', gtk.STOCK_OPEN,
                 _("Import Fiebdc _price database"), "", _("Import database"),
@@ -219,7 +235,7 @@
         page widget in the notebook widget.
         """
         _last_budget = self.__budget_list[-1]
-        _page = Page(_last_budget)
+        _page = Page(self, _last_budget)
         self.__notebook.append_page(_page.widget, _page.title)
         self.__page_list.append(_page)
 
@@ -230,7 +246,7 @@
         widget: the widget where the event is emitted from
         Callback to open a budget file.
         
-        Creates and shows a window to open a budget file.
+        Creates and shows a file selection window to open a budget file.
         """
         _budget = base.Budget()
         self.__budget_temp_list.append(_budget)
@@ -246,9 +262,9 @@
         """def _menuitemImportPriceDatabase(self, widget)
         
         widget: the widget where the event is emitted from
-        Callback to open a budget file.
-        
-        Creates and shows a window to open a price database file.
+        Callback to open a price database file.
+        
+        Creates and shows a file selection window to open a price database file.
         """
         _budget = base.Budget()
         self.__budget_temp_list.append(_budget)
@@ -266,7 +282,7 @@
         widget: the widget where the event is emitted from
         Callback to open a price database from a durus file.
         
-        Creates and shows a window to open a durus database
+        Creates and shows a file selection window to open a durus database
         """
         _budget = None
         self.__budget_temp_list.append(_budget)
@@ -286,19 +302,121 @@
         Callback to close a budget file.
         """
         _page_num = self.__notebook.get_current_page()
+        if _page_num != -1:
+            _page = self.__page_list[_page_num]
+            if isinstance(_page, EmptyPage) and _page.filetype == "durus":
+                print _("Cancel reading Durus database has not been implemented.")
+            else:
+                _page.close()
+
+    def removePage(self, page_num):
+        """def removePage(self, page_num)
+        
+        page_num: The number Page to be removed
+        
+        Removes a page from notebook and page_list.
+        Removes the budget from the budget_list if necessary.
+        """
+        _page = self.__page_list[page_num]
+        if isinstance(_page, Page):
+            #not loading budget
+            self.__budget_list.pop(page_num)
+        self.__page_list.pop(page_num)
+        _page.clear()
+        self.__notebook.remove_page(page_num)
+
+    def _menuitemGoToRoot(self, widget):
+        """def _menuitemGoToRoot(self, widget)
+        
+        widget: the widget where the event is emitted from
+        
+        Callback to go to root record.
+        """
+        _page_num = self.__notebook.get_current_page()
         if _page_num == -1:
             return
-        #_page = self.__page_list.pop(_page_num)
         _page = self.__page_list[_page_num]
         if isinstance(_page, Page):
             #not loading budget
-            self.__budget_list.pop(_page_num)
-        if isinstance(_page, EmptyPage) and _page.filetype == "durus":
-            print _("Cancel reading Durus database has not been implemented.")
-        else:
-            self.__page_list.pop(_page_num)
-            _page.clear()
-            self.__notebook.remove_page(_page_num)
+            _page.propagateMessageFrom("change_active", (-1,), (0,))
+
+    def _menuitemGoUp(self, widget):
+        """def _menuitemGoUp(self, widget)
+        
+        widget: the widget where the event is emitted from
+        
+        Callback to go to up record.
+        """
+        _page_num = self.__notebook.get_current_page()
+        if _page_num != -1:
+            _page = self.__page_list[_page_num]
+            if isinstance(_page, Page):
+                #not loading budget
+                _active_path = _page.activePathRecord
+                if len(_active_path) > 1 and _active_path[-1] > 0:
+                    _budget = self.__budget_list[_page_num]
+                    _up_path = _active_path[:-1] + (_active_path[-1] - 1,)
+                    if _budget.hasPath(_up_path):
+                        _page.propagateMessageFrom("change_active", (-1,),
+                                                   _up_path)
+
+    def _menuitemGoDown(self, widget):
+        """def _menuitemGoToDown(self, widget)
+        
+        widget: the widget where the event is emitted from
+        
+        Callback to go to down record.
+        """
+        _page_num = self.__notebook.get_current_page()
+        if _page_num != -1:
+            _page = self.__page_list[_page_num]
+            if isinstance(_page, Page):
+                #not loading budget
+                _active_path = _page.activePathRecord
+                if len(_active_path) > 1:
+                    _budget = self.__budget_list[_page_num]
+                    _up_path = _active_path[:-1] + (_active_path[-1] + 1,)
+                    if _budget.hasPath(_up_path):
+                        _page.propagateMessageFrom("change_active", (-1,),
+                                                   _up_path)
+
+    def _menuitemGoPrevious(self, widget):
+        """def _menuitemGoPrevious(self, widget)
+        
+        widget: the widget where the event is emitted from
+        
+        Callback to go to previous record.
+        """
+        _page_num = self.__notebook.get_current_page()
+        if _page_num != -1:
+            _page = self.__page_list[_page_num]
+            if isinstance(_page, Page):
+                #not loading budget
+                _previous_path = _page.previousPathRecord
+                if _previous_path is not None:
+                    _budget = self.__budget_list[_page_num]
+                    if _budget.hasPath(_previous_path):
+                        _page.propagateMessageFrom("change_active", (-1,),
+                                                   _previous_path)
+
+    def _menuitemGoPosterior(self, widget):
+        """def _menuitemPosterior(self, widget)
+        
+        widget: the widget where the event is emitted from
+        
+        Callback to go to posterior record.
+        """
+        _page_num = self.__notebook.get_current_page()
+        if _page_num != -1:
+            _page = self.__page_list[_page_num]
+            if isinstance(_page, Page):
+                #not loading budget
+                _posterior_path = _page.posteriorPathRecord
+                if _posterior_path is not None:
+                    _budget = self.__budget_list[_page_num]
+                    if _budget.hasPath(_posterior_path):
+                        _page.propagateMessageFrom("change_active", (-1,),
+                                                   _posterior_path)
 
     def _delete_event(self, widget, event):
         """_delete_event(self, widget, event)
@@ -328,20 +446,87 @@
         gtk.main_quit()
 
     def getNotebook(self):
+        """def getNotebook(self)
+        
+        Return the notebook widget
+        """
         return self.__notebook
+
     def getPageList(self):
+        """def getPageList(self)
+        
+        Return the page list
+        """
         return self.__page_list
+
     def getBudgetList(self):
+        """def getBudgetList(self)
+        
+        Return the budget list
+        """
         return self.__budget_list
 
 class EmptyPage(object):
-    """
+    """gui.EmptyPage:
+    
+    Description:
+    It creates and shows a page in the notebook while a budget is loaded.
+    The page show the pyarq logo, loading time and a progress bar.
+    Constructor:
+        gui.EmptyPage(self, mainWindow, readFileMethod, budget, filename,
+                 cancelMethod, filetype):
+    Ancestry:
+    +-- object
+      +-- EmptyPage
+    Atributes:
+        __mainWindow: gui.Mainwindow object
+        __readFileMethod: Method to read the selected file
+        __budget: base.Budget object
+        __filename: "file"
+        __cancelMethod: Method to cancel the read method
+        __filetype: "budget", "database" or "durus"
+        __children: the read thread
+        __progress: 0 to 1 progress
+        __widget: main widget, a gtk.VBox object
+        __main_item: None
+        __throbber: a gtk.Image
+        __animationThobber: a gtk.gdk.PixbufAnimation
+        __quietThobber: a pixbuf
+        __budget_icon: a gtk.gdk.pixbuf
+        __title: a gtk.HBox
+        __statusbar: a gtk.Statusbar
+        __statuscontext: the statusbar context
+        __progress_bar: a gtk.ProgressBar
+
+    Methods:
+        __init__
+        run
+        progress
+        stopLoading
+        _launchChildren
+        _launchTimeout
+        _updateProgressBar
+        _updateLabel
+        _autoClose
+        threadFinishedSignal
+        threadCanceled
+        close
+        clear
+        getWidget
+        getTitle
+        getFiletype
     """
     def __init__(self, mainWindow, readFileMethod, budget, filename,
                  cancelMethod, filetype):
         """def __init__(self, mainWindow, readFileMethod, budget, filename,
                         cancelMethod, filetype)
         
+        mainWindow: gui.Mainwindow object
+        readFileMethod: Method to read the selected file
+        budget: base.Budget object
+        filename: "file"
+        cancelMethod: Method to cancel the read method
+        filetype: "budget", "database" or "durus"
         """
         self.__mainWindow = mainWindow
         self.__readFileMethod = readFileMethod
@@ -494,7 +679,7 @@
         self.__budget = budget
         self.__children = None
         self.stopLoading()
-        _page = Page(self.__budget)
+        _page = Page(self.__mainWindow, self.__budget)
         _children = self.__widget.get_children()
         for _child in _children:
             self.__widget.remove(_child)
@@ -512,13 +697,20 @@
         """
         self.__children = None
         self.stopLoading()
-
+        _page_num = self.__mainWindow.getNotebook().page_num(self.widget)
+        self.__mainWindow.removePage(_page_num)
+    def close(self):
+        """def close(self)
+        
+        Clos page canceling children
+        """
+        self.__children.cancel()
     def clear(self):
         """def clear(self)
         
-        Cancel thread
+        clear vars
         """
-        self.__children.cancel()
+        pass
         
     def getWidget(self):
         """def getWidget(self)
@@ -555,14 +747,15 @@
     The page can show the budget information in several panes ordered
     according to "panes_list" information.
     Constructor:
-        gui.Page(budget, active_code=None):
-        budget: budget to be showed in this page (base.Budget object)
-        active_code: the code of the active record 
-        Returns the newly created Page instance
+        gui.Page(mainWindow, budget, active_code=None)
+            mainwindow: MainWindow object
+            budget: base.Budget object
+            active_code: Active record code
     Ancestry:
     +-- object
       +-- Page
     Atributes:
+        "widget": Read. Notebook page Widget. (a gtk.VBox instance)
         "budget": Read-Write. Budget to show in the page. (base.obra object)
         "panes_list": Read. info list for create the panes
             ej: [ "v", pane1, pane2 ] , [ "h", pane1, pane2 ]
@@ -573,55 +766,51 @@
                 * "Measure": its creates a "Measure" objetc
                 * "FileView": its creates a "FileView" objet
                 * "CompanyView": its creates a "CompanyView" object
-        "widget": Read. Notebook page Widget. (a gtk.VBox instance)
         "title": Read. Notebook page title (gtk.Label object)
-        "__active_path_record": The active path record
-        "__main_item": main item in the page, can be a View object or a Paned 
-            object
+        "activePathRecord": Read. The active path record
+        "previousPathRecord": Read. The previous path record
+        "posteriorPathRecord" Read. The posterior path record
     Methods:
-        __init__(self, budget=None, active_code=None)
-        propagateMessageFrom(self, message, path, arg=None)
-        sendMessageTo(self, pane, message, path, arg=None)
-        clear(self)
-        getItem(self,path)
-        setMainItem(self, item)
-        itemsFactory(self, list_paned, path=(0,))
-        setActivePathRecord(self, path_record)
-        getTitle(self)
-        getWidget(self)
-        setBudget(self, budget)
-        getBudget(self)
-        getPanesList(self)
+        propagateMessageFrom
+        sendMessageTo
+        close
+        clear
+        getItem
     """
     # TODO:  * The panes can be ordered as the user wishes 
     # TODO:  * Panes in windows
     # TODO:  * pane types
     # TODO:      * General budget properties (is better a dialog?)
 
-    def __init__(self, budget, path_record=(0,)):
+    def __init__(self, mainWindow, budget, path_record=(0,)):
         """def __init__(self, budget=None, active_code=None)
         
+        mainWindow: MainWindow object
         budget: "base.Budget" object
-        active_code: the code of the active record
-        Sets the atributes
-            * __panes_list: info to create the panes
-            * budget (base.Budget object)
-            * active_code
+        path_record: the active path record
         """
         #TODO: __panes_list should come from config file...
+        self.__mainWindow = mainWindow
         self.__widget = gtk.VBox()
         self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure",
             "RecordDescription" ]]
         self.__main_item = None
+        self.__active_path_record = ()
+        self.__history_back = []
+        self.__history_forward = []
         self.setBudget(budget)
-        self.setActivePathRecord(path_record)
+        self._setActivePathRecord(path_record)
         self.__widget.show()
 
-    def propagateMessageFrom(self, message, path, arg=None):
-        """def propagateMessageFrom(self, message, path, arg=None)
+    def propagateMessageFrom(self, message, pane_path, arg=None):
+        """def propagateMessageFrom(self, message, pane_path, arg=None)
         
         message: string message
-        path: tuple that represents the pane path which emits the message
+                * "change_active": change active code
+                * "autoclose"
+                * "split h"
+                * "split v"
+        pane_path: tuple that represents the pane path which emits the message
         arg: arguments for the message
              if message is "change_active" arg is the path record
         
@@ -629,25 +818,38 @@
         """
         _budget = self.__budget
         if message == "change_active" and _budget.hasPath(arg):
-            self.sendMessageTo(self.__main_item, message, path, arg)
+            self.sendMessageTo(self.__main_item, message, pane_path, arg)
+            self._setActivePathRecord(arg)
         elif message == "autoclose":
-            self._closeItem(path)
+            self._closeItem(pane_path)
         elif message == "split h":
-            self._splitItem(path, "h")
+            self._splitItem(pane_path, "h")
         elif message == "split v":
-            self._splitItem(path, "v")
+            self._splitItem(pane_path, "v")
             
-    def sendMessageTo(self, pane, message, path, arg=None):
-        """def sendMessageTo(self, pane,message, path, arg=None)
+    def sendMessageTo(self, pane, message, pane_path, arg=None):
+        """def sendMessageTo(self, pane, message, pane_path, arg=None)
         pane: the receiver pane
         message: string message
-        path: tuple that represents the pane path which emits the message
+        pane_path: tuple that represents the pane pane_path which emits the message
         arg: arguments for the message
         
         Sends a message to a pane
         """
-        if not pane.path == path:
-            pane.runMessage(message, path, arg)
+        if not pane.path == pane_path:
+            pane.runMessage(message, pane_path, arg)
+
+    def close(self):
+        """def close(self)
+        
+        Close Page
+        """
+        _page_list = self.__mainWindow.getPageList()
+        if self in _page_list:
+            _page_num = _page_list.index(self)
+            self.__mainWindow.removePage(_page_num)
+        else:
+            raise IndexError, _("The page is not in the page list")
 
     def clear(self):
         """def clear(self)
@@ -663,20 +865,20 @@
         del self.__active_path_record
         del self.__main_item
 
-    def getItem(self,path):
-        """def getItem(self, path
-        
-        Return the item whith the path "path", it can return a Paned instance
-        or a View instance
+    def getItem(self,pane_path):
+        """def getItem(self, pane_path)
+        
+        Return the item whith the path "pane_path", it can return a Paned
+        instance or a View instance
         """
         _item = self.__main_item
-        if len(path) == 1:
+        if len(pane_path) == 1:
             return _item
         else:
-            return _item.getItem(path[1:])
+            return _item.getItem(pane_path[1:])
 
-    def setMainItem(self, item):
-        """setMainItem(self,item)
+    def _setMainItem(self, item):
+        """_setMainItem(self,item)
         
         Sets a new main item in the page
         """
@@ -688,46 +890,46 @@
         _main_widget.show()
         self.__widget.pack_start(_main_widget, True, True, 0)
 
-    def _splitItem(self, path, orientation):
-        """_splitItem(self, path, orientation)
-        
-        Splits the item that is identifies by the path and the orientation
+    def _splitItem(self, pane_path, orientation):
+        """_splitItem(self, pane_path, orientation)
+        
+        Splits the item that is identifies by the pane_path and the orientation
         """
-        _item = self.getItem(path)
-        _parent = self.getItem(path[:-1])
-        _item.setPath(path+ (0,))
-        _item_clone0 = _item.getClone(path + (0,))
-        _item_clone1 = _item.getClone(path + (1,))
-        _paned = Paned(orientation, path, _item_clone0, _item_clone1)
-        if len(path) > 1:
-            _parent.setItem(path[-1], [_paned])
+        _item = self.getItem(pane_path)
+        _parent = self.getItem(pane_path[:-1])
+        _item.setPath(pane_path+ (0,))
+        _item_clone0 = _item.getClone(pane_path + (0,))
+        _item_clone1 = _item.getClone(pane_path + (1,))
+        _paned = Paned(orientation, pane_path, _item_clone0, _item_clone1)
+        if len(pane_path) > 1:
+            _parent.setItem(pane_path[-1], [_paned])
         else:
-            self.setMainItem(_paned)
-        
-    def _closeItem(self, path):
-        """_closeItem(self, path)
-        
-        Closes the item that is identifies by the path
+            self._setMainItem(_paned)
+        
+    def _closeItem(self, pane_path):
+        """_closeItem(self, pane_path)
+        
+        Closes the item that is identifies by the pane_path
         """
-        _item = self.getItem(path)
-        if len(path) > 1:
+        _item = self.getItem(pane_path)
+        if len(pane_path) > 1:
             # There are more than one item
-            _parent = self.getItem(path[:-1])
+            _parent = self.getItem(pane_path[:-1])
             _brothers = [ _brother for _brother in _parent]
             _brothers.remove(_item)
             _brother = _brothers[0]
             
             _parent.widget.remove(_brother.widget)
-            _brother.path = path[:-1]
-            if len(path) > 2:
-                _grandparent = self.getItem(path[:-2])
-                _grandparent.setItem(path[-2], [_brother])
+            _brother.pane_path = pane_path[:-1]
+            if len(pane_path) > 2:
+                _grandparent = self.getItem(pane_path[:-2])
+                _grandparent.setItem(pane_path[-2], [_brother])
                 _parent.widget.destroy()
                 _parent.clear()
                 _item.clear()
             else:
                 _grandparent = self
-                _grandparent.setMainItem(_brother)
+                _grandparent._setMainItem(_brother)
                 _parent.widget.destroy()
                 _parent.clear()
                 _item.clear()
@@ -735,8 +937,8 @@
             # Thre is only one item in the page, it can not be closed
             pass
 
-    def itemsFactory(self, list_paned, path=(0,)):
-        """def itemsFactory(self, list_paned, path(0,))
+    def _itemsFactory(self, list_paned, pane_path=(0,)):
+        """def _itemsFactory(self, list_paned, pane_path(0,))
         
         list_paned: list in "__panes_list" format
             [ "v" or "h", panel1_type, panel2_type]
@@ -748,7 +950,7 @@
                 * "Sheet of Conditions"
                 * "FileView"
                 * "CompanyView"
-        path: tuple that represents the item path in the page
+        pane_path: tuple that represents the item path in the page
         
         Creates the items and widgets and returns the main item
         """
@@ -761,26 +963,26 @@
                 list_paned[1] = [list_paned[1]]
             if not isinstance(list_paned[2],list):
                 list_paned[2] = [list_paned[2]]
-            _item1 = self.itemsFactory(list_paned[1],path + (0,))
-            _item2 = self.itemsFactory(list_paned[2],path + (1,)) 
-            _item = Paned(list_paned[0], path, _item1, _item2)
+            _item1 = self._itemsFactory(list_paned[1],pane_path + (0,))
+            _item2 = self._itemsFactory(list_paned[2],pane_path + (1,)) 
+            _item = Paned(list_paned[0], pane_path, _item1, _item2)
         elif list_paned[0] == "DecompositionList":
             _item = View( "DecompositionList", self.__budget,
-                weakref.ref(self), path, self.__active_path_record)
+                weakref.ref(self), pane_path, self.__active_path_record)
         elif list_paned[0] == "RecordDescription":
             _item = View( "RecordDescription", self.__budget,weakref.ref(self),
-                path, self.__active_path_record)
+                pane_path, self.__active_path_record)
         elif list_paned[0] == "Measure":
-            _item = View( "Measure", self.__budget, weakref.ref(self), path,
+            _item = View( "Measure", self.__budget, weakref.ref(self), pane_path,
                 self.__active_path_record)
         elif list_paned[0] == "Sheet of Conditions":
-            _item  = Sheet(sef.__budget, weakref.ref(self), path,
+            _item  = Sheet(sef.__budget, weakref.ref(self), pane_path,
                 self.__active_path_record)
         elif list_paned[0] == "FileView":
-            _item  = FileView(sef.__budget, weakref.ref(self), path,
+            _item  = FileView(sef.__budget, weakref.ref(self), pane_path,
                 self.__active_path_record)
         elif list_paned[0] == "CompanyView":
-            _item  = CompanyView(sef.__budget, weakref.ref(self), path,
+            _item  = CompanyView(sef.__budget, weakref.ref(self), pane_path,
                 self.__active_path_record)
         else:
             _item = None
@@ -788,23 +990,75 @@
                   (str(list_paned[0]),))
         return _item
 
-    def setActivePathRecord(self, path_record):
-        """def setActivePathRecord(self, path_record)
+    def _setActivePathRecord(self, path_record):
+        """def _setActivePathRecord(self, path_record)
         
         path_record: the active record path
         
         Sets the active record path
         """
-        if self.__budget.hasPath(path_record):
-            self.__active_path_record = path_record
+        if path_record != self.__active_path_record:
+            if self.__budget.hasPath(path_record):
+                self.__active_path_record = path_record
+                self._appendHistory(path_record)
+            else:
+                raise ValueError, utils.mapping(_("The budget does not have "\
+                    "the path record: $1"), (str(path_record),))
+    def _appendHistory(self, path):
+        """def _appendHistory(self, path))
+        
+        path: the old active path record
+        
+        Sets the old active path record
+        """
+        if len(self.__history_back) > 1 and self.__history_back[-2] == path:
+            # append forward history and pop back history
+            _path = self.__history_back.pop()
+            self.__history_forward.append(_path)
+            if len(self.__history_forward) > 1000:
+                self.__history_forward.pop(0)
         else:
-            raise ValueError, utils.mapping(_("The budget does not have the "\
-                  "path record: $1"), (str(path_record),))
+            # append back history and pop or delete forward history
+            if len(self.__history_forward) > 1 and \
+               self.__history_forward[-1] == path:
+                self.__history_forward.pop()
+            else:
+                self.__history_forward[:] = []
+            self.__history_back.append(path)
+            if len(self.__history_back) > 1000:
+                self.__history_back.pop(0)
+
+    def getActivePathRecord(self):
+        """def getActivePathRecord(self)
+        
+        Return the Active Path Record
+        """
+        return self.__active_path_record
+    
+    def getPreviousPathRecord(self):
+        """def getPreviousPathRecord(self)
+        
+        Return the Previous Path Record
+        """
+        if len(self.__history_back) > 1: 
+            return self.__history_back[-2]
+        else:
+            return None
+
+    def getPosteriorPathRecord(self):
+        """def getPosteriorPathRecord(self)
+        
+        Return the Posterior Path Record
+        """
+        if len(self.__history_forward) > 0: 
+            return self.__history_forward[-1]
+        else:
+            return None
 
     def getTitle(self):
-        """def getTtle(self)
-        
-        Return the title of the page, a gtk.Label objetc
+        """def getTitle(self)
+        
+        Return the page title, a gtk.Label objetc
         """
         return self.__title
     
@@ -828,12 +1082,12 @@
             self.clear()
             return
         self.__budget = budget
-        self.setActivePathRecord((0,))
-        ## Todo: change page title
+        self._setActivePathRecord((0,))
+        # Todo: change page title
         self.__title = gtk.Label(self.__budget.getCode(
                        self.__active_path_record))
         _panes_list = self.__panes_list
-        self.__main_item = self.itemsFactory(_panes_list)
+        self.__main_item = self._itemsFactory(_panes_list)
         _main_widget = self.__main_item.getWidget()
         _main_widget.show()
         self.__widget.pack_start(_main_widget, True, True, 0)
@@ -860,6 +1114,12 @@
                       "Page Title")
     panes_list = property(getPanesList, None, None,
                       "Info list for create the panes")
+    activePathRecord = property(getActivePathRecord, None, None,
+                      "Active Path Record")
+    previousPathRecord = property(getPreviousPathRecord, None, None,
+                      "Previous Active Path Record")
+    posteriorPathRecord = property(getPosteriorPathRecord, None, None,
+                      "Posterior Active Path Record")
 
 class View(object):
     """gui.View:
@@ -4399,4 +4659,6 @@
         
         return the main widget (gtk.ScrolledWindow)
         """
-        return self.__widget
\ No newline at end of file
+        return self.__widget
+    widget = property(getWidget, None, None,
+        "main widget")
\ No newline at end of file