diff options
author | Stefano Karapetsas <[email protected]> | 2012-09-06 14:14:59 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-09-06 14:14:59 +0200 |
commit | f426641aacea9d5f7683be776536bc6301c7baef (patch) | |
tree | d19911212091bfcadf2a976d219aca093ef0606f | |
parent | 465e6ae56a2a81cd346d573532dc4a39c16df225 (diff) | |
download | caja-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)
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | eel/eel-background.c | 6 | ||||
-rw-r--r-- | eel/eel-background.h | 2 | ||||
-rw-r--r-- | libcaja-private/Makefile.am | 2 | ||||
-rw-r--r-- | libcaja-private/caja-desktop-directory-file.c | 157 | ||||
-rw-r--r-- | libcaja-private/caja-desktop-directory-file.h | 10 | ||||
-rw-r--r-- | libcaja-private/caja-desktop-icon-file.c | 5 | ||||
-rw-r--r-- | libcaja-private/caja-desktop-metadata.c | 294 | ||||
-rw-r--r-- | libcaja-private/caja-desktop-metadata.h | 47 | ||||
-rw-r--r-- | libcaja-private/caja-directory-background.c | 130 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.c | 19 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.h | 4 | ||||
-rw-r--r-- | libcaja-private/caja-metadata.h | 3 | ||||
-rw-r--r-- | src/caja-convert-metadata.c | 121 | ||||
-rw-r--r-- | src/caja-emblem-sidebar.c | 9 |
15 files changed, 395 insertions, 416 deletions
diff --git a/configure.in b/configure.in index e7a68106..66575b65 100644 --- a/configure.in +++ b/configure.in @@ -426,7 +426,7 @@ AC_SUBST(LIBCAJA_EXTENSION_LIBS) dnl core caja PKG_CHECK_MODULES(GMODULE, gmodule-2.0, [GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""]) -CORE_MODULES="glib-2.0 $GMODULE_ADD mate-desktop-2.0 gthread-2.0 gio-2.0 mateconf-2.0 gio-unix-2.0 gail libxml-2.0 $EXTRA_CORE_MODULES gtk+-$GTK_API_VERSION" +CORE_MODULES="glib-2.0 $GMODULE_ADD mate-desktop-2.0 gthread-2.0 gio-2.0 gio-unix-2.0 gail libxml-2.0 $EXTRA_CORE_MODULES gtk+-$GTK_API_VERSION" CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES` $x_cflags" AC_SUBST(CORE_CFLAGS) CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $x_libs" diff --git a/eel/eel-background.c b/eel/eel-background.c index f43831e0..33803f58 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -1230,12 +1230,10 @@ eel_background_receive_dropped_color (EelBackground *background, } void -eel_background_save_to_mateconf (EelBackground *background) +eel_background_save_to_settings (EelBackground *background) { - MateConfClient *client = mateconf_client_get_default (); - if (background->details->bg) - mate_bg_save_to_preferences (background->details->bg, client); + mate_bg_save_to_preferences (background->details->bg); } void diff --git a/eel/eel-background.h b/eel/eel-background.h index 3e299a30..1604b537 100644 --- a/eel/eel-background.h +++ b/eel/eel-background.h @@ -118,7 +118,7 @@ void eel_background_receive_dropped_background_image (Eel /* Gets or creates a background so that it's attached to a widget. */ EelBackground * eel_get_widget_background (GtkWidget *widget); -void eel_background_save_to_mateconf (EelBackground *background); +void eel_background_save_to_settings (EelBackground *background); /* Set activity status of background. Inactive backgrounds are drawn in the theme's INSENSITIVE color. */ void eel_background_set_active (EelBackground *background, 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 */ diff --git a/src/caja-convert-metadata.c b/src/caja-convert-metadata.c index 57c2d234..faf44e87 100644 --- a/src/caja-convert-metadata.c +++ b/src/caja-convert-metadata.c @@ -31,99 +31,10 @@ #include <glib/gi18n.h> #include <string.h> #include <libxml/tree.h> -#include <mateconf/mateconf-client.h> #include <libcaja-private/caja-metadata.h> -#define CAJA_DESKTOP_METADATA_MATECONF_PATH "/apps/caja/desktop-metadata" - static gboolean quiet = FALSE; -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 + strlen ("metadata::"), NULL); - g_free (escaped_name); - - return res; -} - -static void -desktop_set_metadata_string (GFile *file, - const char *key, - const char *string) -{ - MateConfClient *client; - char *mateconf_key; - GFile *parent; - char *name; - - parent = g_file_get_parent (file); - if (parent == NULL) - { - name = g_strdup ("directory"); - } - else - { - g_object_unref (parent); - name = g_file_get_basename (file); - } - - client = mateconf_client_get_default (); - mateconf_key = get_metadata_mateconf_path (name, key); - - mateconf_client_set_string (client, mateconf_key, string, NULL); - - g_free (mateconf_key); - g_free (name); - g_object_unref (client); -} - -static void -desktop_set_metadata_stringv (GFile *file, - const char *key, - char **stringv) -{ - MateConfClient *client; - char *mateconf_key; - GSList *list; - int i; - GFile *parent; - char *name; - - parent = g_file_get_parent (file); - if (parent == NULL) - { - name = g_strdup ("directory"); - } - else - { - g_object_unref (parent); - name = g_file_get_basename (file); - } - - 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_free (name); - g_object_unref (client); -} static xmlNodePtr xml_get_children (xmlNodePtr parent) @@ -251,11 +162,7 @@ parse_xml_node (GFile *file, char **strv; GError *error; - info = NULL; - if (!g_file_has_uri_scheme (file, "x-caja-desktop")) - { - info = g_file_info_new (); - } + info = g_file_info_new (); for (attr = filenode->properties; attr != NULL; attr = attr->next) { @@ -271,16 +178,9 @@ parse_xml_node (GFile *file, property = xmlGetProp (filenode, attr->name); if (property) { - if (info) - { - g_file_info_set_attribute_string (info, - new_key, - property); - } - else - { - desktop_set_metadata_string (file, new_key, property); - } + g_file_info_set_attribute_string (info, + new_key, + property); xmlFree (property); } } @@ -314,16 +214,9 @@ parse_xml_node (GFile *file, { strv[i] = l->data; } - if (info) - { - g_file_info_set_attribute_stringv (info, - new_key, - strv); - } - else - { - desktop_set_metadata_stringv (file, new_key, strv); - } + g_file_info_set_attribute_stringv (info, + new_key, + strv); g_free (strv); g_list_foreach (keys, (GFunc)xmlFree, NULL); g_list_free (keys); diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index 57a8ab21..7c188a7d 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -43,7 +43,6 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <mateconf/mateconf-client.h> #include <libcaja-private/caja-icon-dnd.h> #include <libcaja-private/caja-emblem-utils.h> #include <libcaja-private/caja-file-utilities.h> @@ -54,7 +53,6 @@ struct CajaEmblemSidebarDetails { CajaWindowInfo *window; - MateConfClient *client; GtkWidget *emblems_table; GtkWidget *popup; GtkWidget *popup_remove; @@ -1040,8 +1038,6 @@ caja_emblem_sidebar_init (CajaEmblemSidebar *emblem_sidebar) emblem_sidebar->details = g_new0 (CajaEmblemSidebarDetails, 1); - emblem_sidebar->details->client = mateconf_client_get_default (); - create_popup_menu (emblem_sidebar); widget = caja_emblem_sidebar_create_container (emblem_sidebar); @@ -1065,11 +1061,6 @@ caja_emblem_sidebar_finalize (GObject *object) if (emblem_sidebar->details != NULL) { - if (emblem_sidebar->details->client != NULL) - { - g_object_unref (emblem_sidebar->details->client); - } - g_free (emblem_sidebar->details); } |