zathura.h 8.8 KB
Newer Older
Moritz Lipp's avatar
Moritz Lipp committed
1 2 3 4 5 6
/* See LICENSE file for license and copyright information */

#ifndef ZATHURA_H
#define ZATHURA_H

#include <stdbool.h>
7 8
#include <girara/types.h>
#include <gtk/gtk.h>
9
#include "macros.h"
10
#include "types.h"
11

12 13 14 15
#if (GTK_MAJOR_VERSION == 3)
#include <gtk/gtkx.h>
#endif

Moritz Lipp's avatar
Moritz Lipp committed
16 17 18
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,
Moritz Lipp's avatar
Moritz Lipp committed
19 20 21 22
  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 };
Moritz Lipp's avatar
Moritz Lipp committed
23

24
/* forward declaration for types form database.h */
25
typedef struct _ZathuraDatabase zathura_database_t;
26

Sebastian Ramacher's avatar
Sebastian Ramacher committed
27 28 29 30
/* forward declaration for types from render.h */
struct render_thread_s;
typedef struct render_thread_s render_thread_t;

31 32 33 34 35 36 37 38 39 40
/**
 * Jump
 */
typedef struct zathura_jump_s
{
  unsigned int page;
  double x;
  double y;
} zathura_jump_t;

41
struct zathura_s
Moritz Lipp's avatar
Moritz Lipp committed
42
{
Moritz Lipp's avatar
Moritz Lipp committed
43
  struct
Moritz Lipp's avatar
Moritz Lipp committed
44
  {
Moritz Lipp's avatar
Moritz Lipp committed
45
    girara_session_t* session; /**< girara interface session */
Moritz Lipp's avatar
Moritz Lipp committed
46 47 48

    struct
    {
Moritz Lipp's avatar
Moritz Lipp committed
49 50 51
      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 */
Moritz Lipp's avatar
Moritz Lipp committed
52
    } statusbar;
Moritz Lipp's avatar
Moritz Lipp committed
53

Moritz Lipp's avatar
Moritz Lipp committed
54 55
    struct
    {
Moritz Lipp's avatar
Moritz Lipp committed
56 57 58
      GdkColor recolor_dark_color; /**< Dark color for recoloring */
      GdkColor recolor_light_color; /**< Light color for recoloring */
      GdkColor highlight_color; /**< Color for highlighting */
59
      GdkColor highlight_color_active; /** Color for highlighting */
Moritz Lipp's avatar
Moritz Lipp committed
60 61
    } colors;

62 63
    GtkWidget *page_widget_alignment;
    GtkWidget *page_widget; /**< Widget that contains all rendered pages */
Moritz Lipp's avatar
Moritz Lipp committed
64
    GtkWidget *index; /**< Widget to show the index of the document */
Moritz Lipp's avatar
Moritz Lipp committed
65
  } ui;
Moritz Lipp's avatar
Moritz Lipp committed
66

Moritz Lipp's avatar
Moritz Lipp committed
67 68
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
69
    render_thread_t* render_thread; /**< The thread responsible for rendering the pages */
Moritz Lipp's avatar
Moritz Lipp committed
70
  } sync;
Moritz Lipp's avatar
Moritz Lipp committed
71

Sebastian Ramacher's avatar
Sebastian Ramacher committed
72 73
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
74
    void* manager; /**< Plugin manager */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
75 76
  } plugins;

77 78
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
79 80
    gchar* config_dir; /**< Path to the configuration directory */
    gchar* data_dir; /**< Path to the data directory */
81 82
  } config;

83 84 85 86 87 88
  struct
  {
    bool enabled;
    gchar* editor;
  } synctex;

89 90
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
91 92
    GtkPrintSettings* settings; /**< Print settings */
    GtkPageSetup* page_setup; /**< Saved page setup */
93 94
  } print;

Moritz Lipp's avatar
Moritz Lipp committed
95 96
  struct
  {
97
    bool recolor_keep_hue; /**< Keep hue when recoloring */
Moritz Lipp's avatar
Moritz Lipp committed
98
    bool recolor; /**< Recoloring mode switch */
99
    bool update_page_number; /**< Update current page number */
Moritz Lipp's avatar
Moritz Lipp committed
100
    girara_list_t* marks; /**< Marker */
101
    char** arguments; /**> Arguments that were passed at startup */
Moritz Lipp's avatar
Moritz Lipp committed
102 103
  } global;

Pavel Borzenkov's avatar
Pavel Borzenkov committed
104 105
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
106 107 108 109
    girara_mode_t normal; /**< Normal mode */
    girara_mode_t fullscreen; /**< Fullscreen mode */
    girara_mode_t index; /**< Index mode */
    girara_mode_t insert; /**< Insert mode */
Pavel Borzenkov's avatar
Pavel Borzenkov committed
110
  } modes;
Moritz Lipp's avatar
Moritz Lipp committed
111

112 113
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
114 115
    gchar* file; /**< bookmarks file */
    girara_list_t* bookmarks; /**< bookmarks */
116 117
  } bookmarks;

118 119 120 121 122 123 124 125
  struct
  {
    girara_list_t* list;
    girara_list_iterator_t *cur;
    unsigned int size;
    unsigned int max_size;
  } jumplist;

126 127 128 129 130
  struct
  {
    gchar* file;
  } stdin_support;

Moritz Lipp's avatar
Moritz Lipp committed
131
  zathura_document_t* document; /**< The current document */
132
  GtkWidget** pages; /**< The page widgets */
Moritz Lipp's avatar
Moritz Lipp committed
133
  zathura_database_t* database; /**< The database */
Moritz Lipp's avatar
Moritz Lipp committed
134 135 136 137 138 139 140 141 142 143

  /**
   * 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;
144
};
Moritz Lipp's avatar
Moritz Lipp committed
145

146 147 148 149 150 151 152
/**
 * Creates a zathura session
 *
 * @return zathura session object or NULL if zathura could not be creeated
 */
zathura_t* zathura_create(void);

Moritz Lipp's avatar
Moritz Lipp committed
153 154 155
/**
 * Initializes zathura
 *
156 157
 * @param zathura The zathura session
 * @return true if initialization has been successful
Moritz Lipp's avatar
Moritz Lipp committed
158
 */
159
bool zathura_init(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
160 161

/**
162
 * Free zathura session
Moritz Lipp's avatar
Moritz Lipp committed
163
 *
164
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
165
 */
Moritz Lipp's avatar
Moritz Lipp committed
166
void zathura_free(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
167

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
/**
 * 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);

Moritz Lipp's avatar
Moritz Lipp committed
212 213 214 215 216 217 218 219
/**
 * En/Disable zathuras syntex support
 *
 * @param zathura The zathura session
 * @param value The value
 */
void zathura_set_syntex(zathura_t* zathura, bool value);

220 221 222 223 224 225 226 227
/**
 * Sets the program parameters
 *
 * @param zathura The zathura session
 * @param argv List of arguments
 */
void zathura_set_argv(zathura_t* zathura, char** argv);

Moritz Lipp's avatar
Moritz Lipp committed
228 229 230
/**
 * Opens a file
 *
231
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
232 233 234 235 236
 * @param path The path to the file
 * @param password The password of the file
 *
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
237
bool document_open(zathura_t* zathura, const char* path, const char* password);
Moritz Lipp's avatar
Moritz Lipp committed
238

239 240 241 242 243 244 245 246 247
/**
 * 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);

248 249 250 251 252 253 254 255 256 257 258
/**
 * 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);

Moritz Lipp's avatar
Moritz Lipp committed
259 260 261
/**
 * Closes the current opened document
 *
262
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
263
 * @param keep_monitor Set to true if monitor should be kept (sc_reload)
Moritz Lipp's avatar
Moritz Lipp committed
264 265
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
266
bool document_close(zathura_t* zathura, bool keep_monitor);
Moritz Lipp's avatar
Moritz Lipp committed
267 268 269 270

/**
 * Opens the page with the given number
 *
271
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
272
 * @param page_id The id of the page that should be set
Moritz Lipp's avatar
Moritz Lipp committed
273 274
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
275
bool page_set(zathura_t* zathura, unsigned int page_id);
Moritz Lipp's avatar
Moritz Lipp committed
276

277 278 279 280
/**
 * Opens the page with the given number (delayed)
 *
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
281
 * @param page_id The id of the page that should be set
282 283 284 285
 * @return If no error occured true, otherwise false, is returned.
 */
bool page_set_delayed(zathura_t* zathura, unsigned int page_id);

Moritz Lipp's avatar
Moritz Lipp committed
286 287 288 289 290 291 292 293 294 295
/**
 * Moves to the given position
 *
 * @param zathura Zathura session
 * @param position_x X coordinate
 * @param position_y Y coordinate
 * @return If no error occured true, otherwise false, is returned.
 */
bool position_set_delayed(zathura_t* zathura, double position_x, double position_y);

296 297 298
/**
 * Builds the box structure to show the rendered pages
 *
299
 * @param zathura The zathura session
300
 * @param pages_per_row Number of shown pages per row
301
 * @param first_page_column Column on which first page start
302
 */
303
void page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned int first_page_column);
304

305 306 307 308 309 310 311 312
/**
 * 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);

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
/**
 * 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);

/**
 * Save current page to the jumplist at current position
 *
 * @param zathura The zathura session
 */
void zathura_jumplist_save(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);

/**
 * Add a page to the jumplist after current position
 *
 * @param zathura The zathura session
 */
void zathura_jumplist_append_jump(zathura_t* zathura);


Moritz Lipp's avatar
Moritz Lipp committed
357
#endif // ZATHURA_H