Button: make sure icon is optional

This commit is contained in:
o9000 2017-03-25 15:48:03 +01:00
parent a7fc86cfbb
commit 63dd4a3e6c
2 changed files with 8 additions and 3 deletions

View file

@ -207,9 +207,14 @@ void button_reload_icon(Button *button)
free_icon(button->frontend->icon_hover); free_icon(button->frontend->icon_hover);
free_icon(button->frontend->icon_pressed); free_icon(button->frontend->icon_pressed);
button->frontend->icon = NULL; button->frontend->icon = NULL;
button->frontend->icon_hover = NULL;
button->frontend->icon_pressed = NULL;
button->frontend->icon_load_size = button->frontend->iconw; button->frontend->icon_load_size = button->frontend->iconw;
if (!button->backend->icon_name)
return;
char *new_icon_path = get_icon_path(icon_theme_wrapper, button->backend->icon_name, button->frontend->iconw, TRUE); char *new_icon_path = get_icon_path(icon_theme_wrapper, button->backend->icon_name, button->frontend->iconw, TRUE);
if (new_icon_path) if (new_icon_path)
button->frontend->icon = imlib_load_image_immediately(new_icon_path); button->frontend->icon = imlib_load_image_immediately(new_icon_path);

View file

@ -750,14 +750,14 @@ void add_entry(char *key, char *value)
/* Button */ /* Button */
else if (strcmp(key, "button") == 0) { else if (strcmp(key, "button") == 0) {
panel_config.button_list = g_list_append(panel_config.button_list, create_button()); panel_config.button_list = g_list_append(panel_config.button_list, create_button());
} else if (strcmp(key, "button_icon") == 0) { } else if (strcmp(key, "button_icon") == 0 && strlen(value)) {
Button *button = get_or_create_last_button(); Button *button = get_or_create_last_button();
button->backend->icon_name = strdup(value); button->backend->icon_name = strdup(value);
} else if (strcmp(key, "button_text") == 0) { } else if (strcmp(key, "button_text") == 0 && strlen(value)) {
Button *button = get_or_create_last_button(); Button *button = get_or_create_last_button();
free_and_null(button->backend->text); free_and_null(button->backend->text);
button->backend->text = strdup(value); button->backend->text = strdup(value);
} else if (strcmp(key, "button_tooltip") == 0) { } else if (strcmp(key, "button_tooltip") == 0 && strlen(value)) {
Button *button = get_or_create_last_button(); Button *button = get_or_create_last_button();
free_and_null(button->backend->tooltip); free_and_null(button->backend->tooltip);
button->backend->tooltip = strdup(value); button->backend->tooltip = strdup(value);