aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-10-08 15:49:58 -0400
committerTed Gould <ted@gould.cx>2011-10-08 15:49:58 -0400
commit3212519b44786184c2753597cab30d89395e735e (patch)
tree79271dfb1f8d89af96ee60601168f9c33041324d
parent749c8c0bdc194d438b6eea99dbedd0fd327c10da (diff)
downloadayatana-indicator-session-3212519b44786184c2753597cab30d89395e735e.tar.gz
ayatana-indicator-session-3212519b44786184c2753597cab30d89395e735e.tar.bz2
ayatana-indicator-session-3212519b44786184c2753597cab30d89395e735e.zip
Error gracefully if we can't get our settings.
-rw-r--r--src/settings-helper.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/settings-helper.c b/src/settings-helper.c
index d70df95..b8f482f 100644
--- a/src/settings-helper.c
+++ b/src/settings-helper.c
@@ -38,41 +38,44 @@ static guint logout_notify = 0;
static guint restart_notify = 0;
static guint shutdown_notify = 0;
-static void
+static gboolean
build_settings (void) {
- if(!settings) {
+ if (settings == NULL) {
settings = g_settings_new (SESSION_SCHEMA);
}
- return;
+ if (settings == NULL) {
+ return FALSE;
+ }
+ return TRUE;
}
gboolean
supress_confirmations (void) {
- build_settings();
+ g_return_val_if_fail(build_settings(), FALSE);
return g_settings_get_boolean (settings, SUPPRESS_KEY) ;
}
gboolean
should_show_user_menu (void) {
- build_settings();
+ g_return_val_if_fail(build_settings(), TRUE);
return g_settings_get_boolean (settings, SHOW_USER_MENU) ;
}
gboolean
show_logout (void) {
- build_settings();
+ g_return_val_if_fail(build_settings(), TRUE);
return !g_settings_get_boolean (settings, LOGOUT_KEY) ;
}
gboolean
show_restart (void) {
- build_settings();
+ g_return_val_if_fail(build_settings(), TRUE);
return !g_settings_get_boolean (settings, RESTART_KEY) ;
}
gboolean
show_shutdown (void) {
- build_settings();
+ g_return_val_if_fail(build_settings(), TRUE);
return !g_settings_get_boolean (settings, SHUTDOWN_KEY) ;
}
@@ -122,7 +125,7 @@ update_shutdown_callback (GSettings * settings, const gchar * key, gpointer data
void
update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) {
/* If we don't have a client, build one. */
- build_settings();
+ g_return_if_fail(build_settings());
if (confirmation_notify != 0) {
g_signal_handler_disconnect (settings, confirmation_notify);