From: Thierry Lorthiois Date: Sat, 18 Sep 2010 21:22:53 +0000 (+0000) Subject: panel_items : backward compatibility with 0.11 config file X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=6f02aea86bfbd5bc086d2a67318f2534bb8b73c2;p=chaz%2Ftint2 panel_items : backward compatibility with 0.11 config file --- diff --git a/src/config.c b/src/config.c index a464203..37a30ef 100644 --- a/src/config.c +++ b/src/config.c @@ -59,14 +59,14 @@ char *snapshot_path; // -------------------------------------------------- // backward compatibility // detect if it's an old config file (==1) -static int old_config_file; +static int new_config_file; void default_config() { config_path = 0; snapshot_path = 0; - old_config_file = 1; + new_config_file = 0; } void cleanup_config() @@ -236,7 +236,7 @@ void add_entry (char *key, char *value) } } else if (strcmp (key, "panel_items") == 0) { - if (panel_items_order) g_free(panel_items_order); + new_config_file = 1; panel_items_order = strdup(value); int j; for (j=0 ; j < strlen(panel_items_order) ; j++) { @@ -372,6 +372,13 @@ void add_entry (char *key, char *value) /* Clock */ else if (strcmp (key, "time1_format") == 0) { + if (new_config_file == 0) { + clock_enabled = 1; + if (panel_items_order) + panel_items_order = strcat(panel_items_order, "C"); + else + panel_items_order = strdup("C"); + } if (strlen(value) > 0) { time1_format = strdup (value); clock_enabled = 1; @@ -633,6 +640,29 @@ void add_entry (char *key, char *value) } } + // old config option + else if (strcmp(key, "systray") == 0) { + if (new_config_file == 0) { + systray_enabled = atoi(value); + if (systray_enabled) { + if (panel_items_order) + panel_items_order = strcat(panel_items_order, "S"); + else + panel_items_order = strdup("S"); + } + } + } + else if (strcmp(key, "battery") == 0) { + if (new_config_file == 0) { + battery_enabled = atoi(value); + if (battery_enabled) { + if (panel_items_order) + panel_items_order = strcat(panel_items_order, "B"); + else + panel_items_order = strdup("B"); + } + } + } else fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); @@ -705,6 +735,17 @@ int config_read_file (const char *path) } } fclose (fp); + + // append Taskbar item + if (new_config_file == 0) { + taskbar_enabled = 1; + if (panel_items_order) { + char *tmp = strdup("T"); + panel_items_order = strcat(tmp, panel_items_order); + } + else + panel_items_order = strdup("T"); + } return 1; } diff --git a/src/panel.c b/src/panel.c index 9754de7..23bfa63 100644 --- a/src/panel.c +++ b/src/panel.c @@ -80,7 +80,7 @@ void default_panel() task_dragged = 0; panel_horizontal = 1; panel_position = CENTER; - panel_items_order = strdup("LTBSC"); // Default order : Launcher, Taskbar, Battery, Systray, Clock + panel_items_order = 0; panel_autohide = 0; panel_autohide_show_timeout = 0; panel_autohide_hide_timeout = 0; @@ -461,7 +461,7 @@ void set_panel_items(Panel *p) g_slist_free(p->area.list); p->area.list = 0; } - + printf("panel_items_order %s\n", panel_items_order); for (k=0 ; k < strlen(panel_items_order) ; k++) { if (panel_items_order[k] == 'L') { init_launcher_panel(p); diff --git a/src/util/area.c b/src/util/area.c index 460abd9..801e185 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -140,7 +140,7 @@ void size_by_layout (Area *a, int pos, int level) child->posx = pos; child->redraw = 1; } - //printf("level %d, object %d, pos %d\n", level, i, pos); + printf("level %d, object %d, pos %d\n", level, i, pos); size_by_layout(child, pos, level+1);