2010-11-10 19:18:01 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
|
|
|
|
|
|
|
#ifndef ZATHURA_H
|
|
|
|
#define ZATHURA_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2011-10-23 17:01:15 +02:00
|
|
|
#include <girara/types.h>
|
|
|
|
#include <gtk/gtk.h>
|
2013-11-25 18:57:59 +01:00
|
|
|
#include <gtk/gtkx.h>
|
2012-03-16 15:56:37 +01:00
|
|
|
#include "macros.h"
|
2012-04-03 18:39:00 +02:00
|
|
|
#include "types.h"
|
2011-09-21 00:46:03 +02:00
|
|
|
|
2010-11-13 10:05:28 +01:00
|
|
|
enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
|
|
|
|
DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,
|
|
|
|
PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD,
|
2012-04-21 04:59:58 +02:00
|
|
|
BACKWARD, CONTINUOUS, DELETE_LAST, EXPAND, EXPAND_ALL, COLLAPSE_ALL, COLLAPSE,
|
|
|
|
SELECT, GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP,
|
|
|
|
FULL_DOWN, HALF_LEFT, HALF_RIGHT, FULL_LEFT, FULL_RIGHT, NEXT_CHAR,
|
2013-12-17 15:34:40 +01:00
|
|
|
PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW,
|
|
|
|
PAGE_BOTTOM, PAGE_TOP };
|
2010-11-13 10:05:28 +01:00
|
|
|
|
2013-03-17 10:56:43 +01:00
|
|
|
/* unspecified page number */
|
|
|
|
enum {
|
|
|
|
ZATHURA_PAGE_NUMBER_UNSPECIFIED = INT_MIN
|
|
|
|
};
|
|
|
|
|
2013-10-18 20:00:04 +02:00
|
|
|
/* cache constants */
|
|
|
|
enum {
|
|
|
|
ZATHURA_PAGE_CACHE_DEFAULT_SIZE = 15,
|
|
|
|
ZATHURA_PAGE_CACHE_MAX_SIZE = 1024
|
|
|
|
};
|
|
|
|
|
2013-06-09 23:37:00 +02:00
|
|
|
/* forward declaration for types from database.h */
|
2012-03-04 15:56:54 +01:00
|
|
|
typedef struct _ZathuraDatabase zathura_database_t;
|
2011-09-02 20:46:16 +02:00
|
|
|
|
2012-09-02 00:44:18 +02:00
|
|
|
/**
|
|
|
|
* Jump
|
|
|
|
*/
|
|
|
|
typedef struct zathura_jump_s
|
|
|
|
{
|
|
|
|
unsigned int page;
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
} zathura_jump_t;
|
|
|
|
|
2012-04-03 18:39:00 +02:00
|
|
|
struct zathura_s
|
2010-11-10 19:18:01 +01:00
|
|
|
{
|
2010-12-12 22:04:42 +01:00
|
|
|
struct
|
2010-11-10 19:18:01 +01:00
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
girara_session_t* session; /**< girara interface session */
|
2010-11-18 21:22:43 +01:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
girara_statusbar_item_t* buffer; /**< buffer statusbar entry */
|
|
|
|
girara_statusbar_item_t* file; /**< file statusbar entry */
|
|
|
|
girara_statusbar_item_t* page_number; /**< page number statusbar entry */
|
2010-11-18 21:22:43 +01:00
|
|
|
} statusbar;
|
2010-12-26 01:52:17 +01:00
|
|
|
|
2011-04-30 13:27:27 +02:00
|
|
|
struct
|
|
|
|
{
|
2013-12-01 16:04:04 +01:00
|
|
|
GdkRGBA highlight_color; /**< Color for highlighting */
|
|
|
|
GdkRGBA highlight_color_active; /** Color for highlighting */
|
|
|
|
GdkRGBA render_loading_bg; /**< Background color for render "Loading..." */
|
|
|
|
GdkRGBA render_loading_fg; /**< Foreground color for render "Loading..." */
|
2011-04-30 13:27:27 +02:00
|
|
|
} colors;
|
|
|
|
|
2012-02-07 18:30:46 +01:00
|
|
|
GtkWidget *page_widget_alignment;
|
|
|
|
GtkWidget *page_widget; /**< Widget that contains all rendered pages */
|
2012-01-22 21:57:18 +01:00
|
|
|
GtkWidget *index; /**< Widget to show the index of the document */
|
2011-04-18 17:27:49 +02:00
|
|
|
} ui;
|
2010-12-12 22:04:42 +01:00
|
|
|
|
2011-01-24 12:43:39 +01:00
|
|
|
struct
|
|
|
|
{
|
2013-08-21 18:32:18 +02:00
|
|
|
ZathuraRenderer* render_thread; /**< The thread responsible for rendering the pages */
|
2011-04-18 17:27:49 +02:00
|
|
|
} sync;
|
2011-01-24 12:43:39 +01:00
|
|
|
|
2011-04-18 18:19:41 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-04-01 18:32:16 +02:00
|
|
|
void* manager; /**< Plugin manager */
|
2011-04-18 18:19:41 +02:00
|
|
|
} plugins;
|
|
|
|
|
2011-04-19 00:36:56 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
gchar* config_dir; /**< Path to the configuration directory */
|
|
|
|
gchar* data_dir; /**< Path to the data directory */
|
2011-04-19 00:36:56 +02:00
|
|
|
} config;
|
|
|
|
|
2012-07-13 15:39:16 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool enabled;
|
|
|
|
gchar* editor;
|
|
|
|
} synctex;
|
|
|
|
|
2011-04-29 00:28:19 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
GtkPrintSettings* settings; /**< Print settings */
|
|
|
|
GtkPageSetup* page_setup; /**< Saved page setup */
|
2011-04-29 00:28:19 +02:00
|
|
|
} print;
|
|
|
|
|
2011-04-19 19:24:03 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-12-18 04:09:09 +01:00
|
|
|
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
|
2012-04-21 04:59:58 +02:00
|
|
|
girara_list_t* marks; /**< Marker */
|
2012-04-22 11:11:36 +02:00
|
|
|
char** arguments; /**> Arguments that were passed at startup */
|
2011-04-19 19:24:03 +02:00
|
|
|
} global;
|
|
|
|
|
2011-09-21 09:22:12 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
girara_mode_t normal; /**< Normal mode */
|
|
|
|
girara_mode_t fullscreen; /**< Fullscreen mode */
|
|
|
|
girara_mode_t index; /**< Index mode */
|
|
|
|
girara_mode_t insert; /**< Insert mode */
|
2011-09-21 09:22:12 +02:00
|
|
|
} modes;
|
2011-05-07 22:00:52 +02:00
|
|
|
|
2011-09-01 15:43:34 +02:00
|
|
|
struct
|
|
|
|
{
|
2012-01-22 21:57:18 +01:00
|
|
|
gchar* file; /**< bookmarks file */
|
|
|
|
girara_list_t* bookmarks; /**< bookmarks */
|
2011-09-01 15:43:34 +02:00
|
|
|
} bookmarks;
|
|
|
|
|
2012-08-17 14:14:57 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
girara_list_t* list;
|
|
|
|
girara_list_iterator_t *cur;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int max_size;
|
|
|
|
} jumplist;
|
|
|
|
|
2013-10-22 21:24:26 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
guint refresh_view;
|
|
|
|
} signals;
|
|
|
|
|
2011-10-21 15:00:57 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
gchar* file;
|
|
|
|
} stdin_support;
|
|
|
|
|
2012-01-22 21:57:18 +01:00
|
|
|
zathura_document_t* document; /**< The current document */
|
2012-04-03 09:02:45 +02:00
|
|
|
GtkWidget** pages; /**< The page widgets */
|
2012-01-22 21:57:18 +01:00
|
|
|
zathura_database_t* database; /**< The database */
|
2012-02-20 20:07:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* File monitor
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
GFileMonitor* monitor; /**< File monitor */
|
|
|
|
GFile* file; /**< File for file monitor */
|
|
|
|
gchar* file_path; /**< Save file path */
|
|
|
|
gchar* password; /**< Save password */
|
|
|
|
} file_monitor;
|
2013-03-26 04:50:22 +01:00
|
|
|
|
2013-07-07 00:03:52 +02:00
|
|
|
/**
|
|
|
|
* Bisect stage
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
unsigned int last_jump; /**< Page jumped to by bisect */
|
|
|
|
unsigned int start; /**< Bisection range - start */
|
|
|
|
unsigned int end; /**< Bisection range - end */
|
|
|
|
} bisect;
|
2012-04-03 18:39:00 +02:00
|
|
|
};
|
2010-11-10 19:18:01 +01:00
|
|
|
|
2012-08-05 15:34:10 +02:00
|
|
|
/**
|
|
|
|
* Creates a zathura session
|
|
|
|
*
|
|
|
|
* @return zathura session object or NULL if zathura could not be creeated
|
|
|
|
*/
|
|
|
|
zathura_t* zathura_create(void);
|
|
|
|
|
2010-11-10 19:18:01 +01:00
|
|
|
/**
|
|
|
|
* Initializes zathura
|
|
|
|
*
|
2012-08-05 15:34:10 +02:00
|
|
|
* @param zathura The zathura session
|
|
|
|
* @return true if initialization has been successful
|
2011-04-18 17:27:49 +02:00
|
|
|
*/
|
2012-08-05 15:34:10 +02:00
|
|
|
bool zathura_init(zathura_t* zathura);
|
2011-04-18 17:27:49 +02:00
|
|
|
|
|
|
|
/**
|
2011-04-27 19:57:49 +02:00
|
|
|
* Free zathura session
|
2011-04-18 17:27:49 +02:00
|
|
|
*
|
2011-04-27 19:57:49 +02:00
|
|
|
* @param zathura The zathura session
|
2010-11-10 19:18:01 +01:00
|
|
|
*/
|
2011-04-18 17:27:49 +02:00
|
|
|
void zathura_free(zathura_t* zathura);
|
2010-11-10 19:18:01 +01:00
|
|
|
|
2012-08-05 15:34:10 +02:00
|
|
|
/**
|
|
|
|
* Set parent window id
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param xid The window id
|
|
|
|
*/
|
|
|
|
void zathura_set_xid(zathura_t* zathura, Window xid);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the path to the configuration directory
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param dir Directory path
|
|
|
|
*/
|
|
|
|
void zathura_set_config_dir(zathura_t* zathura, const char* dir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the path to the data directory
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param dir Directory path
|
|
|
|
*/
|
|
|
|
void zathura_set_data_dir(zathura_t* zathura, const char* dir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the path to the plugin directory
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param dir Directory path
|
|
|
|
*/
|
|
|
|
void zathura_set_plugin_dir(zathura_t* zathura, const char* dir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables synctex support and sets the synctex editor command
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param command Synctex editor command
|
|
|
|
*/
|
|
|
|
void zathura_set_synctex_editor_command(zathura_t* zathura, const char* command);
|
|
|
|
|
2012-08-13 18:17:20 +02:00
|
|
|
/**
|
2012-12-06 12:24:36 +01:00
|
|
|
* En/Disable zathuras synctex support
|
2012-08-13 18:17:20 +02:00
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param value The value
|
|
|
|
*/
|
2012-12-06 12:24:36 +01:00
|
|
|
void zathura_set_synctex(zathura_t* zathura, bool value);
|
2012-08-13 18:17:20 +02:00
|
|
|
|
2012-08-05 15:34:10 +02:00
|
|
|
/**
|
|
|
|
* Sets the program parameters
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param argv List of arguments
|
|
|
|
*/
|
|
|
|
void zathura_set_argv(zathura_t* zathura, char** argv);
|
|
|
|
|
2010-12-12 22:04:42 +01:00
|
|
|
/**
|
|
|
|
* Opens a file
|
|
|
|
*
|
2011-04-27 19:57:49 +02:00
|
|
|
* @param zathura The zathura session
|
2010-12-12 22:04:42 +01:00
|
|
|
* @param path The path to the file
|
|
|
|
* @param password The password of the file
|
|
|
|
*
|
|
|
|
* @return If no error occured true, otherwise false, is returned.
|
|
|
|
*/
|
2013-03-17 10:56:43 +01:00
|
|
|
bool document_open(zathura_t* zathura, const char* path, const char* password,
|
|
|
|
int page_number);
|
2010-12-12 22:04:42 +01:00
|
|
|
|
2012-08-05 15:34:10 +02:00
|
|
|
/**
|
|
|
|
* Opens a file (idle)
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param path The path to the file
|
|
|
|
* @param password The password of the file
|
|
|
|
*/
|
2013-03-17 10:56:43 +01:00
|
|
|
void document_open_idle(zathura_t* zathura, const char* path,
|
|
|
|
const char* password, int page_number);
|
2012-08-05 15:34:10 +02:00
|
|
|
|
2011-09-01 11:51:49 +02:00
|
|
|
/**
|
|
|
|
* Save a open file
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param path The path
|
|
|
|
* @param overwrite Overwrite existing file
|
|
|
|
*
|
|
|
|
* @return If no error occured true, otherwise false, is returned.
|
|
|
|
*/
|
|
|
|
bool document_save(zathura_t* zathura, const char* path, bool overwrite);
|
|
|
|
|
2010-12-12 22:04:42 +01:00
|
|
|
/**
|
|
|
|
* Closes the current opened document
|
|
|
|
*
|
2011-04-27 19:57:49 +02:00
|
|
|
* @param zathura The zathura session
|
2012-02-20 20:07:24 +01:00
|
|
|
* @param keep_monitor Set to true if monitor should be kept (sc_reload)
|
2010-12-12 22:04:42 +01:00
|
|
|
* @return If no error occured true, otherwise false, is returned.
|
|
|
|
*/
|
2012-02-20 20:07:24 +01:00
|
|
|
bool document_close(zathura_t* zathura, bool keep_monitor);
|
2010-12-12 22:04:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the page with the given number
|
|
|
|
*
|
2011-04-27 19:57:49 +02:00
|
|
|
* @param zathura The zathura session
|
2012-02-08 15:30:13 +01:00
|
|
|
* @param page_id The id of the page that should be set
|
2010-12-12 22:04:42 +01:00
|
|
|
* @return If no error occured true, otherwise false, is returned.
|
|
|
|
*/
|
2011-04-18 17:27:49 +02:00
|
|
|
bool page_set(zathura_t* zathura, unsigned int page_id);
|
2010-12-12 22:04:42 +01:00
|
|
|
|
2013-06-09 05:53:31 +02:00
|
|
|
/**
|
|
|
|
* Moves to the given position
|
|
|
|
*
|
|
|
|
* @param zathura Zathura session
|
|
|
|
* @param position_x X coordinate
|
|
|
|
* @param position_y Y coordinate
|
2013-10-22 21:37:02 +02:00
|
|
|
* @return If no error occured true, otherwise false, is returned.
|
2013-06-09 05:53:31 +02:00
|
|
|
*/
|
2013-10-22 21:37:02 +02:00
|
|
|
bool position_set(zathura_t* zathura, double position_x, double position_y);
|
2012-04-21 04:59:58 +02:00
|
|
|
|
2013-10-22 21:24:26 +02:00
|
|
|
/**
|
|
|
|
* Refresh the page view
|
|
|
|
*
|
|
|
|
* @param zathura Zathura session
|
|
|
|
*/
|
|
|
|
void refresh_view(zathura_t* zathura);
|
|
|
|
|
2013-10-24 22:11:52 +02:00
|
|
|
/**
|
|
|
|
* Recompute the scale according to settings
|
|
|
|
*
|
|
|
|
* @param zathura Zathura session
|
|
|
|
*/
|
|
|
|
bool adjust_view(zathura_t* zathura);
|
|
|
|
|
2011-03-18 18:40:20 +01:00
|
|
|
/**
|
|
|
|
* Builds the box structure to show the rendered pages
|
|
|
|
*
|
2011-04-27 19:57:49 +02:00
|
|
|
* @param zathura The zathura session
|
2013-10-20 16:07:07 +02:00
|
|
|
* @param page_padding padding in pixels between pages
|
2011-03-18 18:40:20 +01:00
|
|
|
* @param pages_per_row Number of shown pages per row
|
2012-06-27 22:34:16 +02:00
|
|
|
* @param first_page_column Column on which first page start
|
2011-03-18 18:40:20 +01:00
|
|
|
*/
|
2013-10-20 16:07:07 +02:00
|
|
|
void page_widget_set_mode(zathura_t* zathura, unsigned int page_padding,
|
|
|
|
unsigned int pages_per_row, unsigned int first_page_column);
|
2011-03-18 18:40:20 +01:00
|
|
|
|
2011-04-27 19:57:49 +02:00
|
|
|
/**
|
|
|
|
* Updates the page number in the statusbar. Note that 1 will be added to the
|
|
|
|
* displayed number
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
*/
|
|
|
|
void statusbar_page_number_update(zathura_t* zathura);
|
|
|
|
|
2013-03-31 17:53:14 +02:00
|
|
|
/**
|
|
|
|
* Checks whether current jump has a previous jump
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @return true if current jump has a previous jump
|
|
|
|
*/
|
|
|
|
bool zathura_jumplist_has_previous(zathura_t* zathura);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether current jump has a next jump
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @return true if current jump has a next jump
|
|
|
|
*/
|
|
|
|
bool zathura_jumplist_has_next(zathura_t* zathura);
|
|
|
|
|
2012-08-17 14:14:57 +02:00
|
|
|
/**
|
|
|
|
* Return current jump in the jumplist
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @return current jump
|
|
|
|
*/
|
|
|
|
zathura_jump_t* zathura_jumplist_current(zathura_t* zathura);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move forward in the jumplist
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
*/
|
|
|
|
void zathura_jumplist_forward(zathura_t* zathura);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move backward in the jumplist
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
*/
|
|
|
|
void zathura_jumplist_backward(zathura_t* zathura);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add current page as a new item to the jumplist after current position
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
*/
|
|
|
|
void zathura_jumplist_add(zathura_t* zathura);
|
|
|
|
|
2013-06-21 14:30:04 +02:00
|
|
|
/**
|
|
|
|
* Trim entries from the beginning of the jumplist to maintain it's maximum size constraint.
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
*/
|
|
|
|
void zathura_jumplist_trim(zathura_t* zathura);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the jumplist of the specified file
|
|
|
|
*
|
|
|
|
* @param zathura The zathura session
|
|
|
|
* @param file The file whose jumplist is to be loaded
|
|
|
|
*
|
|
|
|
* return A linked list of zathura_jump_t structures constituting the jumplist of the specified file, or NULL.
|
|
|
|
*/
|
|
|
|
bool zathura_jumplist_load(zathura_t* zathura, const char* file);
|
|
|
|
|
2010-11-10 19:18:01 +01:00
|
|
|
#endif // ZATHURA_H
|