aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2013-10-29 09:25:02 -0700
committerTed Gould <ted@gould.cx>2013-10-29 09:25:02 -0700
commitfb134415e1e0042a00db4008e91adccd7d8eeff2 (patch)
tree7167a1e3e4fe537daf4f0062a25875806237189e /src
parent812ac9a18c469c7a4ad60cd7bb1921eb622d7df9 (diff)
parent1a9e81a4071d1bd137ca8135a993ad65a91e8ee9 (diff)
downloadayatana-indicator-power-fb134415e1e0042a00db4008e91adccd7d8eeff2.tar.gz
ayatana-indicator-power-fb134415e1e0042a00db4008e91adccd7d8eeff2.tar.bz2
ayatana-indicator-power-fb134415e1e0042a00db4008e91adccd7d8eeff2.zip
Updating to trunk
Diffstat (limited to 'src')
-rw-r--r--src/device-provider-upower.c18
-rw-r--r--src/device.c9
-rw-r--r--src/ib-brightness-control.c3
-rw-r--r--src/service.c32
4 files changed, 39 insertions, 23 deletions
diff --git a/src/device-provider-upower.c b/src/device-provider-upower.c
index 05faeab..1b1b7bd 100644
--- a/src/device-provider-upower.c
+++ b/src/device-provider-upower.c
@@ -249,6 +249,22 @@ on_upower_device_removed (DbusUPower * unused G_GNUC_UNUSED,
}
static void
+on_upower_resuming (DbusUPower * unused G_GNUC_UNUSED,
+ gpointer gself)
+{
+ IndicatorPowerDeviceProviderUPower * self;
+ GHashTableIter iter;
+ gpointer object_path;
+
+ self = INDICATOR_POWER_DEVICE_PROVIDER_UPOWER (gself);
+
+ g_debug ("Resumed from hibernate/sleep; queueing all devices for a refresh");
+ g_hash_table_iter_init (&iter, self->priv->devices);
+ while (g_hash_table_iter_next (&iter, &object_path, NULL))
+ refresh_device_soon (self, object_path);
+}
+
+static void
on_upower_proxy_ready (GObject * source G_GNUC_UNUSED,
GAsyncResult * res,
gpointer gself)
@@ -272,6 +288,8 @@ on_upower_proxy_ready (GObject * source G_GNUC_UNUSED,
p = self->priv;
p->upower_proxy = proxy;
+ g_signal_connect (proxy, "resuming",
+ G_CALLBACK (on_upower_resuming), self);
g_signal_connect (proxy, "device-changed",
G_CALLBACK (on_upower_device_changed), self);
g_signal_connect (proxy, "device-added",
diff --git a/src/device.c b/src/device.c
index 9dc4647..508a734 100644
--- a/src/device.c
+++ b/src/device.c
@@ -328,10 +328,7 @@ device_kind_to_string (UpDeviceKind kind)
This function's logic differs from GSD's power plugin in some ways:
- 1. All charging batteries use the same icon regardless of progress.
- <https://bugs.launchpad.net/indicator-power/+bug/824629/comments/7>
-
- 2. For discharging batteries, we decide whether or not to use the 'caution'
+ 1. For discharging batteries, we decide whether or not to use the 'caution'
icon based on whether or not we have <= 30 minutes remaining, rather than
looking at the battery's percentage left.
<https://bugs.launchpad.net/indicator-power/+bug/743823>
@@ -389,10 +386,6 @@ indicator_power_device_get_icon_names (const IndicatorPowerDevice * device)
case UP_DEVICE_STATE_CHARGING:
case UP_DEVICE_STATE_PENDING_CHARGE:
- /* When charging, always use the same icon regardless of percentage.
- <http://bugs.launchpad.net/indicator-power/+bug/824629> */
- percentage = 0;
-
suffix_str = get_device_icon_suffix (percentage);
index_str = get_device_icon_index (percentage);
g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging-symbolic", kind_str, suffix_str));
diff --git a/src/ib-brightness-control.c b/src/ib-brightness-control.c
index 2b9b79d..4fb6bc5 100644
--- a/src/ib-brightness-control.c
+++ b/src/ib-brightness-control.c
@@ -52,7 +52,7 @@ ib_brightness_control_new (void)
(g_strcmp0 (device_type, "platform") == 0) ||
(g_strcmp0 (device_type, "raw") == 0)) {
path = g_strdup (g_udev_device_get_sysfs_path (device->data));
- g_print ("found: %s\n", path);
+ g_debug ("found: %s", path);
break;
}
}
@@ -126,6 +126,7 @@ ib_brightness_control_get_value_from_file (IbBrightnessControl *self, const gcha
g_error_free (error);
} else {
value = atoi (svalue);
+ g_free (svalue);
}
g_free (filename);
diff --git a/src/service.c b/src/service.c
index 1976332..c70723a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <url-dispatcher.h>
#include "device.h"
#include "device-provider.h"
@@ -331,15 +332,13 @@ create_header_state (IndicatorPowerService * self)
g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add (&b, "{sv}", "title", g_variant_new_string (_("Battery")));
+
g_variant_builder_add (&b, "{sv}", "visible",
g_variant_new_boolean (should_be_visible (self)));
if (label != NULL)
- {
- g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label));
-
- g_free (label);
- }
+ g_variant_builder_add (&b, "{sv}", "label", g_variant_new_take_string (label));
if (icon != NULL)
{
@@ -349,12 +348,7 @@ create_header_state (IndicatorPowerService * self)
}
if (a11y != NULL)
- {
- g_variant_builder_add (&b, "{sv}", "accessible-desc",
- g_variant_new_string (a11y));
-
- g_free (a11y);
- }
+ g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_take_string (a11y));
return g_variant_builder_end (&b);
}
@@ -469,6 +463,9 @@ create_brightness_menuitem (IndicatorPowerService * self)
g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.unity.slider");
g_menu_item_set_attribute (item, "min-value", "d", brightness_to_percentage (self, lo));
g_menu_item_set_attribute (item, "max-value", "d", brightness_to_percentage (self, hi));
+ g_menu_item_set_attribute (item, "min-icon", "s", "torch-off" );
+ g_menu_item_set_attribute (item, "max-icon", "s", "torch-on" );
+
return item;
}
@@ -532,7 +529,7 @@ create_phone_settings_section (IndicatorPowerService * self G_GNUC_UNUSED)
update_brightness_action_state (self);
g_object_unref (item);
- g_menu_append (section, _("Battery settingsā€¦"), "indicator.activate-settings");
+ g_menu_append (section, _("Battery settingsā€¦"), "indicator.activate-phone-settings");
return G_MENU_MODEL (section);
}
@@ -685,8 +682,6 @@ on_settings_activated (GSimpleAction * a G_GNUC_UNUSED,
GVariant * param G_GNUC_UNUSED,
gpointer gself G_GNUC_UNUSED)
{
- /* FIXME: unity8 settings */
-
execute_command ("gnome-control-center power");
}
@@ -698,6 +693,14 @@ on_statistics_activated (GSimpleAction * a G_GNUC_UNUSED,
execute_command ("gnome-power-statistics");
}
+static void
+on_phone_settings_activated (GSimpleAction * a G_GNUC_UNUSED,
+ GVariant * param G_GNUC_UNUSED,
+ gpointer gself G_GNUC_UNUSED)
+{
+ url_dispatch_send("settings:///system/battery", NULL, NULL);
+}
+
/***
****
***/
@@ -739,6 +742,7 @@ init_gactions (IndicatorPowerService * self)
GActionEntry entries[] = {
{ "activate-settings", on_settings_activated },
+ { "activate-phone-settings", on_phone_settings_activated },
{ "activate-statistics", on_statistics_activated }
};