[−][src]Trait zathura_plugin::ZathuraPlugin
Trait to be implemented by Zathura plugins.
Associated Types
type DocumentData
Plugin-specific data attached to Zathura documents.
If the plugin doesn't need to associate custom data with the document,
this can be set to ()
.
type PageData
Plugin-specific data attached to every document page.
If the plugin doesn't need to associate custom data with every page,
this can be set to ()
.
Required methods
fn document_open(doc: DocumentRef) -> Result<DocumentInfo<Self>, PluginError>
Open a document and read its metadata.
This function has to determine and return the number of pages in the document. Zathura will create that number of pages and call the plugin's page initialization and rendering methods.
fn page_init(
page: PageRef,
doc_data: &mut Self::DocumentData
) -> Result<PageInfo<Self>, PluginError>
page: PageRef,
doc_data: &mut Self::DocumentData
) -> Result<PageInfo<Self>, PluginError>
Initialize a document page and obtain its properties.
This is called once per page when the document is loaded initially.
The plugin has to return a PageInfo
structure containing page
properties that will be applied by the library.
fn page_render(
page: PageRef,
doc_data: &mut Self::DocumentData,
page_data: &mut Self::PageData,
cairo: &mut Context,
printing: bool
) -> Result<(), PluginError>
page: PageRef,
doc_data: &mut Self::DocumentData,
page_data: &mut Self::PageData,
cairo: &mut Context,
printing: bool
) -> Result<(), PluginError>
Render a document page to a Cairo context.
Parameters
page
: Mutable reference to the page to render.doc_data
: Plugin-specific data attached to the document.page_data
: Plugin-specific data attached to the page.cairo
: The Cairo context to render to.printing
: Whether the page is being rendered for printing (true
) or viewing (false
).
Provided methods
fn document_free(
doc: DocumentRef,
doc_data: &mut Self::DocumentData
) -> Result<(), PluginError>
doc: DocumentRef,
doc_data: &mut Self::DocumentData
) -> Result<(), PluginError>
Additional hook called before freeing the document resources.
It is not necessary for plugins to implement this. The library will take
care of freeing the DocumentData
attached to the document, and Zathura
itself will free the actual document.
fn page_free(
page: PageRef,
doc_data: &mut Self::DocumentData,
page_data: &mut Self::PageData
) -> Result<(), PluginError>
page: PageRef,
doc_data: &mut Self::DocumentData,
page_data: &mut Self::PageData
) -> Result<(), PluginError>
Additional hook called before freeing page resources.
This doesn't have to be implemented by a plugin. The library already
takes care of freeing the PageData
associated with the page, and
Zathura will free the page itself.