From 6ea2db56307d04ac8dba4bcf929cd716f4840359 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 16 Jul 2014 01:08:54 -0500 Subject: add first draft of low battery notifications --- src/notifier.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/notifier.h (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h new file mode 100644 index 0000000..e8dfaab --- /dev/null +++ b/src/notifier.h @@ -0,0 +1,68 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +#ifndef __INDICATOR_POWER_NOTIFIER_H__ +#define __INDICATOR_POWER_NOTIFIER_H__ + +#include +#include + +#include "device-provider.h" + +G_BEGIN_DECLS + +/* standard GObject macros */ +#define INDICATOR_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_POWER_NOTIFIER, IndicatorPowerNotifier)) +#define INDICATOR_TYPE_POWER_NOTIFIER (indicator_power_notifier_get_type()) +#define INDICATOR_IS_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_POWER_NOTIFIER)) + +typedef struct _IndicatorPowerNotifier IndicatorPowerNotifier; +typedef struct _IndicatorPowerNotifierClass IndicatorPowerNotifierClass; +typedef struct _IndicatorPowerNotifierPrivate IndicatorPowerNotifierPrivate; + +/** + * The Indicator Power Notifier. + */ +struct _IndicatorPowerNotifier +{ + /*< private >*/ + GObject parent; + IndicatorPowerNotifierPrivate * priv; +}; + +struct _IndicatorPowerNotifierClass +{ + GObjectClass parent_class; +}; + +/*** +**** +***/ + +GType indicator_power_notifier_get_type (void); + +IndicatorPowerNotifier * indicator_power_notifier_new (IndicatorPowerDeviceProvider * provider); + +void indicator_power_notifier_set_device_provider (IndicatorPowerNotifier * self, + IndicatorPowerDeviceProvider * provider); + + +G_END_DECLS + +#endif /* __INDICATOR_POWER_NOTIFIER_H__ */ -- cgit v1.2.3 From b08f9b096f956b528ad974a30828a809b827efef Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 21 Jul 2014 00:50:24 -0500 Subject: second draft of low battery power notifications, still a work in progress --- src/notifier.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index e8dfaab..c224b29 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -22,6 +22,7 @@ #include #include +#include /* GDBusConnection */ #include "device-provider.h" @@ -59,6 +60,9 @@ GType indicator_power_notifier_get_type (void); IndicatorPowerNotifier * indicator_power_notifier_new (IndicatorPowerDeviceProvider * provider); +void indicator_power_notifier_set_bus (IndicatorPowerNotifier * self, + GDBusConnection * connection); + void indicator_power_notifier_set_device_provider (IndicatorPowerNotifier * self, IndicatorPowerDeviceProvider * provider); -- cgit v1.2.3 From 1902911c18a863ca285c53ae323e233119cf0d86 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 21 Jul 2014 11:25:16 -0500 Subject: remove DeviceProvider from Notifier --- src/notifier.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index c224b29..2602171 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -24,7 +24,7 @@ #include #include /* GDBusConnection */ -#include "device-provider.h" +#include "device.h" G_BEGIN_DECLS @@ -37,6 +37,15 @@ typedef struct _IndicatorPowerNotifier IndicatorPowerNotifier; typedef struct _IndicatorPowerNotifierClass IndicatorPowerNotifierClass; typedef struct _IndicatorPowerNotifierPrivate IndicatorPowerNotifierPrivate; +typedef enum +{ + POWER_LEVEL_OK, + POWER_LEVEL_LOW, + POWER_LEVEL_VERY_LOW, + POWER_LEVEL_CRITICAL +} +PowerLevel; + /** * The Indicator Power Notifier. */ @@ -58,13 +67,13 @@ struct _IndicatorPowerNotifierClass GType indicator_power_notifier_get_type (void); -IndicatorPowerNotifier * indicator_power_notifier_new (IndicatorPowerDeviceProvider * provider); +IndicatorPowerNotifier * indicator_power_notifier_new (void); void indicator_power_notifier_set_bus (IndicatorPowerNotifier * self, GDBusConnection * connection); -void indicator_power_notifier_set_device_provider (IndicatorPowerNotifier * self, - IndicatorPowerDeviceProvider * provider); +void indicator_power_notifier_set_device (IndicatorPowerNotifier * self, + IndicatorPowerDevice * provider); G_END_DECLS -- cgit v1.2.3 From 7b3b8a27aa6e0a9a10f6faec1cd13b10f5b2492a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 21 Jul 2014 12:10:41 -0500 Subject: fix build issues --- src/notifier.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index 2602171..c1c5a1b 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -72,8 +72,8 @@ IndicatorPowerNotifier * indicator_power_notifier_new (void); void indicator_power_notifier_set_bus (IndicatorPowerNotifier * self, GDBusConnection * connection); -void indicator_power_notifier_set_device (IndicatorPowerNotifier * self, - IndicatorPowerDevice * provider); +void indicator_power_notifier_set_battery (IndicatorPowerNotifier * self, + IndicatorPowerDevice * battery); G_END_DECLS -- cgit v1.2.3 From f5bf7f99724796a21dc05676d613ed47c624bfd1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 21 Jul 2014 13:48:18 -0500 Subject: don't show clickable actions if the Notify server doesn't support them. --- src/notifier.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index c1c5a1b..cab053f 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -29,9 +29,10 @@ G_BEGIN_DECLS /* standard GObject macros */ -#define INDICATOR_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_POWER_NOTIFIER, IndicatorPowerNotifier)) -#define INDICATOR_TYPE_POWER_NOTIFIER (indicator_power_notifier_get_type()) -#define INDICATOR_IS_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_POWER_NOTIFIER)) +#define INDICATOR_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_POWER_NOTIFIER, IndicatorPowerNotifier)) +#define INDICATOR_TYPE_POWER_NOTIFIER (indicator_power_notifier_get_type()) +#define INDICATOR_IS_POWER_NOTIFIER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_POWER_NOTIFIER)) +#define INDICATOR_POWER_NOTIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_POWER_NOTIFIER, IndicatorPowerNotifierClass)) typedef struct _IndicatorPowerNotifier IndicatorPowerNotifier; typedef struct _IndicatorPowerNotifierClass IndicatorPowerNotifierClass; @@ -59,6 +60,10 @@ struct _IndicatorPowerNotifier struct _IndicatorPowerNotifierClass { GObjectClass parent_class; + + /*< private >*/ + gint instance_count; + gboolean interactive; }; /*** -- cgit v1.2.3 From 2cb851b018c5e7a0278dab75f73bb031c7c42422 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 21 Jul 2014 16:08:29 -0500 Subject: add tests to confirm that the DBus object's PowerLevel property changes at the right times (and only at the right times) when the battery is draining --- src/notifier.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index cab053f..0e3ad99 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -80,6 +80,7 @@ void indicator_power_notifier_set_bus (IndicatorPowerNotifier * self, void indicator_power_notifier_set_battery (IndicatorPowerNotifier * self, IndicatorPowerDevice * battery); +PowerLevel indicator_power_notifier_get_power_level (IndicatorPowerDevice * battery); G_END_DECLS -- cgit v1.2.3 From a8ea5a0304e5ee14ee93532f0bc960c99039356a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 23 Jul 2014 16:04:02 -0500 Subject: remove now-unused code that tests whether the Notify server supports actions --- src/notifier.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index 0e3ad99..dddb6e9 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -63,7 +63,6 @@ struct _IndicatorPowerNotifierClass /*< private >*/ gint instance_count; - gboolean interactive; }; /*** -- cgit v1.2.3 From d185409f22c859e3c29bf387955d195a5cd884c3 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 23 Jul 2014 16:22:27 -0500 Subject: remove instance_count from IndicatorPowerNotifierClass --- src/notifier.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index dddb6e9..8763ad6 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -60,9 +60,6 @@ struct _IndicatorPowerNotifier struct _IndicatorPowerNotifierClass { GObjectClass parent_class; - - /*< private >*/ - gint instance_count; }; /*** -- cgit v1.2.3 From 34cf2baf977650c60b53bf5a1e90bfec8b642ec9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 24 Jul 2014 15:20:16 -0500 Subject: remove redundant '#include glib', '#include gobject' calls --- src/notifier.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index 8763ad6..f473ee7 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -20,9 +20,7 @@ #ifndef __INDICATOR_POWER_NOTIFIER_H__ #define __INDICATOR_POWER_NOTIFIER_H__ -#include -#include -#include /* GDBusConnection */ +#include #include "device.h" -- cgit v1.2.3 From b715352603062a4a4dbb5bc69388b1db632c34ae Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 24 Jul 2014 21:25:22 -0500 Subject: in notifier, use G_DEFINE_TYPE_WITH_PRIVATE --- src/notifier.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index f473ee7..c23c585 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -34,7 +34,6 @@ G_BEGIN_DECLS typedef struct _IndicatorPowerNotifier IndicatorPowerNotifier; typedef struct _IndicatorPowerNotifierClass IndicatorPowerNotifierClass; -typedef struct _IndicatorPowerNotifierPrivate IndicatorPowerNotifierPrivate; typedef enum { @@ -52,7 +51,6 @@ struct _IndicatorPowerNotifier { /*< private >*/ GObject parent; - IndicatorPowerNotifierPrivate * priv; }; struct _IndicatorPowerNotifierClass -- cgit v1.2.3 From f15482d3f189c378d4e4cf2dfc69eefa522b30aa Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 24 Jul 2014 23:31:11 -0500 Subject: on the bus, publish the battery's power_level as strings rather than ints --- src/notifier.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index c23c585..18e25d7 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -35,15 +35,6 @@ G_BEGIN_DECLS typedef struct _IndicatorPowerNotifier IndicatorPowerNotifier; typedef struct _IndicatorPowerNotifierClass IndicatorPowerNotifierClass; -typedef enum -{ - POWER_LEVEL_OK, - POWER_LEVEL_LOW, - POWER_LEVEL_VERY_LOW, - POWER_LEVEL_CRITICAL -} -PowerLevel; - /** * The Indicator Power Notifier. */ @@ -72,7 +63,11 @@ void indicator_power_notifier_set_bus (IndicatorPowerNotifier * self, void indicator_power_notifier_set_battery (IndicatorPowerNotifier * self, IndicatorPowerDevice * battery); -PowerLevel indicator_power_notifier_get_power_level (IndicatorPowerDevice * battery); +#define POWER_LEVEL_STR_OK "ok" +#define POWER_LEVEL_STR_LOW "low" +#define POWER_LEVEL_STR_VERY_LOW "very_low" +#define POWER_LEVEL_STR_CRITICAL "critical" +const char * indicator_power_notifier_get_power_level (IndicatorPowerDevice * battery); G_END_DECLS -- cgit v1.2.3