panel_items : backward compatibility with 0.11 config file

git-svn-id: http://tint2.googlecode.com/svn/trunk@552 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
thilor77 2010-09-18 21:22:53 +00:00
parent 8b71e3614c
commit ffe45bd7da
3 changed files with 47 additions and 6 deletions

View file

@ -59,14 +59,14 @@ char *snapshot_path;
// -------------------------------------------------- // --------------------------------------------------
// backward compatibility // backward compatibility
// detect if it's an old config file (==1) // detect if it's an old config file (==1)
static int old_config_file; static int new_config_file;
void default_config() void default_config()
{ {
config_path = 0; config_path = 0;
snapshot_path = 0; snapshot_path = 0;
old_config_file = 1; new_config_file = 0;
} }
void cleanup_config() void cleanup_config()
@ -236,7 +236,7 @@ void add_entry (char *key, char *value)
} }
} }
else if (strcmp (key, "panel_items") == 0) { 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); panel_items_order = strdup(value);
int j; int j;
for (j=0 ; j < strlen(panel_items_order) ; j++) { for (j=0 ; j < strlen(panel_items_order) ; j++) {
@ -372,6 +372,13 @@ void add_entry (char *key, char *value)
/* Clock */ /* Clock */
else if (strcmp (key, "time1_format") == 0) { 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) { if (strlen(value) > 0) {
time1_format = strdup (value); time1_format = strdup (value);
clock_enabled = 1; 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 else
fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key);
@ -706,6 +736,17 @@ int config_read_file (const char *path)
} }
fclose (fp); 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; return 1;
} }

View file

@ -80,7 +80,7 @@ void default_panel()
task_dragged = 0; task_dragged = 0;
panel_horizontal = 1; panel_horizontal = 1;
panel_position = CENTER; panel_position = CENTER;
panel_items_order = strdup("LTBSC"); // Default order : Launcher, Taskbar, Battery, Systray, Clock panel_items_order = 0;
panel_autohide = 0; panel_autohide = 0;
panel_autohide_show_timeout = 0; panel_autohide_show_timeout = 0;
panel_autohide_hide_timeout = 0; panel_autohide_hide_timeout = 0;
@ -461,7 +461,7 @@ void set_panel_items(Panel *p)
g_slist_free(p->area.list); g_slist_free(p->area.list);
p->area.list = 0; p->area.list = 0;
} }
printf("panel_items_order %s\n", panel_items_order);
for (k=0 ; k < strlen(panel_items_order) ; k++) { for (k=0 ; k < strlen(panel_items_order) ; k++) {
if (panel_items_order[k] == 'L') { if (panel_items_order[k] == 'L') {
init_launcher_panel(p); init_launcher_panel(p);

View file

@ -140,7 +140,7 @@ void size_by_layout (Area *a, int pos, int level)
child->posx = pos; child->posx = pos;
child->redraw = 1; 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); size_by_layout(child, pos, level+1);