aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2023-04-05 10:20:47 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-05-05 23:37:05 +0200
commiteeea7eab9aa5877f8e00cf3993ed088abd498427 (patch)
tree89a059d05401d613f611973f19f67f833c475c15
parent490ec9d3410c535b6f1e915ae52d983730bcb93e (diff)
downloadayatana-indicator-power-eeea7eab9aa5877f8e00cf3993ed088abd498427.tar.gz
ayatana-indicator-power-eeea7eab9aa5877f8e00cf3993ed088abd498427.tar.bz2
ayatana-indicator-power-eeea7eab9aa5877f8e00cf3993ed088abd498427.zip
src/service.c: Use level or progress IDO as needed
-rw-r--r--src/service.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/service.c b/src/service.c
index 3914e3f..32f8788 100644
--- a/src/service.c
+++ b/src/service.c
@@ -504,17 +504,6 @@ static GMenuModel *
create_devices_section (IndicatorPowerService * self, int profile)
{
GMenu * menu = g_menu_new ();
-
- if (self->priv->primary_device != NULL)
- {
- GMenuItem * item = g_menu_item_new (_("Charge level"), NULL);
- g_menu_item_set_attribute (item, "x-ayatana-type", "s", "org.ayatana.indicator.progress");
- guint16 battery_level = (guint16)(indicator_power_device_get_percentage (self->priv->primary_device) + 0.5);
- g_menu_item_set_attribute (item, "x-ayatana-progress", "q", battery_level);
- g_menu_append_item (menu, item);
- g_object_unref (item);
- }
-
GList * l;
for (l=self->priv->devices; l!=NULL; l=l->next)
@@ -524,19 +513,38 @@ create_devices_section (IndicatorPowerService * self, int profile)
if (kind != UP_DEVICE_KIND_LINE_POWER)
{
- if (device == self->priv->primary_device)
+ gchar *sLabel = NULL;
+
+ if (kind == UP_DEVICE_KIND_BATTERY)
+ {
+ sLabel = g_strdup (_("Charge level"));
+ }
+ else
{
- continue;
+ sLabel = indicator_power_device_get_readable_text (device);
}
- char * label = indicator_power_device_get_readable_text (device);
- GMenuItem * item = g_menu_item_new (label, NULL);
- g_free (label);
- g_menu_item_set_attribute (item, "x-ayatana-type", "s", "org.ayatana.indicator.progress");
+ gchar *sIndicator = NULL;
+ gchar *sProperty = NULL;
+
+ if (!ayatana_common_utils_is_lomiri())
+ {
+ sIndicator = "org.ayatana.indicator.level";
+ sProperty = "x-ayatana-level";
+ }
+ else
+ {
+ sIndicator = "org.ayatana.indicator.progress";
+ sProperty = "x-ayatana-progress";
+ }
+
+ GMenuItem * item = g_menu_item_new (sLabel, NULL);
+ g_free (sLabel);
+ g_menu_item_set_attribute (item, "x-ayatana-type", "s", sIndicator);
guint16 battery_level = (guint16)(indicator_power_device_get_percentage (device) + 0.5);
- g_menu_item_set_attribute (item, "x-ayatana-progress", "q", battery_level);
+ g_menu_item_set_attribute (item, sProperty, "q", battery_level);
- if (profile != PROFILE_PHONE)
+ if (!ayatana_common_utils_is_lomiri())
{
GIcon * icon = indicator_power_device_get_gicon (device, FALSE);
@@ -553,10 +561,7 @@ create_devices_section (IndicatorPowerService * self, int profile)
g_object_unref (icon);
}
- if (profile == PROFILE_DESKTOP)
- {
- g_menu_item_set_action_and_target(item, "indicator.activate-statistics", "s", indicator_power_device_get_object_path (device));
- }
+ g_menu_item_set_action_and_target(item, "indicator.activate-statistics", "s", indicator_power_device_get_object_path (device));
}
g_menu_append_item (menu, item);