zathura.h 8.89 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 */
100
    int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
Moritz Lipp's avatar
Moritz Lipp committed
101
    girara_list_t* marks; /**< Marker */
102
    char** arguments; /**> Arguments that were passed at startup */
Moritz Lipp's avatar
Moritz Lipp committed
103 104
  } global;

Pavel Borzenkov's avatar
Pavel Borzenkov committed
105 106
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
107 108 109 110
    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
111
  } modes;
Moritz Lipp's avatar
Moritz Lipp committed
112

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

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

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

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

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

147 148 149 150 151 152 153
/**
 * 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
154 155 156
/**
 * Initializes zathura
 *
157 158
 * @param zathura The zathura session
 * @return true if initialization has been successful
Moritz Lipp's avatar
Moritz Lipp committed
159
 */
160
bool zathura_init(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
161 162

/**
163
 * Free zathura session
Moritz Lipp's avatar
Moritz Lipp committed
164
 *
165
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
166
 */
Moritz Lipp's avatar
Moritz Lipp committed
167
void zathura_free(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
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 212
/**
 * 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
213
/**
214
 * En/Disable zathuras synctex support
Moritz Lipp's avatar
Moritz Lipp committed
215 216 217 218
 *
 * @param zathura The zathura session
 * @param value The value
 */
219
void zathura_set_synctex(zathura_t* zathura, bool value);
Moritz Lipp's avatar
Moritz Lipp committed
220

221 222 223 224 225 226 227 228
/**
 * 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
229 230 231
/**
 * Opens a file
 *
232
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
233 234 235 236 237
 * @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
238
bool document_open(zathura_t* zathura, const char* path, const char* password);
Moritz Lipp's avatar
Moritz Lipp committed
239

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

249 250 251 252 253 254 255 256 257 258 259
/**
 * 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
260 261 262
/**
 * Closes the current opened document
 *
263
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
264
 * @param keep_monitor Set to true if monitor should be kept (sc_reload)
Moritz Lipp's avatar
Moritz Lipp committed
265 266
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
267
bool document_close(zathura_t* zathura, bool keep_monitor);
Moritz Lipp's avatar
Moritz Lipp committed
268 269 270 271

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

278 279 280 281
/**
 * Opens the page with the given number (delayed)
 *
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
282
 * @param page_id The id of the page that should be set
283 284 285 286
 * @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
287 288 289 290 291 292 293 294 295 296
/**
 * 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);

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

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

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 357
/**
 * 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
358
#endif // ZATHURA_H