diff Gtk/gui.py @ 4:4e976a99efb9

update ImportPriceDatabase
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Sun, 31 Oct 2010 23:12:06 +0100
parents a221c14c3c31
children 6502bfdaa84d
line wrap: on
line diff
--- a/Gtk/gui.py	Sun Oct 31 21:01:48 2010 +0100
+++ b/Gtk/gui.py	Sun Oct 31 23:12:06 2010 +0100
@@ -104,7 +104,6 @@
         _menuitemOpenPriceDatabase(self, widget)
         _menuitemOpen
         _menuitemClose(self, widget)
-        _menuitemText(self, widget)
         _delete_event(self, widget, event)
         _destroy(self, widget)
     """
@@ -224,34 +223,6 @@
         self.__notebook.append_page(_page.widget, _page.title)
         self.__page_list.append(_page)
 
-    def _testBudgetList2(self):
-        """def _testBudgetList2(self)
-        
-        Test if the number of budgets ("__budget_list") is greater
-        than the number of pages ("__page_list"), if it is greater 
-        appendPage method is called to create a page to show the new budget
-        and save the budget in a durus file.
-        """
-        if len(self.__budget_list) > len(self.__page_list):
-            self._appendPage()
-            #-# in test mode
-            # TODO: It must be in a thread
-            _last_budget = self.__budget_list[-1]
-            _path = globals.getHomePath("DURUS-DATABASE")
-            _file_whit_path_bc3 = _last_budget.filename
-            _filename_bc3 = _file_whit_path_bc3.split("/")[-1]
-            _filename = _filename_bc3.split(".")[-2]
-            _file = _path + _filename + ".durus"
-            print utils.mapping(_("Saving file: $1"), (_file,))
-            _time = time.time()
-            _durus_file = durusdatabase.DurusFile(_file,True)
-            _durus_file.setBudget(_last_budget)
-            _durus_file.close()
-            print utils.mapping(_("Saving time: $1 seconds"),
-                  (("%.2f" %(time.time()-_time) ),))
-            #-#
-            return False
-        return True
 
     def _menuitemImportFiebdc(self, widget):
         """def _menuitemImportFiebdc(self, widget)
@@ -268,9 +239,10 @@
         _budget_file = fiebdc.Read()
         _read_method = _budget_file.readFile
         _filename = "file"
+        _filetype = "budget"
         _exit_method = _budget_file.cancel
         _file_window = importFiebdc.FileSelectionWindow(self,
-            _read_method, _budget, _filename, _exit_method)
+            _read_method, _budget, _filename, _exit_method, _filetype)
 
     def _menuitemImportPriceDatabase(self, widget):
         """def _menuitemImportPriceDatabase(self, widget)
@@ -282,25 +254,21 @@
         
         Creates and shows a window to open a budget file.
         """
-        #TODO: change timeout, it is deprecated
-        #TODO: the .durus file must be direted saved
-        gobject.timeout_add(100, self._testBudgetList2)
         _budget = base.Budget()
         self.__budget_temp_list.append(_budget)
         _budget_file = fiebdc.Read()
         _read_method = _budget_file.readFile
         _filename = "file"
+        _filetype = "basedate"
         _exit_method = _budget_file.cancel
         _file_window = importFiebdc.FileSelectionWindow(self,
-            _read_method, _budget, _filename, _exit_method)
+            _read_method, _budget, _filename, _exit_method, _filetype)
 
     def _menuitemOpenPriceDatabase(self, widget):
-        """def _menuitemImportPriceDatabase(self, widget)
+        """def _menuitemOpenPriceDatabase(self, widget)
         
         widget: the widget where the event is emitted from
         Callback to open a budget file.
-        Inits a timeout to test if a budgets is appended to "__budget_list"
-        calling _testBudgetList method if it is true.
         
         Creates and shows a window to open a budget file.
         """
@@ -382,15 +350,16 @@
     """
     """
     def __init__(self, mainWindow, readFileMethod, budget, filename,
-                 cancelMethod):
+                 cancelMethod, filetype):
         """def __init__(self, mainWindow, readFileMethod, budget, filename,
-                        cancelMethod)
+                        cancelMethod, filetype)
         
         """
         self.__mainWindow = mainWindow
         self.__readFileMethod = readFileMethod
         self.__budget = budget
         self.__filename = filename
+        self.__filetype = filetype
         self.__cancelMethod = cancelMethod
         self.__children = None
         self.__cancel = [False, False]
@@ -465,7 +434,7 @@
         if self.__children is None:
             self.__children = importFiebdc.Thread(self, self.__mainWindow,
                 self.__readFileMethod, self.__budget, self.__filename,
-                self.__cancelMethod)
+                self.__cancelMethod, self.__filetype)
             self.__children.start()
 
     def _launchTimeout(self):