]> Dogcows Code - chaz/tint2/commitdiff
panel_items : backward compatibility with 0.11 config file
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 21:22:53 +0000 (21:22 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 21:22:53 +0000 (21:22 +0000)
src/config.c
src/panel.c
src/util/area.c

index a4642031c9d06f22d2074469867d11130a1071da..37a30eff74d31dc2228d5e45356eaf44996d8568 100644 (file)
@@ -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;
 }
index 9754de79ee22b9585ed9eff799c2f8e21dec2b29..23bfa6363d456a5c23b7495f1f054bfa80f05a42 100644 (file)
@@ -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);
index 460abd94e0f7ffc258c981f14ee2c317eefa2519..801e185776aad83d04c8e219eddbfcb6ffb71c32 100644 (file)
@@ -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);
                
This page took 0.02489 seconds and 4 git commands to generate.