zathura
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Functions
document.c File Reference
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <glib.h>
#include <girara/datastructures.h>
#include <girara/utils.h>
#include "adjustment.h"
#include "document.h"
#include "utils.h"
#include "zathura.h"
#include "page.h"
#include "plugin.h"
#include "content-type.h"

Go to the source code of this file.

Data Structures

struct  zathura_document_t

Macros

#define _BSD_SOURCE
#define _XOPEN_SOURCE   700

Functions

zathura_document_t * zathura_document_open (zathura_plugin_manager_t *plugin_manager, const char *path, const char *password, zathura_error_t *error)
zathura_error_t zathura_document_free (zathura_document_t *document)
const char * zathura_document_get_path (zathura_document_t *document)
const char * zathura_document_get_basename (zathura_document_t *document)
const char * zathura_document_get_password (zathura_document_t *document)
zathura_page_t * zathura_document_get_page (zathura_document_t *document, unsigned int index)
void * zathura_document_get_data (zathura_document_t *document)
void zathura_document_set_data (zathura_document_t *document, void *data)
unsigned int zathura_document_get_number_of_pages (zathura_document_t *document)
void zathura_document_set_number_of_pages (zathura_document_t *document, unsigned int number_of_pages)
unsigned int zathura_document_get_current_page_number (zathura_document_t *document)
void zathura_document_set_current_page_number (zathura_document_t *document, unsigned int current_page)
double zathura_document_get_position_x (zathura_document_t *document)
double zathura_document_get_position_y (zathura_document_t *document)
void zathura_document_set_position_x (zathura_document_t *document, double position_x)
void zathura_document_set_position_y (zathura_document_t *document, double position_y)
double zathura_document_get_scale (zathura_document_t *document)
void zathura_document_set_scale (zathura_document_t *document, double scale)
unsigned int zathura_document_get_rotation (zathura_document_t *document)
void zathura_document_set_rotation (zathura_document_t *document, unsigned int rotation)
zathura_adjust_mode_t zathura_document_get_adjust_mode (zathura_document_t *document)
void zathura_document_set_adjust_mode (zathura_document_t *document, zathura_adjust_mode_t mode)
int zathura_document_get_page_offset (zathura_document_t *document)
void zathura_document_set_page_offset (zathura_document_t *document, unsigned int page_offset)
void zathura_document_set_viewport_width (zathura_document_t *document, unsigned int width)
void zathura_document_set_viewport_height (zathura_document_t *document, unsigned int height)
void zathura_document_get_viewport_size (zathura_document_t *document, unsigned int *height, unsigned int *width)
void zathura_document_get_cell_size (zathura_document_t *document, unsigned int *height, unsigned int *width)
void zathura_document_get_document_size (zathura_document_t *document, unsigned int *height, unsigned int *width)
void zathura_document_set_page_layout (zathura_document_t *document, unsigned int page_padding, unsigned int pages_per_row, unsigned int first_page_column)
unsigned int zathura_document_get_page_padding (zathura_document_t *document)
unsigned int zathura_document_get_pages_per_row (zathura_document_t *document)
unsigned int zathura_document_get_first_page_column (zathura_document_t *document)
zathura_error_t zathura_document_save_as (zathura_document_t *document, const char *path)
girara_tree_node_t * zathura_document_index_generate (zathura_document_t *document, zathura_error_t *error)
girara_list_t * zathura_document_attachments_get (zathura_document_t *document, zathura_error_t *error)
zathura_error_t zathura_document_attachment_save (zathura_document_t *document, const char *attachment, const char *file)
girara_list_t * zathura_document_get_information (zathura_document_t *document, zathura_error_t *error)
zathura_plugin_t * zathura_document_get_plugin (zathura_document_t *document)

Macro Definition Documentation

#define _BSD_SOURCE

Definition at line 3 of file document.c.

#define _XOPEN_SOURCE   700

Definition at line 4 of file document.c.

Function Documentation

zathura_error_t zathura_document_attachment_save ( zathura_document_t *  document,
const char *  attachment,
const char *  file 
)

Save document attachment

Parameters
documentThe document objects
attachmentname of the attachment
filethe target filename
Returns
ZATHURA_ERROR_OK when no error occured, otherwise see zathura_error_t

Definition at line 618 of file document.c.

girara_list_t* zathura_document_attachments_get ( zathura_document_t *  document,
zathura_error_t error 
)

Get list of attachments

Parameters
documentThe document object
errorSet to an error value (see zathura_error_t) if an error occured
Returns
List of attachments

Definition at line 597 of file document.c.

zathura_error_t zathura_document_free ( zathura_document_t *  document)

Free the document

Parameters
document
Returns
ZATHURA_ERROR_OK when no error occured, otherwise see zathura_error_t

Definition at line 194 of file document.c.

zathura_adjust_mode_t zathura_document_get_adjust_mode ( zathura_document_t *  document)

Returns the adjust mode of the document

Parameters
documentThe document
Returns
The adjust mode

Definition at line 419 of file document.c.

const char* zathura_document_get_basename ( zathura_document_t *  document)

Returns the basename of the document

Parameters
documentThe document
Returns
The basename of the document

Definition at line 238 of file document.c.

void zathura_document_get_cell_size ( zathura_document_t *  document,
unsigned int *  height,
unsigned int *  width 
)

Return the size of a cell from the document's layout table in pixels. Assumes that the table is homogeneous (i.e. every cell has the same dimensions). It takes the current scale into account.

Parameters
[in]documentThe document instance
[out]height,widthThe computed height and width of the cell

Definition at line 486 of file document.c.

unsigned int zathura_document_get_current_page_number ( zathura_document_t *  document)

Returns the current page number

Parameters
documentThe document
Returns
Current page

Definition at line 308 of file document.c.

void* zathura_document_get_data ( zathura_document_t *  document)

Returns the private data of the document

Parameters
documentThe document
Returns
The private data or NULL

Definition at line 268 of file document.c.

void zathura_document_get_document_size ( zathura_document_t *  document,
unsigned int *  height,
unsigned int *  width 
)

Compute the size of the entire document to be displayed in pixels. Takes into account the scale, the layout of the pages, and the padding between them. It should be equal to the allocation of zathura->ui.page_widget once it's shown.

Parameters
[in]documentThe document
[out]height,widthThe height and width of the document

Definition at line 496 of file document.c.

unsigned int zathura_document_get_first_page_column ( zathura_document_t *  document)

Returns the column for the first page (first column = 1)

Parameters
documentThe document
Returns
The column for the first page

Definition at line 552 of file document.c.

girara_list_t* zathura_document_get_information ( zathura_document_t *  document,
zathura_error_t error 
)

Returns a string of the requested information

Parameters
documentThe zathura document
errorSet to an error value (see zathura_error_t) if an error occured
Returns
List of document information entries or NULL if information could not be retreived

Definition at line 633 of file document.c.

unsigned int zathura_document_get_number_of_pages ( zathura_document_t *  document)

Returns the number of pages

Parameters
documentThe document
Returns
Number of pages

Definition at line 288 of file document.c.

zathura_page_t* zathura_document_get_page ( zathura_document_t *  document,
unsigned int  index 
)

Returns the page at the given index

Parameters
documentThe document
indexThe index of the page
Returns
The page or NULL if an error occured

Definition at line 258 of file document.c.

int zathura_document_get_page_offset ( zathura_document_t *  document)

Returns the page offset of the document

Parameters
documentThe document
Returns
The page offset

Definition at line 439 of file document.c.

unsigned int zathura_document_get_page_padding ( zathura_document_t *  document)

Returns the padding in pixels betwen pages

Parameters
documentThe document
Returns
The padding in pixels between pages

Definition at line 534 of file document.c.

unsigned int zathura_document_get_pages_per_row ( zathura_document_t *  document)

Returns the number of pages per row

Parameters
documentThe document
Returns
The number of pages per row

Definition at line 543 of file document.c.

const char* zathura_document_get_password ( zathura_document_t *  document)

Returns the password of the document

Parameters
documentThe document
Returns
Returns the password of the document

Definition at line 248 of file document.c.

const char* zathura_document_get_path ( zathura_document_t *  document)

Returns the path of the document

Parameters
documentThe document
Returns
The file path of the document

Definition at line 228 of file document.c.

zathura_plugin_t* zathura_document_get_plugin ( zathura_document_t *  document)

Returns the associated plugin

Parameters
documentThe document
Returns
The plugin or NULL

Definition at line 659 of file document.c.

double zathura_document_get_position_x ( zathura_document_t *  document)

Returns the X position, as a value relative to the document width (0=left, 1=right).

Parameters
documentThe document
Returns
X adjustment

Definition at line 329 of file document.c.

double zathura_document_get_position_y ( zathura_document_t *  document)

Returns the Y position as value relative to the document height (0=top, 1=bottom)

Parameters
documentThe document
Returns
Y adjustment

Definition at line 339 of file document.c.

unsigned int zathura_document_get_rotation ( zathura_document_t *  document)

Returns the rotation value of zathura (0..360)

Parameters
documentThe document
Returns
The current rotation value

Definition at line 389 of file document.c.

double zathura_document_get_scale ( zathura_document_t *  document)

Returns the current scale value of the document

Parameters
documentThe document
Returns
The current scale value

Definition at line 369 of file document.c.

void zathura_document_get_viewport_size ( zathura_document_t *  document,
unsigned int *  height,
unsigned int *  width 
)

Return the size of the viewport in pixels.

Parameters
[in]documentThe document instance
[out]height,widthThe width and height of the viewport

Definition at line 477 of file document.c.

girara_tree_node_t* zathura_document_index_generate ( zathura_document_t *  document,
zathura_error_t error 
)

Generate the document index

Parameters
documentThe document object
errorSet to an error value (see zathura_error_t) if an error occured
Returns
Generated index

Definition at line 576 of file document.c.

zathura_document_t* zathura_document_open ( zathura_plugin_manager_t *  plugin_manager,
const char *  path,
const char *  password,
zathura_error_t error 
)

Open the document

Parameters
plugin_managerThe plugin manager
pathPath to the document
passwordPassword of the document or NULL
errorOptional error parameter
Returns
The document object and NULL if an error occurs

Definition at line 59 of file document.c.

zathura_error_t zathura_document_save_as ( zathura_document_t *  document,
const char *  path 
)

Save the document

Parameters
documentThe document object
pathPath for the saved file
Returns
ZATHURA_ERROR_OK when no error occured, otherwise see zathura_error_t

Definition at line 561 of file document.c.

void zathura_document_set_adjust_mode ( zathura_document_t *  document,
zathura_adjust_mode_t  mode 
)

Sets the new adjust mode of the document

Parameters
documentThe document
modeThe new adjust mode

Definition at line 429 of file document.c.

void zathura_document_set_current_page_number ( zathura_document_t *  document,
unsigned int  current_page 
)

Sets the number of pages

Parameters
documentThe document
current_pageThe current page number

Definition at line 318 of file document.c.

void zathura_document_set_data ( zathura_document_t *  document,
void *  data 
)

Sets the private data of the document

Parameters
documentThe document
dataThe new private data

Definition at line 278 of file document.c.

void zathura_document_set_number_of_pages ( zathura_document_t *  document,
unsigned int  number_of_pages 
)

Sets the number of pages

Parameters
documentThe document
number_of_pagesNumber of pages

Definition at line 298 of file document.c.

void zathura_document_set_page_layout ( zathura_document_t *  document,
unsigned int  page_padding,
unsigned int  pages_per_row,
unsigned int  first_page_column 
)

Sets the layout of the pages in the document

Parameters
[in]documentThe document instance
[in]page_paddingpixels of padding between pages
[in]pages_per_rownumber of pages per row
[in]first_page_columncolumn of the first page (first column is 1)

Definition at line 516 of file document.c.

void zathura_document_set_page_offset ( zathura_document_t *  document,
unsigned int  page_offset 
)

Sets the new page offset of the document

Parameters
documentThe document
page_offsetThe new page offset

Definition at line 449 of file document.c.

void zathura_document_set_position_x ( zathura_document_t *  document,
double  position_x 
)

Sets the X position as a value relative to the document width (0=left, 1=right)

Parameters
documentThe document
position_xthe X adjustment

Definition at line 349 of file document.c.

void zathura_document_set_position_y ( zathura_document_t *  document,
double  position_y 
)

Sets the Y position as a value relative to the document height (0=top, 1=bottom)

Parameters
documentThe document
position_ythe Y adjustment

Definition at line 359 of file document.c.

void zathura_document_set_rotation ( zathura_document_t *  document,
unsigned int  rotation 
)

Sets the new rotation value

Parameters
documentThe document
rotationThe new rotation value

Definition at line 399 of file document.c.

void zathura_document_set_scale ( zathura_document_t *  document,
double  scale 
)

Sets the new scale value of the document

Parameters
documentThe document
scaleThe new scale value

Definition at line 379 of file document.c.

void zathura_document_set_viewport_height ( zathura_document_t *  document,
unsigned int  height 
)

Sets the height of the viewport in pixels.

Parameters
[in]documentThe document instance
[in]heightThe height of the viewport

Definition at line 468 of file document.c.

void zathura_document_set_viewport_width ( zathura_document_t *  document,
unsigned int  width 
)

Sets the width of the viewport in pixels.

Parameters
[in]documentThe document instance
[in]widthThe width of the viewport

Definition at line 459 of file document.c.