aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2020-09-03 18:43:57 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-09-04 19:15:05 +0000
commit147130a91624079dbc6237d2426f122e0f6513e6 (patch)
tree3f5f484e69eb1daa45a2e1a4feba003cfbe9f0ed
parent2849569fffd380b4424278c848e9483e54e4a0c5 (diff)
downloadayatana-indicator-power-147130a91624079dbc6237d2426f122e0f6513e6.tar.gz
ayatana-indicator-power-147130a91624079dbc6237d2426f122e0f6513e6.tar.bz2
ayatana-indicator-power-147130a91624079dbc6237d2426f122e0f6513e6.zip
Fix deprecations and build warnings.
Fixes AyatanaIndicators/ayatana-indicator-power#9.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/device.c8
-rw-r--r--src/service.c14
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/test-notify.cc4
6 files changed, 10 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11ed3f6..c5580f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,7 +69,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-c++98-compat -Wno-padded") # these are annoying
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-documentation") # gtk-doc != doxygen
else()
- set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wall -Wextra -Wpedantic -Wformat=2")
+ set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wall -Wformat=2") # Use -Wextra and -Wpedantic explicitly if needed
endif()
set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-missing-field-initializers") # GActionEntry
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 524ce92..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));
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),
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4010b54..93b62e9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,7 +8,6 @@ include_directories (SYSTEM ${DBUSTEST_INCLUDE_DIRS})
# add warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_WARNING_ARGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test
# build the necessary schemas
set_directory_properties (PROPERTIES
diff --git a/tests/test-notify.cc b/tests/test-notify.cc
index 9a11984..63214c2 100644
--- a/tests/test-notify.cc
+++ b/tests/test-notify.cc
@@ -150,8 +150,8 @@ protected:
while ((bus != nullptr) && (cleartry < 50))
{
g_usleep(100000);
- while (g_main_pending())
- g_main_iteration(true);
+ while (g_main_context_pending(NULL))
+ g_main_context_iteration(NULL, true);
cleartry++;
}