diff options
author | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-10-13 15:58:27 +0100 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-10-13 15:58:27 +0100 |
commit | 15c23becda24c70c2d859eb7ddf4f72e63d38825 (patch) | |
tree | decd45ce0b4b4c227d90f2b758a51c842fac03e7 /src/indicator-power.c | |
parent | 29f26133d5fbf3b67b9bbac487f2441cda1f3f1e (diff) | |
download | ayatana-indicator-power-15c23becda24c70c2d859eb7ddf4f72e63d38825.tar.gz ayatana-indicator-power-15c23becda24c70c2d859eb7ddf4f72e63d38825.tar.bz2 ayatana-indicator-power-15c23becda24c70c2d859eb7ddf4f72e63d38825.zip |
Do not hardcode icon percentage when discharging
Diffstat (limited to 'src/indicator-power.c')
-rw-r--r-- | src/indicator-power.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c index 1ef1b85..cb684f5 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -360,6 +360,20 @@ set_accessible_desc (IndicatorPower *self, priv->accessible_desc = g_strdup (desc); } +static const gchar * +get_icon_percentage_for_status (const gchar *status) +{ + + if (g_strcmp0 (status, "caution") == 0) + return "000"; + else if (g_strcmp0 (status, "low") == 0) + return "040"; + else if (g_strcmp0 (status, "good") == 0) + return "080"; + else + return "100"; +} + static GIcon* build_battery_icon (UpDeviceState state, gchar *suffix_str) @@ -388,10 +402,11 @@ build_battery_icon (UpDeviceState state, } else if (state == UP_DEVICE_STATE_DISCHARGING) { + const gchar *percentage = get_icon_percentage_for_status (suffix_str); g_string_append_printf (filename, "battery-%s;", suffix_str); g_string_append_printf (filename, "battery-%s-symbolic;", suffix_str); - g_string_append (filename, "battery-040;"); - g_string_append (filename, "gpm-battery-040;"); + g_string_append_printf (filename, "battery-%s;", percentage); + g_string_append_printf (filename, "gpm-battery-%s;", percentage); } iconnames = g_strsplit (filename->str, ";", -1); |