gboolean cd_powermanager_alert (MyAppletCharge alert)
{
    cd_debug ("%s", __func__);
    GString *sInfo = g_string_new ("");

    gchar *hms = NULL;
    if (myData.battery_time > 0.)
        hms = get_hours_minutes (myData.battery_time);
    else
        hms = g_strdup_printf ("%s", D_("Unknown"));

    if ((alert == POWER_MANAGER_CHARGE_LOW && myConfig.lowBatteryWitness) || (alert == POWER_MANAGER_CHARGE_CRITICAL && myConfig.criticalBatteryWitness))
    {
        g_string_printf (sInfo, "%s (%.2f%%%%) \n %s %s \n %s", D_("PowerManager.\nBattery charge seems to be low"), myData.battery_charge, D_("Estimated time with Charge:"), hms, D_("Please put your Laptop on charge."));
        _cd_powermanager_dialog (sInfo);
    }

    else if (alert == POWER_MANAGER_CHARGE_FULL && myConfig.highBatteryWitness)
    {
        g_string_printf (sInfo, "%s (%.2f%%%%) \n %s %s ", D_("PowerManager.\nYour battery is now Charged"), myData.battery_charge, D_("Estimated time with Charge:"), hms);
        _cd_powermanager_dialog (sInfo);
        if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_FULL] != NULL)
            cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_FULL]);
    }
    if (myConfig.batteryWitness)
    {
        CD_APPLET_ANIMATE_MY_ICON ("rotate", 3);
    }

    g_free (hms);
    g_string_free (sInfo, TRUE);
    myData.alerted = TRUE;
    return FALSE;
}
void cd_powermanager_bubble (void)
{
    cd_debug ("%s", __func__);
    GString *sInfo = g_string_new ("");
    if(myData.battery_present)
    {
        gchar *hms = NULL;
        if (myData.battery_time > 0.)
            hms = get_hours_minutes (myData.battery_time);
        else
            hms = g_strdup_printf ("%s", D_("Unknown"));
        if(myData.on_battery)
        {
            g_string_printf (sInfo, "%s %.2f%%%% \n %s %s", D_("Laptop on Battery.\n Battery charged at:"), myData.battery_charge, D_("Estimated time with Charge:"), hms);
        }
        else
        {
            g_string_printf (sInfo, "%s %.2f%%%% \n %s %s", D_("Laptop on Charge.\n Battery charged at:"), myData.battery_charge, D_("Estimated Charge time:"), hms);
        }
        g_free (hms);
    }
    else
    {
        g_string_printf (sInfo, "%s", D_("No Battery found."));
    }

    _cd_powermanager_dialog (sInfo);
    g_string_free (sInfo, TRUE);
}
void cd_powermanager_bubble (void)
{
	GString *sInfo = g_string_new ("");
	if (myData.cBatteryStateFilePath != NULL || myData.pBatteryDeviceList != NULL)
	{
		// time and charge.
		gchar *hms = NULL;
		if (myData.iTime > 0.)
			hms = get_hours_minutes (myData.iTime);
		else
			hms = g_strdup_printf ("%s", D_("Unknown"));
		if (myData.bOnBattery)
		{
			g_string_printf (sInfo, "%s\n"
				"%s %d%%\n"
				"%s %s",
				D_("Laptop on Battery."),
				D_("Battery charged at:"), (int)myData.iPercentage,
				D_("Estimated time before empty:"), hms);
		}
		else
		{
			g_string_printf (sInfo, "%s\n"
				"%s %d%%\n"
				"%s %s",
				D_("Laptop on Charge."),
				D_("Battery charged at:"), (int)myData.iPercentage,
				D_("Estimated time before full:"), (myData.iPercentage > 99.9 ? "0" : hms));
		}
		g_free (hms);
		
		// static info
		if (myData.cVendor != NULL || myData.cModel != NULL)
		{
			g_string_append_printf (sInfo, "\n%s %s %s", D_("Model:"),
				myData.cVendor ? myData.cVendor : "",
				myData.cModel ? myData.cModel : "");
		}
		if (myData.cTechnology != NULL)
		{
			g_string_append_printf (sInfo, "\n%s %s", D_("Technology:"), myData.cTechnology);
		}
		if (myData.fMaxAvailableCapacity != 0)
		{
			g_string_append_printf (sInfo, "\n%s %d%%", D_("Maximum capacity:"), (int)myData.fMaxAvailableCapacity);
		}
	}
	else
	{
		g_string_assign (sInfo, D_("No battery found."));
	}
	
	_cd_powermanager_dialog (sInfo->str, 7);
	g_string_free (sInfo, TRUE);
}
gboolean cd_powermanager_alert (MyAppletCharge alert)
{
	cd_debug ("%s", __func__);
	GString *sInfo = g_string_new ("");
	
	gchar *hms = NULL;
	if (myData.iTime > 0.)
		hms = get_hours_minutes (myData.iTime);
	else
		hms = g_strdup (D_("Unknown"));
		
	if ((alert == POWER_MANAGER_CHARGE_LOW && myConfig.lowBatteryWitness) || (alert == POWER_MANAGER_CHARGE_CRITICAL && myConfig.criticalBatteryWitness))
	{
		if (myConfig.iNotificationType != 1)
		{
			g_string_printf (sInfo, "%s (%d%%) \n %s %s \n %s", D_("PowerManager.\nBattery charge seems to be low"), (int)myData.iPercentage, D_("Estimated time with charge:"), hms, D_("Please put your laptop on charge."));
			_cd_powermanager_dialog (sInfo->str, myConfig.iNotificationDuration);
		}
		if (myConfig.iNotificationType != 2)
		{
			CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, myConfig.iNotificationDuration);
		}
		if (myConfig.cSoundPath[alert] != NULL)
			cairo_dock_play_sound (myConfig.cSoundPath[alert]);
	}
	else if (alert == POWER_MANAGER_CHARGE_FULL && myConfig.highBatteryWitness)
	{
		if (myConfig.iNotificationType != 1)
		{
			g_string_printf (sInfo, "%s (%d%%)", D_("PowerManager.\nYour battery is now charged"), (int)myData.iPercentage);
			_cd_powermanager_dialog (sInfo->str, myConfig.iNotificationDuration);
		}
		if (! myData.bIsHidden && myConfig.iNotificationType != 2)
		{
			CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, myConfig.iNotificationDuration);
		}
		if (myConfig.cSoundPath[alert] != NULL)
			cairo_dock_play_sound (myConfig.cSoundPath[alert]);
	}
	
	g_free (hms);
	g_string_free (sInfo, TRUE);
	return FALSE;
}