From d24ad831b86b8b6098286750c1dc32141f4ce0c5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 28 Apr 2012 21:47:27 +0200 Subject: [PATCH] Add setting abort-clear-search and clear search results on abort if set. --- config.c | 2 ++ shortcuts.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/config.c b/config.c index c90fb11..b07e5c4 100644 --- a/config.c +++ b/config.c @@ -140,6 +140,8 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "open-first-page", &bool_value, BOOLEAN, false, _("Always open on first page"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "nohlsearch", &bool_value, BOOLEAN, false, _("Highlight search results"), cb_nohlsearch_changed, NULL); + bool_value = true; + girara_setting_add(gsession, "abort-clear-search", &bool_value, BOOLEAN, false, _("Clear search results on abort"), NULL, NULL); /* define default shortcuts */ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); diff --git a/shortcuts.c b/shortcuts.c index 46e8f8e..2d5657e 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -26,6 +26,9 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument), g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; + bool clear_search = true; + girara_setting_get(session, "abort-clear-search", &clear_search); + if (zathura->document != NULL) { unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) { @@ -35,6 +38,9 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument), } g_object_set(zathura_page_get_widget(zathura, page), "draw-links", FALSE, NULL); + if (clear_search) { + g_object_set(zathura_page_get_widget(zathura, page), "search-results", NULL, NULL); + } } }