]> Dogcows Code - chaz/tint2/commitdiff
panel_items : fixed hide/unhide of baterry and systray
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Wed, 22 Sep 2010 19:33:10 +0000 (19:33 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Wed, 22 Sep 2010 19:33:10 +0000 (19:33 +0000)
src/battery/battery.c
src/clock/clock.c
src/systray/systraybar.c
src/util/area.c
src/util/area.h

index 46eb539a650fc1c66c7feb8c40a90575f35e7655..fd4d59b26be8612418840b840b90266a969a3bb6 100644 (file)
@@ -79,14 +79,14 @@ void update_batterys(void* arg)
        for (i=0 ; i < nb_panel ; i++) {
                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;
+                               hide(&panel1[i].battery.area);
                                panel_refresh = 1;
                        }
                }
                else {
                        if (panel1[i].battery.area.on_screen == 0) {
-                               panel1[i].battery.area.on_screen = 1;
+                               show(&panel1[i].battery.area);
+                               panel_refresh = 1;
                        }
                }
                if (panel1[i].battery.area.on_screen == 1) {
@@ -237,9 +237,6 @@ void init_battery_panel(void *p)
        battery->area._draw_foreground = draw_battery;
        battery->area.size_mode = SIZE_BY_CONTENT;
        battery->area._resize = resize_battery;
-       battery->area.resize = 1;
-       battery->area.redraw = 1;
-       battery->area.on_screen = 1;
 }
 
 
@@ -462,14 +459,13 @@ int resize_battery(void *obj)
        }
        else {
                int new_size = bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
-               if (new_size != battery->area.height) {
+               if (new_size > battery->area.height || new_size < (battery->area.height-2)) {
                        battery->area.height =  new_size;
                        battery->bat1_posy = ((battery->area.height - bat_percentage_height) / 2) - ((bat_time_height_ink + 2) / 2);
                        battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
                        ret = 1;
                }
        }
-
        return ret;
 }
 
index 55e5e456285b59b019dc8f9d4460a22c3e2c05e5..79c4266f3b239e86c318033c8a9b38833c2f459b 100644 (file)
@@ -148,12 +148,11 @@ void init_clock_panel(void *p)
        clock->area._draw_foreground = draw_clock;
        clock->area.size_mode = SIZE_BY_CONTENT;
        clock->area._resize = resize_clock;
-       clock->area.resize = 1;
-       clock->area.redraw = 1;
        // check consistency
        if (time1_format == 0)
                return;
 
+       clock->area.resize = 1;
        clock->area.on_screen = 1;
 
        if (time_tooltip_format) {
@@ -205,6 +204,7 @@ int resize_clock (void *obj)
 
        clock->area.redraw = 1;
        
+       date_height = date_width = 0;
        strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
        get_text_size2(time1_font_desc, &time_height_ink, &time_height, &time_width, panel->area.height, panel->area.width, buf_time, strlen(buf_time));
        if (time2_format) {
index 2d13af46b457eb0c908cb7b01f8464530f1e1079..e5bb7a1260a716c4237e76195a4ad4d832fc5cdf 100644 (file)
@@ -107,9 +107,9 @@ void init_systray_panel(void *p)
                        count++;
        }
        if (count == 0)
-               systray.area.on_screen = 0;
+               hide(&systray.area);
        else 
-               systray.area.on_screen = 1;
+               show(&systray.area);
        refresh_systray = 0;
 }
 
@@ -426,7 +426,7 @@ gboolean add_icon(Window id)
        traywin->damage = 0;
 
        if (systray.area.on_screen == 0)
-               systray.area.on_screen = 1;
+               show(&systray.area);
 
        if (systray.sort == 3)
                systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
@@ -488,10 +488,9 @@ void remove_icon(TrayWindow *traywin)
                if (!((TrayWindow*)l->data)->hide)
                        count++;
        }
-       if (count == 0) {
-               systray.area.on_screen = 0;
-               systray.area.width = 0;
-       }
+       if (count == 0)
+               hide(&systray.area);
+               
        // changed in systray
        systray.area.resize = 1;
        panel_refresh = 1;
index 0320bbb549a32e3bd0206be094f12c8d3ecd153c..e5804335442eb454e0a53e60097f790c0cbd1168 100644 (file)
@@ -123,8 +123,8 @@ void size_by_content (Area *a)
                        if (a->_resize(a)) {
                                // 'size' changed => 'resize = 1' on the parent and redraw object
                                ((Area*)a->parent)->resize = 1;
-                               a->redraw = 1;
                        }
+                       a->redraw = 1;
                }
        }
 }
@@ -317,6 +317,26 @@ void set_redraw (Area *a)
                set_redraw(l->data);
 }
 
+void hide(Area *a)
+{
+       Area *parent = (Area*)a->parent;
+
+       a->on_screen = 0;
+       parent->resize = 1;
+       if (panel_horizontal)
+               a->width = 0;
+       else
+               a->height = 0;
+}
+
+void show(Area *a)
+{
+       Area *parent = (Area*)a->parent;
+
+       a->on_screen = 1;
+       parent->resize = 1;
+       a->resize = 1;
+}
 
 void draw (Area *a)
 {
index a5d1434e856e818f14aa81aa1fea20216a810074..2f8d822671b3ef75b486d3fa1535d0b97ab355f5 100644 (file)
@@ -104,6 +104,10 @@ int resize_by_layout(void *obj);
 // set 'redraw' on an area and childs
 void set_redraw (Area *a);
 
+// hide/unhide area
+void hide(Area *a);
+void show(Area *a);
+
 // draw pixmap
 void draw (Area *a);
 void draw_background (Area *a, cairo_t *c);
This page took 0.024889 seconds and 4 git commands to generate.