summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalló György <[email protected]>2014-10-03 00:20:05 +0200
committerStefano Karapetsas <[email protected]>2014-10-03 08:31:39 +0200
commitac5bfbfd01210309674bd946f09f576773d06917 (patch)
tree7004916d766356cf181f43565ca5e2fb5b8ca6f8
parentd76fe8f9c85557ee767fd15fb692f3820ebb5610 (diff)
downloadmate-control-center-ac5bfbfd01210309674bd946f09f576773d06917.tar.bz2
mate-control-center-ac5bfbfd01210309674bd946f09f576773d06917.tar.xz
Use Caja GSettings schema optionally
This makes Caja dependency optional. Disable desktop font setting if no Caja present. Closes https://github.com/mate-desktop/mate-control-center/pull/119
-rw-r--r--capplets/appearance/appearance-font.c14
-rw-r--r--capplets/appearance/appearance-main.c13
-rw-r--r--capplets/appearance/appearance-themes.c28
-rw-r--r--capplets/common/mate-theme-apply.c20
4 files changed, 33 insertions, 42 deletions
diff --git a/capplets/appearance/appearance-font.c b/capplets/appearance/appearance-font.c
index 0ae22153..99281f23 100644
--- a/capplets/appearance/appearance-font.c
+++ b/capplets/appearance/appearance-font.c
@@ -759,11 +759,15 @@ void font_init(AppearanceData* data)
G_SETTINGS_BIND_DEFAULT);
widget = appearance_capplet_get_widget (data, "desktop_font");
- g_settings_bind (data->caja_settings,
- DESKTOP_FONT_KEY,
- G_OBJECT (widget),
- "font-name",
- G_SETTINGS_BIND_DEFAULT);
+
+ if (data->caja_settings)
+ g_settings_bind (data->caja_settings,
+ DESKTOP_FONT_KEY,
+ G_OBJECT (widget),
+ "font-name",
+ G_SETTINGS_BIND_DEFAULT);
+ else
+ gtk_widget_set_sensitive (widget, FALSE);
widget = appearance_capplet_get_widget (data, "window_title_font");
g_settings_bind (data->marco_settings,
diff --git a/capplets/appearance/appearance-main.c b/capplets/appearance/appearance-main.c
index 7a717ad1..be4f3682 100644
--- a/capplets/appearance/appearance-main.c
+++ b/capplets/appearance/appearance-main.c
@@ -19,6 +19,7 @@
*/
#include <glib/gi18n.h>
+#include <libmate-desktop/mate-gsettings.h>
#include "appearance.h"
#include "appearance-desktop.h"
#include "appearance-font.h"
@@ -62,7 +63,12 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context)
data = g_new (AppearanceData, 1);
data->settings = g_settings_new (APPEARANCE_SCHEMA);
data->wp_settings = g_settings_new (WP_SCHEMA);
- data->caja_settings = g_settings_new (CAJA_SCHEMA);
+
+ if (mate_gsettings_schema_exists (CAJA_SCHEMA))
+ data->caja_settings = g_settings_new (CAJA_SCHEMA);
+ else
+ data->caja_settings = NULL;
+
data->interface_settings = g_settings_new (INTERFACE_SCHEMA);
data->marco_settings = g_settings_new (MARCO_SCHEMA);
data->mouse_settings = g_settings_new (MOUSE_SCHEMA);
@@ -95,7 +101,10 @@ main_window_response (GtkWidget *widget,
g_object_unref (data->thumb_factory);
g_object_unref (data->settings);
g_object_unref (data->wp_settings);
- g_object_unref (data->caja_settings);
+
+ if (data->caja_settings)
+ g_object_unref (data->caja_settings);
+
g_object_unref (data->interface_settings);
g_object_unref (data->marco_settings);
g_object_unref (data->mouse_settings);
diff --git a/capplets/appearance/appearance-themes.c b/capplets/appearance/appearance-themes.c
index 87266c94..6f051051 100644
--- a/capplets/appearance/appearance-themes.c
+++ b/capplets/appearance/appearance-themes.c
@@ -31,6 +31,7 @@
#include <libwindow-settings/mate-wm-manager.h>
#include <string.h>
#include <libmate-desktop/mate-desktop-thumbnail.h>
+#include <libmate-desktop/mate-gsettings.h>
#define CUSTOM_THEME_NAME "__custom__"
@@ -201,9 +202,6 @@ theme_load_from_gsettings (AppearanceData *data)
{
MateThemeMetaInfo *theme;
gchar *scheme;
- const char * const *schemas;
- gboolean schema_exists;
- gint i;
theme = mate_theme_meta_info_new ();
@@ -226,18 +224,7 @@ theme_load_from_gsettings (AppearanceData *data)
if (theme->icon_theme_name == NULL)
theme->icon_theme_name = g_strdup ("menta");
- /* We need this because mate-control-center does not depend on mate-notification-daemon,
- * and if we try to get notification theme without schema installed, gsettings crashes
- * see https://bugzilla.gnome.org/show_bug.cgi?id=651225 */
- schemas = g_settings_list_schemas ();
- schema_exists = FALSE;
- for (i = 0; schemas[i] != NULL; i++) {
- if (g_strcmp0 (schemas[i], NOTIFICATION_SCHEMA) == 0) {
- schema_exists = TRUE;
- break;
- }
- }
- if (schema_exists == TRUE) {
+ if (mate_gsettings_schema_exists (NOTIFICATION_SCHEMA)) {
GSettings *notification_settings;
notification_settings = g_settings_new (NOTIFICATION_SCHEMA);
theme->notification_theme_name = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY);
@@ -465,7 +452,7 @@ theme_message_area_response_cb (GtkWidget *w,
data->revert_documents_font = NULL;
}
- if (data->revert_desktop_font != NULL) {
+ if (data->caja_settings && data->revert_desktop_font != NULL) {
g_settings_set_string (data->caja_settings, DESKTOP_FONT_KEY, data->revert_desktop_font);
g_free (data->revert_desktop_font);
data->revert_desktop_font = NULL;
@@ -513,7 +500,7 @@ theme_message_area_response_cb (GtkWidget *w,
g_settings_set_string (data->interface_settings, DOCUMENT_FONT_KEY, theme->documents_font);
}
- if (theme->desktop_font) {
+ if (data->caja_settings && theme->desktop_font) {
tmpfont = g_settings_get_string (data->caja_settings, DESKTOP_FONT_KEY);
if (tmpfont != NULL) {
g_free (data->revert_desktop_font);
@@ -617,7 +604,7 @@ theme_message_area_update (AppearanceData *data)
g_free (font);
}
- if (!show_apply_font && theme->desktop_font) {
+ if (data->caja_settings && !show_apply_font && theme->desktop_font) {
font = g_settings_get_string (data->caja_settings, DESKTOP_FONT_KEY);
show_apply_font =
(!font || strcmp (theme->application_font, font) != 0);
@@ -1131,7 +1118,10 @@ void themes_init(AppearanceData* data)
g_signal_connect (data->wp_settings, "changed::" WP_FILE_KEY, G_CALLBACK (background_or_font_changed), data);
g_signal_connect (data->interface_settings, "changed::" GTK_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
g_signal_connect (data->interface_settings, "changed::" DOCUMENT_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
- g_signal_connect (data->caja_settings, "changed::" DESKTOP_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
+
+ if (data->caja_settings)
+ g_signal_connect (data->caja_settings, "changed::" DESKTOP_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
+
g_signal_connect (data->marco_settings, "changed::" WINDOW_TITLE_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
g_signal_connect (data->interface_settings, "changed::" MONOSPACE_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
diff --git a/capplets/common/mate-theme-apply.c b/capplets/common/mate-theme-apply.c
index 4489b302..df5a8953 100644
--- a/capplets/common/mate-theme-apply.c
+++ b/capplets/common/mate-theme-apply.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <gio/gio.h>
+#include <libmate-desktop/mate-gsettings.h>
#include "mate-theme-apply.h"
#include "gtkrc-utils.h"
@@ -52,9 +53,6 @@ mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
GSettings *marco_settings;
GSettings *mouse_settings;
GSettings *notification_settings = NULL;
- const char * const *schemas;
- gboolean schema_exists;
- gint i;
gchar *old_key;
gint old_key_int;
@@ -62,20 +60,10 @@ mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
marco_settings = g_settings_new (MARCO_SCHEMA);
mouse_settings = g_settings_new (MOUSE_SCHEMA);
- /* We need this because mate-control-center does not depend on mate-notification-daemon,
- * and if we try to get notification theme without schema installed, gsettings crashes
- * see https://bugzilla.gnome.org/show_bug.cgi?id=651225 */
- schemas = g_settings_list_schemas ();
- schema_exists = FALSE;
- for (i = 0; schemas[i] != NULL; i++) {
- if (g_strcmp0 (schemas[i], NOTIFICATION_SCHEMA) == 0) {
- schema_exists = TRUE;
- break;
- }
- }
- if (schema_exists == TRUE) {
+ if (mate_gsettings_schema_exists (NOTIFICATION_SCHEMA))
+ {
notification_settings = g_settings_new (NOTIFICATION_SCHEMA);
- }
+ }
/* Set the gtk+ key */
old_key = g_settings_get_string (interface_settings, GTK_THEME_KEY);