config.c 42.2 KB
Newer Older
1
/* SPDX-License-Identifier: Zlib */
2

3
#include "config.h"
4 5
#include "commands.h"
#include "completion.h"
6
#include "callbacks.h"
7 8
#include "shortcuts.h"
#include "zathura.h"
9
#include "render.h"
Moritz Lipp's avatar
Moritz Lipp committed
10
#include "marks.h"
11
#include "utils.h"
12

13 14 15 16 17
#include <girara/settings.h>
#include <girara/session.h>
#include <girara/shortcuts.h>
#include <girara/config.h>
#include <girara/commands.h>
18
#include <girara/utils.h>
19
#include <glib/gi18n.h>
20

21 22 23
#define GLOBAL_RC  "/etc/zathurarc"
#define ZATHURA_RC "zathurarc"

24 25
static void
cb_jumplist_change(girara_session_t* session, const char* name,
Moritz Lipp's avatar
Moritz Lipp committed
26
                   girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
27 28 29 30 31 32
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);
  g_return_if_fail(name != NULL);
  zathura_t* zathura = session->global.data;
33

Sebastian Ramacher's avatar
Sebastian Ramacher committed
34 35 36
  const int* ivalue = value;

  if (*ivalue < 0) {
37 38
    zathura->jumplist.max_size = 0;
  } else {
Sebastian Ramacher's avatar
Sebastian Ramacher committed
39
    zathura->jumplist.max_size = *ivalue;
40
  }
41

42 43 44
  if (zathura->jumplist.list != NULL && zathura->jumplist.size != 0) {
    zathura_jumplist_trim(zathura);
  }
45 46
}

47
static void
48
cb_color_change(girara_session_t* session, const char* name,
Moritz Lipp's avatar
Moritz Lipp committed
49
                girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
50 51 52 53 54 55 56
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);
  g_return_if_fail(name != NULL);
  zathura_t* zathura = session->global.data;

Sebastian Ramacher's avatar
Sebastian Ramacher committed
57
  const char* string_value = (const char*) value;
58
  if (g_strcmp0(name, "highlight-color") == 0) {
59
    parse_color(&zathura->ui.colors.highlight_color, string_value);
60
  } else if (g_strcmp0(name, "highlight-active-color") == 0) {
61
    parse_color(&zathura->ui.colors.highlight_color_active, string_value);
62
  } else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
63 64 65
    if (zathura->sync.render_thread != NULL) {
      zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value);
    }
66
  } else if (g_strcmp0(name, "recolor-lightcolor") == 0) {
67 68 69
    if (zathura->sync.render_thread != NULL) {
      zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL);
    }
70
  } else if (g_strcmp0(name, "render-loading-bg") == 0) {
71
    parse_color(&zathura->ui.colors.render_loading_bg, string_value);
72
  } else if (g_strcmp0(name, "render-loading-fg") == 0) {
73
    parse_color(&zathura->ui.colors.render_loading_fg, string_value);
74 75
  }

76
  render_all(zathura);
77 78
}

79 80
static void
cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name),
Moritz Lipp's avatar
Moritz Lipp committed
81
                      girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
82 83 84 85 86 87
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);
  zathura_t* zathura = session->global.data;

Sebastian Ramacher's avatar
Sebastian Ramacher committed
88 89
  bool* bvalue = value;
  document_draw_search_results(zathura, !*bvalue);
90 91 92
  render_all(zathura);
}

93 94
static void
cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
Moritz Lipp's avatar
Moritz Lipp committed
95
                     girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
96 97 98 99 100 101 102 103 104 105
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);

  bool inc_search = *(bool*) value;
  girara_special_command_add(session, '/', cmd_search, inc_search, FORWARD,  NULL);
  girara_special_command_add(session, '?', cmd_search, inc_search, BACKWARD, NULL);
}

Sebastian Ramacher's avatar
Sebastian Ramacher committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
static void
cb_sandbox_changed(girara_session_t* session, const char* UNUSED(name),
                   girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);
  zathura_t* zathura = session->global.data;

  const char* sandbox = value;
  if (g_strcmp0(sandbox, "none") == 0) {
    zathura->global.sandbox = ZATHURA_SANDBOX_NONE;
  } else if (g_strcmp0(sandbox, "normal") == 0)  {
    zathura->global.sandbox = ZATHURA_SANDBOX_NORMAL;
  } else if (g_strcmp0(sandbox, "strict") == 0) {
    zathura->global.sandbox = ZATHURA_SANDBOX_STRICT;
  } else {
    girara_error("Invalid sandbox option");
  }
}
126

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
static void
cb_window_statbusbar_changed(girara_session_t* session, const char* name,
                             girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
  g_return_if_fail(value != NULL);
  g_return_if_fail(session != NULL);
  g_return_if_fail(session->global.data != NULL);
  zathura_t* zathura = session->global.data;

  const bool is_window_setting = g_str_has_prefix(name, "window-");
  if (is_window_setting) {
    char* formatted_filename = get_formatted_filename(zathura, !is_window_setting);
    girara_set_window_title(zathura->ui.session, formatted_filename);
    g_free(formatted_filename);
  } else {
    statusbar_page_number_update(zathura);
  }
}

146
void
147
config_load_default(zathura_t* zathura)
148
{
Moritz Lipp's avatar
Moritz Lipp committed
149
  if (zathura == NULL || zathura->ui.session == NULL) {
150
    return;
151
  }
152

153
  int int_value              = 0;
154
  float float_value          = 0;
155
  bool bool_value            = false;
156
  char* string_value         = NULL;
157
  girara_session_t* gsession = zathura->ui.session;
Moritz Lipp's avatar
Moritz Lipp committed
158

Moritz Lipp's avatar
Moritz Lipp committed
159
  /* mode settings */
160 161 162 163 164
  zathura->modes.normal       = gsession->modes.normal;
  zathura->modes.fullscreen   = girara_mode_add(gsession, "fullscreen");
  zathura->modes.index        = girara_mode_add(gsession, "index");
  zathura->modes.insert       = girara_mode_add(gsession, "insert");
  zathura->modes.presentation = girara_mode_add(gsession, "presentation");
Moritz Lipp's avatar
Moritz Lipp committed
165 166 167 168 169

#define NORMAL zathura->modes.normal
#define INSERT zathura->modes.insert
#define INDEX zathura->modes.index
#define FULLSCREEN zathura->modes.fullscreen
170
#define PRESENTATION zathura->modes.presentation
Moritz Lipp's avatar
Moritz Lipp committed
171

172 173 174 175 176 177 178 179
  const girara_mode_t all_modes[] = {
    NORMAL,
    INSERT,
    INDEX,
    FULLSCREEN,
    PRESENTATION
  };

180
  /* Set default mode */
Moritz Lipp's avatar
Moritz Lipp committed
181
  girara_mode_set(gsession, zathura->modes.normal);
182

183
  /* zathura settings */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
184
  girara_setting_add(gsession, "database",              "plain",      STRING, true,  _("Database backend"),         NULL, NULL);
185
  girara_setting_add(gsession, "filemonitor",           "glib",       STRING, true,  _("File monitor backend"),     NULL, NULL);
Moritz Lipp's avatar
Moritz Lipp committed
186
  int_value = 10;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
187
  girara_setting_add(gsession, "zoom-step",             &int_value,   INT,    false, _("Zoom step"),                NULL, NULL);
Moritz Lipp's avatar
Moritz Lipp committed
188
  int_value = 1;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
189
  girara_setting_add(gsession, "page-padding",          &int_value,   INT,    false, _("Padding between pages"),    cb_page_layout_value_changed, NULL);
190
  int_value = 1;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
191
  girara_setting_add(gsession, "pages-per-row",         &int_value,   INT,    false, _("Number of pages per row"),  cb_page_layout_value_changed, NULL);
192
  int_value = 1;
193
  girara_setting_add(gsession, "first-page-column",     "1:2",        STRING, false, _("Column of the first page"), cb_page_layout_value_changed, NULL);
194 195
  bool_value = false;
  girara_setting_add(gsession, "page-right-to-left",    &bool_value,  BOOLEAN, false, _("Render pages from right to left"),  cb_page_layout_value_changed, NULL);
196
  float_value = 40;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
197
  girara_setting_add(gsession, "scroll-step",           &float_value, FLOAT,  false, _("Scroll step"),              NULL, NULL);
198
  float_value = 40;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
199
  girara_setting_add(gsession, "scroll-hstep",          &float_value, FLOAT,  false, _("Horizontal scroll step"),   NULL, NULL);
200
  float_value = 0.0;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
201
  girara_setting_add(gsession, "scroll-full-overlap",   &float_value, FLOAT,  false, _("Full page scroll overlap"), NULL, NULL);
202
  int_value = 10;
203
  girara_setting_add(gsession, "zoom-min",              &int_value,   INT,    false, _("Zoom minimum"), NULL, NULL);
204
  int_value = 1000;
205
  girara_setting_add(gsession, "zoom-max",              &int_value,   INT,    false, _("Zoom maximum"), NULL, NULL);
206
  int_value = ZATHURA_PAGE_CACHE_DEFAULT_SIZE;
Sebastian Ramacher's avatar
Sebastian Ramacher committed
207
  girara_setting_add(gsession, "page-cache-size",       &int_value,   INT,    true,  _("Maximum number of pages to keep in the cache"), NULL, NULL);
208 209
  int_value = ZATHURA_PAGE_THUMBNAIL_DEFAULT_SIZE;
  girara_setting_add(gsession, "page-thumbnail-size",   &int_value,   INT,    true,  _("Maximum size in pixels of thumbnails to keep in the cache"), NULL, NULL);
210
  int_value = 2000;
211
  girara_setting_add(gsession, "jumplist-size",         &int_value,   INT,    false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL);
212

213 214
  girara_setting_add(gsession, "recolor-darkcolor",      "#FFFFFF", STRING, false, _("Recoloring (dark color)"),         cb_color_change, NULL);
  girara_setting_add(gsession, "recolor-lightcolor",     "#000000", STRING, false, _("Recoloring (light color)"),        cb_color_change, NULL);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
215
  girara_setting_add(gsession, "highlight-color",        NULL,      STRING, false, _("Color for highlighting"),          cb_color_change, NULL);
216
  girara_setting_set(gsession, "highlight-color",        "#9FBC00");
Sebastian Ramacher's avatar
Sebastian Ramacher committed
217
  girara_setting_add(gsession, "highlight-active-color", NULL,      STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
218
  girara_setting_set(gsession, "highlight-active-color", "#00BC00");
Sebastian Ramacher's avatar
Sebastian Ramacher committed
219
  girara_setting_add(gsession, "render-loading-bg",      NULL,      STRING, false, _("'Loading ...' background color"),  cb_color_change, NULL);
220
  girara_setting_set(gsession, "render-loading-bg",      "#FFFFFF");
Sebastian Ramacher's avatar
Sebastian Ramacher committed
221
  girara_setting_add(gsession, "render-loading-fg",      NULL,      STRING, false, _("'Loading ...' foreground color"),  cb_color_change, NULL);
222
  girara_setting_set(gsession, "render-loading-fg",      "#000000");
223

224 225 226 227 228
  girara_setting_add(gsession, "index-fg",        "#DDDDDD", STRING, true, _("Index mode foreground color"), NULL, NULL);
  girara_setting_add(gsession, "index-bg",        "#232323", STRING, true, _("Index mode background color"), NULL, NULL);
  girara_setting_add(gsession, "index-active-fg", "#232323", STRING, true, _("Index mode foreground color (active element)"), NULL, NULL);
  girara_setting_add(gsession, "index-active-bg", "#9FBC00", STRING, true, _("Index mode background color (active element)"), NULL, NULL);

Moritz Lipp's avatar
Moritz Lipp committed
229 230
  bool_value = false;
  girara_setting_add(gsession, "recolor",                &bool_value,  BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
231
  bool_value = false;
232 233
  girara_setting_add(gsession, "recolor-keephue",        &bool_value,  BOOLEAN, false, _("When recoloring keep original hue and adjust lightness only"), cb_setting_recolor_keep_hue_change, NULL);
  bool_value = false;
234 235
  girara_setting_add(gsession, "recolor-reverse-video",  &bool_value,  BOOLEAN, false, _("When recoloring keep original image colors"), cb_setting_recolor_keep_reverse_video_change, NULL);
  bool_value = false;
236
  girara_setting_add(gsession, "scroll-wrap",            &bool_value,  BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
237
  bool_value = false;
238
  girara_setting_add(gsession, "scroll-page-aware",      &bool_value,  BOOLEAN, false, _("Page aware scrolling"), NULL, NULL);
239
  bool_value = true;
240
  girara_setting_add(gsession, "advance-pages-per-row",  &bool_value,  BOOLEAN, false, _("Advance number of pages per row"), NULL, NULL);
Julian Orth's avatar
Julian Orth committed
241 242
  bool_value = false;
  girara_setting_add(gsession, "zoom-center",            &bool_value,  BOOLEAN, false, _("Horizontally centered zoom"), NULL, NULL);
243 244
  bool_value = false;
  girara_setting_add(gsession, "vertical-center",        &bool_value,  BOOLEAN, false, _("Vertically center pages"), NULL, NULL);
Julian Orth's avatar
Julian Orth committed
245
  bool_value = true;
246 247
  girara_setting_add(gsession, "link-hadjust",           &bool_value,  BOOLEAN, false, _("Align link target to the left"), NULL, NULL);
  bool_value = true;
248 249
  girara_setting_add(gsession, "link-zoom",              &bool_value,  BOOLEAN, false, _("Let zoom be changed when following links"), NULL, NULL);
  bool_value = true;
Julian Orth's avatar
Julian Orth committed
250
  girara_setting_add(gsession, "search-hadjust",         &bool_value,  BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
251
  float_value = 0.5;
252
  girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT,   false, _("Transparency for highlighting"), NULL, NULL);
253
  bool_value = true;
254
  girara_setting_add(gsession, "render-loading",         &bool_value,  BOOLEAN, false, _("Render 'Loading ...'"), NULL, NULL);
255
  girara_setting_add(gsession, "adjust-open",            "best-fit",   STRING,  false, _("Adjust to when opening file"), NULL, NULL);
256
  bool_value = false;
257
  girara_setting_add(gsession, "show-hidden",            &bool_value,  BOOLEAN, false, _("Show hidden files and directories"), NULL, NULL);
258
  bool_value = true;
259
  girara_setting_add(gsession, "show-directories",       &bool_value,  BOOLEAN, false, _("Show directories"), NULL, NULL);
260 261
  int_value = 10;
  girara_setting_add(gsession, "show-recent",            &int_value,   INT,     false, _("Show recent files"), NULL, NULL);
262 263
  bool_value = false;
  girara_setting_add(gsession, "open-first-page",        &bool_value,  BOOLEAN, false, _("Always open on first page"), NULL, NULL);
264 265
  bool_value = false;
  girara_setting_add(gsession, "nohlsearch",             &bool_value,  BOOLEAN, false, _("Highlight search results"), cb_nohlsearch_changed, NULL);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
266 267 268
#define INCREMENTAL_SEARCH false
  bool_value = INCREMENTAL_SEARCH;
  girara_setting_add(gsession, "incremental-search",     &bool_value,  BOOLEAN, false, _("Enable incremental search"), cb_incsearch_changed, NULL);
269 270
  bool_value = true;
  girara_setting_add(gsession, "abort-clear-search",     &bool_value,  BOOLEAN, false, _("Clear search results on abort"), NULL, NULL);
271
  bool_value = false;
272
  girara_setting_add(gsession, "window-title-basename",  &bool_value,  BOOLEAN, false, _("Use basename of the file in the window title"), cb_window_statbusbar_changed, NULL);
Moritz Lipp's avatar
Moritz Lipp committed
273
  bool_value = false;
274
  girara_setting_add(gsession, "window-title-home-tilde",  &bool_value,  BOOLEAN, false, _("Use ~ instead of $HOME in the filename in the window title"), cb_window_statbusbar_changed, NULL);
275
  bool_value = false;
276
  girara_setting_add(gsession, "window-title-page",      &bool_value,  BOOLEAN, false, _("Display the page number in the window title"), cb_window_statbusbar_changed, NULL);
277
  bool_value = false;
278 279
  girara_setting_add(gsession, "window-icon-document",   &bool_value,  BOOLEAN, false, _("Use first page of a document as window icon"), NULL, NULL);
  bool_value = false;
280
  girara_setting_add(gsession, "statusbar-basename",     &bool_value,  BOOLEAN, false, _("Use basename of the file in the statusbar"), cb_window_statbusbar_changed, NULL);
281
  bool_value = false;
282
  girara_setting_add(gsession, "statusbar-home-tilde",  &bool_value,  BOOLEAN, false, _("Use ~ instead of $HOME in the filename in the statusbar"), cb_window_statbusbar_changed, NULL);
283
  bool_value = true;
284
  girara_setting_add(gsession, "synctex",                &bool_value,  BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
285 286
  string_value = "";
  girara_setting_add(gsession, "synctex-editor-command", string_value, STRING,  false, _("Synctex editor command"), NULL, NULL);
287
  bool_value = true;
288
  girara_setting_add(gsession, "dbus-service",           &bool_value,  BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL);
289 290
  bool_value = false;
  girara_setting_add(gsession, "continuous-hist-save",   &bool_value,  BOOLEAN, false, _("Save history at each page change"), NULL, NULL);
291
  string_value = "primary";
292
  girara_setting_add(gsession, "selection-clipboard",    string_value, STRING,  false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL);
293 294
  bool_value = true;
  girara_setting_add(gsession, "selection-notification", &bool_value,  BOOLEAN, false, _("Enable notification after selecting text"), NULL, NULL);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
295
  girara_setting_add(gsession, "sandbox",                "normal",     STRING, true,   _("Sandbox level"), cb_sandbox_changed, NULL);
296

297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 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
#define DEFAULT_SHORTCUTS(mode) \
  girara_shortcut_add(gsession, 0,                GDK_KEY_a,          NULL, sc_adjust_window,           (mode),     ZATHURA_ADJUST_BESTFIT, NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_s,          NULL, sc_adjust_window,           (mode),     ZATHURA_ADJUST_WIDTH,   NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_F,          NULL, sc_display_link,            (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_slash,      NULL, sc_focus_inputbar,          (mode),     0,                      &("/")); \
  girara_shortcut_add(gsession, GDK_SHIFT_MASK,   GDK_KEY_slash,      NULL, sc_focus_inputbar,          (mode),     0,                      &("/")); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_question,   NULL, sc_focus_inputbar,          (mode),     0,                      &("?")); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_colon,      NULL, sc_focus_inputbar,          (mode),     0,                      &(":")); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_o,          NULL, sc_focus_inputbar,          (mode),     0,                      &(":open ")); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_O,          NULL, sc_focus_inputbar,          (mode),     APPEND_FILEPATH,        &(":open ")); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_f,          NULL, sc_follow,                  (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                0,                  "gg", sc_goto,                    (mode),     TOP,                    NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "G",  sc_goto,                    (mode),     BOTTOM,                 NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_m,          NULL, sc_mark_add,                (mode),     0,                      NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_apostrophe, NULL, sc_mark_evaluate,           (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_J,          NULL, sc_navigate,                (mode),     NEXT,                   NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_K,          NULL, sc_navigate,                (mode),     PREVIOUS,               NULL); \
  girara_shortcut_add(gsession, GDK_MOD1_MASK,    GDK_KEY_Right,      NULL, sc_navigate,                (mode),     NEXT,                   NULL); \
  girara_shortcut_add(gsession, GDK_MOD1_MASK,    GDK_KEY_Left,       NULL, sc_navigate,                (mode),     PREVIOUS,               NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_Page_Down,  NULL, sc_navigate,                (mode),     NEXT,                   NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_Page_Up,    NULL, sc_navigate,                (mode),     PREVIOUS,               NULL); \
\
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_p,          NULL, sc_print,                   (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_r,          NULL, sc_recolor,                 (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_R,          NULL, sc_reload,                  (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_r,          NULL, sc_rotate,                  (mode),     ROTATE_CW,              NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_h,          NULL, sc_scroll,                  (mode),     LEFT,                   NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_j,          NULL, sc_scroll,                  (mode),     DOWN,                   NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_k,          NULL, sc_scroll,                  (mode),     UP,                     NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_l,          NULL, sc_scroll,                  (mode),     RIGHT,                  NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_Left,       NULL, sc_scroll,                  (mode),     LEFT,                   NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_Up,         NULL, sc_scroll,                  (mode),     UP,                     NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_Down,       NULL, sc_scroll,                  (mode),     DOWN,                   NULL); \
340 341
  girara_shortcut_add(gsession, 0,                GDK_KEY_H,          NULL, sc_scroll,                  (mode),     PAGE_TOP,               NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_L,          NULL, sc_scroll,                  (mode),     PAGE_BOTTOM,            NULL); \
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
  girara_shortcut_add(gsession, 0,                GDK_KEY_Right,      NULL, sc_scroll,                  (mode),     RIGHT,                  NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_t,          NULL, sc_scroll,                  (mode),     HALF_LEFT,              NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_d,          NULL, sc_scroll,                  (mode),     HALF_DOWN,              NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_u,          NULL, sc_scroll,                  (mode),     HALF_UP,                NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_y,          NULL, sc_scroll,                  (mode),     HALF_RIGHT,             NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_t,          NULL, sc_scroll,                  (mode),     FULL_LEFT,              NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_f,          NULL, sc_scroll,                  (mode),     FULL_DOWN,              NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_b,          NULL, sc_scroll,                  (mode),     FULL_UP,                NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_y,          NULL, sc_scroll,                  (mode),     FULL_RIGHT,             NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_space,      NULL, sc_scroll,                  (mode),     FULL_DOWN,              NULL); \
  girara_shortcut_add(gsession, GDK_SHIFT_MASK,   GDK_KEY_space,      NULL, sc_scroll,                  (mode),     FULL_UP,                NULL); \
\
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_o,          NULL, sc_jumplist,                (mode),     BACKWARD,               NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i,          NULL, sc_jumplist,                (mode),     FORWARD,                NULL); \
\
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_j,          NULL, sc_bisect,                  (mode),     FORWARD,                NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_k,          NULL, sc_bisect,                  (mode),     BACKWARD,               NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_n,          NULL, sc_search,                  (mode),     FORWARD,                NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_N,          NULL, sc_search,                  (mode),     BACKWARD,               NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_Tab,        NULL, sc_toggle_index,            (mode),     0,                      NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_n,          NULL, girara_sc_toggle_statusbar, (mode),     0,                      NULL); \
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_m,          NULL, girara_sc_toggle_inputbar,  (mode),     0,                      NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_d,          NULL, sc_toggle_page_mode,        (mode),     0,                      NULL); \
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_q,          NULL, sc_quit,                    (mode),     0,                      NULL); \
369 370 371 372 373 374 375 376 377 378 379 380 381
\
  girara_shortcut_add(gsession, 0,                GDK_KEY_plus,       NULL, sc_zoom,                    (mode),     ZOOM_IN,                NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_KP_Add,     NULL, sc_zoom,                    (mode),     ZOOM_IN,                NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_minus,      NULL, sc_zoom,                    (mode),     ZOOM_OUT,               NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_KP_Subtract,NULL, sc_zoom,                    (mode),     ZOOM_OUT,               NULL); \
  girara_shortcut_add(gsession, 0,                GDK_KEY_equal,      NULL, sc_zoom,                    (mode),     ZOOM_SPECIFIC,          NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zi", sc_zoom,                    (mode),     ZOOM_IN,                NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zI", sc_zoom,                    (mode),     ZOOM_IN,                NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zo", sc_zoom,                    (mode),     ZOOM_OUT,               NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zO", sc_zoom,                    (mode),     ZOOM_OUT,               NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "z0", sc_zoom,                    (mode),     ZOOM_ORIGINAL,          NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zz", sc_zoom,                    (mode),     ZOOM_SPECIFIC,          NULL); \
  girara_shortcut_add(gsession, 0,                0,                  "zZ", sc_zoom,                    (mode),     ZOOM_SPECIFIC,          NULL);
382 383

#define DEFAULT_MOUSE_EVENTS(mode) \
384 385 386 387 388
  girara_mouse_event_add(gsession, 0, 0,                                   sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_UP,            UP,            NULL); \
  girara_mouse_event_add(gsession, 0, 0,                                   sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_DOWN,          DOWN,          NULL); \
  girara_mouse_event_add(gsession, 0, 0,                                   sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_LEFT,          LEFT,          NULL); \
  girara_mouse_event_add(gsession, 0, 0,                                   sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_RIGHT,         RIGHT,         NULL); \
  girara_mouse_event_add(gsession, 0, 0,                                   sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_BIDIRECTIONAL, BIDIRECTIONAL, NULL); \
389 390 391 392
\
  girara_mouse_event_add(gsession, GDK_SHIFT_MASK, 0,                      sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_UP,      LEFT,  NULL); \
  girara_mouse_event_add(gsession, GDK_SHIFT_MASK, 0,                      sc_mouse_scroll, (mode),     GIRARA_EVENT_SCROLL_DOWN,    RIGHT, NULL); \
\
393 394 395
  girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0,                    sc_mouse_zoom,   (mode),     GIRARA_EVENT_SCROLL_UP,            UP,            NULL); \
  girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0,                    sc_mouse_zoom,   (mode),     GIRARA_EVENT_SCROLL_DOWN,          DOWN,          NULL); \
  girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0,                    sc_mouse_zoom,   (mode),     GIRARA_EVENT_SCROLL_BIDIRECTIONAL, BIDIRECTIONAL, NULL); \
396 397 398 399
  girara_mouse_event_add(gsession, 0,                GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, (mode),     GIRARA_EVENT_BUTTON_PRESS,   0,    NULL); \
  girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, (mode),     GIRARA_EVENT_BUTTON_RELEASE, 0,    NULL); \
  girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0,                    sc_mouse_scroll, (mode),     GIRARA_EVENT_MOTION_NOTIFY,  0,    NULL); \

400 401 402 403 404 405 406
  /* Define mode-less shortcuts
   * girara adds them only for normal mode, so passing 0 as mode is currently
   * not enough. We need to add/override for every mode. */
  for (size_t idx = 0; idx != LENGTH(all_modes); ++idx) {
    girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c,      NULL, sc_abort, all_modes[idx], 0, NULL);
    girara_shortcut_add(gsession, 0,                GDK_KEY_Escape, NULL, sc_abort, all_modes[idx], 0, NULL);
  }
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425

  /* Normal mode */
  girara_shortcut_add(gsession, 0, GDK_KEY_F5,  NULL, sc_toggle_presentation, NORMAL, 0, NULL);
  girara_shortcut_add(gsession, 0, GDK_KEY_F11, NULL, sc_toggle_fullscreen,   NORMAL, 0, NULL);

  DEFAULT_SHORTCUTS(NORMAL)

  /* Normal mode - Mouse events */
  DEFAULT_MOUSE_EVENTS(NORMAL)

  /* Fullscreen mode */
  girara_shortcut_add(gsession, 0, GDK_KEY_F11, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL);

  DEFAULT_SHORTCUTS(FULLSCREEN)

  /* Fullscreen mode - Mouse events */
  DEFAULT_MOUSE_EVENTS(FULLSCREEN)

  /* Index mode */
Sebastian Ramacher's avatar
Sebastian Ramacher committed
426
  girara_shortcut_add(gsession, 0,                GDK_KEY_Tab,         NULL, sc_toggle_index,        INDEX,        0,            NULL);
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
  girara_shortcut_add(gsession, 0,                GDK_KEY_k,           NULL, sc_navigate_index,      INDEX,        UP,           NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_j,           NULL, sc_navigate_index,      INDEX,        DOWN,         NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_h,           NULL, sc_navigate_index,      INDEX,        COLLAPSE,     NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_l,           NULL, sc_navigate_index,      INDEX,        EXPAND,       NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_L,           NULL, sc_navigate_index,      INDEX,        EXPAND_ALL,   NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_H,           NULL, sc_navigate_index,      INDEX,        COLLAPSE_ALL, NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Up,          NULL, sc_navigate_index,      INDEX,        UP,           NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Down,        NULL, sc_navigate_index,      INDEX,        DOWN,         NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Left,        NULL, sc_navigate_index,      INDEX,        COLLAPSE,     NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Right,       NULL, sc_navigate_index,      INDEX,        EXPAND,       NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_space,       NULL, sc_navigate_index,      INDEX,        SELECT,       NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Return,      NULL, sc_navigate_index,      INDEX,        SELECT,       NULL);
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_j,           NULL, sc_navigate_index,      INDEX,        SELECT,       NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_q,           NULL, sc_quit,                INDEX,        0,            NULL);
  girara_shortcut_add(gsession, 0,                0,                   "gg", sc_navigate_index,      INDEX,        TOP,          NULL);
  girara_shortcut_add(gsession, 0,                0,                   "G",  sc_navigate_index,      INDEX,        BOTTOM,       NULL);
  girara_shortcut_add(gsession, 0,                GDK_KEY_Escape,      NULL, sc_toggle_index,        INDEX,        0,            NULL);
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_bracketleft, NULL, sc_toggle_index,        INDEX,        0,            NULL);
  girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c,           NULL, sc_toggle_index,        INDEX,        0,            NULL);
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477

  /* Presentation mode */
  girara_shortcut_add(gsession, 0,              GDK_KEY_J,         NULL, sc_navigate,            PRESENTATION, NEXT,         NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Down,      NULL, sc_navigate,            PRESENTATION, NEXT,         NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Right,     NULL, sc_navigate,            PRESENTATION, NEXT,         NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Page_Down, NULL, sc_navigate,            PRESENTATION, NEXT,         NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_space,     NULL, sc_navigate,            PRESENTATION, NEXT,         NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_K,         NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Left,      NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Up,        NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_Page_Up,   NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);
  girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space,     NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);
  girara_shortcut_add(gsession, 0,              GDK_KEY_BackSpace, NULL, sc_navigate,            PRESENTATION, PREVIOUS,     NULL);

  girara_shortcut_add(gsession, 0,              GDK_KEY_F5,        NULL, sc_toggle_presentation, PRESENTATION, 0,            NULL);

  girara_shortcut_add(gsession, 0,              GDK_KEY_q,         NULL, sc_quit,                PRESENTATION, 0,            NULL);

  /* Presentation mode - Mouse events */
  girara_mouse_event_add(gsession, 0,                0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_UP,    UP,       NULL);
  girara_mouse_event_add(gsession, 0,                0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_DOWN,  DOWN,     NULL);
  girara_mouse_event_add(gsession, 0,                0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_LEFT,  LEFT,     NULL);
  girara_mouse_event_add(gsession, 0,                0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_RIGHT, RIGHT,    NULL);

  girara_mouse_event_add(gsession, 0,                GIRARA_MOUSE_BUTTON1, sc_navigate,     PRESENTATION, GIRARA_EVENT_BUTTON_PRESS, NEXT,     NULL);
  girara_mouse_event_add(gsession, 0,                GIRARA_MOUSE_BUTTON3, sc_navigate,     PRESENTATION, GIRARA_EVENT_BUTTON_PRESS, PREVIOUS, NULL);

  girara_mouse_event_add(gsession, GDK_SHIFT_MASK,   0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_UP,    LEFT,     NULL);
  girara_mouse_event_add(gsession, GDK_SHIFT_MASK,   0,                    sc_mouse_scroll, PRESENTATION, GIRARA_EVENT_SCROLL_DOWN,  RIGHT,    NULL);

  girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0,                    sc_mouse_zoom,   PRESENTATION, GIRARA_EVENT_SCROLL_UP,    UP,       NULL);
  girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0,                    sc_mouse_zoom,   PRESENTATION, GIRARA_EVENT_SCROLL_DOWN,  DOWN,     NULL);
478

479 480 481 482
  /* inputbar shortcuts */
  girara_inputbar_shortcut_add(gsession, 0,                GDK_KEY_Escape, sc_abort, 0, NULL);
  girara_inputbar_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c,      sc_abort, 0, NULL);

483
  /* define default inputbar commands */
484 485 486 487 488
  girara_inputbar_command_add(gsession, "bmark",      NULL,   cmd_bookmark_create, NULL,         _("Add a bookmark"));
  girara_inputbar_command_add(gsession, "bdelete",    NULL,   cmd_bookmark_delete, cc_bookmarks, _("Delete a bookmark"));
  girara_inputbar_command_add(gsession, "blist",      NULL,   cmd_bookmark_open,   cc_bookmarks, _("List all bookmarks"));
  girara_inputbar_command_add(gsession, "close",      NULL,   cmd_close,           NULL,         _("Close current file"));
  girara_inputbar_command_add(gsession, "info",       NULL,   cmd_info,            NULL,         _("Show file information"));
Moritz Lipp's avatar
Moritz Lipp committed
489
  girara_inputbar_command_add(gsession, "exec",       NULL,   cmd_exec,            NULL,         _("Execute a command"));
Sebastian Ramacher's avatar
Sebastian Ramacher committed
490
  girara_inputbar_command_add(gsession, "!",          NULL,   cmd_exec,            NULL,         _("Execute a command")); /* like vim */
491 492 493 494 495 496 497 498 499 500 501 502
  girara_inputbar_command_add(gsession, "help",       NULL,   cmd_help,            NULL,         _("Show help"));
  girara_inputbar_command_add(gsession, "open",       "o",    cmd_open,            cc_open,      _("Open document"));
  girara_inputbar_command_add(gsession, "quit",       "q",    cmd_quit,            NULL,         _("Close zathura"));
  girara_inputbar_command_add(gsession, "print",      NULL,   cmd_print,           NULL,         _("Print document"));
  girara_inputbar_command_add(gsession, "write",      NULL,   cmd_save,            cc_write,     _("Save document"));
  girara_inputbar_command_add(gsession, "write!",     NULL,   cmd_savef,           cc_write,     _("Save document (and force overwriting)"));
  girara_inputbar_command_add(gsession, "export",     NULL,   cmd_export,          cc_export,    _("Save attachments"));
  girara_inputbar_command_add(gsession, "offset",     NULL,   cmd_offset,          NULL,         _("Set page offset"));
  girara_inputbar_command_add(gsession, "mark",       NULL,   cmd_marks_add,       NULL,         _("Mark current location within the document"));
  girara_inputbar_command_add(gsession, "delmarks",   "delm", cmd_marks_delete,    NULL,         _("Delete the specified marks"));
  girara_inputbar_command_add(gsession, "nohlsearch", "nohl", cmd_nohlsearch,      NULL,         _("Don't highlight current search results"));
  girara_inputbar_command_add(gsession, "hlsearch",   NULL,   cmd_hlsearch,        NULL,         _("Highlight current search results"));
Moritz Lipp's avatar
Moritz Lipp committed
503
  girara_inputbar_command_add(gsession, "version",    NULL,   cmd_version,         NULL,         _("Show version information"));
Sebastian Ramacher's avatar
Sebastian Ramacher committed
504

Sebastian Ramacher's avatar
Sebastian Ramacher committed
505 506
  girara_special_command_add(gsession, '/', cmd_search, INCREMENTAL_SEARCH, FORWARD,  NULL);
  girara_special_command_add(gsession, '?', cmd_search, INCREMENTAL_SEARCH, BACKWARD, NULL);
Moritz Lipp's avatar
Moritz Lipp committed
507

Moritz Lipp's avatar
Moritz Lipp committed
508
  /* add shortcut mappings */
509 510 511 512 513 514 515 516 517 518 519 520 521 522
  girara_shortcut_mapping_add(gsession, "abort",               sc_abort);
  girara_shortcut_mapping_add(gsession, "adjust_window",       sc_adjust_window);
  girara_shortcut_mapping_add(gsession, "bisect",              sc_bisect);
  girara_shortcut_mapping_add(gsession, "change_mode",         sc_change_mode);
  girara_shortcut_mapping_add(gsession, "display_link",        sc_display_link);
  girara_shortcut_mapping_add(gsession, "exec",                sc_exec);
  girara_shortcut_mapping_add(gsession, "focus_inputbar",      sc_focus_inputbar);
  girara_shortcut_mapping_add(gsession, "follow",              sc_follow);
  girara_shortcut_mapping_add(gsession, "goto",                sc_goto);
  girara_shortcut_mapping_add(gsession, "jumplist",            sc_jumplist);
  girara_shortcut_mapping_add(gsession, "mark_add",            sc_mark_add);
  girara_shortcut_mapping_add(gsession, "mark_evaluate",       sc_mark_evaluate);
  girara_shortcut_mapping_add(gsession, "navigate",            sc_navigate);
  girara_shortcut_mapping_add(gsession, "navigate_index",      sc_navigate_index);
523
  girara_shortcut_mapping_add(gsession, "nohlsearch",          sc_nohlsearch);
524 525 526 527 528 529 530 531 532 533
  girara_shortcut_mapping_add(gsession, "print",               sc_print);
  girara_shortcut_mapping_add(gsession, "quit",                sc_quit);
  girara_shortcut_mapping_add(gsession, "recolor",             sc_recolor);
  girara_shortcut_mapping_add(gsession, "reload",              sc_reload);
  girara_shortcut_mapping_add(gsession, "rotate",              sc_rotate);
  girara_shortcut_mapping_add(gsession, "scroll",              sc_scroll);
  girara_shortcut_mapping_add(gsession, "search",              sc_search);
  girara_shortcut_mapping_add(gsession, "toggle_fullscreen",   sc_toggle_fullscreen);
  girara_shortcut_mapping_add(gsession, "toggle_index",        sc_toggle_index);
  girara_shortcut_mapping_add(gsession, "toggle_page_mode",    sc_toggle_page_mode);
Sebastian Ramacher's avatar
Sebastian Ramacher committed
534
  girara_shortcut_mapping_add(gsession, "toggle_presentation", sc_toggle_presentation);
535
  girara_shortcut_mapping_add(gsession, "zoom",                sc_zoom);
Moritz Lipp's avatar
Moritz Lipp committed
536 537

  /* add argument mappings */
538
  girara_argument_mapping_add(gsession, "backward",     BACKWARD);
539 540 541 542 543 544 545
  girara_argument_mapping_add(gsession, "bottom",       BOTTOM);
  girara_argument_mapping_add(gsession, "default",      DEFAULT);
  girara_argument_mapping_add(gsession, "collapse",     COLLAPSE);
  girara_argument_mapping_add(gsession, "collapse-all", COLLAPSE_ALL);
  girara_argument_mapping_add(gsession, "down",         DOWN);
  girara_argument_mapping_add(gsession, "expand",       EXPAND);
  girara_argument_mapping_add(gsession, "expand-all",   EXPAND_ALL);
546
  girara_argument_mapping_add(gsession, "select",       SELECT);
547
  girara_argument_mapping_add(gsession, "toggle",       TOGGLE);
548
  girara_argument_mapping_add(gsession, "forward",      FORWARD);
549 550 551 552
  girara_argument_mapping_add(gsession, "full-down",    FULL_DOWN);
  girara_argument_mapping_add(gsession, "full-up",      FULL_UP);
  girara_argument_mapping_add(gsession, "half-down",    HALF_DOWN);
  girara_argument_mapping_add(gsession, "half-up",      HALF_UP);
553 554 555 556
  girara_argument_mapping_add(gsession, "full-right",   FULL_RIGHT);
  girara_argument_mapping_add(gsession, "full-left",    FULL_LEFT);
  girara_argument_mapping_add(gsession, "half-right",   HALF_RIGHT);
  girara_argument_mapping_add(gsession, "half-left",    HALF_LEFT);
557 558 559 560
  girara_argument_mapping_add(gsession, "in",           ZOOM_IN);
  girara_argument_mapping_add(gsession, "left",         LEFT);
  girara_argument_mapping_add(gsession, "next",         NEXT);
  girara_argument_mapping_add(gsession, "out",          ZOOM_OUT);
561 562
  girara_argument_mapping_add(gsession, "page-top",     PAGE_TOP);
  girara_argument_mapping_add(gsession, "page-bottom",  PAGE_BOTTOM);
563 564 565 566 567
  girara_argument_mapping_add(gsession, "previous",     PREVIOUS);
  girara_argument_mapping_add(gsession, "right",        RIGHT);
  girara_argument_mapping_add(gsession, "specific",     ZOOM_SPECIFIC);
  girara_argument_mapping_add(gsession, "top",          TOP);
  girara_argument_mapping_add(gsession, "up",           UP);
568 569
  girara_argument_mapping_add(gsession, "best-fit",     ZATHURA_ADJUST_BESTFIT);
  girara_argument_mapping_add(gsession, "width",        ZATHURA_ADJUST_WIDTH);
570 571
  girara_argument_mapping_add(gsession, "rotate-cw",    ROTATE_CW);
  girara_argument_mapping_add(gsession, "rotate-ccw",   ROTATE_CCW);
572
}
Moritz Lipp's avatar
Moritz Lipp committed
573 574

void
575
config_load_files(zathura_t* zathura)
Moritz Lipp's avatar
Moritz Lipp committed
576
{
577 578 579 580 581 582 583 584 585
  /* load global configuration files */
  char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS);
  girara_list_t* config_dirs = girara_split_path_array(config_path);
  ssize_t size = girara_list_size(config_dirs) - 1;
  for (; size >= 0; --size) {
    const char* dir = girara_list_nth(config_dirs, size);
    char* file = g_build_filename(dir, ZATHURA_RC, NULL);
    girara_config_parse(zathura->ui.session, file);
    g_free(file);
Moritz Lipp's avatar
Moritz Lipp committed
586
  }
587 588 589 590
  girara_list_free(config_dirs);
  g_free(config_path);

  girara_config_parse(zathura->ui.session, GLOBAL_RC);
Moritz Lipp's avatar
Moritz Lipp committed
591

592 593 594 595
  /* load local configuration files */
  char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
  girara_config_parse(zathura->ui.session, configuration_file);
  g_free(configuration_file);
Moritz Lipp's avatar
Moritz Lipp committed
596
}