aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-09-04 21:17:12 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-09-04 21:17:12 +0200
commit527bbe441c788bae626637d7c75b0603d08eceb4 (patch)
tree3f5f484e69eb1daa45a2e1a4feba003cfbe9f0ed /src
parentca5a779dc20a5d33249a9298eb1ec834e63ecdee (diff)
parent147130a91624079dbc6237d2426f122e0f6513e6 (diff)
downloadayatana-indicator-power-527bbe441c788bae626637d7c75b0603d08eceb4.tar.gz
ayatana-indicator-power-527bbe441c788bae626637d7c75b0603d08eceb4.tar.bz2
ayatana-indicator-power-527bbe441c788bae626637d7c75b0603d08eceb4.zip
Merge branch 'tari01-pr/deprecations-warnings'
Attributes GH PR #14: https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/14
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/device.c16
-rw-r--r--src/service.c14
3 files changed, 11 insertions, 22 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 958c9f8..fb8ffef 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,9 +42,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# add warnings/coverage info on handwritten files
# but not the autogenerated ones...
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-bad-function-cast") # g_clear_object()
-set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-used-but-marked-unused") # G_ADD_PRIVATE
-set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-disabled-macro-expansion") # G_DEFINE_TYPE
-set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-assign-enum") # GParamFlags
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-switch-enum")
set_source_files_properties(${SERVICE_MANUAL_SOURCES}
PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -g -std=c99")
diff --git a/src/device.c b/src/device.c
index ef17ca6..05eb15e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -69,7 +69,7 @@ static void set_property (GObject*, guint prop_id, const GValue*, GParamSpec* );
static void get_property (GObject*, guint prop_id, GValue*, GParamSpec* );
/* LCOV_EXCL_START */
-G_DEFINE_TYPE (IndicatorPowerDevice, indicator_power_device, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE(IndicatorPowerDevice, indicator_power_device, G_TYPE_OBJECT)
/* LCOV_EXCL_STOP */
static void
@@ -77,8 +77,6 @@ indicator_power_device_class_init (IndicatorPowerDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (IndicatorPowerDevicePrivate));
-
object_class->dispose = indicator_power_device_dispose;
object_class->finalize = indicator_power_device_finalize;
object_class->set_property = set_property;
@@ -133,8 +131,7 @@ indicator_power_device_init (IndicatorPowerDevice *self)
{
IndicatorPowerDevicePrivate * priv;
- priv = G_TYPE_INSTANCE_GET_PRIVATE (self, INDICATOR_POWER_DEVICE_TYPE,
- IndicatorPowerDevicePrivate);
+ priv = indicator_power_device_get_instance_private(self);
priv->kind = UP_DEVICE_KIND_UNKNOWN;
priv->state = UP_DEVICE_STATE_UNKNOWN;
priv->object_path = NULL;
@@ -449,6 +446,7 @@ indicator_power_device_get_icon_names (const IndicatorPowerDevice * device)
break;
case UP_DEVICE_STATE_CHARGING:
+
suffix_str = get_device_icon_suffix (percentage);
index_str = get_closest_10_percent_percentage (percentage);
g_ptr_array_add (names, g_strdup_printf ("%s-%s-charging", kind_str, index_str));
@@ -744,11 +742,11 @@ time_is_relevant (const IndicatorPowerDevice * device)
* * “X (charged)” if it is fully charged and not discharging;
* * “X (expanded time-remaining string)” if it is charging,
* or discharging with less than 24 hours left;
- * * “X” if it is discharging with 24 hours or more left.
+ * * “X” if it is discharging with 24 hours or more left.
*
* The accessible label for the menu item should be the same as the
* visible label, except with the accessible time-remaining string
- * instead of the expanded time-remaining string.
+ * instead of the expanded time-remaining string.
*/
static char *
get_menuitem_text (const IndicatorPowerDevice * device,
@@ -817,7 +815,7 @@ indicator_power_device_get_accessible_text (const IndicatorPowerDevice * device)
* If “Show Percentage in Menu Bar” is checked (as it should not be by default),
* the brackets should contain the percentage charge for that device.
*
- * If both conditions are true, the time and percentage should be separated by a space.
+ * If both conditions are true, the time and percentage should be separated by a space.
*/
char*
indicator_power_device_get_readable_title (const IndicatorPowerDevice * device,
@@ -873,7 +871,7 @@ indicator_power_device_get_readable_title (const IndicatorPowerDevice * device,
/**
* Regardless, the accessible name for the whole menu title should be the same
- * as the accessible name for that thing’s component inside the menu itself.
+ * as the accessible name for that thing’s component inside the menu itself.
*/
char *
indicator_power_device_get_accessible_title (const IndicatorPowerDevice * device,
diff --git a/src/service.c b/src/service.c
index c7aec9e..cc4e9aa 100644
--- a/src/service.c
+++ b/src/service.c
@@ -37,10 +37,6 @@
#define SETTINGS_ICON_POLICY_S "icon-policy"
#define SETTINGS_SHOW_PERCENTAGE_S "show-percentage"
-G_DEFINE_TYPE (IndicatorPowerService,
- indicator_power_service,
- G_TYPE_OBJECT)
-
enum
{
SIGNAL_NAME_LOST,
@@ -129,6 +125,8 @@ struct _IndicatorPowerServicePrivate
typedef IndicatorPowerServicePrivate priv_t;
+G_DEFINE_TYPE_WITH_PRIVATE(IndicatorPowerService, indicator_power_service, G_TYPE_OBJECT)
+
/***
****
**** DEVICES
@@ -967,7 +965,7 @@ on_bus_acquired (GDBusConnection * connection,
g_debug ("bus acquired: %s", name);
- p->conn = g_object_ref (G_OBJECT (connection));
+ p->conn = (GDBusConnection*)g_object_ref(G_OBJECT (connection));
g_object_notify_by_pspec (G_OBJECT(self), properties[PROP_BUS]);
/* export the battery properties */
@@ -1188,9 +1186,7 @@ indicator_power_service_init (IndicatorPowerService * self)
priv_t * p;
int i;
- p = G_TYPE_INSTANCE_GET_PRIVATE (self,
- INDICATOR_TYPE_POWER_SERVICE,
- IndicatorPowerServicePrivate);
+ p = indicator_power_service_get_instance_private(self);
self->priv = p;
p->cancellable = g_cancellable_new ();
@@ -1233,8 +1229,6 @@ indicator_power_service_class_init (IndicatorPowerServiceClass * klass)
object_class->get_property = my_get_property;
object_class->set_property = my_set_property;
- g_type_class_add_private (klass, sizeof (IndicatorPowerServicePrivate));
-
signals[SIGNAL_NAME_LOST] = g_signal_new (
INDICATOR_POWER_SERVICE_SIGNAL_NAME_LOST,
G_TYPE_FROM_CLASS(klass),