From 8594fc52a33579c98d2197ecc32a1d97d08ebc02 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Mon, 16 Dec 2019 19:38:12 -0800 Subject: [PATCH] Parsing image escapes and markup will only occur if their respective options are enabled --- inc/wofi.h | 2 ++ modes/dmenu.c | 16 ++++++++++------ src/wofi.c | 21 ++++++++++++++++----- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/inc/wofi.h b/inc/wofi.h index 98703ac..7618409 100644 --- a/inc/wofi.h +++ b/inc/wofi.h @@ -54,6 +54,8 @@ void wofi_insert_widget(char* mode, char** text, char* search_text, char** actio bool wofi_allow_images(); +bool wofi_allow_markup(); + uint64_t wofi_get_image_size(); bool wofi_mod_shift(); diff --git a/modes/dmenu.c b/modes/dmenu.c index cb40095..84cd05b 100644 --- a/modes/dmenu.c +++ b/modes/dmenu.c @@ -59,12 +59,16 @@ void wofi_dmenu_init(struct map* config) { void wofi_dmenu_exec(const gchar* cmd) { char* action = strdup(cmd); if(parse_action) { - free(action); - action = wofi_parse_image_escapes(cmd); - char* out; - pango_parse_markup(action, -1, 0, NULL, &out, NULL, NULL); - free(action); - action = out; + if(wofi_allow_images()) { + free(action); + action = wofi_parse_image_escapes(cmd); + } + if(wofi_allow_markup()) { + char* out; + pango_parse_markup(action, -1, 0, NULL, &out, NULL, NULL); + free(action); + action = out; + } } wofi_write_cache(MODE, cmd); printf("%s\n", action); diff --git a/src/wofi.c b/src/wofi.c index 67ac3f2..b424f5e 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -235,11 +235,18 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char* gtk_container_add(GTK_CONTAINER(box), label); } if(parse_search) { - search_text = parse_images(WOFI_PROPERTY_BOX(box), search_text, false); - char* out; - pango_parse_markup(search_text, -1, 0, NULL, &out, NULL, NULL); - free(search_text); - search_text = out; + search_text = strdup(search_text); + if(allow_images) { + char* tmp = search_text; + search_text = parse_images(WOFI_PROPERTY_BOX(box), search_text, false); + free(tmp); + } + if(allow_markup) { + char* out; + pango_parse_markup(search_text, -1, 0, NULL, &out, NULL, NULL); + free(search_text); + search_text = out; + } } wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", search_text); if(parse_search) { @@ -433,6 +440,10 @@ bool wofi_allow_images() { return allow_images; } +bool wofi_allow_markup() { + return allow_markup; +} + uint64_t wofi_get_image_size() { return image_size; }