zathura/zathura.h

435 lines
11 KiB
C
Raw Normal View History

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>
#include <girara/types.h>
#include <gtk/gtk.h>
#include "macros.h"
#include "types.h"
2011-09-21 00:46:03 +02:00
2012-08-05 15:31:42 +02:00
#if (GTK_MAJOR_VERSION == 3)
#include <gtk/gtkx.h>
#endif
#define ZATHURA_PAGE_CACHE_DEFAULT_SIZE 15
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,
PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW };
2010-11-13 10:05:28 +01:00
/* unspecified page number */
enum {
ZATHURA_PAGE_NUMBER_UNSPECIFIED = INT_MIN
};
/* forward declaration for types from database.h */
typedef struct _ZathuraDatabase zathura_database_t;
2011-04-18 18:19:41 +02:00
/* forward declaration for types from render.h */
struct render_thread_s;
typedef struct render_thread_s render_thread_t;
/**
* Jump
*/
typedef struct zathura_jump_s
{
unsigned int page;
double x;
double y;
} zathura_jump_t;
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
{
2012-01-22 21:57:18 +01:00
GdkColor recolor_dark_color; /**< Dark color for recoloring */
GdkColor recolor_light_color; /**< Light color for recoloring */
GdkColor highlight_color; /**< Color for highlighting */
GdkColor highlight_color_active; /** Color for highlighting */
GdkColor render_loading_bg; /**< Background color for render "Loading..." */
GdkColor 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 */
GtkAdjustment *hadjustment; /**< Tracking hadjustment */
GtkAdjustment *vadjustment; /**< Tracking vadjustment */
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
{
2012-01-22 21:57:18 +01:00
render_thread_t* 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;
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 */
} config;
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
{
bool recolor_keep_hue; /**< Keep hue when recoloring */
2012-01-22 21:57:18 +01:00
bool recolor; /**< Recoloring mode switch */
bool update_page_number; /**< Update current page number */
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;
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 */
} 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;
struct
{
girara_list_t* list;
girara_list_iterator_t *cur;
unsigned int size;
unsigned int max_size;
} jumplist;
struct
{
gchar* file;
} stdin_support;
2012-01-22 21:57:18 +01:00
zathura_document_t* document; /**< The current document */
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;
/**
* The page cache
*/
struct {
int* cache;
unsigned int size;
unsigned int num_cached_pages;
} page_cache;
/**
* 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;
};
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
/**
* Free zathura session
2011-04-18 17:27: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
*/
#if (GTK_MAJOR_VERSION == 2)
void zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid);
#else
void zathura_set_xid(zathura_t* zathura, Window xid);
#endif
/**
* 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
/**
* En/Disable zathuras synctex support
2012-08-13 18:17:20 +02:00
*
* @param zathura The zathura session
* @param value The value
*/
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
*
* @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.
*/
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
*/
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
*
* @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
*
* @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
/**
* Opens the page with the given number (delayed)
*
* @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
* @return If no error occured true, otherwise false, is returned.
*/
bool page_set_delayed(zathura_t* zathura, unsigned int page_id);
2012-04-21 04:59:58 +02:00
/**
* Moves to the given position
*
* @param zathura Zathura session
* @param position_x X coordinate
* @param position_y Y coordinate
*/
Enhancements/Cleanups for the jumplist mechansim - Don't delete the elements on the right of the current one, when appending a new jump to the jumplist, because this makes no sense at all; the point of the jumplist in the first place is to remember previously jumped-to positions in the document, so there is no need to delete anythings except to trim the oldest entries from the beginning to maintain the maximum size. This also makes us compatible with the Vim way of doing things. - Make the jumplist mechanism functional on the same page; if we followed a link to a target on the same page, remember the adjustments before and after following the link. The same holds for navigating search results on the same page. - Implement position_set and use it instead of position_set_delayed when following links in order to give zathura_jumplist_save a chance to record the exact adjustments of the link target. Otherwise, it will always record the adjustments after going to the target page, but before going to the exact position within it. - Don't consider movements with ^i and ^o as jumps :) - Don't use page_set followed by setting the adjustments in sc_jumplist, because this is redundant and causes clutter when using ^i and ^o, as the adjustments is set twice this way (once in page_set and again in position_set_delayed). It's enough to only update the page number on the statusbar and then set the adjustments. - Hide implementation details (zathura_jumplist_save and zathura_jumplist_append), and make things more consistent by exporting and using only zathura_jumplist_add for adding new entries. The end result: A more slick jumping experience :-) Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
2013-06-09 05:53:31 +02:00
void position_set_delayed(zathura_t* zathura, double position_x, double position_y);
/**
* Moves to the given position
*
* @param zathura Zathura session
* @param position_x X coordinate
* @param position_y Y coordinate
*/
void position_set(zathura_t* zathura, double position_x, double position_y);
2012-04-21 04:59:58 +02:00
2011-03-18 18:40:20 +01:00
/**
* Builds the box structure to show the rendered pages
*
* @param zathura The zathura session
2011-03-18 18:40:20 +01:00
* @param pages_per_row Number of shown pages per row
* @param first_page_column Column on which first page start
2011-03-18 18:40:20 +01:00
*/
void page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned int first_page_column);
2011-03-18 18:40:20 +01: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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* Add a page to the page cache
*
* @param zathura The zathura session
* @param page_index The index of the page to be cached
*/
void zathura_page_cache_add(zathura_t* zathura, unsigned int page_index);
/**
* Checks if the given page is cached
*
* @param zathura The zathura session
* @param page_index The index of the page that may be cached
*
* @return true if page is cached otherwise false
*/
bool zathura_page_cache_is_cached(zathura_t* zathura, unsigned int page_index);
2010-11-10 19:18:01 +01:00
#endif // ZATHURA_H