- }
- 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;
- panel_config->clock.area.visible = 1;
- }
- 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 (save_file_config) old_time1_font = strdup (value);
- 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 (save_file_config) old_time2_font = strdup (value);
- 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 (save_file_config) old_task_font = strdup (value);
- 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));
- }
-
- /* Systray */
- else if (strcmp (key, "systray_padding") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config->systray.area.paddingxlr = panel_config->systray.area.paddingx = atoi (value1);
- if (value2) panel_config->systray.area.paddingy = atoi (value2);
- if (value3) panel_config->systray.area.paddingx = atoi (value3);
- panel_config->systray.area.visible = 1;
- }
- else if (strcmp (key, "systray_background_id") == 0) {
- int id = atoi (value);
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&panel_config->systray.area.pix.back, &a->pix.back, sizeof(Color));
- memcpy(&panel_config->systray.area.pix.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 tint-0.6 config for backward compatibility */
- else if (strcmp (key, "panel_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, "panel_rounded") == 0) {
- Area *a = calloc(1, sizeof(Area));
- a->pix.border.rounded = atoi (value);
- list_back = g_slist_append(list_back, a);
- }
- else if (strcmp (key, "panel_border_width") == 0) {
- Area *a = g_slist_last(list_back)->data;
- a->pix.border.width = atoi (value);
- }
- else if (strcmp (key, "panel_background_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, a->pix.back.color);
- if (value2) a->pix.back.alpha = (atoi (value2) / 100.0);
- else a->pix.back.alpha = 0.5;
- }
- else if (strcmp (key, "panel_border_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, a->pix.border.color);
- if (value2) a->pix.border.alpha = (atoi (value2) / 100.0);
- else a->pix.border.alpha = 0.5;
- }
- else if (strcmp (key, "task_text_centered") == 0)
- panel_config->g_task.centered = atoi (value);
- else if (strcmp (key, "task_margin") == 0) {
- panel_config->g_taskbar.paddingxlr = 0;
- panel_config->g_taskbar.paddingx = atoi (value);
- }
- else if (strcmp (key, "task_icon_size") == 0)
- old_task_icon_size = atoi (value);
- else if (strcmp (key, "task_rounded") == 0) {
- area_task = calloc(1, sizeof(Area));
- area_task->pix.border.rounded = atoi (value);
- list_back = g_slist_append(list_back, area_task);
-
- area_task_active = calloc(1, sizeof(Area));
- area_task_active->pix.border.rounded = atoi (value);
- list_back = g_slist_append(list_back, area_task_active);
- }
- else if (strcmp (key, "task_background_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, area_task->pix.back.color);
- if (value2) area_task->pix.back.alpha = (atoi (value2) / 100.0);
- else area_task->pix.back.alpha = 0.5;
- }
- else if (strcmp (key, "task_active_background_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, area_task_active->pix.back.color);
- if (value2) area_task_active->pix.back.alpha = (atoi (value2) / 100.0);
- else area_task_active->pix.back.alpha = 0.5;
- }
- else if (strcmp (key, "task_border_width") == 0) {
- area_task->pix.border.width = atoi (value);
- area_task_active->pix.border.width = atoi (value);
- }
- else if (strcmp (key, "task_border_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, area_task->pix.border.color);
- if (value2) area_task->pix.border.alpha = (atoi (value2) / 100.0);
- else area_task->pix.border.alpha = 0.5;
- }
- else if (strcmp (key, "task_active_border_color") == 0) {
- extract_values(value, &value1, &value2, &value3);
- get_color (value1, area_task_active->pix.border.color);
- if (value2) area_task_active->pix.border.alpha = (atoi (value2) / 100.0);
- else area_task_active->pix.border.alpha = 0.5;
- }
-
- 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;