From 5b1a07e36c4018a0a39fc5cc8b355ca8f719e0fc Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 3 May 2012 21:47:10 +0200 Subject: [PATCH] Introduced some new text annotation functions --- annotations.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++- annotations.h | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 1 deletion(-) diff --git a/annotations.c b/annotations.c index c394fad..371d00c 100644 --- a/annotations.c +++ b/annotations.c @@ -20,7 +20,13 @@ struct zathura_annotation_s { char* label; /**< Label */ char* subject; /**< Subject of the annotation */ zathura_annotation_popup_t* popup; /**< Optional popup */ + time_t creation_date; /**< Creation date */ } markup; + struct { + zathura_annotation_text_icon_t icon; /**< The icon of the text annotation */ + zathura_annotation_text_state_t state; /**< The state of the text annotation */ + bool opened; /**< Open status of the text annotation */ + } text; } data; }; @@ -42,13 +48,18 @@ zathura_annotation_new(zathura_annotation_type_t type) switch (type) { case ZATHURA_ANNOTATION_MARKUP: + annotation->data.markup.creation_date = (time_t) -1; break; + case ZATHURA_ANNOTATION_TEXT: + annotation->data.text.icon = ZATHURA_ANNOTATION_TEXT_ICON_UNKNOWN; + annotation->data.text.state = ZATHURA_ANNOTATION_TEXT_STATE_UNKNOWN; default: free(annotation); return NULL; } - annotation->type = type; + annotation->type = type; + annotation->modification_date = (time_t) -1; return annotation; } @@ -331,6 +342,86 @@ zathura_annotation_markup_set_popup(zathura_annotation_t* annotation, zathura_an annotation->data.markup.popup = popup; } +time_t +zathura_annotation_markup_get_creation_date(zathura_annotation_t* annotation) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_MARKUP) { + return (time_t) -1; + } + + return annotation->data.markup.creation_date; +} + +void +zathura_annotation_markup_set_creation_date(zathura_annotation_t* annotation, time_t creation_date) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_MARKUP) { + return; + } + + annotation->data.markup.creation_date = creation_date; +} + +zathura_annotation_text_icon_t +zathura_annotation_text_get_icon(zathura_annotation_t* annotation) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return ZATHURA_ANNOTATION_TEXT_ICON_UNKNOWN; + } + + return annotation->data.text.icon; +} + +void +zathura_annotation_text_set_icon(zathura_annotation_t* annotation, zathura_annotation_text_icon_t icon) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return; + } + + annotation->data.text.icon = icon; +} + +zathura_annotation_text_state_t +zathura_annotation_text_get_state(zathura_annotation_t* annotation) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return ZATHURA_ANNOTATION_TEXT_STATE_UNKNOWN; + } + + return annotation->data.text.state; +} + +void +zathura_annotation_text_set_state(zathura_annotation_t* annotation, zathura_annotation_text_state_t state) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return; + } + + annotation->data.text.state = state; +} + +bool +zathura_annotation_text_get_open_status(zathura_annotation_t* annotation) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return false; + } + + return annotation->data.text.opened; +} + +void +zathura_annotation_text_set_open_status(zathura_annotation_t* annotation, bool opened) +{ + if (annotation == NULL || annotation->type != ZATHURA_ANNOTATION_TEXT) { + return; + } + + annotation->data.text.opened = opened; +} + zathura_annotation_popup_t* zathura_annotation_popup_new() { diff --git a/annotations.h b/annotations.h index e99d89f..7e273eb 100644 --- a/annotations.h +++ b/annotations.h @@ -56,6 +56,30 @@ typedef enum zathura_annotation_flag_s { ZATHURA_ANNOTATION_FLAG_LOCKED_CONTENTS = 1 << 9, } zathura_annotation_flag_t; +typedef enum zathura_annotation_text_icon_s { + ZATHURA_ANNOTATION_TEXT_ICON_UNKNOWN, + ZATHURA_ANNOTATION_TEXT_ICON_NOTE, + ZATHURA_ANNOTATION_TEXT_ICON_COMMENT, + ZATHURA_ANNOTATION_TEXT_ICON_KEY, + ZATHURA_ANNOTATION_TEXT_ICON_HELP, + ZATHURA_ANNOTATION_TEXT_ICON_NEW_PARAGRAPH, + ZATHURA_ANNOTATION_TEXT_ICON_PARAGRAPH, + ZATHURA_ANNOTATION_TEXT_ICON_INSERT, + ZATHURA_ANNOTATION_TEXT_ICON_CROSS, + ZATHURA_ANNOTATION_TEXT_ICON_CIRCLE +} zathura_annotation_text_icon_t; + +typedef enum zathura_annotation_text_state_s { + ZATHURA_ANNOTATION_TEXT_STATE_UNKNOWN, + ZATHURA_ANNOTATION_TEXT_STATE_NONE, + ZATHURA_ANNOTATION_TEXT_STATE_MARKED, + ZATHURA_ANNOTATION_TEXT_STATE_UNMARKED, + ZATHURA_ANNOTATION_TEXT_STATE_ACCEPTED, + ZATHURA_ANNOTATION_TEXT_STATE_REJECTED, + ZATHURA_ANNOTATION_TEXT_STATE_CANCELLED, + ZATHURA_ANNOTATION_TEXT_STATE_COMPLETED +} zathura_annotation_text_state_t; + /** * Creates a new annotation * @@ -240,6 +264,70 @@ zathura_annotation_popup_t* zathura_annotation_markup_get_popup(zathura_annotati */ void zathura_annotation_markup_set_popup(zathura_annotation_t* annotation, zathura_annotation_popup_t* popup); +/** + * Returns the creation date of the annotation + * + * @param annotation The annotation + * @retun The creation date + */ +time_t zathura_annotation_markup_get_creation_date(zathura_annotation_t* annotation); + +/** + * Sets the creation date of the annotation + * + * @param annotation The annotation + * @param creation_date The creation date + */ +void zathura_annotation_markup_set_creation_date(zathura_annotation_t* annotation, time_t creation_date); + +/** + * Returns the defined icon of the text annotation + * + * @param annotation The annotation + * @return The set icon of the text annotation + */ +zathura_annotation_text_icon_t zathura_annotation_text_get_icon(zathura_annotation_t* annotation); + +/** + * Sets the icon of the text annotation + * + * @param annotation The annotation + * @param icon The icon of the text annotation + */ +void zathura_annotation_text_set_icon(zathura_annotation_t* annotation, zathura_annotation_text_icon_t icon); + +/** + * Returns the state of the text annotation + * + * @param annotation The annotation + * @return The state of the text annotation + */ +zathura_annotation_text_state_t zathura_annotation_text_get_state(zathura_annotation_t* annotation); + +/** + * Sets the state of the text annotation + * + * @param annotation The annotation + * @param state The new state of the text annotation + */ +void zathura_annotation_text_set_state(zathura_annotation_t* annotation, zathura_annotation_text_state_t state); + +/** + * Returns whether the text annotation is open or not + * + * @param annotation The annotation + * @return true if the annotation is open otherwise false + */ +bool zathura_annotation_text_get_open_status(zathura_annotation_t* annotation); + +/** + * Sets the text annotation open status + * + * @param annotation The annotation + * @param opened The new open status + */ +void zathura_annotation_text_set_open_status(zathura_annotation_t* annotation, bool opened); + /** * Creates a new annotation popup *