| 1 |
# (C) Copyright 2007-2025 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
""" The action set interface. """ |
| 11 |
|
| 12 |
|
| 13 |
# Enthought library imports. |
| 14 |
from traits.api import Dict, Interface, List, Str |
| 15 |
|
| 16 |
# Local imports. |
| 17 |
from .action import Action |
| 18 |
from .group import Group |
| 19 |
from .menu import Menu |
| 20 |
from .tool_bar import ToolBar |
| 21 |
|
| 22 |
|
| 23 |
class IActionSet(Interface): |
| 24 |
"""The action set interface. |
| 25 |
|
| 26 |
An action set is a collection of menus, groups, and actions. |
| 27 |
|
| 28 |
""" |
| 29 |
|
| 30 |
# The action set's globally unique identifier. |
| 31 |
id = Str |
| 32 |
|
| 33 |
# The action set's name. |
| 34 |
# |
| 35 |
# fixme: This is not currently used, but in future it will be the name that |
| 36 |
# is shown to the user when they are customizing perspectives by adding or |
| 37 |
# removing action sets etc. |
| 38 |
name = Str |
| 39 |
|
| 40 |
# The actions in this set. |
| 41 |
actions = List(Action) |
| 42 |
|
| 43 |
# The groups in this set. |
| 44 |
groups = List(Group) |
| 45 |
|
| 46 |
# The menus in this set. |
| 47 |
menus = List(Menu) |
| 48 |
|
| 49 |
# The tool bars in this set. |
| 50 |
tool_bars = List(ToolBar) |
| 51 |
|
| 52 |
# A mapping from human-readable names to globally unique IDs. |
| 53 |
# |
| 54 |
# This mapping is used when interpreting the first item in a location path |
| 55 |
# (i.e., the **path** trait of a **Location** instance). |
| 56 |
# |
| 57 |
# When the path is intepreted, the first component (i.e., the first item |
| 58 |
# before any '/') is checked to see if it is in the mapping, and if so it |
| 59 |
# is replaced with the value in the map. |
| 60 |
# |
| 61 |
# This technique allows paths to start with human readable names, as |
| 62 |
# opposed to IDs (which are required in order to manage the namespace of |
| 63 |
# all action sets). |
| 64 |
# |
| 65 |
# For example, in the Envisage workbench, the menu bar ID is: |
| 66 |
# |
| 67 |
# ``'envisage.workbench.menubar'`` |
| 68 |
# |
| 69 |
# Without aliases, you must specify a location like this: |
| 70 |
# |
| 71 |
# ``Location(path='envisage.workbench.menubar/ASubMenu/AGroup')`` |
| 72 |
# |
| 73 |
# This is a bit long-winded! Instead, you can define an alias: |
| 74 |
# |
| 75 |
# ``aliases = { 'MenuBar' : 'envisage.workbench.menubar' }`` |
| 76 |
# |
| 77 |
# In that case, you can specify a location like this: |
| 78 |
# |
| 79 |
# ``Location(path='MenuBar/ASubMenu/AGroup')`` |
| 80 |
# |
| 81 |
aliases = Dict(Str, Str) |