aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/notifier.c13
-rw-r--r--tests/glib-fixture.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/src/notifier.c b/src/notifier.c
index 93ab461..e6c511f 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -95,6 +95,7 @@ typedef struct
GCancellable * cancellable;
#ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
DbusAccountsServiceSound * accounts_service_sound_proxy;
+ gboolean accounts_service_sound_proxy_pending;
#endif
}
IndicatorPowerNotifierPrivate;
@@ -168,7 +169,10 @@ on_sound_proxy_ready (GObject * source_object G_GNUC_UNUSED,
if (error != NULL)
{
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning("%s Couldn't find accounts service sound proxy: %s", G_STRLOC, error->message);
+ {
+ get_priv(gself)->accounts_service_sound_proxy_pending = FALSE;
+ g_warning("%s Couldn't find accounts service sound proxy: %s", G_STRLOC, error->message);
+ }
g_clear_error(&error);
}
@@ -178,6 +182,7 @@ on_sound_proxy_ready (GObject * source_object G_GNUC_UNUSED,
priv_t * const p = get_priv (self);
g_clear_object (&p->accounts_service_sound_proxy);
p->accounts_service_sound_proxy = proxy;
+ p->accounts_service_sound_proxy_pending = FALSE;
}
}
@@ -189,10 +194,11 @@ silent_mode (IndicatorPowerNotifier * self)
/* if we don't have a proxy yet, assume we're in silent mode
as a "do no harm" level of response */
- if (p->accounts_service_sound_proxy == NULL)
+ if (p->accounts_service_sound_proxy_pending)
return TRUE;
- return dbus_accounts_service_sound_get_silent_mode(p->accounts_service_sound_proxy);
+ return (p->accounts_service_sound_proxy != NULL)
+ && dbus_accounts_service_sound_get_silent_mode(p->accounts_service_sound_proxy);
}
#endif
@@ -515,6 +521,7 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self)
g_critical("Unable to initialize libnotify! Notifications might not be shown.");
#ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
+ p->accounts_service_sound_proxy_pending = TRUE;
gchar* object_path = g_strdup_printf("/org/freedesktop/Accounts/User%lu", (gulong)getuid());
dbus_accounts_service_sound_proxy_new_for_bus(
G_BUS_TYPE_SYSTEM,
diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h
index 09c37a3..9494df2 100644
--- a/tests/glib-fixture.h
+++ b/tests/glib-fixture.h
@@ -52,7 +52,7 @@ class GlibFixture : public ::testing::Test
if (expected_log[level] != n)
for (size_t i=0; i<n; ++i)
- g_print("%lu %s\n", (n+1), v[i].c_str());
+ g_print("%d %s\n", int(n+1), v[i].c_str());
}
expected_log.clear();