- }
- else if (strcmp (key, "panel_margin") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->marginx = atoi (value1);
- if (value2) panel_config->marginy = atoi (value2);
- }
- else if (strcmp (key, "panel_padding") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->area.paddingxlr = panel_config->area.paddingx = atoi (value1);
- if (value2) panel_config->area.paddingy = atoi (value2);
- if (value3) panel_config->area.paddingx = atoi (value3);
- }
- else if (strcmp (key, "panel_position") == 0) {
- extract_values(value, &value1, &value2, &value3);
- if (strcmp (value1, "top") == 0) panel_position = TOP;
- else panel_position = BOTTOM;
-
- if (!value2) panel_position = CENTER;
- else {
- if (strcmp (value2, "left") == 0) panel_position |= LEFT;
- else {
- if (strcmp (value2, "right") == 0) panel_position |= RIGHT;
- else panel_position |= CENTER;
- }
- }
- }
- else if (strcmp (key, "font_shadow") == 0)
- panel_config->g_task.font_shadow = atoi (value);
- else if (strcmp (key, "panel_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->area.pix.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border));
- }
-
- /* Clock */
- else if (strcmp (key, "time1_format") == 0) {
- if (time1_format) g_free(time1_format);
- if (strlen(value) > 0) time1_format = strdup (value);
- else time1_format = 0;
- }
- else if (strcmp (key, "time2_format") == 0) {
- if (time2_format) g_free(time2_format);
- if (strlen(value) > 0) time2_format = strdup (value);
- else time2_format = 0;
- }
- else if (strcmp (key, "time1_font") == 0) {
- if (time1_font_desc) pango_font_description_free(time1_font_desc);
- time1_font_desc = pango_font_description_from_string (value);
- }
- else if (strcmp (key, "time2_font") == 0) {
- if (time2_font_desc) pango_font_description_free(time2_font_desc);
- time2_font_desc = pango_font_description_from_string (value);
- }
- else if (strcmp (key, "clock_font_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, panel_config->clock.font.color);
- if (value2) panel_config->clock.font.alpha = (atoi (value2) / 100.0);
- else panel_config->clock.font.alpha = 0.5;
- }
- else if (strcmp (key, "clock_padding") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->clock.area.paddingxlr = panel_config->clock.area.paddingx = atoi (value1);
- if (value2) panel_config->clock.area.paddingy = atoi (value2);
- if (value3) panel_config->clock.area.paddingx = atoi (value3);
- }
- else if (strcmp (key, "clock_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border));
- }
-
- /* Taskbar */
- else if (strcmp (key, "taskbar_mode") == 0) {
- if (strcmp (value, "multi_desktop") == 0) panel_mode = MULTI_DESKTOP;
- else if (strcmp (value, "single_desktop") == 0) panel_mode = SINGLE_DESKTOP;
- else panel_mode = SINGLE_MONITOR;
- }
- else if (strcmp (key, "taskbar_padding") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->g_taskbar.paddingxlr = panel_config->g_taskbar.paddingx = atoi (value1);
- if (value2) panel_config->g_taskbar.paddingy = atoi (value2);
- if (value3) panel_config->g_taskbar.paddingx = atoi (value3);
- }
- else if (strcmp (key, "taskbar_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->g_taskbar.pix.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->g_taskbar.pix.border, &a->pix.border, sizeof(Border));
- }
-
- /* Task */
- else if (strcmp (key, "task_text") == 0)
- panel_config->g_task.text = atoi (value);
- else if (strcmp (key, "task_icon") == 0)
- panel_config->g_task.icon = atoi (value);
- else if (strcmp (key, "task_centered") == 0)
- panel_config->g_task.centered = atoi (value);
- else if (strcmp (key, "task_width") == 0)
- panel_config->g_task.maximum_width = atoi (value);
- else if (strcmp (key, "task_padding") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->g_task.area.paddingxlr = panel_config->g_task.area.paddingx = atoi (value1);
- if (value2) panel_config->g_task.area.paddingy = atoi (value2);
- if (value3) panel_config->g_task.area.paddingx = atoi (value3);
- }
- else if (strcmp (key, "task_font") == 0) {
- if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc);
- panel_config->g_task.font_desc = pango_font_description_from_string (value);
- }
- else if (strcmp (key, "task_font_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, panel_config->g_task.font.color);
- if (value2) panel_config->g_task.font.alpha = (atoi (value2) / 100.0);
- else panel_config->g_task.font.alpha = 0.1;
- }
- else if (strcmp (key, "task_active_font_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, panel_config->g_task.font_active.color);
- if (value2) panel_config->g_task.font_active.alpha = (atoi (value2) / 100.0);
- else panel_config->g_task.font_active.alpha = 0.1;
- }
- else if (strcmp (key, "task_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->g_task.area.pix.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->g_task.area.pix.border, &a->pix.border, sizeof(Border));
- }
- else if (strcmp (key, "task_active_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->g_task.area.pix_active.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border));
- }
-
- /* Mouse actions */
- else if (strcmp (key, "mouse_middle") == 0)
- get_action (value, &mouse_middle);
- else if (strcmp (key, "mouse_right") == 0)
- get_action (value, &mouse_right);
- else if (strcmp (key, "mouse_scroll_up") == 0)
- get_action (value, &mouse_scroll_up);
- else if (strcmp (key, "mouse_scroll_down") == 0)
- get_action (value, &mouse_scroll_down);
-
-
- /* Read old config for backward compatibility */
- else if (strcmp (key, "font") == 0) {
- old_config_file = 1;
- if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc);
- panel_config->g_task.font_desc = pango_font_description_from_string (value);
- if (old_task_font) free(old_task_font);
- old_task_font = strdup (value);
- }
- else if (strcmp (key, "font_color") == 0)
- get_color (value, panel_config->g_task.font.color);
- else if (strcmp (key, "font_alpha") == 0)
- panel_config->g_task.font.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "font_active_color") == 0)
- get_color (value, panel_config->g_task.font_active.color);
- else if (strcmp (key, "font_active_alpha") == 0)
- panel_config->g_task.font_active.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "panel_show_all_desktop") == 0) {
- if (atoi (value) == 0) panel_mode = SINGLE_DESKTOP;
- else panel_mode = MULTI_DESKTOP;
- }
- else if (strcmp (key, "panel_width") == 0)
- panel_config->area.width = atoi (value);
- else if (strcmp (key, "panel_height") == 0)
- panel_config->area.height = atoi (value);
- else if (strcmp (key, "panel_background") == 0)
- old_panel_background = atoi (value);
- else if (strcmp (key, "panel_background_alpha") == 0)
- panel_config->area.pix.back.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "panel_border_alpha") == 0)
- panel_config->area.pix.border.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "task_icon") == 0)
- old_task_icon = atoi (value);
- else if (strcmp (key, "task_background") == 0)
- old_task_background = atoi (value);
- else if (strcmp (key, "task_background_alpha") == 0)
- panel_config->g_task.area.pix.back.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "task_active_background_alpha") == 0)
- panel_config->g_task.area.pix_active.back.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "task_border_alpha") == 0)
- panel_config->g_task.area.pix.border.alpha = (atoi (value) / 100.0);
- else if (strcmp (key, "task_active_border_alpha") == 0)
- panel_config->g_task.area.pix_active.border.alpha = (atoi (value) / 100.0);
- // disabled parameters
- else if (strcmp (key, "task_active_border_width") == 0) ;
- else if (strcmp (key, "task_active_rounded") == 0) ;
-
- else
- fprintf(stderr, "Invalid option: \"%s\", correct your config file\n", key);
-
- if (value1) free (value1);
- if (value2) free (value2);
- if (value3) free (value3);
-}
-
-
-int parse_line (const char *line)
-{
- char *a, *b, *key, *value;
-
- /* Skip useless lines */
- if ((line[0] == '#') || (line[0] == '\n')) return 0;
- if (!(a = strchr (line, '='))) return 0;