Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

battstat: fix deprecated up_client_get_devices #487

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions battstat/battstat-upower.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ device_cb (UpClient *client, UpDevice *device, gpointer user_data) {
schedule_status_callback();
}

#if UP_CHECK_VERSION (0, 99, 0)
static void
device_removed_cb (UpClient *client, const gchar *object_path, gpointer user_data) {
schedule_status_callback();
}
#endif

/* ---- public functions ---- */

Expand All @@ -87,29 +85,15 @@ battstat_upower_initialise (void (*callback) (void))
if( (upc = up_client_new() ) == NULL )
goto error_out;

#if UP_CHECK_VERSION(0, 99, 0)
GPtrArray *devices;
devices = up_client_get_devices(upc);
devices = up_client_get_devices2 (upc);
if (!devices) {
goto error_shutdownclient;
}
g_ptr_array_unref(devices);
#else
GError *gerror;
GCancellable *cancellable = g_cancellable_new ();
if (! up_client_enumerate_devices_sync (upc, cancellable, &gerror)) {
g_debug ("Unable to enumerate upower devices: %s\n", gerror->message);
goto error_shutdownclient;
}
#endif

g_signal_connect_after( upc, "device-added", G_CALLBACK (device_cb), NULL );
#if UP_CHECK_VERSION(0, 99, 0)
g_signal_connect_after( upc, "device-removed", G_CALLBACK (device_removed_cb), NULL );
#else
g_signal_connect_after( upc, "device-changed", G_CALLBACK (device_cb), NULL );
g_signal_connect_after( upc, "device-removed", G_CALLBACK (device_cb), NULL );
#endif

return NULL;

Expand Down Expand Up @@ -149,7 +133,7 @@ void
battstat_upower_get_battery_info( BatteryStatus *status )
{

GPtrArray *devices = up_client_get_devices( upc );
GPtrArray *devices = up_client_get_devices2 (upc);

/* The calculation to get overall percentage power remaining is as follows:
*
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GTK_REQUIRED=3.22.0
LIBPANEL4_REQUIRED=1.17.0
LIBGTOP_REQUIRED=2.12.0
LIBNOTIFY_REQUIRED=0.7.0
UPOWER_REQUIRED=0.9.4
UPOWER_REQUIRED=0.99.8
DBUS_GLIB_REQUIRED=0.74
LIBXML_REQUIRED=2.5.0
POLKIT_REQUIRED=0.97
Expand Down