From 17c928627c158749d5fe75d585d83b49b3adaa2e Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Sun, 2 Jul 2017 14:35:14 -0300 Subject: [PATCH 1/3] Including actions to go to a deck overview by name and to got to the deck browser screen. --- AnkiConnect.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/AnkiConnect.py b/AnkiConnect.py index 024c0dc..9eb6595 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -507,6 +507,19 @@ class AnkiBridge: reviewer._answerCard(ease) return True + def guiDeckOverview(self, name): + collection = self.collection() + if collection is not None: + deck = collection.decks.byName(name) + if (deck is not None): + collection.decks.select(deck['id']) + self.window().onOverview() + return True + return False + + def guiDeckBrowser(self): + self.window().moveToState("deckBrowser") + return True # # AnkiConnect @@ -630,6 +643,12 @@ class AnkiConnect: def api_guiShowAnswer(self): return self.anki.guiShowAnswer() + + def api_guiDeckOverview(self, name): + return self.anki.guiDeckOverview(name) + + def api_guiDeckBrowser(self): + return self.anki.guiDeckBrowser() # From ffd64ffca0c0184c1be30529bb2348b011afe9ce Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Sun, 2 Jul 2017 14:50:30 -0300 Subject: [PATCH 2/3] Including documentation. --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 4138480..2fb661c 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,40 @@ Below is a list of currently supported actions. Requests with invalid actions or } ``` + *Sample response*: + ``` + true + ``` +* **guiDeckOverview** + + Opens the Deck Overview screen for the deck with the given name; returns `true` if succeeded or `False` otherwise. + + *Sample request*: + ``` + { + "action": "guiDeckOverview", + "params": { + "name": "Default" + } + } + ``` + + *Sample response*: + ``` + true + ``` + +* **guiDeckBrowser** + + Opens the Deck Browser screen; returns `true` if succeeded or `null` otherwise. + + *Sample request*: + ``` + { + "action": "guiDeckBrowser" + } + ``` + *Sample response*: ``` true From 013050cb9a0bbe7d2ecb62a1f7b7f9ba51eba52e Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Sun, 2 Jul 2017 17:38:08 -0300 Subject: [PATCH 3/3] Fixing some issues. Changing the guiDeckBrowser return to nothing. --- AnkiConnect.py | 3 +-- README.md | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index 9eb6595..e3ec3b8 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -511,7 +511,7 @@ class AnkiBridge: collection = self.collection() if collection is not None: deck = collection.decks.byName(name) - if (deck is not None): + if deck is not None: collection.decks.select(deck['id']) self.window().onOverview() return True @@ -519,7 +519,6 @@ class AnkiBridge: def guiDeckBrowser(self): self.window().moveToState("deckBrowser") - return True # # AnkiConnect diff --git a/README.md b/README.md index 2fb661c..a288292 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ Below is a list of currently supported actions. Requests with invalid actions or ``` * **guiDeckOverview** - Opens the Deck Overview screen for the deck with the given name; returns `true` if succeeded or `False` otherwise. + Opens the Deck Overview screen for the deck with the given name; returns `true` if succeeded or `false` otherwise. *Sample request*: ``` @@ -411,7 +411,7 @@ Below is a list of currently supported actions. Requests with invalid actions or * **guiDeckBrowser** - Opens the Deck Browser screen; returns `true` if succeeded or `null` otherwise. + Opens the Deck Browser screen. *Sample request*: ``` @@ -422,7 +422,7 @@ Below is a list of currently supported actions. Requests with invalid actions or *Sample response*: ``` - true + null ``` * **upgrade**