comparison Gtk/gui.py @ 8:55df0b15706b

Docstrings and names in GTK/gui.py
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Wed, 17 Nov 2010 21:05:56 +0100
parents 0359329a1c26
children 229986217a3d
comparison
equal deleted inserted replaced
7:0359329a1c26 8:55df0b15706b
30 have 2 viewes represented for the View class or other gtk.Paned that have other 30 have 2 viewes represented for the View class or other gtk.Paned that have other
31 viewes or more gtk.Paned. 31 viewes or more gtk.Paned.
32 The view can have diferente type of widgets to show the budget information. 32 The view can have diferente type of widgets to show the budget information.
33 The DecompositionList class show the decompositon list information of a record 33 The DecompositionList class show the decompositon list information of a record
34 The Measure class show the measure information of a record 34 The Measure class show the measure information of a record
35 The TextWindow class show the long description of a record
36 The Sheet class class show the sheet of condition information of a record 35 The Sheet class class show the sheet of condition information of a record
37 36
38 The views can send signal to the others. 37 The views can send signal to the others.
39 All the viewes ordered in panes can be or not be connected to the others, 38 All the viewes ordered in panes can be or not be connected to the others,
40 if there are connecteded to the others when the user change the active code in 39 if there are connecteded to the others when the user change the active code in
72 # Autodetect desktop 71 # Autodetect desktop
73 if globalVars.desktop["autodetect"]: 72 if globalVars.desktop["autodetect"]:
74 openwith.autodetect_desktop() 73 openwith.autodetect_desktop()
75 print utils.mapping(_("pyArq-Presupuestos running on $1"), 74 print utils.mapping(_("pyArq-Presupuestos running on $1"),
76 (globalVars.desktop["desktop"],)) 75 (globalVars.desktop["desktop"],))
76
77 77
78 class MainWindow(object): 78 class MainWindow(object):
79 """gui.MainWindow: 79 """gui.MainWindow:
80 80
81 Description: 81 Description:
85 gui.MainWindow() 85 gui.MainWindow()
86 Ancestry: 86 Ancestry:
87 +-- object 87 +-- object
88 +-- MainWindow 88 +-- MainWindow
89 Atributes: 89 Atributes:
90 "window": Main window widget ("gtk.Window" object) 90 notebook: Read. notebook widget
91 pageList: Read. page list
92 budgetList: Read. budget list
91 Methods: 93 Methods:
92 removePage 94 removePage
93 getNotebook
94 getPageList
95 getBudgetList
96 """ 95 """
97 # TODO:* Can choose open budget in new window 96 # TODO:* Can choose open budget in new window
98 # TODO:* gtk.Action for menu and toolbar 97 # TODO:* gtk.Action for menu and toolbar
99 # TODO:* Can choose show more than one notebook in the same window or 98 # TODO:* Can choose show more than one notebook in the same window or
100 # TODO: can show basedata notebook in a side pane 99 # TODO: can show basedata notebook in a side pane
129 <toolitem action="GoToRoot"/> 128 <toolitem action="GoToRoot"/>
130 </toolbar> 129 </toolbar>
131 </ui>''' 130 </ui>'''
132 131
133 def __init__(self): 132 def __init__(self):
134 """def __init__(self) 133 """__init__()
135 134
136 Initialize the atributes "__budget_list" and "__page_list" without data. 135 Initialize the atributes "__budget_list" and "__page_list" without data.
137 Creates the widgets "window" and "__notebook". 136 Creates the widgets "window" and "__notebook".
138 137
138 self.__window: gtk.Window object
139 self.__budget_temp_list: Temporal list of budgets 139 self.__budget_temp_list: Temporal list of budgets
140 self.__budget_list: List of budgets ("base.Budget" objects) 140 self.__budget_list: List of budgets ("base.Budget" objects)
141 self.__page_list: List of pages ("Page" object) 141 self.__page_list: List of pages ("Page" object)
142 self.__notebook: Notebook widget ("gtk.Notebook" object) 142 self.__notebook: Notebook widget ("gtk.Notebook" object)
143 self.__general_action_group: "General" action group 143 self.__general_action_group: "General" action group
145 #TODO: action group for Navigation buttons 145 #TODO: action group for Navigation buttons
146 self.__budget_temp_list = [] 146 self.__budget_temp_list = []
147 self.__budget_list = [] 147 self.__budget_list = []
148 self.__page_list = [] 148 self.__page_list = []
149 # Main window 149 # Main window
150 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) 150 self.__window = gtk.Window(gtk.WINDOW_TOPLEVEL)
151 self.window.set_default_size(771, 570) 151 self.__window.set_default_size(771, 570)
152 self.window.set_title("Presupuestos") 152 self.__window.set_title("Presupuestos")
153 self.window.set_border_width(0) 153 self.__window.set_border_width(0)
154 self.window.connect("destroy", self._destroy) 154 self.__window.connect("destroy", self._destroy)
155 self.window.connect("delete_event", self._delete_event) 155 self.__window.connect("delete_event", self._delete_event)
156 # Vertical box 156 # Vertical box
157 _vbox1 = gtk.VBox(False, 0) 157 _vbox1 = gtk.VBox(False, 0)
158 self.window.add(_vbox1) 158 self.__window.add(_vbox1)
159 _vbox1.show() 159 _vbox1.show()
160 #Uimanager 160 #Uimanager
161 _uimanager = gtk.UIManager() 161 _uimanager = gtk.UIManager()
162 _accelgroup = _uimanager.get_accel_group() 162 _accelgroup = _uimanager.get_accel_group()
163 self.window.add_accel_group(_accelgroup) 163 self.__window.add_accel_group(_accelgroup)
164 _general_action_group = gtk.ActionGroup("General") 164 _general_action_group = gtk.ActionGroup("General")
165 self.__general_action_group = _general_action_group 165 self.__general_action_group = _general_action_group
166 _general_action_group.add_actions( 166 _general_action_group.add_actions(
167 [("File", None, _("_File"), None), 167 [("File", None, _("_File"), None),
168 ("ImportFiebdc", gtk.STOCK_OPEN, _('_Import Fiebdc'), "", 168 ("ImportFiebdc", gtk.STOCK_OPEN, _('_Import Fiebdc'), "",
203 self.__notebook.set_show_tabs(True) 203 self.__notebook.set_show_tabs(True)
204 self.__notebook.set_show_border(True) 204 self.__notebook.set_show_border(True)
205 self.__notebook.set_scrollable(True) 205 self.__notebook.set_scrollable(True)
206 self.__notebook.show() 206 self.__notebook.show()
207 self._main() 207 self._main()
208 208
209 def _main(self): 209 def _main(self):
210 """def main(self) 210 """main()
211 211
212 Shows window and starts the GTK+ event processing loop. 212 Shows window and starts the GTK+ event processing loop.
213 """ 213 """
214 self.window.show() 214 self.__window.show()
215 gtk.main() 215 gtk.main()
216 216
217 def _addBudget(self, budget): 217 def _addBudget(self, budget):
218 """def _addBudget(self, budget) 218 """_addBudget(budget)
219 219
220 budget: "base.Budget" object 220 budget: "base.Budget" object
221 221
222 Appends a budget in the "__budget_list" 222 Appends a budget in the "__budget_list"
223 """ 223 """
226 if _budget in self.__budget_temp_list: 226 if _budget in self.__budget_temp_list:
227 self.__budget_temp_list.remove(_budget) 227 self.__budget_temp_list.remove(_budget)
228 self.__budget_list.append(_budget) 228 self.__budget_list.append(_budget)
229 229
230 def _appendPage(self): 230 def _appendPage(self):
231 """def _appendPage(self) 231 """_appendPage()
232 232
233 Creates a new page (instance of "Page class") from the last budget in 233 Creates a new page (instance of "Page class") from the last budget in
234 __budget_list, appends this page in the "__page_list" and shows the 234 __budget_list, appends this page in the "__page_list" and shows the
235 page widget in the notebook widget. 235 page widget in the notebook widget.
236 """ 236 """
239 self.__notebook.append_page(_page.widget, _page.title) 239 self.__notebook.append_page(_page.widget, _page.title)
240 self.__page_list.append(_page) 240 self.__page_list.append(_page)
241 241
242 242
243 def _menuitemImportFiebdc(self, widget): 243 def _menuitemImportFiebdc(self, widget):
244 """def _menuitemImportFiebdc(self, widget) 244 """_menuitemImportFiebdc(widget)
245 245
246 widget: the widget where the event is emitted from 246 widget: the widget where the event is emitted from
247 Callback to open a budget file. 247 Callback to open a budget file.
248 248
249 Creates and shows a file selection window to open a budget file. 249 Creates and shows a file selection window to open a budget file.
257 _exit_method = _budget_file.cancel 257 _exit_method = _budget_file.cancel
258 _file_window = importFiebdc.FileSelectionWindow(self, 258 _file_window = importFiebdc.FileSelectionWindow(self,
259 _read_method, _budget, _filename, _exit_method, _filetype) 259 _read_method, _budget, _filename, _exit_method, _filetype)
260 260
261 def _menuitemImportPriceDatabase(self, widget): 261 def _menuitemImportPriceDatabase(self, widget):
262 """def _menuitemImportPriceDatabase(self, widget) 262 """_menuitemImportPriceDatabase(widget)
263 263
264 widget: the widget where the event is emitted from 264 widget: the widget where the event is emitted from
265 Callback to open a price database file. 265 Callback to open a price database file.
266 266
267 Creates and shows a file selection window to open a price database file. 267 Creates and shows a file selection window to open a price database file.
275 _exit_method = _budget_file.cancel 275 _exit_method = _budget_file.cancel
276 _file_window = importFiebdc.FileSelectionWindow(self, 276 _file_window = importFiebdc.FileSelectionWindow(self,
277 _read_method, _budget, _filename, _exit_method, _filetype) 277 _read_method, _budget, _filename, _exit_method, _filetype)
278 278
279 def _menuitemOpenPriceDatabase(self, widget): 279 def _menuitemOpenPriceDatabase(self, widget):
280 """def _menuitemOpenPriceDatabase(self, widget) 280 """_menuitemOpenPriceDatabase(widget)
281 281
282 widget: the widget where the event is emitted from 282 widget: the widget where the event is emitted from
283 Callback to open a price database from a durus file. 283 Callback to open a price database from a durus file.
284 284
285 Creates and shows a file selection window to open a durus database 285 Creates and shows a file selection window to open a durus database
293 _exit_method = _budget_file.cancel 293 _exit_method = _budget_file.cancel
294 _file_window = importFiebdc.FileSelectionWindow(self, 294 _file_window = importFiebdc.FileSelectionWindow(self,
295 _read_method, _budget, _filename, _exit_method, _filetype) 295 _read_method, _budget, _filename, _exit_method, _filetype)
296 296
297 def _menuitemClose(self, widget): 297 def _menuitemClose(self, widget):
298 """def _menuitemClose(self, widget) 298 """_menuitemClose(widget)
299 299
300 widget: the widget where the event is emitted from 300 widget: the widget where the event is emitted from
301 301
302 Callback to close a budget file. 302 Callback to close a budget file.
303 """ 303 """
308 print _("Cancel reading Durus database has not been implemented.") 308 print _("Cancel reading Durus database has not been implemented.")
309 else: 309 else:
310 _page.close() 310 _page.close()
311 311
312 def removePage(self, page_num): 312 def removePage(self, page_num):
313 """def removePage(self, page_num) 313 """removePage(page_num)
314 314
315 page_num: The number Page to be removed 315 page_num: The number Page to be removed
316 316
317 Removes a page from notebook and page_list. 317 Removes a page from notebook and page_list.
318 Removes the budget from the budget_list if necessary. 318 Removes the budget from the budget_list if necessary.
324 self.__page_list.pop(page_num) 324 self.__page_list.pop(page_num)
325 _page.clear() 325 _page.clear()
326 self.__notebook.remove_page(page_num) 326 self.__notebook.remove_page(page_num)
327 327
328 def _menuitemGoToRoot(self, widget): 328 def _menuitemGoToRoot(self, widget):
329 """def _menuitemGoToRoot(self, widget) 329 """_menuitemGoToRoot(widget)
330 330
331 widget: the widget where the event is emitted from 331 widget: the widget where the event is emitted from
332 332
333 Callback to go to root record. 333 Callback to go to root record.
334 """ 334 """
339 if isinstance(_page, Page): 339 if isinstance(_page, Page):
340 #not loading budget 340 #not loading budget
341 _page.propagateMessageFrom("change_active", (-1,), (0,)) 341 _page.propagateMessageFrom("change_active", (-1,), (0,))
342 342
343 def _menuitemGoUp(self, widget): 343 def _menuitemGoUp(self, widget):
344 """def _menuitemGoUp(self, widget) 344 """_menuitemGoUp(widget)
345 345
346 widget: the widget where the event is emitted from 346 widget: the widget where the event is emitted from
347 347
348 Callback to go to up record. 348 Callback to go to up record.
349 """ 349 """
359 if _budget.hasPath(_up_path): 359 if _budget.hasPath(_up_path):
360 _page.propagateMessageFrom("change_active", (-1,), 360 _page.propagateMessageFrom("change_active", (-1,),
361 _up_path) 361 _up_path)
362 362
363 def _menuitemGoDown(self, widget): 363 def _menuitemGoDown(self, widget):
364 """def _menuitemGoToDown(self, widget) 364 """_menuitemGoToDown(widget)
365 365
366 widget: the widget where the event is emitted from 366 widget: the widget where the event is emitted from
367 367
368 Callback to go to down record. 368 Callback to go to down record.
369 """ 369 """
379 if _budget.hasPath(_up_path): 379 if _budget.hasPath(_up_path):
380 _page.propagateMessageFrom("change_active", (-1,), 380 _page.propagateMessageFrom("change_active", (-1,),
381 _up_path) 381 _up_path)
382 382
383 def _menuitemGoPrevious(self, widget): 383 def _menuitemGoPrevious(self, widget):
384 """def _menuitemGoPrevious(self, widget) 384 """_menuitemGoPrevious(widget)
385 385
386 widget: the widget where the event is emitted from 386 widget: the widget where the event is emitted from
387 387
388 Callback to go to previous record. 388 Callback to go to previous record.
389 """ 389 """
398 if _budget.hasPath(_previous_path): 398 if _budget.hasPath(_previous_path):
399 _page.propagateMessageFrom("change_active", (-1,), 399 _page.propagateMessageFrom("change_active", (-1,),
400 _previous_path) 400 _previous_path)
401 401
402 def _menuitemGoPosterior(self, widget): 402 def _menuitemGoPosterior(self, widget):
403 """def _menuitemPosterior(self, widget) 403 """_menuitemPosterior(widget)
404 404
405 widget: the widget where the event is emitted from 405 widget: the widget where the event is emitted from
406 406
407 Callback to go to posterior record. 407 Callback to go to posterior record.
408 """ 408 """
417 if _budget.hasPath(_posterior_path): 417 if _budget.hasPath(_posterior_path):
418 _page.propagateMessageFrom("change_active", (-1,), 418 _page.propagateMessageFrom("change_active", (-1,),
419 _posterior_path) 419 _posterior_path)
420 420
421 def _delete_event(self, widget, event): 421 def _delete_event(self, widget, event):
422 """_delete_event(self, widget, event) 422 """_delete_event(widget, event)
423 423
424 widget: the widget where the event is emitted from 424 widget: the widget where the event is emitted from
425 event: the "gtk.gdk.Event" 425 event: the "gtk.gdk.Event"
426 426
427 Method connected to "delete_event" signal of main window widget 427 Method connected to "delete_event" signal of main window widget
431 for _page in self.__page_list: 431 for _page in self.__page_list:
432 _page.clear() 432 _page.clear()
433 return False # -> destroy 433 return False # -> destroy
434 434
435 def _destroy(self, widget): 435 def _destroy(self, widget):
436 """_destroy(self, widget) 436 """_destroy(widget)
437 437
438 widget: the widget where the event is emitted from 438 widget: the widget where the event is emitted from
439 Method connected to "destroy" signal of main window widget 439 Method connected to "destroy" signal of main window widget
440 440
441 This signal is emited when the method connected to "delete_event" 441 This signal is emited when the method connected to "delete_event"
443 the gtk.Window widget. 443 the gtk.Window widget.
444 The window is closed and the GTK+ event processing loop is ended. 444 The window is closed and the GTK+ event processing loop is ended.
445 """ 445 """
446 gtk.main_quit() 446 gtk.main_quit()
447 447
448 def getNotebook(self): 448 def _getNotebook(self):
449 """def getNotebook(self) 449 """_getNotebook()
450 450
451 Return the notebook widget 451 Return the notebook widget
452 """ 452 """
453 return self.__notebook 453 return self.__notebook
454 454
455 def getPageList(self): 455 def _getPageList(self):
456 """def getPageList(self) 456 """_getPageList()
457 457
458 Return the page list 458 Return the page list
459 """ 459 """
460 return self.__page_list 460 return self.__page_list
461 461
462 def getBudgetList(self): 462 def _getBudgetList(self):
463 """def getBudgetList(self) 463 """_getBudgetList()
464 464
465 Return the budget list 465 Return the budget list
466 """ 466 """
467 return self.__budget_list 467 return self.__budget_list
468
469 notebook = property(_getNotebook, None, None,
470 "notebook object")
471 pageList = property(_getPageList, None, None,
472 "Page list")
473 budgetList = property(_getBudgetList, None, None,
474 "Budget list")
475
468 476
469 class EmptyPage(object): 477 class EmptyPage(object):
470 """gui.EmptyPage: 478 """gui.EmptyPage:
471 479
472 Description: 480 Description:
473 It creates and shows a page in the notebook while a budget is loaded. 481 It creates and shows a page in the notebook while a budget is loaded.
474 The page show the pyarq logo, loading time and a progress bar. 482 The page show the pyarq logo, loading time and a progress bar.
475 Constructor: 483 Constructor:
476 gui.EmptyPage(self, mainWindow, readFileMethod, budget, filename, 484 gui.EmptyPage(mainWindow, readFileMethod, budget, filename,
477 cancelMethod, filetype): 485 cancelMethod, filetype):
486 mainWindow: gui.Mainwindow object
487 readFileMethod: Method to read the selected file
488 budget: base.Budget object
489 filename: "file"
490 cancelMethod: Method to cancel the read method
491 filetype: "budget", "database" or "durus"
478 Ancestry: 492 Ancestry:
479 +-- object 493 +-- object
480 +-- EmptyPage 494 +-- EmptyPage
481 Atributes: 495 Atributes:
482 __mainWindow: gui.Mainwindow object 496 widget: Read. Main widget showed in the pane
483 __readFileMethod: Method to read the selected file 497 title: Read. Page Title
484 __budget: base.Budget object 498 filetype: Read. budget, basedata or durus
485 __filename: "file"
486 __cancelMethod: Method to cancel the read method
487 __filetype: "budget", "database" or "durus"
488 __children: the read thread
489 __progress: 0 to 1 progress
490 __widget: main widget, a gtk.VBox object
491 __main_item: None
492 __throbber: a gtk.Image
493 __animationThobber: a gtk.gdk.PixbufAnimation
494 __quietThobber: a pixbuf
495 __budget_icon: a gtk.gdk.pixbuf
496 __title: a gtk.HBox
497 __statusbar: a gtk.Statusbar
498 __statuscontext: the statusbar context
499 __progress_bar: a gtk.ProgressBar
500
501 Methods: 499 Methods:
502 __init__
503 run 500 run
504 progress 501 progress
505 stopLoading 502 stopLoading
506 _launchChildren
507 _launchTimeout
508 _updateProgressBar
509 _updateLabel
510 _autoClose
511 threadFinishedSignal 503 threadFinishedSignal
512 threadCanceled 504 threadCanceled
513 close 505 close
514 clear 506 clear
515 getWidget
516 getTitle
517 getFiletype
518 """ 507 """
508
519 def __init__(self, mainWindow, readFileMethod, budget, filename, 509 def __init__(self, mainWindow, readFileMethod, budget, filename,
520 cancelMethod, filetype): 510 cancelMethod, filetype):
521 """def __init__(self, mainWindow, readFileMethod, budget, filename, 511 """__init__(mainWindow, readFileMethod, budget, filename,
522 cancelMethod, filetype) 512 cancelMethod, filetype)
523 513
524 mainWindow: gui.Mainwindow object 514 mainWindow: gui.Mainwindow object
525 readFileMethod: Method to read the selected file 515 readFileMethod: Method to read the selected file
526 budget: base.Budget object 516 budget: base.Budget object
527 filename: "file" 517 filename: "file"
528 cancelMethod: Method to cancel the read method 518 cancelMethod: Method to cancel the read method
529 filetype: "budget", "database" or "durus" 519 filetype: "budget", "database" or "durus"
520
521 self.__mainWindow: gui.Mainwindow object
522 self.__readFileMethod: Method to read the selected file
523 self.__budget: base.Budget object
524 self.__filename: "file"
525 self.__cancelMethod: Method to cancel the read method
526 self.__filetype: "budget", "database" or "durus"
527 self.__children: the read thread
528 self.__progress: 0 to 1 progress
529 self.__widget: main widget, a gtk.VBox object
530 self.__main_item: None
531 self.__throbber: a gtk.Image
532 self.__animationThobber: a gtk.gdk.PixbufAnimation
533 self.__quietThobber: a pixbuf
534 self.__budget_icon: a gtk.gdk.pixbuf
535 self.__title: a gtk.HBox
536 self.__statusbar: a gtk.Statusbar
537 self.__statuscontext: the statusbar context
538 self.__progress_bar: a gtk.ProgressBar
530 """ 539 """
531 self.__mainWindow = mainWindow 540 self.__mainWindow = mainWindow
532 self.__readFileMethod = readFileMethod 541 self.__readFileMethod = readFileMethod
533 self.__budget = budget 542 self.__budget = budget
534 self.__filename = filename 543 self.__filename = filename
584 self.__statusbar.pack_start(_progressframe, False, False, 0) 593 self.__statusbar.pack_start(_progressframe, False, False, 0)
585 self.__widget.pack_end(self.__statusbar, False, True, 0) 594 self.__widget.pack_end(self.__statusbar, False, True, 0)
586 self.__main_item = None 595 self.__main_item = None
587 596
588 def run(self): 597 def run(self):
598 """run()
599
600 Launch clildren and timeouts
601 """
589 self.__statusbar.push(self.__statuscontext, _("Time: 0s")) 602 self.__statusbar.push(self.__statuscontext, _("Time: 0s"))
590 self.__throbber.set_from_animation(self.__animationThobber) 603 self.__throbber.set_from_animation(self.__animationThobber)
591 self._launchChildren() 604 self._launchChildren()
592 self._launchTimeout() 605 self._launchTimeout()
593 606
594 def progress(self, percent): 607 def progress(self, percent):
608 """progress(percent)
609
610 percent: Percentage executed.
611
612 Sets progress
613 """
595 _progress = str(int(round(100 * percent,0))) 614 _progress = str(int(round(100 * percent,0)))
596 self.__progress = percent 615 self.__progress = percent
597 616
598 def stopLoading(self): 617 def stopLoading(self):
618 """stopLoading()
619
620 Stop progressbar
621 """
599 self.__throbber.set_from_pixbuf(self.__budget_icon) 622 self.__throbber.set_from_pixbuf(self.__budget_icon)
600 self.__progress_bar.hide() 623 self.__progress_bar.hide()
601 self.__statusbar.pop(self.__statuscontext) 624 self.__statusbar.pop(self.__statuscontext)
602 625
603 def _launchChildren(self): 626 def _launchChildren(self):
604 """_launchChildren(self) 627 """_launchChildren()
605 628
606 Launch the thread to read the file 629 Launch the thread to read the file
607 """ 630 """
608 if self.__children is None: 631 if self.__children is None:
609 self.__children = importFiebdc.Thread(self, self.__mainWindow, 632 self.__children = importFiebdc.Thread(self, self.__mainWindow,
610 self.__readFileMethod, self.__budget, self.__filename, 633 self.__readFileMethod, self.__budget, self.__filename,
611 self.__cancelMethod, self.__filetype) 634 self.__cancelMethod, self.__filetype)
612 self.__children.start() 635 self.__children.start()
613 636
614 def _launchTimeout(self): 637 def _launchTimeout(self):
615 """def _launchTimeout(self) 638 """_launchTimeout()
616 639
617 Launch the timeouts: 640 Launch the timeouts:
618 1- update progress bar 641 1- update progress bar
619 2- update time label 642 2- update time label
620 3- If the other timetouts are stoped the window is closed 643 3- If the other timetouts are stoped the window is closed
626 else: 649 else:
627 self.__cancel = [True, False] 650 self.__cancel = [True, False]
628 gobject.timeout_add(1000, self._autoClose) 651 gobject.timeout_add(1000, self._autoClose)
629 652
630 def _updateProgressBar(self): 653 def _updateProgressBar(self):
631 """def _updateProgressBar(self) 654 """_updateProgressBar()
632 655
633 update progress bar in a timeout 656 update progress bar in a timeout
634 If the thread end or is canceled the timeout is stoped 657 If the thread end or is canceled the timeout is stoped
635 """ 658 """
636 if self.__children is None or self.__children.isCanceled() == True: 659 if self.__children is None or self.__children.isCanceled() == True:
641 _text = "%s%%" %str(int(round(100 * self.__progress,0))) 664 _text = "%s%%" %str(int(round(100 * self.__progress,0)))
642 self.__progress_bar.set_text(_text) 665 self.__progress_bar.set_text(_text)
643 return True 666 return True
644 667
645 def _updateLabel(self, _time): 668 def _updateLabel(self, _time):
646 """def _updateProgressBar(self) 669 """_updateProgressBar(_time)
647 670
648 update time label in a timeout 671 update time label in a timeout
649 If the thread end or is canceled the timeout is stoped 672 If the thread end or is canceled the timeout is stoped
650 """ 673 """
651 if self.__children is None or self.__children.isCanceled() == True: 674 if self.__children is None or self.__children.isCanceled() == True:
657 self.__statusbar.pop(self.__statuscontext) 680 self.__statusbar.pop(self.__statuscontext)
658 self.__statusbar.push(self.__statuscontext, _text) 681 self.__statusbar.push(self.__statuscontext, _text)
659 return True 682 return True
660 683
661 def _autoClose(self): 684 def _autoClose(self):
662 """def _updateProgressBar(self) 685 """_updateProgressBar()
663 686
664 If the time label and progress bar timeouts are stoped the window is 687 If the time label and progress bar timeouts are stoped the window is
665 closed and ist tiemeout is stoped 688 closed and ist tiemeout is stoped
666 """ 689 """
667 if self.__cancel == [ True, True ]: 690 if self.__cancel == [ True, True ]:
668 return False 691 return False
669 else: 692 else:
670 return True 693 return True
671 694
672 def threadFinishedSignal(self, budget): 695 def threadFinishedSignal(self, budget):
673 """def closeWindow(self) 696 """threadFinishedSignal(budget)
674 697
675 Sets the __children atribute to None 698 Sets the self.__children to None
676 This causes that the timeouts is ended. 699 This causes that the timeouts is ended.
677 This method is called from thread when it is finished 700 This method is called from thread when it finish
678 """ 701 """
679 self.__budget = budget 702 self.__budget = budget
680 self.__children = None 703 self.__children = None
681 self.stopLoading() 704 self.stopLoading()
682 _page = Page(self.__mainWindow, self.__budget) 705 _page = Page(self.__mainWindow, self.__budget)
683 _children = self.__widget.get_children() 706 _children = self.__widget.get_children()
684 for _child in _children: 707 for _child in _children:
685 self.__widget.remove(_child) 708 self.__widget.remove(_child)
686 self.__widget.pack_start(_page.widget, True, True, 0) 709 self.__widget.pack_start(_page.widget, True, True, 0)
687 _noteBook = self.__mainWindow.getNotebook() 710 _noteBook = self.__mainWindow.notebook
688 _pageIndex = _noteBook.page_num(self.__widget) 711 _pageIndex = _noteBook.page_num(self.__widget)
689 self.__mainWindow.getPageList()[_pageIndex] = _page 712 self.__mainWindow.pageList[_pageIndex] = _page
713
690 def threadCanceled(self): 714 def threadCanceled(self):
691 """def threadCanceled(self) 715 """threadCanceled()
692 716
693 Sets the __children atribute to None 717 Sets the __children atribute to None
694 This causes that the timeouts is ended. 718 This causes that the timeouts is ended.
695 This method is called from thread when is canceled 719 This method is called from thread when is canceled
696 TODO: it must called threadFinished or somethig 720 TODO: it must called threadFinished or somethig
697 """ 721 """
698 self.__children = None 722 self.__children = None
699 self.stopLoading() 723 self.stopLoading()
700 _page_num = self.__mainWindow.getNotebook().page_num(self.widget) 724 _page_num = self.__mainWindow.notebook.page_num(self.widget)
701 self.__mainWindow.removePage(_page_num) 725 self.__mainWindow.removePage(_page_num)
726
702 def close(self): 727 def close(self):
703 """def close(self) 728 """close()
704 729
705 Clos page canceling children 730 Close page canceling children
706 """ 731 """
707 self.__children.cancel() 732 self.__children.cancel()
733
708 def clear(self): 734 def clear(self):
709 """def clear(self) 735 """clear()
710 736
711 clear vars 737 clear vars
712 """ 738 """
713 pass 739 pass
714 740
715 def getWidget(self): 741 def _getWidget(self):
716 """def getWidget(self) 742 """_getWidget()
717 743
718 Return de main widget to show in the page 744 Return de main widget to show in the page
719 """ 745 """
720 return self.__widget 746 return self.__widget
721 747
722 def getTitle(self): 748 def _getTitle(self):
723 """def getTitle(self) 749 """_getTitle()
724 750
725 Return the title of the page, a gtk.Label objetc 751 Return the title of the page, a gtk.Label objetc
726 """ 752 """
727 return self.__title 753 return self.__title
728 def getFiletype(self): 754
729 """def getFiletipe(self) 755 def _getFiletype(self):
756 """_getFiletipe()
730 757
731 Return the title of the page, a gtk.Label objetc 758 Return the title of the page, a gtk.Label objetc
732 """ 759 """
733 return self.__filetype 760 return self.__filetype
734 761
735 widget = property(getWidget, None, None, 762 widget = property(_getWidget, None, None,
736 "Main widget showed in the pane") 763 "Main widget showed in the pane")
737 title = property(getTitle, None, None, 764 title = property(_getTitle, None, None,
738 "Page Title") 765 "Page Title")
739 filetype = property(getFiletype, None, None, 766 filetype = property(_getFiletype, None, None,
740 "Filetype: budget, basedata or durus") 767 "Filetype: budget, basedata or durus")
768
741 769
742 class Page(object): 770 class Page(object):
743 """gui.Page: 771 """gui.Page:
744 772
745 Description: 773 Description:
753 active_code: Active record code 781 active_code: Active record code
754 Ancestry: 782 Ancestry:
755 +-- object 783 +-- object
756 +-- Page 784 +-- Page
757 Atributes: 785 Atributes:
758 "widget": Read. Notebook page Widget. (a gtk.VBox instance) 786 widget: Read. Notebook page Widget. (a gtk.VBox instance)
759 "budget": Read-Write. Budget to show in the page. (base.obra object) 787 budget: Read-Write. Budget to show in the page. (base.obra object)
760 "panes_list": Read. info list for create the panes 788 panes_list: Read. info list for create the panes
761 ej: [ "v", pane1, pane2 ] , [ "h", pane1, pane2 ] 789 ej: [ "v", pane1, pane2 ] , [ "h", pane1, pane2 ]
762 [ "v", [ "h", pane1, pane2 ], [ "h", pane1, pane2 ] ] 790 [ "v", [ "h", pane1, pane2 ], [ "h", pane1, pane2 ] ]
763 pane types: 791 pane types:
764 * "DecompositionList": its creates a "DecompositionList" object 792 * "DecompositionList": its creates a "DecompositionList" object
765 * "RecordDescription" : its creates a "Description" objetc 793 * "RecordDescription" : its creates a "Description" objetc
766 * "Measure": its creates a "Measure" objetc 794 * "Measure": its creates a "Measure" objetc
767 * "FileView": its creates a "FileView" objet 795 * "FileView": its creates a "FileView" objet
768 * "CompanyView": its creates a "CompanyView" object 796 * "CompanyView": its creates a "CompanyView" object
769 "title": Read. Notebook page title (gtk.Label object) 797 title: Read. Notebook page title (gtk.Label object)
770 "activePathRecord": Read. The active path record 798 activePathRecord: Read. The active path record
771 "previousPathRecord": Read. The previous path record 799 previousPathRecord: Read. The previous path record
772 "posteriorPathRecord" Read. The posterior path record 800 posteriorPathRecord Read. The posterior path record
773 Methods: 801 Methods:
774 propagateMessageFrom 802 propagateMessageFrom
775 sendMessageTo 803 sendMessageTo
776 close 804 close
777 clear 805 clear
781 # TODO: * Panes in windows 809 # TODO: * Panes in windows
782 # TODO: * pane types 810 # TODO: * pane types
783 # TODO: * General budget properties (is better a dialog?) 811 # TODO: * General budget properties (is better a dialog?)
784 812
785 def __init__(self, mainWindow, budget, path_record=(0,)): 813 def __init__(self, mainWindow, budget, path_record=(0,)):
786 """def __init__(self, budget=None, active_code=None) 814 """__init__(mainWindow, budget, path_record=(0,))
787 815
788 mainWindow: MainWindow object 816 mainWindow: MainWindow object
789 budget: "base.Budget" object 817 budget: "base.Budget" object
790 path_record: the active path record 818 path_record: the active path record
791 """ 819 """
796 "RecordDescription" ]] 824 "RecordDescription" ]]
797 self.__main_item = None 825 self.__main_item = None
798 self.__active_path_record = () 826 self.__active_path_record = ()
799 self.__history_back = [] 827 self.__history_back = []
800 self.__history_forward = [] 828 self.__history_forward = []
801 self.setBudget(budget) 829 self.budget = budget
802 self._setActivePathRecord(path_record) 830 self._setActivePathRecord(path_record)
803 self.__widget.show() 831 self.__widget.show()
804 832
805 def propagateMessageFrom(self, message, pane_path, arg=None): 833 def propagateMessageFrom(self, message, pane_path, arg=None):
806 """def propagateMessageFrom(self, message, pane_path, arg=None) 834 """propagateMessageFrom(message, pane_path, arg=None)
807 835
808 message: string message 836 message: string message
809 * "change_active": change active code 837 * "change_active": change active code
810 * "autoclose" 838 * "autoclose"
811 * "split h" 839 * "split h"
824 self._closeItem(pane_path) 852 self._closeItem(pane_path)
825 elif message == "split h": 853 elif message == "split h":
826 self._splitItem(pane_path, "h") 854 self._splitItem(pane_path, "h")
827 elif message == "split v": 855 elif message == "split v":
828 self._splitItem(pane_path, "v") 856 self._splitItem(pane_path, "v")
829 857
830 def sendMessageTo(self, pane, message, pane_path, arg=None): 858 def sendMessageTo(self, pane, message, pane_path, arg=None):
831 """def sendMessageTo(self, pane, message, pane_path, arg=None) 859 """sendMessageTo(pane, message, pane_path, arg=None)
832 pane: the receiver pane 860 pane: the receiver pane
833 message: string message 861 message: string message
834 pane_path: tuple that represents the pane pane_path which emits the message 862 pane_path: tuple that represents the pane pane_path which emits the message
835 arg: arguments for the message 863 arg: arguments for the message
836 864
838 """ 866 """
839 if not pane.path == pane_path: 867 if not pane.path == pane_path:
840 pane.runMessage(message, pane_path, arg) 868 pane.runMessage(message, pane_path, arg)
841 869
842 def close(self): 870 def close(self):
843 """def close(self) 871 """close()
844 872
845 Close Page 873 Close Page
846 """ 874 """
847 _page_list = self.__mainWindow.getPageList() 875 _page_list = self.__mainWindow.pageList
848 if self in _page_list: 876 if self in _page_list:
849 _page_num = _page_list.index(self) 877 _page_num = _page_list.index(self)
850 self.__mainWindow.removePage(_page_num) 878 self.__mainWindow.removePage(_page_num)
851 else: 879 else:
852 raise IndexError, _("The page is not in the page list") 880 raise IndexError, _("The page is not in the page list")
853 881
854 def clear(self): 882 def clear(self):
855 """def clear(self) 883 """clear()
856 884
857 Clear atributes 885 Clear atributes
858 """ 886 """
859 self.propagateMessageFrom("clear", (0,)) 887 self.propagateMessageFrom("clear", (0,))
860 888
863 del self.__widget 891 del self.__widget
864 del self.__title 892 del self.__title
865 del self.__active_path_record 893 del self.__active_path_record
866 del self.__main_item 894 del self.__main_item
867 895
868 def getItem(self,pane_path): 896 def getItem(self, pane_path):
869 """def getItem(self, pane_path) 897 """getItem(pane_path)
870 898
871 Return the item whith the path "pane_path", it can return a Paned 899 Return the item whith the path "pane_path", it can return a Paned
872 instance or a View instance 900 instance or a View instance
873 """ 901 """
874 _item = self.__main_item 902 _item = self.__main_item
876 return _item 904 return _item
877 else: 905 else:
878 return _item.getItem(pane_path[1:]) 906 return _item.getItem(pane_path[1:])
879 907
880 def _setMainItem(self, item): 908 def _setMainItem(self, item):
881 """_setMainItem(self,item) 909 """_setMainItem(item)
882 910
883 Sets a new main item in the page 911 Sets a new main item in the page
884 """ 912 """
885 if not self.__main_item is None: 913 if not self.__main_item is None:
886 _old_main_widget = self.__main_item.widget 914 _old_main_widget = self.__main_item.widget
889 _main_widget = self.__main_item.widget 917 _main_widget = self.__main_item.widget
890 _main_widget.show() 918 _main_widget.show()
891 self.__widget.pack_start(_main_widget, True, True, 0) 919 self.__widget.pack_start(_main_widget, True, True, 0)
892 920
893 def _splitItem(self, pane_path, orientation): 921 def _splitItem(self, pane_path, orientation):
894 """_splitItem(self, pane_path, orientation) 922 """_splitItem(pane_path, orientation)
895 923
896 Splits the item that is identifies by the pane_path and the orientation 924 Splits the item that is identifies by the pane_path and the orientation
897 """ 925 """
898 _item = self.getItem(pane_path) 926 _item = self.getItem(pane_path)
899 _parent = self.getItem(pane_path[:-1]) 927 _parent = self.getItem(pane_path[:-1])
900 _item.setPath(pane_path+ (0,)) 928 _item.path = pane_path + (0,)
901 _item_clone0 = _item.getClone(pane_path + (0,)) 929 _item_clone0 = _item.getClone(pane_path + (0,))
902 _item_clone1 = _item.getClone(pane_path + (1,)) 930 _item_clone1 = _item.getClone(pane_path + (1,))
903 _paned = Paned(orientation, pane_path, _item_clone0, _item_clone1) 931 _paned = Paned(orientation, pane_path, _item_clone0, _item_clone1)
904 if len(pane_path) > 1: 932 if len(pane_path) > 1:
905 _parent.setItem(pane_path[-1], [_paned]) 933 _parent.setItem(pane_path[-1], [_paned])
906 else: 934 else:
907 self._setMainItem(_paned) 935 self._setMainItem(_paned)
908 936
909 def _closeItem(self, pane_path): 937 def _closeItem(self, pane_path):
910 """_closeItem(self, pane_path) 938 """_closeItem(pane_path)
911 939
912 Closes the item that is identifies by the pane_path 940 Closes the item that is identifies by the pane_path
913 """ 941 """
914 _item = self.getItem(pane_path) 942 _item = self.getItem(pane_path)
915 if len(pane_path) > 1: 943 if len(pane_path) > 1:
936 else: 964 else:
937 # Thre is only one item in the page, it can not be closed 965 # Thre is only one item in the page, it can not be closed
938 pass 966 pass
939 967
940 def _itemsFactory(self, list_paned, pane_path=(0,)): 968 def _itemsFactory(self, list_paned, pane_path=(0,)):
941 """def _itemsFactory(self, list_paned, pane_path(0,)) 969 """_itemsFactory(list_paned, pane_path(0,))
942 970
943 list_paned: list in "__panes_list" format 971 list_paned: list in "__panes_list" format
944 [ "v" or "h", panel1_type, panel2_type] 972 [ "v" or "h", panel1_type, panel2_type]
945 which contains the info for create the widgets. 973 which contains the info for create the widgets.
946 panel types: 974 panel types:
989 raise ValueError, utils.mapping(_("Incorrect item $1"), 1017 raise ValueError, utils.mapping(_("Incorrect item $1"),
990 (str(list_paned[0]),)) 1018 (str(list_paned[0]),))
991 return _item 1019 return _item
992 1020
993 def _setActivePathRecord(self, path_record): 1021 def _setActivePathRecord(self, path_record):
994 """def _setActivePathRecord(self, path_record) 1022 """_setActivePathRecord(path_record)
995 1023
996 path_record: the active record path 1024 path_record: the active record path
997 1025
998 Sets the active record path 1026 Sets the active record path
999 """ 1027 """
1002 self.__active_path_record = path_record 1030 self.__active_path_record = path_record
1003 self._appendHistory(path_record) 1031 self._appendHistory(path_record)
1004 else: 1032 else:
1005 raise ValueError, utils.mapping(_("The budget does not have "\ 1033 raise ValueError, utils.mapping(_("The budget does not have "\
1006 "the path record: $1"), (str(path_record),)) 1034 "the path record: $1"), (str(path_record),))
1035
1007 def _appendHistory(self, path): 1036 def _appendHistory(self, path):
1008 """def _appendHistory(self, path)) 1037 """_appendHistory(path))
1009 1038
1010 path: the old active path record 1039 path: the old active path record
1011 1040
1012 Sets the old active path record 1041 Sets the old active path record
1013 """ 1042 """
1026 self.__history_forward[:] = [] 1055 self.__history_forward[:] = []
1027 self.__history_back.append(path) 1056 self.__history_back.append(path)
1028 if len(self.__history_back) > 1000: 1057 if len(self.__history_back) > 1000:
1029 self.__history_back.pop(0) 1058 self.__history_back.pop(0)
1030 1059
1031 def getActivePathRecord(self): 1060 def _getActivePathRecord(self):
1032 """def getActivePathRecord(self) 1061 """_getActivePathRecord()
1033 1062
1034 Return the Active Path Record 1063 Return the Active Path Record
1035 """ 1064 """
1036 return self.__active_path_record 1065 return self.__active_path_record
1037 1066
1038 def getPreviousPathRecord(self): 1067 def _getPreviousPathRecord(self):
1039 """def getPreviousPathRecord(self) 1068 """_getPreviousPathRecord()
1040 1069
1041 Return the Previous Path Record 1070 Return the Previous Path Record
1042 """ 1071 """
1043 if len(self.__history_back) > 1: 1072 if len(self.__history_back) > 1:
1044 return self.__history_back[-2] 1073 return self.__history_back[-2]
1045 else: 1074 else:
1046 return None 1075 return None
1047 1076
1048 def getPosteriorPathRecord(self): 1077 def _getPosteriorPathRecord(self):
1049 """def getPosteriorPathRecord(self) 1078 """_getPosteriorPathRecord()
1050 1079
1051 Return the Posterior Path Record 1080 Return the Posterior Path Record
1052 """ 1081 """
1053 if len(self.__history_forward) > 0: 1082 if len(self.__history_forward) > 0:
1054 return self.__history_forward[-1] 1083 return self.__history_forward[-1]
1055 else: 1084 else:
1056 return None 1085 return None
1057 1086
1058 def getTitle(self): 1087 def _getTitle(self):
1059 """def getTitle(self) 1088 """_getTitle()
1060 1089
1061 Return the page title, a gtk.Label objetc 1090 Return the page title, a gtk.Label objetc
1062 """ 1091 """
1063 return self.__title 1092 return self.__title
1064 1093
1065 def getWidget(self): 1094 def _getWidget(self):
1066 """def getWidget(self) 1095 """_getWidget()
1067 1096
1068 Return de main widget to show in the pane 1097 Return de main widget to show in the pane
1069 """ 1098 """
1070 return self.__widget 1099 return self.__widget
1071 1100
1072 def setBudget(self, budget): 1101 def _setBudget(self, budget):
1073 """def setBudget(self, budget) 1102 """_setBudget(budget)
1074 1103
1075 budget: a base.Budget object 1104 budget: a base.Budget object
1076 1105
1077 Sets the budget and the active code atributes, 1106 Sets the budget and the active code atributes,
1078 creates the page title and the widgets in the pane and 1107 creates the page title and the widgets in the pane and
1086 # Todo: change page title 1115 # Todo: change page title
1087 self.__title = gtk.Label(self.__budget.getCode( 1116 self.__title = gtk.Label(self.__budget.getCode(
1088 self.__active_path_record)) 1117 self.__active_path_record))
1089 _panes_list = self.__panes_list 1118 _panes_list = self.__panes_list
1090 self.__main_item = self._itemsFactory(_panes_list) 1119 self.__main_item = self._itemsFactory(_panes_list)
1091 _main_widget = self.__main_item.getWidget() 1120 _main_widget = self.__main_item.widget
1092 _main_widget.show() 1121 _main_widget.show()
1093 self.__widget.pack_start(_main_widget, True, True, 0) 1122 self.__widget.pack_start(_main_widget, True, True, 0)
1094 1123
1095 def getBudget(self): 1124 def _getBudget(self):
1096 """def getBudget(self) 1125 """_getBudget()
1097 1126
1098 Return de budget, a "base.Budget" object. 1127 Return de budget, a "base.Budget" object.
1099 """ 1128 """
1100 return self.__budget 1129 return self.__budget
1101 1130
1102 def getPanesList(self): 1131 def _getPanesList(self):
1103 """def getPanesList(self) 1132 """_getPanesList()
1104 1133
1105 Return the panes list, info list for create the panes. 1134 Return the panes list, info list for create the panes.
1106 """ 1135 """
1107 return self.__panes_list 1136 return self.__panes_list
1108 1137
1109 budget = property(getBudget, setBudget, None, 1138 budget = property(_getBudget, _setBudget, None,
1110 "Budget to show, base.Budget object") 1139 "Budget to show, base.Budget object")
1111 widget = property(getWidget, None, None, 1140 widget = property(_getWidget, None, None,
1112 "Main widget showed in the pane") 1141 "Main widget showed in the pane")
1113 title = property(getTitle, None, None, 1142 title = property(_getTitle, None, None,
1114 "Page Title") 1143 "Page Title")
1115 panes_list = property(getPanesList, None, None, 1144 panes_list = property(_getPanesList, None, None,
1116 "Info list for create the panes") 1145 "Info list for create the panes")
1117 activePathRecord = property(getActivePathRecord, None, None, 1146 activePathRecord = property(_getActivePathRecord, None, None,
1118 "Active Path Record") 1147 "Active Path Record")
1119 previousPathRecord = property(getPreviousPathRecord, None, None, 1148 previousPathRecord = property(_getPreviousPathRecord, None, None,
1120 "Previous Active Path Record") 1149 "Previous Active Path Record")
1121 posteriorPathRecord = property(getPosteriorPathRecord, None, None, 1150 posteriorPathRecord = property(_getPosteriorPathRecord, None, None,
1122 "Posterior Active Path Record") 1151 "Posterior Active Path Record")
1152
1123 1153
1124 class View(object): 1154 class View(object):
1125 """gui.View: 1155 """gui.View:
1126 1156
1127 Description: 1157 Description:
1128 It creates a view to show the budget info 1158 It creates a view to show the budget info
1129 Constructor: 1159 Constructor:
1130 View(view_type, budget, wr_page, path, active_path_record) 1160 View(view_type, budget, wr_page, path, active_path_record)
1161 view_type: the object type to show
1162 * DecompositionList
1163 * Description
1164 * Measure
1165 * Sheet
1166 * FileView
1167 * CompanyView
1168 budget: the budget to show
1169 wr_page: weak reference to the page where the view must be showed
1170 path: the position or path of the view in the page notebook
1171 active_path_record: the record path that must be showed
1131 Ancestry: 1172 Ancestry:
1132 +-- object 1173 +-- object
1133 +-- Paned 1174 +-- View
1134 Atributes: 1175 Atributes:
1135 "path": the tuple that identifies the view in the main notebook page 1176 path: Read-Write. The tuple that identifies the view in the main
1136 "widget": the main gtk widget to show in a view object, 1177 notebook page
1178 widget: Read. the main gtk widget to show in a view object,
1137 a gtk.VBox object 1179 a gtk.VBox object
1138 "__view_type": the object type to show
1139 * DecompositionList
1140 * Description
1141 * Measure
1142 * Sheet of conditions
1143 * FileView
1144 * CompanyView
1145 "__wr_page": weak reference to the page where the view must be showed
1146 "__budget": the budget to show
1147 "__view ": the object to show:
1148 * DecompositionList object
1149 * Description object
1150 * Measure object
1151 * Sheet object
1152 * FileView object
1153 * Comapany View
1154 "__connected": boolean value, True means that the View object sends and
1155 receives signals from/to others views
1156 "__connected_button": a button to switch __connected True or False
1157 Methods: 1180 Methods:
1158 __init__(self) 1181 getItem
1159 getItem(self, path) 1182 propagateMessgeFrom
1160 _closeItem(self, close_button) 1183 runMessage
1161 _change_combo(self, combobox) 1184 getClone
1162 propagateMessgeFrom(self, message, path, arg=None) 1185 clear
1163 runMessage(self, message, path, arg=None)
1164 getWidget(self)
1165 getPath(self)
1166 setPath(self)
1167 getClone(self, newpath)
1168 clear(self)
1169 """ 1186 """
1187
1170 def __init__(self, view_type, budget, wr_page, path, active_path_record): 1188 def __init__(self, view_type, budget, wr_page, path, active_path_record):
1171 1189 """__init__(view_type, budget, wr_page, path, active_path_record)
1172 """def __init__(self, view_type, budget, wr_page, path,
1173 active_path_record)
1174 view_type: the object type to show 1190 view_type: the object type to show
1175 * DecompositionList 1191 * DecompositionList
1176 * Description 1192 * Description
1177 * Measure 1193 * Measure
1178 * Sheet 1194 * Sheet
1180 * CompanyView 1196 * CompanyView
1181 budget: the budget to show 1197 budget: the budget to show
1182 wr_page: weak reference to the page where the view must be showed 1198 wr_page: weak reference to the page where the view must be showed
1183 path: the position or path of the view in the page notebook 1199 path: the position or path of the view in the page notebook
1184 active_path_record: the record path that must be showed 1200 active_path_record: the record path that must be showed
1201
1202 self.__active_path_record: the record path that must be showed
1203 self.__view_type: the object type to show
1204 * DecompositionList
1205 * Description
1206 * Measure
1207 * Sheet of conditions
1208 * FileView
1209 * CompanyView
1210 self.__wr_page: weak reference to the page where the view must be
1211 showed
1212 self.__budget: the budget to show
1213 self.__path: the position or path of the view in the page notebook
1214 self.__connected: boolean value, True means that the View object sends
1215 and receives signals from/to others views
1216 self.__widget: main widget. a gtk.Toolbar?
1217 self.__view: the object to show:
1218 * DecompositionList object
1219 * Description object
1220 * Measure object
1221 * Sheet object
1222 * FileView object
1223 * Comapany View
1224 self.__connected_button: a button to switch self.__connected True or
1225 False
1185 1226
1186 Creates and shows a new view 1227 Creates and shows a new view
1187 """ 1228 """
1188 self.__active_path_record = active_path_record 1229 self.__active_path_record = active_path_record
1189 self.__view_type = view_type 1230 self.__view_type = view_type
1215 if view_type == "DecompositionList": 1256 if view_type == "DecompositionList":
1216 self.__view = DecompositionList(budget, weakref.ref(self), 1257 self.__view = DecompositionList(budget, weakref.ref(self),
1217 path, active_path_record) 1258 path, active_path_record)
1218 _combobox.set_active(0) 1259 _combobox.set_active(0)
1219 _view_icon = gtk.Image() 1260 _view_icon = gtk.Image()
1220 _view_icon.set_from_file(globalVars.getAppPath("DECOMPOSITION-ICON")) 1261 _view_icon.set_from_file(globalVars.getAppPath(
1262 "DECOMPOSITION-ICON"))
1221 elif view_type == "RecordDescription": 1263 elif view_type == "RecordDescription":
1222 self.__view = Description(budget, weakref.ref(self), 1264 self.__view = Description(budget, weakref.ref(self),
1223 path, active_path_record) 1265 path, active_path_record)
1224 _combobox.set_active(1) 1266 _combobox.set_active(1)
1225 _view_icon = gtk.Image() 1267 _view_icon = gtk.Image()
1226 _view_icon.set_from_file(globalVars.getAppPath("DESCRIPTION-ICON")) 1268 _view_icon.set_from_file(globalVars.getAppPath(
1269 "DESCRIPTION-ICON"))
1227 elif view_type == "Measure": 1270 elif view_type == "Measure":
1228 self.__view = Measure(budget, weakref.ref(self), 1271 self.__view = Measure(budget, weakref.ref(self),
1229 path, active_path_record) 1272 path, active_path_record)
1230 _combobox.set_active(2) 1273 _combobox.set_active(2)
1231 _view_icon = gtk.Image() 1274 _view_icon = gtk.Image()
1246 self.__view = CompanyView(budget, weakref.ref(self), path, 1289 self.__view = CompanyView(budget, weakref.ref(self), path,
1247 active_path_record) 1290 active_path_record)
1248 _combobox.set_active(5) 1291 _combobox.set_active(5)
1249 _view_icon = gtk.Image() 1292 _view_icon = gtk.Image()
1250 _view_icon.set_from_file(globalVars.getAppPath("SHEET-ICON")) 1293 _view_icon.set_from_file(globalVars.getAppPath("SHEET-ICON"))
1251
1252 else: 1294 else:
1253 raise ValueError, _(utils.mapping("Invalid type of View: $1", 1295 raise ValueError, _(utils.mapping("Invalid type of View: $1",
1254 view_type)) 1296 view_type))
1255 _view_icon.show() 1297 _view_icon.show()
1256 _combobox.connect("changed", self._change_combo) 1298 _combobox.connect("changed", self._change_combo)
1288 _hbox.pack_start(_close_button, False, False, 0) 1330 _hbox.pack_start(_close_button, False, False, 0)
1289 _hbox.show() 1331 _hbox.show()
1290 self.__widget.show() 1332 self.__widget.show()
1291 1333
1292 def getItem(self, path): 1334 def getItem(self, path):
1293 """def getItem(self, path) 1335 """getItem(path)
1294 1336
1295 Return itself. 1337 Return itself.
1296 """ 1338 """
1297 return self 1339 return self
1298 1340
1299 def _closeItem(self, close_button): 1341 def _closeItem(self, close_button):
1300 """_closeItem(self, widget) 1342 """_closeItem(close_button)
1301 1343
1302 Method connected to the "clicked" signal of the _close_button widget 1344 Method connected to the "clicked" signal of the _close_button widget
1303 Send the "autoclose" message to the page to close this view 1345 Send the "autoclose" message to the page to close this view
1304 """ 1346 """
1305 self.propagateMessageFrom( "autoclose", self.__path) 1347 self.propagateMessageFrom("autoclose", self.__path)
1306 1348
1307 def _change_combo(self, combobox): 1349 def _change_combo(self, combobox):
1308 """_change_combo(self, combobox) 1350 """_change_combo(combobox)
1309 1351
1310 Method connected to the "changed" signal of the _combobox widget 1352 Method connected to the "changed" signal of the _combobox widget
1311 It changes the view type to the type selected in the combobox 1353 It changes the view type to the type selected in the combobox
1312 """ 1354 """
1313 _index = combobox.get_active() 1355 _index = combobox.get_active()
1334 _view_icon = gtk.Image() 1376 _view_icon = gtk.Image()
1335 if _index == 0: 1377 if _index == 0:
1336 self.__view = DecompositionList(_budget, _wr_page, _path, 1378 self.__view = DecompositionList(_budget, _wr_page, _path,
1337 _path_record) 1379 _path_record)
1338 1380
1339 _view_icon.set_from_file(globalVars.getAppPath("DECOMPOSITION-ICON")) 1381 _view_icon.set_from_file(globalVars.getAppPath(
1382 "DECOMPOSITION-ICON"))
1340 self.__view_type = "DecompositionList" 1383 self.__view_type = "DecompositionList"
1341 elif _index == 1: 1384 elif _index == 1:
1342 self.__view = Description(_budget, _wr_page, _path, 1385 self.__view = Description(_budget, _wr_page, _path,
1343 _path_record) 1386 _path_record)
1344 _view_icon.set_from_file(globalVars.getAppPath("DESCRIPTION-ICON")) 1387 _view_icon.set_from_file(globalVars.getAppPath("DESCRIPTION-ICON"))
1374 _hbox.show() 1417 _hbox.show()
1375 _vbox.pack_start(_hbox, False, False, 0) 1418 _vbox.pack_start(_hbox, False, False, 0)
1376 _vbox.pack_start(self.__view.widget, True, True, 0) 1419 _vbox.pack_start(self.__view.widget, True, True, 0)
1377 1420
1378 def _menu_view(self, widget): 1421 def _menu_view(self, widget):
1379 """_menu_view(self, widget) 1422 """_menu_view(widget)
1380 1423
1381 Method connected to the "clicked" signal of the __connected_button 1424 Method connected to the "clicked" signal of the __connected_button
1382 It shows a popup menu with some options 1425 It shows a popup menu with some options
1383 """ 1426 """
1384 _menu_view = gtk.Menu() 1427 _menu_view = gtk.Menu()
1393 _item_close = gtk.MenuItem(_("Close view")) 1436 _item_close = gtk.MenuItem(_("Close view"))
1394 _menu_view.append(_item_close) 1437 _menu_view.append(_item_close)
1395 _item_close.connect_object("activate", self._closeItem, None) 1438 _item_close.connect_object("activate", self._closeItem, None)
1396 _item_close.show() 1439 _item_close.show()
1397 _menu_view.popup(None, None, None, 0, 0) 1440 _menu_view.popup(None, None, None, 0, 0)
1398 1441
1399 def _split_view(self, orientation): 1442 def _split_view(self, orientation):
1400 """_menu_view(self, orientation) 1443 """_menu_view(orientation)
1401 1444
1402 orientation: orientation split, "h" or "v" 1445 orientation: orientation split, "h" or "v"
1403 1446
1404 Method connected to the "activate" signal of the _item_leftright and 1447 Method connected to the "activate" signal of the _item_leftright and
1405 _item_topbottom menu items. 1448 _item_topbottom menu items.
1407 specified orientation 1450 specified orientation
1408 """ 1451 """
1409 self.propagateMessageFrom( "split " + orientation, self.__path) 1452 self.propagateMessageFrom( "split " + orientation, self.__path)
1410 1453
1411 def _connected(self, widget): 1454 def _connected(self, widget):
1412 """_connected(self, widget) 1455 """_connected(widget)
1413 1456
1414 Method connected to the "clicked" signal of the _menu_button 1457 Method connected to the "clicked" signal of the _menu_button
1415 It changes the __connected atribute to True or False, if the 1458 It changes the __connected atribute to True or False, if the
1416 _connected atribute is False the view do not send and receive messages 1459 _connected atribute is False the view do not send and receive messages
1417 to/from others views 1460 to/from others views
1428 _icon.show() 1471 _icon.show()
1429 self.__connected_button.set_icon_widget(_icon) 1472 self.__connected_button.set_icon_widget(_icon)
1430 self.__connected = True 1473 self.__connected = True
1431 1474
1432 def propagateMessageFrom(self, message, path, arg=None): 1475 def propagateMessageFrom(self, message, path, arg=None):
1433 """def propagateMessageFrom(self, message, path, arg=None) 1476 """propagateMessageFrom(message, path, arg=None)
1434 1477
1435 message: string message 1478 message: string message
1436 path: tuple that represents the pane path which emits the message 1479 path: tuple that represents the pane path which emits the message
1437 arg: arguments for the message 1480 arg: arguments for the message
1438 The panes are connectted to this method to send messages to other panes 1481 The panes are connectted to this method to send messages to other panes
1440 if self.__connected or message == "autoclose" or \ 1483 if self.__connected or message == "autoclose" or \
1441 message == "split h" or message == "split v": 1484 message == "split h" or message == "split v":
1442 self.__wr_page().propagateMessageFrom(message, path, arg) 1485 self.__wr_page().propagateMessageFrom(message, path, arg)
1443 1486
1444 def runMessage(self, message, path, arg=None): 1487 def runMessage(self, message, path, arg=None):
1445 """def runMessage(self, message, path, arg=None) 1488 """runMessage(message, path, arg=None)
1446 1489
1447 message: the message type 1490 message: the message type
1448 "change_active": change the active record 1491 "change_active": change the active record
1449 "clear": clear instance 1492 "clear": clear instance
1450 path: tuple that identifies the pane in the notebook page 1493 path: tuple that identifies the pane in the notebook page
1458 if message == "change_active": 1501 if message == "change_active":
1459 if self.__budget.hasPath(arg): 1502 if self.__budget.hasPath(arg):
1460 _path_record = arg 1503 _path_record = arg
1461 self.__active_path_record = _path_record 1504 self.__active_path_record = _path_record
1462 1505
1463 def getWidget(self): 1506 def _getWidget(self):
1464 """def getWidget(self) 1507 """_getWidget()
1465 1508
1466 Return de pane widget 1509 Return de pane widget
1467 """ 1510 """
1468 return self.__widget 1511 return self.__widget
1469 1512
1470 def getPath(self): 1513 def _getPath(self):
1471 """def getPath(self) 1514 """_getPath()
1472 1515
1473 return the tuple that identifies the pane in the notebook page 1516 return the tuple that identifies the pane in the notebook page
1474 """ 1517 """
1475 return self.__view.path 1518 return self.__view.path
1476 1519
1477 def setPath(self, path): 1520 def _setPath(self, path):
1478 """def setPath(self) 1521 """_setPath()
1479 1522
1480 set the tuple that identifies the pane in the notebook page 1523 set the tuple that identifies the pane in the notebook page
1481 """ 1524 """
1482 self.__path = path 1525 self.__path = path
1483 self.__view.path = path 1526 self.__view.path = path
1484 1527
1485 def getClone(self, new_path): 1528 def getClone(self, new_path):
1486 """getClone(self, new_path) 1529 """getClone(new_path)
1487 1530
1488 new_path: the path that identifies the clone view in the page 1531 new_path: the path that identifies the clone view in the page
1489 1532
1490 return a clone of itself 1533 return a clone of itself
1491 """ 1534 """
1492 return View(self.__view_type, self.__budget, self.__wr_page, 1535 return View(self.__view_type, self.__budget, self.__wr_page,
1493 new_path, self.__active_path_record) 1536 new_path, self.__active_path_record)
1494 1537
1495 def clear(self): 1538 def clear(self):
1496 """clear(self) 1539 """clear()
1497 1540
1498 Clear the intance atributes 1541 Clear the intance atributes
1499 """ 1542 """
1500 del self.__wr_page 1543 del self.__wr_page
1501 del self.__budget 1544 del self.__budget
1502 del self.__path 1545 del self.__path
1503 del self.__widget 1546 del self.__widget
1504 del self.__view 1547 del self.__view
1505 del self.__connected 1548 del self.__connected
1506 del self.__connected_button 1549 del self.__connected_button
1507 1550
1508 path = property(getPath, setPath, None, 1551 path = property(_getPath, _setPath, None,
1509 "path that identifies the item in the notebook page") 1552 "path that identifies the item in the notebook page")
1510 widget = property(getWidget, None, None, "View widget") 1553 widget = property(_getWidget, None, None, "View widget")
1554
1511 1555
1512 class Paned(object): 1556 class Paned(object):
1513 """gui.Paned: 1557 """gui.Paned:
1514 1558
1515 Description: 1559 Description:
1516 It creates and shows gtk.Hpaned or gtk.Vpaned to show in page budget 1560 It creates and shows gtk.Hpaned or gtk.Vpaned to show in page budget
1517 Constructor: 1561 Constructor:
1518 Paned(orientation, widget1, widget2) 1562 Paned(orientation, widget1, widget2)
1519 orientation: The orientation of the pane separator, can be "v" or "h" 1563 orientation: The orientation of the pane separator, can be "v" or
1520 widget1: the top or left pane widget 1564 "h"
1521 widget2: the botton or right pane widget 1565 widget1: the top or left pane widget
1522 Returns the newly created Paned instance 1566 widget2: the botton or right pane widget
1523 Ancestry: 1567 Ancestry:
1524 +-- object 1568 +-- object
1525 +-- Paned 1569 +-- Paned
1526 Atributes: 1570 Atributes:
1527 "widget": Pane widget("gtk.VPaned" or "gtk.HPaned" object) 1571 widget: Read. Pane widget("gtk.VPaned" or "gtk.HPaned" object)
1528 "__orientation": The orientation of de gtk.Paned, can be "v" or "h" 1572 path: Read-Write. The paned path in the page
1529 "__items": list of items showed in the paned, its can be View or Paned
1530 instances
1531 "__path": the paned path in the page
1532 Methods: 1573 Methods:
1533 __init__(self) 1574 getClone
1534 __getitem__(self, item) 1575 getItem
1535 getClone(self, new_path) 1576 setItem
1536 getItem(self, path) 1577 runMessage
1537 runMessage(self, messge, path, arg=None)
1538 getWidget(self)
1539 {get/set}Path
1540 clear(self) 1578 clear(self)
1541 """ 1579 """
1542 # TODO: *control the position paned separator. Now is always 200 pixels 1580 # TODO: *control the position paned separator. Now is always 200 pixels
1543 # TODO: can be with a float(0.0-1.0) aspect ratio 1581 # TODO: can be with a float(0.0-1.0) aspect ratio
1544 # TODO: 0.0 no space for widget1 1582 # TODO: 0.0 no space for widget1
1545 # TODO: 1.0 all the space for widget1 1583 # TODO: 1.0 all the space for widget1
1546 # TODO: *control the position pane separator when the size of the window 1584 # TODO: *control the position pane separator when the size of the window
1547 # TODO: change with the same ascpect ratio 1585 # TODO: change with the same ascpect ratio
1548 1586
1549 def __init__(self, orientation, path, item1, item2): 1587 def __init__(self, orientation, path, item1, item2):
1550 """def __init__(self, oritentation, path, item1, item2) 1588 """__init__(oritentation, path, item1, item2)
1551 1589
1552 orientation: The orientation of de gtk.Paned, can be "v" or "h" 1590 orientation: The orientation of de gtk.Paned, can be "v" or "h"
1553 path: the paned path in the page 1591 path: the paned path in the page
1554 item1: the top or left pane object 1592 item1: the top or left pane object
1555 item2: the bottom or right pane object 1593 item2: the bottom or right pane object
1594
1595 self.__orientation: The orientation of de gtk.Paned, can be "v" or "h"
1596 self.__widget: Main widget, a gtk.VPaned o gtk.HPaned
1597 self.__items: list of items showed in the paned, its can be View or
1598 Paned instances
1599 self.__path: the paned path in the page
1556 1600
1557 Creates and shows a new gtk.Paned 1601 Creates and shows a new gtk.Paned
1558 """ 1602 """
1559 self.__orientation = orientation 1603 self.__orientation = orientation
1560 if not isinstance(item1.widget, gtk.Widget) or \ 1604 if not isinstance(item1.widget, gtk.Widget) or \
1572 self.__widget.show() 1616 self.__widget.show()
1573 self.__items = [item1, item2] 1617 self.__items = [item1, item2]
1574 self.__path = path 1618 self.__path = path
1575 1619
1576 def __getitem__(self, item): 1620 def __getitem__(self, item):
1577 """__getitem__(self, item) 1621 """__getitem__(item)
1578 1622
1579 Called to implement evaluation of self[key]. 1623 Called to implement evaluation of self[key].
1580 The accepted keys should be integers 0 or 1. 1624 The accepted keys should be integers 0 or 1.
1581 """ 1625 """
1582 return self.__items[item] 1626 return self.__items[item]
1583 1627
1584 def getClone(self, new_path): 1628 def getClone(self, new_path):
1585 """getClone(self, new_path) 1629 """getClone(new_path)
1586 1630
1587 Return a clone Paned instance with the path new_path 1631 Return a clone Paned instance with the path new_path
1588 """ 1632 """
1589 return Paned(self.__orientation, new_path, 1633 return Paned(self.__orientation, new_path,
1590 self.__items[0].getClone(new_path + (0,)), 1634 self.__items[0].getClone(new_path + (0,)),
1591 self.__items[1].getClone(new_path + (1,))) 1635 self.__items[1].getClone(new_path + (1,)))
1592 1636
1593 def getItem(self,path): 1637 def getItem(self,path):
1594 """def getItem(self, path) 1638 """getItem(path)
1595 1639
1596 Return the item whith the specified path. 1640 Return the item whith the specified path.
1597 """ 1641 """
1598 _item = self.__items[path[0]] 1642 _item = self.__items[path[0]]
1599 if len(path) == 1: 1643 if len(path) == 1:
1600 return _item 1644 return _item
1601 else: 1645 else:
1602 return _item.getItem(path[1:]) 1646 return _item.getItem(path[1:])
1603 1647
1604 def setItem(self, path, item_list): 1648 def setItem(self, path, item_list):
1605 """def setItem(self, path, item_list) 1649 """setItem(path, item_list)
1606 1650
1607 Sets the first item in the item_list whith the especified path and 1651 Sets the first item in the item_list whith the especified path and
1608 remove the old item in this position. 1652 remove the old item in this position.
1609 """ 1653 """
1610 item = item_list[0] 1654 item = item_list[0]
1618 self.__widget.pack2(item.widget,True,False) 1662 self.__widget.pack2(item.widget,True,False)
1619 return True 1663 return True
1620 return False 1664 return False
1621 1665
1622 def runMessage(self, message, path, arg=None): 1666 def runMessage(self, message, path, arg=None):
1623 """def runMessage(self, message, page_path, arg=None) 1667 """runMessage(message, page_path, arg=None)
1624 1668
1625 message: the message type 1669 message: the message type
1626 "change_active": change the active record 1670 "change_active": change the active record
1627 "clear": clear instance 1671 "clear": clear instance
1628 page_path: tuple that identifies the pane in the notebook page 1672 page_path: tuple that identifies the pane in the notebook page
1632 """ 1676 """
1633 for _item in self.__items: 1677 for _item in self.__items:
1634 if not _item.path == path: 1678 if not _item.path == path:
1635 _item.runMessage(message, path, arg) 1679 _item.runMessage(message, path, arg)
1636 1680
1637 def getWidget(self): 1681 def _getWidget(self):
1638 """def getWidget(self) 1682 """_getWidget()
1639 1683
1640 Return de gtk.Paned widget 1684 Return de gtk.Paned widget
1641 """ 1685 """
1642 return self.__widget 1686 return self.__widget
1643 1687
1644 def getPath(self): 1688 def _getPath(self):
1645 """def getPath(self) 1689 """_getPath()
1646 1690
1647 Return de Paned path in the notebook page 1691 Return de Paned path in the notebook page
1648 """ 1692 """
1649 return self.__path 1693 return self.__path
1650 1694
1651 def setPath(self, path): 1695 def _setPath(self, path):
1652 """def setPath(self) 1696 """_setPath()
1653 1697
1654 sets the tuple that identifies the pane in the notebook page 1698 sets the tuple that identifies the pane in the notebook page
1655 """ 1699 """
1656 self.__path = path 1700 self.__path = path
1657 self.__items[0].path = path + (0,) 1701 self.__items[0].path = path + (0,)
1658 self.__items[1].path = path + (1,) 1702 self.__items[1].path = path + (1,)
1659 1703
1660 def clear(self): 1704 def clear(self):
1705 """clear()
1706
1707 Delete atributes
1708 """
1661 del self.__widget 1709 del self.__widget
1662 del self.__orientation 1710 del self.__orientation
1663 del self.__items 1711 del self.__items
1664 del self.__path 1712 del self.__path
1665 1713
1666 widget = property(getWidget, None, None, "gtk.Paned widget") 1714 widget = property(_getWidget, None, None, "gtk.Paned widget")
1667 path = property(getPath, setPath, None, "Pane path in the notebook page") 1715 path = property(_getPath, _setPath, None, "Pane path in the notebook page")
1716
1668 1717
1669 class TreeView(object): 1718 class TreeView(object):
1670 """gui.Treeviev: 1719 """gui.Treeviev:
1671 1720
1672 Description: 1721 Description:
1689 5. model column index 1738 5. model column index
1690 Ancestry: 1739 Ancestry:
1691 +-- object 1740 +-- object
1692 +-- TreeView 1741 +-- TreeView
1693 Atributes: 1742 Atributes:
1694 "columns": list of columns (gtk.TreeViewColumn isntances) 1743 columns: list of columns (gtk.TreeViewColumn objects)
1695 Methods: 1744 Methods:
1696 __init__(self) 1745 createColumn
1697 __getitem__(self, item) 1746 createTextBaseColumn
1698 createColumn(self, args) 1747 createBaseColumn
1699 createTextBaseColumn(self,args)
1700 createBaseColumn(self,args)
1701 """ 1748 """
1702 1749
1703 def __init__(self, args): 1750 def __init__(self, args):
1704 """__init__(self, args) 1751 """__init__(args)
1705 1752
1706 args: list of tuples, the tuple items are: 1753 args: list of tuples, the tuple items are:
1707 0.type: 1754 0.type:
1708 * index column 1755 * index column
1709 * float column 1756 * float column
1722 """ 1769 """
1723 self.columns = [ self.createColumn(arg) for arg in args ] 1770 self.columns = [ self.createColumn(arg) for arg in args ]
1724 self.columns.append(self.createColumn(("END",))) 1771 self.columns.append(self.createColumn(("END",)))
1725 1772
1726 def createColumn(self, args): 1773 def createColumn(self, args):
1727 """createColumn(self, args) 1774 """createColumn(args)
1728 1775
1729 args: tuple with the args 1776 args: tuple with the args
1730 0.type: 1777 0.type:
1731 * index column 1778 * index column
1732 * float column 1779 * float column
1752 globalVars.getAppPath("ARROW-ICON")) 1799 globalVars.getAppPath("ARROW-ICON"))
1753 _pixbuf_index_cell.set_property("pixbuf", _arrow_icon) 1800 _pixbuf_index_cell.set_property("pixbuf", _arrow_icon)
1754 _index_column.pack_start(_text_index_cell, True) 1801 _index_column.pack_start(_text_index_cell, True)
1755 _index_column.pack_start(_pixbuf_index_cell, True) 1802 _index_column.pack_start(_pixbuf_index_cell, True)
1756 _index_column.set_cell_data_func(_text_index_cell, 1803 _index_column.set_cell_data_func(_text_index_cell,
1757 self.colorCell, 1804 self._colorCell,
1758 [gtk.gdk.color_parse(globalVars.color["INDEX-UNEVEN"]), 1805 [gtk.gdk.color_parse(globalVars.color["INDEX-UNEVEN"]),
1759 gtk.gdk.color_parse(globalVars.color["INDEX-EVEN"])]) 1806 gtk.gdk.color_parse(globalVars.color["INDEX-EVEN"])])
1760 return _index_column 1807 return _index_column
1761 elif args[0] == "TEXT": 1808 elif args[0] == "TEXT":
1762 _column, _cell = self.createTextBaseColumn(args) 1809 _column, _cell = self.createTextBaseColumn(args)
1781 _type_cell2.set_property('foreground-gdk', args[3]) 1828 _type_cell2.set_property('foreground-gdk', args[3])
1782 _column.pack_start(_type_cell1, True) 1829 _column.pack_start(_type_cell1, True)
1783 _column.pack_start(_type_cell2, True) 1830 _column.pack_start(_type_cell2, True)
1784 _column.add_attribute(_type_cell2, 'text', args[5]) 1831 _column.add_attribute(_type_cell2, 'text', args[5])
1785 _column.set_cell_data_func(_type_cell1, 1832 _column.set_cell_data_func(_type_cell1,
1786 self.colorCell, args[4]) 1833 self._colorCell, args[4])
1787 _column.set_cell_data_func(_type_cell2, 1834 _column.set_cell_data_func(_type_cell2,
1788 self.colorCell, args[4]) 1835 self._colorCell, args[4])
1789 return _column 1836 return _column
1790 elif args[0] == "PIXBUF": 1837 elif args[0] == "PIXBUF":
1791 _column = self.createBaseColumn(args) 1838 _column = self.createBaseColumn(args)
1792 _type_cell1 = gtk.CellRendererPixbuf() 1839 _type_cell1 = gtk.CellRendererPixbuf()
1793 _column.pack_start(_type_cell1, True) 1840 _column.pack_start(_type_cell1, True)
1794 _column.set_cell_data_func(_type_cell1, 1841 _column.set_cell_data_func(_type_cell1,
1795 self.colorCell, args[4]) 1842 self._colorCell, args[4])
1796 return _column 1843 return _column
1797 elif args[0] == "END": 1844 elif args[0] == "END":
1798 _end_column = gtk.TreeViewColumn() 1845 _end_column = gtk.TreeViewColumn()
1799 _end_column.set_clickable(False) 1846 _end_column.set_clickable(False)
1800 _end_cell = gtk.CellRendererText() 1847 _end_cell = gtk.CellRendererText()
1802 gtk.gdk.color_parse(globalVars.color["UNEVEN"])) 1849 gtk.gdk.color_parse(globalVars.color["UNEVEN"]))
1803 _end_column.pack_start(_end_cell, True) 1850 _end_column.pack_start(_end_cell, True)
1804 return _end_column 1851 return _end_column
1805 return None 1852 return None
1806 1853
1807 def createTextBaseColumn(self,args): 1854 def createTextBaseColumn(self, args):
1808 """createTextBaseColumn(self,args) 1855 """createTextBaseColumn(args)
1809 1856
1810 args: tuple with the args 1857 args: tuple with the args
1811 0.type: 1858 0.type:
1812 * float column 1859 * float column
1813 * text column 1860 * text column
1823 """ 1870 """
1824 _column = self.createBaseColumn(args) 1871 _column = self.createBaseColumn(args)
1825 _cell = gtk.CellRendererText() 1872 _cell = gtk.CellRendererText()
1826 _cell.set_property('foreground-gdk', args[3]) 1873 _cell.set_property('foreground-gdk', args[3])
1827 _column.pack_start(_cell, True) 1874 _column.pack_start(_cell, True)
1828 _column.set_cell_data_func(_cell, self.colorCell, args[4]) 1875 _column.set_cell_data_func(_cell, self._colorCell, args[4])
1829 return _column, _cell 1876 return _column, _cell
1830 1877
1831 def createBaseColumn(self,args): 1878 def createBaseColumn(self, args):
1832 """createBaseColumn(self,args) 1879 """createBaseColumn(args)
1833 1880
1834 args: tuple with the args 1881 args: tuple with the args
1835 0.type: 1882 0.type:
1836 * index column 1883 * index column
1837 * float column 1884 * float column
1853 _column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) 1900 _column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
1854 _column.set_fixed_width(args[2]) 1901 _column.set_fixed_width(args[2])
1855 _column.set_resizable(True) 1902 _column.set_resizable(True)
1856 return _column 1903 return _column
1857 1904
1905
1858 class DecompositionList(TreeView): 1906 class DecompositionList(TreeView):
1859 """gui.DecompositionList: 1907 """gui.DecompositionList:
1860 1908
1861 Description: 1909 Description:
1862 Class to show a budget Decomposition List 1910 Class to show a budget Decomposition List
1863 Constructor: 1911 Constructor:
1864 DecompositionList(budget, page, path) 1912 DecompositionList(budget, page, path, path_record=(0,))
1865 budget: budget showed ("base.Budget" object) 1913 budget: budget showed ("base.Budget" object)
1866 page: weak reference from Page instance which creates this class 1914 page: weak reference from Page instance which creates this class
1867 path: tuple that represents the view path in the Page 1915 path: tuple that represents the view path in the Page
1916 path_record: the record path that must be showed
1868 Returns the newly created DecompositionList instance 1917 Returns the newly created DecompositionList instance
1869 Ancestry: 1918 Ancestry:
1870 +-- object 1919 +-- object
1871 +-- TreeView 1920 +-- TreeView
1872 +-- DecompositionList 1921 +-- DecompositionList
1873 Atributes: 1922 Atributes:
1874 "budget": Budget to show, base.obra instance. 1923 budget: Read. Budget to show, base.obra object.
1875 "widget or __scrolled_window": Window that contains the table, 1924 widget: Read. Window that contains the table, gtk.ScrolledWindow
1876 (gtk.ScrolledWindow) 1925 path: Read-Write. Pane page identifier
1877 "path": Pane page identifier 1926 page: Read-Write. weak ref from Page object which creates this class
1878 "page": weak reference from Page instance which creates this class 1927 active_path_record: Read. Active path record
1879 "__active_color": background color of the active cell, a
1880 gtk.gdk.Color object
1881 "__chapter_background_colors": background colors of the Code
1882 column cells when there is a chapter record,
1883 list of gtk.gdk.Color objects [even cell, uneven cell]
1884 "__methond_message": Method to send messages to the page
1885 "__liststore": list model which store the list data
1886 (gtk.ListStore object)
1887 "__treeview": widget for displaying decomposition lists (gtk.TreeView)
1888 "__index_column": Index column (gtk.TreeViewColumn object)
1889 "__code_column": Record code column (gtk.TreeViewColumn)
1890 "__unit_column": Unit of measure column (gtk.TreeViewColumn)
1891 "__description_column": record's short description column
1892 (gtk.TreeViewColumn)
1893 "__measure_column": Measure column (gtk.TreeViewColumn)
1894 "__price_column": Price column (gtk.TreeViewColumn)
1895 "__amount_column": Amount column(gtk.TreeViewColumn)
1896 "__end_column": End empty column (gtk.TreeViewColumn)
1897 "__treeselection": active selection
1898 "__selection_control": state of the selection control (True/False)
1899 "__cursor": cursor position in the table
1900 Methods: 1928 Methods:
1901 __init__(self, budget) 1929 runMessage
1902 treeviewCursorChanged(self, treeview)
1903 treeviewClickedEvent(self, widget, event)
1904 treeviewKeyPressEvent(self, widget, event)
1905 moveCursor(self, treeview, step, count)
1906 controlSelection(self, selection)
1907 selectAll(self, column)
1908 setColumnsHeaders(self)
1909 setListstoreValues(self, puntero, treeiter=None)
1910 colorCell(self, column, cell_renderer, tree_model, iter, lcolor)
1911 _claculateAmount(self, row_path, tree_model)
1912 showParentRecord(self, column)
1913 showMessageRecord(self, camino,_code):
1914 showRowRecord(self, treeview, path, column)
1915 runMessage(self, messagem path, arg=None)
1916 _clear(self)
1917 getWidget(self)
1918 {get/set}Path
1919 {get/seg}Page
1920 getBudget(self)
1921 getActivePathRecord(self)
1922 """ 1930 """
1923 1931
1924 def __init__(self, budget, page, path, path_record=(0,)): 1932 def __init__(self, budget, page, path, path_record=(0,)):
1925 """def __init__(self, budget, page, path) 1933 """__init__(budget, page, path, path_record=(0,))
1926 1934
1927 budget: budget showed ("base.Budget" object) 1935 budget: budget showed ("base.Budget" object)
1928 page: weak reference from Page instance which creates this class 1936 page: weak reference from Page instance which creates this class
1929 path: tuple that represents the path of the List in the Page 1937 path: tuple that represents the path of the List in the Page
1938 path_record: the record path that must be showed
1939
1940 self.__budget: budget showed ("base.Budget" object)
1941 self.__page: weak reference from Page instance which creates this class
1942 self.__path: tuple that represents the path of the List in the Page
1943 self.__liststore: list model which store the list data
1944 (gtk.ListStore object)
1945 self.__active_path_record: the record path that must be showed
1946 self.__treeview: widget for displaying decomposition lists
1947 (gtk.TreeView)
1948 self.__scrolled_window: widget to contain the treeview object
1949 self.__chapter_background_colors: background colors of the Code
1950 column cells when there is a chapter record,
1951 list of gtk.gdk.Color objects [even cell, uneven cell]
1952 self.__chapter_background_colors
1953 self.__index_column: Index column (gtk.TreeViewColumn object)
1954 self.__code_column: Record code column (gtk.TreeViewColumn)
1955 self.__type_column: Record Type column (gtk.TreeViewColumn)
1956 self.__unit_column: Unit of measure column (gtk.TreeViewColumn)
1957 self.__description_column: record's short description column
1958 (gtk.TreeViewColumn)
1959 self.__measure_column: Measure column (gtk.TreeViewColumn)
1960 self.__price_column: Price column (gtk.TreeViewColumn)
1961 self.__amount_column: Amount column(gtk.TreeViewColumn)
1962 self.__end_column: End empty column (gtk.TreeViewColumn)
1963 self.__chapter_icon: a gtk.gdk.pixbuf
1964 self.__unit_icon: a gtk.gdk.pixbuf
1965 self.__material_icon: a gtk.gdk.pixbuf
1966 self.__machinery_icon: a gtk.gdk.pixbuf
1967 self.__labourforce_icon: a gtk.gdk.pixbuf
1968 self.__treeselection: active selection
1969 self.__selection_control: state of the selection control (True/False)
1970 self.__cursor: cursor position in the table
1930 1971
1931 Sets the init atributes 1972 Sets the init atributes
1932 Creates the init list values in self.__liststore from the budget 1973 Creates the init list values in self.__liststore from the budget
1933 showing the top record descomposition 1974 showing the top record descomposition
1934 Creates the list in self.__treeview 1975 Creates the list in self.__treeview
1947 # ListStore 1988 # ListStore
1948 self.__liststore = gtk.ListStore(object 1989 self.__liststore = gtk.ListStore(object
1949 #, int, int, str, str, str, str, str,str 1990 #, int, int, str, str, str, str, str,str
1950 ) 1991 )
1951 if path_record is None: 1992 if path_record is None:
1952 print _("DecompositionList.__init__: Record path can not be None") 1993 print _("Record path can not be None")
1953 path_record = (0,) 1994 path_record = (0,)
1954 self.__active_path_record = path_record 1995 self.__active_path_record = path_record
1955 self.setListstoreValues(self.__active_path_record) 1996 self._setListstoreValues(self.__active_path_record)
1956 # Treeview 1997 # Treeview
1957 self.__treeview = gtk.TreeView(self.__liststore) 1998 self.__treeview = gtk.TreeView(self.__liststore)
1958 self.__treeview.set_enable_search(False) 1999 self.__treeview.set_enable_search(False)
1959 self.__treeview.set_reorderable(False) 2000 self.__treeview.set_reorderable(False)
1960 self.__treeview.set_headers_clickable(True) 2001 self.__treeview.set_headers_clickable(True)
1971 gtk.gdk.color_parse(globalVars.color["EVEN"])] 2012 gtk.gdk.color_parse(globalVars.color["EVEN"])]
1972 self.__chapter_background_colors = [ 2013 self.__chapter_background_colors = [
1973 gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]), 2014 gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]),
1974 gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])] 2015 gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])]
1975 super(DecompositionList,self).__init__( 2016 super(DecompositionList,self).__init__(
1976 [("INDEX",self.selectAll,42), 2017 [("INDEX",self._selectAll,42),
1977 ("CALCULATEDTEXT", self.showParentRecord, 2018 ("CALCULATEDTEXT", self._showParentRecord,
1978 gtk.Label("A"*10).size_request()[0] +10, 2019 gtk.Label("A"*10).size_request()[0] +10,
1979 _text_color, _background_color), 2020 _text_color, _background_color),
1980 ("PIXBUF", self.showParentRecord, 26, _text_color, 2021 ("PIXBUF", self._showParentRecord, 26, _text_color,
1981 _background_color), 2022 _background_color),
1982 ("CALCULATEDTEXT", self.showParentRecord, 2023 ("CALCULATEDTEXT", self._showParentRecord,
1983 gtk.Label(_("a"*4)).size_request()[0] +10, 2024 gtk.Label(_("a"*4)).size_request()[0] +10,
1984 _text_color, _background_color), 2025 _text_color, _background_color),
1985 ("CALCULATEDTEXT", self.showParentRecord, 2026 ("CALCULATEDTEXT", self._showParentRecord,
1986 gtk.Label("a"*30).size_request()[0] +10, 2027 gtk.Label("a"*30).size_request()[0] +10,
1987 _text_color, _background_color), 2028 _text_color, _background_color),
1988 ("CALCULATED", self.showParentRecord, 2029 ("CALCULATED", self._showParentRecord,
1989 gtk.Label("a"*10).size_request()[0] +10, 2030 gtk.Label("a"*10).size_request()[0] +10,
1990 _text_color, _background_color), 2031 _text_color, _background_color),
1991 ("CALCULATED", self.showParentRecord, 2032 ("CALCULATED", self._showParentRecord,
1992 gtk.Label("a"*10).size_request()[0] +10, 2033 gtk.Label("a"*10).size_request()[0] +10,
1993 _text_color, _background_color), 2034 _text_color, _background_color),
1994 ("CALCULATED", self.showParentRecord, 2035 ("CALCULATED", self._showParentRecord,
1995 gtk.Label("a"*10).size_request()[0] +10, 2036 gtk.Label("a"*10).size_request()[0] +10,
1996 gtk.gdk.color_parse(globalVars.color["CALCULATED-TEXT"]), 2037 gtk.gdk.color_parse(globalVars.color["CALCULATED-TEXT"]),
1997 _background_color), 2038 _background_color),
1998 ]) 2039 ])
1999 self.__index_column = self.columns[0] 2040 self.__index_column = self.columns[0]
2009 self.__treeview.append_column(self.__index_column) 2050 self.__treeview.append_column(self.__index_column)
2010 # Code column 2051 # Code column
2011 self.__treeview.append_column(self.__code_column) 2052 self.__treeview.append_column(self.__code_column)
2012 # Type column 2053 # Type column
2013 self.__treeview.append_column(self.__type_column) 2054 self.__treeview.append_column(self.__type_column)
2014 self.chapter_icon = gtk.gdk.pixbuf_new_from_file( 2055 self.__chapter_icon = gtk.gdk.pixbuf_new_from_file(
2015 globalVars.getAppPath("CHAPTER-ICON")) 2056 globalVars.getAppPath("CHAPTER-ICON"))
2016 self.unit_icon = gtk.gdk.pixbuf_new_from_file( 2057 self.__unit_icon = gtk.gdk.pixbuf_new_from_file(
2017 globalVars.getAppPath("UNIT-ICON") ) 2058 globalVars.getAppPath("UNIT-ICON") )
2018 self.material_icon = gtk.gdk.pixbuf_new_from_file( 2059 self.__material_icon = gtk.gdk.pixbuf_new_from_file(
2019 globalVars.getAppPath("MATERIAL-ICON") ) 2060 globalVars.getAppPath("MATERIAL-ICON") )
2020 self.machinery_icon = gtk.gdk.pixbuf_new_from_file( 2061 self.__machinery_icon = gtk.gdk.pixbuf_new_from_file(
2021 globalVars.getAppPath("MACHINERY-ICON")) 2062 globalVars.getAppPath("MACHINERY-ICON"))
2022 self.labourforce_icon = gtk.gdk.pixbuf_new_from_file( 2063 self.__labourforce_icon = gtk.gdk.pixbuf_new_from_file(
2023 globalVars.getAppPath("LABOURFORCE-ICON")) 2064 globalVars.getAppPath("LABOURFORCE-ICON"))
2024 self.__type_column.get_cell_renderers()[0].set_property("pixbuf", 2065 self.__type_column.get_cell_renderers()[0].set_property("pixbuf",
2025 self.labourforce_icon) 2066 self.__labourforce_icon)
2026 2067
2027 # Unit column 2068 # Unit column
2028 self.__treeview.append_column(self.__unit_column) 2069 self.__treeview.append_column(self.__unit_column)
2029 # Description column 2070 # Description column
2030 self.__treeview.append_column(self.__description_column) 2071 self.__treeview.append_column(self.__description_column)
2035 # Amount column 2076 # Amount column
2036 self.__treeview.append_column(self.__amount_column) 2077 self.__treeview.append_column(self.__amount_column)
2037 # End Column 2078 # End Column
2038 self.__treeview.append_column(self.__end_column) 2079 self.__treeview.append_column(self.__end_column)
2039 # Connect 2080 # Connect
2040 self.__treeview.connect("row-activated", self.showRowRecord) 2081 self.__treeview.connect("row-activated", self._showRowRecord)
2041 self.__treeview.connect("move-cursor", self.moveCursor) 2082 self.__treeview.connect("move-cursor", self._moveCursor)
2042 self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) 2083 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
2043 self.__treeview.connect("button-press-event", self.treeviewClickedEvent) 2084 self.__treeview.connect("button-press-event",
2044 self.__treeview.connect("cursor-changed", self.treeviewCursorChanged) 2085 self._treeviewClickedEvent)
2086 self.__treeview.connect("cursor-changed", self._treeviewCursorChanged)
2045 # control selection 2087 # control selection
2046 self.__treeselection = self.__treeview.get_selection() 2088 self.__treeselection = self.__treeview.get_selection()
2047 self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) 2089 self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE)
2048 self.__treeselection.set_select_function(self.controlSelection) 2090 self.__treeselection.set_select_function(self._controlSelection)
2049 self.__selection_control = True 2091 self.__selection_control = True
2050 if len(self.__liststore) > 0: 2092 if len(self.__liststore) > 0:
2051 self.__treeview.set_cursor_on_cell((0,),self.__unit_column, 2093 self.__treeview.set_cursor_on_cell((0,),self.__unit_column,
2052 self.__unit_column.get_cell_renderers()[0],True) 2094 self.__unit_column.get_cell_renderers()[0],True)
2053 self.__treeview.grab_focus() 2095 self.__treeview.grab_focus()
2054 self.__cursor = self.__treeview.get_cursor() 2096 self.__cursor = self.__treeview.get_cursor()
2055 # Show 2097 # Show
2056 self.setColumnsHeaders() 2098 self._setColumnsHeaders()
2057 self.__scrolled_window.show() 2099 self.__scrolled_window.show()
2058 2100
2059 def treeviewCursorChanged(self, treeview): 2101 def _treeviewCursorChanged(self, treeview):
2060 """def treeviewCursorChanged(self, treeview) 2102 """_treeviewCursorChanged(treeview)
2061 2103
2062 treeview: treewiew widget 2104 treeview: treewiew widget
2063 Method connected to "cursor-changed" signal 2105 Method connected to "cursor-changed" signal
2064 The "cursor-changed" signal is emitted when the cursor moves or is set 2106 The "cursor-changed" signal is emitted when the cursor moves or is set
2065 Sets the new cursor position in self.__cursor, it is used to avoid 2107 Sets the new cursor position in self.__cursor, it is used to avoid
2068 event = gtk.get_current_event() 2110 event = gtk.get_current_event()
2069 (_cursor_path, _column) = treeview.get_cursor() 2111 (_cursor_path, _column) = treeview.get_cursor()
2070 if event is None or event.type != gtk.gdk.BUTTON_RELEASE: 2112 if event is None or event.type != gtk.gdk.BUTTON_RELEASE:
2071 if not _column is self.__index_column: 2113 if not _column is self.__index_column:
2072 self.__cursor = treeview.get_cursor() 2114 self.__cursor = treeview.get_cursor()
2073 2115
2074 def treeviewClickedEvent(self, widget, event): 2116 def _treeviewClickedEvent(self, widget, event):
2075 """def treeviewClickedEvent(self, widget, event) 2117 """_treeviewClickedEvent(widget, event)
2076 2118
2077 widget: treewiew widget 2119 widget: treewiew widget
2078 event: clicked event 2120 event: clicked event
2079 Method connected to "button-press-event" signal 2121 Method connected to "button-press-event" signal
2080 The "button-press-event" signal is emitted when a mouse button is 2122 The "button-press-event" signal is emitted when a mouse button is
2095 return True 2137 return True
2096 if _column is self.columns[0]: 2138 if _column is self.columns[0]:
2097 self.__cursor[0] == _path_cursor 2139 self.__cursor[0] == _path_cursor
2098 return False 2140 return False
2099 2141
2100 def treeviewKeyPressEvent(self, widget, event): 2142 def _treeviewKeyPressEvent(self, widget, event):
2101 """def treeviewKeyPressEvent(self, widget, event) 2143 """_treeviewKeyPressEvent(widget, event)
2102 2144
2103 widget: treewiew widget 2145 widget: treewiew widget
2104 event: Key Press event 2146 event: Key Press event
2105 Method connected to "key-press-event" signal 2147 Method connected to "key-press-event" signal
2106 The "key-press-event" signal is emitted when the user presses a key 2148 The "key-press-event" signal is emitted when the user presses a key
2118 or (event.keyval == gtk.keysyms.Left \ 2160 or (event.keyval == gtk.keysyms.Left \
2119 and _column == self.columns[1]): 2161 and _column == self.columns[1]):
2120 return True 2162 return True
2121 return False 2163 return False
2122 2164
2123 def moveCursor(self, treeview, step, count): 2165 def _moveCursor(self, treeview, step, count):
2124 """def treeviewKeyPressEvent(self, widget, event) 2166 """_moveCursor(treeview, step, count)
2125 2167
2126 treeview: the treeview that received the signal 2168 treeview: the treeview that received the signal
2127 step: the movement step size 2169 step: the movement step size
2128 count: the number of steps to take 2170 count: the number of steps to take
2129 2171
2134 2176
2135 Returns :TRUE if the signal was handled. 2177 Returns :TRUE if the signal was handled.
2136 """ 2178 """
2137 return False 2179 return False
2138 2180
2139 def controlSelection(self, selection): 2181 def _controlSelection(self, selection):
2140 """def controlSelection(self, selection) 2182 """_controlSelection(selection)
2141 2183
2142 selection: treeselection 2184 selection: treeselection
2143 2185
2144 Method connected to set_selection_function() 2186 Method connected to set_selection_function()
2145 This method is called before any node is selected or unselected, 2187 This method is called before any node is selected or unselected,
2159 self.__selection_control = False 2201 self.__selection_control = False
2160 self.__treeselection.unselect_all() 2202 self.__treeselection.unselect_all()
2161 self.__selection_control = True 2203 self.__selection_control = True
2162 return False 2204 return False
2163 2205
2164 def selectAll(self, column): 2206 def _selectAll(self, column):
2165 """def selectAll(self, column) 2207 """_selectAll(column)
2166 2208
2167 column: index column 2209 column: index column
2168 Method connected to "clicked" event in the index column 2210 Method connected to "clicked" event in the index column
2169 If the user clickes in the index column header selecs or deselects 2211 If the user clickes in the index column header selecs or deselects
2170 all rows 2212 all rows
2179 else: 2221 else:
2180 # unselect all 2222 # unselect all
2181 self.__treeselection.unselect_all() 2223 self.__treeselection.unselect_all()
2182 self.__selection_control = True 2224 self.__selection_control = True
2183 2225
2184 def setColumnsHeaders(self): 2226 def _setColumnsHeaders(self):
2185 """def setColumnsHeaders(self) 2227 """_setColumnsHeaders()
2186 2228
2187 Sets the headers column values 2229 Sets the headers column values
2188 """ 2230 """
2189 _path_record = self.__active_path_record 2231 _path_record = self.__active_path_record
2190 _number = _path_record[-1] 2232 _number = _path_record[-1]
2216 self.__price_column.set_title( 2258 self.__price_column.set_title(
2217 _("Price") + chr(10) + "[" + _price + "]") 2259 _("Price") + chr(10) + "[" + _price + "]")
2218 self.__amount_column.set_title( 2260 self.__amount_column.set_title(
2219 _("Amount") + chr(10) + "[" + str(_amount) + "]") 2261 _("Amount") + chr(10) + "[" + str(_amount) + "]")
2220 2262
2221 2263 def _setListstoreValues(self, path_record):
2222 def setListstoreValues(self, path_record): 2264 """_setListstoreValues(path_record)
2223 """def setListstoreValues(self, path_record)
2224 2265
2225 path_record: Record path in the budget 2266 path_record: Record path in the budget
2226 Sets the liststore record values from a path record 2267 Sets the liststore record values from a path record
2227 """ 2268 """
2228 self.__liststore.clear() 2269 self.__liststore.clear()
2246 #_record.prices[_budget.getActiveTitle()].prices] 2287 #_record.prices[_budget.getActiveTitle()].prices]
2247 #_record.getPrice(_budget.getActiveTitle()) 2288 #_record.getPrice(_budget.getActiveTitle())
2248 ] 2289 ]
2249 _treeiter = self.__liststore.append(_values) 2290 _treeiter = self.__liststore.append(_values)
2250 2291
2251 def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): 2292 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
2252 """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) 2293 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
2253 2294
2254 column: the gtk.TreeViewColumn in the treeview 2295 column: the gtk.TreeViewColumn in the treeview
2255 cell_renderer: a gtk.CellRenderer 2296 cell_renderer: a gtk.CellRenderer
2256 tree_model: the gtk.TreeModel 2297 tree_model: the gtk.TreeModel
2257 iter: gtk.TreeIter pointing at the row 2298 iter: gtk.TreeIter pointing at the row
2311 elif column is self.__type_column: 2352 elif column is self.__type_column:
2312 _hierarchy = tree_model[_row_path][0].recordType.hierarchy 2353 _hierarchy = tree_model[_row_path][0].recordType.hierarchy
2313 _type = tree_model[_row_path][0].recordType.type 2354 _type = tree_model[_row_path][0].recordType.type
2314 _subtype = tree_model[_row_path][0].recordType.subtype 2355 _subtype = tree_model[_row_path][0].recordType.subtype
2315 if _hierarchy == 1: 2356 if _hierarchy == 1:
2316 cell_renderer.set_property("pixbuf",self.chapter_icon) 2357 cell_renderer.set_property("pixbuf",self.__chapter_icon)
2317 else: 2358 else:
2318 if _type == 0: 2359 if _type == 0:
2319 cell_renderer.set_property("pixbuf",self.unit_icon) 2360 cell_renderer.set_property("pixbuf",self.__unit_icon)
2320 elif _type == 1: 2361 elif _type == 1:
2321 cell_renderer.set_property("pixbuf", 2362 cell_renderer.set_property("pixbuf",
2322 self.labourforce_icon) 2363 self.__labourforce_icon)
2323 elif _type == 2: 2364 elif _type == 2:
2324 cell_renderer.set_property("pixbuf", 2365 cell_renderer.set_property("pixbuf",
2325 self.machinery_icon) 2366 self.__machinery_icon)
2326 else: 2367 else:
2327 cell_renderer.set_property("pixbuf",self.material_icon) 2368 cell_renderer.set_property("pixbuf",self.__material_icon)
2328 if self.__treeview.get_cursor() == (_row_path,column): 2369 if self.__treeview.get_cursor() == (_row_path,column):
2329 cell_renderer.set_property('cell-background-gdk', 2370 cell_renderer.set_property('cell-background-gdk',
2330 gtk.gdk.color_parse(globalVars.color["ACTIVE"])) 2371 gtk.gdk.color_parse(globalVars.color["ACTIVE"]))
2331 else: 2372 else:
2332 cell_renderer.set_property('cell-background-gdk', 2373 cell_renderer.set_property('cell-background-gdk',
2333 lcolor[_number % 2]) 2374 lcolor[_number % 2])
2334 2375
2335 def showParentRecord(self, column): 2376 def _showParentRecord(self, column):
2336 """def showParentRecord(self, column) 2377 """_showParentRecord(column)
2337 2378
2338 column: the column that is clicked 2379 column: the column that is clicked
2339 Method connected to "clicked" event of many columns 2380 Method connected to "clicked" event of many columns
2340 Show the parent record 2381 Show the parent record
2341 """ 2382 """
2346 self.__treeview.set_cursor(self.__cursor[0], self.__cursor[1]) 2387 self.__treeview.set_cursor(self.__cursor[0], self.__cursor[1])
2347 else: 2388 else:
2348 _path_record = self.__active_path_record[:-1] 2389 _path_record = self.__active_path_record[:-1]
2349 _parent = self.__active_path_record[-1] 2390 _parent = self.__active_path_record[-1]
2350 self.__active_path_record = _path_record 2391 self.__active_path_record = _path_record
2351 self.setColumnsHeaders() 2392 self._setColumnsHeaders()
2352 self.setListstoreValues(self.__active_path_record) 2393 self._setListstoreValues(self.__active_path_record)
2353 arg = ( _path_record ) 2394 arg = ( _path_record )
2354 _page = self.__page() 2395 _page = self.__page()
2355 _page.propagateMessageFrom("change_active", self.__path, arg) 2396 _page.propagateMessageFrom("change_active", self.__path, arg)
2356 self.__treeview.set_cursor(_parent, self.__cursor[1]) 2397 self.__treeview.set_cursor(_parent, self.__cursor[1])
2357 self.__cursor = self.__treeview.get_cursor() 2398 self.__cursor = self.__treeview.get_cursor()
2358 2399
2359 def showMessageRecord(self, record_path): 2400 def _showMessageRecord(self, record_path):
2360 """def showMessageRecord(self, record_path) 2401 """_showMessageRecord(record_path)
2361 2402
2362 record_path: the path of the record to show 2403 record_path: the path of the record to show
2363 Method connected to "change_active" message 2404 Method connected to "change_active" message
2364 Show the record especified in the "change_active" message 2405 Show the record especified in the "change_active" message
2365 """ 2406 """
2366 _budget = self.__budget 2407 _budget = self.__budget
2367 self.__active_path_record = record_path 2408 self.__active_path_record = record_path
2368 self.setColumnsHeaders() 2409 self._setColumnsHeaders()
2369 self.setListstoreValues(self.__active_path_record) 2410 self._setListstoreValues(self.__active_path_record)
2370 self.__treeview.set_cursor((0,)) 2411 self.__treeview.set_cursor((0,))
2371 2412
2372 def showRowRecord(self, treeview, treeview_path, column): 2413 def _showRowRecord(self, treeview, treeview_path, column):
2373 """def showRowRecord(self, treeview, treeview_path, column) 2414 """_showRowRecord(treeview, treeview_path, column)
2374 2415
2375 treeview: treview to show 2416 treeview: treview to show
2376 treeview_path: the path of the record to show 2417 treeview_path: the path of the record to show
2377 code: the code of the record to show 2418 code: the code of the record to show
2378 2419
2392 #_code = _model.get_value(_iter, 4) 2433 #_code = _model.get_value(_iter, 4)
2393 _path_record = self.__active_path_record + treeview_path 2434 _path_record = self.__active_path_record + treeview_path
2394 if self.__budget.hasPath(_path_record): 2435 if self.__budget.hasPath(_path_record):
2395 # if this record path is valid 2436 # if this record path is valid
2396 self.__active_path_record = _path_record 2437 self.__active_path_record = _path_record
2397 self.setColumnsHeaders() 2438 self._setColumnsHeaders()
2398 self.setListstoreValues(self.__active_path_record) 2439 self._setListstoreValues(self.__active_path_record)
2399 self.__treeview.set_cursor((0,)) 2440 self.__treeview.set_cursor((0,))
2400 _arg = ( _path_record ) 2441 _arg = ( _path_record )
2401 _page = self.__page() 2442 _page = self.__page()
2402 _page.propagateMessageFrom("change_active", self.__path, 2443 _page.propagateMessageFrom("change_active", self.__path,
2403 _arg ) 2444 _arg )
2404 2445
2405 def runMessage(self, message, path, arg=None): 2446 def runMessage(self, message, path, arg=None):
2406 """def runMessage(self, message, path, arg=None) 2447 """runMessage(message, path, arg=None)
2407 2448
2408 message: the message type 2449 message: the message type
2409 "change_active": change the active record 2450 "change_active": change the active record
2410 "clear": clear instance 2451 "clear": clear instance
2411 path: tuple that identifies the pane in the notebook page 2452 path: tuple that identifies the pane in the notebook page
2416 """ 2457 """
2417 _budget = self.__budget 2458 _budget = self.__budget
2418 if message == "change_active": 2459 if message == "change_active":
2419 if _budget.hasPath(arg): 2460 if _budget.hasPath(arg):
2420 _path_record = arg 2461 _path_record = arg
2421 self.showMessageRecord( _path_record) 2462 self._showMessageRecord( _path_record)
2422 elif message == "clear": 2463 elif message == "clear":
2423 self._clear() 2464 self._clear()
2424 2465
2425 def _clear(self): 2466 def _clear(self):
2426 """def _clear(self) 2467 """_clear()
2427 2468
2428 it deletes the __budget value 2469 it deletes the __budget reference
2429 this would not be necessary if there were not circular references,
2430 which are pending to fix
2431 """ 2470 """
2432 del self.__budget 2471 del self.__budget
2433 2472
2434 def getWidget(self): 2473 def _getWidget(self):
2435 """def getWidget(self) 2474 """_getWidget()
2436 2475
2437 return the main widget (gtk.ScrolledWindow) 2476 return the main widget (gtk.ScrolledWindow)
2438 """ 2477 """
2439 return self.__scrolled_window 2478 return self.__scrolled_window
2440 2479
2441 def getPath(self): 2480 def _getPath(self):
2442 """def getPath(self) 2481 """_getPath()
2443 2482
2444 return the tuple that identifies the pane in the notebook page 2483 return the tuple that identifies the pane in the notebook page
2445 """ 2484 """
2446 return self.__path 2485 return self.__path
2447 2486
2448 def setPath(self, path): 2487 def _setPath(self, path):
2449 """def setPath(self) 2488 """_setPath()
2450 2489
2451 sets the tuple that identifies the pane in the notebook page 2490 sets the tuple that identifies the pane in the notebook page
2452 """ 2491 """
2453 self.__path = path 2492 self.__path = path
2454 2493
2455 def getPage(self): 2494 def _getPage(self):
2456 """def getPage(self) 2495 """_getPage()
2457 2496
2458 return the Page 2497 return the Page
2459 """ 2498 """
2460 return self.__page 2499 return self.__page
2461 2500
2462 def setPage(self,page): 2501 def _setPage(self,page):
2463 """def setPage(self) 2502 """_setPage()
2464 2503
2465 set the Page 2504 set the Page
2466 """ 2505 """
2467 self.__page = page 2506 self.__page = page
2468 2507
2469 def getBudget(self): 2508 def _getBudget(self):
2470 """def getBudget(self) 2509 """_getBudget()
2471 2510
2472 return the Budget objet 2511 return the Budget objet
2473 """ 2512 """
2474 return self.__budget 2513 return self.__budget
2475 2514
2476 def getActivePathRecord(self): 2515 def _getActivePathRecord(self):
2477 """def getActivePathRecord(self) 2516 """_getActivePathRecord()
2478 2517
2479 return the Active Path Record 2518 return the Active Path Record
2480 """ 2519 """
2481 return self.__active_path_record 2520 return self.__active_path_record
2482 2521
2483 widget = property(getWidget, None, None, 2522 widget = property(_getWidget, None, None,
2484 "Pane configuration list") 2523 "Pane configuration list")
2485 path = property(getPath, setPath, None, 2524 path = property(_getPath, _setPath, None,
2486 "path that identifie the item in the page notebook") 2525 "path that identifie the item in the page notebook")
2487 page = property(getPage, setPage, None, 2526 page = property(_getPage, _setPage, None,
2488 "weak reference from Page instance which creates this class") 2527 "weak reference from Page instance which creates this class")
2489 budget = property(getBudget, None, None, 2528 budget = property(_getBudget, None, None,
2490 "Budget object") 2529 "Budget object")
2491 active_path_record = property(getActivePathRecord, None, None, 2530 active_path_record = property(_getActivePathRecord, None, None,
2492 "Active path record") 2531 "Active path record")
2532
2493 2533
2494 class Measure(TreeView): 2534 class Measure(TreeView):
2495 """gui.Measure: 2535 """gui.Measure:
2496 2536
2497 Description: 2537 Description:
2498 Class to show a Measure List 2538 Class to show a Measure List
2499 Constructor: 2539 Constructor:
2500 Measure(budget, page, path) 2540 Measure(budget, page, path, path_record=(0,)
2501 budget: budget showed ("base.Budget" object) 2541 budget: budget showed ("base.Budget" object)
2502 page: weak reference from Page instance which creates this class 2542 page: weak reference from Page instance which creates this class
2503 path: tuple that represents the path of the List in the Page 2543 path: tuple that represents the path of the List in the Page
2504 Returns the newly created DecompositionList instance 2544 path_record: path of the active record in the budget
2505 Ancestry: 2545 Ancestry:
2506 +-- object 2546 +-- object
2507 +-- TreeView 2547 +-- TreeView
2508 +-- DecompositionList 2548 +-- DecompositionList
2509 Atributes: 2549 Atributes:
2510 "budget": Budget to show, base.obra instance. 2550 budget: Read. Budget to show, base.obra instance.
2511 "__active_path_record": path of the active record in the budget 2551 widget: Read. Window that contains the table, gtk.ScrolledWindow
2512 "widget or __scrolled_window": Window that contains the table, 2552 path: Read-Write. Pane page identifier
2513 (gtk.ScrolledWindow) 2553 page: Read-Write. weak reference from Page instance which creates
2514 "path": Pane page identifier 2554 this class
2515 "page": weak reference from Page instance which creates this class 2555 active_path_record: Read. Path of the active record in the budget
2516 "__active_color": The background color of the active cell as a
2517 gtk.gdk.Color object
2518 "__chapter_background_colors": The background colors of the Code
2519 column cells when there is a chapter record
2520 as a list of gtk.gdk.Color objects [even cell, uneven cell]
2521 "__methond_message": Method to send messages to the page
2522 "__liststore": list model which store the list data
2523 (gtk.ListStore object)
2524 "__treeview": widget for displaying decomposition lists (gtk.TreeView)
2525 "__index_column": Index column (gtk.TreeViewColumn object)
2526 "__code_column": Record code column (gtk.TreeViewColumn)
2527 "__unit_column": Unit of measure column (gtk.TreeViewColumn)
2528 "__description_column": record's short description column
2529 (gtk.TreeViewColumn)
2530 "__measure_column": Measure column (gtk.TreeViewColumn)
2531 "__price_column": Price column (gtk.TreeViewColumn)
2532 "__amount_column": Amount column(gtk.TreeViewColumn)
2533 "__end_column": End empty column (gtk.TreeViewColumn)
2534 "__treeselection": active selection
2535 "__selection_control": state of the selection control (True/False)
2536 "__cursor": Situation of the cursor in the table
2537 Methods: 2556 Methods:
2538 __init__(self, budget, page, path, path_record=(0,)) 2557 runMessage
2539 setListstoreValues(self, path_record)
2540 setColumnsHeaders(self)
2541 controlSelection(self, selection)
2542 showMessageRecord(self, record_path)
2543 treeviewCursorChanged(self, treeview)
2544 moveCursor(self, treeview, step, count)
2545 treeviewClickedEvent(self, widget, event)
2546 treeviewKeyPressEvent(self, widget, event)
2547 runMessage(self, message, path, arg=None)
2548 selectAll(self, column)
2549 colorCell(self, column, cell_renderer, tree_model, iter, lcolor)
2550 _clear(self)
2551 getWidget(self)
2552 {get/set}Path
2553 {get/set}Page
2554 getBudget(self)
2555 getActivePathRecord(self)
2556 """ 2558 """
2557 2559
2558 def __init__(self, budget, page, path, path_record=(0,)): 2560 def __init__(self, budget, page, path, path_record=(0,)):
2559 """def __init__(self, budget, page, path, path_record=(0,)) 2561 """__init__(budget, page, path, path_record=(0,))
2560 2562
2561 budget: budget: budget showed ("base.Budget" object) 2563 budget: budget: budget showed ("base.Budget" object)
2562 page: weak reference from Page instance which creates this class 2564 page: weak reference from Page instance which creates this class
2563 path: tuple that represents the path of the List in the Page 2565 path: tuple that represents the path of the List in the Page
2564 path_record: path of the active record in the budget 2566 path_record: path of the active record in the budget
2567
2568 self.__budget: budget showed ("base.Budget" object)
2569 self.__page: weak reference from Page instance which creates this class
2570 self.__path: tuple that represents the path of the List in the Page
2571 self.__active_path_record: path of the active record in the budget
2572 self.__liststore: list model which store the list data
2573 (gtk.ListStore object)
2574 self.__treeview: widget to display decomposition lists
2575 (gtk.TreeView)
2576 self.__scrolled_window: widget to scroll the treeview
2577 gtk.ScrolledWindow()
2578 self.__chapter_background_colors: The background colors of the Code
2579 column cells when there is a chapter record
2580 as a list of gtk.gdk.Color objects [even cell, uneven cell]
2581 self.__index_column: Index column (gtk.TreeViewColumn object)
2582 self.__linetype_column: Linetype column (gtk.TreeViewColumn object)
2583 self.__comment_column: Comment column (gtk.TreeViewColumn)
2584 self.__unit_column: Unit column (gtk.TreeViewColumn)
2585 self.__length_column: Legth column (gtk.TreeViewColumn)
2586 self.__width_column: With column (gtk.TreeViewColumn)
2587 self.__height_column: Height column (gtk.TreeViewColumn)
2588 self.__formula_column: Formula column (gtk.TreeViewColumn)
2589 self.__parcial_column: Parcial column (gtk.TreeViewColumn)
2590 self.__subtotal_column: Subtotal column (gtk.TreeViewColumn)
2591 self.__end_column: End empty column (gtk.TreeViewColumn
2592 self.__calculatedline_icon: gtk.gdk.pixbuf
2593 self.__normalline_icon: gtk.gdk.pixbuf
2594 self.__parcialline_icon: gtk.gdk.pixbuf
2595 self.__acumulatedline_icon: gtk.gdk.pixbuf
2596 self.__treeselection: active selection
2597 self.__selection_control: state of the selection control (True/False)
2598 self.__cursor: Situation of the cursor in the table
2565 2599
2566 Sets the init atributes 2600 Sets the init atributes
2567 Creates the init list values in self.__liststore from the budget 2601 Creates the init list values in self.__liststore from the budget
2568 showing the top record from the record with path path_record 2602 showing the top record from the record with path path_record
2569 Creates the list in self.__treeview 2603 Creates the list in self.__treeview
2582 print _("Record path must be a tuple") 2616 print _("Record path must be a tuple")
2583 path_record = (0,) 2617 path_record = (0,)
2584 self.__active_path_record = path_record 2618 self.__active_path_record = path_record
2585 # ListStore 2619 # ListStore
2586 self.__liststore = gtk.ListStore(object) 2620 self.__liststore = gtk.ListStore(object)
2587 self.setListstoreValues(self.__active_path_record) 2621 self._setListstoreValues(self.__active_path_record)
2588 # Treeview 2622 # Treeview
2589 self.__treeview = gtk.TreeView(self.__liststore) 2623 self.__treeview = gtk.TreeView(self.__liststore)
2590 self.__treeview.set_enable_search(False) 2624 self.__treeview.set_enable_search(False)
2591 self.__treeview.set_reorderable(False) 2625 self.__treeview.set_reorderable(False)
2592 self.__treeview.set_headers_clickable(True) 2626 self.__treeview.set_headers_clickable(True)
2604 gtk.gdk.color_parse(globalVars.color["EVEN"])] 2638 gtk.gdk.color_parse(globalVars.color["EVEN"])]
2605 self.__chapter_background_colors = [ 2639 self.__chapter_background_colors = [
2606 gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]), 2640 gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]),
2607 gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])] 2641 gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])]
2608 super(Measure,self).__init__( 2642 super(Measure,self).__init__(
2609 [("INDEX",self.selectAll,42), 2643 [("INDEX",self._selectAll,42),
2610 ("PIXBUF", self.passMethod, 2644 ("PIXBUF", self._passMethod,
2611 gtk.Label("A"*4).size_request()[0] +10, 2645 gtk.Label("A"*4).size_request()[0] +10,
2612 _text_color, _background_color), 2646 _text_color, _background_color),
2613 ("CALCULATEDTEXT", self.passMethod, 2647 ("CALCULATEDTEXT", self._passMethod,
2614 gtk.Label("A"*12).size_request()[0] +10, 2648 gtk.Label("A"*12).size_request()[0] +10,
2615 _text_color, _background_color), 2649 _text_color, _background_color),
2616 ("CALCULATED", self.passMethod, 2650 ("CALCULATED", self._passMethod,
2617 gtk.Label("A"*5).size_request()[0] +10, 2651 gtk.Label("A"*5).size_request()[0] +10,
2618 _text_color, _background_color), 2652 _text_color, _background_color),
2619 ("CALCULATED", self.passMethod, 2653 ("CALCULATED", self._passMethod,
2620 gtk.Label("A"*7).size_request()[0] +10, 2654 gtk.Label("A"*7).size_request()[0] +10,
2621 _text_color, _background_color), 2655 _text_color, _background_color),
2622 ("CALCULATED", self.passMethod, 2656 ("CALCULATED", self._passMethod,
2623 gtk.Label("A"*7).size_request()[0] +10, 2657 gtk.Label("A"*7).size_request()[0] +10,
2624 _text_color, _background_color), 2658 _text_color, _background_color),
2625 ("CALCULATED", self.passMethod, 2659 ("CALCULATED", self._passMethod,
2626 gtk.Label("A"*7).size_request()[0] +10, 2660 gtk.Label("A"*7).size_request()[0] +10,
2627 _text_color, _background_color), 2661 _text_color, _background_color),
2628 ("CALCULATEDTEXT", self.passMethod, 2662 ("CALCULATEDTEXT", self._passMethod,
2629 gtk.Label("A"*12).size_request()[0] +10, 2663 gtk.Label("A"*12).size_request()[0] +10,
2630 _text_color, _background_color), 2664 _text_color, _background_color),
2631 ("CALCULATED", self.passMethod, 2665 ("CALCULATED", self._passMethod,
2632 gtk.Label("A"*7).size_request()[0] +10, 2666 gtk.Label("A"*7).size_request()[0] +10,
2633 _calculated_text, _background_color), 2667 _calculated_text, _background_color),
2634 ("CALCULATED", self.passMethod, 2668 ("CALCULATED", self._passMethod,
2635 gtk.Label("A"*7).size_request()[0] +10, 2669 gtk.Label("A"*7).size_request()[0] +10,
2636 _calculated_text, _background_color), 2670 _calculated_text, _background_color),
2637 ]) 2671 ])
2672 # Colums
2638 self.__index_column = self.columns[0] 2673 self.__index_column = self.columns[0]
2639 self.__linetype_column = self.columns[1] 2674 self.__linetype_column = self.columns[1]
2640 self.__comment_column = self.columns[2] 2675 self.__comment_column = self.columns[2]
2641 self.__units_column = self.columns[3] 2676 self.__units_column = self.columns[3]
2642 self.__length_column = self.columns[4] 2677 self.__length_column = self.columns[4]
2648 self.__end_column = self.columns[10] 2683 self.__end_column = self.columns[10]
2649 # Index column 2684 # Index column
2650 self.__treeview.append_column(self.__index_column) 2685 self.__treeview.append_column(self.__index_column)
2651 # Linetype column 2686 # Linetype column
2652 self.__treeview.append_column(self.__linetype_column) 2687 self.__treeview.append_column(self.__linetype_column)
2653 self.calculatedline_icon = gtk.gdk.pixbuf_new_from_file( 2688 self.__calculatedline_icon = gtk.gdk.pixbuf_new_from_file(
2654 globalVars.getAppPath("CALCULATEDLINE-ICON")) 2689 globalVars.getAppPath("CALCULATEDLINE-ICON"))
2655 self.normalline_icon = gtk.gdk.pixbuf_new_from_file( 2690 self.__normalline_icon = gtk.gdk.pixbuf_new_from_file(
2656 globalVars.getAppPath("NORMALLINE-ICON") ) 2691 globalVars.getAppPath("NORMALLINE-ICON") )
2657 self.parcialline_icon = gtk.gdk.pixbuf_new_from_file( 2692 self.__parcialline_icon = gtk.gdk.pixbuf_new_from_file(
2658 globalVars.getAppPath("PARCIALLINE-ICON") ) 2693 globalVars.getAppPath("PARCIALLINE-ICON") )
2659 self.acumulatedline_icon = gtk.gdk.pixbuf_new_from_file( 2694 self.__acumulatedline_icon = gtk.gdk.pixbuf_new_from_file(
2660 globalVars.getAppPath("ACUMULATEDLINE-ICON")) 2695 globalVars.getAppPath("ACUMULATEDLINE-ICON"))
2661 # Comment column 2696 # Comment column
2662 self.__treeview.append_column(self.__comment_column) 2697 self.__treeview.append_column(self.__comment_column)
2663 # Units column 2698 # Units column
2664 self.__treeview.append_column(self.__units_column) 2699 self.__treeview.append_column(self.__units_column)
2675 # Subtotal column 2710 # Subtotal column
2676 self.__treeview.append_column(self.__subtotal_column) 2711 self.__treeview.append_column(self.__subtotal_column)
2677 # End Column 2712 # End Column
2678 self.__treeview.append_column(self.__end_column) 2713 self.__treeview.append_column(self.__end_column)
2679 # Connect 2714 # Connect
2680 self.__treeview.connect("move-cursor", self.moveCursor) 2715 self.__treeview.connect("move-cursor", self._moveCursor)
2681 self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) 2716 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
2682 self.__treeview.connect("button-press-event", self.treeviewClickedEvent) 2717 self.__treeview.connect("button-press-event",
2683 self.__treeview.connect("cursor-changed", self.treeviewCursorChanged) 2718 self._treeviewClickedEvent)
2719 self.__treeview.connect("cursor-changed", self._treeviewCursorChanged)
2684 # control selection 2720 # control selection
2685 self.__treeselection = self.__treeview.get_selection() 2721 self.__treeselection = self.__treeview.get_selection()
2686 self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) 2722 self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE)
2687 self.__treeselection.set_select_function(self.controlSelection) 2723 self.__treeselection.set_select_function(self._controlSelection)
2688 self.__selection_control = True 2724 self.__selection_control = True
2689 self.__treeview.set_cursor_on_cell((1,), self.columns[1], 2725 self.__treeview.set_cursor_on_cell((1,), self.columns[1],
2690 self.columns[1].get_cell_renderers()[0],True) 2726 self.columns[1].get_cell_renderers()[0],True)
2691 self.__treeview.grab_focus() 2727 self.__treeview.grab_focus()
2692 self.__cursor = self.__treeview.get_cursor() 2728 self.__cursor = self.__treeview.get_cursor()
2693 # Show 2729 # Show
2694 self.setColumnsHeaders() 2730 self._setColumnsHeaders()
2695 self.__scrolled_window.show() 2731 self.__scrolled_window.show()
2696 2732
2697 def passMethod(self, args): 2733 def _passMethod(self, column):
2734 """_passMethod(column)
2735
2736 column: the column that is clicked
2737 Method connected to "clicked" event of many columns
2738 Do nothing
2739 """
2698 pass 2740 pass
2699 2741
2700 def setListstoreValues(self, path_record): 2742 def _setListstoreValues(self, path_record):
2701 """def setListstoreValues(self, path_record) 2743 """_setListstoreValues(path_record)
2702 2744
2703 path_record: Record path in the budget 2745 path_record: Record path in the budget
2704 Sets the liststore record values from a path record 2746 Sets the liststore record values from a path record
2705 """ 2747 """
2706 self.__liststore.clear() 2748 self.__liststore.clear()
2710 else: 2752 else:
2711 _measure = _budget.getMeasure(path_record) 2753 _measure = _budget.getMeasure(path_record)
2712 if isinstance(_measure, base.Measure): 2754 if isinstance(_measure, base.Measure):
2713 _lines = _measure.lines 2755 _lines = _measure.lines
2714 for _line in _lines: 2756 for _line in _lines:
2715 _values = [ 2757 _values = [ _line ]
2716 _line,
2717 ## _line.type,
2718 ## _line.comment,
2719 ## _line.units,
2720 ## _line.length,
2721 ## _line.width,
2722 ## _line.height
2723 ]
2724 _treeiter = self.__liststore.append(_values) 2758 _treeiter = self.__liststore.append(_values)
2725 else: 2759 else:
2726 raise ValueError, utils.mapping(_("measure must be a Measure "\ 2760 raise ValueError, utils.mapping(_("measure must be a Measure "\
2727 "object. Type: $1"), (type(_measure),)) 2761 "object. Type: $1"), (type(_measure),))
2728 def setColumnsHeaders(self): 2762
2729 """def setColumnsHeaders(self) 2763 def _setColumnsHeaders(self):
2764 """_setColumnsHeaders()
2730 2765
2731 Sets the headers column values 2766 Sets the headers column values
2732 """ 2767 """
2733 _measure = self.__budget.getMeasure(self.__active_path_record) 2768 _measure = self.__budget.getMeasure(self.__active_path_record)
2734 _DS = self.__budget.getDecimals("DS") 2769 _DS = self.__budget.getDecimals("DS")
2741 self.columns[5].set_title(_("Width\n(c)")) 2776 self.columns[5].set_title(_("Width\n(c)"))
2742 self.columns[6].set_title(_("Height\n(d)")) 2777 self.columns[6].set_title(_("Height\n(d)"))
2743 self.columns[7].set_title(_("Formula")) 2778 self.columns[7].set_title(_("Formula"))
2744 self.columns[8].set_title(_("Parcial\n[%s]" % _total_str)) 2779 self.columns[8].set_title(_("Parcial\n[%s]" % _total_str))
2745 self.columns[9].set_title(_("Subtotal")) 2780 self.columns[9].set_title(_("Subtotal"))
2746 def controlSelection(self, selection): 2781
2747 """def controlSelection(self, selection) 2782 def _controlSelection(self, selection):
2783 """_controlSelection(selection)
2748 2784
2749 selection: treeselection 2785 selection: treeselection
2750 2786
2751 Method connected to set_selection_function() 2787 Method connected to set_selection_function()
2752 This method is called before any node is selected or unselected, 2788 This method is called before any node is selected or unselected,
2766 self.__selection_control = False 2802 self.__selection_control = False
2767 self.__treeselection.unselect_all() 2803 self.__treeselection.unselect_all()
2768 self.__selection_control = True 2804 self.__selection_control = True
2769 return False 2805 return False
2770 2806
2771 def showMessageRecord(self, record_path): 2807 def _showMessageRecord(self, record_path):
2772 """def showMessageRecord(self, record_path) 2808 """_showMessageRecord(record_path)
2773 2809
2774 record_path: the path of the record to show 2810 record_path: the path of the record to show
2775 Method connected to "change_active" message 2811 Method connected to "change_active" message
2776 Show the record especified in the "change_active" message 2812 Show the record especified in the "change_active" message
2777 """ 2813 """
2778 _budget = self.__budget 2814 _budget = self.__budget
2779 self.__active_path_record = record_path 2815 self.__active_path_record = record_path
2780 self.setColumnsHeaders() 2816 self._setColumnsHeaders()
2781 self.setListstoreValues(self.__active_path_record) 2817 self._setListstoreValues(self.__active_path_record)
2782 self.__treeview.set_cursor((0,)) 2818 self.__treeview.set_cursor((0,))
2783 2819
2784 def treeviewCursorChanged(self, treeview): 2820 def _treeviewCursorChanged(self, treeview):
2785 """def treeviewCursorChanged(self, treeview) 2821 """_treeviewCursorChanged(treeview)
2786 2822
2787 treeview: treewiew widget 2823 treeview: treewiew widget
2788 Method connected to "cursor-changed" signal 2824 Method connected to "cursor-changed" signal
2789 The "cursor-changed" signal is emitted when the cursor moves or is set 2825 The "cursor-changed" signal is emitted when the cursor moves or is set
2790 Sets the new cursor position in self.__cursor, it is used to avoid 2826 Sets the new cursor position in self.__cursor, it is used to avoid
2794 (_cursor_path, _column) = treeview.get_cursor() 2830 (_cursor_path, _column) = treeview.get_cursor()
2795 if event is None or event.type != gtk.gdk.BUTTON_RELEASE: 2831 if event is None or event.type != gtk.gdk.BUTTON_RELEASE:
2796 if not _column is self.__index_column: 2832 if not _column is self.__index_column:
2797 self.__cursor = treeview.get_cursor() 2833 self.__cursor = treeview.get_cursor()
2798 2834
2799 def moveCursor(self, treeview, step, count): 2835 def _moveCursor(self, treeview, step, count):
2800 """def treeviewKeyPressEvent(self, widget, event) 2836 """moveCursor(treeview, step, count)
2801 2837
2802 treeview: the treeview that received the signal 2838 treeview: the treeview that received the signal
2803 step: the movement step size 2839 step: the movement step size
2804 count: the number of steps to take 2840 count: the number of steps to take
2805 2841
2810 2846
2811 Returns :TRUE if the signal was handled. 2847 Returns :TRUE if the signal was handled.
2812 """ 2848 """
2813 return False 2849 return False
2814 2850
2815 def treeviewClickedEvent(self, widget, event): 2851 def _treeviewClickedEvent(self, widget, event):
2816 """def treeviewClickedEvent(self, widget, event) 2852 """_treeviewClickedEvent(widget, event)
2817 2853
2818 widget: treewiew widget 2854 widget: treewiew widget
2819 event: clicked event 2855 event: clicked event
2820 Method connected to "button-press-event" signal 2856 Method connected to "button-press-event" signal
2821 The "button-press-event" signal is emitted when a mouse button is 2857 The "button-press-event" signal is emitted when a mouse button is
2836 return True 2872 return True
2837 if _column is self.columns[0]: 2873 if _column is self.columns[0]:
2838 self.__cursor[0] == _path_cursor 2874 self.__cursor[0] == _path_cursor
2839 return False 2875 return False
2840 2876
2841 def treeviewKeyPressEvent(self, widget, event): 2877 def _treeviewKeyPressEvent(self, widget, event):
2842 """def treeviewKeyPressEvent(self, widget, event) 2878 """_treeviewKeyPressEvent(widget, event)
2843 2879
2844 widget: treewiew widget 2880 widget: treewiew widget
2845 event: Key Press event 2881 event: Key Press event
2846 Method connected to "key-press-event" signal 2882 Method connected to "key-press-event" signal
2847 The "key-press-event" signal is emitted when the user presses a key 2883 The "key-press-event" signal is emitted when the user presses a key
2860 and _column == self.columns[1]): 2896 and _column == self.columns[1]):
2861 return True 2897 return True
2862 return False 2898 return False
2863 2899
2864 def runMessage(self, message, path, arg=None): 2900 def runMessage(self, message, path, arg=None):
2865 """def runMessage(self, message, path, arg=None) 2901 """runMessage(message, path, arg=None)
2866 2902
2867 message: the message type 2903 message: the message type
2868 "change_active": change the active record 2904 "change_active": change the active record
2869 "clear": clear instance 2905 "clear": clear instance
2870 path: tuple that identifies the pane in the notebook page 2906 path: tuple that identifies the pane in the notebook page
2875 """ 2911 """
2876 _budget = self.__budget 2912 _budget = self.__budget
2877 if message == "change_active": 2913 if message == "change_active":
2878 if _budget.hasPath(arg): 2914 if _budget.hasPath(arg):
2879 _path_record = arg 2915 _path_record = arg
2880 self.showMessageRecord( _path_record) 2916 self._showMessageRecord( _path_record)
2881 elif message == "clear": 2917 elif message == "clear":
2882 self._clear() 2918 self._clear()
2883 2919
2884 def selectAll(self, column): 2920 def _selectAll(self, column):
2885 """def selectAll(self, column) 2921 """_selectAll(column)
2886 2922
2887 column: index column 2923 column: index column
2888 Method connected to "clicked" event in the index column 2924 Method connected to "clicked" event in the index column
2889 If the user clickes in the index column header selecs or deselects 2925 If the user clickes in the index column header selecs or deselects
2890 all rows 2926 all rows
2899 else: 2935 else:
2900 # unselect all 2936 # unselect all
2901 self.__treeselection.unselect_all() 2937 self.__treeselection.unselect_all()
2902 self.__selection_control = True 2938 self.__selection_control = True
2903 2939
2904 def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): 2940 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
2905 """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) 2941 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
2906 2942
2907 column: the gtk.TreeViewColumn in the treeview 2943 column: the gtk.TreeViewColumn in the treeview
2908 cell_renderer: a gtk.CellRenderer 2944 cell_renderer: a gtk.CellRenderer
2909 tree_model: the gtk.TreeModel 2945 tree_model: the gtk.TreeModel
2910 iter: gtk.TreeIter pointing at the row 2946 iter: gtk.TreeIter pointing at the row
2934 'cell-background-gdk', lcolor[_number % 2]) 2970 'cell-background-gdk', lcolor[_number % 2])
2935 elif column is self.__linetype_column: 2971 elif column is self.__linetype_column:
2936 _measure = tree_model[_row_path][0] 2972 _measure = tree_model[_row_path][0]
2937 _type = _measure.lineType 2973 _type = _measure.lineType
2938 if _type == 0: 2974 if _type == 0:
2939 cell_renderer.set_property("pixbuf",self.normalline_icon) 2975 cell_renderer.set_property("pixbuf",self.__normalline_icon)
2940 elif _type == 1: 2976 elif _type == 1:
2941 cell_renderer.set_property("pixbuf",self.parcialline_icon) 2977 cell_renderer.set_property("pixbuf",self.__parcialline_icon)
2942 elif _type == 2: 2978 elif _type == 2:
2943 cell_renderer.set_property("pixbuf", 2979 cell_renderer.set_property("pixbuf",
2944 self.acumulatedline_icon) 2980 self.__acumulatedline_icon)
2945 else: #elif _type == 3: 2981 else: #elif _type == 3:
2946 cell_renderer.set_property("pixbuf", 2982 cell_renderer.set_property("pixbuf",
2947 self.calculatedline_icon) 2983 self.__calculatedline_icon)
2948 2984
2949 elif column is self.__comment_column: 2985 elif column is self.__comment_column:
2950 _measure = tree_model[_row_path][0] 2986 _measure = tree_model[_row_path][0]
2951 _comment = str(_measure.comment) 2987 _comment = str(_measure.comment)
2952 cell_renderer.set_property('text', _comment) 2988 cell_renderer.set_property('text', _comment)
3018 else: 3054 else:
3019 cell_renderer.set_property('cell-background-gdk', 3055 cell_renderer.set_property('cell-background-gdk',
3020 lcolor[_number % 2]) 3056 lcolor[_number % 2])
3021 3057
3022 def _clear(self): 3058 def _clear(self):
3023 """def _clear(self) 3059 """_clear()
3024 3060
3025 it deletes the __budget value 3061 it deletes the __budget value
3026 this would not be necessary if there were not circular references,
3027 which are pending to fix
3028 """ 3062 """
3029 del self.__budget 3063 del self.__budget
3030 3064
3031 def getWidget(self): 3065 def _getWidget(self):
3032 """def getWidget(self) 3066 """_getWidget()
3033 3067
3034 return the main widget (gtk.ScrolledWindow) 3068 return the main widget (gtk.ScrolledWindow)
3035 """ 3069 """
3036 return self.__scrolled_window 3070 return self.__scrolled_window
3037 3071
3038 def getPath(self): 3072 def _getPath(self):
3039 """def getPath(self) 3073 """_getPath()
3040 3074
3041 return the tuple that identifies the pane in the notebook page 3075 return the tuple that identifies the pane in the notebook page
3042 """ 3076 """
3043 return self.__path 3077 return self.__path
3044 3078
3045 def setPath(self, path): 3079 def _setPath(self, path):
3046 """def setPath(self) 3080 """_setPath()
3047 3081
3048 sets the tuple that identifies the pane in the notebook page 3082 sets the tuple that identifies the pane in the notebook page
3049 """ 3083 """
3050 self.__path = path 3084 self.__path = path
3051 def getPage(self): 3085
3052 """def getPage(self) 3086 def _getPage(self):
3087 """_getPage()
3053 3088
3054 return the Page 3089 return the Page
3055 """ 3090 """
3056 return self.__page 3091 return self.__page
3057 3092
3058 def setPage(self,page): 3093 def _setPage(self,page):
3059 """def setPage(self) 3094 """_setPage()
3060 3095
3061 set the Page 3096 set the Page
3062 """ 3097 """
3063 self.__page = page 3098 self.__page = page
3064 3099
3065 def getBudget(self): 3100 def _getBudget(self):
3066 """def getBudget(self) 3101 """_getBudget()
3067 3102
3068 return the Budget objet 3103 return the Budget objet
3069 """ 3104 """
3070 return self.__budget 3105 return self.__budget
3071 3106
3072 def getActivePathRecord(self): 3107 def _getActivePathRecord(self):
3073 """def getActivePathRecord(self) 3108 """getActivePathRecord()
3074 3109
3075 return the Active Path Record 3110 return the Active Path Record
3076 """ 3111 """
3077 return self.__active_path_record 3112 return self.__active_path_record
3078 3113
3079 widget = property(getWidget, None, None, 3114 widget = property(_getWidget, None, None,
3080 "Pane configuration list") 3115 "Pane configuration list")
3081 path = property(getPath, setPath, None, 3116 path = property(_getPath, _setPath, None,
3082 "Path that identifies the item in the page notebook") 3117 "Path that identifies the item in the page notebook")
3083 page = property(getPage, setPage, None, 3118 page = property(_getPage, _setPage, None,
3084 "Weak reference from Page instance which creates this class") 3119 "Weak reference from Page instance which creates this class")
3085 budget = property(getBudget, None, None, 3120 budget = property(_getBudget, None, None,
3086 "Budget object") 3121 "Budget object")
3087 active_path_record = property(getActivePathRecord, None, None, 3122 active_path_record = property(_getActivePathRecord, None, None,
3088 "Active Code") 3123 "Active Code")
3124
3089 3125
3090 class Description(object): 3126 class Description(object):
3091 """gui.Description 3127 """gui.Description
3092 3128
3093 Description: 3129 Description:
3094 Class to show a description text of a record in a pane 3130 Class to show a description text of a record in a pane
3095 Constructor: 3131 Constructor:
3096 Description(budget, code) 3132 Description(budget, code)
3097 budget: budget 3133 budget: base.Budget object
3098 code: code record 3134 code: record code
3099 Ancestry: 3135 Ancestry:
3100 +-- object 3136 +-- object
3101 +-- Description 3137 +-- Description
3102 Atributes: 3138 Atributes:
3103 "widget": the main widget (gtk.ScrolledWindow object) 3139 widget: the main widget (gtk.ScrolledWindow object)
3104 "path": the tuple that identifies the pane in the notebook page 3140 path: the tuple that identifies the pane in the notebook page
3105 TODO 3141 budget: The budget (base.obra objetc)
3106 "budget": The budget (base.obra objetc) 3142 active_path_record: The active path record
3107 "active_code": The active code of the record
3108 "__textbuffer": The textbuffer of the textview that contain
3109 the record text.
3110 "__label": The gtk.label with the title of the pane
3111 Methods: 3143 Methods:
3112 __init__(self, budget, code) 3144 runMessage
3113 setActiveCode(self, code)
3114 runMessage(self, message, nt, arg=None)
3115 _clear(self)
3116 getWidget(self)
3117 {get/set}Path
3118 {get/seg}Page
3119 getBudget(self)
3120 getActviCode(self)
3121 """ 3145 """
3122 # TODO: make standar: "DecompositonList and Description" 3146 # TODO: make standar: "DecompositonList and Description"
3147
3123 def __init__(self, budget, page, path, path_record=(0,)): 3148 def __init__(self, budget, page, path, path_record=(0,)):
3124 """def __init__(self, budget, page, path, path_record=(0,)) 3149 """__init__(budget, page, path, path_record=(0,))
3125 3150
3126 budget: the budget (base.obra object) 3151 budget: the budget (base.obra object)
3127 page: weak reference from Page instance which creates this class 3152 page: weak reference from Page instance which creates this class
3128 path: the path position of the description in the page 3153 path: the path position of the description in the page
3129 path_record: the path of the active record 3154 path_record: the path of the active record
3155
3156 self.__budget: the budget (base.obra object)
3157 self.__page: weak reference from Page instance which creates this class
3158 self.__path: the path position of the description in the page
3159 self.__active_path_recordthe path of the active record
3160
3161 self.__textbuffer: The textbuffer of the textview that contain
3162 the record text.
3163 self.__label: The gtk.label with the title of the pane
3164 self.__widget: the main pane widget, a gtk.ScrolledWindow()
3130 3165
3131 Creates an shows the scroledwindow that contain the description text 3166 Creates an shows the scroledwindow that contain the description text
3132 of the record to be showed in a pane. 3167 of the record to be showed in a pane.
3133 """ 3168 """
3134 self.__budget = budget 3169 self.__budget = budget
3161 _scrollwindow.add_with_viewport(_vbox) 3196 _scrollwindow.add_with_viewport(_vbox)
3162 _scrollwindow.show() 3197 _scrollwindow.show()
3163 self.__widget = _scrollwindow 3198 self.__widget = _scrollwindow
3164 3199
3165 3200
3166 def setActivePathRecord(self, path_record): 3201 def _setActivePathRecord(self, path_record):
3167 """def setActivePathRecord(self, path_record)) 3202 """_setActivePathRecord(path_record))
3168 3203
3169 path_record: active path record 3204 path_record: active path record
3170 Set the new path code to show its description text. 3205 Set the new path code to show its description text.
3171 """ 3206 """
3172 _budget = self.__budget 3207 _budget = self.__budget
3176 "$1"), (_code,))) 3211 "$1"), (_code,)))
3177 _text = _budget.getRecord(_code).text 3212 _text = _budget.getRecord(_code).text
3178 self.__textbuffer.set_text(_text) 3213 self.__textbuffer.set_text(_text)
3179 3214
3180 def runMessage(self, message, path, arg=None): 3215 def runMessage(self, message, path, arg=None):
3181 """def runMessage(self, message, path, arg=None) 3216 """runMessage(message, path, arg=None)
3182 3217
3183 message: the message type 3218 message: the message type
3184 "change_active": change the active record 3219 "change_active": change the active record
3185 "clear": clear instance 3220 "clear": clear instance
3186 path: tuple that identifies the pane in the notebook page 3221 path: tuple that identifies the pane in the notebook page
3190 This method receives a message and executes its corresponding action 3225 This method receives a message and executes its corresponding action
3191 """ 3226 """
3192 _budget = self.__budget 3227 _budget = self.__budget
3193 if message == "change_active": 3228 if message == "change_active":
3194 if _budget.hasPath(arg): 3229 if _budget.hasPath(arg):
3195 self.setActivePathRecord(arg) 3230 self._setActivePathRecord(arg)
3196 elif message == "clear": 3231 elif message == "clear":
3197 self._clear() 3232 self._clear()
3198 3233
3199 def _clear(self): 3234 def _clear(self):
3200 """def _clear(self) 3235 """_clear()
3201 3236
3202 Delete all instance atributes 3237 Delete all instance atributes
3203 """ 3238 """
3204 del self.__widget 3239 del self.__widget
3205 del self.__path 3240 del self.__path
3206 del self.__budget 3241 del self.__budget
3207 del self.__active_code 3242 del self.__active_code
3208 del self.__textbuffer 3243 del self.__textbuffer
3209 del self.__label 3244 del self.__label
3210 3245
3211 def getWidget(self): 3246 def _getWidget(self):
3212 """def getWidget(self) 3247 """_getWidget()
3213 3248
3214 return the main widget (gtk.ScrolledWindow) 3249 return the main widget (gtk.ScrolledWindow)
3215 """ 3250 """
3216 return self.__widget 3251 return self.__widget
3217 3252
3218 def getPath(self): 3253 def _getPath(self):
3219 """def getPath(self) 3254 """_getPath()
3220 3255
3221 return the tuple that identifies the pane in the notebook page 3256 return the tuple that identifies the pane in the notebook page
3222 """ 3257 """
3223 return self.__path 3258 return self.__path
3224 3259
3225 def setPath(self, path): 3260 def _setPath(self, path):
3226 """def setPath(self) 3261 """_setPath()
3227 3262
3228 sets the tuple that identifies the pane in the notebook page 3263 sets the tuple that identifies the pane in the notebook page
3229 """ 3264 """
3230 self.__path = path 3265 self.__path = path
3231 3266
3232 def getPage(self): 3267 def _getPage(self):
3233 """def getPage(self) 3268 """_getPage()
3234 3269
3235 return the weak reference from Page instance 3270 return the weak reference from Page instance
3236 """ 3271 """
3237 return self.__page 3272 return self.__page
3238 3273
3239 def setPage(self, page): 3274 def _setPage(self, page):
3240 """def setPage(self) 3275 """_setPage()
3241 3276
3242 set the weak reference from Page instance 3277 set the weak reference from Page instance
3243 """ 3278 """
3244 self.__page = page 3279 self.__page = page
3245 3280
3246 def getBudget(self): 3281 def _getBudget(self):
3247 """def getBudget(self) 3282 """_getBudget()
3248 3283
3249 return the budget object 3284 return the budget object
3250 """ 3285 """
3251 return self.__budget 3286 return self.__budget
3252 3287
3253 def getActivePathRecord(self): 3288 def _getActivePathRecord(self):
3254 """def getActivePathRecord(self) 3289 """_getActivePathRecord()
3255 3290
3256 return the Active Path Record 3291 return the Active Path Record
3257 """ 3292 """
3258 return self.__active_path_record 3293 return self.__active_path_record
3259 3294
3260 path = property(getPath, setPath, None, 3295 path = property(_getPath, _setPath, None,
3261 "Path that identifie the item in the page notebook") 3296 "Path that identifie the item in the page notebook")
3262 widget = property(getWidget, None, None, 3297 widget = property(_getWidget, None, None,
3263 "The main widget (gtk.ScrolledWindow)") 3298 "The main widget (gtk.ScrolledWindow)")
3264 page = property(getPage, setPage, None, 3299 page = property(_getPage, _setPage, None,
3265 "Weak reference from Page instance which creates this class") 3300 "Weak reference from Page instance which creates this class")
3266 budget = property(getBudget, None, None, 3301 budget = property(_getBudget, None, None,
3267 "Budget object") 3302 "Budget object")
3268 active_path_record = property(getActivePathRecord, None, None, 3303 active_path_record = property(_getActivePathRecord, None, None,
3269 "Active Path Record") 3304 "Active Path Record")
3305
3270 3306
3271 class Sheet(object): 3307 class Sheet(object):
3272 """gui.Sheet 3308 """gui.Sheet
3273 3309
3274 Description: 3310 Description:
3279 code: code record 3315 code: code record
3280 Ancestry: 3316 Ancestry:
3281 +-- object 3317 +-- object
3282 +-- Sheet 3318 +-- Sheet
3283 Atributes: 3319 Atributes:
3284 "widget": the main widget (gtk.ScrolledWindow object) 3320 widget: the main widget (gtk.VBox() object)
3285 "path": the tuple that identifies the pane in the notebook page 3321 path: the tuple that identifies the pane in the notebook page
3286 "budget": The budget (base.obra objetc) 3322 page: weak reference from Page instance which creates this class
3287 "active_path_record": The active path record 3323 budget: The budget (base.obra objetc)
3288 "page": weak reference from Page instance which creates this class 3324 active_path_record: The active path record
3289
3290 "__textbuffer": The textbuffer of the textview that contain
3291 the record text.
3292 "__label": The gtk.label with the title of the pane
3293 "__field_liststore": the field liststore
3294 "__field_treeview": the field treeview
3295 "__field_selection": the field selected in field treview
3296 "__section_liststore": the section liststore
3297 "__section_treeview": the section treeview
3298 "__section_selection": the section selected in the section treeview
3299 Methods: 3325 Methods:
3300 __init__(self, budget, code) 3326 runMessage
3301 setFields(self)
3302 setSection(self)
3303 setText(self)
3304 field_controlSelection(self, selection)
3305 section_controlSelection(self, selection)
3306 runMessage(self, message, nt, arg=None)
3307 _clear(self)
3308 getWidget(self)
3309 {get/set}Path
3310 {get/set}Page
3311 getBudget(self)
3312 getActviPathRecord(self)
3313 """ 3327 """
3328
3314 def __init__(self, budget, page, path, path_record=(0,)): 3329 def __init__(self, budget, page, path, path_record=(0,)):
3315 """def __init__(self, budget, page, path, path_record=(0,)) 3330 """__init__(budget, page, path, path_record=(0,))
3316 3331
3317 budget: the budget (base.obra object) 3332 budget: the budget (base.obra object)
3318 page: weak reference from Page instance which creates this class 3333 page: weak reference from Page instance which creates this class
3319 path: the path position of the description in the page 3334 path: the path position of the description in the page
3320 path_record: the path of the active record 3335 path_record: the path of the active record
3336
3337 self.__budget: the budget (base.obra object)
3338 self.__page: weak reference from Page instance which creates this class
3339 self.__path: the path position of the description in the page
3340 self.__active_path_record: the path of the active record
3341 self.__label: The gtk.label with the title of the pane
3342 self.__field_liststore: the field liststore
3343 self.__field_treeview: the field treeview
3344 self.__field_selection: the field selected in field treview
3345 self.__section_liststore: the section liststore
3346 self.__section_treeview: the section treeview
3347 self.__section_selection: the section selected in the section treeview
3348 self.__textbuffer: The textbuffer of the textview that contain
3349 the record text.
3350 self.__widget: main widget, a gtk.VBox()
3351
3321 Creates an shows the scroledwindow that contain the description text 3352 Creates an shows the scroledwindow that contain the description text
3322 of the record to be showed in a pane. 3353 of the record to be showed in a pane.
3323 """ 3354 """
3324 self.__budget = budget 3355 self.__budget = budget
3325 self.__page = page 3356 self.__page = page
3326 self.__path = path 3357 self.__path = path
3327 self.__active_path_record = path_record 3358 self.__active_path_record = path_record
3328 _budget = budget 3359 _budget = budget
3329
3330 _main_box = gtk.VBox() 3360 _main_box = gtk.VBox()
3331
3332 self.__label = gtk.Label(utils.mapping(_("Sheet of Conditions of the "\ 3361 self.__label = gtk.Label(utils.mapping(_("Sheet of Conditions of the "\
3333 "record $1"), (self.__budget.getCode( 3362 "record $1"), (self.__budget.getCode(
3334 self.__active_path_record),))) 3363 self.__active_path_record),)))
3335 self.__label.set_alignment(0, 0) 3364 self.__label.set_alignment(0, 0)
3336 self.__label.show() 3365 self.__label.show()
3337
3338 _frame = gtk.Frame() 3366 _frame = gtk.Frame()
3339 _frame.set_shadow_type(gtk.SHADOW_IN) 3367 _frame.set_shadow_type(gtk.SHADOW_IN)
3340 _frame_box = gtk.VBox() 3368 _frame_box = gtk.VBox()
3341 _list_box = gtk.HBox() 3369 _list_box = gtk.HBox()
3342
3343 self.__field_liststore = gtk.ListStore(str, str) 3370 self.__field_liststore = gtk.ListStore(str, str)
3344 self.__field_treeview = gtk.TreeView(self.__field_liststore) 3371 self.__field_treeview = gtk.TreeView(self.__field_liststore)
3345 _field_treeselection = self.__field_treeview.get_selection() 3372 _field_treeselection = self.__field_treeview.get_selection()
3346 _field_treeselection.set_mode(gtk.SELECTION_SINGLE) 3373 _field_treeselection.set_mode(gtk.SELECTION_SINGLE)
3347 self.__field_selection = None 3374 self.__field_selection = None
3348 _field_treeselection.set_select_function( 3375 _field_treeselection.set_select_function(
3349 self.field_controlSelection) 3376 self._field_controlSelection)
3350 self.__field_treeview.show() 3377 self.__field_treeview.show()
3351 _fieldcode_cell = gtk.CellRendererText() 3378 _fieldcode_cell = gtk.CellRendererText()
3352 _field_column = gtk.TreeViewColumn(_("Field")) 3379 _field_column = gtk.TreeViewColumn(_("Field"))
3353 _field_column.pack_start(_fieldcode_cell, False) 3380 _field_column.pack_start(_fieldcode_cell, False)
3354 _field_cell = gtk.CellRendererText() 3381 _field_cell = gtk.CellRendererText()
3359 _field_scrollwindow = gtk.ScrolledWindow() 3386 _field_scrollwindow = gtk.ScrolledWindow()
3360 _field_scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, 3387 _field_scrollwindow.set_policy(gtk.POLICY_AUTOMATIC,
3361 gtk.POLICY_AUTOMATIC) 3388 gtk.POLICY_AUTOMATIC)
3362 _field_scrollwindow.add(self.__field_treeview) 3389 _field_scrollwindow.add(self.__field_treeview)
3363 _field_scrollwindow.show() 3390 _field_scrollwindow.show()
3364
3365 self.__section_liststore = gtk.ListStore(str, str) 3391 self.__section_liststore = gtk.ListStore(str, str)
3366 self.__section_treeview = gtk.TreeView(self.__section_liststore) 3392 self.__section_treeview = gtk.TreeView(self.__section_liststore)
3367 _section_treeselection = self.__section_treeview.get_selection() 3393 _section_treeselection = self.__section_treeview.get_selection()
3368 _section_treeselection.set_mode(gtk.SELECTION_SINGLE) 3394 _section_treeselection.set_mode(gtk.SELECTION_SINGLE)
3369 self.__section_selection = None 3395 self.__section_selection = None
3370 _section_treeselection.set_select_function( 3396 _section_treeselection.set_select_function(
3371 self.section_controlSelection) 3397 self._section_controlSelection)
3372 self.__section_treeview.show() 3398 self.__section_treeview.show()
3373 _sectioncode_cell = gtk.CellRendererText() 3399 _sectioncode_cell = gtk.CellRendererText()
3374 _section_column = gtk.TreeViewColumn(_("Section")) 3400 _section_column = gtk.TreeViewColumn(_("Section"))
3375 _section_column.pack_start(_sectioncode_cell, False) 3401 _section_column.pack_start(_sectioncode_cell, False)
3376 _section_column.add_attribute(_sectioncode_cell, "text", 0) 3402 _section_column.add_attribute(_sectioncode_cell, "text", 0)
3396 self.__textbuffer = _textview.get_buffer() 3422 self.__textbuffer = _textview.get_buffer()
3397 _textview.show() 3423 _textview.show()
3398 _hbox = gtk.HBox() 3424 _hbox = gtk.HBox()
3399 _hbox.pack_start(_textview, True, True, 5) 3425 _hbox.pack_start(_textview, True, True, 5)
3400 _hbox.show() 3426 _hbox.show()
3401
3402 _frame_box.pack_start(self.__label, False, False, 5) 3427 _frame_box.pack_start(self.__label, False, False, 5)
3403 _frame_box.pack_start(_list_box, False, False, 5) 3428 _frame_box.pack_start(_list_box, False, False, 5)
3404 _frame_box.show() 3429 _frame_box.show()
3405 _frame.add(_frame_box) 3430 _frame.add(_frame_box)
3406 _frame.show() 3431 _frame.show()
3407 _main_box.pack_start(_frame, False) 3432 _main_box.pack_start(_frame, False)
3408
3409
3410 _vbox = gtk.VBox() 3433 _vbox = gtk.VBox()
3411 _vbox.pack_start(_hbox, True, True, 5) 3434 _vbox.pack_start(_hbox, True, True, 5)
3412 _vbox.show() 3435 _vbox.show()
3413 _main_box.pack_start(_scrollwindow, True, True, 5) 3436 _main_box.pack_start(_scrollwindow, True, True, 5)
3414 _main_box.show() 3437 _main_box.show()
3415
3416 _scrollwindow.add_with_viewport(_vbox) 3438 _scrollwindow.add_with_viewport(_vbox)
3417 _scrollwindow.show() 3439 _scrollwindow.show()
3418 self.__widget = _main_box 3440 self.__widget = _main_box
3419 3441 self._setFields()
3420 self.setFields() 3442
3421 3443 def _setFields(self):
3422 def setFields(self): 3444 """_setFields()
3423 """setFields(self)
3424 3445
3425 Set the fields items in the field treeview 3446 Set the fields items in the field treeview
3426 """ 3447 """
3427 _record = self.__budget.getRecord(self.__budget.getCode( 3448 _record = self.__budget.getRecord(self.__budget.getCode(
3428 self.__active_path_record)) 3449 self.__active_path_record))
3433 _field_text = self.__budget.getSheetField(_field) 3454 _field_text = self.__budget.getSheetField(_field)
3434 _iter = self.__field_liststore.append([_field, _field_text]) 3455 _iter = self.__field_liststore.append([_field, _field_text])
3435 _treeselection = self.__field_treeview.get_selection() 3456 _treeselection = self.__field_treeview.get_selection()
3436 _treeselection.select_path(0) 3457 _treeselection.select_path(0)
3437 3458
3438 def setSection(self): 3459 def _setSection(self):
3439 """setSection(self) 3460 """_setSection()
3440 3461
3441 Set the section items in the section treeview 3462 Set the section items in the section treeview
3442 """ 3463 """
3443 self.__section_liststore.clear() 3464 self.__section_liststore.clear()
3444 if not self.__field_selection is None: 3465 if not self.__field_selection is None:
3450 _section_text = self.__budget.getSheetSection(_section) 3471 _section_text = self.__budget.getSheetSection(_section)
3451 _iter = self.__section_liststore.append([_section, _section_text]) 3472 _iter = self.__section_liststore.append([_section, _section_text])
3452 _treeselection = self.__section_treeview.get_selection() 3473 _treeselection = self.__section_treeview.get_selection()
3453 _treeselection.select_path(0) 3474 _treeselection.select_path(0)
3454 3475
3455 def setText(self): 3476 def _setText(self):
3456 """setText(self) 3477 """_setText()
3457 3478
3458 Set the text in the textview 3479 Set the text in the textview
3459 """ 3480 """
3460 if not self.__section_selection is None and\ 3481 if not self.__section_selection is None and\
3461 not self.__field_selection is None: 3482 not self.__field_selection is None:
3467 _paragraph = self.__budget.getSheetParagraph(_paragraph_code) 3488 _paragraph = self.__budget.getSheetParagraph(_paragraph_code)
3468 self.__textbuffer.set_text(_paragraph) 3489 self.__textbuffer.set_text(_paragraph)
3469 else: 3490 else:
3470 self.__textbuffer.set_text("") 3491 self.__textbuffer.set_text("")
3471 3492
3472 def field_controlSelection(self, selection): 3493 def _field_controlSelection(self, selection):
3473 """def controlSelection(self, selection) 3494 """_controlSelection(selection)
3474 3495
3475 selection: treeselection 3496 selection: treeselection
3476 3497
3477 Method connected to set_selection_function() in field treeview 3498 Method connected to set_selection_function() in field treeview
3478 This method is called before any node is selected or unselected, 3499 This method is called before any node is selected or unselected,
3484 When a user select a row in the field treeview the section treeview is 3505 When a user select a row in the field treeview the section treeview is
3485 reloaded to show the sections of this field and already the text sheet. 3506 reloaded to show the sections of this field and already the text sheet.
3486 """ 3507 """
3487 _treeiter = self.__field_liststore.get_iter(selection) 3508 _treeiter = self.__field_liststore.get_iter(selection)
3488 self.__field_selection = self.__field_liststore.get_value(_treeiter, 0) 3509 self.__field_selection = self.__field_liststore.get_value(_treeiter, 0)
3489 self.setSection() 3510 self._setSection()
3490 return True 3511 return True
3491 3512
3492 def section_controlSelection(self, selection): 3513 def _section_controlSelection(self, selection):
3493 """def controlSelection(self, selection) 3514 """_section_controlSelection(selection)
3494 3515
3495 selection: treeselection 3516 selection: treeselection
3496 3517
3497 Method connected to set_selection_function() in sector treeview 3518 Method connected to set_selection_function() in sector treeview
3498 This method is called before any node is selected or unselected, 3519 This method is called before any node is selected or unselected,
3504 When a user select a row in the field treeview the text sheet for this 3525 When a user select a row in the field treeview the text sheet for this
3505 section in showed 3526 section in showed
3506 """ 3527 """
3507 _treeiter = self.__section_liststore.get_iter(selection) 3528 _treeiter = self.__section_liststore.get_iter(selection)
3508 self.__section_selection = self.__section_liststore.get_value(_treeiter, 0) 3529 self.__section_selection = self.__section_liststore.get_value(_treeiter, 0)
3509 self.setText() 3530 self._setText()
3510 return True 3531 return True
3511 3532
3512 def setActivePathRecord(self, path_record): 3533 def _setActivePathRecord(self, path_record):
3513 """def setActivePathRecord(self, path_record)) 3534 """_setActivePathRecord(path_record))
3514 3535
3515 path_record: active path record 3536 path_record: active path record
3516 3537
3517 Set the new path code to show its sheet of condition text. 3538 Set the new path code to show its sheet of condition text.
3518 """ 3539 """
3524 _budget = self.__budget 3545 _budget = self.__budget
3525 self.__active_path_record = path_record 3546 self.__active_path_record = path_record
3526 _code = _budget.getCode(self.__active_path_record) 3547 _code = _budget.getCode(self.__active_path_record)
3527 self.__label.set_text(utils.mapping(_("Sheet2 of Conditions of the "\ 3548 self.__label.set_text(utils.mapping(_("Sheet2 of Conditions of the "\
3528 "record $1"), (_code,))) 3549 "record $1"), (_code,)))
3529 self.setFields() 3550 self._setFields()
3530 3551
3531 def runMessage(self, message, path, arg=None): 3552 def runMessage(self, message, path, arg=None):
3532 """def runMessage(self, message, path, arg=None) 3553 """runMessage(message, path, arg=None)
3533 3554
3534 message: the message type 3555 message: the message type
3535 "change_active": change the active record 3556 "change_active": change the active record
3536 "clear": clear instance 3557 "clear": clear instance
3537 path: tuple that identifies the pane in the notebook page 3558 path: tuple that identifies the pane in the notebook page
3541 This method receives a message and executes its corresponding action 3562 This method receives a message and executes its corresponding action
3542 """ 3563 """
3543 _budget = self.__budget 3564 _budget = self.__budget
3544 if message == "change_active": 3565 if message == "change_active":
3545 if _budget.hasPath(arg): 3566 if _budget.hasPath(arg):
3546 self.setActivePathRecord(arg) 3567 self._setActivePathRecord(arg)
3547 elif message == "clear": 3568 elif message == "clear":
3548 self._clear() 3569 self._clear()
3549 3570
3550 def _clear(self): 3571 def _clear(self):
3551 """def _clear(self) 3572 """_clear()
3552 3573
3553 Deletes all the instance atributes 3574 Deletes all the instance atributes
3554 """ 3575 """
3555 del self.__page 3576 del self.__page
3556 del self.__widget 3577 del self.__widget
3566 del self.__field_selection 3587 del self.__field_selection
3567 del self.__section_liststore 3588 del self.__section_liststore
3568 del self.__section_treeview 3589 del self.__section_treeview
3569 del self.__section_selection 3590 del self.__section_selection
3570 3591
3571 def getWidget(self): 3592 def _getWidget(self):
3572 """def getWidget(self) 3593 """_getWidget()
3573 3594
3574 return the main widget (gtk.ScrolledWindow) 3595 return the main widget (gtk.ScrolledWindow)
3575 """ 3596 """
3576 return self.__widget 3597 return self.__widget
3577 3598
3578 def getPath(self): 3599 def _getPath(self):
3579 """def getPath(self) 3600 """_getPath()
3580 3601
3581 return the tuple that identifies the pane in the notebook page 3602 return the tuple that identifies the pane in the notebook page
3582 """ 3603 """
3583 return self.__page 3604 return self.__page
3584 3605
3585 def setPath(self, path): 3606 def _setPath(self, path):
3586 """def setPath(self) 3607 """_setPath()
3587 3608
3588 sets the tuple that identifies the pane in the notebook page 3609 sets the tuple that identifies the pane in the notebook page
3589 """ 3610 """
3590 self.__path = path 3611 self.__path = path
3591 3612
3592 def getPage(self): 3613 def _getPage(self):
3593 """def getPage(self) 3614 """_getPage()
3594 3615
3595 return the weak reference from Page instance 3616 return the weak reference from Page instance
3596 """ 3617 """
3597 return self.__page 3618 return self.__page
3598 3619
3599 def setPage(self, page): 3620 def _setPage(self, page):
3600 """def setPage(self) 3621 """_setPage()
3601 3622
3602 set the weak reference from Page instance 3623 set the weak reference from Page instance
3603 """ 3624 """
3604 self.__page = page 3625 self.__page = page
3605 3626
3606 def getBudget(self): 3627 def _getBudget(self):
3607 """def getBudget(self) 3628 """_getBudget()
3608 3629
3609 return the budget object 3630 return the budget object
3610 """ 3631 """
3611 return self.__budget 3632 return self.__budget
3612 3633
3613 def getActivePathRecord(self): 3634 def _getActivePathRecord(self):
3614 """def getActivePathRecord(self) 3635 """_getActivePathRecord()
3615 3636
3616 return the Active Path Record 3637 return the Active Path Record
3617 """ 3638 """
3618 return self.__active_path_record 3639 return self.__active_path_record
3619 3640
3620 path = property(getPath, setPath, None, 3641 path = property(_getPath, _setPath, None,
3621 "Path that identifie the item in the page notebook") 3642 "Path that identifie the item in the page notebook")
3622 widget = property(getWidget, None, None, 3643 widget = property(_getWidget, None, None,
3623 "Lista de configuracion de vistas") 3644 "Lista de configuracion de vistas")
3624 page = property(getPage, setPage, None, 3645 page = property(_getPage, _setPage, None,
3625 "Weak reference from Page instance which creates this class") 3646 "Weak reference from Page instance which creates this class")
3626 budget = property(getBudget, None, None, 3647 budget = property(_getBudget, None, None,
3627 "Budget object") 3648 "Budget object")
3628 active_path_record = property(getActivePathRecord, None, None, 3649 active_path_record = property(_getActivePathRecord, None, None,
3629 "Active Path Record") 3650 "Active Path Record")
3651
3630 3652
3631 class FileView(object): 3653 class FileView(object):
3632 """gui.FileView 3654 """gui.FileView
3633 3655
3634 Description: 3656 Description:
3635 Class to show the file icons of a record in a pane 3657 Class to show the file icons of a record in a pane
3636 Constructor: 3658 Constructor:
3637 Description(budget, code) 3659 Description(budget, page, path, path_record=(0,))
3638 budget: budget 3660 budget: the budget (base.obra object)
3639 code: code record 3661 page: weak reference from Page instance which creates this class
3662 path: the path position of the description in the page
3663 path_record: the path of the active record
3640 Ancestry: 3664 Ancestry:
3641 +-- object 3665 +-- object
3642 +-- Description 3666 +-- FileView
3643 Atributes: 3667 Atributes:
3644 "widget": the main widget (gtk.ScrolledWindow object) 3668 widget: the main widget (gtk.ScrolledWindow object)
3645 "__icon_box": the box that contains the icon
3646 "path": the tuple that identifies the pane in the notebook page 3669 "path": the tuple that identifies the pane in the notebook page
3647 "budget": The budget (base.obra objetc) 3670 "budget": The budget (base.obra objetc)
3648 "active_code": The active code of the record 3671 "active_code": The active code of the record
3649 Methods: 3672 Methods:
3650 __init__(self, budget, code) 3673 runMessage
3651 setActiveCode(self, code)
3652 runMessage(self, message, nt, arg=None)
3653 _clear(self)
3654 getWidget(self)
3655 {get/set}Path
3656 {get/seg}Page
3657 getBudget(self)
3658 getActviCode(self)
3659 """ 3674 """
3660 3675
3661 def __init__(self, budget, page, path, path_record=(0,)): 3676 def __init__(self, budget, page, path, path_record=(0,)):
3662 """def __init__(self, budget, page, path, path_record=(0,)) 3677 """__init__(budget, page, path, path_record=(0,))
3663 3678
3664 budget: the budget (base.obra object) 3679 budget: the budget (base.obra object)
3665 page: weak reference from Page instance which creates this class 3680 page: weak reference from Page instance which creates this class
3666 path: the path position of the description in the page 3681 path: the path position of the description in the page
3667 path_record: the path of the active record 3682 path_record: the path of the active record
3683
3684 self.__budget: the budget (base.obra object)
3685 self.__page: weak reference from Page instance which creates this class
3686 self.__path: the path position of the description in the page
3687 self.__active_path_record: the path of the active record
3688 self.__active_code: the code of the active record
3689 self.__icon_box: the box that contains the icon
3690 self.__widget: main widget, a gtk.ScrolledWindow
3668 3691
3669 Creates an shows the scroledwindow that contain icon files 3692 Creates an shows the scroledwindow that contain icon files
3670 of the record to be showed in a pane. 3693 of the record to be showed in a pane.
3671 """ 3694 """
3672 self.__budget = budget 3695 self.__budget = budget
3676 self.__active_code = budget.getCode(self.__active_path_record) 3699 self.__active_code = budget.getCode(self.__active_path_record)
3677 _budget = budget 3700 _budget = budget
3678 _record = self.__budget.getRecord(self.__budget.getCode( 3701 _record = self.__budget.getRecord(self.__budget.getCode(
3679 self.__active_path_record)) 3702 self.__active_path_record))
3680 3703
3681 self.__icon_box = self.getIconBox(_record) 3704 self.__icon_box = self._getIconBox(_record)
3682 _scrollwindow = gtk.ScrolledWindow() 3705 _scrollwindow = gtk.ScrolledWindow()
3683 _scrollwindow.set_policy(gtk.POLICY_ALWAYS, 3706 _scrollwindow.set_policy(gtk.POLICY_ALWAYS,
3684 gtk.POLICY_NEVER) 3707 gtk.POLICY_NEVER)
3685
3686 self.__icon_box.show() 3708 self.__icon_box.show()
3687 _scrollwindow.add_with_viewport(self.__icon_box) 3709 _scrollwindow.add_with_viewport(self.__icon_box)
3688 _scrollwindow.show() 3710 _scrollwindow.show()
3689 self.__widget = _scrollwindow 3711 self.__widget = _scrollwindow
3690 3712
3691 def getIconBox(self, record): 3713 def _getIconBox(self, record):
3692 """getIconBox(self, record) 3714 """_getIconBox(record)
3693 3715
3694 record: the active record object 3716 record: the active record object
3695 3717
3696 Creates and returns the box whith te icon files of the active record. 3718 Creates and returns the box whith te icon files of the active record.
3697 """ 3719 """
3719 _image_icon = gtk.Image() 3741 _image_icon = gtk.Image()
3720 _image_icon.set_from_pixbuf(_image_pixbuf) 3742 _image_icon.set_from_pixbuf(_image_pixbuf)
3721 _image_icon.show() 3743 _image_icon.show()
3722 _event_box.add(_image_icon) 3744 _event_box.add(_image_icon)
3723 _box.pack_start(_event_box, False, False, 5) 3745 _box.pack_start(_event_box, False, False, 5)
3724 _event_box.connect("button-press-event", self.launchFile, 3746 _event_box.connect("button-press-event", self._launchFile,
3725 "image", _file_path) 3747 "image", _file_path)
3726 _event_box.show() 3748 _event_box.show()
3727 3749
3728 elif _filetype == "dxf": 3750 elif _filetype == "dxf":
3729 _event_box = gtk.EventBox() 3751 _event_box = gtk.EventBox()
3734 gtk.gdk.INTERP_BILINEAR) 3756 gtk.gdk.INTERP_BILINEAR)
3735 _dxf_icon.set_from_pixbuf(_dxf_pixbuf) 3757 _dxf_icon.set_from_pixbuf(_dxf_pixbuf)
3736 _dxf_icon.show() 3758 _dxf_icon.show()
3737 _event_box.add(_dxf_icon) 3759 _event_box.add(_dxf_icon)
3738 _box.pack_start(_event_box, False, False, 5) 3760 _box.pack_start(_event_box, False, False, 5)
3739 _event_box.connect("button-press-event", self.launchFile, 3761 _event_box.connect("button-press-event", self._launchFile,
3740 "dxf", _file_path) 3762 "dxf", _file_path)
3741 _event_box.show() 3763 _event_box.show()
3742 _label_event_box = gtk.EventBox() 3764 _label_event_box = gtk.EventBox()
3743 _label = gtk.Label(_file.name) 3765 _label = gtk.Label(_file.name)
3744 _label_event_box.add(_label) 3766 _label_event_box.add(_label)
3749 _hbox.pack_start(_box, False, False, 5) 3771 _hbox.pack_start(_box, False, False, 5)
3750 _hbox.show() 3772 _hbox.show()
3751 _frame.add(_hbox) 3773 _frame.add(_hbox)
3752 return _frame 3774 return _frame
3753 3775
3754 def launchFile(self, widget, event, kind, file_path): 3776 def _launchFile(self, widget, event, kind, file_path):
3755 """launchFile(self, widget, event, kind, file_path) 3777 """_launchFile(widget, event, kind, file_path)
3756 3778
3757 widget: the widget that emit the signal 3779 widget: the widget that emit the signal
3758 event: the event that emit the signal 3780 event: the event that emit the signal
3759 king: kind of file 3781 king: kind of file
3760 file_path: the path file to be launch 3782 file_path: the path file to be launch
3763 Method connected to "button-press-event" signal in images event box 3785 Method connected to "button-press-event" signal in images event box
3764 """ 3786 """
3765 if event.type is gtk.gdk._2BUTTON_PRESS: 3787 if event.type is gtk.gdk._2BUTTON_PRESS:
3766 openwith.launch_file(kind, file_path) 3788 openwith.launch_file(kind, file_path)
3767 3789
3768 def setActivePathRecord(self, path_record): 3790 def _setActivePathRecord(self, path_record):
3769 """def setActivePathRecord(self, path_record)) 3791 """_setActivePathRecord(path_record))
3770 3792
3771 path_record: active path record 3793 path_record: active path record
3772 Set the new path code to show its description text. 3794 Set the new path code to show its description text.
3773 """ 3795 """
3774 _budget = self.__budget 3796 _budget = self.__budget
3775 self.__active_path_record = path_record 3797 self.__active_path_record = path_record
3776 _code = _budget.getCode(self.__active_path_record) 3798 _code = _budget.getCode(self.__active_path_record)
3777 _record = self.__budget.getRecord(_code) 3799 _record = self.__budget.getRecord(_code)
3778 self.__icon_box.destroy() 3800 self.__icon_box.destroy()
3779 self.__icon_box = self.getIconBox(_record) 3801 self.__icon_box = self._getIconBox(_record)
3780 self.__icon_box.show() 3802 self.__icon_box.show()
3781 self.__widget.add_with_viewport(self.__icon_box) 3803 self.__widget.add_with_viewport(self.__icon_box)
3782 3804
3783 def runMessage(self, message, path, arg=None): 3805 def runMessage(self, message, path, arg=None):
3784 """def runMessage(self, message, path, arg=None) 3806 """runMessage(message, path, arg=None)
3785 3807
3786 message: the message type 3808 message: the message type
3787 "change_active": change the active record 3809 "change_active": change the active record
3788 "clear": clear instance 3810 "clear": clear instance
3789 path: tuple that identifies the pane in the notebook page 3811 path: tuple that identifies the pane in the notebook page
3793 This method receives a message and executes its corresponding action 3815 This method receives a message and executes its corresponding action
3794 """ 3816 """
3795 _budget = self.__budget 3817 _budget = self.__budget
3796 if message == "change_active": 3818 if message == "change_active":
3797 if _budget.hasPath(arg): 3819 if _budget.hasPath(arg):
3798 self.setActivePathRecord(arg) 3820 self._setActivePathRecord(arg)
3799 elif message == "clear": 3821 elif message == "clear":
3800 self._clear() 3822 self._clear()
3801 3823
3802 def _clear(self): 3824 def _clear(self):
3803 """def _clear(self) 3825 """_clear()
3804 3826
3805 Delete all instance atributes 3827 Delete all instance atributes
3806 """ 3828 """
3807 del self.__hbox
3808 del self.__widget 3829 del self.__widget
3809 del self.__path 3830 del self.__path
3810 del self.__budget 3831 del self.__budget
3811 del self.__active_code 3832 del self.__active_code
3812 3833
3813 def getWidget(self): 3834 def _getWidget(self):
3814 """def getWidget(self) 3835 """_getWidget()
3815 3836
3816 return the main widget (gtk.ScrolledWindow) 3837 return the main widget (gtk.ScrolledWindow)
3817 """ 3838 """
3818 return self.__widget 3839 return self.__widget
3819 3840
3820 def getPath(self): 3841 def _getPath(self):
3821 """def getPath(self) 3842 """_getPath()
3822 3843
3823 return the tuple that identifies the pane in the notebook page 3844 return the tuple that identifies the pane in the notebook page
3824 """ 3845 """
3825 return self.__path 3846 return self.__path
3826 3847
3827 def setPath(self, path): 3848 def _setPath(self, path):
3828 """def setPath(self) 3849 """_setPath()
3829 3850
3830 sets the tuple that identifies the pane in the notebook page 3851 sets the tuple that identifies the pane in the notebook page
3831 """ 3852 """
3832 self.__path = path 3853 self.__path = path
3833 3854
3834 def getPage(self): 3855 def _getPage(self):
3835 """def getPage(self) 3856 """_getPage()
3836 3857
3837 return the weak reference from Page instance 3858 return the weak reference from Page instance
3838 """ 3859 """
3839 return self.__page 3860 return self.__page
3840 3861
3841 def setPage(self, page): 3862 def _setPage(self, page):
3842 """def setPage(self) 3863 """setPage()
3843 3864
3844 set the weak reference from Page instance 3865 set the weak reference from Page instance
3845 """ 3866 """
3846 self.__page = page 3867 self.__page = page
3847 3868
3848 def getBudget(self): 3869 def _getBudget(self):
3849 """def getBudget(self) 3870 """getBudget()
3850 3871
3851 return the budget object 3872 return the budget object
3852 """ 3873 """
3853 return self.__budget 3874 return self.__budget
3854 3875
3855 def getActivePathRecord(self): 3876 def _getActivePathRecord(self):
3856 """def getActivePathRecord(self) 3877 """_getActivePathRecord()
3857 3878
3858 return the Active Path Record 3879 return the Active Path Record
3859 """ 3880 """
3860 return self.__active_path_record 3881 return self.__active_path_record
3861 3882
3862 path = property(getPath, setPath, None, 3883 path = property(_getPath, _setPath, None,
3863 "Path that identifie the item in the page notebook") 3884 "Path that identifie the item in the page notebook")
3864 widget = property(getWidget, None, None, 3885 widget = property(_getWidget, None, None,
3865 "The main widget (gtk.ScrolledWindow)") 3886 "The main widget (gtk.ScrolledWindow)")
3866 page = property(getPage, setPage, None, 3887 page = property(_getPage, _setPage, None,
3867 "Weak reference from Page instance which creates this class") 3888 "Weak reference from Page instance which creates this class")
3868 budget = property(getBudget, None, None, 3889 budget = property(_getBudget, None, None,
3869 "Budget object") 3890 "Budget object")
3870 active_path_record = property(getActivePathRecord, None, None, 3891 active_path_record = property(_getActivePathRecord, None, None,
3871 "Active Path Record") 3892 "Active Path Record")
3872 3893
3873
3874 class TextWindow(object):
3875 """gui.TextWindow
3876
3877 Description:
3878 Class to show a description text of a record in a new gtk window
3879 Constructor:
3880 TextWindow(code, text)
3881 code: code of the record
3882 text: description text of the record
3883 Ancestry:
3884 +-- object
3885 +-- TextWindow
3886 Atributes:
3887 Methods:
3888 __init__(self, code, text)
3889 main(self)
3890 destroy(self, widget)
3891 """
3892
3893 def __init__(self, code, text):
3894 """def __init__(self, code, text)
3895
3896 code: code of the record
3897 text: description text of the record
3898 Creates an shows the window.
3899 """
3900 _window = gtk.Window(gtk.WINDOW_TOPLEVEL)
3901 _window.set_resizable(True)
3902 _window.set_default_size(700, 300)
3903 _window.set_title(utils.mapping(_("$1 text"), (code,)))
3904 _window.set_border_width(0)
3905 _box1 = gtk.VBox(False, 0)
3906 _window.add(_box1)
3907 _box1.show()
3908 _sw = gtk.ScrolledWindow()
3909 _sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
3910 _textview = gtk.TextView()
3911 _textview.set_wrap_mode(gtk.WRAP_WORD)
3912 _textbuffer = _textview.get_buffer()
3913 _sw.add(_textview)
3914 _sw.show()
3915 _textview.show()
3916 _box1.pack_start(_sw)
3917 _textbuffer.set_text(text)
3918 _window.connect("destroy", self.destroy)
3919 _window.show()
3920
3921 def main(self):
3922 """def main(self)
3923
3924 Starts the GTK+ event processing loop.
3925 """
3926 gtk.main()
3927
3928 def destroy(self, widget):
3929 """destroy(self, widget)
3930 widget: the widget where the event is emitted from
3931 Method connected to "destroy" signal of window widget
3932 This signal is emited when the method connected to "delete_event"
3933 signal returns True or when the program call the destroy() method of
3934 the gtk.Window widget.
3935 The window is closed and the GTK+ event processing loop is ended.
3936 """
3937 gtk.main_quit()
3938 3894
3939 class CompanyView(object): 3895 class CompanyView(object):
3940 """gui.CompanyView: 3896 """gui.CompanyView:
3941 3897
3942 Description: 3898 Description:
3943 Class to show the company records of a budget 3899 Class to show the company records of a budget
3944 Constructor: 3900 Constructor:
3945 CompanyView(budget, page, path) 3901 CompanyView(budget, page, path, path_record=(0,))
3946 budget: budget showed ("base.Budget" object) 3902 budget: budget showed ("base.Budget" object)
3947 page: weak reference from Page instance which creates this class 3903 page: weak reference from Page instance which creates this class
3948 path: tuple that represents the path of the List in the Page 3904 path: tuple that represents the path of the List in the Page
3949 Returns the newly created CompanyView instance 3905 path_record: path of the active record in the budget
3950 Ancestry: 3906 Ancestry:
3951 +-- object 3907 +-- object
3952 +-- CompanyView 3908 +-- CompanyView
3953 Atributes: 3909 Atributes:
3954 "budget": Budget to show, base.obra instance. 3910 active_path_record: Read. Path of the active record in the budget
3955 "active_path_record" 3911 widget: Read. Window that contains the main widget, a gtk.HPaned
3956 "widget": Window that contains the main widget, 3912 path: Read-Write. Pane page identifier
3957 (gtk.ScrolledWindow) 3913 page: Read-Write. weak reference from Page instance which creates this class
3958 "path": Pane page identifier 3914 budget: Read. Budget to show, base.budget instance.
3959 "page": weak reference from Page instance which creates this class
3960 "__methond_message": Method to send messages to the page
3961 Methods: 3915 Methods:
3962 __init__(self, budget, page, path, path_record=(0,)) 3916 runMessage
3963 runMessage(self, message, path, arg=None)
3964 _clear(self)
3965 getWidget(self)
3966 {get/set}Path
3967 {get/set}Page
3968 getBudget(self)
3969 getActivePathRecord(self)
3970 """ 3917 """
3971 3918
3972 def __init__(self, budget, page, path, path_record=(0,)): 3919 def __init__(self, budget, page, path, path_record=(0,)):
3973 """def __init__(self, budget, page, path, path_record=(0,)) 3920 """__init__(budget, page, path, path_record=(0,))
3974 3921
3975 budget: budget: budget showed ("base.Budget" object) 3922 budget: budget: budget showed ("base.Budget" object)
3976 page: weak reference from Page instance which creates this class 3923 page: weak reference from Page instance which creates this class
3977 path: tuple that represents the path of the List in the Page 3924 path: tuple that represents the path of the List in the Page
3978 path_record: path of the active record in the budget 3925 path_record: path of the active record in the budget
3979 3926
3980 Sets the init atributes 3927 self.__selection:
3981 Creates the 3928 self.__budget: budget: budget showed ("base.Budget" object)
3982 3929 self.__page: weak reference from Page instance which creates this class
3930 self.__path: tuple that represents the path of the List in the Page
3931 self.__active_path_record: path of the active record in the budget
3932 self.__widget: main widget, a gtk.HPaned
3933 self.__treestore: to store companys data
3934 self.__option_View: OptionView object
3935
3936 Creates an shows the scroledwindow that contain the company data.
3983 """ 3937 """
3984 self.__selection = None 3938 self.__selection = None
3985 # Seting init args 3939 # Seting init args
3986 if not isinstance(budget, base.Budget): 3940 if not isinstance(budget, base.Budget):
3987 raise ValueError, _("Argument must be a Budget object") 3941 raise ValueError, _("Argument must be a Budget object")
3988 self.__budget = budget 3942 self.__budget = budget
3989 self.__page = page 3943 self.__page = page
3990 self.__path = path 3944 self.__path = path
3991 self.__active_path_record = path_record 3945 self.__active_path_record = path_record
3992 # HVox 3946 # main widget
3993 self.__hbox = gtk.HPaned() 3947 self.__widget = gtk.HPaned()
3994 self.__hbox.set_position(230) 3948 self.__widget.set_position(230)
3995 # TreeStore 3949 # TreeStore
3996 self.__treestore = gtk.TreeStore(str, str) 3950 self.__treestore = gtk.TreeStore(str, str)
3997 self.setTreeStoreValues() 3951 self._setTreeStoreValues()
3998 # Select Treeview 3952 # Select Treeview
3999 self.__select_treeview = gtk.TreeView(self.__treestore) 3953 _select_treeview = gtk.TreeView(self.__treestore)
4000 self.__select_treeview.set_enable_search(False) 3954 _select_treeview.set_enable_search(False)
4001 self.__select_treeview.set_reorderable(False) 3955 _select_treeview.set_reorderable(False)
4002 self.__select_treeview.set_headers_visible(False) 3956 _select_treeview.set_headers_visible(False)
4003 self.__select_treeview.show() 3957 _select_treeview.show()
4004 # Scrolled_window 3958 # Scrolled_window
4005 self.__scrolled_window = gtk.ScrolledWindow() 3959 _scrolled_window = gtk.ScrolledWindow()
4006 self.__scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 3960 _scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
4007 gtk.POLICY_AUTOMATIC) 3961 gtk.POLICY_AUTOMATIC)
4008 self.__scrolled_window.add(self.__select_treeview) 3962 _scrolled_window.add(_select_treeview)
4009 # colors 3963 # colors
4010 _text_color = gtk.gdk.color_parse(globalVars.color["TEXT"]) 3964 _text_color = gtk.gdk.color_parse(globalVars.color["TEXT"])
4011 _background_color = [ 3965 _background_color = [
4012 gtk.gdk.color_parse(globalVars.color["UNEVEN"]), 3966 gtk.gdk.color_parse(globalVars.color["UNEVEN"]),
4013 gtk.gdk.color_parse(globalVars.color["EVEN"])] 3967 gtk.gdk.color_parse(globalVars.color["EVEN"])]
4014 self.__code_column = gtk.TreeViewColumn() 3968 _code_column = gtk.TreeViewColumn()
4015 self.__code_column.set_clickable(True) 3969 _code_column.set_clickable(True)
4016 self.__code_column.set_fixed_width(200) 3970 _code_column.set_fixed_width(200)
4017 _code_cell = gtk.CellRendererText() 3971 _code_cell = gtk.CellRendererText()
4018 _code_cell.set_property('foreground-gdk', _text_color) 3972 _code_cell.set_property('foreground-gdk', _text_color)
4019 self.__code_column.pack_start(_code_cell, True) 3973 _code_column.pack_start(_code_cell, True)
4020 self.__code_column.add_attribute(_code_cell, 'text', 0) 3974 _code_column.add_attribute(_code_cell, 'text', 0)
4021 _summary_cell = gtk.CellRendererText() 3975 _summary_cell = gtk.CellRendererText()
4022 _summary_cell.set_property('foreground-gdk', _text_color) 3976 _summary_cell.set_property('foreground-gdk', _text_color)
4023 self.__code_column.pack_start(_summary_cell, True) 3977 _code_column.pack_start(_summary_cell, True)
4024 self.__code_column.add_attribute(_summary_cell, 'text', 1) 3978 _code_column.add_attribute(_summary_cell, 'text', 1)
4025 # Index column 3979 # Index column
4026 self.__select_treeview.append_column(self.__code_column) 3980 _select_treeview.append_column(_code_column)
4027 # control selection 3981 # control selection
4028 self.__treeselection = self.__select_treeview.get_selection() 3982 _treeselection = _select_treeview.get_selection()
4029 self.__treeselection.set_mode(gtk.SELECTION_SINGLE) 3983 _treeselection.set_mode(gtk.SELECTION_SINGLE)
4030 self.__treeselection.set_select_function(self.controlSelection) 3984 _treeselection.set_select_function(self._controlSelection)
4031 # Show 3985 # Show
4032 self.setColumnsHeaders() 3986 _scrolled_window.show()
4033 self.__scrolled_window.show()
4034 # Option View 3987 # Option View
4035 self.__option_View = OptionView("") 3988 self.__option_View = OptionView("")
4036 # Selection 3989 # Selection
4037 self.__select_treeview.set_cursor((0,), None, False) 3990 _select_treeview.set_cursor((0,), None, False)
4038 self.__select_treeview.grab_focus() 3991 _select_treeview.grab_focus()
4039 # 3992 #
4040 self.__hbox.add1(self.__scrolled_window) 3993 self.__widget.add1(_scrolled_window)
4041 self.__hbox.add2(self.__option_View.widget) 3994 self.__widget.add2(self.__option_View.widget)
4042 self.__hbox.show() 3995 self.__widget.show()
4043 self.__widget = self.__hbox 3996
4044 3997 def _setOptions(self, type):
4045 def setOptions(self, type): 3998 """_setOptions(type)
3999
4000 type: "company" or "office"
4001 Sets the Options in the OptionView
4002 """
4046 if type == "company": 4003 if type == "company":
4047 _options = [("code", _("Code"), "string", 4004 _options = [("code", _("Code"), "string",
4048 _("""Code that define the company""")), 4005 _("""Code that define the company""")),
4049 ("summary", _("Summary"), "string", 4006 ("summary", _("Summary"), "string",
4050 _("""Summary of the company name""")), 4007 _("""Summary of the company name""")),
4055 ("web", _("Web"), "string", 4012 ("web", _("Web"), "string",
4056 _("""Company web page""")), 4013 _("""Company web page""")),
4057 ("email", _("Email"), "string", 4014 ("email", _("Email"), "string",
4058 _("""Company email""")), 4015 _("""Company email""")),
4059 ] 4016 ]
4060 self.__option_View.setOptions(_options) 4017 self.__option_View.options = _options
4061 elif type == "office": 4018 elif type == "office":
4062 _options = [("type", _("Type"), "string", 4019 _options = [("type", _("Type"), "string",
4063 _("""Type of Office: 4020 _("""Type of Office:
4064 C: Central office 4021 C: Central office
4065 D: Local office 4022 D: Local office
4076 ("fax", _("Fax"), "list", 4033 ("fax", _("Fax"), "list",
4077 _("Fax numbers of the office")), 4034 _("Fax numbers of the office")),
4078 ("contact person", _("Contact person"), "string", 4035 ("contact person", _("Contact person"), "string",
4079 _("Contact persons in the office")), 4036 _("Contact persons in the office")),
4080 ] 4037 ]
4081 self.__option_View.setOptions(_options) 4038 self.__option_View.options = _options
4082 else: 4039 else:
4083 print _("Unknow Option Type") 4040 print _("Unknow Option Type")
4084 def setOptionValues(self, company_key): 4041
4085 self.__option_View.setValues(_values) 4042 def _setTreeStoreValues(self):
4086 4043 """_setTreeStoreValues()
4087 def setTreeStoreValues(self): 4044
4088 """def setListstoreValues(self) 4045 Sets the treestore values from the budget
4089
4090 Sets the treestore values from the budget
4091 """ 4046 """
4092 _budget = self.__budget 4047 _budget = self.__budget
4093 _company_keys = _budget.getCompanyKeys() 4048 _company_keys = _budget.getCompanyKeys()
4094 for _company_key in _company_keys: 4049 for _company_key in _company_keys:
4095 _company = _budget.getCompany(_company_key) 4050 _company = _budget.getCompany(_company_key)
4099 for _office in _offices: 4054 for _office in _offices:
4100 # TODO: Test offices 4055 # TODO: Test offices
4101 _values = [_office.officeType, _office.subname] 4056 _values = [_office.officeType, _office.subname]
4102 self.__treestore.append(_treeiter, _values) 4057 self.__treestore.append(_treeiter, _values)
4103 4058
4104 def setColumnsHeaders(self): 4059
4105 """def setColumnsHeaders(self) 4060 def _controlSelection(self, selection):
4106 4061 """_controlSelection(selection)
4107 Sets the headers column values
4108 """
4109 #self.columns[1].set_title(_("Type")) # Σ parcial Σ total
4110 #self.columns[2].set_title(_("Comment"))
4111 #self.columns[3].set_title(_("N"))
4112 #self.columns[4].set_title(_("Length"))
4113 #self.columns[5].set_title(_("Width"))
4114 #self.columns[6].set_title(_("Height"))
4115 pass
4116
4117 def controlSelection(self, selection):
4118 """def controlSelection(self, selection)
4119 4062
4120 selection: selection 4063 selection: selection
4121 4064
4122 Method connected to set_selection_function() 4065 Method connected to set_selection_function()
4123 This method is called before any node is selected or unselected, 4066 This method is called before any node is selected or unselected,
4141 _selection = "office" 4084 _selection = "office"
4142 _office = _company.offices[selection[1]] 4085 _office = _company.offices[selection[1]]
4143 _values = _office.values 4086 _values = _office.values
4144 if not self.__selection == _selection: 4087 if not self.__selection == _selection:
4145 self.__selection = _selection 4088 self.__selection = _selection
4146 self.setOptions(_selection) 4089 self.options = _selection
4147 self.__option_View.setValues(_values) 4090 self.__option_View.values = _values
4148 4091
4149 return True 4092 return True
4150 4093
4151 def showMessageRecord(self, record_path): 4094 def _showMessageRecord(self, record_path):
4152 """def showMessageRecord(self, record_path) 4095 """_showMessageRecord(record_path)
4153 4096
4154 record_path: the path of the record to show 4097 record_path: the path of the record to show
4155 Method connected to "change_active" message 4098 Method connected to "change_active" message
4156 Show the record especified in the "change_active" message 4099 Show the record especified in the "change_active" message
4157 """ 4100 """
4158 self.__active_path_record = record_path 4101 self.__active_path_record = record_path
4159 4102
4160 def runMessage(self, message, path, arg=None): 4103 def runMessage(self, message, path, arg=None):
4161 """def runMessage(self, message, path, arg=None) 4104 """runMessage(message, path, arg=None)
4162 4105
4163 message: the message type 4106 message: the message type
4164 "change_active": change the active record 4107 "change_active": change the active record
4165 "clear": clear instance 4108 "clear": clear instance
4166 path: tuple that identifies the pane in the notebook page 4109 path: tuple that identifies the pane in the notebook page
4171 """ 4114 """
4172 _budget = self.__budget 4115 _budget = self.__budget
4173 if message == "change_active": 4116 if message == "change_active":
4174 if _budget.hasPath(arg): 4117 if _budget.hasPath(arg):
4175 _path_record = arg 4118 _path_record = arg
4176 self.showMessageRecord( _path_record) 4119 self._showMessageRecord( _path_record)
4177 pass 4120 pass
4178 elif message == "clear": 4121 elif message == "clear":
4179 self._clear() 4122 self._clear()
4180 4123
4181 def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): 4124 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
4182 """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) 4125 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
4183 4126
4184 column: the gtk.TreeViewColumn in the treeview 4127 column: the gtk.TreeViewColumn in the treeview
4185 cell_renderer: a gtk.CellRenderer 4128 cell_renderer: a gtk.CellRenderer
4186 tree_model: the gtk.TreeModel 4129 tree_model: the gtk.TreeModel
4187 iter: gtk.TreeIter pointing at the row 4130 iter: gtk.TreeIter pointing at the row
4215 else: 4158 else:
4216 cell_renderer.set_property('cell-background-gdk', 4159 cell_renderer.set_property('cell-background-gdk',
4217 lcolor[_number % 2]) 4160 lcolor[_number % 2])
4218 4161
4219 def _clear(self): 4162 def _clear(self):
4220 """def _clear(self) 4163 """_clear()
4221 4164
4222 it deletes the __budget value 4165 it deletes the self.__budget value
4223 this would not be necessary if there were not circular references,
4224 which are pending to fix
4225 """ 4166 """
4226 del self.__budget 4167 del self.__budget
4227 4168
4228 def getWidget(self): 4169 def _getWidget(self):
4229 """def getWidget(self) 4170 """_getWidget()
4230 4171
4231 return the main widget (gtk.ScrolledWindow) 4172 return the main widget (gtk.ScrolledWindow)
4232 """ 4173 """
4233 return self.__widget 4174 return self.__widget
4234 4175
4235 def getPath(self): 4176 def _getPath(self):
4236 """def getPath(self) 4177 """_getPath()
4237 4178
4238 return the tuple that identifies the pane in the notebook page 4179 return the tuple that identifies the pane in the notebook page
4239 """ 4180 """
4240 return self.__path 4181 return self.__path
4241 4182
4242 def setPath(self, path): 4183 def _setPath(self, path):
4243 """def setPath(self) 4184 """_setPath()
4244 4185
4245 sets the tuple that identifies the pane in the notebook page 4186 sets the tuple that identifies the pane in the notebook page
4246 """ 4187 """
4247 self.__path = path 4188 self.__path = path
4248 def getPage(self): 4189
4249 """def getPage(self) 4190 def _getPage(self):
4191 """_getPage()
4250 4192
4251 return the Page 4193 return the Page
4252 """ 4194 """
4253 return self.__page 4195 return self.__page
4254 4196
4255 def setPage(self,page): 4197 def _setPage(self,page):
4256 """def setPage(self) 4198 """_setPage()
4257 4199
4258 set the Page 4200 set the Page
4259 """ 4201 """
4260 self.__page = page 4202 self.__page = page
4261 4203
4262 def getBudget(self): 4204 def _getBudget(self):
4263 """def getBudget(self) 4205 """_getBudget()
4264 4206
4265 return the Budget objet 4207 return the Budget objet
4266 """ 4208 """
4267 return self.__budget 4209 return self.__budget
4268 4210
4269 def getActivePathRecord(self): 4211 def _getActivePathRecord(self):
4270 """def getActivePathRecord(self) 4212 """_getActivePathRecord()
4271 4213
4272 return the Active Path Record 4214 return the Active Path Record
4273 """ 4215 """
4274 return self.__active_path_record 4216 return self.__active_path_record
4275 4217
4276 active_path_record = property(getActivePathRecord, None, None, 4218 active_path_record = property(_getActivePathRecord, None, None,
4277 "Active path record") 4219 "Active path record")
4278 widget = property(getWidget, None, None, 4220 widget = property(_getWidget, None, None,
4279 "main widget") 4221 "main widget")
4280 path = property(getPath, setPath, None, 4222 path = property(_getPath, _setPath, None,
4281 "Path that identifies the item in the page notebook") 4223 "Path that identifies the item in the page notebook")
4282 page = property(getPage, setPage, None, 4224 page = property(_getPage, _setPage, None,
4283 "Weak reference from Page instance which creates this class") 4225 "Weak reference from Page instance which creates this class")
4284 budget = property(getBudget, None, None, 4226 budget = property(_getBudget, None, None,
4285 "Budget object") 4227 "Budget object")
4286 4228
4287 4229
4288 class OptionView(object): 4230 class OptionView(object):
4289 """gui.OptionView: 4231 """gui.OptionView:
4297 (option_name, type) 4239 (option_name, type)
4298 Ancestry: 4240 Ancestry:
4299 +-- object 4241 +-- object
4300 +-- OptionView 4242 +-- OptionView
4301 Atributes: 4243 Atributes:
4302 "__liststore" 4244 widget: Read. Main widget
4303 "__treeview" 4245 options: Write
4304 "__option_column" 4246 values: Write
4305 "__value_column"
4306 "__type_column"
4307 "__treeselection"
4308 "__widget": Main windget
4309 "__option_list"
4310 "__option_dict"
4311 "__description_label"
4312 "option_types"
4313 "widget": __widget
4314 Methods: 4247 Methods:
4315 __init__(self, option_list)
4316 createColumn(self, args)
4317 createTextBaseColumn(self,args)
4318 createBaseColumn(self,args)
4319 """ 4248 """
4320 4249
4321 def __init__(self, option_list): 4250 def __init__(self, option_list):
4322 """__init__(self, option_list) 4251 """__init__(option_list)
4323 4252
4253 self.__option_dict:
4254 {"option key" : ["option name", "value", "option type",
4255 "option_description"]}
4256 self.__option_list: option keys list
4257 self.__option_types: valid option types list
4258 self.__liststore: gtk.ListStore
4259 self.__treeview: gtk.TreeView
4260 self.__option_column: option column
4261 self.__value_column: value column
4262 self.__type_column: type column
4263 self.__description_label: gtk.Label
4264 self.__widget: Main widget
4265
4266 Creates an shows the widget that contain the option data.
4324 """ 4267 """
4325 self.__option_dict = {} 4268 self.__option_dict = {}
4326 self.__option_list = [] 4269 self.__option_list = []
4327 self.option_types = {"boolean" : _("Boolean"), 4270 self.__option_types = {"boolean" : _("Boolean"),
4328 "integer": _("Integer"), 4271 "integer": _("Integer"),
4329 "string": _("Text"), 4272 "string": _("Text"),
4330 "color" : _("Color"), 4273 "color" : _("Color"),
4331 "list" : _("List")} 4274 "list" : _("List")}
4332 # ListStore 4275 # ListStore
4356 self.__option_column.set_fixed_width(150) 4299 self.__option_column.set_fixed_width(150)
4357 self.__option_column.set_resizable(True) 4300 self.__option_column.set_resizable(True)
4358 _option_cell = gtk.CellRendererText() 4301 _option_cell = gtk.CellRendererText()
4359 _option_cell.set_property('foreground-gdk', _text_color) 4302 _option_cell.set_property('foreground-gdk', _text_color)
4360 self.__option_column.pack_start(_option_cell, True) 4303 self.__option_column.pack_start(_option_cell, True)
4361 self.__option_column.set_cell_data_func(_option_cell, self.colorCell, 4304 self.__option_column.set_cell_data_func(_option_cell, self._colorCell,
4362 _background_color) 4305 _background_color)
4363 self.__option_column.set_title(_("Option name")) 4306 self.__option_column.set_title(_("Option name"))
4364 self.__option_column.add_attribute(_option_cell, 'text', 1) 4307 self.__option_column.add_attribute(_option_cell, 'text', 1)
4365 self.__treeview.append_column(self.__option_column) 4308 self.__treeview.append_column(self.__option_column)
4366 # Value Column 4309 # Value Column
4369 self.__value_column.set_fixed_width(275) 4312 self.__value_column.set_fixed_width(275)
4370 self.__value_column.set_resizable(True) 4313 self.__value_column.set_resizable(True)
4371 _value_cell = gtk.CellRendererText() 4314 _value_cell = gtk.CellRendererText()
4372 _value_cell.set_property('foreground-gdk', _text_color) 4315 _value_cell.set_property('foreground-gdk', _text_color)
4373 self.__value_column.pack_start(_value_cell, True) 4316 self.__value_column.pack_start(_value_cell, True)
4374 self.__value_column.set_cell_data_func(_value_cell, self.colorCell, 4317 self.__value_column.set_cell_data_func(_value_cell, self._colorCell,
4375 _background_color) 4318 _background_color)
4376 self.__value_column.set_title(_("Value")) 4319 self.__value_column.set_title(_("Value"))
4377 self.__value_column.add_attribute(_value_cell, 'text', 2) 4320 self.__value_column.add_attribute(_value_cell, 'text', 2)
4378 self.__treeview.append_column(self.__value_column) 4321 self.__treeview.append_column(self.__value_column)
4379 # Type Column 4322 # Type Column
4382 self.__type_column.set_fixed_width(70) 4325 self.__type_column.set_fixed_width(70)
4383 self.__type_column.set_resizable(True) 4326 self.__type_column.set_resizable(True)
4384 _type_cell = gtk.CellRendererText() 4327 _type_cell = gtk.CellRendererText()
4385 _type_cell.set_property('foreground-gdk', _text_color) 4328 _type_cell.set_property('foreground-gdk', _text_color)
4386 self.__type_column.pack_start(_type_cell, True) 4329 self.__type_column.pack_start(_type_cell, True)
4387 self.__type_column.set_cell_data_func(_type_cell, self.colorCell, 4330 self.__type_column.set_cell_data_func(_type_cell, self._colorCell,
4388 _background_color) 4331 _background_color)
4389 self.__type_column.set_title(_("Type")) 4332 self.__type_column.set_title(_("Type"))
4390 self.__treeview.append_column(self.__type_column) 4333 self.__treeview.append_column(self.__type_column)
4391 # End Column 4334 # End Column
4392 _end_column = gtk.TreeViewColumn() 4335 _end_column = gtk.TreeViewColumn()
4395 _end_cell.set_property('cell-background-gdk', 4338 _end_cell.set_property('cell-background-gdk',
4396 gtk.gdk.color_parse(globalVars.color["UNEVEN"])) 4339 gtk.gdk.color_parse(globalVars.color["UNEVEN"]))
4397 _end_column.pack_start(_end_cell, True) 4340 _end_column.pack_start(_end_cell, True)
4398 self.__treeview.append_column(_end_column) 4341 self.__treeview.append_column(_end_column)
4399 # Connect 4342 # Connect
4400 self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) 4343 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
4401 self.__treeview.connect("button-press-event", self.treeviewClickedEvent) 4344 self.__treeview.connect("button-press-event",
4345 self._treeviewClickedEvent)
4402 # control selection 4346 # control selection
4403 self.__treeselection = self.__treeview.get_selection() 4347 _treeselection = self.__treeview.get_selection()
4404 self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) 4348 _treeselection.set_mode(gtk.SELECTION_MULTIPLE)
4405 self.__treeselection.set_select_function(self.controlSelection) 4349 _treeselection.set_select_function(self._controlSelection)
4406 # labels 4350 # labels
4407 _frame = gtk.Frame() 4351 _frame = gtk.Frame()
4408 _frame.set_shadow_type(gtk.SHADOW_OUT) 4352 _frame.set_shadow_type(gtk.SHADOW_OUT)
4409 _vbox2 = gtk.VBox() 4353 _vbox2 = gtk.VBox()
4410 _frame.add(_vbox2) 4354 _frame.add(_vbox2)
4429 # Show 4373 # Show
4430 self.__treeview.show() 4374 self.__treeview.show()
4431 _vbox.show() 4375 _vbox.show()
4432 self.__widget = _vbox 4376 self.__widget = _vbox
4433 4377
4434 def treeviewKeyPressEvent(self, widget, event): 4378 def _treeviewKeyPressEvent(self, widget, event):
4435 """def treeviewKeyPressEvent(self, widget, event) 4379 """_treeviewKeyPressEvent(widget, event)
4436 4380
4437 widget: treewiew widget 4381 widget: treewiew widget
4438 event: Key Press event 4382 event: Key Press event
4439 Method connected to "key-press-event" signal 4383 Method connected to "key-press-event" signal
4440 The "key-press-event" signal is emitted when the user presses a key 4384 The "key-press-event" signal is emitted when the user presses a key
4455 else: 4399 else:
4456 _description = self.__liststore[_cursor_path][4] 4400 _description = self.__liststore[_cursor_path][4]
4457 self.__description_label.set_text(_description) 4401 self.__description_label.set_text(_description)
4458 return False 4402 return False
4459 4403
4460 def treeviewClickedEvent(self, widget, event): 4404 def _treeviewClickedEvent(self, widget, event):
4461 """def treeviewClickedEvent(self, widget, event) 4405 """_treeviewClickedEvent(widget, event)
4462 4406
4463 widget: treewiew widget 4407 widget: treewiew widget
4464 event: clicked event 4408 event: clicked event
4465 Method connected to "button-press-event" signal 4409 Method connected to "button-press-event" signal
4466 The "button-press-event" signal is emitted when a mouse button is 4410 The "button-press-event" signal is emitted when a mouse button is
4482 self.__treeview.set_cursor(_path_cursor,self.__value_column, 4426 self.__treeview.set_cursor(_path_cursor,self.__value_column,
4483 True) 4427 True)
4484 self.__treeview.grab_focus() 4428 self.__treeview.grab_focus()
4485 return True 4429 return True
4486 return True 4430 return True
4487 4431
4488 def controlSelection(self, selection): 4432 def _controlSelection(self, selection):
4489 """def controlSelection(self, selection) 4433 """_controlSelection(selection)
4490 4434
4491 selection: treeselection 4435 selection: treeselection
4492 4436
4493 Method connected to set_selection_function() 4437 Method connected to set_selection_function()
4494 This method is called before any node is selected or unselected, 4438 This method is called before any node is selected or unselected,
4499 4443
4500 Return False so none row is selected 4444 Return False so none row is selected
4501 """ 4445 """
4502 return False 4446 return False
4503 4447
4504 4448 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
4505 def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): 4449 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
4506 """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor)
4507 4450
4508 column: the gtk.TreeViewColumn in the treeview 4451 column: the gtk.TreeViewColumn in the treeview
4509 cell_renderer: a gtk.CellRenderer 4452 cell_renderer: a gtk.CellRenderer
4510 tree_model: the gtk.TreeModel 4453 tree_model: the gtk.TreeModel
4511 iter: gtk.TreeIter pointing at the row 4454 iter: gtk.TreeIter pointing at the row
4534 gtk.gdk.color_parse(globalVars.color["ACTIVE"])) 4477 gtk.gdk.color_parse(globalVars.color["ACTIVE"]))
4535 else: 4478 else:
4536 cell_renderer.set_property('cell-background-gdk', 4479 cell_renderer.set_property('cell-background-gdk',
4537 lcolor[_number % 2]) 4480 lcolor[_number % 2])
4538 if column is self.__type_column: 4481 if column is self.__type_column:
4539 _type = self.option_types[tree_model[_row_path][3]] 4482 _type = self.__option_types[tree_model[_row_path][3]]
4540 cell_renderer.set_property('text', _type) 4483 cell_renderer.set_property('text', _type)
4541 4484
4542 def setOptions(self, option_list): 4485 def _setOptions(self, option_list):
4543 """setOptions(self, option_list) 4486 """_setOptions(option_list)
4544 4487
4545 option_list: list of tuples 4488 option_list: list of tuples
4546 (option, option name, type) 4489 (option, option name, type)
4547 option: option identifier 4490 option: option identifier
4548 option name: a string with the option name 4491 option name: a string with the option name
4564 _option_type = _option[2] 4507 _option_type = _option[2]
4565 _option_description = _option[3] 4508 _option_description = _option[3]
4566 if isinstance(_option_key, str) and \ 4509 if isinstance(_option_key, str) and \
4567 (isinstance(_option_name, str) or\ 4510 (isinstance(_option_name, str) or\
4568 isinstance(_option_name, unicode))and \ 4511 isinstance(_option_name, unicode))and \
4569 _option_type in self.option_types.keys(): 4512 _option_type in self.__option_types.keys():
4570 self.__liststore.append([_option_key, _option_name, "", 4513 self.__liststore.append([_option_key, _option_name, "",
4571 _option_type, _option_description]) 4514 _option_type, _option_description])
4572 self.__option_dict[_option_key] = [_option_name, "", 4515 self.__option_dict[_option_key] = [_option_name, "",
4573 _option_type, _option_description] 4516 _option_type, _option_description]
4574 self.__option_list.append(_option_key) 4517 self.__option_list.append(_option_key)
4576 print _("Option values must be strings") 4519 print _("Option values must be strings")
4577 else: 4520 else:
4578 print _("Option must be a tuple with 4 items") 4521 print _("Option must be a tuple with 4 items")
4579 else: 4522 else:
4580 print _("Option list must be a list") 4523 print _("Option list must be a list")
4581 return 4524
4582 def setValues(self, values): 4525 def _setValues(self, values):
4583 """setValues(self, values) 4526 """_setValues(values)
4584 4527
4585 values: dictionary {option : value} 4528 values: dictionary {option : value}
4586 4529
4587 Sets the Options values 4530 Sets the Options values
4588 """ 4531 """
4652 self.__treeview.grab_focus() 4595 self.__treeview.grab_focus()
4653 (_cursor_path, _column) = self.__treeview.get_cursor() 4596 (_cursor_path, _column) = self.__treeview.get_cursor()
4654 _description = self.__liststore[_cursor_path][4] 4597 _description = self.__liststore[_cursor_path][4]
4655 self.__description_label.set_text(_description) 4598 self.__description_label.set_text(_description)
4656 4599
4657 def getWidget(self): 4600 def _getWidget(self):
4658 """def getWidget(self) 4601 """_getWidget()
4659 4602
4660 return the main widget (gtk.ScrolledWindow) 4603 return the main widget (gtk.ScrolledWindow)
4661 """ 4604 """
4662 return self.__widget 4605 return self.__widget
4663 widget = property(getWidget, None, None, 4606
4607 widget = property(_getWidget, None, None,
4664 "main widget") 4608 "main widget")
4609 values = property(None, _setValues, None,
4610 "values")
4611 options = property(None, _setOptions, None,
4612 "options")