From 8f05b636f0b4217942a712dec61a13613f591ed7 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 7 Aug 2014 20:50:58 +0200 Subject: [PATCH] Add setting to hide notifications after text selection --- callbacks.c | 17 +++++++++++------ config.c | 2 ++ doc/man/zathurarc.5.rst | 9 ++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/callbacks.c b/callbacks.c index 0f7561d..0a1fcc7 100644 --- a/callbacks.c +++ b/callbacks.c @@ -556,13 +556,18 @@ cb_page_widget_text_selected(ZathuraPage* page, const char* text, void* data) if (selection != NULL) { gtk_clipboard_set_text(gtk_clipboard_get(*selection), text, -1); - char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' '); - char* escaped_text = g_markup_printf_escaped( - _("Copied selected text to clipboard: %s"), stripped_text); - g_free(stripped_text); + bool notification = true; + girara_setting_get(zathura->ui.session, "selection-notification", ¬ification); - girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text); - g_free(escaped_text); + if (notification == true) { + char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' '); + char* escaped_text = g_markup_printf_escaped( + _("Copied selected text to clipboard: %s"), stripped_text); + g_free(stripped_text); + + girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text); + g_free(escaped_text); + } } g_free(selection); diff --git a/config.c b/config.c index 7735d76..b3281f1 100644 --- a/config.c +++ b/config.c @@ -229,6 +229,8 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL); string_value = "primary"; girara_setting_add(gsession, "selection-clipboard", string_value, STRING, false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL); + bool_value = true; + girara_setting_add(gsession, "selection-notification", &bool_value, BOOLEAN, false, _("Enable notification after selecting text"), NULL, NULL); #define DEFAULT_SHORTCUTS(mode) \ girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, (mode), ZATHURA_ADJUST_BESTFIT, NULL); \ diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index 4277fd5..8141b49 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -846,7 +846,7 @@ zoom-center En/Disables horizontally centered zooming. * Value type: Boolean -* Default value: False +* Default value: false zoom-max ^^^^^^^^ @@ -880,6 +880,13 @@ middle mouse button, or the Shift-Insert key combination. * Value type: String * Default value: primary +selection-notification +^^^^^^^^^^^^^^^^^^^^^^ +Defines if a notification should be displayed after selecting text. + +* Value type: Boolean +* Default value: true + synctex ^^^^^^^ En/Disables SyncTeX backward synchronization support.