diff options
author | Robert Tari <robert@tari.in> | 2023-04-05 13:51:53 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-05-05 23:37:05 +0200 |
commit | 8f7c0cdbfd3ac5166a9628f917a0184fe5a44628 (patch) | |
tree | 62152c893faf4b24a6925fdebe2a9b40f2bfe1fd /src | |
parent | 906c021e2ebd927b512c9d52c03c17e70c01f065 (diff) | |
download | ayatana-indicator-power-8f7c0cdbfd3ac5166a9628f917a0184fe5a44628.tar.gz ayatana-indicator-power-8f7c0cdbfd3ac5166a9628f917a0184fe5a44628.tar.bz2 ayatana-indicator-power-8f7c0cdbfd3ac5166a9628f917a0184fe5a44628.zip |
Do not use charge-aware icons in the menu
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 57 | ||||
-rw-r--r-- | src/device.h | 2 | ||||
-rw-r--r-- | src/service.c | 4 |
3 files changed, 56 insertions, 7 deletions
diff --git a/src/device.c b/src/device.c index a373981..6e79557 100644 --- a/src/device.c +++ b/src/device.c @@ -436,6 +436,42 @@ device_kind_to_string (UpDeviceKind kind) } } +static const char *device_kind_to_icon_name (UpDeviceKind kind) +{ + switch (kind) + { + case UP_DEVICE_KIND_LINE_POWER: return "ac-adapter"; + case UP_DEVICE_KIND_BATTERY: return "battery"; + case UP_DEVICE_KIND_UPS: return "gpm-ups-charged"; + case UP_DEVICE_KIND_MONITOR: return "display"; + case UP_DEVICE_KIND_MOUSE: return "mouse"; + case UP_DEVICE_KIND_KEYBOARD: return "keyboard"; + case UP_DEVICE_KIND_PDA: return "pda"; + case UP_DEVICE_KIND_PHONE: return "phone"; + case UP_DEVICE_KIND_MEDIA_PLAYER: return "multimedia-player"; + case UP_DEVICE_KIND_TABLET: return "tablet"; + case UP_DEVICE_KIND_COMPUTER: return "computer"; + case UP_DEVICE_KIND_GAMING_INPUT: return "input-gaming"; + case UP_DEVICE_KIND_PEN: return "input-tablet"; + case UP_DEVICE_KIND_TOUCHPAD: return "input-touchpad"; + case UP_DEVICE_KIND_MODEM: return "modem"; + case UP_DEVICE_KIND_NETWORK: return "network-wireless"; + case UP_DEVICE_KIND_HEADSET: return "audio-headset"; + case UP_DEVICE_KIND_SPEAKERS: return "audio-speakers"; + case UP_DEVICE_KIND_HEADPHONES: return "audio-headphones"; + case UP_DEVICE_KIND_VIDEO: return "camera-video"; + case UP_DEVICE_KIND_OTHER_AUDIO: return "audio-card"; + case UP_DEVICE_KIND_REMOTE_CONTROL: return "remote-control"; + case UP_DEVICE_KIND_PRINTER: return "printer"; + case UP_DEVICE_KIND_SCANNER: return "scanner"; + case UP_DEVICE_KIND_CAMERA: return "camera-photo"; + case UP_DEVICE_KIND_WEARABLE: return "wearable"; + case UP_DEVICE_KIND_TOY: return "toy"; + case UP_DEVICE_KIND_BLUETOOTH_GENERIC: return "blueman-device"; + default: return "unknown"; + } +} + /** indicator_power_device_get_icon_names: @device: #IndicatorPowerDevice from which to generate the icon names @@ -595,6 +631,7 @@ indicator_power_device_get_icon_names (const IndicatorPowerDevice * device, gboo indicator_power_device_get_gicon: @device: #IndicatorPowerDevice to generate the icon names from @panel: Whether to prefer panel icons + @bShowCharge: Whether to return a charge-aware icon A convenience function to call g_themed_icon_new_from_names() with the names returned by indicator_power_device_get_icon_names() @@ -602,11 +639,23 @@ indicator_power_device_get_icon_names (const IndicatorPowerDevice * device, gboo Return value: (transfer full): A themed GIcon */ GIcon * -indicator_power_device_get_gicon (const IndicatorPowerDevice * device, gboolean panel) +indicator_power_device_get_gicon (const IndicatorPowerDevice * device, gboolean panel, gboolean bShowCharge) { - GStrv names = indicator_power_device_get_icon_names (device, panel); - GIcon * icon = g_themed_icon_new_from_names (names, -1); - g_strfreev (names); + GIcon * icon = NULL; + + if (!bShowCharge) + { + const UpDeviceKind nKind = indicator_power_device_get_kind (device); + const gchar *sIcon = device_kind_to_icon_name (nKind); + icon = g_themed_icon_new_with_default_fallbacks (sIcon); + } + else + { + GStrv names = indicator_power_device_get_icon_names (device, panel); + icon = g_themed_icon_new_from_names (names, -1); + g_strfreev (names); + } + return icon; } diff --git a/src/device.h b/src/device.h index d9e9264..169305b 100644 --- a/src/device.h +++ b/src/device.h @@ -148,7 +148,7 @@ time_t indicator_power_device_get_time (const IndicatorPower gboolean indicator_power_device_get_power_supply (const IndicatorPowerDevice * device); GStrv indicator_power_device_get_icon_names (const IndicatorPowerDevice * device, gboolean panel); -GIcon * indicator_power_device_get_gicon (const IndicatorPowerDevice * device, gboolean panel); +GIcon * indicator_power_device_get_gicon (const IndicatorPowerDevice * device, gboolean panel, gboolean bShowCharge); char * indicator_power_device_get_readable_text (const IndicatorPowerDevice * device, gboolean bModelName); diff --git a/src/service.c b/src/service.c index bdf4caa..a7b3f10 100644 --- a/src/service.c +++ b/src/service.c @@ -466,7 +466,7 @@ create_header_state (IndicatorPowerService * self) g_free (title); } - if ((icon = indicator_power_device_get_gicon (p->primary_device, TRUE))) + if ((icon = indicator_power_device_get_gicon (p->primary_device, TRUE, TRUE))) { GVariant * serialized_icon = g_icon_serialize (icon); @@ -553,7 +553,7 @@ create_devices_section (IndicatorPowerService * self, int profile) if (!ayatana_common_utils_is_lomiri()) { - GIcon * icon = indicator_power_device_get_gicon (device, FALSE); + GIcon * icon = indicator_power_device_get_gicon (device, FALSE, FALSE); if (icon) { |