=== modified file 'src/xfpm-battery.c' --- src/xfpm-battery.c 2009-09-24 09:10:34 +0000 +++ src/xfpm-battery.c 2009-09-26 20:41:29 +0000 @@ -159,10 +159,12 @@ XfpmBatteryState state, guint percentage) { - gchar *icon; + gchar *icon = NULL, *notify_icon = NULL; if ( state == BATTERY_NOT_PRESENT ) { + //FIXME what icon is most appropriate for this case? When does it happen? + xfpm_tray_icon_set_notify_icon (battery->priv->icon, "notification-battery-100-plugged"); xfpm_tray_icon_set_icon (battery->priv->icon, battery->priv->type == HAL_DEVICE_TYPE_UPS ? "xfpm-ups-missing" : "xfpm-primary-missing"); return; @@ -172,7 +174,10 @@ if ( state == BATTERY_FULLY_CHARGED ) { if ( battery->priv->type == HAL_DEVICE_TYPE_PRIMARY) + { + xfpm_tray_icon_set_notify_icon (battery->priv->icon, battery->priv->adapter_present ? "notification-battery-100-plugged" : "notification-battery-100"); xfpm_tray_icon_set_icon (battery->priv->icon, battery->priv->adapter_present ? "xfpm-primary-charged" : "xfpm-primary-100"); + } else { icon = g_strdup_printf("%s%s", @@ -180,6 +185,11 @@ xfpm_battery_get_icon_index (battery->priv->type, percentage)); xfpm_tray_icon_set_icon (battery->priv->icon, icon); g_free(icon); + + notify_icon = g_strdup_printf("%s%s", "notification-battery-", + xfpm_battery_get_icon_index (battery->priv->type, percentage)); + xfpm_tray_icon_set_notify_icon (battery->priv->icon, notify_icon); + g_free(notify_icon); } } else if ( state == BATTERY_NOT_FULLY_CHARGED ) @@ -190,16 +200,26 @@ battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, percentage), "charging"); + notify_icon = g_strdup_printf("%s%s-%s", + "notification-battery-", + xfpm_battery_get_icon_index (battery->priv->type, percentage), + "plugged"); } else { icon = g_strdup_printf("%s%s", battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, percentage)); + notify_icon = g_strdup_printf("%s%s", + "notification-battery-", + xfpm_battery_get_icon_index (battery->priv->type, percentage)); } xfpm_tray_icon_set_icon (battery->priv->icon, icon); g_free(icon); + xfpm_tray_icon_set_notify_icon (battery->priv->icon, notify_icon); + g_free(notify_icon); + } else if ( state == BATTERY_IS_CHARGING ) { @@ -207,9 +227,16 @@ battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, percentage), "charging"); + notify_icon = g_strdup_printf("%s%s-%s", + "notification-battery-", + xfpm_battery_get_icon_index (battery->priv->type, percentage), + "plugged"); xfpm_tray_icon_set_icon (battery->priv->icon, icon); g_free(icon); + + xfpm_tray_icon_set_notify_icon (battery->priv->icon, notify_icon); + g_free(notify_icon); } else if ( state == BATTERY_IS_DISCHARGING || state == BATTERY_CHARGE_CRITICAL || state == BATTERY_CHARGE_LOW ) @@ -217,10 +244,15 @@ icon = g_strdup_printf("%s%s", battery->priv->icon_prefix, xfpm_battery_get_icon_index (battery->priv->type, percentage)); + notify_icon = g_strdup_printf("%s%s", + "notification-battery-", + xfpm_battery_get_icon_index (battery->priv->type, percentage)); xfpm_tray_icon_set_icon (battery->priv->icon, icon); g_free(icon); + xfpm_tray_icon_set_notify_icon (battery->priv->icon, notify_icon); + g_free(notify_icon); } } @@ -239,7 +271,7 @@ xfpm_notify_show_notification (battery->priv->notify, _("Xfce power manager"), message, - xfpm_tray_icon_get_icon_name (battery->priv->icon), + xfpm_tray_icon_get_notify_icon_name (battery->priv->icon), 8000, battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ? FALSE : TRUE, XFPM_NOTIFY_NORMAL, === modified file 'src/xfpm-tray-icon.c' --- src/xfpm-tray-icon.c 2009-09-24 09:10:34 +0000 +++ src/xfpm-tray-icon.c 2009-09-26 20:52:17 +0000 @@ -60,6 +60,7 @@ GtkStatusIcon *icon; GQuark icon_quark; + GQuark notify_icon_quark; gboolean info_menu; gboolean inhibited; gboolean data_available; @@ -118,7 +119,7 @@ xfpm_notify_show_notification (tray->priv->notify, _("Xfce power manager"), error->message, - xfpm_tray_icon_get_icon_name (tray), + xfpm_tray_icon_get_notify_icon_name (tray), 10000, FALSE, XFPM_NOTIFY_CRITICAL, @@ -141,7 +142,7 @@ xfpm_notify_show_notification (tray->priv->notify, _("Xfce power manager"), error->message, - xfpm_tray_icon_get_icon_name (tray), + xfpm_tray_icon_get_notify_icon_name (tray), 10000, FALSE, XFPM_NOTIFY_CRITICAL, @@ -431,6 +432,7 @@ tray->priv->info_menu = TRUE; tray->priv->icon_quark = 0; + tray->priv->notify_icon_quark = 0; g_signal_connect (tray->priv->icon, "size-changed", G_CALLBACK (xfpm_tray_icon_size_changed_cb), tray); @@ -505,6 +507,13 @@ icon); } +void xfpm_tray_icon_set_notify_icon (XfpmTrayIcon *icon, const gchar *icon_name) +{ + g_return_if_fail(XFPM_IS_TRAY_ICON(icon)); + + icon->priv->notify_icon_quark = g_quark_from_string(icon_name); +} + void xfpm_tray_icon_set_tooltip (XfpmTrayIcon *icon, const gchar *tooltip) { g_return_if_fail (XFPM_IS_TRAY_ICON (icon)); @@ -549,3 +558,12 @@ return g_quark_to_string (icon->priv->icon_quark); } + +const gchar *xfpm_tray_icon_get_notify_icon_name (XfpmTrayIcon *icon) +{ + g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL); + + if ( icon->priv->notify_icon_quark == 0 ) return NULL; + + return g_quark_to_string (icon->priv->notify_icon_quark); +} === modified file 'src/xfpm-tray-icon.h' --- src/xfpm-tray-icon.h 2009-09-24 09:10:34 +0000 +++ src/xfpm-tray-icon.h 2009-09-26 20:50:38 +0000 @@ -55,6 +55,9 @@ void xfpm_tray_icon_set_icon (XfpmTrayIcon *icon, const gchar *icon_name); + +void xfpm_tray_icon_set_notify_icon (XfpmTrayIcon *icon, + const gchar *icon_name); void xfpm_tray_icon_set_tooltip (XfpmTrayIcon *icon, const gchar *tooltip); @@ -68,6 +71,8 @@ const gchar *xfpm_tray_icon_get_icon_name (XfpmTrayIcon *icon) G_GNUC_PURE; +const gchar *xfpm_tray_icon_get_notify_icon_name (XfpmTrayIcon *icon) G_GNUC_PURE; + G_END_DECLS #endif /* __XFPM_TRAY_ICON_H */