-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2666 from freakboy3742/document-api
Finalize API for Document-based apps
- Loading branch information
Showing
75 changed files
with
3,624 additions
and
1,379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
import sys | ||
|
||
from org.beeware.android import MainActivity | ||
|
||
from toga import Command as StandardCommand | ||
|
||
|
||
class Command: | ||
def __init__(self, interface): | ||
self.interface = interface | ||
self.native = [] | ||
|
||
@classmethod | ||
def standard(cls, app, id): | ||
# ---- Help menu ---------------------------------- | ||
if id == StandardCommand.ABOUT: | ||
return { | ||
"text": f"About {app.formal_name}", | ||
"section": sys.maxsize, | ||
} | ||
# ---- Undefined commands-------------------------- | ||
elif id in { | ||
StandardCommand.EXIT, | ||
StandardCommand.NEW, | ||
StandardCommand.OPEN, | ||
StandardCommand.PREFERENCES, | ||
StandardCommand.SAVE, | ||
StandardCommand.SAVE_AS, | ||
StandardCommand.SAVE_ALL, | ||
StandardCommand.VISIT_HOMEPAGE, | ||
}: | ||
# These are valid commands, but they're not defined on Android. | ||
return None | ||
|
||
raise ValueError(f"Unknown standard command {id!r}") | ||
|
||
def set_enabled(self, value): | ||
MainActivity.singletonThis.invalidateOptionsMenu() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The API for Documents and document types has been finalized. Document handling behavior is now controlled by declaring document types as part of your ``toga.App`` definition. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
The API for Documents and Document-based apps has been significantly modified. Unfortunately, these changes are not backwards compatible; any existing Document-based app will require modification. | ||
|
||
The ``DocumentApp`` base class is no longer required. Apps can subclass ``App`` directly, passing the document types as a ``list`` of ``Document`` classes, rather than a mapping of extension to document type. | ||
|
||
The API for ``Document`` subclasses has also changed: | ||
|
||
* A path is no longer provided as an argument to the Document constructor; | ||
|
||
* The ``document_type`` is now specified as a class property called ``description``; and | ||
|
||
* Extensions are now defined as a class property of the ``Document``; and | ||
|
||
* The ``can_close()`` handler is no longer honored. Documents now track if they are modified, and have a default ``on_close`` handler that uses the modification status of a document to control whether a document can close. Invoking ``touch()`` on document will mark a document as modified. This modification flag is cleared by saving the document. |
Oops, something went wrong.