[gnome-settings-daemon] power: Clear any low power or discharging notifications when the batteries are fully charged
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Clear any low power or discharging notifications when the batteries are fully charged
- Date: Mon, 4 Jul 2011 16:55:42 +0000 (UTC)
commit fbe9a60b3f0cda661e616bf8b8df06617bbacce2
Author: Richard Hughes <richard hughsie com>
Date: Fri Jul 1 13:54:58 2011 +0100
power: Clear any low power or discharging notifications when the batteries are fully charged
plugins/power/gsd-power-manager.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 4cd5adc..35a64b1 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -28,6 +28,7 @@
#include <gtk/gtk.h>
#include <canberra-gtk.h>
#include <libupower-glib/upower.h>
+#include <libnotify/notify.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-rr.h>
@@ -136,6 +137,8 @@ struct GsdPowerManagerPrivate
guint low_percentage;
guint low_time;
UpDevice *device_composite;
+ NotifyNotification *notification_discharging;
+ NotifyNotification *notification_warning_low;
};
enum {
@@ -162,6 +165,22 @@ gsd_power_manager_error_quark (void)
return quark;
}
+static void
+notify_close_if_showing (NotifyNotification *notification)
+{
+ gboolean ret;
+ GError *error = NULL;
+
+ if (notification == NULL)
+ return;
+ ret = notify_notification_close (notification, &error);
+ if (!ret) {
+ g_warning ("failed to close notification: %s",
+ error->message);
+ g_error_free (error);
+ }
+}
+
typedef enum {
WARNING_NONE = 0,
WARNING_DISCHARGING = 1,
@@ -856,7 +875,9 @@ engine_device_changed_cb (UpClient *client, UpDevice *device, GsdPowerManager *m
if (state == UP_DEVICE_STATE_DISCHARGING) {
g_debug ("** EMIT: discharging");
} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
- g_debug ("** EMIT: fully charged");
+ g_debug ("fully charged, hiding notifications if any");
+ notify_close_if_showing (manager->priv->notification_warning_low);
+ notify_close_if_showing (manager->priv->notification_discharging);
}
/* save new state */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]