Subversion Repositories basico

Rev

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