Mercurial > pyarq-presupuestos
comparison Gtk/gui.py @ 25:189f8274aecd
gui. switch navigation menu on switch page
| author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
|---|---|
| date | Mon, 20 May 2019 13:18:33 +0200 |
| parents | 65e7ae0d0e63 |
| children | 16f91684686b |
comparison
equal
deleted
inserted
replaced
| 24:2b393934f1db | 25:189f8274aecd |
|---|---|
| 75 # Load default icon | 75 # Load default icon |
| 76 _icons = [ "ICON16", "ICON32","ICON64","ICON128"] | 76 _icons = [ "ICON16", "ICON32","ICON64","ICON128"] |
| 77 _pixbufIcons = [] | 77 _pixbufIcons = [] |
| 78 for _icon in _icons: | 78 for _icon in _icons: |
| 79 if os.path.exists(globalVars.getAppPath(_icon)): | 79 if os.path.exists(globalVars.getAppPath(_icon)): |
| 80 _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(globalVars.getAppPath(_icon)) | 80 _icon_file = globalVars.getAppPath(_icon) |
| 81 _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file) | |
| 81 _pixbufIcons.append(_pixbufIcon) | 82 _pixbufIcons.append(_pixbufIcon) |
| 82 else: | 83 else: |
| 83 print(utils.mapping(_("The icon file does not exist. '$1'"), | 84 print(utils.mapping(_("The icon file does not exist. '$1'"), |
| 84 (str(globalVars.getAppPath(_icon)),)) ) | 85 (str(globalVars.getAppPath(_icon)),)) ) |
| 85 if len(_pixbufIcons) > 0: | 86 if len(_pixbufIcons) > 0: |
| 102 Description: | 103 Description: |
| 103 This is the Gtk application base class. | 104 This is the Gtk application base class. |
| 104 Constructor: | 105 Constructor: |
| 105 App() | 106 App() |
| 106 Ancestry: | 107 Ancestry: |
| 107 +-- Gtk.Application https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html | 108 +-- Gtk.Application |
| 109 https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html | |
| 108 +-- App | 110 +-- App |
| 109 Atributes: | 111 Atributes: |
| 110 Methods: | 112 Methods: |
| 111 do_activate | 113 do_activate |
| 112 do_startup | 114 do_startup |
| 139 """do_activate() | 141 """do_activate() |
| 140 | 142 |
| 141 Shows new appplication windows. | 143 Shows new appplication windows. |
| 142 """ | 144 """ |
| 143 _mainWindow = MainWindow(self, self.filesToOpen ) | 145 _mainWindow = MainWindow(self, self.filesToOpen ) |
| 144 _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000) | 146 _mainWindow.window.present_with_time(Gtk.get_current_event_time()) |
| 145 | 147 |
| 146 def do_startup(self): | 148 def do_startup(self): |
| 147 """do_startup() | 149 """do_startup() |
| 148 | 150 |
| 149 Sets the app actions. | 151 Sets the app actions. |
| 190 win_menu = False | 192 win_menu = False |
| 191 # Win Menu | 193 # Win Menu |
| 192 if win_menu: | 194 if win_menu: |
| 193 _win_menu = Gio.Menu() | 195 _win_menu = Gio.Menu() |
| 194 _win_submenu_file = Gio.Menu.new() | 196 _win_submenu_file = Gio.Menu.new() |
| 195 _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"), "win.ImportFiebdc") | 197 _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"), |
| 198 "win.ImportFiebdc") | |
| 196 _import_fiebdc.set_icon(Gio.Icon.new_for_string("document-open")) | 199 _import_fiebdc.set_icon(Gio.Icon.new_for_string("document-open")) |
| 197 _win_submenu_file.append_item(_import_fiebdc) | 200 _win_submenu_file.append_item(_import_fiebdc) |
| 198 | 201 |
| 199 _close_tab = Gio.MenuItem.new(_("_Close tab"), "win.CloseTab") | 202 _close_tab = Gio.MenuItem.new(_("_Close tab"), "win.CloseTab") |
| 200 _close_tab.set_icon(Gio.Icon.new_for_string("window-close")) | 203 _close_tab.set_icon(Gio.Icon.new_for_string("window-close")) |
| 221 """on_newWindow(action, param) | 224 """on_newWindow(action, param) |
| 222 | 225 |
| 223 Shows new appplication windows. | 226 Shows new appplication windows. |
| 224 """ | 227 """ |
| 225 _mainWindow = MainWindow(self, []) | 228 _mainWindow = MainWindow(self, []) |
| 226 _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000) | 229 _mainWindow.window.present_with_time(Gtk.get_current_event_time()) |
| 227 | 230 |
| 228 def _on_about(self, action, param): | 231 def _on_about(self, action, param): |
| 229 """_on_about(action, param) | 232 """_on_about(action, param) |
| 230 | 233 |
| 231 Shows About dialog. | 234 Shows About dialog. |
| 238 _aboutDialog.set_website(base.website) | 241 _aboutDialog.set_website(base.website) |
| 239 _aboutDialog.set_website_label(base.website_label) | 242 _aboutDialog.set_website_label(base.website_label) |
| 240 _aboutDialog.set_license_type(Gtk.License(3)) | 243 _aboutDialog.set_license_type(Gtk.License(3)) |
| 241 _aboutDialog.set_comments(base.comments) | 244 _aboutDialog.set_comments(base.comments) |
| 242 _aboutDialog.connect("response", self._on_close_aboutdialog) | 245 _aboutDialog.connect("response", self._on_close_aboutdialog) |
| 243 _aboutDialog.present_with_time(GLib.get_monotonic_time() / 1000) | 246 _aboutDialog.present_with_time(Gtk.get_current_event_time()) |
| 244 | 247 |
| 245 def _on_close_aboutdialog(self, action, parameter): | 248 def _on_close_aboutdialog(self, action, parameter): |
| 246 """on_close_aboutdialog(action, param) | 249 """on_close_aboutdialog(action, param) |
| 247 | 250 |
| 248 Close About dialog. | 251 Close About dialog. |
| 386 _toolbar = Gtk.Toolbar() | 389 _toolbar = Gtk.Toolbar() |
| 387 _toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) | 390 _toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) |
| 388 # Import Fiebdc | 391 # Import Fiebdc |
| 389 _gtk_image = Gtk.Image.new_from_icon_name("document-open",1) | 392 _gtk_image = Gtk.Image.new_from_icon_name("document-open",1) |
| 390 _gtk_image.show() | 393 _gtk_image.show() |
| 391 _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image , _("Import Fiebdc")) | 394 _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image, |
| 395 _("Import Fiebdc")) | |
| 392 _ImportFiebdc_button.set_tooltip_text(_("Import Fiebdc")) | 396 _ImportFiebdc_button.set_tooltip_text(_("Import Fiebdc")) |
| 393 _ImportFiebdc_button.set_is_important(False) # label not shown | 397 _ImportFiebdc_button.set_is_important(False) # label not shown |
| 394 _toolbar.insert(_ImportFiebdc_button, -1) | 398 _toolbar.insert(_ImportFiebdc_button, -1) |
| 395 _ImportFiebdc_button.show() | 399 _ImportFiebdc_button.show() |
| 396 _ImportFiebdc_button.set_action_name("win.ImportFiebdc") | 400 _ImportFiebdc_button.set_action_name("win.ImportFiebdc") |
| 417 self.__goBack_button.show() | 421 self.__goBack_button.show() |
| 418 self.__goBack_button.set_action_name("win.GoPrevious") | 422 self.__goBack_button.set_action_name("win.GoPrevious") |
| 419 # Go Forward | 423 # Go Forward |
| 420 _gtk_image = Gtk.Image.new_from_icon_name("go-next",1) | 424 _gtk_image = Gtk.Image.new_from_icon_name("go-next",1) |
| 421 _gtk_image.show() | 425 _gtk_image.show() |
| 422 self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image ,_("Forward")) | 426 self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image, |
| 427 _("Forward")) | |
| 423 self.__goForward_button.set_tooltip_text(_("Forward")) | 428 self.__goForward_button.set_tooltip_text(_("Forward")) |
| 424 self.__goForward_button.set_is_important(False) # label not shown | 429 self.__goForward_button.set_is_important(False) # label not shown |
| 425 _toolbar.insert(self.__goForward_button, -1) | 430 _toolbar.insert(self.__goForward_button, -1) |
| 426 self.__goForward_button.show() | 431 self.__goForward_button.show() |
| 427 self.__goForward_button.set_action_name("win.GoPosterior") | 432 self.__goForward_button.set_action_name("win.GoPosterior") |
| 536 self.__GoPosterior_action.set_enabled(False) | 541 self.__GoPosterior_action.set_enabled(False) |
| 537 self.__GoUp_action.set_enabled(False) | 542 self.__GoUp_action.set_enabled(False) |
| 538 self.__GoToRoot_action.set_enabled(False) | 543 self.__GoToRoot_action.set_enabled(False) |
| 539 self.__navigation_is_enabled = False | 544 self.__navigation_is_enabled = False |
| 540 | 545 |
| 541 def _switch_page(self, notebook, page, page_num,): | 546 def _switch_page(self, notebook, page, page_num): |
| 542 """_switch_page(notebook, page, page_num) | 547 """_switch_page(notebook, page, page_num) |
| 543 | 548 |
| 544 Method connected to the "switch-page" signal of the notebook widget | 549 Method connected to the "switch-page" signal of the notebook widget |
| 545 | 550 |
| 546 It shows/hides closeTabButton | 551 It shows/hides closeTabButton |
| 557 self.__navigation_is_enabled: | 562 self.__navigation_is_enabled: |
| 558 self._disable_navigation() | 563 self._disable_navigation() |
| 559 elif isinstance(_page, Page): | 564 elif isinstance(_page, Page): |
| 560 if not self.__navigation_is_enabled: | 565 if not self.__navigation_is_enabled: |
| 561 self.__navigation_is_enabled = True | 566 self.__navigation_is_enabled = True |
| 562 self._checkButtonsSensitive(page_num) | 567 self.__goBack_button.set_menu(_page.back_menu) |
| 568 self.__goForward_button.set_menu(_page.forward_menu) | |
| 569 self._checkButtonsSensitive(page_num) | |
| 563 | 570 |
| 564 def _main(self): | 571 def _main(self): |
| 565 """main() | 572 """main() |
| 566 | 573 |
| 567 Shows window. | 574 Shows window. |
| 955 self.closeTabButton = Gtk.ToolButton.new(_gtk_image , _("_Close tab")) | 962 self.closeTabButton = Gtk.ToolButton.new(_gtk_image , _("_Close tab")) |
| 956 self.closeTabButton.set_tooltip_text(_("Close tab")) | 963 self.closeTabButton.set_tooltip_text(_("Close tab")) |
| 957 self.closeTabButton.set_is_important(False) # label not shown | 964 self.closeTabButton.set_is_important(False) # label not shown |
| 958 self.__title.add(self.closeTabButton) | 965 self.__title.add(self.closeTabButton) |
| 959 self.closeTabButton.hide() | 966 self.closeTabButton.hide() |
| 960 self.__closeTabId = self.closeTabButton.connect("clicked", self.on_close_button) | 967 self.__closeTabId = self.closeTabButton.connect("clicked", |
| 968 self.on_close_button) | |
| 961 # Statusbar | 969 # Statusbar |
| 962 self.__statusbar = Gtk.Statusbar() | 970 self.__statusbar = Gtk.Statusbar() |
| 963 self.__statuscontext = self.__statusbar.get_context_id("Statusbar") | 971 self.__statuscontext = self.__statusbar.get_context_id("Statusbar") |
| 964 self.__statusbar.show() | 972 self.__statusbar.show() |
| 965 _iconVbox = Gtk.Grid() | 973 _iconVbox = Gtk.Grid() |
| 1270 self.closeTabButton = closeTabButton | 1278 self.closeTabButton = closeTabButton |
| 1271 self.__widget = Gtk.Grid() | 1279 self.__widget = Gtk.Grid() |
| 1272 self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical | 1280 self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical |
| 1273 self.__widget.props.margin = 5 | 1281 self.__widget.props.margin = 5 |
| 1274 #TODO: __panes_list should come from gui config file... | 1282 #TODO: __panes_list should come from gui config file... |
| 1275 # "DecompositionList" "RecordDescription" "Measure" "Sheet of Conditions" | 1283 # "DecompositionList" "RecordDescription" "Measure" |
| 1276 # "FileView" "CompanyView" | 1284 # "Sheet of Conditions" "FileView" "CompanyView" |
| 1277 self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure", | 1285 self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure", |
| 1278 "RecordDescription" ]] | 1286 "RecordDescription" ]] |
| 1279 self.__main_item = None | 1287 self.__main_item = None |
| 1280 self.__active_path_record = () | 1288 self.__active_path_record = () |
| 1281 self.__history_back = [] | 1289 self.__history_back = [] |
| 1328 | 1336 |
| 1329 def sendMessageTo(self, pane, message, pane_path, arg=None): | 1337 def sendMessageTo(self, pane, message, pane_path, arg=None): |
| 1330 """sendMessageTo(pane, message, pane_path, arg=None) | 1338 """sendMessageTo(pane, message, pane_path, arg=None) |
| 1331 pane: the receiver pane | 1339 pane: the receiver pane |
| 1332 message: string message | 1340 message: string message |
| 1333 pane_path: tuple that represents the pane pane_path which emits the message | 1341 pane_path: tuple that represents the pane pane_path which emits |
| 1342 the message | |
| 1334 arg: arguments for the message | 1343 arg: arguments for the message |
| 1335 | 1344 |
| 1336 Sends a message to a pane | 1345 Sends a message to a pane |
| 1337 """ | 1346 """ |
| 1338 pane.runMessage(message, pane_path, arg) | 1347 pane.runMessage(message, pane_path, arg) |
| 1468 weakref.ref(self), pane_path, self.__active_path_record, True) | 1477 weakref.ref(self), pane_path, self.__active_path_record, True) |
| 1469 elif list_paned[0] == "RecordDescription": | 1478 elif list_paned[0] == "RecordDescription": |
| 1470 _item = View( "RecordDescription", self.__budget,weakref.ref(self), | 1479 _item = View( "RecordDescription", self.__budget,weakref.ref(self), |
| 1471 pane_path, self.__active_path_record, True) | 1480 pane_path, self.__active_path_record, True) |
| 1472 elif list_paned[0] == "Measure": | 1481 elif list_paned[0] == "Measure": |
| 1473 _item = View( "Measure", self.__budget, weakref.ref(self), pane_path, | 1482 _item = View("Measure", self.__budget, weakref.ref(self), |
| 1474 self.__active_path_record, True) | 1483 pane_path, self.__active_path_record, True) |
| 1475 elif list_paned[0] == "Sheet of Conditions": | 1484 elif list_paned[0] == "Sheet of Conditions": |
| 1476 _item = View("Sheet of Conditions", self.__budget, weakref.ref(self), pane_path, | 1485 _item = View("Sheet of Conditions", |
| 1486 self.__budget, weakref.ref(self), pane_path, | |
| 1477 self.__active_path_record) | 1487 self.__active_path_record) |
| 1478 elif list_paned[0] == "FileView": | 1488 elif list_paned[0] == "FileView": |
| 1479 _item = View("FileView", self.__budget, weakref.ref(self), pane_path, | 1489 _item = View("FileView", self.__budget, weakref.ref(self), |
| 1480 self.__active_path_record) | 1490 pane_path, self.__active_path_record) |
| 1481 elif list_paned[0] == "CompanyView": | 1491 elif list_paned[0] == "CompanyView": |
| 1482 _item = View("CompanyView", self.__budget, weakref.ref(self), pane_path, | 1492 _item = View("CompanyView", self.__budget, weakref.ref(self), |
| 1483 self.__active_path_record) | 1493 pane_path, self.__active_path_record) |
| 1484 else: | 1494 else: |
| 1485 _item = None | 1495 _item = None |
| 1486 raise ValueError( utils.mapping(_("Incorrect item $1"), | 1496 raise ValueError( utils.mapping(_("Incorrect item $1"), |
| 1487 (str(list_paned[0]),)) ) | 1497 (str(list_paned[0]),)) ) |
| 1488 return _item | 1498 return _item |
| 1924 self.__widget.add(self.__view.widget) | 1934 self.__widget.add(self.__view.widget) |
| 1925 _hbox.add(_view_icon) | 1935 _hbox.add(_view_icon) |
| 1926 _hbox.add(_combobox) | 1936 _hbox.add(_combobox) |
| 1927 _invisible = Gtk.Grid() | 1937 _invisible = Gtk.Grid() |
| 1928 _invisible.set_orientation(Gtk.Orientation(0)) # 0 Horizontal | 1938 _invisible.set_orientation(Gtk.Orientation(0)) # 0 Horizontal |
| 1929 _invisible.set_property("hexpand", True) # widget expand horizontal space | 1939 _invisible.set_property("hexpand", True) # expand horizontal space |
| 1930 _invisible.show() | 1940 _invisible.show() |
| 1931 _hbox.add(_invisible) | 1941 _hbox.add(_invisible) |
| 1932 # TODO : Set thist with config | 1942 # TODO : Set thist with config |
| 1933 add_menu = False | 1943 add_menu = False |
| 1934 if add_menu: | 1944 if add_menu: |
| 1962 _hbox.add(_vertical_button) | 1972 _hbox.add(_vertical_button) |
| 1963 | 1973 |
| 1964 self.__connected_button = Gtk.ToolButton() | 1974 self.__connected_button = Gtk.ToolButton() |
| 1965 _icon_connected = Gtk.Image() | 1975 _icon_connected = Gtk.Image() |
| 1966 if self.__connected: | 1976 if self.__connected: |
| 1967 _icon_connected.set_from_file(globalVars.getAppPath("CONNECTED-ICON")) | 1977 _icon_path = globalVars.getAppPath("CONNECTED-ICON") |
| 1978 _icon_connected.set_from_file(_icon_path) | |
| 1968 self.__connected_button.set_tooltip_text(_("Disconnect view")) | 1979 self.__connected_button.set_tooltip_text(_("Disconnect view")) |
| 1969 else: | 1980 else: |
| 1970 _icon_connected.set_from_file(globalVars.getAppPath("DISCONNECTED-ICON")) | 1981 _icon_path = globalVars.getAppPath("DISCONNECTED-ICON") |
| 1982 _icon_connected.set_from_file(_icon_path) | |
| 1971 self.__connected_button.set_tooltip_text(_("Connect view")) | 1983 self.__connected_button.set_tooltip_text(_("Connect view")) |
| 1972 _icon_connected.show() | 1984 _icon_connected.show() |
| 1973 self.__connected_button.set_icon_widget(_icon_connected) | 1985 self.__connected_button.set_icon_widget(_icon_connected) |
| 1974 self.__connected_button.connect("clicked", self._connected) | 1986 self.__connected_button.connect("clicked", self._connected) |
| 1975 self.__connected_button.show() | 1987 self.__connected_button.show() |
| 2080 _item_topbottom.show() | 2092 _item_topbottom.show() |
| 2081 _item_close = Gtk.MenuItem(_("Close view")) | 2093 _item_close = Gtk.MenuItem(_("Close view")) |
| 2082 _menu_view.append(_item_close) | 2094 _menu_view.append(_item_close) |
| 2083 _item_close.connect("activate",self._closeItem_from_menu) | 2095 _item_close.connect("activate",self._closeItem_from_menu) |
| 2084 _item_close.show() | 2096 _item_close.show() |
| 2085 _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1), Gtk.get_current_event()) | 2097 _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1), |
| 2098 Gtk.get_current_event()) | |
| 2086 | 2099 |
| 2087 def _split_view(self, widget, orientation): | 2100 def _split_view(self, widget, orientation): |
| 2088 """_menu_view(orientation) | 2101 """_menu_view(orientation) |
| 2089 | 2102 |
| 2090 orientation: orientation split, "h" or "v" | 2103 orientation: orientation split, "h" or "v" |
| 2580 page: weak reference from Page instance which creates this class | 2593 page: weak reference from Page instance which creates this class |
| 2581 pane_path: tuple that represents the path of the List in the Page | 2594 pane_path: tuple that represents the path of the List in the Page |
| 2582 path_record: the record path that must be showed | 2595 path_record: the record path that must be showed |
| 2583 | 2596 |
| 2584 self.__budget: budget showed ("base.Budget" object) | 2597 self.__budget: budget showed ("base.Budget" object) |
| 2585 self.__wr_page: weak reference from Page instance which creates this class | 2598 self.__wr_page: weak reference from Page instance which creates self |
| 2586 self.__pane_path: tuple that represents the path of the List in the Page | 2599 self.__pane_path: tuple that represents the path of the List in the Page |
| 2587 self.__liststore: list model which store the list data | 2600 self.__liststore: list model which store the list data |
| 2588 (Gtk.ListStore object) | 2601 (Gtk.ListStore object) |
| 2589 self.__active_path_record: the record path that must be showed | 2602 self.__active_path_record: the record path that must be showed |
| 2590 self.__treeview: widget for displaying decomposition lists | 2603 self.__treeview: widget for displaying decomposition lists |
| 2643 self.__treeview.set_reorderable(False) | 2656 self.__treeview.set_reorderable(False) |
| 2644 self.__treeview.set_headers_clickable(True) | 2657 self.__treeview.set_headers_clickable(True) |
| 2645 self.__treeview.show() | 2658 self.__treeview.show() |
| 2646 # Scrolled_window | 2659 # Scrolled_window |
| 2647 self.__scrolled_window = Gtk.ScrolledWindow() | 2660 self.__scrolled_window = Gtk.ScrolledWindow() |
| 2648 self.__scrolled_window.set_property("expand", True) # widget expand all space | 2661 # widget expand all space |
| 2662 self.__scrolled_window.set_property("expand", True) | |
| 2649 self.__scrolled_window.set_policy(Gtk.PolicyType(1), | 2663 self.__scrolled_window.set_policy(Gtk.PolicyType(1), |
| 2650 Gtk.PolicyType(1)) # 1 Automatic | 2664 Gtk.PolicyType(1)) # 1 Automatic |
| 2651 self.__scrolled_window.add(self.__treeview) | 2665 self.__scrolled_window.add(self.__treeview) |
| 2652 # colors | 2666 # colors |
| 2653 _text_color = globalVars.color["TEXT"] | 2667 _text_color = globalVars.color["TEXT"] |
| 2816 | 2830 |
| 2817 Returns :TRUE if the signal was handled. | 2831 Returns :TRUE if the signal was handled. |
| 2818 """ | 2832 """ |
| 2819 return False | 2833 return False |
| 2820 | 2834 |
| 2821 def _controlSelection(self, selection, model, path, path_currently_selected, *data): | 2835 def _controlSelection(self, selection, model, path, |
| 2822 """_controlSelection(selection) | 2836 path_currently_selected, *data): |
| 2837 """_controlSelection(selection, model, path, | |
| 2838 path_currently_selected, *data) | |
| 2823 | 2839 |
| 2824 selection: treeselection | 2840 selection: treeselection |
| 2825 | 2841 |
| 2826 Method connected to set_selection_function() | 2842 Method connected to set_selection_function() |
| 2827 This method is called before any node is selected or unselected, | 2843 This method is called before any node is selected or unselected, |
| 2887 _amount = _price | 2903 _amount = _price |
| 2888 else: | 2904 else: |
| 2889 _parent_code = self.budget.getCode(self.__active_path_record[:-1]) | 2905 _parent_code = self.budget.getCode(self.__active_path_record[:-1]) |
| 2890 _parent_record = self.__budget.getRecord(_parent_code) | 2906 _parent_record = self.__budget.getRecord(_parent_code) |
| 2891 _amount = _budget.getStrAmount(self.__active_path_record) | 2907 _amount = _budget.getStrAmount(self.__active_path_record) |
| 2892 self.__code_column.set_title(_("Code") + chr(10) + "[" + _code.decode("utf8") + "]") | 2908 _str = _("Code") + chr(10) + "[" + _code.decode("utf8") + "]" |
| 2893 self.__unit_column.set_title(_("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]") | 2909 self.__code_column.set_title(_str) |
| 2894 self.__description_column.set_title( | 2910 _str = _("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]" |
| 2895 _("Description") + chr(10) + "[" + _description.decode("utf8") + "]") | 2911 self.__unit_column.set_title(_str) |
| 2912 _str = _("Description") + chr(10) + "[" + \ | |
| 2913 _description.decode("utf8") + "]" | |
| 2914 self.__description_column.set_title(_str) | |
| 2896 self.__measure_column.set_title( | 2915 self.__measure_column.set_title( |
| 2897 _("Measure") + chr(10) + "[" + _stryield + "]") | 2916 _("Measure") + chr(10) + "[" + _stryield + "]") |
| 2898 self.__price_column.set_title( | 2917 self.__price_column.set_title( |
| 2899 _("Price") + chr(10) + "[" + _price + "]") | 2918 _("Price") + chr(10) + "[" + _price + "]") |
| 2900 self.__amount_column.set_title( | 2919 self.__amount_column.set_title( |
| 3270 self.__treeview.set_reorderable(False) | 3289 self.__treeview.set_reorderable(False) |
| 3271 self.__treeview.set_headers_clickable(True) | 3290 self.__treeview.set_headers_clickable(True) |
| 3272 self.__treeview.show() | 3291 self.__treeview.show() |
| 3273 # Scrolled_window | 3292 # Scrolled_window |
| 3274 self.__scrolled_window = Gtk.ScrolledWindow() | 3293 self.__scrolled_window = Gtk.ScrolledWindow() |
| 3275 self.__scrolled_window.set_property("expand", True) # widget expand all space | 3294 # widget expand all space |
| 3295 self.__scrolled_window.set_property("expand", True) | |
| 3276 self.__scrolled_window.set_policy(Gtk.PolicyType(1), | 3296 self.__scrolled_window.set_policy(Gtk.PolicyType(1), |
| 3277 Gtk.PolicyType(1)) # 1 Automatic | 3297 Gtk.PolicyType(1)) # 1 Automatic |
| 3278 self.__scrolled_window.add(self.__treeview) | 3298 self.__scrolled_window.add(self.__treeview) |
| 3279 # colors | 3299 # colors |
| 3280 _text_color = globalVars.color["TEXT"] | 3300 _text_color = globalVars.color["TEXT"] |
| 3449 | 3469 |
| 3450 Returns :TRUE if the signal was handled. | 3470 Returns :TRUE if the signal was handled. |
| 3451 """ | 3471 """ |
| 3452 return False | 3472 return False |
| 3453 | 3473 |
| 3454 def _controlSelection(self, selection, model, path, path_currently_selected, *data): | 3474 def _controlSelection(self, selection, model, path, |
| 3455 """_controlSelection(selection) | 3475 path_currently_selected, *data): |
| 3476 """_controlSelection(selection, model, path, | |
| 3477 path_currently_selected, *data) | |
| 3456 | 3478 |
| 3457 selection: treeselection | 3479 selection: treeselection |
| 3458 | 3480 |
| 3459 Method connected to set_selection_function() | 3481 Method connected to set_selection_function() |
| 3460 This method is called before any node is selected or unselected, | 3482 This method is called before any node is selected or unselected, |
| 3795 wr_page: weak reference from Page instance which creates this class | 3817 wr_page: weak reference from Page instance which creates this class |
| 3796 pane_path: the path position of the description in the page | 3818 pane_path: the path position of the description in the page |
| 3797 path_record: the path of the active record | 3819 path_record: the path of the active record |
| 3798 | 3820 |
| 3799 self.__budget: the budget (base.obra object) | 3821 self.__budget: the budget (base.obra object) |
| 3800 self.__wr_page: weak reference from Page instance which creates this class | 3822 self.__wr_page: weak reference from Page instance which creates self |
| 3801 self.__pane_path: the path position of the description in the page | 3823 self.__pane_path: the path position of the description in the page |
| 3802 self.__active_path_recordthe path of the active record | 3824 self.__active_path_recordthe path of the active record |
| 3803 | 3825 |
| 3804 self.__textbuffer: The textbuffer of the textview that contain | 3826 self.__textbuffer: The textbuffer of the textview that contain |
| 3805 the record text. | 3827 the record text. |
| 3820 self.__active_path_record)).text | 3842 self.__active_path_record)).text |
| 3821 _scrollwindow = Gtk.ScrolledWindow() | 3843 _scrollwindow = Gtk.ScrolledWindow() |
| 3822 _scrollwindow.set_property("expand", True) # widget expand all space | 3844 _scrollwindow.set_property("expand", True) # widget expand all space |
| 3823 _scrollwindow.set_policy(Gtk.PolicyType(1), | 3845 _scrollwindow.set_policy(Gtk.PolicyType(1), |
| 3824 Gtk.PolicyType(1)) # 1 Automatic | 3846 Gtk.PolicyType(1)) # 1 Automatic |
| 3825 _scrollwindow.set_shadow_type(1) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4 | 3847 _scrollwindow.set_shadow_type(1) # IN 1 |
| 3826 _textview = Gtk.TextView() | 3848 _textview = Gtk.TextView() |
| 3827 _textview.set_wrap_mode(2) # 2 Word | 3849 _textview.set_wrap_mode(2) # 2 Word |
| 3828 _textview.set_hexpand(True) | 3850 _textview.set_hexpand(True) |
| 3829 _textview.set_vexpand(True) | 3851 _textview.set_vexpand(True) |
| 3830 self.__textbuffer = _textview.get_buffer() | 3852 self.__textbuffer = _textview.get_buffer() |
| 3979 wr_page: weak reference from Page instance which creates this class | 4001 wr_page: weak reference from Page instance which creates this class |
| 3980 pane_path: the path position of the description in the page | 4002 pane_path: the path position of the description in the page |
| 3981 path_record: the path of the active record | 4003 path_record: the path of the active record |
| 3982 | 4004 |
| 3983 self.__budget: the budget (base.obra object) | 4005 self.__budget: the budget (base.obra object) |
| 3984 self.__wr_page: weak reference from Page instance which creates this class | 4006 self.__wr_page: weak reference from Page instance which creates self |
| 3985 self.__pane_path: the path position of the description in the page | 4007 self.__pane_path: the path position of the description in the page |
| 3986 self.__active_path_record: the path of the active record | 4008 self.__active_path_record: the path of the active record |
| 3987 self.__label: The Gtk.label with the title of the pane | 4009 self.__label: The Gtk.label with the title of the pane |
| 3988 self.__field_liststore: the field liststore | 4010 self.__field_liststore: the field liststore |
| 3989 self.__field_treeview: the field treeview | 4011 self.__field_treeview: the field treeview |
| 4036 _field_column.add_attribute(_field_cell, "text", 1) | 4058 _field_column.add_attribute(_field_cell, "text", 1) |
| 4037 self.__field_treeview.append_column(_field_column) | 4059 self.__field_treeview.append_column(_field_column) |
| 4038 _field_scrollwindow = Gtk.ScrolledWindow() | 4060 _field_scrollwindow = Gtk.ScrolledWindow() |
| 4039 _field_scrollwindow.set_policy(Gtk.PolicyType(1), | 4061 _field_scrollwindow.set_policy(Gtk.PolicyType(1), |
| 4040 Gtk.PolicyType(1)) # 1 Automatic | 4062 Gtk.PolicyType(1)) # 1 Automatic |
| 4041 _field_scrollwindow.set_property("hexpand", True) # widget expand all space | 4063 # widget expand all space |
| 4064 _field_scrollwindow.set_property("hexpand", True) | |
| 4042 _field_scrollwindow.add(self.__field_treeview) | 4065 _field_scrollwindow.add(self.__field_treeview) |
| 4043 _field_scrollwindow.set_size_request(-1, 80) | 4066 _field_scrollwindow.set_size_request(-1, 80) |
| 4044 _field_scrollwindow.show() | 4067 _field_scrollwindow.show() |
| 4045 self.__section_liststore = Gtk.ListStore(str, str) | 4068 self.__section_liststore = Gtk.ListStore(str, str) |
| 4046 self.__section_treeview = Gtk.TreeView(self.__section_liststore) | 4069 self.__section_treeview = Gtk.TreeView(self.__section_liststore) |
| 4059 _section_column.add_attribute(_section_cell, "text", 1) | 4082 _section_column.add_attribute(_section_cell, "text", 1) |
| 4060 self.__section_treeview.append_column(_section_column) | 4083 self.__section_treeview.append_column(_section_column) |
| 4061 _section_scrollwindow = Gtk.ScrolledWindow() | 4084 _section_scrollwindow = Gtk.ScrolledWindow() |
| 4062 _section_scrollwindow.set_policy(Gtk.PolicyType(1), | 4085 _section_scrollwindow.set_policy(Gtk.PolicyType(1), |
| 4063 Gtk.PolicyType(1)) # 1 Automatic | 4086 Gtk.PolicyType(1)) # 1 Automatic |
| 4064 _section_scrollwindow.set_property("hexpand", True) # widget expand all space | 4087 # widget expand all space |
| 4088 _section_scrollwindow.set_property("hexpand", True) | |
| 4065 _section_scrollwindow.set_size_request(-1, 90) | 4089 _section_scrollwindow.set_size_request(-1, 90) |
| 4066 _section_scrollwindow.add(self.__section_treeview) | 4090 _section_scrollwindow.add(self.__section_treeview) |
| 4067 _section_scrollwindow.show() | 4091 _section_scrollwindow.show() |
| 4068 | 4092 |
| 4069 _list_box.add(_field_scrollwindow) | 4093 _list_box.add(_field_scrollwindow) |
| 4127 self.__active_path_record)) | 4151 self.__active_path_record)) |
| 4128 _sheet = _record.getSheet() | 4152 _sheet = _record.getSheet() |
| 4129 _section_list = _sheet.getSections(self.__field_selection) | 4153 _section_list = _sheet.getSections(self.__field_selection) |
| 4130 for _section in _section_list: | 4154 for _section in _section_list: |
| 4131 _section_text = self.__budget.getSheetSection(_section) | 4155 _section_text = self.__budget.getSheetSection(_section) |
| 4132 _iter = self.__section_liststore.append([_section, _section_text]) | 4156 _iter = self.__section_liststore.append([_section, |
| 4157 _section_text]) | |
| 4133 _treeselection = self.__section_treeview.get_selection() | 4158 _treeselection = self.__section_treeview.get_selection() |
| 4134 _treeselection.select_path(0) | 4159 _treeselection.select_path(0) |
| 4135 | 4160 |
| 4136 def _setText(self): | 4161 def _setText(self): |
| 4137 """_setText() | 4162 """_setText() |
| 4190 | 4215 |
| 4191 When a user select a row in the field treeview the text sheet for this | 4216 When a user select a row in the field treeview the text sheet for this |
| 4192 section in showed | 4217 section in showed |
| 4193 """ | 4218 """ |
| 4194 _treeiter = self.__section_liststore.get_iter(path) | 4219 _treeiter = self.__section_liststore.get_iter(path) |
| 4195 self.__section_selection = self.__section_liststore.get_value(_treeiter, 0) | 4220 self.__section_selection = self.__section_liststore.get_value(_treeiter, |
| 4221 0) | |
| 4196 self._setText() | 4222 self._setText() |
| 4197 return True | 4223 return True |
| 4198 | 4224 |
| 4199 def _setActivePathRecord(self, path_record): | 4225 def _setActivePathRecord(self, path_record): |
| 4200 """_setActivePathRecord(path_record)) | 4226 """_setActivePathRecord(path_record)) |
| 4333 Atributes: | 4359 Atributes: |
| 4334 widget: the main widget (Gtk.ScrolledWindow object) | 4360 widget: the main widget (Gtk.ScrolledWindow object) |
| 4335 pane_path: the tuple that identifies the pane in the notebook page | 4361 pane_path: the tuple that identifies the pane in the notebook page |
| 4336 budget: The budget (base.obra object) | 4362 budget: The budget (base.obra object) |
| 4337 active_path_record: Read. | 4363 active_path_record: Read. |
| 4338 wr_page: Read-Write. weak reference from Page instance which creates this class | 4364 wr_page: Read-Write. weak reference from Page instance |
| 4339 Methods: | 4365 Methods: |
| 4340 runMessage | 4366 runMessage |
| 4341 """ | 4367 """ |
| 4342 | 4368 |
| 4343 def __init__(self, budget, wr_page, pane_path, path_record=None): | 4369 def __init__(self, budget, wr_page, pane_path, path_record=None): |
| 4347 wr_page: weak reference from Page instance which creates this class | 4373 wr_page: weak reference from Page instance which creates this class |
| 4348 pane_path: the path position of the description in the page | 4374 pane_path: the path position of the description in the page |
| 4349 path_record: the path of the active record | 4375 path_record: the path of the active record |
| 4350 | 4376 |
| 4351 self.__budget: the budget (base.obra object) | 4377 self.__budget: the budget (base.obra object) |
| 4352 self.__wr_page: weak reference from Page instance which creates this class | 4378 self.__wr_page: weak reference from Page instance which creates self |
| 4353 self.__pane_path: the path position of the description in the page | 4379 self.__pane_path: the path position of the description in the page |
| 4354 self.__active_path_record: the path of the active record | 4380 self.__active_path_record: the path of the active record |
| 4355 self.__active_code: the code of the active record | 4381 self.__active_code: the code of the active record |
| 4356 self.__icon_box: the box that contains the icon | 4382 self.__icon_box: the box that contains the icon |
| 4357 self.__widget: main widget, a Gtk.ScrolledWindow | 4383 self.__widget: main widget, a Gtk.ScrolledWindow |
| 4399 if os.path.exists(_file_path): | 4425 if os.path.exists(_file_path): |
| 4400 _filetype = utils.getFiletype(_file_path) | 4426 _filetype = utils.getFiletype(_file_path) |
| 4401 _event_box = Gtk.LinkButton() | 4427 _event_box = Gtk.LinkButton() |
| 4402 _file_icon = Gtk.Image() | 4428 _file_icon = Gtk.Image() |
| 4403 # "image", "wmf", "dxf", "pdf" , "video", | 4429 # "image", "wmf", "dxf", "pdf" , "video", |
| 4404 # "office-document", "office-presentation", "office-spreadsheet", | 4430 # "office-document", "office-presentation", |
| 4405 # "html", "rtf", "txt", "" | 4431 # "office-spreadsheet", "html", "rtf", "txt", "" |
| 4406 # icon | 4432 # icon |
| 4407 if _filetype in ["image", "wmf"]: | 4433 if _filetype in ["image", "wmf"]: |
| 4408 try: | 4434 try: |
| 4409 _image_pixbuf = GdkPixbuf.Pixbuf.new_from_file(_file_path) | 4435 _image_pixbuf = GdkPixbuf.Pixbuf.new_from_file(_file_path) |
| 4410 _image_pixbuf = _image_pixbuf.scale_simple(64, 64, | 4436 _image_pixbuf = _image_pixbuf.scale_simple(64, 64, |
| 4639 +-- CompanyView | 4665 +-- CompanyView |
| 4640 Atributes: | 4666 Atributes: |
| 4641 active_path_record: Read. Path of the active record in the budget | 4667 active_path_record: Read. Path of the active record in the budget |
| 4642 widget: Read. Window that contains the main widget, a Gtk.Paned | 4668 widget: Read. Window that contains the main widget, a Gtk.Paned |
| 4643 pane_path: Read-Write. Pane page identifier | 4669 pane_path: Read-Write. Pane page identifier |
| 4644 wr_page: Read-Write. weak reference from Page instance which creates this class | 4670 wr_page: Read-Write. weak reference from Page instance |
| 4645 budget: Read. Budget to show, base.budget instance. | 4671 budget: Read. Budget to show, base.budget instance. |
| 4646 Methods: | 4672 Methods: |
| 4647 runMessage | 4673 runMessage |
| 4648 """ | 4674 """ |
| 4649 | 4675 |
| 4655 pane_path: tuple that represents the path of the pane in the Page | 4681 pane_path: tuple that represents the path of the pane in the Page |
| 4656 path_record: path of the active record in the budget | 4682 path_record: path of the active record in the budget |
| 4657 | 4683 |
| 4658 self.__selection: "company" or "office" selected treeview | 4684 self.__selection: "company" or "office" selected treeview |
| 4659 self.__budget: budget: budget showed ("base.Budget" object) | 4685 self.__budget: budget: budget showed ("base.Budget" object) |
| 4660 self.__wr_page: weak reference from Page instance which creates this class | 4686 self.__wr_page: weak reference from Page instance |
| 4661 self.__pane_path: tuple that represents the path of the List in the Page | 4687 self.__pane_path: tuple that represents the path of the List in the Page |
| 4662 self.__active_path_record: path of the active record in the budget | 4688 self.__active_path_record: path of the active record in the budget |
| 4663 self.__widget: main widget, a Gtk.Paned | 4689 self.__widget: main widget, a Gtk.Paned |
| 4664 self.__treestore: to store companys data | 4690 self.__treestore: to store companys data |
| 4665 self.__option_View: OptionView object | 4691 self.__option_View: OptionView object |
| 4789 for _office in _offices: | 4815 for _office in _offices: |
| 4790 # TODO: Test offices | 4816 # TODO: Test offices |
| 4791 _values = [_office.officeType, _office.subname] | 4817 _values = [_office.officeType, _office.subname] |
| 4792 self.__treestore.append(_treeiter, _values) | 4818 self.__treestore.append(_treeiter, _values) |
| 4793 | 4819 |
| 4794 def _controlSelection(self, selection, model, path, path_currently_selected, *data): | 4820 def _controlSelection(self, selection, model, path, |
| 4795 """_controlSelection(selection, model, path, path_currently_selected, *data) | 4821 path_currently_selected, *data): |
| 4822 """_controlSelection(selection, model, path, | |
| 4823 path_currently_selected, *data) | |
| 4796 | 4824 |
| 4797 selection: selection | 4825 selection: selection |
| 4798 | 4826 |
| 4799 Method connected to set_selection_function() | 4827 Method connected to set_selection_function() |
| 4800 This method is called before any node is selected or unselected, | 4828 This method is called before any node is selected or unselected, |
| 5081 _treeselection = self.__treeview.get_selection() | 5109 _treeselection = self.__treeview.get_selection() |
| 5082 _treeselection.set_mode(Gtk.SelectionMode(3)) # 3 MULTIPLE | 5110 _treeselection.set_mode(Gtk.SelectionMode(3)) # 3 MULTIPLE |
| 5083 _treeselection.set_select_function(self._controlSelection) | 5111 _treeselection.set_select_function(self._controlSelection) |
| 5084 # labels | 5112 # labels |
| 5085 _frame = Gtk.Frame() | 5113 _frame = Gtk.Frame() |
| 5086 _frame.set_shadow_type(2) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4 | 5114 _frame.set_shadow_type(2) # OUT 2 |
| 5087 _vbox2 = Gtk.Grid() | 5115 _vbox2 = Gtk.Grid() |
| 5088 _vbox2.set_orientation(Gtk.Orientation(1)) # 1 Vertical | 5116 _vbox2.set_orientation(Gtk.Orientation(1)) # 1 Vertical |
| 5089 _frame.add(_vbox2) | 5117 _frame.add(_vbox2) |
| 5090 _label = Gtk.Label() | 5118 _label = Gtk.Label() |
| 5091 _label.set_xalign(0) | 5119 _label.set_xalign(0) |
