mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-29 01:04:56 +01:00
Introduced page_add_annotation / page_remove_annotation
This commit is contained in:
parent
d02d49c79b
commit
7f8f8969ef
5 changed files with 52 additions and 17 deletions
|
@ -6,12 +6,12 @@
|
|||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "page.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef struct zathura_annotation_s zathura_annotation_t;
|
||||
typedef struct zathura_annotation_popup_s zathura_annotation_popup_t;
|
||||
|
||||
#include "page.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef enum zathura_annotation_type_s {
|
||||
ZATHURA_ANNOTATION_UNKNOWN,
|
||||
ZATHURA_ANNOTATION_TEXT,
|
||||
|
|
|
@ -807,9 +807,8 @@ cb_menu_annotation_add(GtkMenuItem* item, ZathuraPage* page)
|
|||
}
|
||||
}
|
||||
|
||||
/* save to current list */
|
||||
girara_list_append(priv->annotations.list, annotation);
|
||||
zathura_page_set_annotations(priv->page, priv->annotations.list);
|
||||
/* add annotation */
|
||||
zathura_page_add_annotation(priv->page, annotation);
|
||||
|
||||
/* retrieve new list */
|
||||
girara_list_free(priv->annotations.list);
|
||||
|
|
23
page.c
23
page.c
|
@ -356,18 +356,33 @@ zathura_page_get_annotations(zathura_page_t* page, zathura_error_t* error)
|
|||
}
|
||||
|
||||
zathura_error_t
|
||||
zathura_page_set_annotations(zathura_page_t* page, girara_list_t* annotations)
|
||||
zathura_page_add_annotation(zathura_page_t* page, zathura_annotation_t* annotation)
|
||||
{
|
||||
if (page == NULL || page->document == NULL ) {
|
||||
if (page == NULL || page->document == NULL || annotation == NULL) {
|
||||
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
|
||||
if (plugin->functions.page_set_annotations == NULL) {
|
||||
if (plugin->functions.page_add_annotation == NULL) {
|
||||
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return plugin->functions.page_set_annotations(page, page->data, annotations);
|
||||
return plugin->functions.page_add_annotation(page, page->data, annotation);
|
||||
}
|
||||
|
||||
zathura_error_t
|
||||
zathura_page_remove_annotation(zathura_page_t* page, zathura_annotation_t* annotation)
|
||||
{
|
||||
if (page == NULL || page->document == NULL || annotation == NULL) {
|
||||
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
|
||||
if (plugin->functions.page_remove_annotation == NULL) {
|
||||
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return plugin->functions.page_remove_annotation(page, page->data, annotation);
|
||||
}
|
||||
|
||||
zathura_error_t
|
||||
|
|
17
page.h
17
page.h
|
@ -6,6 +6,7 @@
|
|||
#include <girara/datastructures.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include "annotations.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
|
@ -203,14 +204,24 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
|
|||
girara_list_t* zathura_page_get_annotations(zathura_page_t* page, zathura_error_t* error);
|
||||
|
||||
/**
|
||||
* Sets the list of annotations (see \ref zathura_annotation_t)
|
||||
* Adds an annotation (see \ref zathura_annotation_t) to the page
|
||||
*
|
||||
* @param page Page
|
||||
* @param annotations List of annotations
|
||||
* @param annotation The annotation that should be added
|
||||
* @return ZATHURA_ERROR_OK when no error occured, otherwise see
|
||||
* zathura_error_t
|
||||
*/
|
||||
zathura_error_t zathura_page_set_annotations(zathura_page_t* page, girara_list_t* annotations);
|
||||
zathura_error_t zathura_page_add_annotation(zathura_page_t* page, zathura_annotation_t* annotation);
|
||||
|
||||
/**
|
||||
* Removes an annotation (see \ref zathura_annotation_t) to the page
|
||||
*
|
||||
* @param page Page
|
||||
* @param annotation The annotation that should be removed
|
||||
* @return ZATHURA_ERROR_OK when no error occured, otherwise see
|
||||
* zathura_error_t
|
||||
*/
|
||||
zathura_error_t zathura_page_remove_annotation(zathura_page_t* page, zathura_annotation_t* annotation);
|
||||
|
||||
/**
|
||||
* Render page
|
||||
|
|
18
plugin-api.h
18
plugin-api.h
|
@ -147,9 +147,14 @@ typedef char* (*zathura_plugin_page_get_text_t)(zathura_page_t* page, void* data
|
|||
typedef girara_list_t* (*zathura_plugin_page_get_annotations_t)(zathura_page_t* page, void* data, zathura_error_t* error);
|
||||
|
||||
/**
|
||||
* Set list of annotations
|
||||
* Add annotation
|
||||
*/
|
||||
typedef zathura_error_t (*zathura_plugin_page_set_annotations_t)(zathura_page_t* page, void* data, girara_list_t* annotations);
|
||||
typedef zathura_error_t (*zathura_plugin_page_add_annotation_t)(zathura_page_t* page, void* data, zathura_annotation_t* annotation);
|
||||
|
||||
/**
|
||||
* Remove annotation
|
||||
*/
|
||||
typedef zathura_error_t (*zathura_plugin_page_remove_annotation_t)(zathura_page_t* page, void* data, zathura_annotation_t* annotation);
|
||||
|
||||
/**
|
||||
* Renders the page
|
||||
|
@ -245,9 +250,14 @@ struct zathura_plugin_functions_s
|
|||
zathura_plugin_page_get_annotations_t page_get_annotations;
|
||||
|
||||
/**
|
||||
* Set list of annotations
|
||||
* Add annotation
|
||||
*/
|
||||
zathura_plugin_page_set_annotations_t page_set_annotations;
|
||||
zathura_plugin_page_add_annotation_t page_add_annotation;
|
||||
|
||||
/**
|
||||
* Remove annotation
|
||||
*/
|
||||
zathura_plugin_page_remove_annotation_t page_remove_annotation;
|
||||
|
||||
/**
|
||||
* Renders the page
|
||||
|
|
Loading…
Reference in a new issue