#include "dockapp.h"
#include "dockapp-mask.xpm"
+#define BAT_BORDER 2
#define BAT_W 35
#define BAT_H 49
#define BAT_TIP_W (BAT_W / 2)
static void
draw_background(GtkWidget *clock, cairo_t *cr)
{
- int y;
+ int y_start;
+ int height;
read_ac_status();
read_battery_status();
cairo_save(cr);
- cairo_set_line_width(cr, 2);
+ cairo_set_line_width(cr, BAT_BORDER);
/* Draw battery tip. */
color_set_gray(cr);
color_set_green(cr);
}
- y = BAT_START_Y + BAT_TIP_H + BAT_H - ((BAT_H * capacity) / 100);
+ y_start = BAT_START_Y + BAT_TIP_H + BAT_H;
- /* Draw remaining capacity. */
- cairo_rectangle(cr, BAT_START_X, y, BAT_W,
- BAT_START_Y + BAT_TIP_H + BAT_H - y);
+ /* Compute colored height (no borders). */
+ height = ((BAT_H - BAT_BORDER) * capacity) / 100;
+
+ /* Make sure capacity > 0 gets a colored line. */
+ if ((capacity != 0) && (height == 0))
+ height = 1;
+ /* Add border width: */
+ height += BAT_BORDER;
+
+ /* Draw remaining capacity. */
+ cairo_rectangle(cr, BAT_START_X, y_start, BAT_W, -height);
cairo_fill_preserve(cr);
color_set_black(cr);
cairo_stroke(cr);