Changeset 3272


Ignore:
Timestamp:
10/25/07 18:57:18 (6 years ago)
Author:
thomas
Message:
  • src/openmoko-panel-battery.c: (timeout),

(mb_panel_applet_create): Only update the display if the battery status

has changed

Location:
trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery/ChangeLog

    r2897 r3272  
    1 2007-09-02      Michael Lauer <mickey@openmoko.org> 
     12007-10-25  Thomas Wood  <thomas@openedhand.com> 
     2 
     3        * src/openmoko-panel-battery.c: (timeout), 
     4        (mb_panel_applet_create): Only update the display if the battery status 
     5         has changed 
     6 
     72007-09-02 Michael Lauer <mickey@openmoko.org> 
    28 
    39        * src/openmoko-battery-plugin.c: 
  • trunk/src/target/OM-2007.2/panel-plugins/openmoko-panel-battery/src/openmoko-panel-battery.c

    r2897 r3272  
     1/* vim: set sts=4 sw=4 expandtab: */ 
    12/*  openmoko-panel-battery.c 
    23 * 
     
    2021 */ 
    2122 
     23 
    2224#include <libmokopanelui2/moko-panel-applet.h> 
    2325 
     
    3032#define JUICE_PIXMAPS 6 
    3133 
    32 #define DEBUG_THIS_FILE 
    33  
    3434typedef struct { 
    3535    MokoPanelApplet* mokoapplet; 
     
    3737} BatteryApplet; 
    3838 
     39/* applets cannot be unloaded yet */ 
     40#if 0 
    3941static void 
    4042battery_applet_free (BatteryApplet *applet) 
     
    4345    g_slice_free (BatteryApplet, applet); 
    4446} 
     47#endif 
    4548 
    4649/* Called every 5 minutes */ 
     
    4851timeout (BatteryApplet *applet) 
    4952{ 
    50     // g_debug( "openmoko-panel-battery::timeout" ); 
     53    char* icon; 
     54    static int last_status = -255; /* the status last time we checked */ 
    5155 
    5256    apm_info info; 
     
    5559    apm_read (&info); 
    5660 
    57     char* icon; 
     61    /* don't do any update if status is the same as the last time */ 
     62    if (last_status == info.battery_status) 
     63    { 
     64        return TRUE; 
     65    } 
    5866 
    5967    //FIXME Can we actually find out, when the battery is full? 
    6068 
    61     // g_debug( "-- info.battery_status = %0xd", info.battery_status ); 
    62     // g_debug( "-- info.battery_percentage = %0xd", info.battery_percentage ); 
     69    last_status = info.battery_status; 
    6370 
    6471    if ( info.battery_status == BATTERY_STATUS_ABSENT || 
     
    8390    } 
    8491 
    85     //FIXME Check whether we actually need to update 
     92    moko_panel_applet_set_icon( applet->mokoapplet, icon ); 
    8693 
    87     moko_panel_applet_set_icon( applet->mokoapplet, icon ); 
    8894    return TRUE; 
    8995} 
     
    98104    t = time( NULL ); 
    99105    local_time = localtime(&t); 
    100 #ifndef DEBUG_THIS_FILE 
    101     applet->timeout_id = g_timeout_add( 60 * 1000 * 5, (GSourceFunc) timeout, applet); 
     106 
     107    //FIXME Add source watching for charger insertion event on /dev/input/event1 
     108 
     109    /* should use g_timeout_add_seconds() here to save power, but it is only 
     110     * available in glib >= 2.14 
     111     */ 
     112    applet->timeout_id = g_timeout_add ( 10 * 1000, (GSourceFunc) timeout, applet); 
    102113    timeout(applet); 
    103     //FIXME Add source watching for charger insertion event on /dev/input/event1 
    104 #else 
    105     applet->timeout_id = g_timeout_add( 10 * 1000, (GSourceFunc) timeout, applet); 
    106 #endif 
     114 
    107115    moko_panel_applet_set_icon( mokoapplet, PKGDATADIR "/Battery_00.png" ); 
    108116    gtk_widget_show_all( GTK_WIDGET(mokoapplet) ); 
Note: See TracChangeset for help on using the changeset viewer.