Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for user-defined New, Save, Save As and Save All commands #2688

Closed
wants to merge 19 commits into from

Conversation

freakboy3742
Copy link
Member

Builds on #2666; that PR should be reviewed and merged before this one.

This is the last of the PRs derived from #2244. It adds the rest of the APIs needed by a real Document-based app: New, Save, Save As, and Save All.

There are app-level entry points for these commands that can be overridden to activate the corresponding menu items; or, they will all be installed if there is at least one document type registered.

The save commands all trigger file dialogs to pick filenames (and check for overwriting existing files) as required.

On GTK/Windows, the new document handling is used to generate an empty document when there are no command line arguments.

One area for future improvement - the save/save as menu items are always active, but only save the current window. Making the menu items enabled/disabled depends on having either gain/lost focus events for windows (#2009), and/or window-based menus (#2210). In the meantime, if the current window defines a save()/save_as() method, that method will be invoked; if the current window doesn't define those methods, the save request will be ignored.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

suggested_path = (
self.doc.path
if self.doc.path
else f"Untitled{self.doc.default_extension}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a dot before the extension? And there should be a test for this.

@freakboy3742
Copy link
Member Author

Following discussion with @mhsmith, this has been merged into #2666.

@freakboy3742 freakboy3742 deleted the document-api-extensions branch July 19, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants