diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-09-08 15:35:19 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-09-08 15:35:19 -0500 |
commit | 24b9a28725106d1762fcefb0652f2cb06ad9aa4c (patch) | |
tree | 2d481e78ce95ea8827061a9193d5bb402f507934 /src | |
parent | 48b162d72dc3e470e95de8259901e9689d229668 (diff) | |
download | ayatana-indicator-power-24b9a28725106d1762fcefb0652f2cb06ad9aa4c.tar.gz ayatana-indicator-power-24b9a28725106d1762fcefb0652f2cb06ad9aa4c.tar.bz2 ayatana-indicator-power-24b9a28725106d1762fcefb0652f2cb06ad9aa4c.zip |
in notifier's snap decisions, distinguish in the title between low battery and critical battery
Diffstat (limited to 'src')
-rw-r--r-- | src/notifier.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/notifier.c b/src/notifier.c index a059447..f4c8950 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -187,15 +187,22 @@ notification_show(IndicatorPowerNotifier * self) { priv_t * const p = get_priv(self); gdouble pct; + const char * title; char * body; GStrv icon_names; const char * icon_name; NotifyNotification * nn; GError * error; + const PowerLevel power_level = get_battery_power_level(p->battery); notification_clear(self); + g_return_if_fail(power_level != POWER_LEVEL_OK); + /* create the notification */ + title = power_level == POWER_LEVEL_LOW + ? _("Battery Low") + : _("Battery Critical"); pct = indicator_power_device_get_percentage(p->battery); body = g_strdup_printf(_("%.0f%% charge remaining"), pct); icon_names = indicator_power_device_get_icon_names(p->battery); @@ -203,7 +210,10 @@ notification_show(IndicatorPowerNotifier * self) icon_name = icon_names[0]; else icon_name = NULL; - nn = notify_notification_new(_("Battery Low"), body, icon_name); + nn = notify_notification_new(title, body, icon_name); + g_strfreev (icon_names); + g_free (body); + if (actions_supported) { notify_notification_set_hint(nn, "x-canonical-snap-decisions", g_variant_new_boolean(TRUE)); @@ -213,8 +223,6 @@ notification_show(IndicatorPowerNotifier * self) notify_notification_add_action(nn, "dismiss", _("OK"), on_dismiss_clicked, NULL, NULL); notify_notification_add_action(nn, "settings", _("Battery settings"), on_battery_settings_clicked, NULL, NULL); } - g_strfreev (icon_names); - g_free (body); /* if we can show it, keep it */ error = NULL; |