diff options
author | Mike Ruprecht <cmaiku@gmail.com> | 2017-07-09 16:15:25 -0500 |
---|---|---|
committer | Mike Ruprecht <cmaiku@gmail.com> | 2017-07-09 16:15:25 -0500 |
commit | b639df6f90c5f7d17204f9727d3488cb90e86d92 (patch) | |
tree | ee67dc0131fcef109d863a312bd9401661bf1624 /pidgin/gtkidle.c | |
parent | 4807ef1907ab4a47acbfe1227e0205024afde26a (diff) | |
download | pidgin-b639df6f90c5f7d17204f9727d3488cb90e86d92.tar.gz |
gtkidle: Use clearer control structure for checking DBus screensavers
It was suggested it would be better to avoid pointer math and to use
a for loop instead of a while loop in this case. This patch addresses
these suggestions.
Diffstat (limited to 'pidgin/gtkidle.c')
-rw-r--r-- | pidgin/gtkidle.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pidgin/gtkidle.c b/pidgin/gtkidle.c index b46b5b2eee..c8f8292a39 100644 --- a/pidgin/gtkidle.c +++ b/pidgin/gtkidle.c @@ -53,7 +53,6 @@ static const PidginDBusScreenSaverInfo screensavers[] = { "/org/kde/ScreenSaver", "org.kde.ScreenSaver" }, - { NULL, NULL, NULL} }; #endif /* !HAVE_IOKIT && !_WIN32 */ @@ -100,7 +99,7 @@ pidgin_get_time_idle(void) /* Query Windows */ return (GetTickCount() - winpidgin_get_lastactive()) / 1000; # else - static const PidginDBusScreenSaverInfo *info = screensavers; + static guint idx = 0; GApplication *app; GDBusConnection *conn; GVariant *reply = NULL; @@ -124,7 +123,9 @@ pidgin_get_time_idle(void) return 0; } - while (reply == NULL && info->bus_name != NULL) { + for (; idx < G_N_ELEMENTS(screensavers); ++idx) { + const PidginDBusScreenSaverInfo *info = &screensavers[idx]; + reply = g_dbus_connection_call_sync(conn, info->bus_name, info->object_path, info->iface_name, "GetActiveTime", @@ -156,7 +157,6 @@ pidgin_get_time_idle(void) } g_clear_error(&error); - ++info; } if (reply == NULL) { |