zathura.h 10.5 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
25
26
27
28
/* unspecified page number */
enum {
  ZATHURA_PAGE_NUMBER_UNSPECIFIED = INT_MIN
};

29
30
31
32
33
34
/* cache constants */
enum {
  ZATHURA_PAGE_CACHE_DEFAULT_SIZE = 15,
  ZATHURA_PAGE_CACHE_MAX_SIZE = 1024
};

Marwan Tanager's avatar
Marwan Tanager committed
35
/* forward declaration for types from database.h */
36
typedef struct _ZathuraDatabase zathura_database_t;
37

38
39
40
41
42
43
44
45
46
47
/**
 * Jump
 */
typedef struct zathura_jump_s
{
  unsigned int page;
  double x;
  double y;
} zathura_jump_t;

48
struct zathura_s
Moritz Lipp's avatar
Moritz Lipp committed
49
{
Moritz Lipp's avatar
Moritz Lipp committed
50
  struct
Moritz Lipp's avatar
Moritz Lipp committed
51
  {
Moritz Lipp's avatar
Moritz Lipp committed
52
    girara_session_t* session; /**< girara interface session */
Moritz Lipp's avatar
Moritz Lipp committed
53
54
55

    struct
    {
Moritz Lipp's avatar
Moritz Lipp committed
56
57
58
      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
59
    } statusbar;
Moritz Lipp's avatar
Moritz Lipp committed
60

Moritz Lipp's avatar
Moritz Lipp committed
61
62
    struct
    {
Moritz Lipp's avatar
Moritz Lipp committed
63
      GdkColor highlight_color; /**< Color for highlighting */
64
      GdkColor highlight_color_active; /** Color for highlighting */
65
66
      GdkColor render_loading_bg; /**< Background color for render "Loading..." */
      GdkColor render_loading_fg; /**< Foreground color for render "Loading..." */
Moritz Lipp's avatar
Moritz Lipp committed
67
68
    } colors;

69
70
    GtkWidget *page_widget_alignment;
    GtkWidget *page_widget; /**< Widget that contains all rendered pages */
Moritz Lipp's avatar
Moritz Lipp committed
71
    GtkWidget *index; /**< Widget to show the index of the document */
72
73
74

    GtkAdjustment *hadjustment; /**< Tracking hadjustment */
    GtkAdjustment *vadjustment; /**< Tracking vadjustment */
Moritz Lipp's avatar
Moritz Lipp committed
75
  } ui;
Moritz Lipp's avatar
Moritz Lipp committed
76

Moritz Lipp's avatar
Moritz Lipp committed
77
78
  struct
  {
79
    ZathuraRenderer* render_thread; /**< The thread responsible for rendering the pages */
Moritz Lipp's avatar
Moritz Lipp committed
80
  } sync;
Moritz Lipp's avatar
Moritz Lipp committed
81

Sebastian Ramacher's avatar
Sebastian Ramacher committed
82
83
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
84
    void* manager; /**< Plugin manager */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
85
86
  } plugins;

87
88
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
89
90
    gchar* config_dir; /**< Path to the configuration directory */
    gchar* data_dir; /**< Path to the data directory */
91
92
  } config;

93
94
95
96
97
98
  struct
  {
    bool enabled;
    gchar* editor;
  } synctex;

99
100
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
101
102
    GtkPrintSettings* settings; /**< Print settings */
    GtkPageSetup* page_setup; /**< Saved page setup */
103
104
  } print;

Moritz Lipp's avatar
Moritz Lipp committed
105
106
  struct
  {
107
    bool update_page_number; /**< Update current page number */
108
    int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
Moritz Lipp's avatar
Moritz Lipp committed
109
    girara_list_t* marks; /**< Marker */
110
    char** arguments; /**> Arguments that were passed at startup */
Moritz Lipp's avatar
Moritz Lipp committed
111
112
  } global;

Pavel Borzenkov's avatar
Pavel Borzenkov committed
113
114
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
115
116
117
118
    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
119
  } modes;
Moritz Lipp's avatar
Moritz Lipp committed
120

121
122
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
123
124
    gchar* file; /**< bookmarks file */
    girara_list_t* bookmarks; /**< bookmarks */
125
126
  } bookmarks;

127
128
129
130
131
132
133
134
  struct
  {
    girara_list_t* list;
    girara_list_iterator_t *cur;
    unsigned int size;
    unsigned int max_size;
  } jumplist;

135
136
137
138
139
  struct
  {
    guint refresh_view;
  } signals;

140
141
142
143
144
  struct
  {
    gchar* file;
  } stdin_support;

Moritz Lipp's avatar
Moritz Lipp committed
145
  zathura_document_t* document; /**< The current document */
146
  GtkWidget** pages; /**< The page widgets */
Moritz Lipp's avatar
Moritz Lipp committed
147
  zathura_database_t* database; /**< The database */
Moritz Lipp's avatar
Moritz Lipp committed
148
149
150
151
152
153
154
155
156
157

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

159
160
161
162
163
164
165
166
  /**
   * 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;
167
};
Moritz Lipp's avatar
Moritz Lipp committed
168

169
170
171
172
173
174
175
/**
 * 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
176
177
178
/**
 * Initializes zathura
 *
179
180
 * @param zathura The zathura session
 * @return true if initialization has been successful
Moritz Lipp's avatar
Moritz Lipp committed
181
 */
182
bool zathura_init(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
183
184

/**
185
 * Free zathura session
Moritz Lipp's avatar
Moritz Lipp committed
186
 *
187
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
188
 */
Moritz Lipp's avatar
Moritz Lipp committed
189
void zathura_free(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
190

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**
 * 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
235
/**
236
 * En/Disable zathuras synctex support
Moritz Lipp's avatar
Moritz Lipp committed
237
238
239
240
 *
 * @param zathura The zathura session
 * @param value The value
 */
241
void zathura_set_synctex(zathura_t* zathura, bool value);
Moritz Lipp's avatar
Moritz Lipp committed
242

243
244
245
246
247
248
249
250
/**
 * 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
251
252
253
/**
 * Opens a file
 *
254
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
255
256
257
258
259
 * @param path The path to the file
 * @param password The password of the file
 *
 * @return If no error occured true, otherwise false, is returned.
 */
260
261
bool document_open(zathura_t* zathura, const char* path, const char* password,
                   int page_number);
Moritz Lipp's avatar
Moritz Lipp committed
262

263
264
265
266
267
268
269
/**
 * Opens a file (idle)
 *
 * @param zathura The zathura session
 * @param path The path to the file
 * @param password The password of the file
 */
270
271
void document_open_idle(zathura_t* zathura, const char* path,
                        const char* password, int page_number);
272

273
274
275
276
277
278
279
280
281
282
283
/**
 * 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
284
285
286
/**
 * Closes the current opened document
 *
287
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
288
 * @param keep_monitor Set to true if monitor should be kept (sc_reload)
Moritz Lipp's avatar
Moritz Lipp committed
289
290
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
291
bool document_close(zathura_t* zathura, bool keep_monitor);
Moritz Lipp's avatar
Moritz Lipp committed
292
293
294
295

/**
 * Opens the page with the given number
 *
296
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
297
 * @param page_id The id of the page that should be set
Moritz Lipp's avatar
Moritz Lipp committed
298
299
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
300
bool page_set(zathura_t* zathura, unsigned int page_id);
Moritz Lipp's avatar
Moritz Lipp committed
301

302
303
304
305
/**
 * Opens the page with the given number (delayed)
 *
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
306
 * @param page_id The id of the page that should be set
307
308
309
310
 * @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
311
312
313
314
315
316
317
/**
 * Moves to the given position
 *
 * @param zathura Zathura session
 * @param position_x X coordinate
 * @param position_y Y coordinate
 */
318
319
320
321
322
323
324
325
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
326
 * @return If no error occured true, otherwise false, is returned.
327
 */
328
bool position_set(zathura_t* zathura, double position_x, double position_y);
Moritz Lipp's avatar
Moritz Lipp committed
329

330
331
332
333
334
335
336
/**
 * Refresh the page view
 *
 * @param zathura Zathura session
 */
void refresh_view(zathura_t* zathura);

337
338
339
340
341
342
343
/**
 * Recompute the scale according to settings
 *
 * @param zathura Zathura session
 */
bool adjust_view(zathura_t* zathura);

344
345
346
/**
 * Builds the box structure to show the rendered pages
 *
347
 * @param zathura The zathura session
348
 * @param page_padding padding in pixels between pages
349
 * @param pages_per_row Number of shown pages per row
350
 * @param first_page_column Column on which first page start
351
 */
352
353
void page_widget_set_mode(zathura_t* zathura, unsigned int page_padding,
                          unsigned int pages_per_row, unsigned int first_page_column);
354

355
356
357
358
359
360
361
362
/**
 * 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);

363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/**
 * 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);

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
/**
 * 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);

408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/**
 * 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
425
#endif // ZATHURA_H