File: sample_plugin.enaml

package info (click to toggle)
python-enaml 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,284 kB
  • sloc: python: 31,443; cpp: 4,499; makefile: 140; javascript: 68; lisp: 53; sh: 20
file content (116 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
#------------------------------------------------------------------------------
from enaml.workbench.api import Extension, PluginManifest
from enaml.workbench.ui.api import ActionItem, Branding, MenuItem, ItemGroup


def first_view_factory(workbench):
    from sample_workspace import SampleWorkspace

    import enaml
    with enaml.imports():
        from first_view import FirstView, FirstManifest

    space = SampleWorkspace()
    space.window_title = 'First View'
    space.content_def = FirstView
    space.manifest_def = FirstManifest
    return space


def second_view_factory(workbench):
    from sample_workspace import SampleWorkspace

    import enaml
    with enaml.imports():
        from second_view import SecondView, SecondManifest

    space = SampleWorkspace()
    space.window_title = 'Second View'
    space.content_def = SecondView
    space.manifest_def = SecondManifest
    return space


def persistent_view_factory(workbench):
    from persistent_workspace import PersistentWorkspace
    space = PersistentWorkspace()
    space.window_title = 'Persistent View'
    return space


enamldef SampleManifest(PluginManifest):
    """ The plugin manifest for the primary example plugin.

    This plugin acts as the entry point for all other plugins in this
    example. It contributes the window branding, default actions, and
    the workspace definitions.

    """
    id = 'sample'
    Extension:
        id = 'branding'
        point = 'enaml.workbench.ui.branding'
        Branding:
            title = 'Sample Plugin App'
    Extension:
        id = 'actions'
        point = 'enaml.workbench.ui.actions'
        MenuItem:
            path = '/file'
            label = 'File'
            ItemGroup:
                id = 'user'
        MenuItem:
            path = '/workspace'
            label = 'Workspace'
            ItemGroup:
                id = 'spaces'
        ActionItem:
            path = '/file/close'
            label = 'Close'
            shortcut = 'Ctrl+Q'
            command = 'enaml.workbench.ui.close_window'
        ActionItem:
            path = '/workspace/first'
            label = 'First'
            shortcut = 'Ctrl+1'
            group = 'spaces'
            command = 'enaml.workbench.ui.select_workspace'
            parameters = {'workspace': 'sample.first_view'}
        ActionItem:
            path = '/workspace/second'
            label = 'Second'
            shortcut = 'Ctrl+2'
            group = 'spaces'
            command = 'enaml.workbench.ui.select_workspace'
            parameters = {'workspace': 'sample.second_view'}
        ActionItem:
            path = '/workspace/persistent'
            label = 'Persistent'
            shortcut = 'Ctrl+3'
            group = 'spaces'
            command = 'enaml.workbench.ui.select_workspace'
            parameters = {'workspace': 'sample.persistent_view'}
        ActionItem:
            path = '/workspace/close'
            label = 'Close Workspace'
            shortcut = 'Ctrl+D'
            command = 'enaml.workbench.ui.close_workspace'
    Extension:
        id = 'first_view'
        point = 'enaml.workbench.ui.workspaces'
        factory = first_view_factory
    Extension:
        id = 'second_view'
        point = 'enaml.workbench.ui.workspaces'
        factory = second_view_factory
    Extension:
        id = 'persistent_view'
        point = 'enaml.workbench.ui.workspaces'
        factory = persistent_view_factory