summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-09-06 14:14:59 +0200
committerStefano Karapetsas <[email protected]>2012-09-06 14:14:59 +0200
commitf426641aacea9d5f7683be776536bc6301c7baef (patch)
treed19911212091bfcadf2a976d219aca093ef0606f /libcaja-private
parent465e6ae56a2a81cd346d573532dc4a39c16df225 (diff)
downloadcaja-f426641aacea9d5f7683be776536bc6301c7baef.tar.bz2
caja-f426641aacea9d5f7683be776536bc6301c7baef.tar.xz
remove latest mateconf usage
metadata saved in files instead of migrate to gsettings (caja-desktop-metadata.c is from nautilus)
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/Makefile.am2
-rw-r--r--libcaja-private/caja-desktop-directory-file.c157
-rw-r--r--libcaja-private/caja-desktop-directory-file.h10
-rw-r--r--libcaja-private/caja-desktop-icon-file.c5
-rw-r--r--libcaja-private/caja-desktop-metadata.c294
-rw-r--r--libcaja-private/caja-desktop-metadata.h47
-rw-r--r--libcaja-private/caja-directory-background.c130
-rw-r--r--libcaja-private/caja-global-preferences.c19
-rw-r--r--libcaja-private/caja-global-preferences.h4
-rw-r--r--libcaja-private/caja-metadata.h3
10 files changed, 384 insertions, 287 deletions
diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am
index 93d67834..da22bd94 100644
--- a/libcaja-private/Makefile.am
+++ b/libcaja-private/Makefile.am
@@ -74,6 +74,8 @@ libcaja_private_la_SOURCES = \
caja-desktop-link-monitor.h \
caja-desktop-link.c \
caja-desktop-link.h \
+ caja-desktop-metadata.c \
+ caja-desktop-metadata.h \
caja-directory-async.c \
caja-directory-background.c \
caja-directory-background.h \
diff --git a/libcaja-private/caja-desktop-directory-file.c b/libcaja-private/caja-desktop-directory-file.c
index 8cddf779..0f15cda1 100644
--- a/libcaja-private/caja-desktop-directory-file.c
+++ b/libcaja-private/caja-desktop-directory-file.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "caja-desktop-directory-file.h"
+#include "caja-desktop-metadata.h"
#include "caja-directory-notify.h"
#include "caja-directory-private.h"
#include "caja-file-attributes.h"
@@ -33,8 +34,6 @@
#include "caja-file-utilities.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
-#include <mateconf/mateconf-client.h>
-#include <mateconf/mateconf-value.h>
#include "caja-desktop-directory.h"
#include "caja-metadata.h"
#include <gtk/gtk.h>
@@ -225,7 +224,7 @@ desktop_callback_check_done (DesktopCallback *desktop_callback)
}
/* Ensure our metadata is updated before calling back. */
- caja_desktop_update_metadata_from_mateconf(CAJA_FILE (desktop_callback->desktop_file),
+ caja_desktop_update_metadata_from_keyfile(CAJA_FILE (desktop_callback->desktop_file),
"directory");
/* Remove from the hash table before sending it. */
@@ -467,156 +466,6 @@ monitor_destroy (gpointer data)
g_free (monitor);
}
-static char *
-get_metadata_mateconf_path (const char *name,
- const char *key)
-{
- char *res, *escaped_name;
-
- escaped_name = mateconf_escape_key (name, -1);
- res = g_build_filename (CAJA_DESKTOP_METADATA_MATECONF_PATH, escaped_name, key, NULL);
- g_free (escaped_name);
-
- return res;
-}
-
-void
-caja_desktop_set_metadata_string (CajaFile *file,
- const char *name,
- const char *key,
- const char *string)
-{
- MateConfClient *client;
- char *mateconf_key;
-
- client = mateconf_client_get_default ();
- mateconf_key = get_metadata_mateconf_path (name, key);
-
- if (string)
- {
- mateconf_client_set_string (client, mateconf_key, string, NULL);
- }
- else
- {
- mateconf_client_unset (client, mateconf_key, NULL);
- }
-
- g_free (mateconf_key);
- g_object_unref (client);
-
- if (caja_desktop_update_metadata_from_mateconf (file, name))
- {
- caja_file_changed (file);
- }
-}
-
-void
-caja_desktop_set_metadata_stringv (CajaFile *file,
- const char *name,
- const char *key,
- char **stringv)
-{
- MateConfClient *client;
- char *mateconf_key;
- GSList *list;
- int i;
-
- client = mateconf_client_get_default ();
- mateconf_key = get_metadata_mateconf_path (name, key);
-
- list = NULL;
- for (i = 0; stringv[i] != NULL; i++)
- {
- list = g_slist_prepend (list, stringv[i]);
- }
- list = g_slist_reverse (list);
-
- mateconf_client_set_list (client, mateconf_key,
- MATECONF_VALUE_STRING,
- list, NULL);
-
- g_slist_free (list);
- g_free (mateconf_key);
- g_object_unref (client);
-
- if (caja_desktop_update_metadata_from_mateconf (file, name))
- {
- caja_file_changed (file);
- }
-}
-
-gboolean
-caja_desktop_update_metadata_from_mateconf (CajaFile *file,
- const char *name)
-{
- MateConfClient *client;
- GSList *entries, *l;
- char *dir;
- const char *key;
- MateConfEntry *entry;
- MateConfValue *value;
- GFileInfo *info;
- gboolean changed;
- char *gio_key;
- GSList *value_list;
- char **strv;
- int i;
-
- client = mateconf_client_get_default ();
-
- dir = get_metadata_mateconf_path (name, NULL);
- entries = mateconf_client_all_entries (client, dir, NULL);
- g_free (dir);
-
- info = g_file_info_new ();
-
- for (l = entries; l != NULL; l = l->next)
- {
- entry = l->data;
-
- key = mateconf_entry_get_key (entry);
- value = mateconf_entry_get_value (entry);
-
- if (value == NULL)
- {
- continue;
- }
- key = strrchr (key, '/') + 1;
-
- gio_key = g_strconcat ("metadata::", key, NULL);
- if (value->type == MATECONF_VALUE_STRING)
- {
- g_file_info_set_attribute_string (info, gio_key,
- mateconf_value_get_string (value));
- }
- else if (value->type == MATECONF_VALUE_LIST &&
- mateconf_value_get_list_type (value) == MATECONF_VALUE_STRING)
- {
- value_list = mateconf_value_get_list (value);
- strv = g_new (char *, g_slist_length (value_list) + 1);
- for (i = 0; value_list != NULL; i++, value_list = value_list->next)
- {
- strv[i] = l->data;
- }
- strv[i] = NULL;
- g_file_info_set_attribute_stringv (info, gio_key, strv);
- g_free (strv);
- }
-
- g_free (gio_key);
-
- mateconf_entry_unref (entry);
- }
- g_slist_free (entries);
-
- changed = caja_file_update_metadata_from_info (file, info);
-
- g_object_unref (info);
- g_object_unref (client);
-
- return changed;
-}
-
static void
caja_desktop_directory_file_set_metadata (CajaFile *file,
const char *key,
@@ -630,7 +479,7 @@ caja_desktop_directory_file_set_metadata_as_list (CajaFile *file,
const char *key,
char **value)
{
- caja_desktop_set_metadata_stringv (file, "directory", key, value);
+ caja_desktop_set_metadata_stringv (file, "directory", key, (const gchar **) value);
}
static void
diff --git a/libcaja-private/caja-desktop-directory-file.h b/libcaja-private/caja-desktop-directory-file.h
index 367fa1fd..c78906f2 100644
--- a/libcaja-private/caja-desktop-directory-file.h
+++ b/libcaja-private/caja-desktop-directory-file.h
@@ -54,15 +54,5 @@ typedef struct
} CajaDesktopDirectoryFileClass;
GType caja_desktop_directory_file_get_type (void);
-gboolean caja_desktop_update_metadata_from_mateconf (CajaFile *file,
- const char *name);
-void caja_desktop_set_metadata_string (CajaFile *file,
- const char *name,
- const char *key,
- const char *string);
-void caja_desktop_set_metadata_stringv (CajaFile *file,
- const char *name,
- const char *key,
- char **stringv);
#endif /* CAJA_DESKTOP_DIRECTORY_FILE_H */
diff --git a/libcaja-private/caja-desktop-icon-file.c b/libcaja-private/caja-desktop-icon-file.c
index 7e24f6dc..c91d2067 100644
--- a/libcaja-private/caja-desktop-icon-file.c
+++ b/libcaja-private/caja-desktop-icon-file.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "caja-desktop-icon-file.h"
+#include "caja-desktop-metadata.h"
#include "caja-desktop-directory-file.h"
#include "caja-directory-notify.h"
#include "caja-directory-private.h"
@@ -294,7 +295,7 @@ caja_desktop_icon_file_new (CajaDesktopLink *link)
update_info_from_link (icon_file);
- caja_desktop_update_metadata_from_mateconf (file, file->details->name);
+ caja_desktop_update_metadata_from_keyfile (file, file->details->name);
caja_directory_add_file (directory, file);
@@ -378,7 +379,7 @@ caja_desktop_icon_file_set_metadata_as_list (CajaFile *file,
CajaDesktopIconFile *desktop_file;
desktop_file = CAJA_DESKTOP_ICON_FILE (file);
- caja_desktop_set_metadata_stringv (file, file->details->name, key, value);
+ caja_desktop_set_metadata_stringv (file, file->details->name, key, (const gchar **) value);
}
static void
diff --git a/libcaja-private/caja-desktop-metadata.c b/libcaja-private/caja-desktop-metadata.c
new file mode 100644
index 00000000..f9d1b25f
--- /dev/null
+++ b/libcaja-private/caja-desktop-metadata.c
@@ -0,0 +1,294 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Caja
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ * 2012 Stefano Karapetsas
+ *
+ * Caja is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Caja is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Cosimo Cecchi <[email protected]>
+ * Stefano Karapetsas <[email protected]>
+ */
+
+#include <config.h>
+
+#include "caja-desktop-metadata.h"
+
+#include "caja-directory-notify.h"
+#include "caja-file-private.h"
+#include "caja-file-utilities.h"
+
+#include <glib/gstdio.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+static guint save_in_idle_source_id = 0;
+
+static gchar *
+get_keyfile_path (void)
+{
+ gchar *xdg_dir, *retval;
+
+ xdg_dir = caja_get_user_directory ();
+ retval = g_build_filename (xdg_dir, "desktop-metadata", NULL);
+
+ g_free (xdg_dir);
+
+ return retval;
+}
+
+static gboolean
+save_in_idle_cb (gpointer data)
+{
+ GKeyFile *keyfile = data;
+ gchar *contents, *filename;
+ gsize length;
+ GError *error = NULL;
+
+ save_in_idle_source_id = 0;
+
+ contents = g_key_file_to_data (keyfile, &length, NULL);
+ filename = get_keyfile_path ();
+
+ if (contents != NULL) {
+ g_file_set_contents (filename,
+ contents, length,
+ &error);
+ g_free (contents);
+ }
+
+ if (error != NULL) {
+ g_warning ("Couldn't save the desktop metadata keyfile to disk: %s",
+ error->message);
+ g_error_free (error);
+ }
+
+ g_free (filename);
+
+ return FALSE;
+}
+
+static void
+save_in_idle (GKeyFile *keyfile)
+{
+ if (save_in_idle_source_id != 0) {
+ g_source_remove (save_in_idle_source_id);
+ }
+
+ save_in_idle_source_id = g_idle_add (save_in_idle_cb, keyfile);
+}
+
+static GKeyFile *
+load_metadata_keyfile (void)
+{
+ GKeyFile *retval;
+ GError *error = NULL;
+ gchar *filename;
+
+ retval = g_key_file_new ();
+ filename = get_keyfile_path ();
+
+ g_key_file_load_from_file (retval,
+ filename,
+ G_KEY_FILE_NONE,
+ &error);
+
+ if (error != NULL) {
+ if (!g_error_matches (error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_NOENT)) {
+ g_print ("Unable to open the desktop metadata keyfile: %s\n",
+ error->message);
+ }
+
+ g_error_free (error);
+ }
+
+ g_free (filename);
+
+ return retval;
+}
+
+static GKeyFile *
+get_keyfile (void)
+{
+ static gboolean keyfile_loaded = FALSE;
+ static GKeyFile *keyfile = NULL;
+
+ if (!keyfile_loaded) {
+ keyfile = load_metadata_keyfile ();
+ keyfile_loaded = TRUE;
+ }
+
+ return keyfile;
+}
+
+void
+caja_desktop_set_metadata_string (CajaFile *file,
+ const gchar *name,
+ const gchar *key,
+ const gchar *string)
+{
+ GKeyFile *keyfile;
+
+ keyfile = get_keyfile ();
+
+ g_key_file_set_string (keyfile,
+ name,
+ key,
+ string);
+
+ save_in_idle (keyfile);
+
+ if (caja_desktop_update_metadata_from_keyfile (file, name)) {
+ caja_file_changed (file);
+ }
+}
+
+#define STRV_TERMINATOR "@x-caja-desktop-metadata-term@"
+
+void
+caja_desktop_set_metadata_stringv (CajaFile *file,
+ const char *name,
+ const char *key,
+ const char * const *stringv)
+{
+ GKeyFile *keyfile;
+ guint length;
+ gchar **actual_stringv = NULL;
+ gboolean free_strv = FALSE;
+
+ keyfile = get_keyfile ();
+
+ /* if we would be setting a single-length strv, append a fake
+ * terminator to the array, to be able to differentiate it later from
+ * the single string case
+ */
+ length = g_strv_length ((gchar **) stringv);
+
+ if (length == 1) {
+ actual_stringv = g_malloc0 (3 * sizeof (gchar *));
+ actual_stringv[0] = (gchar *) stringv[0];
+ actual_stringv[1] = STRV_TERMINATOR;
+ actual_stringv[2] = NULL;
+
+ length = 2;
+ free_strv = TRUE;
+ } else {
+ actual_stringv = (gchar **) stringv;
+ }
+
+ g_key_file_set_string_list (keyfile,
+ name,
+ key,
+ (const gchar **) actual_stringv,
+ length);
+
+ save_in_idle (keyfile);
+
+ if (caja_desktop_update_metadata_from_keyfile (file, name)) {
+ caja_file_changed (file);
+ }
+
+ if (free_strv) {
+ g_free (actual_stringv);
+ }
+}
+
+gboolean
+caja_desktop_update_metadata_from_keyfile (CajaFile *file,
+ const gchar *name)
+{
+ gchar **keys, **values;
+ const gchar *actual_values[2];
+ const gchar *key, *value;
+ gchar *gio_key;
+ gsize length, values_length;
+ GKeyFile *keyfile;
+ GFileInfo *info;
+ gint idx;
+ gboolean res;
+
+ keyfile = get_keyfile ();
+
+ keys = g_key_file_get_keys (keyfile,
+ name,
+ &length,
+ NULL);
+
+ if (keys == NULL) {
+ return FALSE;
+ }
+
+ info = g_file_info_new ();
+
+ for (idx = 0; idx < length; idx++) {
+ key = keys[idx];
+ values = g_key_file_get_string_list (keyfile,
+ name,
+ key,
+ &values_length,
+ NULL);
+
+ gio_key = g_strconcat ("metadata::", key, NULL);
+
+ if (values_length < 1) {
+ continue;
+ } else if (values_length == 1) {
+ g_file_info_set_attribute_string (info,
+ gio_key,
+ values[0]);
+ } else if (values_length == 2) {
+ /* deal with the fact that single-length strv are stored
+ * with an additional terminator in the keyfile string, to differentiate
+ * them from the regular string case.
+ */
+ value = values[1];
+
+ if (g_strcmp0 (value, STRV_TERMINATOR) == 0) {
+ /* if the 2nd value is the terminator, remove it */
+ actual_values[0] = values[0];
+ actual_values[1] = NULL;
+
+ g_file_info_set_attribute_stringv (info,
+ gio_key,
+ (gchar **) actual_values);
+ } else {
+ /* otherwise, set it as a regular strv */
+ g_file_info_set_attribute_stringv (info,
+ gio_key,
+ values);
+ }
+ } else {
+ g_file_info_set_attribute_stringv (info,
+ gio_key,
+ values);
+ }
+
+ g_free (gio_key);
+ g_strfreev (values);
+ }
+
+ res = caja_file_update_metadata_from_info (file, info);
+
+ g_strfreev (keys);
+ g_object_unref (info);
+
+ return res;
+}
diff --git a/libcaja-private/caja-desktop-metadata.h b/libcaja-private/caja-desktop-metadata.h
new file mode 100644
index 00000000..17a85218
--- /dev/null
+++ b/libcaja-private/caja-desktop-metadata.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Caja
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ * 2012 Stefano Karapetsas
+ *
+ * Caja is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Caja is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Cosimo Cecchi <[email protected]>
+ * Stefano Karapetsas <[email protected]>
+ */
+
+#ifndef __CAJA_DESKTOP_METADATA_H__
+#define __CAJA_DESKTOP_METADATA_H__
+
+#include <glib.h>
+
+#include <libcaja-private/caja-file.h>
+
+void caja_desktop_set_metadata_string (CajaFile *file,
+ const gchar *name,
+ const gchar *key,
+ const gchar *string);
+
+void caja_desktop_set_metadata_stringv (CajaFile *file,
+ const char *name,
+ const char *key,
+ const char * const *stringv);
+
+gboolean caja_desktop_update_metadata_from_keyfile (CajaFile *file,
+ const gchar *name);
+
+#endif /* __CAJA_DESKTOP_METADATA_H__ */
diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c
index c5286b8c..05a0f8e5 100644
--- a/libcaja-private/caja-directory-background.c
+++ b/libcaja-private/caja-directory-background.c
@@ -46,7 +46,7 @@ static void background_reset_callback (EelBackground *background,
static void saved_settings_changed_callback (CajaFile *file,
EelBackground *background);
-static void caja_file_background_receive_mateconf_changes (EelBackground *background);
+static void caja_file_background_receive_settings_changes (EelBackground *background);
static void caja_file_background_theme_changed (GSettings *settings,
const gchar *key,
@@ -72,7 +72,7 @@ caja_connect_desktop_background_to_file_metadata (CajaIconContainer *icon_contai
*/
caja_connect_background_to_file_metadata (GTK_WIDGET (icon_container), file, CAJA_DND_ACTION_SET_AS_FOLDER_BACKGROUND);
- caja_file_background_receive_mateconf_changes (background);
+ caja_file_background_receive_settings_changes (background);
}
static void
@@ -101,20 +101,20 @@ caja_file_background_get_default_settings (char **color,
}
-#define BG_PREFERENCES_DRAW_BACKGROUND "/desktop/mate/background/draw_background"
-#define BG_PREFERENCES_PRIMARY_COLOR "/desktop/mate/background/primary_color"
-#define BG_PREFERENCES_SECONDARY_COLOR "/desktop/mate/background/secondary_color"
-#define BG_PREFERENCES_COLOR_SHADING_TYPE "/desktop/mate/background/color_shading_type"
-#define BG_PREFERENCES_PICTURE_OPTIONS "/desktop/mate/background/picture_options"
-#define BG_PREFERENCES_PICTURE_OPACITY "/desktop/mate/background/picture_opacity"
-#define BG_PREFERENCES_PICTURE_FILENAME "/desktop/mate/background/picture_filename"
+#define BG_PREFERENCES_DRAW_BACKGROUND "draw-background"
+#define BG_PREFERENCES_PRIMARY_COLOR "primary-color"
+#define BG_PREFERENCES_SECONDARY_COLOR "secondary-color"
+#define BG_PREFERENCES_COLOR_SHADING_TYPE "color-shading-type"
+#define BG_PREFERENCES_PICTURE_OPTIONS "picture-options"
+#define BG_PREFERENCES_PICTURE_OPACITY "picture-opacity"
+#define BG_PREFERENCES_PICTURE_FILENAME "picture-filename"
static void
-read_color (MateConfClient *client, const char *key, GdkColor *color)
+read_color (const char *key, GdkColor *color)
{
gchar *tmp;
- tmp = mateconf_client_get_string (client, key, NULL);
+ tmp = g_settings_get_string (mate_background_preferences, key);
if (tmp != NULL)
{
@@ -135,7 +135,6 @@ caja_file_background_read_desktop_settings (char **color,
char **image,
EelBackgroundImagePlacement *placement)
{
- MateConfClient *client;
gboolean enabled;
GdkColor primary, secondary;
gchar *tmp, *filename;
@@ -146,13 +145,11 @@ caja_file_background_read_desktop_settings (char **color,
filename = NULL;
- client = mateconf_client_get_default ();
-
/* Get the image filename */
- enabled = mateconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, NULL);
+ enabled = g_settings_get_boolean (mate_background_preferences, BG_PREFERENCES_DRAW_BACKGROUND);
if (enabled)
{
- tmp = mateconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, NULL);
+ tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_PICTURE_FILENAME);
if (tmp != NULL)
{
if (g_utf8_validate (tmp, -1, NULL) && g_file_test (tmp, G_FILE_TEST_EXISTS))
@@ -182,7 +179,7 @@ caja_file_background_read_desktop_settings (char **color,
}
/* Get the placement */
- tmp = mateconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, NULL);
+ tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_PICTURE_OPTIONS);
if (tmp != NULL)
{
if (strcmp (tmp, "wallpaper") == 0)
@@ -228,7 +225,7 @@ caja_file_background_read_desktop_settings (char **color,
g_free (tmp);
/* Get the color */
- tmp = mateconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, NULL);
+ tmp = g_settings_get_string (mate_background_preferences, BG_PREFERENCES_COLOR_SHADING_TYPE);
if (tmp != NULL)
{
if (strcmp (tmp, "solid") == 0)
@@ -259,8 +256,8 @@ caja_file_background_read_desktop_settings (char **color,
}
g_free (tmp);
- read_color (client, BG_PREFERENCES_PRIMARY_COLOR, &primary);
- read_color (client, BG_PREFERENCES_SECONDARY_COLOR, &secondary);
+ read_color (BG_PREFERENCES_PRIMARY_COLOR, &primary);
+ read_color (BG_PREFERENCES_SECONDARY_COLOR, &secondary);
start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary));
end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary));
@@ -278,38 +275,6 @@ caja_file_background_read_desktop_settings (char **color,
g_free (end_color);
}
-static void
-caja_file_background_write_desktop_default_settings (void)
-{
- /* We just unset all the mateconf keys so they go back to
- * defaults
- */
- MateConfClient *client;
- MateConfChangeSet *set;
-
- client = mateconf_client_get_default ();
- set = mateconf_change_set_new ();
-
- /* the list of keys here has to be kept in sync with libmate
- * schemas, which isn't the most maintainable thing ever.
- */
- mateconf_change_set_unset (set, "/desktop/mate/background/picture_options");
- mateconf_change_set_unset (set, "/desktop/mate/background/picture_filename");
- mateconf_change_set_unset (set, "/desktop/mate/background/picture_opacity");
- mateconf_change_set_unset (set, "/desktop/mate/background/primary_color");
- mateconf_change_set_unset (set, "/desktop/mate/background/secondary_color");
- mateconf_change_set_unset (set, "/desktop/mate/background/color_shading_type");
-
- /* this isn't atomic yet so it'll be a bit inefficient, but
- * someday it might be atomic.
- */
- mateconf_client_commit_change_set (client, set, FALSE, NULL);
-
- mateconf_change_set_unref (set);
-
- g_object_unref (G_OBJECT (client));
-}
-
static int
call_settings_changed (EelBackground *background)
{
@@ -319,61 +284,34 @@ call_settings_changed (EelBackground *background)
{
saved_settings_changed_callback (file, background);
}
- g_object_set_data (G_OBJECT (background), "desktop_mateconf_notification_timeout", GUINT_TO_POINTER (0));
return FALSE;
}
static void
-desktop_background_destroyed_callback (EelBackground *background, void *georgeWBush)
+desktop_background_settings_notify_cb (GSettings *settings, gchar *key, gpointer data)
{
- guint notification_id;
- guint notification_timeout_id;
+ EelBackground *background;
- notification_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (background), "desktop_mateconf_notification"));
- mateconf_client_notify_remove (caja_mateconf_client, notification_id);
+ background = EEL_BACKGROUND (data);
- notification_timeout_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (background), "desktop_mateconf_notification_timeout"));
- if (notification_timeout_id != 0)
- {
- g_source_remove (notification_timeout_id);
- }
+ call_settings_changed (background);
}
static void
-desktop_background_mateconf_notify_cb (MateConfClient *client, guint notification_id, MateConfEntry *entry, gpointer data)
+desktop_background_destroyed_callback (EelBackground *background, void *georgeWBush)
{
- EelBackground *background;
- guint notification_timeout_id;
-
- background = EEL_BACKGROUND (data);
-
- notification_timeout_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (background), "desktop_mateconf_notification_timeout"));
-
- if (strcmp (entry->key, "/desktop/mate/background/stamp") == 0)
- {
- if (notification_timeout_id != 0)
- g_source_remove (notification_timeout_id);
-
- call_settings_changed (background);
- }
- else if (notification_timeout_id == 0)
- {
- notification_timeout_id = g_timeout_add (300, (GSourceFunc) call_settings_changed, background);
-
- g_object_set_data (G_OBJECT (background), "desktop_mateconf_notification_timeout", GUINT_TO_POINTER (notification_timeout_id));
- }
+ g_signal_handlers_disconnect_by_func(mate_background_preferences,
+ G_CALLBACK (desktop_background_settings_notify_cb),
+ background);
}
static void
-caja_file_background_receive_mateconf_changes (EelBackground *background)
+caja_file_background_receive_settings_changes (EelBackground *background)
{
- guint notification_id;
-
- notification_id = mateconf_client_notify_add (caja_mateconf_client,
- "/desktop/mate/background", desktop_background_mateconf_notify_cb, background,
- NULL, NULL);
-
- g_object_set_data (G_OBJECT (background), "desktop_mateconf_notification", GUINT_TO_POINTER (notification_id));
+ g_signal_connect (mate_background_preferences,
+ "changed",
+ G_CALLBACK (desktop_background_settings_notify_cb),
+ background);
g_signal_connect (background, "destroy",
G_CALLBACK (desktop_background_destroyed_callback), NULL);
@@ -418,7 +356,7 @@ background_changed_callback (EelBackground *background,
if (eel_background_is_desktop (background))
{
- eel_background_save_to_mateconf (background);
+ eel_background_save_to_settings (background);
}
else
{
@@ -575,11 +513,7 @@ background_reset_callback (EelBackground *background,
char *color;
char *image;
- if (eel_background_is_desktop (background))
- {
- caja_file_background_write_desktop_default_settings ();
- }
- else
+ if (!eel_background_is_desktop (background))
{
/* Block the other handler while we are writing metadata so it doesn't
* try to change the background.
diff --git a/libcaja-private/caja-global-preferences.c b/libcaja-private/caja-global-preferences.c
index 58afa365..f66dc95f 100644
--- a/libcaja-private/caja-global-preferences.c
+++ b/libcaja-private/caja-global-preferences.c
@@ -34,12 +34,6 @@
#include <eel/eel-string.h>
#include <glib/gi18n.h>
-/* Path for mate-vfs preferences */
-static const char *EXTRA_MONITOR_PATHS[] = {
- "/desktop/mate/lockdown",
- NULL
- };
-
/*
* Public functions
*/
@@ -90,15 +84,6 @@ caja_global_preferences_init (void)
caja_tree_sidebar_preferences = g_settings_new("org.mate.caja.sidebar-panels.tree");
caja_list_view_preferences = g_settings_new("org.mate.caja.list-view");
- mate_lockdown_preferences = g_settings_new("org.mate.desktop.lockdown");
-
- caja_mateconf_client = mateconf_client_get_default ();
-
- /* Add monitors for any other MateConf paths we have keys in */
- for (i=0; EXTRA_MONITOR_PATHS[i] != NULL; i++) {
- mateconf_client_add_dir (caja_mateconf_client,
- EXTRA_MONITOR_PATHS[i],
- MATECONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- }
+ mate_background_preferences = g_settings_new("org.mate.background");
+ mate_lockdown_preferences = g_settings_new("org.mate.lockdown");
}
diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h
index 6ef7f372..0430a016 100644
--- a/libcaja-private/caja-global-preferences.h
+++ b/libcaja-private/caja-global-preferences.h
@@ -27,7 +27,6 @@
#define CAJA_GLOBAL_PREFERENCES_H
#include <gio/gio.h>
-#include <mateconf/mateconf-client.h>
G_BEGIN_DECLS
@@ -221,10 +220,9 @@ GSettings *caja_tree_sidebar_preferences;
GSettings *caja_compact_view_preferences;
GSettings *caja_list_view_preferences;
+GSettings *mate_background_preferences;
GSettings *mate_lockdown_preferences;
-MateConfClient *caja_mateconf_client;
-
G_END_DECLS
#endif /* CAJA_GLOBAL_PREFERENCES_H */
diff --git a/libcaja-private/caja-metadata.h b/libcaja-private/caja-metadata.h
index ee9d22e4..02384c60 100644
--- a/libcaja-private/caja-metadata.h
+++ b/libcaja-private/caja-metadata.h
@@ -74,9 +74,6 @@
#define CAJA_METADATA_KEY_SCREEN "screen"
#define CAJA_METADATA_KEY_EMBLEMS "emblems"
-/* This is where desktop item metadata are stored in mateconf */
-#define CAJA_DESKTOP_METADATA_MATECONF_PATH "/apps/caja/desktop-metadata"
-
guint caja_metadata_get_id (const char *metadata);
#endif /* CAJA_METADATA_H */