zathura.h 5.08 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
#include <girara/types.h>
Sebastian Ramacher's avatar
Sebastian Ramacher committed
8
#include <girara/macros.h>
9
#include <gtk/gtk.h>
Moritz Lipp's avatar
Moritz Lipp committed
10

Sebastian Ramacher's avatar
Sebastian Ramacher committed
11
#define UNUSED(x) GIRARA_UNUSED(x)
12

Moritz Lipp's avatar
Moritz Lipp committed
13
14
15
16
17
18
19
20
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, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST,
  ADD_MARKER, EVAL_MARKER, EXPAND, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS,
  GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR,
  DELETE_TO_LINE_START, APPEND_FILEPATH };

Sebastian Ramacher's avatar
Sebastian Ramacher committed
21
22
23
24
25
26
/* forward declaration for types from document.h */
struct zathura_document_s;
struct zathura_page_s;
typedef struct zathura_document_s zathura_document_t;
typedef struct zathura_page_s zathura_page_t;

27
28
29
30
/* forward declaration for types form database.h */
struct zathura_database_s;
typedef struct zathura_database_s zathura_database_t;

Sebastian Ramacher's avatar
Sebastian Ramacher committed
31
32
33
34
/* forward declaration for types from render.h */
struct render_thread_s;
typedef struct render_thread_s render_thread_t;

Moritz Lipp's avatar
Moritz Lipp committed
35
typedef struct zathura_s
Moritz Lipp's avatar
Moritz Lipp committed
36
{
Moritz Lipp's avatar
Moritz Lipp committed
37
  struct
Moritz Lipp's avatar
Moritz Lipp committed
38
39
  {
    girara_session_t* session; /**> girara interface session */
Moritz Lipp's avatar
Moritz Lipp committed
40
41
42
43
44
45
46

    struct
    {
      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 */
    } statusbar;
Moritz Lipp's avatar
Moritz Lipp committed
47

Moritz Lipp's avatar
Moritz Lipp committed
48
49
50
51
52
53
    struct
    {
      GdkColor recolor_dark_color; /**> Dark color for recoloring */
      GdkColor recolor_light_color; /**> Light color for recoloring */
    } colors;

54
    GtkWidget *page_view_alignment;
Moritz Lipp's avatar
Moritz Lipp committed
55
    GtkWidget *page_view; /**> Widget that contains all rendered pages */
56
    GtkWidget *index; /**> Widget to show the index of the document */
Moritz Lipp's avatar
Moritz Lipp committed
57
  } ui;
Moritz Lipp's avatar
Moritz Lipp committed
58

Moritz Lipp's avatar
Moritz Lipp committed
59
60
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
61
    render_thread_t* render_thread; /**> The thread responsible for rendering the pages */
Moritz Lipp's avatar
Moritz Lipp committed
62
  } sync;
Moritz Lipp's avatar
Moritz Lipp committed
63

Sebastian Ramacher's avatar
Sebastian Ramacher committed
64
65
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
66
67
    girara_list_t* plugins; /**> List of plugins */
    girara_list_t* path; /**> List of plugin paths */
68
    girara_list_t* type_plugin_mapping; /**> List of type -> plugin mappings */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
69
70
  } plugins;

71
72
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
73
74
    gchar* config_dir; /**> Path to the configuration directory */
    gchar* data_dir; /**> Path to the data directory */
75
76
  } config;

77
78
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
79
80
    GtkPrintSettings* settings; /**> Print settings */
    GtkPageSetup* page_setup; /**> Saved page setup */
81
82
  } print;

Moritz Lipp's avatar
Moritz Lipp committed
83
84
  struct
  {
Moritz Lipp's avatar
Moritz Lipp committed
85
86
    unsigned int page_padding; /**> Padding between the pages */
    bool recolor; /**> Recoloring mode switch */
Moritz Lipp's avatar
Moritz Lipp committed
87
88
  } global;

Pavel Borzenkov's avatar
Pavel Borzenkov committed
89
90
91
92
93
94
95
  struct
  {
    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;
Moritz Lipp's avatar
Moritz Lipp committed
96

97
98
99
100
101
102
  struct
  {
    gchar* file; /**> bookmarks file */
    girara_list_t* bookmarks; /**> bookmarks */
  } bookmarks;

103
104
105
106
107
  struct
  {
    gchar* file;
  } stdin_support;

Moritz Lipp's avatar
Moritz Lipp committed
108
  zathura_document_t* document; /**> The current document */
109
  zathura_database_t* database; /**> The database */
Moritz Lipp's avatar
Moritz Lipp committed
110
} zathura_t;
Moritz Lipp's avatar
Moritz Lipp committed
111
112
113
114

/**
 * Initializes zathura
 *
Moritz Lipp's avatar
Moritz Lipp committed
115
116
 * @param argc Number of arguments
 * @param argv Values of arguments
117
 * @return zathura session object or NULL if zathura could not been initialized
Moritz Lipp's avatar
Moritz Lipp committed
118
119
120
121
 */
zathura_t* zathura_init(int argc, char* argv[]);

/**
122
 * Free zathura session
Moritz Lipp's avatar
Moritz Lipp committed
123
 *
124
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
125
 */
Moritz Lipp's avatar
Moritz Lipp committed
126
void zathura_free(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
127

Moritz Lipp's avatar
Moritz Lipp committed
128
129
130
/**
 * Opens a file
 *
131
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
132
133
134
135
136
 * @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
137
bool document_open(zathura_t* zathura, const char* path, const char* password);
Moritz Lipp's avatar
Moritz Lipp committed
138

139
140
141
142
143
144
145
146
147
148
149
/**
 * 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
150
151
152
/**
 * Closes the current opened document
 *
153
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
154
155
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
156
bool document_close(zathura_t* zathura);
Moritz Lipp's avatar
Moritz Lipp committed
157
158
159
160

/**
 * Opens the page with the given number
 *
161
 * @param zathura The zathura session
Moritz Lipp's avatar
Moritz Lipp committed
162
163
 * @return If no error occured true, otherwise false, is returned.
 */
Moritz Lipp's avatar
Moritz Lipp committed
164
bool page_set(zathura_t* zathura, unsigned int page_id);
Moritz Lipp's avatar
Moritz Lipp committed
165

166
167
168
169
170
171
172
173
/**
 * Opens the page with the given number (delayed)
 *
 * @param zathura The zathura session
 * @return If no error occured true, otherwise false, is returned.
 */
bool page_set_delayed(zathura_t* zathura, unsigned int page_id);

174
175
176
/**
 * Builds the box structure to show the rendered pages
 *
177
 * @param zathura The zathura session
178
179
 * @param pages_per_row Number of shown pages per row
 */
Moritz Lipp's avatar
Moritz Lipp committed
180
void page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row);
181

182
183
184
185
186
187
188
189
/**
 * 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);

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