| 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 |
# Enthought library imports. |
| 11 |
from pyface.action.api import Action, Group |
| 12 |
|
| 13 |
|
| 14 |
class PreferencesAction(Action): |
| 15 |
"""An action that displays the preferences dialog.""" |
| 16 |
|
| 17 |
#### 'Action' interface ################################################### |
| 18 |
|
| 19 |
# A longer description of the action. |
| 20 |
description = "Open the preferences dialog" |
| 21 |
|
| 22 |
# The action's name (displayed on menus/tool bar tools etc). |
| 23 |
name = "Prefere&nces..." |
| 24 |
|
| 25 |
# A short description of the action used for tooltip text etc. |
| 26 |
tooltip = "Open the preferences dialog" |
| 27 |
|
| 28 |
########################################################################### |
| 29 |
# 'Action' interface. |
| 30 |
########################################################################### |
| 31 |
|
| 32 |
def perform(self, event): |
| 33 |
from envisage.ui.tasks.preferences_dialog import PreferencesDialog |
| 34 |
|
| 35 |
window = event.task.window |
| 36 |
dialog = window.application.get_service(PreferencesDialog) |
| 37 |
ui = dialog.edit_traits(parent=window.control, kind="livemodal") |
| 38 |
|
| 39 |
if ui.result: |
| 40 |
window.application.preferences.save() |
| 41 |
|
| 42 |
|
| 43 |
class PreferencesGroup(Group): |
| 44 |
"""A group that contains the preferences action.""" |
| 45 |
|
| 46 |
#### 'Action' interface ################################################### |
| 47 |
|
| 48 |
# The group's identifier (unique within action manager). |
| 49 |
id = "PreferencesGroup" |
| 50 |
|
| 51 |
########################################################################### |
| 52 |
# 'object' interface. |
| 53 |
########################################################################### |
| 54 |
|
| 55 |
def __init__(self, **traits): |
| 56 |
super().__init__(PreferencesAction(), **traits) |