Parsing image escapes and markup will only occur if their respective options are enabled

This commit is contained in:
Scoopta 2019-12-16 19:38:12 -08:00
parent c248461260
commit 8594fc52a3
3 changed files with 28 additions and 11 deletions

View File

@ -54,6 +54,8 @@ void wofi_insert_widget(char* mode, char** text, char* search_text, char** actio
bool wofi_allow_images(); bool wofi_allow_images();
bool wofi_allow_markup();
uint64_t wofi_get_image_size(); uint64_t wofi_get_image_size();
bool wofi_mod_shift(); bool wofi_mod_shift();

View File

@ -59,13 +59,17 @@ void wofi_dmenu_init(struct map* config) {
void wofi_dmenu_exec(const gchar* cmd) { void wofi_dmenu_exec(const gchar* cmd) {
char* action = strdup(cmd); char* action = strdup(cmd);
if(parse_action) { if(parse_action) {
if(wofi_allow_images()) {
free(action); free(action);
action = wofi_parse_image_escapes(cmd); action = wofi_parse_image_escapes(cmd);
}
if(wofi_allow_markup()) {
char* out; char* out;
pango_parse_markup(action, -1, 0, NULL, &out, NULL, NULL); pango_parse_markup(action, -1, 0, NULL, &out, NULL, NULL);
free(action); free(action);
action = out; action = out;
} }
}
wofi_write_cache(MODE, cmd); wofi_write_cache(MODE, cmd);
printf("%s\n", action); printf("%s\n", action);
free(action); free(action);

View File

@ -235,12 +235,19 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char*
gtk_container_add(GTK_CONTAINER(box), label); gtk_container_add(GTK_CONTAINER(box), label);
} }
if(parse_search) { if(parse_search) {
search_text = strdup(search_text);
if(allow_images) {
char* tmp = search_text;
search_text = parse_images(WOFI_PROPERTY_BOX(box), search_text, false); search_text = parse_images(WOFI_PROPERTY_BOX(box), search_text, false);
free(tmp);
}
if(allow_markup) {
char* out; char* out;
pango_parse_markup(search_text, -1, 0, NULL, &out, NULL, NULL); pango_parse_markup(search_text, -1, 0, NULL, &out, NULL, NULL);
free(search_text); free(search_text);
search_text = out; search_text = out;
} }
}
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", search_text); wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "filter", search_text);
if(parse_search) { if(parse_search) {
free(search_text); free(search_text);
@ -433,6 +440,10 @@ bool wofi_allow_images() {
return allow_images; return allow_images;
} }
bool wofi_allow_markup() {
return allow_markup;
}
uint64_t wofi_get_image_size() { uint64_t wofi_get_image_size() {
return image_size; return image_size;
} }