]> Dogcows Code - chaz/tint2/commitdiff
panel_items : fixed some segfault.
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 14:58:00 +0000 (14:58 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 14:58:00 +0000 (14:58 +0000)
src/battery/battery.c
src/clock/clock.c
src/launcher/launcher.c
src/util/area.c

index 8fd6aa03deb0fb654b0cd5687d197972218b4fba..086b6d0dd7180910f6780857026d87137e35438d 100644 (file)
@@ -73,17 +73,20 @@ void update_batterys(void* arg)
                if (battery_state.percentage >= percentage_hide) {
                        if (panel1[i].battery.area.on_screen == 1) {
                                panel1[i].battery.area.on_screen = 0;
+                               panel1[i].area.resize = 1;
                                panel_refresh = 1;
                        }
-                       continue;
                }
                else {
                        if (panel1[i].battery.area.on_screen == 0) {
                                panel1[i].battery.area.on_screen = 1;
-                               panel_refresh = 1;
+                               panel1[i].area.resize = 1;
                        }
                }
-               panel1[i].battery.area.resize = 1;
+               if (panel1[i].battery.area.on_screen == 1) {
+                       panel1[i].battery.area.resize = 1;
+                       panel_refresh = 1;
+               }
        }
 }
 
@@ -448,7 +451,6 @@ int resize_battery(void *obj)
 
        percentage_width = time_width = 0;
        battery->area.redraw = 1;
-
        snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
        if(battery_state.state == BATTERY_FULL) {
                strcpy(buf_bat_time, "Full");
index 783f7e9ff4031f5d269623804d4218b05bdd73dd..70babb66ab75e9315d36965de06d14e6480088e9 100644 (file)
@@ -151,8 +151,11 @@ void init_clock_panel(void *p)
        clock->area._resize = resize_clock;
        clock->area.resize = 1;
        clock->area.redraw = 1;
-       clock->area.on_screen = 1;
+       // check consistency
+       if (time1_format == 0)
+               return;
 
+       clock->area.on_screen = 1;
        strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
        get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time));
        if (time2_format) {
@@ -167,8 +170,6 @@ void init_clock_panel(void *p)
        }
        else {
                // panel vertical => fixed width, height, posy and posx
-//             clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
-//             clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
                clock->area.posx = panel->area.bg->border.width + panel->area.paddingy;
                clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
        }
@@ -236,7 +237,11 @@ int resize_clock (void *obj)
                strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
 
        // vertical panel doen't adjust width
-       if (!panel_horizontal) return ret;
+       if (!panel_horizontal) {
+//             clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
+//             clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
+               return ret;
+       }
 
        //printf("  resize_clock\n");
        cairo_surface_t *cs;
index 50d3829100636e665a6bcf1e833ab4dd4f9e8841..75388f1099b24fd9ee9975382610049336b7a8a6 100644 (file)
@@ -70,8 +70,12 @@ void init_launcher_panel(void *p)
        launcher->area._resize = resize_launcher;
        launcher->area.resize = 1;
        launcher->area.redraw = 1;
-       launcher->area.on_screen = 1;
 
+       // check consistency
+       if (launcher->list_apps == NULL)
+               return;
+
+       launcher->area.on_screen = 1;
        if (panel_horizontal) {
                // panel horizonal => fixed height and posy
                launcher->area.posy = panel->area.bg->border.width + panel->area.paddingy;
@@ -149,6 +153,7 @@ void cleanup_launcher()
        launcher_enabled = 0;
 }
 
+
 int resize_launcher(void *obj)
 {
        Launcher *launcher = obj;
@@ -222,9 +227,6 @@ int resize_launcher(void *obj)
                        icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
                        launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx);
                }
-
-//             launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr;
-               launcher->area.posy = panel->area.bg->border.width;
        }
        else {
                if (!count) launcher->area.height = 0;
@@ -236,9 +238,6 @@ int resize_launcher(void *obj)
                        icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
                        launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * launcher->area.paddingx);
                }
-
-               launcher->area.posx = panel->area.bg->border.width;
-//             launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height;
        }
 
        int i, posx, posy;
index ce122a2178d5f31de655c074da6aa6f380d1d0ea..460abd94e0f7ffc258c981f14ee2c317eefa2519 100644 (file)
  * 'panel_items = SC' define a panel with just Systray and Clock.
  * So the tree 'Panel.Area' will have 2 childs (Systray and Clock).
  *
- * 1) ok
- * 2) ??
- * 3) ??
- * répartition entre niveau global et niveau local ??
- *   size_by_content peut-il modifier redraw=1 en cas de changement ? ou est ce géré par chaque composant ?
- *   size_by_layout peut-il modifier redraw ?
- *
  ************************************************************/
 
 void rendering(void *obj)
This page took 0.028083 seconds and 4 git commands to generate.