From f6c6b4a883c1566afb018bc224e499f9263c3c65 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 13 Aug 2012 18:17:20 +0200 Subject: [PATCH] En/Disable syntex support --- config.c | 2 ++ main.c | 5 +++++ page-widget.c | 5 ++++- zathura.c | 9 +++++++++ zathura.h | 8 ++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 99443b3..6db7ffc 100644 --- a/config.c +++ b/config.c @@ -161,6 +161,8 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "abort-clear-search", &bool_value, BOOLEAN, false, _("Clear search results on abort"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "window-title-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the window title"), NULL, NULL); + bool_value = false; + girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable syntex support"), NULL, NULL); /* define default shortcuts */ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); diff --git a/main.c b/main.c index 3590e1f..86ea05b 100644 --- a/main.c +++ b/main.c @@ -40,6 +40,7 @@ main(int argc, char* argv[]) gchar* synctex_editor = NULL; bool forkback = false; bool print_version = false; + bool synctex = false; #if (GTK_MAJOR_VERSION == 3) Window embed = 0; @@ -56,6 +57,7 @@ main(int argc, char* argv[]) { "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" }, { "debug", 'l', 0, G_OPTION_ARG_STRING, &loglevel, _("Log level (debug, info, warning, error)"), "level" }, { "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL }, + { "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL }, { "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" }, { NULL, '\0', 0, 0, NULL, NULL, NULL } }; @@ -108,6 +110,9 @@ main(int argc, char* argv[]) return -1; } + /* Enable/Disable synctex support */ + zathura_set_syntex(zathura, synctex); + /* Print version */ if (print_version == true) { char* string = zathura_get_version_string(zathura, false); diff --git a/page-widget.c b/page-widget.c index 9248220..bd1ff0b 100644 --- a/page-widget.c +++ b/page-widget.c @@ -613,7 +613,10 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b } else { redraw_rect(ZATHURA_PAGE(widget), &priv->mouse.selection); - if (priv->zathura->synctex.enabled && button->state & GDK_CONTROL_MASK) { + bool synctex = false; + girara_setting_get(priv->zathura->ui.session, "synctex", &synctex); + + if (synctex == true && button->state & GDK_CONTROL_MASK) { /* synctex backwards sync */ double scale = zathura_document_get_scale(document); int x = button->x / scale, y = button->y / scale; diff --git a/zathura.c b/zathura.c index 1ab8318..191f4a8 100644 --- a/zathura.c +++ b/zathura.c @@ -374,6 +374,15 @@ zathura_set_synctex_editor_command(zathura_t* zathura, const char* command) } } +void +zathura_set_syntex(zathura_t* zathura, bool value) +{ + g_return_if_fail(zathura != NULL); + g_return_if_fail(zathura->ui.session != NULL); + + girara_setting_set(zathura->ui.session, "synctex", &value); +} + void zathura_set_argv(zathura_t* zathura, char** argv) { diff --git a/zathura.h b/zathura.h index fcb7ea5..9aa807c 100644 --- a/zathura.h +++ b/zathura.h @@ -191,6 +191,14 @@ void zathura_set_plugin_dir(zathura_t* zathura, const char* dir); */ void zathura_set_synctex_editor_command(zathura_t* zathura, const char* command); +/** + * En/Disable zathuras syntex support + * + * @param zathura The zathura session + * @param value The value + */ +void zathura_set_syntex(zathura_t* zathura, bool value); + /** * Sets the program parameters *