zathura.h 9.96 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>
Sebastian Ramacher's avatar
Sebastian Ramacher committed
9
#include <gtk/gtkx.h>
10
#include "macros.h"
11
#include "types.h"
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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,
  BACKWARD,
  CONTINUOUS,
  DELETE_LAST,
  EXPAND,
  EXPAND_ALL,
  COLLAPSE_ALL,
  COLLAPSE,
  TOGGLE,
  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,
  PAGE_BOTTOM,
  PAGE_TOP
};
Moritz Lipp's avatar
Moritz Lipp committed
65

66
67
68
69
70
/* unspecified page number */
enum {
  ZATHURA_PAGE_NUMBER_UNSPECIFIED = INT_MIN
};

71
72
73
74
75
76
/* cache constants */
enum {
  ZATHURA_PAGE_CACHE_DEFAULT_SIZE = 15,
  ZATHURA_PAGE_CACHE_MAX_SIZE = 1024
};

Marwan Tanager's avatar
Marwan Tanager committed
77
/* forward declaration for types from database.h */
78
typedef struct _ZathuraDatabase zathura_database_t;
79

80
81
82
83
84
85
86
87
88
89
/**
 * Jump
 */
typedef struct zathura_jump_s
{
  unsigned int page;
  double x;
  double y;
} zathura_jump_t;

90
struct zathura_s
Moritz Lipp's avatar
Moritz Lipp committed
91
{
Moritz Lipp's avatar
Moritz Lipp committed
92
  struct
Moritz Lipp's avatar
Moritz Lipp committed
93
  {
Moritz Lipp's avatar
Moritz Lipp committed
94
    girara_session_t* session; /**< girara interface session */
Moritz Lipp's avatar
Moritz Lipp committed
95
96
97

    struct
    {
Moritz Lipp's avatar
Moritz Lipp committed
98
99
100
      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
101
    } statusbar;
Moritz Lipp's avatar
Moritz Lipp committed
102

Moritz Lipp's avatar
Moritz Lipp committed
103
104
    struct
    {
105
106
107
108
      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..." */
Moritz Lipp's avatar
Moritz Lipp committed
109
110
    } colors;

111
112
    GtkWidget *page_widget_alignment;
    GtkWidget *page_widget; /**< Widget that contains all rendered pages */
Moritz Lipp's avatar
Moritz Lipp committed
113
    GtkWidget *index; /**< Widget to show the index of the document */
Moritz Lipp's avatar
Moritz Lipp committed
114
  } ui;
Moritz Lipp's avatar
Moritz Lipp committed
115

Moritz Lipp's avatar
Moritz Lipp committed
116
117
  struct
  {
118
    ZathuraRenderer* render_thread; /**< The thread responsible for rendering the pages */
Moritz Lipp's avatar
Moritz Lipp committed
119
  } sync;
Moritz Lipp's avatar
Moritz Lipp committed
120

Sebastian Ramacher's avatar
Sebastian Ramacher committed
121
122
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
123
    void* manager; /**< Plugin manager */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
124
125
  } plugins;

126
127
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
128
129
    gchar* config_dir; /**< Path to the configuration directory */
    gchar* data_dir; /**< Path to the data directory */
130
131
  } config;

132
133
134
135
136
137
  struct
  {
    bool enabled;
    gchar* editor;
  } synctex;

138
139
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
140
141
    GtkPrintSettings* settings; /**< Print settings */
    GtkPageSetup* page_setup; /**< Saved page setup */
142
143
  } print;

Moritz Lipp's avatar
Moritz Lipp committed
144
145
  struct
  {
146
    int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
Moritz Lipp's avatar
Moritz Lipp committed
147
    girara_list_t* marks; /**< Marker */
148
    char** arguments; /**> Arguments that were passed at startup */
Moritz Lipp's avatar
Moritz Lipp committed
149
150
  } global;

Pavel Borzenkov's avatar
Pavel Borzenkov committed
151
152
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
153
154
155
156
    girara_mode_t normal; /**< Normal mode */
    girara_mode_t fullscreen; /**< Fullscreen mode */
    girara_mode_t index; /**< Index mode */
    girara_mode_t insert; /**< Insert mode */
157
    girara_mode_t presentation; /**< Presentation mode */
Pavel Borzenkov's avatar
Pavel Borzenkov committed
158
  } modes;
Moritz Lipp's avatar
Moritz Lipp committed
159

160
161
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
162
163
    gchar* file; /**< bookmarks file */
    girara_list_t* bookmarks; /**< bookmarks */
164
165
  } bookmarks;

166
167
168
169
170
171
172
173
  struct
  {
    girara_list_t* list;
    girara_list_iterator_t *cur;
    unsigned int size;
    unsigned int max_size;
  } jumplist;

174
175
176
  struct
  {
    guint refresh_view;
Moritz Lipp's avatar
Moritz Lipp committed
177
178
179
#ifdef G_OS_UNIX
    guint sigterm;
#endif
180
181
  } signals;

182
183
184
185
186
  struct
  {
    gchar* file;
  } stdin_support;

Moritz Lipp's avatar
Moritz Lipp committed
187
  zathura_document_t* document; /**< The current document */
188
  GtkWidget** pages; /**< The page widgets */
Moritz Lipp's avatar
Moritz Lipp committed
189
  zathura_database_t* database; /**< The database */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
190
  ZathuraDbus* dbus; /**< D-Bus service */
Moritz Lipp's avatar
Moritz Lipp committed
191
192
193
194
195
196
197
198
199
200

  /**
   * 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;
201

202
203
204
205
206
207
208
209
  /**
   * 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;
210
};
Moritz Lipp's avatar
Moritz Lipp committed
211

212
213
214
215
216
217
218
/**
 * 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
219
220
221
/**
 * Initializes zathura
 *
222
223
 * @param zathura The zathura session
 * @return true if initialization has been successful
Moritz Lipp's avatar
Moritz Lipp committed
224
 */
225
bool zathura_init(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
226
227

/**
228
 * Free zathura session
Moritz Lipp's avatar
Moritz Lipp committed
229
 *
230
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
231
 */
Moritz Lipp's avatar
Moritz Lipp committed
232
void zathura_free(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
233

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/**
 * 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);

Moritz Lipp's avatar
Moritz Lipp committed
274
/**
275
 * En/Disable zathuras synctex support
Moritz Lipp's avatar
Moritz Lipp committed
276
277
278
279
 *
 * @param zathura The zathura session
 * @param value The value
 */
280
void zathura_set_synctex(zathura_t* zathura, bool value);
Moritz Lipp's avatar
Moritz Lipp committed
281

282
283
284
285
286
287
288
289
/**
 * 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
290
291
292
/**
 * Opens a file
 *
293
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
294
295
296
297
298
 * @param path The path to the file
 * @param password The password of the file
 *
 * @return If no error occured true, otherwise false, is returned.
 */
299
300
bool document_open(zathura_t* zathura, const char* path, const char* password,
                   int page_number);
Moritz Lipp's avatar
Moritz Lipp committed
301

302
303
304
305
306
307
308
/**
 * Opens a file (idle)
 *
 * @param zathura The zathura session
 * @param path The path to the file
 * @param password The password of the file
 */
309
void document_open_idle(zathura_t* zathura, const char* path,
Sebastian Ramacher's avatar
Sebastian Ramacher committed
310
311
                        const char* password, int page_number,
                        const char* mode);
312

313
314
315
316
317
318
319
320
321
322
323
/**
 * 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
324
325
326
/**
 * Closes the current opened document
 *
327
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
328
 * @param keep_monitor Set to true if monitor should be kept (sc_reload)
Moritz Lipp's avatar
Moritz Lipp committed
329
330
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
331
bool document_close(zathura_t* zathura, bool keep_monitor);
Moritz Lipp's avatar
Moritz Lipp committed
332
333
334
335

/**
 * Opens the page with the given number
 *
336
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
337
 * @param page_id The id of the page that should be set
Moritz Lipp's avatar
Moritz Lipp committed
338
339
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
340
bool page_set(zathura_t* zathura, unsigned int page_id);
Moritz Lipp's avatar
Moritz Lipp committed
341

342
343
344
345
346
347
/**
 * Moves to the given position
 *
 * @param zathura Zathura session
 * @param position_x X coordinate
 * @param position_y Y coordinate
348
 * @return If no error occured true, otherwise false, is returned.
349
 */
350
bool position_set(zathura_t* zathura, double position_x, double position_y);
Moritz Lipp's avatar
Moritz Lipp committed
351

352
353
354
355
356
357
358
/**
 * Refresh the page view
 *
 * @param zathura Zathura session
 */
void refresh_view(zathura_t* zathura);

359
360
361
362
363
364
365
/**
 * Recompute the scale according to settings
 *
 * @param zathura Zathura session
 */
bool adjust_view(zathura_t* zathura);

366
367
368
/**
 * Builds the box structure to show the rendered pages
 *
369
 * @param zathura The zathura session
370
 * @param page_padding padding in pixels between pages
371
 * @param pages_per_row Number of shown pages per row
372
 * @param first_page_column Column on which first page start
373
 */
374
375
void page_widget_set_mode(zathura_t* zathura, unsigned int page_padding,
                          unsigned int pages_per_row, unsigned int first_page_column);
376

377
378
379
380
381
382
383
384
/**
 * 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);

385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/**
 * 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);

401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
/**
 * 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);

430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/**
 * 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);

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