mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Add hook: overview_will_render_bottom (#1946)
This commit is contained in:
parent
fe302a5d1b
commit
fbbd3e678c
3 changed files with 38 additions and 2 deletions
|
@ -75,7 +75,6 @@ Meredith Derecho <meredithderecho@gmail.com>
|
|||
Daniel Wallgren <github.com/wallgrenen>
|
||||
Kerrick Staley <kerrick@kerrickstaley.com>
|
||||
Maksim Abramchuk <maximabramchuck@gmail.com>
|
||||
Mateus Etto <mateus.etto@gmail.com>
|
||||
Benjamin Kulnik <benjamin.kulnik@student.tuwien.ac.at>
|
||||
Shaun Ren <shaun.ren@linux.com>
|
||||
Ryan Greenblatt <greenblattryan@gmail.com>
|
||||
|
@ -105,6 +104,7 @@ wisherhxl <wisherhxl@gmail.com>
|
|||
dobefore <1432338032@qq.com>
|
||||
Bart Louwers <bart.git@emeel.net>
|
||||
Sam Penny <github.com/sam1penny>
|
||||
Mateus Etto <mateus.etto@gmail.com>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
@ -286,6 +286,12 @@ class Overview:
|
|||
if self.mw.col.sched.have_buried():
|
||||
links.append(["U", "unbury", tr.studying_unbury()])
|
||||
links.append(["", "description", tr.scheduling_description()])
|
||||
link_handler = gui_hooks.overview_will_render_bottom(
|
||||
self._linkHandler,
|
||||
links,
|
||||
)
|
||||
if not callable(link_handler):
|
||||
link_handler = self._linkHandler
|
||||
buf = ""
|
||||
for b in links:
|
||||
if b[0]:
|
||||
|
@ -295,7 +301,9 @@ class Overview:
|
|||
b
|
||||
)
|
||||
self.bottom.draw(
|
||||
buf=buf, link_handler=self._linkHandler, web_context=OverviewBottomBar(self)
|
||||
buf=buf,
|
||||
link_handler=link_handler,
|
||||
web_context=OverviewBottomBar(self),
|
||||
)
|
||||
|
||||
# Studying more
|
||||
|
|
|
@ -65,6 +65,34 @@ hooks = [
|
|||
content.table += "\n<div>my html</div>"
|
||||
""",
|
||||
),
|
||||
Hook(
|
||||
name="overview_will_render_bottom",
|
||||
args=[
|
||||
"link_handler: Callable[[str], bool]",
|
||||
"links: list[list[str]]",
|
||||
],
|
||||
return_type="Callable[[str], bool]",
|
||||
doc="""Allows adding buttons to the Overview bottom bar.
|
||||
|
||||
Append a list of strings to 'links' argument to add new buttons.
|
||||
- The first value is the shortcut to appear in the tooltip.
|
||||
- The second value is the url to be triggered.
|
||||
- The third value is the text of the new button.
|
||||
|
||||
Extend the callable 'link_handler' to handle new urls. This callable
|
||||
accepts one argument: the triggered url.
|
||||
Make a check of the triggered url, call any functions related to
|
||||
that trigger, and return the new link_handler.
|
||||
|
||||
Example:
|
||||
links.append(['H', 'hello', 'Click me!'])
|
||||
def custom_link_handler(url):
|
||||
if url == 'hello':
|
||||
print('Hello World!')
|
||||
return link_handler(url=url)
|
||||
return custom_link_handler
|
||||
""",
|
||||
),
|
||||
Hook(
|
||||
name="reviewer_did_show_question",
|
||||
args=["card: Card"],
|
||||
|
|
Loading…
Reference in a new issue