summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Hull <[email protected]>2012-11-04 00:03:13 -0400
committerBrent Hull <[email protected]>2012-11-04 00:03:13 -0400
commit6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff (patch)
tree774710082697e9b466b1f87c311fedbe2e0ce05f
parent7fa7c26dce5c987539f70b323ae1ff9d40752b0b (diff)
downloadmate-power-manager-6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff.tar.bz2
mate-power-manager-6e3ef00b551ed8ac5b877f0c7c8ebbc4f7fcb3ff.tar.xz
Don't depend on mate-screensaver's gschema being installed
-rw-r--r--src/gpm-control.c25
-rw-r--r--src/gpm-screensaver.c18
-rw-r--r--src/gpm-screensaver.h1
3 files changed, 20 insertions, 24 deletions
diff --git a/src/gpm-control.c b/src/gpm-control.c
index d29146f..4b6c959 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -55,7 +55,6 @@
struct GpmControlPrivate
{
GSettings *settings;
- GSettings *settings_ss;
UpClient *client;
};
@@ -116,13 +115,31 @@ gpm_control_get_lock_policy (GpmControl *control, const gchar *policy)
{
gboolean do_lock;
gboolean use_ss_setting;
+ const char * const *schemas;
+ gboolean schema_exists;
+ gint i;
+
+ /* Check if the mate-screensaver schema exists before trying to read
+ the lock setting to prevent crashing. See GNOME bug #651225. */
+ schemas = g_settings_list_schemas ();
+ schema_exists = FALSE;
+ for (i = 0; schemas[i] != NULL; i++) {
+ if (g_strcmp0 (schemas[i], GS_SETTINGS_SCHEMA) == 0) {
+ schema_exists = TRUE;
+ break;
+ }
+ }
+
/* This allows us to over-ride the custom lock settings set
with a system default set in mate-screensaver.
See bug #331164 for all the juicy details. :-) */
use_ss_setting = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_USE_SCREENSAVER);
- if (use_ss_setting) {
- do_lock = g_settings_get_boolean (control->priv->settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
+ if (use_ss_setting && schema_exists) {
+ GSettings *settings_ss;
+ settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
+ do_lock = g_settings_get_boolean (settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
egg_debug ("Using ScreenSaver settings (%i)", do_lock);
+ g_object_unref (settings_ss);
} else {
do_lock = g_settings_get_boolean (control->priv->settings, policy);
egg_debug ("Using custom locking settings (%i)", do_lock);
@@ -279,7 +296,6 @@ gpm_control_finalize (GObject *object)
control = GPM_CONTROL (object);
g_object_unref (control->priv->settings);
- g_object_unref (control->priv->settings_ss);
g_object_unref (control->priv->client);
g_return_if_fail (control->priv != NULL);
@@ -328,7 +344,6 @@ gpm_control_init (GpmControl *control)
control->priv->client = up_client_new ();
control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
- control->priv->settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
}
/**
diff --git a/src/gpm-screensaver.c b/src/gpm-screensaver.c
index 5d049dc..7aad8a2 100644
--- a/src/gpm-screensaver.c
+++ b/src/gpm-screensaver.c
@@ -25,7 +25,6 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#include <gio/gio.h>
#include "gpm-screensaver.h"
#include "gpm-common.h"
@@ -42,7 +41,6 @@ static void gpm_screensaver_finalize (GObject *object);
struct GpmScreensaverPrivate
{
DBusGProxy *proxy;
- GSettings *settings;
};
enum {
@@ -128,20 +126,6 @@ gpm_screensaver_proxy_disconnect_more (GpmScreensaver *screensaver)
#endif
/**
- * gpm_screensaver_lock_enabled:
- * @screensaver: This class instance
- * Return value: If mate-screensaver is set to lock the screen on screensave
- **/
-gboolean
-gpm_screensaver_lock_enabled (GpmScreensaver *screensaver)
-{
- gboolean enabled;
- g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- enabled = g_settings_get_boolean (screensaver->priv->settings, GS_SETTINGS_PREF_LOCK_ENABLED);
- return enabled;
-}
-
-/**
* gpm_screensaver_lock
* @screensaver: This class instance
* Return value: Success value
@@ -357,7 +341,6 @@ gpm_screensaver_init (GpmScreensaver *screensaver)
GS_LISTENER_SERVICE,
GS_LISTENER_PATH,
GS_LISTENER_INTERFACE);
- screensaver->priv->settings = g_settings_new (GS_SETTINGS_SCHEMA);
}
/**
@@ -374,7 +357,6 @@ gpm_screensaver_finalize (GObject *object)
screensaver = GPM_SCREENSAVER (object);
screensaver->priv = GPM_SCREENSAVER_GET_PRIVATE (screensaver);
- g_object_unref (screensaver->priv->settings);
g_object_unref (screensaver->priv->proxy);
G_OBJECT_CLASS (gpm_screensaver_parent_class)->finalize (object);
diff --git a/src/gpm-screensaver.h b/src/gpm-screensaver.h
index b4c5733..2732f28 100644
--- a/src/gpm-screensaver.h
+++ b/src/gpm-screensaver.h
@@ -55,7 +55,6 @@ GpmScreensaver *gpm_screensaver_new (void);
void gpm_screensaver_test (gpointer data);
gboolean gpm_screensaver_lock (GpmScreensaver *screensaver);
-gboolean gpm_screensaver_lock_enabled (GpmScreensaver *screensaver);
guint32 gpm_screensaver_add_throttle (GpmScreensaver *screensaver,
const gchar *reason);
gboolean gpm_screensaver_remove_throttle (GpmScreensaver *screensaver,