aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/device.c16
-rw-r--r--src/service.c14
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/test-notify.cc12
6 files changed, 19 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2a18bc0..c5580f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ option (enable_tests "Build the package's automatic tests." ON)
##
## GNU standard installation directories
-##
+##
include (GNUInstallDirs)
set (CMAKE_INSTALL_PKGLIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
@@ -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 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),
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 a7e2beb..63214c2 100644
--- a/tests/test-notify.cc
+++ b/tests/test-notify.cc
@@ -88,8 +88,8 @@ protected:
NOTIFY_INTERFACE,
&error);
g_assert_no_error (error);
-
- // METHOD_GET_INFO
+
+ // METHOD_GET_INFO
dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_GET_INFO,
nullptr,
G_VARIANT_TYPE("(ssss)"),
@@ -113,7 +113,7 @@ protected:
g_assert_no_error (error);
g_free (str);
- // METHOD_CLOSE
+ // METHOD_CLOSE
str = g_strdup_printf("self.EmitSignal('%s', '%s', 'uu', [ args[0], %d ])",
NOTIFY_INTERFACE,
SIGNAL_CLOSED,
@@ -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++;
}
@@ -293,7 +293,7 @@ TEST_F(NotifyFixture, LevelsDuringBatteryDrain)
nullptr);
// confirm that draining the battery puts
- // the power_level change through its paces
+ // the power_level change through its paces
for (int i=100; i>=0; --i)
{
changed_params = ChangedParams();