aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device.c126
-rw-r--r--src/device.h3
-rw-r--r--tests/test-device.cc12
-rw-r--r--tests/test-indicator.cc23
4 files changed, 10 insertions, 154 deletions
diff --git a/src/device.c b/src/device.c
index 3dbfd4e..cd35c9b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -28,7 +28,6 @@ struct _IndicatorPowerDevicePrivate
UpDeviceKind kind;
UpDeviceState state;
gchar * object_path;
- gchar * icon;
gdouble percentage;
time_t time;
};
@@ -86,10 +85,6 @@ indicator_power_device_class_init (IndicatorPowerDeviceClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_OBJECT_PATH, pspec);
- pspec = g_param_spec_string (INDICATOR_POWER_DEVICE_ICON, "icon", "The device's icon", NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_ICON, pspec);
-
pspec = g_param_spec_double (INDICATOR_POWER_DEVICE_PERCENTAGE, "percentage", "percent charged",
0.0, 100.0, 0.0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
@@ -113,7 +108,6 @@ indicator_power_device_init (IndicatorPowerDevice *self)
priv->kind = UP_DEVICE_KIND_UNKNOWN;
priv->state = UP_DEVICE_STATE_UNKNOWN;
priv->object_path = NULL;
- priv->icon = NULL;
priv->percentage = 0.0;
priv->time = 0;
@@ -133,7 +127,6 @@ indicator_power_device_finalize (GObject *object)
IndicatorPowerDevicePrivate * priv = self->priv;
g_clear_pointer (&priv->object_path, g_free);
- g_clear_pointer (&priv->icon, g_free);
}
/***
@@ -160,10 +153,6 @@ get_property (GObject * o, guint prop_id, GValue * value, GParamSpec * pspec)
g_value_set_string (value, priv->object_path);
break;
- case PROP_ICON:
- g_value_set_string (value, priv->icon);
- break;
-
case PROP_PERCENTAGE:
g_value_set_double (value, priv->percentage);
break;
@@ -195,11 +184,6 @@ set_property (GObject * o, guint prop_id, const GValue * value, GParamSpec * psp
priv->object_path = g_value_dup_string (value);
break;
- case PROP_ICON:
- g_free (priv->icon);
- priv->icon = g_value_dup_string (value);
- break;
-
case PROP_PERCENTAGE:
priv->percentage = g_value_get_double (value);
break;
@@ -244,16 +228,6 @@ indicator_power_device_get_object_path (const IndicatorPowerDevice * device)
return device->priv->object_path;
}
-const gchar *
-indicator_power_device_get_icon (const IndicatorPowerDevice * device)
-{
- /* LCOV_EXCL_START */
- g_return_val_if_fail (INDICATOR_IS_POWER_DEVICE(device), UP_DEVICE_KIND_UNKNOWN);
- /* LCOV_EXCL_STOP */
-
- return device->priv->icon;
-}
-
gdouble
indicator_power_device_get_percentage (const IndicatorPowerDevice * device)
{
@@ -418,103 +392,6 @@ indicator_power_device_get_gicon (const IndicatorPowerDevice * device)
}
-
-#if 0
-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)
-{
- GIcon *gicon;
-
- GString *filename;
- gchar **iconnames;
-
- filename = g_string_new (NULL);
-
- if (state == UP_DEVICE_STATE_FULLY_CHARGED)
- {
- g_string_append (filename, "battery-charged;");
- g_string_append (filename, "battery-full-charged-symbolic;");
- g_string_append (filename, "battery-full-charged;");
- g_string_append (filename, "gpm-battery-charged;");
- g_string_append (filename, "gpm-battery-100-charging;");
- }
- else if (state == UP_DEVICE_STATE_CHARGING)
- {
- g_string_append (filename, "battery-000-charging;");
- g_string_append (filename, "battery-caution-charging-symbolic;");
- g_string_append (filename, "battery-caution-charging;");
- g_string_append (filename, "gpm-battery-000-charging;");
- }
- 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_printf (filename, "battery-%s;", percentage);
- g_string_append_printf (filename, "gpm-battery-%s;", percentage);
- }
-
- iconnames = g_strsplit (filename->str, ";", -1);
- gicon = g_themed_icon_new_from_names (iconnames, -1);
-
- g_strfreev (iconnames);
- g_string_free (filename, TRUE);
-
- return gicon;
-}
-
-static GIcon*
-get_device_icon (UpDeviceKind kind,
- UpDeviceState state,
- guint64 time_sec,
- const gchar *device_icon)
-{
- GIcon *gicon = NULL;
-
- if (kind == UP_DEVICE_KIND_BATTERY &&
- (state == UP_DEVICE_STATE_FULLY_CHARGED ||
- state == UP_DEVICE_STATE_CHARGING ||
- state == UP_DEVICE_STATE_DISCHARGING))
- {
- if (state == UP_DEVICE_STATE_FULLY_CHARGED ||
- state == UP_DEVICE_STATE_CHARGING)
- {
- gicon = build_battery_icon (state, NULL);
- }
- else if (state == UP_DEVICE_STATE_DISCHARGING)
- {
- if ((time_sec > 60 * 30) && /* more than 30 minutes left */
- (g_strrstr (device_icon, "000") ||
- g_strrstr (device_icon, "020") ||
- g_strrstr (device_icon, "caution"))) /* the icon is red */
- {
- gicon = build_battery_icon (state, "low");
- }
- }
- }
-
- if (gicon == NULL)
- gicon = g_icon_new_for_string (device_icon, NULL);
-
- return gicon;
-}
-#endif
-
/***
**** Instantiation
***/
@@ -522,7 +399,6 @@ get_device_icon (UpDeviceKind kind,
IndicatorPowerDevice *
indicator_power_device_new (const gchar * object_path,
UpDeviceKind kind,
- const gchar * icon_path,
gdouble percentage,
UpDeviceState state,
time_t timestamp)
@@ -531,7 +407,6 @@ indicator_power_device_new (const gchar * object_path,
INDICATOR_POWER_DEVICE_KIND, kind,
INDICATOR_POWER_DEVICE_STATE, state,
INDICATOR_POWER_DEVICE_OBJECT_PATH, object_path,
- INDICATOR_POWER_DEVICE_ICON, icon_path,
INDICATOR_POWER_DEVICE_PERCENTAGE, percentage,
INDICATOR_POWER_DEVICE_TIME, (guint64)timestamp,
NULL);
@@ -558,7 +433,6 @@ indicator_power_device_new_from_variant (GVariant * v)
return indicator_power_device_new (object_path,
kind,
- icon,
percentage,
state,
time);
diff --git a/src/device.h b/src/device.h
index 9b82830..11cd83b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -43,7 +43,6 @@ typedef struct _IndicatorPowerDevicePrivate IndicatorPowerDevicePrivate;
#define INDICATOR_POWER_DEVICE_KIND "indicator-power-device-kind"
#define INDICATOR_POWER_DEVICE_STATE "indicator-power-device-state"
#define INDICATOR_POWER_DEVICE_OBJECT_PATH "indicator-power-device-object-path"
-#define INDICATOR_POWER_DEVICE_ICON "indicator-power-device-icon"
#define INDICATOR_POWER_DEVICE_PERCENTAGE "indicator-power-device-percentage"
#define INDICATOR_POWER_DEVICE_TIME "indicator-power-device-time"
@@ -75,7 +74,6 @@ GType indicator_power_device_get_type (void);
IndicatorPowerDevice* indicator_power_device_new (const gchar * object_path,
UpDeviceKind kind,
- const gchar * icon,
gdouble percentage,
UpDeviceState state,
time_t time);
@@ -90,7 +88,6 @@ IndicatorPowerDevice* indicator_power_device_new_from_variant (GVariant * varian
UpDeviceKind indicator_power_device_get_kind (const IndicatorPowerDevice * device);
UpDeviceState indicator_power_device_get_state (const IndicatorPowerDevice * device);
const gchar * indicator_power_device_get_object_path (const IndicatorPowerDevice * device);
-const gchar * indicator_power_device_get_icon (const IndicatorPowerDevice * device);
gdouble indicator_power_device_get_percentage (const IndicatorPowerDevice * device);
time_t indicator_power_device_get_time (const IndicatorPowerDevice * device);
diff --git a/tests/test-device.cc b/tests/test-device.cc
index b11188c..0ea7177 100644
--- a/tests/test-device.cc
+++ b/tests/test-device.cc
@@ -111,13 +111,6 @@ TEST_F(DeviceTest, Properties)
ASSERT_STREQ (str, "/object/path");
g_free (str);
- // ICON
- key = INDICATOR_POWER_DEVICE_ICON;
- g_object_set (o, key, "something", NULL);
- g_object_get (o, key, &str, NULL);
- ASSERT_STREQ (str, "something");
- g_free (str);
-
// PERCENTAGE
key = INDICATOR_POWER_DEVICE_PERCENTAGE;
g_object_set (o, key, 50.0, NULL);
@@ -140,7 +133,6 @@ TEST_F(DeviceTest, New)
IndicatorPowerDevice * device = indicator_power_device_new ("/object/path",
UP_DEVICE_KIND_BATTERY,
- "icon",
50.0,
UP_DEVICE_STATE_CHARGING,
30);
@@ -149,7 +141,6 @@ TEST_F(DeviceTest, New)
ASSERT_EQ (indicator_power_device_get_kind(device), UP_DEVICE_KIND_BATTERY);
ASSERT_EQ (indicator_power_device_get_state(device), UP_DEVICE_STATE_CHARGING);
ASSERT_STREQ (indicator_power_device_get_object_path(device), "/object/path");
- ASSERT_STREQ (indicator_power_device_get_icon(device), "icon");
ASSERT_EQ ((int)indicator_power_device_get_percentage(device), 50);
ASSERT_EQ (indicator_power_device_get_time(device), 30);
@@ -175,7 +166,6 @@ TEST_F(DeviceTest, NewFromVariant)
ASSERT_EQ (indicator_power_device_get_kind(device), UP_DEVICE_KIND_BATTERY);
ASSERT_EQ (indicator_power_device_get_state(device), UP_DEVICE_STATE_CHARGING);
ASSERT_STREQ (indicator_power_device_get_object_path(device), "/object/path");
- ASSERT_STREQ (indicator_power_device_get_icon(device), "icon");
ASSERT_EQ ((int)indicator_power_device_get_percentage(device), 50);
ASSERT_EQ (indicator_power_device_get_time(device), 30);
@@ -192,7 +182,6 @@ TEST_F(DeviceTest, BadAccessors)
IndicatorPowerDevice * device = NULL;
indicator_power_device_get_kind (device);
indicator_power_device_get_time (device);
- indicator_power_device_get_icon (device);
indicator_power_device_get_state (device);
indicator_power_device_get_percentage (device);
indicator_power_device_get_object_path (device);
@@ -201,7 +190,6 @@ TEST_F(DeviceTest, BadAccessors)
device = reinterpret_cast<IndicatorPowerDevice*>(g_cancellable_new ());
indicator_power_device_get_kind (device);
indicator_power_device_get_time (device);
- indicator_power_device_get_icon (device);
indicator_power_device_get_state (device);
indicator_power_device_get_percentage (device);
indicator_power_device_get_object_path (device);
diff --git a/tests/test-indicator.cc b/tests/test-indicator.cc
index 32d6f4f..b9f7321 100644
--- a/tests/test-indicator.cc
+++ b/tests/test-indicator.cc
@@ -61,13 +61,11 @@ class IndicatorTest : public ::testing::Test
ac_device = indicator_power_device_new (
"/org/freedesktop/UPower/devices/line_power_AC",
UP_DEVICE_KIND_LINE_POWER,
- ". GThemedIcon ac-adapter-symbolic ac-adapter ",
0.0, UP_DEVICE_STATE_UNKNOWN, 0);
battery_device = indicator_power_device_new (
"/org/freedesktop/UPower/devices/battery_BAT0",
UP_DEVICE_KIND_BATTERY,
- ". GThemedIcon battery-good-symbolic gpm-battery-060 battery-good ",
52.871712, UP_DEVICE_STATE_DISCHARGING, 8834);
}
@@ -238,7 +236,6 @@ TEST_F(IndicatorTest, AvoidChargingBatteriesWithZeroSecondsLeft)
IndicatorPowerDevice * bad_battery_device = indicator_power_device_new (
"/org/freedesktop/UPower/devices/battery_BAT0",
UP_DEVICE_KIND_BATTERY,
- ". GThemedIcon battery-good-symbolic gpm-battery-060 battery-good ",
53, UP_DEVICE_STATE_CHARGING, 0);
GSList * devices = NULL;
@@ -262,34 +259,34 @@ TEST_F(IndicatorTest, OtherDevices)
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/mouse", UP_DEVICE_KIND_MOUSE,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/ups", UP_DEVICE_KIND_UPS,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/keyboard", UP_DEVICE_KIND_KEYBOARD,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/pda", UP_DEVICE_KIND_PDA,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/phone", UP_DEVICE_KIND_PHONE,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/monitor", UP_DEVICE_KIND_MONITOR,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/media_player", UP_DEVICE_KIND_MEDIA_PLAYER,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/tablet", UP_DEVICE_KIND_TABLET,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/computer", UP_DEVICE_KIND_COMPUTER,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
devices = g_slist_append (devices, indicator_power_device_new (
"/org/freedesktop/UPower/devices/unknown", UP_DEVICE_KIND_UNKNOWN,
- "unused", 0, UP_DEVICE_STATE_UNKNOWN, 0));
+ 0, UP_DEVICE_STATE_UNKNOWN, 0));
indicator_power_set_devices (power, devices);