Entries without a mode when images are enabled are now displayed as text
This commit is contained in:
parent
43bc6eb5ed
commit
5d271d5d31
24
src/wofi.c
24
src/wofi.c
@ -92,6 +92,10 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char*
|
|||||||
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "mode", mode);
|
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "mode", mode);
|
||||||
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "action", action);
|
wofi_property_box_add_property(WOFI_PROPERTY_BOX(box), "action", action);
|
||||||
if(allow_images) {
|
if(allow_images) {
|
||||||
|
struct map* modes = map_init();
|
||||||
|
map_put(modes, "img", "true");
|
||||||
|
map_put(modes, "text", "true");
|
||||||
|
|
||||||
char* tmp = strdup(text);
|
char* tmp = strdup(text);
|
||||||
char* mode = NULL;
|
char* mode = NULL;
|
||||||
|
|
||||||
@ -102,7 +106,24 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char*
|
|||||||
char* str = strtok_r(tmp, ":", &save_ptr);
|
char* str = strtok_r(tmp, ":", &save_ptr);
|
||||||
do {
|
do {
|
||||||
if(mode == NULL) {
|
if(mode == NULL) {
|
||||||
mode = str;
|
if(map_contains(modes, str)) {
|
||||||
|
mode = str;
|
||||||
|
} else {
|
||||||
|
char* start = (str - tmp) + text;
|
||||||
|
if(start != text) {
|
||||||
|
--start;
|
||||||
|
}
|
||||||
|
long end = strlen(str) + 1;
|
||||||
|
str = strdup(start);
|
||||||
|
*(str + end) = 0;
|
||||||
|
|
||||||
|
GtkWidget* label = gtk_label_new(str);
|
||||||
|
gtk_widget_set_name(label, "text");
|
||||||
|
gtk_label_set_use_markup(GTK_LABEL(label), allow_markup);
|
||||||
|
gtk_label_set_xalign(GTK_LABEL(label), 0);
|
||||||
|
gtk_container_add(GTK_CONTAINER(box), label);
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if(strcmp(mode, "img") == 0) {
|
if(strcmp(mode, "img") == 0) {
|
||||||
GdkPixbuf* buf = gdk_pixbuf_new_from_file(str, NULL);
|
GdkPixbuf* buf = gdk_pixbuf_new_from_file(str, NULL);
|
||||||
@ -133,6 +154,7 @@ static GtkWidget* create_label(char* mode, char* text, char* search_text, char*
|
|||||||
}
|
}
|
||||||
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
|
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
map_free(modes);
|
||||||
} else {
|
} else {
|
||||||
GtkWidget* label = gtk_label_new(text);
|
GtkWidget* label = gtk_label_new(text);
|
||||||
gtk_widget_set_name(label, "text");
|
gtk_widget_set_name(label, "text");
|
||||||
|
Loading…
Reference in New Issue
Block a user