summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-09-03 15:46:10 +0200
committerStefano Karapetsas <[email protected]>2012-09-03 15:46:10 +0200
commit060faa2203f81c7fd1ce719d4a5dcaff7813dadf (patch)
tree9efe3501ce41cb0699d853a98ccaf2ca6cdff6d1 /libmate-desktop
parentf2ce79172dea2db12a1d85f441990e8b56cae225 (diff)
downloadmate-desktop-060faa2203f81c7fd1ce719d4a5dcaff7813dadf.tar.bz2
mate-desktop-060faa2203f81c7fd1ce719d4a5dcaff7813dadf.tar.xz
migrate to gsettings
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/libmateui/mate-bg.h10
-rw-r--r--libmate-desktop/mate-bg.c149
-rw-r--r--libmate-desktop/mate-desktop-utils.c12
3 files changed, 56 insertions, 115 deletions
diff --git a/libmate-desktop/libmateui/mate-bg.h b/libmate-desktop/libmateui/mate-bg.h
index 42b0997..6b7539e 100644
--- a/libmate-desktop/libmateui/mate-bg.h
+++ b/libmate-desktop/libmateui/mate-bg.h
@@ -30,7 +30,7 @@
#endif
#include <gdk/gdk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <libmateui/mate-desktop-thumbnail.h>
#include <libmateui/mate-bg-crossfade.h>
@@ -45,7 +45,7 @@ extern "C" {
#define MATE_IS_BG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_BG))
#define MATE_BG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_BG, MateBGClass))
-#define MATE_BG_KEY_DIR "/desktop/mate/background"
+#define MATE_BG_SCHEMA "org.mate.background"
typedef struct _MateBG MateBG;
typedef struct _MateBGClass MateBGClass;
@@ -67,10 +67,8 @@ typedef enum {
GType mate_bg_get_type (void);
MateBG * mate_bg_new (void);
-void mate_bg_load_from_preferences (MateBG *bg,
- MateConfClient *client);
-void mate_bg_save_to_preferences (MateBG *bg,
- MateConfClient *client);
+void mate_bg_load_from_preferences (MateBG *bg);
+void mate_bg_save_to_preferences (MateBG *bg);
/* Setters */
void mate_bg_set_filename (MateBG *bg,
const char *filename);
diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c
index a46fc27..d2a373b 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -41,19 +41,19 @@ Author: Soren Sandmann <[email protected]>
#include <cairo.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmateui/mate-bg.h>
#include <libmateui/mate-bg-crossfade.h>
-#define BG_KEY_DRAW_BACKGROUND MATE_BG_KEY_DIR "/draw_background"
-#define BG_KEY_PRIMARY_COLOR MATE_BG_KEY_DIR "/primary_color"
-#define BG_KEY_SECONDARY_COLOR MATE_BG_KEY_DIR "/secondary_color"
-#define BG_KEY_COLOR_TYPE MATE_BG_KEY_DIR "/color_shading_type"
-#define BG_KEY_PICTURE_PLACEMENT MATE_BG_KEY_DIR "/picture_options"
-#define BG_KEY_PICTURE_OPACITY MATE_BG_KEY_DIR "/picture_opacity"
-#define BG_KEY_PICTURE_FILENAME MATE_BG_KEY_DIR "/picture_filename"
+#define BG_KEY_DRAW_BACKGROUND "draw-background"
+#define BG_KEY_PRIMARY_COLOR "primary-color"
+#define BG_KEY_SECONDARY_COLOR "secondary-color"
+#define BG_KEY_COLOR_TYPE "color-shading-type"
+#define BG_KEY_PICTURE_PLACEMENT "picture-options"
+#define BG_KEY_PICTURE_OPACITY "picture-opacity"
+#define BG_KEY_PICTURE_FILENAME "picture-filename"
/* We keep the large pixbufs around if the next update
in the slideshow is less than 60 seconds away */
@@ -221,59 +221,6 @@ color_to_string (const GdkColor *color)
color->blue >> 8);
}
-static MateConfEnumStringPair placement_lookup[] = {
- { MATE_BG_PLACEMENT_CENTERED, "centered" },
- { MATE_BG_PLACEMENT_FILL_SCREEN, "stretched" },
- { MATE_BG_PLACEMENT_SCALED, "scaled" },
- { MATE_BG_PLACEMENT_ZOOMED, "zoom" },
- { MATE_BG_PLACEMENT_TILED, "wallpaper" },
- { MATE_BG_PLACEMENT_SPANNED, "spanned" },
- { 0, NULL }
-};
-
-static MateConfEnumStringPair color_type_lookup[] = {
- { MATE_BG_COLOR_SOLID, "solid" },
- { MATE_BG_COLOR_H_GRADIENT, "horizontal-gradient" },
- { MATE_BG_COLOR_V_GRADIENT, "vertical-gradient" },
- { 0, NULL }
-};
-
-static void
-color_type_from_string (const char *string,
- MateBGColorType *color_type)
-{
- *color_type = MATE_BG_COLOR_SOLID;
-
- if (string) {
- mateconf_string_to_enum (color_type_lookup,
- string, (int *)color_type);
- }
-}
-
-static const char *
-color_type_to_string (MateBGColorType color_type)
-{
- return mateconf_enum_to_string (color_type_lookup, color_type);
-}
-
-static void
-placement_from_string (const char *string,
- MateBGPlacement *placement)
-{
- *placement = MATE_BG_PLACEMENT_ZOOMED;
-
- if (string) {
- mateconf_string_to_enum (placement_lookup,
- string, (int *)placement);
- }
-}
-
-static const char *
-placement_to_string (MateBGPlacement placement)
-{
- return mateconf_enum_to_string (placement_lookup, placement);
-}
-
static gboolean
do_changed (MateBG *bg)
{
@@ -343,21 +290,22 @@ queue_transitioned (MateBG *bg)
}
void
-mate_bg_load_from_preferences (MateBG *bg,
- MateConfClient *client)
+mate_bg_load_from_preferences (MateBG *bg)
{
char *tmp;
char *filename;
MateBGColorType ctype;
GdkColor c1, c2;
MateBGPlacement placement;
+ GSettings *settings;
g_return_if_fail (MATE_IS_BG (bg));
- g_return_if_fail (client != NULL);
+
+ settings = g_settings_new (MATE_BG_SCHEMA);
/* Filename */
filename = NULL;
- tmp = mateconf_client_get_string (client, BG_KEY_PICTURE_FILENAME, NULL);
+ tmp = g_settings_get_string(settings, BG_KEY_PICTURE_FILENAME);
if (tmp != NULL && *tmp != '\0') {
if (g_utf8_validate (tmp, -1, NULL) &&
g_file_test (tmp, G_FILE_TEST_EXISTS)) {
@@ -369,41 +317,32 @@ mate_bg_load_from_preferences (MateBG *bg,
/* Fall back to default background if filename was set
but no longer exists */
if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
- MateConfValue *default_value;
g_free (filename);
filename = NULL;
+
+ /* FIXME: default value? */
- default_value =
- mateconf_client_get_default_from_schema (client,
- BG_KEY_PICTURE_FILENAME,
- NULL);
- if (default_value != NULL) {
- filename = g_strdup (mateconf_value_get_string (default_value));
- mateconf_value_free (default_value);
- }
}
}
g_free (tmp);
/* Colors */
- tmp = mateconf_client_get_string (client, BG_KEY_PRIMARY_COLOR, NULL);
+ tmp = g_settings_get_string (settings, BG_KEY_PRIMARY_COLOR);
color_from_string (tmp, &c1);
g_free (tmp);
- tmp = mateconf_client_get_string (client, BG_KEY_SECONDARY_COLOR, NULL);
+ tmp = g_settings_get_string (settings, BG_KEY_SECONDARY_COLOR);
color_from_string (tmp, &c2);
g_free (tmp);
/* Color type */
- tmp = mateconf_client_get_string (client, BG_KEY_COLOR_TYPE, NULL);
- color_type_from_string (tmp, &ctype);
- g_free (tmp);
+ ctype = g_settings_get_enum (settings, BG_KEY_COLOR_TYPE);
/* Placement */
- tmp = mateconf_client_get_string (client, BG_KEY_PICTURE_PLACEMENT, NULL);
- placement_from_string (tmp, &placement);
- g_free (tmp);
+ placement = g_settings_get_enum (settings, BG_KEY_PICTURE_PLACEMENT);
+
+ g_object_unref (settings);
mate_bg_set_color (bg, ctype, &c1, &c2);
mate_bg_set_placement (bg, placement);
@@ -413,34 +352,38 @@ mate_bg_load_from_preferences (MateBG *bg,
}
void
-mate_bg_save_to_preferences (MateBG *bg,
- MateConfClient *client)
+mate_bg_save_to_preferences (MateBG *bg)
{
- const char *color_type;
- const char *placement;
- const gchar *filename;
- gchar *primary;
- gchar *secondary;
+ MateBGColorType color_type;
+ MateBGPlacement placement;
+ const gchar *filename;
+ gchar *primary;
+ gchar *secondary;
+ GSettings *settings;
+
+ settings = g_settings_new (MATE_BG_SCHEMA);
primary = color_to_string (&bg->primary);
secondary = color_to_string (&bg->secondary);
- color_type = color_type_to_string (bg->color_type);
+ color_type = bg->color_type;
- if (bg->filename) {
+ if (bg->filename) {
filename = bg->filename;
- placement = placement_to_string (bg->placement);
- }
- else {
- filename = "(none)";
- placement = "none";
- }
-
- mateconf_client_set_string (client, BG_KEY_PICTURE_FILENAME, filename, NULL);
- mateconf_client_set_string (client, BG_KEY_PRIMARY_COLOR, primary, NULL);
- mateconf_client_set_string (client, BG_KEY_SECONDARY_COLOR, secondary, NULL);
- mateconf_client_set_string (client, BG_KEY_COLOR_TYPE, color_type, NULL);
- mateconf_client_set_string (client, BG_KEY_PICTURE_PLACEMENT, placement, NULL);
+ placement = bg->placement;
+ }
+ else {
+ filename = "(none)";
+ placement = MATE_BG_PLACEMENT_ZOOMED;
+ }
+
+ g_settings_set_string (settings, BG_KEY_PICTURE_FILENAME, filename);
+ g_settings_set_string (settings, BG_KEY_PRIMARY_COLOR, primary);
+ g_settings_set_string (settings, BG_KEY_SECONDARY_COLOR, secondary);
+ g_settings_set_enum (settings, BG_KEY_COLOR_TYPE, color_type);
+ g_settings_set_enum (settings, BG_KEY_PICTURE_PLACEMENT, placement);
+
+ g_object_unref (settings);
g_free (primary);
g_free (secondary);
diff --git a/libmate-desktop/mate-desktop-utils.c b/libmate-desktop/mate-desktop-utils.c
index 003a37f..a0a6877 100644
--- a/libmate-desktop/mate-desktop-utils.c
+++ b/libmate-desktop/mate-desktop-utils.c
@@ -26,7 +26,7 @@
#include <config.h>
#include <glib.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
@@ -57,7 +57,7 @@ mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
int i, j;
char **term_argv = NULL;
int term_argc = 0;
- MateConfClient *client;
+ GSettings *settings;
gchar *terminal = NULL;
@@ -81,14 +81,13 @@ mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
*argc = i;
}
- client = mateconf_client_get_default ();
- terminal = mateconf_client_get_string (client, "/desktop/mate/applications/terminal/exec", NULL);
- g_object_unref (client);
+ settings = g_settings_new ("org.mate.applications-terminal");
+ terminal = g_settings_get_string (settings, "exec");
if (terminal) {
gchar *command_line;
gchar *exec_flag;
- exec_flag = mateconf_client_get_string (client, "/desktop/mate/applications/terminal/exec_arg", NULL);
+ exec_flag = g_settings_get_string (settings, "exec-arg");
if (exec_flag == NULL)
command_line = g_strdup (terminal);
@@ -105,6 +104,7 @@ mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
g_free (exec_flag);
g_free (terminal);
}
+ g_object_unref (settings);
if (term_argv == NULL) {
char *check;