types.h 7.15 KB
Newer Older
1
/* SPDX-License-Identifier: Zlib */
Moritz Lipp's avatar
Moritz Lipp committed
2 3 4 5

#ifndef TYPES_H
#define TYPES_H

Moritz Lipp's avatar
Moritz Lipp committed
6 7
#include <girara/datastructures.h>

8 9 10 11 12 13 14 15 16 17
#include "macros.h"

/**
 * Document
 */
typedef struct zathura_document_s zathura_document_t;
/**
 * Page
 */
typedef struct zathura_page_s zathura_page_t;
18 19 20 21 22
/**
 * Page widget
 */
typedef struct zathura_page_widget_s ZathuraPage;
typedef struct zathura_page_widget_class_s ZathuraPageClass;
23 24 25 26
/**
 * Zathura
 */
typedef struct zathura_s zathura_t;
Moritz Lipp's avatar
Moritz Lipp committed
27

28 29 30 31 32
/**
 * Plugin manager
 */
typedef struct zathura_plugin_manager_s zathura_plugin_manager_t;

33 34 35
/**
 * Renderer
 */
36
typedef struct zathura_renderer_s ZathuraRenderer;
37

Sebastian Ramacher's avatar
Sebastian Ramacher committed
38 39 40 41 42
/**
 * Render request
 */
typedef struct zathura_render_request_s ZathuraRenderRequest;

43
/**
Sebastian Ramacher's avatar
Sebastian Ramacher committed
44
 * D-Bus manager
45
 */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
46
typedef struct zathura_dbus_s ZathuraDbus;
47

48 49 50 51 52
/**
 * Error types
 */
typedef enum zathura_plugin_error_e
{
53 54
  ZATHURA_ERROR_OK, /**< No error occurred */
  ZATHURA_ERROR_UNKNOWN, /**< An unknown error occurred */
55 56 57 58 59 60
  ZATHURA_ERROR_OUT_OF_MEMORY, /**< Out of memory */
  ZATHURA_ERROR_NOT_IMPLEMENTED, /**< The called function has not been implemented */
  ZATHURA_ERROR_INVALID_ARGUMENTS, /**< Invalid arguments have been passed */
  ZATHURA_ERROR_INVALID_PASSWORD /**< The provided password is invalid */
} zathura_error_t;

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
/**
 * Possible information entry types
 */
typedef enum zathura_document_information_type_e
{
  ZATHURA_DOCUMENT_INFORMATION_TITLE, /**< Title of the document */
  ZATHURA_DOCUMENT_INFORMATION_AUTHOR, /**< Author of the document */
  ZATHURA_DOCUMENT_INFORMATION_SUBJECT, /**< Subject of the document */
  ZATHURA_DOCUMENT_INFORMATION_KEYWORDS, /**< Keywords of the document */
  ZATHURA_DOCUMENT_INFORMATION_CREATOR, /**< Creator of the document */
  ZATHURA_DOCUMENT_INFORMATION_PRODUCER, /**< Producer of the document */
  ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE, /**< Creation data */
  ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE, /**< Modification data */
  ZATHURA_DOCUMENT_INFORMATION_OTHER /**< Any other information */
} zathura_document_information_type_t;

Moritz Lipp's avatar
Moritz Lipp committed
77 78 79 80 81
/**
  * Plugin
  */
typedef struct zathura_plugin_s zathura_plugin_t;

82 83 84 85 86 87
/**
 * Document information entry
 *
 * Represents a single entry in the returned list from the \ref
 * zathura_document_get_information function
 */
88
typedef struct zathura_document_information_entry_s zathura_document_information_entry_t;
89

Moritz Lipp's avatar
Moritz Lipp committed
90 91 92 93 94 95 96 97 98 99 100
/**
 * Image buffer
 */
typedef struct zathura_image_buffer_s
{
  unsigned char* data; /**< Image buffer data */
  unsigned int height; /**< Height of the image */
  unsigned int width; /**< Width of the image */
  unsigned int rowstride; /**< Rowstride of the image */
} zathura_image_buffer_t;

101 102 103 104 105 106 107
/**
 * Adjust mode
 */
typedef enum zathura_adjust_mode_e
{
  ZATHURA_ADJUST_NONE, /**< No adjustment */
  ZATHURA_ADJUST_BESTFIT, /**< Adjust to best-fit */
108
  ZATHURA_ADJUST_WIDTH, /**< Adjust to width */
109 110
  ZATHURA_ADJUST_INPUTBAR, /**< Focusing the inputbar */
  ZATHURA_ADJUST_MODE_NUMBER /**< Number of adjust modes */
111 112
} zathura_adjust_mode_t;

Moritz Lipp's avatar
Moritz Lipp committed
113 114 115 116 117
/**
 * Creates an image buffer
 *
 * @param width Width of the image stored in the buffer
 * @param height Height of the image stored in the buffer
118
 * @return Image buffer or NULL if an error occurred
Moritz Lipp's avatar
Moritz Lipp committed
119
 */
120
ZATHURA_PLUGIN_API zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned int height);
Moritz Lipp's avatar
Moritz Lipp committed
121 122 123 124 125 126

/**
 * Frees the image buffer
 *
 * @param buffer The image buffer
 */
127
ZATHURA_PLUGIN_API void zathura_image_buffer_free(zathura_image_buffer_t* buffer);
Moritz Lipp's avatar
Moritz Lipp committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

/**
 * Rectangle structure.
 * The coordinate system has its origin in the left upper corner. The x axes
 * goes to the right, the y access goes down.
 */
typedef struct zathura_rectangle_s
{
  double x1; /**< X coordinate of point 1 */
  double y1; /**< Y coordinate of point 1 */
  double x2; /**< X coordinate of point 2 */
  double y2; /**< Y coordinate of point 2 */
} zathura_rectangle_t;

/**
 * Image structure
 */
typedef struct zathura_image_s
{
  zathura_rectangle_t position; /**< Coordinates of the image */
  void* data; /**< Custom data of the plugin */
} zathura_image_t;

/**
 * Possible link types
 */
typedef enum zathura_link_type_e
{
  ZATHURA_LINK_INVALID, /**< Invalid type */
157
  ZATHURA_LINK_NONE, /**< No action */
Moritz Lipp's avatar
Moritz Lipp committed
158 159 160 161
  ZATHURA_LINK_GOTO_DEST, /**< Links to a page */
  ZATHURA_LINK_GOTO_REMOTE, /**< Links to a page */
  ZATHURA_LINK_URI, /**< Links to an external source */
  ZATHURA_LINK_LAUNCH, /**< Links to an external source */
Moritz Lipp's avatar
Moritz Lipp committed
162
  ZATHURA_LINK_NAMED /**< Links to an external source */
Moritz Lipp's avatar
Moritz Lipp committed
163 164
} zathura_link_type_t;

165
typedef enum zathura_link_destination_type_e
Moritz Lipp's avatar
Moritz Lipp committed
166
{
167 168 169 170 171 172 173 174 175
  ZATHURA_LINK_DESTINATION_UNKNOWN,
  ZATHURA_LINK_DESTINATION_XYZ,
  ZATHURA_LINK_DESTINATION_FIT,
  ZATHURA_LINK_DESTINATION_FITH,
  ZATHURA_LINK_DESTINATION_FITV,
  ZATHURA_LINK_DESTINATION_FITR,
  ZATHURA_LINK_DESTINATION_FITB,
  ZATHURA_LINK_DESTINATION_FITBH,
  ZATHURA_LINK_DESTINATION_FITBV
176
} zathura_link_destination_type_t;
Moritz Lipp's avatar
Moritz Lipp committed
177 178 179

typedef struct zathura_link_target_s
{
180
  zathura_link_destination_type_t destination_type;
Moritz Lipp's avatar
Moritz Lipp committed
181
  char* value; /**< Value */
Moritz Lipp's avatar
Moritz Lipp committed
182 183 184 185 186
  unsigned int page_number; /**< Page number */
  double left; /**< Left coordinate */
  double right; /**< Right coordinate */
  double top; /**< Top coordinate */
  double bottom; /**< Bottom coordinate */
187
  double zoom; /**< Zoom */
Moritz Lipp's avatar
Moritz Lipp committed
188 189 190 191 192
} zathura_link_target_t;

/**
 * Link
 */
193
typedef struct zathura_link_s zathura_link_t;
Moritz Lipp's avatar
Moritz Lipp committed
194 195 196 197 198 199 200

/**
 * Index element
 */
typedef struct zathura_index_element_s
{
  char* title; /**< Title of the element */
Moritz Lipp's avatar
Moritz Lipp committed
201
  zathura_link_t* link;
Moritz Lipp's avatar
Moritz Lipp committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
} zathura_index_element_t;

/**
 * Form type
 */
typedef enum zathura_form_type_e
{
  ZATHURA_FORM_CHECKBOX, /**< Checkbox */
  ZATHURA_FORM_TEXTFIELD /**< Textfield */
} zathura_form_type_t;

/**
 * Form element
 */
typedef struct zathura_form_s
{
  zathura_rectangle_t position; /**< Position */
  zathura_form_type_t type; /**< Type */
} zathura_form_t;

222 223 224 225 226 227 228 229 230 231
/**
 * Jump
 */
typedef struct zathura_jump_s
{
  unsigned int page;
  double x;
  double y;
} zathura_jump_t;

Moritz Lipp's avatar
Moritz Lipp committed
232 233 234 235 236 237
/**
 * Create new index element
 *
 * @param title Title of the index element
 * @return Index element
 */
238
ZATHURA_PLUGIN_API zathura_index_element_t* zathura_index_element_new(const char* title);
Moritz Lipp's avatar
Moritz Lipp committed
239 240 241 242 243 244

/**
 * Free index element
 *
 * @param index The index element
 */
245
ZATHURA_PLUGIN_API void zathura_index_element_free(zathura_index_element_t* index);
Moritz Lipp's avatar
Moritz Lipp committed
246

247 248 249 250
/**
 * Creates a list that should be used to store \ref
 * zathura_document_information_entry_t entries
 *
251
 * @return A list or NULL if an error occurred
252
 */
253
ZATHURA_PLUGIN_API girara_list_t* zathura_document_information_entry_list_new(void);
254 255 256 257 258 259 260

/**
 * Creates a new document information entry
 *
 * @param type The type
 * @param value The value
 *
261
 * @return A new entry or NULL if an error occurred
262
 */
263
ZATHURA_PLUGIN_API zathura_document_information_entry_t*
264 265 266 267 268 269 270 271
zathura_document_information_entry_new(zathura_document_information_type_t
    type, const char* value);

/**
 * Frees a document information entry
 *
 * @param entry The entry that should be freed
 */
272
ZATHURA_PLUGIN_API void zathura_document_information_entry_free(zathura_document_information_entry_t* entry);
273

274 275 276 277 278
/**
 * Context for MIME type detection
 */
typedef struct zathura_content_type_context_s zathura_content_type_context_t;

279 280 281 282 283 284 285 286 287
/**
 * Device scaling structure.
 */
typedef struct zathura_device_factors_s
{
  double x;
  double y;
} zathura_device_factors_t;

Moritz Lipp's avatar
Moritz Lipp committed
288
#endif // TYPES_H