static int parse_taskbar_state(struct taskbar_state *ts, const char *name, struct config_format_entry *e, struct config_format_tree *tree, int required) { struct config_format_entry *ee = find_config_format_entry(e, name); if (!ee) { if (required) required_entry_not_found(e, name); ts->exists = 0; return -1; } if (parse_triple_image(&ts->background, ee, tree, 1)) goto parse_taskbar_state_error_background; if (parse_text_info_named(&ts->font, "font", ee, 1)) goto parse_taskbar_state_error_font; parse_2ints(ts->icon_offset, "icon_offset", ee); ts->exists = 1; return 0; parse_taskbar_state_error_font: free_triple_image(&ts->background); parse_taskbar_state_error_background: return -1; }
static int load_panel_theme(struct panel_theme *theme, struct config_format_tree *tree) { CLEAR_STRUCT(theme); struct config_format_entry *e = find_config_format_entry(&tree->root, "panel"); if (!e) return XERROR("Failed to find 'panel' section in theme format file"); theme->position = PANEL_POSITION_TOP; /* default */ const char *v = find_config_format_entry_value(e, "position"); if (v) theme->position = parse_position(v); theme->background = parse_image_part_named("background", e, tree, 1); if (!theme->background) return -1; theme->separator = parse_image_part_named("separator", e, tree, 0); theme->transparent = parse_bool("transparent", e); theme->align = parse_align("align", e); theme->height = parse_int("height", e, -1); theme->width = parse_int_or_percents("width", e, -1, &theme->width_in_percents); return 0; }
static int parse_taskbar_theme(struct taskbar_theme *tt, struct config_format_entry *e, struct config_format_tree *tree) { if (parse_taskbar_state(&tt->states[BUTTON_STATE_IDLE], "idle", e, tree, 1)) goto parse_taskbar_button_theme_error_idle; if (parse_taskbar_state(&tt->states[BUTTON_STATE_PRESSED], "pressed", e, tree, 1)) goto parse_taskbar_button_theme_error_pressed; struct config_format_entry *ee = find_config_format_entry(e, "default_icon"); tt->draw_mode = parse_draw_mode("draw_mode", e); if (ee && tt->draw_mode != DRAW_MODE_ONLY_TEXT); tt->default_icon = parse_image_part(ee, tree, 0); parse_taskbar_state(&tt->states[BUTTON_STATE_IDLE_HIGHLIGHT], "idle_highlight", e, tree, 0); parse_taskbar_state(&tt->states[BUTTON_STATE_PRESSED_HIGHLIGHT], "pressed_highlight", e, tree, 0); tt->separator = parse_image_part_named("separator", e, tree, 0); tt->task_max_width = parse_int("task_max_width", e, 0); return 0; parse_taskbar_button_theme_error_pressed: free_taskbar_state(&tt->states[BUTTON_STATE_IDLE]); parse_taskbar_button_theme_error_idle: return -1; }
static unsigned int parse_mbutton_state(const char *name, unsigned int def) { struct config_format_entry *e = find_config_format_entry(&g_settings.root, name); if (!e) return def; char *str = e->value; if (!str) return 0; unsigned int bitarray = 0; for_each_word(str, really_parse_mbutton_flag, &bitarray); return bitarray; }
static int parse_draw_mode(const char *name, struct config_format_entry *e) { struct config_format_entry *ee = find_config_format_entry(e, name); if (!ee || !ee->value) return DRAW_MODE_ALL; if (strcmp("all", ee->value) == 0) { return DRAW_MODE_ALL; } else if (strcmp("only_text", ee->value) == 0) { return DRAW_MODE_ONLY_TEXT; } else if (strcmp("only_icon", ee->value) == 0) { return DRAW_MODE_ONLY_ICON; } XWARNING("Unknown draw mode value, using \"all\" (line: %d)", ee->value, ee->line); return DRAW_MODE_ALL; }