zathura/document.h

147 lines
3.9 KiB
C
Raw Normal View History

2010-11-17 22:51:15 +01:00
/* See LICENSE file for license and copyright information */
#ifndef DOCUMENT_H
#define DOCUMENT_H
#include <gtk/gtk.h>
2010-11-17 22:51:15 +01:00
#include <stdbool.h>
#include <girara-datastructures.h>
2011-03-05 21:00:41 +01:00
#define PLUGIN_DIR "/usr/lib/zathura"
#define PLUGIN_REGISTER_FUNCTION "plugin_register"
2010-11-17 22:51:15 +01:00
typedef struct zathura_list_s zathura_list_t;
typedef struct zathura_document_s zathura_document_t;
2010-11-18 02:35:33 +01:00
typedef bool (*zathura_document_open_t)(zathura_document_t* document);
typedef struct zathura_document_plugin_s
{
char* file_extension;
2010-11-18 02:35:33 +01:00
zathura_document_open_t open_function;
void* handle;
struct zathura_document_plugin_s *next;
2010-11-18 02:35:33 +01:00
} zathura_document_plugin_t;
typedef void (*zathura_plugin_register_service_t)(zathura_document_plugin_t*);
2011-03-05 21:00:41 +01:00
2010-11-17 22:51:15 +01:00
struct zathura_list_s
{
void* data;
struct zathura_list_s* next;
};
typedef struct zathura_rectangle_s
{
double x1;
double y1;
double x2;
double y2;
} zathura_rectangle_t;
typedef enum zathura_link_type_e
{
ZATHURA_LINK_TO_PAGE,
ZATHURA_LINK_EXTERNAL,
} zathura_link_type_t;
typedef struct zathura_link_s
{
zathura_rectangle_t position;
zathura_link_type_t type;
union
{
unsigned int page_number;
char* value;
} target;
} zathura_link_t;
2010-12-25 00:47:52 +01:00
typedef struct zathura_index_element_s
{
char* title;
zathura_link_type_t type;
union
{
unsigned int page_number;
char* uri;
} target;
} zathura_index_element_t;
2010-11-17 22:51:15 +01:00
typedef enum zathura_form_type_e
{
ZATHURA_FORM_CHECKBOX,
ZATHURA_FORM_TEXTFIELD
} zathura_form_type_t;
typedef struct zathura_form_s
{
zathura_rectangle_t position;
zathura_form_type_t type;
} zathura_form_t;
typedef struct zathura_page_s
{
2010-11-18 14:51:13 +01:00
double height;
double width;
2010-12-29 11:46:13 +01:00
double offset;
unsigned int number;
2010-11-17 22:51:15 +01:00
zathura_document_t* document;
void* data;
2011-01-06 08:59:10 +01:00
bool rendered;
GStaticMutex lock;
2010-11-17 22:51:15 +01:00
} zathura_page_t;
struct zathura_document_s
{
2010-11-18 13:54:35 +01:00
char* file_path;
2010-11-18 02:35:33 +01:00
const char* password;
2010-11-17 22:51:15 +01:00
unsigned int current_page_number;
unsigned int number_of_pages;
2010-12-26 20:35:26 +01:00
double scale;
2010-11-17 22:51:15 +01:00
int rotate;
2010-11-18 03:15:32 +01:00
void* data;
2010-11-17 22:51:15 +01:00
struct
{
2010-11-18 02:35:33 +01:00
bool (*document_free)(zathura_document_t* document);
girara_tree_node_t* (*document_index_generate)(zathura_document_t* document);
2010-11-18 02:35:33 +01:00
bool (*document_save_as)(zathura_document_t* document, const char* path);
zathura_list_t* (*document_attachments_get)(zathura_document_t* document);
zathura_page_t* (*page_get)(zathura_document_t* document, unsigned int page_id);
2010-11-17 22:51:15 +01:00
zathura_list_t* (*page_search_text)(zathura_page_t* page, const char* text);
zathura_list_t* (*page_links_get)(zathura_page_t* page);
zathura_list_t* (*page_form_fields_get)(zathura_page_t* page);
GtkWidget* (*page_render)(zathura_page_t* page);
2010-11-18 02:35:33 +01:00
bool (*page_free)(zathura_page_t* page);
2010-11-17 22:51:15 +01:00
} functions;
2010-12-28 00:47:41 +01:00
zathura_page_t** pages;
2010-11-17 22:51:15 +01:00
};
2011-03-05 21:00:41 +01:00
void zathura_document_plugins_load(void);
void zathura_document_plugins_free(void);
bool zathura_document_plugin_register(zathura_document_plugin_t* new_plugin, void* handle);
2010-11-18 02:35:33 +01:00
zathura_document_t* zathura_document_open(const char* path, const char* password);
2010-11-17 23:15:08 +01:00
bool zathura_document_free(zathura_document_t* document);
bool zathura_document_save_as(zathura_document_t* document, const char* path);
girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document);
2010-11-17 23:15:08 +01:00
zathura_list_t* zathura_document_attachments_get(zathura_document_t* document);
bool zathura_document_attachments_free(zathura_list_t* list);
zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page_id);
2010-11-18 02:35:33 +01:00
bool zathura_page_free(zathura_page_t* page);
2010-11-17 22:51:15 +01:00
zathura_list_t* zathura_page_search_text(zathura_page_t* page, const char* text);
zathura_list_t* zathura_page_links_get(zathura_page_t* page);
bool zathura_page_links_free(zathura_list_t* list);
zathura_list_t* zathura_page_form_fields_get(zathura_page_t* page);
bool zathura_page_form_fields_free(zathura_list_t* list);
GtkWidget* zathura_page_render(zathura_page_t* page);
2010-11-17 22:51:15 +01:00
2010-12-25 00:47:52 +01:00
zathura_index_element_t* zathura_index_element_new(const char* title);
void zathura_index_element_free(zathura_index_element_t* index);
2010-11-17 22:51:15 +01:00
#endif // DOCUMENT_H