[Goodies-commits] r7350 - in xfce4-power-manager/trunk: . libxfpm settings src

Ali Abdallah aliov at xfce.org
Sat May 16 19:38:01 CEST 2009


Author: aliov
Date: 2009-05-16 17:38:01 +0000 (Sat, 16 May 2009)
New Revision: 7350

Modified:
   xfce4-power-manager/trunk/ChangeLog
   xfce4-power-manager/trunk/libxfpm/hal-battery.c
   xfce4-power-manager/trunk/libxfpm/xfpm-notify.c
   xfce4-power-manager/trunk/libxfpm/xfpm-notify.h
   xfce4-power-manager/trunk/settings/xfpm-settings.glade
   xfce4-power-manager/trunk/src/xfpm-battery.c
Log:
Handle wrong battery information data

Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/ChangeLog	2009-05-16 17:38:01 UTC (rev 7350)
@@ -1,4 +1,7 @@
 
+2009-05-16 19:37 Ali aliov at xfce.org 
+	 * : Handle wrong battery information data
+
 2009-05-16 19:06 Ali aliov at xfce.org 
 	 * : Open settings dialog when tray icon is clicked
 

Modified: xfce4-power-manager/trunk/libxfpm/hal-battery.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/hal-battery.c	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/libxfpm/hal-battery.c	2009-05-16 17:38:01 UTC (rev 7350)
@@ -386,11 +386,20 @@
     guint val = 100;
     float f;
     
-    if ( last_full <= current ) return val;
+    if ( G_UNLIKELY (last_full <= current) ) return val;
     
+    /*
+     * Special case when we get 0 as last full
+     * this happens for me once i had the battery
+     * totally empty on my aspire one.
+     */
+    if ( G_UNLIKELY (last_full == 0 ) )
+	return 0;
+	
     f = (float)current/last_full *100;
 	
 	val = (guint)f;
+	
     return val;   
 }
 

Modified: xfce4-power-manager/trunk/libxfpm/xfpm-notify.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-notify.c	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-notify.c	2009-05-16 17:38:01 UTC (rev 7350)
@@ -260,3 +260,10 @@
     if ( n )
 	g_object_unref (n);
 }
+
+void xfpm_notify_close_normal  (XfpmNotify *notify)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+    
+    xfpm_notify_close_notification (notify);
+}

Modified: xfce4-power-manager/trunk/libxfpm/xfpm-notify.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-notify.h	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-notify.h	2009-05-16 17:38:01 UTC (rev 7350)
@@ -90,6 +90,9 @@
 								     NotifyNotification *n);
 
 void                      xfpm_notify_close_critical                (XfpmNotify *notify);
+
+void			  xfpm_notify_close_normal		    (XfpmNotify *notify);
+
 G_END_DECLS
 
 #endif /* __XFPM_NOTIFY_H */

Modified: xfce4-power-manager/trunk/settings/xfpm-settings.glade
===================================================================
--- xfce4-power-manager/trunk/settings/xfpm-settings.glade	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/settings/xfpm-settings.glade	2009-05-16 17:38:01 UTC (rev 7350)
@@ -360,6 +360,7 @@
                                             </child>
                                           </widget>
                                           <packing>
+                                            <property name="expand">False</property>
                                             <property name="position">1</property>
                                           </packing>
                                         </child>

Modified: xfce4-power-manager/trunk/src/xfpm-battery.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.c	2009-05-16 17:06:56 UTC (rev 7349)
+++ xfce4-power-manager/trunk/src/xfpm-battery.c	2009-05-16 17:38:01 UTC (rev 7350)
@@ -273,8 +273,14 @@
 				guint percentage,
 				guint8 critical_level)
 {
-    if ( !is_charging && !is_discharging && last_full == current_charge )
+    if ( G_UNLIKELY (current_charge == 0 || percentage == 0) )
     {
+	*state = BATTERY_CHARGE_CRITICAL;
+	return _("is empty");
+    }
+    
+    if ( !is_charging && !is_discharging &&  current_charge >= last_full )
+    {
 	*state = BATTERY_FULLY_CHARGED;
 	return _("is fully charged");
     }
@@ -322,8 +328,11 @@
 	battery->priv->state = state;
 	TRACE("Emitting signal battery state changed");
 	g_signal_emit (G_OBJECT(battery), signals[BATTERY_STATE_CHANGED], 0, state);
+	
 	if ( battery->priv->state != BATTERY_NOT_FULLY_CHARGED )
 	    xfpm_battery_notify (battery);
+	else
+	    xfpm_notify_close_normal (battery->priv->notify);
     }
 }
 
@@ -451,7 +460,15 @@
 		  "current-charge", &current_charge,
 		  "time", &time_per,
 		  NULL);
-    
+		  
+    TRACE ("Battery status is_present %s is_charging %s is_discharging %s", 
+	   xfpm_bool_to_string (is_present), 
+	   xfpm_bool_to_string (is_charging), 
+	   xfpm_bool_to_string (is_discharging));
+	   
+    TRACE ("Battery info precentage %i last_full %i current_charge %i time_per %i",
+	   percentage, last_full, current_charge, time_per);
+	   
     battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ?
 			   xfpm_battery_refresh_primary (battery, is_present, 
 							 is_charging, is_discharging, 




More information about the Goodies-commits mailing list