Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/ChangeLog,v
retrieving revision 1.272
diff -u -r1.272 ChangeLog
--- ChangeLog	19 Jan 2006 16:48:41 -0000	1.272
+++ ChangeLog	19 Jan 2006 20:33:02 -0000
@@ -1,3 +1,11 @@
+2006-01-19  Jaap Haitsma  <jaap@haitsma.org>
+
+	* src/gpm-power.c: (power_get_summary_for_kind) 
+	Make tooltip more concise. Make some comments clearer or remove them.
+
+	* src/gpm-common.c: return "Unknown time" if minutes <=0 for
+	get_timestring_from_minutes ()
+
 2006-01-19  William Jon McCann  <mccann@jhu.edu>
 
 	* src/gpm-prefs.c (gpm_prefs_help_cb): Use gnome_help.
Index: src/gpm-common.c
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-common.c,v
retrieving revision 1.36
diff -u -r1.36 gpm-common.c
--- src/gpm-common.c	11 Jan 2006 19:59:37 -0000	1.36
+++ src/gpm-common.c	19 Jan 2006 20:33:02 -0000
@@ -48,7 +48,7 @@
 	gint   hours;
 
 	if (minutes == 0) {
-		timestring = g_strdup_printf (_("Unknown"));
+		timestring = g_strdup_printf (_("Unknown time"));
 		return timestring;
 	}
 
Index: src/gpm-power.c
===================================================================
RCS file: /cvs/gnome/gnome-power-manager/src/gpm-power.c,v
retrieving revision 1.10
diff -u -r1.10 gpm-power.c
--- src/gpm-power.c	18 Jan 2006 22:09:46 -0000	1.10
+++ src/gpm-power.c	19 Jan 2006 20:33:03 -0000
@@ -485,7 +485,10 @@
 		}
 	}
 
-	/* use floating division here */
+	/* Perform following calculations with floating point otherwise we might
+	 * get an with batteries which have a very small charge unit and consequently
+	 * a very high charge. Solves bug #327471 
+	 */
 	entry->percentage_charge = 100 * ((float)entry->current_charge / (float)entry->last_full_charge);
 
 	if ((entry->is_discharging) && (entry->charge_rate != 0)) {
@@ -494,7 +497,6 @@
 		entry->remaining_time = 3600 * ((float)(entry->last_full_charge - entry->current_charge) / (float)entry->charge_rate);
 	}
 
-	/* find new percentage_charge  */
 	new_charge = entry->percentage_charge;
 
 	g_debug ("new_charge = %i, old_charge = %i", new_charge, old_charge);
@@ -618,8 +620,7 @@
 			    GString    *summary)
 {
 	BatteryKindCacheEntry *entry;
-	const char            *kind_desc = NULL;
-	const char            *charge_state = NULL;
+	char *timestring;
 
 	entry = battery_kind_cache_find (power, kind);
 
@@ -631,8 +632,6 @@
 		return;
 	}
 
-	kind_desc = kind_for_display (entry->kind);
-
 	/* don't display all the extra stuff for keyboards and mice */
 	if (strcmp (entry->kind, "mouse") == 0
 	    || strcmp (entry->kind, "keyboard") == 0
@@ -640,60 +639,37 @@
 
 		g_string_append_printf (summary,
 					"%s (%i%%)\n",
-					kind_desc,
+					kind_for_display (entry->kind),
 					entry->percentage_charge);
 		return;
 	}
 
-	/* work out chargestate */
+	/* Add 0.5 to do rounding */
+	timestring = get_timestring_from_minutes ((int)((entry->remaining_time / 60.0) + 0.5));
+
 	if (entry->is_charging) {
-		charge_state = _("charging");
+		g_string_append_printf (summary,
+					"%s %s (%i%%)\n",
+					timestring,
+					_("until charged"),
+					entry->percentage_charge);
 	} else if (entry->is_discharging) {
-		charge_state = _("discharging");
-	} else if (entry->percentage_charge > 99) {
-		charge_state = _("charged");
-	} else if (power->priv->on_ac) {
-		/* intermediate state: assume charging if on-ac */
-		charge_state = _("charging");
+		g_string_append_printf (summary,
+					"%s (%i%%) %s\n",
+					timestring,
+					entry->percentage_charge,
+					_("remaining"));
+	} else if (!entry->is_discharging && !entry->is_charging && entry->percentage_charge == 100){
+		g_string_append_printf (summary,
+					"%s %s\n",
+					kind_for_display (entry->kind),
+					_("fully charged"));
 	} else {
-		/* intermediate state: assume discharging if not on-ac */
-		charge_state = _("discharging");
-	}
-
-	g_string_append_printf (summary,
-				"%s %s (%i%%)",
-				kind_desc,
-				charge_state,
-				entry->percentage_charge);
-
-	/*
-	 * only display time remaining if remaining_time > 120
-	 * and percentage_charge < 99 to cope with some broken
-	 * batteries.
-	 */
-	if (entry->remaining_time > 120 && entry->percentage_charge < 99) {
-		char *timestring;
-
-		/* why add 0.5 ? */
-		timestring = get_timestring_from_minutes ((int)((entry->remaining_time / 60) + 0.5));
-
-		if (timestring) {
-			if (entry->is_charging) {
-				g_string_append_printf (summary,
-							"\n%s %s",
-							timestring,
-							_("until charged"));
-			} else {
-				g_string_append_printf (summary,
-							"\n%s %s",
-							timestring,
-							_("until empty"));
-			}
-			g_free (timestring);
-		}
+		g_warning ("power_get_summary_for_kind (): in an undefined state we are not charging or "
+			   "discharging and the batteries are also not fully loaded");
 	}
-	g_string_append (summary, "\n");
 
+	g_free (timestring);
 }
 
 gboolean
@@ -1078,7 +1054,6 @@
 
 	battery_device_cache_entry_update_key (entry, key);
 
-	/* find old percentage_charge */
 	kind_entry = battery_kind_cache_find (power, entry->kind);
 
 	if (kind_entry == NULL) {
