Subversion Repositories basico

Rev

Rev 109 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 t00mlabs 1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
# File: sapnoteview.py
4
# Author: Tomás Vírseda
5
# License: GPL v3
106 t00mlabs 6
# Description: Workplace service
4 t00mlabs 7
 
106 t00mlabs 8
 
80 t00mlabs 9
import traceback as tb
10
 
106 t00mlabs 11
from gi.repository import Gio
80 t00mlabs 12
 
4 t00mlabs 13
from .log import get_logger
113 t00mlabs 14
from .sapnoteviewmenu import SAPNoteViewMenu
15
from .sapnoteviewvisor import SAPNoteViewVisor
101 t00mlabs 16
from .service import Service
17
 
4 t00mlabs 18
 
105 t00mlabs 19
class Workplace(Service):
101 t00mlabs 20
    def initialize(self):
21
        '''
105 t00mlabs 22
        Setup Workplace Service
101 t00mlabs 23
        '''
24
        self.get_services()
106 t00mlabs 25
        self.setup_widgets()
101 t00mlabs 26
 
106 t00mlabs 27
 
28
    def setup_widgets(self):
109 t00mlabs 29
        # Toolbar
30
        tgbshowmenu = self.gui.get_widget('tgbShowMenuView')
31
        tgbshowmenu.connect('toggled', self.show_menu_view)
106 t00mlabs 32
        # Menu Views
33
        self.setup_menu_views()
34
 
35
        # Views
36
        viewsbox = self.gui.get_widget('viewsbox')
101 t00mlabs 37
        viewmenu = self.gui.add_widget('viewmenu', SAPNoteViewMenu(self.app))
113 t00mlabs 38
        viewmenu.set_view('components')
106 t00mlabs 39
        self.gui.swap_widget(viewsbox, viewmenu)
40
 
41
        # SAP Notes Visor
42
        visorbox = self.gui.get_widget('notesbox')
101 t00mlabs 43
        visor = self.gui.add_widget('visor', SAPNoteViewVisor(self.app))
44
        self.gui.swap_widget(visorbox, visor)
45
 
46
 
47
    def get_services(self):
48
        self.gui = self.app.get_service("GUI")
106 t00mlabs 49
        self.uif = self.app.get_service("UIF")
4 t00mlabs 50
        self.cb = self.app.get_service('Callbacks')
51
 
52
 
109 t00mlabs 53
    def show_menu_view(self, *args):
54
        paned = self.gui.get_widget('boxMenuView')
55
        button = self.gui.get_widget('tgbShowMenuView')
56
        if button.get_active():
57
            paned.show_all()
58
        else:
59
            paned.hide()
60
 
106 t00mlabs 61
    def setup_menu_views(self):
62
        app = self.gui.get_app()
101 t00mlabs 63
 
106 t00mlabs 64
        # View label
65
        self.gui.add_widget('lblViewCurrent')
101 t00mlabs 66
 
106 t00mlabs 67
        ## Views Menu
68
        views_menu = self.gui.add_widget('mnuviews', Gio.Menu())
4 t00mlabs 69
 
106 t00mlabs 70
        # Last added view
71
        #~ TODO
72
        #~ views_menu.append_item(self.uif.create_item('View last added', 'app.view-lastadded', ''))
73
        #~ self.app.add_action(self.uif.create_action("view-lastadded", self.cb_show_dlnotes_window))
101 t00mlabs 74
 
106 t00mlabs 75
        # Most used view
76
        #~ TODO
77
        #~ views_menu.append_item(self.uif.create_item('View most used', 'app.view-mostused', ''))
78
        #~ self.app.add_action(self.uif.create_action("view-mostused", self.cb_show_dlnotes_window))
4 t00mlabs 79
 
106 t00mlabs 80
        # Tasks view
81
        views_menu.append_item(self.uif.create_item('View by tasks', 'app.view-tasks', 'emblem-system'))
82
        app.add_action(self.uif.create_action("view-tasks", self.cb.refresh_view, 'tasks'))
74 t00mlabs 83
 
106 t00mlabs 84
        # Projects view
85
        #~ views_menu.append_item(self.uif.create_item('View by projects', 'app.view-projects', ''))
86
        #~ self.app.add_action(self.uif.create_action("view-projects", self.cb.refresh_view, 'projects'))
74 t00mlabs 87
 
106 t00mlabs 88
        # Components view
89
        views_menu.append_item(self.uif.create_item('View by components', 'app.view-components', ''))
90
        app.add_action(self.uif.create_action("view-components", self.cb.refresh_view, 'components'))
4 t00mlabs 91
 
106 t00mlabs 92
        # Component descriptions view
93
        views_menu.append_item(self.uif.create_item('View by description', 'app.view-component-descriptions', ''))
94
        app.add_action(self.uif.create_action("view-component-descriptions", self.cb.refresh_view, 'description'))
4 t00mlabs 95
 
106 t00mlabs 96
        # Bookmarks view
113 t00mlabs 97
        #~ views_menu.append_item(self.uif.create_item('View bookmarks', 'app.view-bookmarks', ''))
98
        #~ app.add_action(self.uif.create_action("view-bookmarks", self.cb.refresh_view, 'bookmarks'))
4 t00mlabs 99
 
106 t00mlabs 100
        # Category view
101
        views_menu.append_item(self.uif.create_item('View categories', 'app.view-categories', ''))
102
        app.add_action(self.uif.create_action("view-categories", self.cb.refresh_view, 'category'))
4 t00mlabs 103
 
106 t00mlabs 104
        # Chronologic order view
105
        views_menu.append_item(self.uif.create_item('View chronologically', 'app.chronologic-order', ''))
106
        app.add_action(self.uif.create_action("chronologic-order", self.cb.refresh_view, 'chronologic'))
4 t00mlabs 107
 
106 t00mlabs 108
        # Priority view
109
        views_menu.append_item(self.uif.create_item('View by priority', 'app.view-priority', ''))
110
        app.add_action(self.uif.create_action("view-priority", self.cb.refresh_view, 'priority'))
4 t00mlabs 111
 
106 t00mlabs 112
        # SAP Note Type view
113
        views_menu.append_item(self.uif.create_item('View by type', 'app.view-type', ''))
114
        app.add_action(self.uif.create_action("view-type", self.cb.refresh_view, 'type'))
4 t00mlabs 115
 
106 t00mlabs 116
        # Annotations view
117
        #~ TODO
118
        #~ views_menu.append_item(self.uif.create_item('View by annotations', 'app.view-annotations', ''))
119
        #~ self.app.add_action(self.uif.create_action("view-annotations", self.cb_show_dlnotes_window))
4 t00mlabs 120
 
106 t00mlabs 121
        # Set menu model in button
122
        btnviews = self.gui.get_widget('mnuBtnViews')
123
        btnviews.set_menu_model(views_menu)
124
        btnviews.clicked()