Merging upstream version 0.5.7.
[debian/lxpanel.git] / debian / patches / batt_status.patch
1 diff -ur lxpanel-0.5.5-orig//src/plugins/batt/batt_sys.c lxpanel-0.5.5//src/plugins/batt/batt_sys.c
2 --- lxpanel-0.5.5-orig//src/plugins/batt/batt_sys.c     2010-02-06 20:45:38.000000000 +0100
3 +++ lxpanel-0.5.5//src/plugins/batt/batt_sys.c  2010-05-06 14:02:29.000000000 +0200
4 @@ -38,6 +38,13 @@
5  battery* battery_new() {
6      static int battery_num = 1;
7      battery * b = g_new0 ( battery, 1 );
8 +    battery_reset(b);
9 +    b->battery_num = battery_num;
10 +    battery_num++;
11 +    return b;
12 +}
13 +
14 +void battery_reset( battery * b) {
15      b->type_battery = TRUE;
16      b->capacity_unit = "mAh";
17      b->last_capacity_unit = -1;
18 @@ -49,12 +56,8 @@
19      b->remaining_capacity = -1;
20      b->present_rate = -1;
21      b->state = NULL;
22 -    b->battery_num = battery_num;
23 -    battery_num++;
24 -    return b;
25  }
26  
27 -
28  static gchar* parse_info_file(char *filename)
29  {
30      char *buf = NULL;
31 @@ -136,6 +139,8 @@
32      };
33      const gchar *sys_file;
34  
35 +    battery_reset(b);
36 +
37      while ( (sys_file = sys_list[i]) != NULL ) {
38      
39         gchar *file_content;
40 @@ -150,7 +155,7 @@
41                     b->state = "available";
42             }
43             else if ( strcmp("energy_now", sys_file ) == 0 ) {
44 -               b->remaining_capacity = get_unit_value((gchar*) file_content) / 1000;
45 +               b->remaining_energy = get_unit_value((gchar*) file_content) / 1000;
46                 if (!b->state)
47                     b->state = "available";
48             }
49