[][src]Trait zathura_plugin::ZathuraPlugin

pub trait ZathuraPlugin {
type DocumentData;
type PageData;
    fn document_open(
        doc: DocumentRef
    ) -> Result<DocumentInfo<Self>, PluginError>;
fn page_init(
        page: PageRef,
        doc_data: &mut Self::DocumentData
    ) -> Result<PageInfo<Self>, PluginError>;
fn page_render(
        page: PageRef,
        doc_data: &mut Self::DocumentData,
        page_data: &mut Self::PageData,
        cairo: &mut Context,
        printing: bool
    ) -> Result<(), PluginError>; fn document_free(
        doc: DocumentRef,
        doc_data: &mut Self::DocumentData
    ) -> Result<(), PluginError> { ... }
fn page_free(
        page: PageRef,
        doc_data: &mut Self::DocumentData,
        page_data: &mut Self::PageData
    ) -> Result<(), PluginError> { ... } }

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 ().

Loading content...

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>

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>

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).
Loading content...

Provided methods

fn document_free(
    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>

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.

Loading content...

Implementors

Loading content...