Subversion Repositories basico

Rev

Rev 106 | Rev 113 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/usr/bin/python
# -*- coding: utf-8 -*-
# File: sapnoteview.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Workplace service


import traceback as tb

from gi.repository import Gio

from .log import get_logger
from .sapnoteview import SAPNoteViewMenu, SAPNoteViewVisor
from .service import Service


class Workplace(Service):
    def initialize(self):
        '''
        Setup Workplace Service
        '''

        self.get_services()
        self.setup_widgets()


    def setup_widgets(self):
        # Toolbar
        tgbshowmenu = self.gui.get_widget('tgbShowMenuView')
        tgbshowmenu.connect('toggled', self.show_menu_view)
        # Menu Views
        self.setup_menu_views()

        # Views
        viewsbox = self.gui.get_widget('viewsbox')
        viewmenu = self.gui.add_widget('viewmenu', SAPNoteViewMenu(self.app))
        viewmenu.set_view('component')
        self.gui.swap_widget(viewsbox, viewmenu)

        # SAP Notes Visor
        visorbox = self.gui.get_widget('notesbox')
        visor = self.gui.add_widget('visor', SAPNoteViewVisor(self.app))
        self.gui.swap_widget(visorbox, visor)


    def get_services(self):
        self.gui = self.app.get_service("GUI")
        self.uif = self.app.get_service("UIF")
        self.cb = self.app.get_service('Callbacks')


    def show_menu_view(self, *args):
        paned = self.gui.get_widget('boxMenuView')
        button = self.gui.get_widget('tgbShowMenuView')
        if button.get_active():
            paned.show_all()
        else:
            paned.hide()

    def setup_menu_views(self):
        app = self.gui.get_app()

        # View label
        self.gui.add_widget('lblViewCurrent')

        ## Views Menu
        views_menu = self.gui.add_widget('mnuviews', Gio.Menu())

        # Last added view
        #~ TODO
        #~ views_menu.append_item(self.uif.create_item('View last added', 'app.view-lastadded', ''))
        #~ self.app.add_action(self.uif.create_action("view-lastadded", self.cb_show_dlnotes_window))

        # Most used view
        #~ TODO
        #~ views_menu.append_item(self.uif.create_item('View most used', 'app.view-mostused', ''))
        #~ self.app.add_action(self.uif.create_action("view-mostused", self.cb_show_dlnotes_window))

        # Tasks view
        views_menu.append_item(self.uif.create_item('View by tasks', 'app.view-tasks', 'emblem-system'))
        app.add_action(self.uif.create_action("view-tasks", self.cb.refresh_view, 'tasks'))

        # Projects view
        #~ views_menu.append_item(self.uif.create_item('View by projects', 'app.view-projects', ''))
        #~ self.app.add_action(self.uif.create_action("view-projects", self.cb.refresh_view, 'projects'))

        # Components view
        views_menu.append_item(self.uif.create_item('View by components', 'app.view-components', ''))
        app.add_action(self.uif.create_action("view-components", self.cb.refresh_view, 'components'))

        # Component descriptions view
        views_menu.append_item(self.uif.create_item('View by description', 'app.view-component-descriptions', ''))
        app.add_action(self.uif.create_action("view-component-descriptions", self.cb.refresh_view, 'description'))

        # Bookmarks view
        views_menu.append_item(self.uif.create_item('View bookmarks', 'app.view-bookmarks', ''))
        app.add_action(self.uif.create_action("view-bookmarks", self.cb.refresh_view, 'bookmarks'))

        # Category view
        views_menu.append_item(self.uif.create_item('View categories', 'app.view-categories', ''))
        app.add_action(self.uif.create_action("view-categories", self.cb.refresh_view, 'category'))

        # Chronologic order view
        views_menu.append_item(self.uif.create_item('View chronologically', 'app.chronologic-order', ''))
        app.add_action(self.uif.create_action("chronologic-order", self.cb.refresh_view, 'chronologic'))

        # Priority view
        views_menu.append_item(self.uif.create_item('View by priority', 'app.view-priority', ''))
        app.add_action(self.uif.create_action("view-priority", self.cb.refresh_view, 'priority'))

        # SAP Note Type view
        views_menu.append_item(self.uif.create_item('View by type', 'app.view-type', ''))
        app.add_action(self.uif.create_action("view-type", self.cb.refresh_view, 'type'))

        # Annotations view
        #~ TODO
        #~ views_menu.append_item(self.uif.create_item('View by annotations', 'app.view-annotations', ''))
        #~ self.app.add_action(self.uif.create_action("view-annotations", self.cb_show_dlnotes_window))

        # Set menu model in button
        btnviews = self.gui.get_widget('mnuBtnViews')
        btnviews.set_menu_model(views_menu)
        btnviews.clicked()