zathura.c 14 KB
Newer Older
1
2
/* See LICENSE file for license and copyright information */

Moritz Lipp's avatar
Moritz Lipp committed
3
4
#include <stdlib.h>

5
6
#include <girara.h>

7
#include "bookmarks.h"
Moritz Lipp's avatar
Moritz Lipp committed
8
9
#include "callbacks.h"
#include "config.h"
10
#include "database.h"
11
#include "document.h"
Moritz Lipp's avatar
Moritz Lipp committed
12
#include "shortcuts.h"
Moritz Lipp's avatar
Moritz Lipp committed
13
#include "zathura.h"
Moritz Lipp's avatar
Moritz Lipp committed
14
#include "utils.h"
Sebastian Ramacher's avatar
Sebastian Ramacher committed
15
#include "render.h"
Moritz Lipp's avatar
Moritz Lipp committed
16

Moritz Lipp's avatar
Update    
Moritz Lipp committed
17
18
19
20
21
22
23
24
typedef struct zathura_document_info_s
{
  zathura_t* zathura;
  const char* path;
  const char* password;
} zathura_document_info_t;

gboolean document_info_open(gpointer data);
Moritz Lipp's avatar
Moritz Lipp committed
25

Moritz Lipp's avatar
Moritz Lipp committed
26
/* function implementation */
Moritz Lipp's avatar
Moritz Lipp committed
27
28
zathura_t*
zathura_init(int argc, char* argv[])
29
{
Sebastian Ramacher's avatar
Sebastian Ramacher committed
30
31
32
  /* parse command line options */
  GdkNativeWindow embed = 0;
  gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL;
33
  GOptionEntry entries[] =
Sebastian Ramacher's avatar
Sebastian Ramacher committed
34
35
36
37
38
  {
    { "reparent",    'e', 0, G_OPTION_ARG_INT,      &embed,       "Reparents to window specified by xid",       "xid"  },
    { "config-dir",  'c', 0, G_OPTION_ARG_FILENAME, &config_dir,  "Path to the config directory",               "path" },
    { "data-dir",    'd', 0, G_OPTION_ARG_FILENAME, &data_dir,    "Path to the data directory",                 "path" },
    { "plugins-dir", 'p', 0, G_OPTION_ARG_STRING,   &plugin_path, "Path to the directories containing plugins", "path" },
39
    { NULL, '\0', 0, 0, NULL, NULL, NULL }
Sebastian Ramacher's avatar
Sebastian Ramacher committed
40
41
42
43
44
45
46
47
48
49
50
  };

  GOptionContext* context = g_option_context_new(" [file] [password]");
  g_option_context_add_main_entries(context, entries, NULL);

  GError* error = NULL;
  if (!g_option_context_parse(context, &argc, &argv, &error))
  {
    printf("Error parsing command line arguments: %s\n", error->message);
    g_option_context_free(context);
    g_error_free(error);
51
    goto error_free;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
52
53
54
  }
  g_option_context_free(context);

55
56
57
58
59
60
61
62
63
64
65
  zathura_t* zathura = malloc(sizeof(zathura_t));

  if (zathura == NULL) {
    return NULL;
  }

  /* general */
  zathura->document = NULL;

  /* plugins */
  zathura->plugins.plugins = girara_list_new();
Sebastian Ramacher's avatar
Sebastian Ramacher committed
66
67
  girara_list_set_free_function(zathura->plugins.plugins, 
      (girara_free_function_t)zathura_document_plugin_free);
68
69
  zathura->plugins.path    = girara_list_new();
  girara_list_set_free_function(zathura->plugins.path, g_free);
70
  zathura->plugins.type_plugin_mapping = girara_list_new();
Sebastian Ramacher's avatar
Sebastian Ramacher committed
71
72
  girara_list_set_free_function(zathura->plugins.type_plugin_mapping,
      (girara_free_function_t)zathura_type_plugin_mapping_free);
73

Sebastian Ramacher's avatar
Sebastian Ramacher committed
74
75
76
77
78
79
80
81
82
83
84
85
  if (config_dir) {
    zathura->config.config_dir = g_strdup(config_dir);
  } else {
    gchar* path = girara_get_xdg_path(XDG_CONFIG);
    zathura->config.config_dir = g_build_filename(path, "zathura", NULL);
    g_free(path);
  }

  if (data_dir) {
    zathura->config.data_dir = g_strdup(config_dir);
  } else {
    gchar* path = girara_get_xdg_path(XDG_DATA);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
86
    zathura->config.data_dir = g_build_filename(path, "zathura", NULL);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    g_free(path);
  }

  if (plugin_path) {
    gchar** paths = g_strsplit(plugin_path, ":", 0);
    for (unsigned int i = 0; paths[i] != '\0'; ++i) {
      girara_list_append(zathura->plugins.path, g_strdup(paths[i]));
    }
    g_strfreev(paths);
  } else {
    /* XXX: this shouldn't be hard coded! */
    girara_list_append(zathura->plugins.path, g_strdup("/usr/local/lib/zathura"));
    girara_list_append(zathura->plugins.path, g_strdup("/usr/lib/zathura"));
  }

102
  /* UI */
Moritz Lipp's avatar
Moritz Lipp committed
103
  if ((zathura->ui.session = girara_session_create()) == NULL) {
Moritz Lipp's avatar
Moritz Lipp committed
104
    goto error_out;
Moritz Lipp's avatar
Moritz Lipp committed
105
  }
106

Moritz Lipp's avatar
Moritz Lipp committed
107
  zathura->ui.session->global.data  = zathura;
Moritz Lipp's avatar
Moritz Lipp committed
108
109
110
111
112
  zathura->ui.statusbar.file        = NULL;
  zathura->ui.statusbar.buffer      = NULL;
  zathura->ui.statusbar.page_number = NULL;
  zathura->ui.page_view             = NULL;
  zathura->ui.index                 = NULL;
113

Moritz Lipp's avatar
Moritz Lipp committed
114
  /* print settings */
115
116
117
  zathura->print.settings   = NULL;
  zathura->print.page_setup = NULL;

Moritz Lipp's avatar
Moritz Lipp committed
118
119
120
  /* global settings */
  zathura->global.recolor = false;

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  /* load plugins */
  zathura_document_plugins_load(zathura);

  /* configuration */
  config_load_default(zathura);

  /* load global configuration files */
  config_load_file(zathura, GLOBAL_RC);

  /* load local configuration files */
  char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
  config_load_file(zathura, configuration_file);
  free(configuration_file);

  /* initialize girara */
  zathura->ui.session->gtk.embed = embed;
  if (girara_session_init(zathura->ui.session) == false) {
    goto error_out;
  }

  /* girara events */
  zathura->ui.session->events.buffer_changed = buffer_changed;

144
  /* page view */
145
  zathura->ui.page_view = gtk_table_new(0, 0, TRUE);
Moritz Lipp's avatar
Moritz Lipp committed
146
  if (!zathura->ui.page_view) {
147
148
149
    goto error_free;
  }

Moritz Lipp's avatar
Moritz Lipp committed
150
151
152
153
154
155
  /* callbacks */
  GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
  g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
  GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
  g_signal_connect(G_OBJECT(view_hadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);

Moritz Lipp's avatar
Moritz Lipp committed
156
  gtk_widget_show(zathura->ui.page_view);
Moritz Lipp's avatar
Moritz Lipp committed
157

158
  /* statusbar */
Moritz Lipp's avatar
Moritz Lipp committed
159
160
  zathura->ui.statusbar.file = girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL);
  if (zathura->ui.statusbar.file == NULL) {
Moritz Lipp's avatar
Moritz Lipp committed
161
    goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
162
163
  }

Moritz Lipp's avatar
Moritz Lipp committed
164
165
  zathura->ui.statusbar.buffer = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
  if (zathura->ui.statusbar.buffer == NULL) {
Moritz Lipp's avatar
Moritz Lipp committed
166
    goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
167
168
  }

Moritz Lipp's avatar
Moritz Lipp committed
169
170
  zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
  if (!zathura->ui.statusbar.page_number) {
Moritz Lipp's avatar
Moritz Lipp committed
171
    goto error_free;
Moritz Lipp's avatar
Moritz Lipp committed
172
173
  }

Moritz Lipp's avatar
Moritz Lipp committed
174
  girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, "[No Name]");
Moritz Lipp's avatar
Moritz Lipp committed
175

Moritz Lipp's avatar
Moritz Lipp committed
176
  /* signals */
Moritz Lipp's avatar
Moritz Lipp committed
177
  g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL);
178

Moritz Lipp's avatar
Moritz Lipp committed
179
180
181
182
  /* save page padding */
  int* page_padding = girara_setting_get(zathura->ui.session, "page-padding");
  zathura->global.page_padding = (page_padding) ? *page_padding : 1;

Moritz Lipp's avatar
Moritz Lipp committed
183
184
185
  gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
  gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);

Moritz Lipp's avatar
Moritz Lipp committed
186
187
188
189
190
191
192
193
194
195
196
197
198
  /* parse colors */
  char* string_value = girara_setting_get(zathura->ui.session, "recolor-dark-color");
  if (string_value != NULL) {
    gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
    free(string_value);
  }

  string_value = girara_setting_get(zathura->ui.session, "recolor-light-color");
  if (string_value != NULL) {
    gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
    free(string_value);
  }

199
200
201
202
203
204
205
206
  /* database */
  char* database_path = g_build_filename(zathura->config.data_dir, "bookmarks.sqlite", NULL);
  zathura->database = zathura_db_init(database_path);
  if (zathura->database == NULL) {
    girara_error("Unable to inizialize database. Bookmarks won't be available.");
  }
  g_free(database_path);

207
208
209
210
  /* bookmarks */
  zathura->bookmarks.bookmarks = girara_list_new();
  girara_list_set_free_function(zathura->bookmarks.bookmarks, (girara_free_function_t) zathura_bookmark_free);

Moritz Lipp's avatar
Moritz Lipp committed
211
  /* open document if passed */
Moritz Lipp's avatar
Update    
Moritz Lipp committed
212
213
214
215
216
217
218
219
220
221
222
  if (argc > 1) {
    zathura_document_info_t* document_info = malloc(sizeof(zathura_document_info_t));

    if (document_info != NULL) {
      document_info->zathura  = zathura;
      document_info->path     = argv[1];
      document_info->password = (argc >= 2) ? argv[2] : NULL;
      g_idle_add(document_info_open, document_info);
    }
  }

Moritz Lipp's avatar
Moritz Lipp committed
223
  return zathura;
Moritz Lipp's avatar
Moritz Lipp committed
224
225
226

error_free:

Moritz Lipp's avatar
Moritz Lipp committed
227
228
  if (zathura->ui.page_view) {
    g_object_unref(zathura->ui.page_view);
229
230
  }

Moritz Lipp's avatar
Moritz Lipp committed
231
  girara_session_destroy(zathura->ui.session);
232
233
  girara_list_free(zathura->bookmarks.bookmarks);
  zathura_db_free(zathura->database);
Moritz Lipp's avatar
Moritz Lipp committed
234
235
236

error_out:

Moritz Lipp's avatar
Moritz Lipp committed
237
238
  free(zathura);

Moritz Lipp's avatar
Moritz Lipp committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  return NULL;
}

void
zathura_free(zathura_t* zathura)
{
  if (zathura == NULL) {
    return;
  }

  if (zathura->ui.session != NULL) {
    girara_session_destroy(zathura->ui.session);
  }

  document_close(zathura);

255
256
257
  /* bookmarks */
  girara_list_free(zathura->bookmarks.bookmarks);

258
259
260
  /* database */
  zathura_db_free(zathura->database);

261
  /* free print settings */
262
263
264
265
266
267
268
  if(zathura->print.settings != NULL) {
    g_object_unref(zathura->print.settings);
  }

  if (zathura->print.page_setup != NULL) {
    g_object_unref(zathura->print.page_setup);
  }
269

Moritz Lipp's avatar
Moritz Lipp committed
270
  /* free registered plugins */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
271
  girara_list_free(zathura->plugins.plugins);
272
273
274
275
276
  girara_list_free(zathura->plugins.path);

  /* free config variables */
  g_free(zathura->config.config_dir);
  g_free(zathura->config.data_dir);
Moritz Lipp's avatar
Moritz Lipp committed
277
278

  free(zathura);
279
280
}

Moritz Lipp's avatar
Update    
Moritz Lipp committed
281
282
283
284
285
286
287
288
289
290
291
292
gboolean
document_info_open(gpointer data)
{
  zathura_document_info_t* document_info = data;
  g_return_val_if_fail(document_info != NULL, FALSE);

  if (document_info->zathura == NULL || document_info->path == NULL) {
    free(document_info);
    return FALSE;
  }

  document_open(document_info->zathura, document_info->path, document_info->password);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
293
  free(document_info);
Moritz Lipp's avatar
Update    
Moritz Lipp committed
294
295

  return FALSE;
296
297
}

Moritz Lipp's avatar
Moritz Lipp committed
298
bool
Moritz Lipp's avatar
Moritz Lipp committed
299
document_open(zathura_t* zathura, const char* path, const char* password)
Moritz Lipp's avatar
Moritz Lipp committed
300
{
Moritz Lipp's avatar
Moritz Lipp committed
301
  if (!path) {
302
    goto error_out;
Moritz Lipp's avatar
Moritz Lipp committed
303
304
  }

Sebastian Ramacher's avatar
Sebastian Ramacher committed
305
  zathura_document_t* document = zathura_document_open(zathura, path, password);
Moritz Lipp's avatar
Moritz Lipp committed
306

Moritz Lipp's avatar
Moritz Lipp committed
307
  if (!document) {
308
    goto error_out;
Moritz Lipp's avatar
Moritz Lipp committed
309
310
  }

Moritz Lipp's avatar
Moritz Lipp committed
311
  zathura->document = document;
Moritz Lipp's avatar
Moritz Lipp committed
312

313
  /* view mode */
Moritz Lipp's avatar
Moritz Lipp committed
314
  int* value = girara_setting_get(zathura->ui.session, "pages-per-row");
315
316
  int pages_per_row = (value) ? *value : 1;
  free(value);
Moritz Lipp's avatar
Moritz Lipp committed
317
  page_view_set_mode(zathura, pages_per_row);
Moritz Lipp's avatar
Moritz Lipp committed
318

Moritz Lipp's avatar
Moritz Lipp committed
319
  girara_set_view(zathura->ui.session, zathura->ui.page_view);
Moritz Lipp's avatar
Moritz Lipp committed
320

Moritz Lipp's avatar
Moritz Lipp committed
321
  /* threads */
Moritz Lipp's avatar
Moritz Lipp committed
322
  zathura->sync.render_thread = render_init(zathura);
Moritz Lipp's avatar
Moritz Lipp committed
323

Moritz Lipp's avatar
Moritz Lipp committed
324
  if (!zathura->sync.render_thread) {
Moritz Lipp's avatar
Moritz Lipp committed
325
326
327
    goto error_free;
  }

Moritz Lipp's avatar
Moritz Lipp committed
328
  /* create blank pages */
329
  for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
Moritz Lipp's avatar
Moritz Lipp committed
330
331
    zathura_page_t* page = document->pages[page_id];
    gtk_widget_realize(page->event_box);
332
  }
Moritz Lipp's avatar
Moritz Lipp committed
333

334
335
336
337
338
  /* bookmarks */
  if (!zathura_bookmarks_load(zathura, zathura->document->file_path)) {
    girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path);
  }

Moritz Lipp's avatar
Moritz Lipp committed
339
  return true;
340
341
342
343
344
345
346
347

error_free:

  zathura_document_free(document);

error_out:

  return false;
Moritz Lipp's avatar
Moritz Lipp committed
348
349
}

350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
bool
document_save(zathura_t* zathura, const char* path, bool overwrite)
{
  g_return_val_if_fail(zathura, false);
  g_return_val_if_fail(zathura->document, false);
  g_return_val_if_fail(path, false);

  gchar* file_path = girara_fix_path(path);
  if (!overwrite && g_file_test(file_path, G_FILE_TEST_EXISTS))
  {
    gchar* message = g_strdup_printf("File already exists: %s. Use :write! to overwrite it.", file_path);
    girara_error(message);
    g_free(message);
    return false;
  }

  bool res = zathura_document_save_as(zathura->document, file_path);
  g_free(file_path);
  return res;
}

Pavel Borzenkov's avatar
Pavel Borzenkov committed
371
372
373
374
375
376
377
378
379
380
static void
remove_page_from_table(GtkWidget* page, gpointer permanent)
{
  if (!permanent) {
    g_object_ref(G_OBJECT(page));
  }

  gtk_container_remove(GTK_CONTAINER(page->parent), page);
}

Moritz Lipp's avatar
Moritz Lipp committed
381
bool
Moritz Lipp's avatar
Moritz Lipp committed
382
document_close(zathura_t* zathura)
Moritz Lipp's avatar
Moritz Lipp committed
383
{
Moritz Lipp's avatar
Moritz Lipp committed
384
  if (!zathura->document) {
Moritz Lipp's avatar
Moritz Lipp committed
385
386
387
    return false;
  }

Pavel Borzenkov's avatar
Pavel Borzenkov committed
388
389
390
391
  render_free(zathura->sync.render_thread);
  zathura->sync.render_thread = NULL;

  gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_view), remove_page_from_table, (gpointer)1);
Moritz Lipp's avatar
Moritz Lipp committed
392

Moritz Lipp's avatar
Moritz Lipp committed
393
  zathura_document_free(zathura->document);
Pavel Borzenkov's avatar
Pavel Borzenkov committed
394
395
  zathura->document = NULL;

396
397
398
399
400
401
402
  gtk_widget_hide(zathura->ui.page_view);

  statusbar_page_number_update(zathura);

  if (zathura->ui.session != NULL && zathura->ui.statusbar.file != NULL) {
    girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, "[No name]");
  }
Moritz Lipp's avatar
Moritz Lipp committed
403
404
405
406
407

  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
408
page_set(zathura_t* zathura, unsigned int page_id)
Moritz Lipp's avatar
Moritz Lipp committed
409
{
410
  if (zathura == NULL || zathura->document == NULL || zathura->document->pages == NULL) {
Moritz Lipp's avatar
Moritz Lipp committed
411
    goto error_out;
Moritz Lipp's avatar
Moritz Lipp committed
412
413
  }

Moritz Lipp's avatar
Moritz Lipp committed
414
  if (page_id >= zathura->document->number_of_pages) {
Moritz Lipp's avatar
Moritz Lipp committed
415
    goto error_out;
Moritz Lipp's avatar
Moritz Lipp committed
416
417
  }

418
  /* render page */
Moritz Lipp's avatar
Moritz Lipp committed
419
  zathura_page_t* page = zathura->document->pages[page_id];
Moritz Lipp's avatar
Moritz Lipp committed
420

Moritz Lipp's avatar
Moritz Lipp committed
421
  if (!page) {
422
423
424
    goto error_out;
  }

Moritz Lipp's avatar
Moritz Lipp committed
425
426
427
428
429
  page_offset_t* offset = page_calculate_offset(page);
  if (offset == NULL) {
    goto error_out;
  }

Moritz Lipp's avatar
Moritz Lipp committed
430
  GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
Moritz Lipp's avatar
Moritz Lipp committed
431
432
433
  GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
  gtk_adjustment_set_value(view_hadjustment, offset->x);
  gtk_adjustment_set_value(view_vadjustment, offset->y);
434
435

  /* update page number */
Moritz Lipp's avatar
Moritz Lipp committed
436
  zathura->document->current_page_number = page_id;
437
  statusbar_page_number_update(zathura);
Moritz Lipp's avatar
Moritz Lipp committed
438
439

  return true;
Moritz Lipp's avatar
Moritz Lipp committed
440
441
442
443

error_out:

  return false;
Moritz Lipp's avatar
Moritz Lipp committed
444
445
}

446
447
448
449
450
451
452
void
statusbar_page_number_update(zathura_t* zathura)
{
  if (zathura == NULL || zathura->ui.statusbar.page_number == NULL) {
    return;
  }

453
454
455
456
457
458
459
  if (zathura->document != NULL) {
    char* page_number_text = g_strdup_printf("[%d/%d]", zathura->document->current_page_number + 1, zathura->document->number_of_pages);
    girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, page_number_text);
    g_free(page_number_text);
  } else {
    girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, "");
  }
460
461
}

462
void
Moritz Lipp's avatar
Moritz Lipp committed
463
page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
464
{
Moritz Lipp's avatar
Moritz Lipp committed
465
466
467
468
469
  /* show at least one page */
  if (pages_per_row == 0) {
    pages_per_row = 1;
  }

470
471
472
473
  if (zathura->document == NULL) {
    return;
  }

Pavel Borzenkov's avatar
Pavel Borzenkov committed
474
  gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_view), remove_page_from_table, (gpointer)0);
475

476
  gtk_table_resize(GTK_TABLE(zathura->ui.page_view), zathura->document->number_of_pages / pages_per_row + 1, pages_per_row);
Moritz Lipp's avatar
Moritz Lipp committed
477
  for (unsigned int i = 0; i < zathura->document->number_of_pages; i++)
478
  {
479
480
    int x = i % pages_per_row;
    int y = i / pages_per_row;
Moritz Lipp's avatar
Moritz Lipp committed
481
    gtk_table_attach(GTK_TABLE(zathura->ui.page_view), zathura->document->pages[i]->event_box, x, x + 1, y, y + 1, GTK_EXPAND, GTK_EXPAND, 0, 0);
482
483
  }

Moritz Lipp's avatar
Moritz Lipp committed
484
  gtk_widget_show_all(zathura->ui.page_view);
485
486
}

Moritz Lipp's avatar
Moritz Lipp committed
487
/* main function */
488
int main(int argc, char* argv[])
Moritz Lipp's avatar
Moritz Lipp committed
489
{
490
491
  g_thread_init(NULL);
  gdk_threads_init();
Moritz Lipp's avatar
Moritz Lipp committed
492
493
  gtk_init(&argc, &argv);

Moritz Lipp's avatar
Moritz Lipp committed
494
495
  zathura_t* zathura = zathura_init(argc, argv);
  if (zathura == NULL) {
Moritz Lipp's avatar
Moritz Lipp committed
496
497
498
    printf("error: coult not initialize zathura\n");
    return -1;
  }
Moritz Lipp's avatar
Moritz Lipp committed
499

Moritz Lipp's avatar
Moritz Lipp committed
500
501
502
  gdk_threads_enter();
  gtk_main();
  gdk_threads_leave();
503

Moritz Lipp's avatar
Moritz Lipp committed
504
505
  zathura_free(zathura);

Moritz Lipp's avatar
Moritz Lipp committed
506
507
  return 0;
}