summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-12-01 15:15:31 -0800
committerStefano Karapetsas <[email protected]>2012-12-01 15:15:31 -0800
commit72c09a319a2062a8e71c467b7461e0e9e71f9ad4 (patch)
tree7f77dab3cbec3c8efe10bb60fcf46cd7bb1c91c3 /libmate-desktop
parente93b5be6cda47dcd0afbc280f494b236d076444f (diff)
parent66994a9b25116e509512bdee0903d138f6ab802c (diff)
downloadmate-desktop-72c09a319a2062a8e71c467b7461e0e9e71f9ad4.tar.bz2
mate-desktop-72c09a319a2062a8e71c467b7461e0e9e71f9ad4.tar.xz
Merge pull request #44 from jasmineaura/develop
[mate-bg] add 2 new gsettings functions
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/libmateui/mate-bg.h8
-rw-r--r--libmate-desktop/mate-bg.c46
2 files changed, 44 insertions, 10 deletions
diff --git a/libmate-desktop/libmateui/mate-bg.h b/libmate-desktop/libmateui/mate-bg.h
index aa557a5..8fbc230 100644
--- a/libmate-desktop/libmateui/mate-bg.h
+++ b/libmate-desktop/libmateui/mate-bg.h
@@ -68,10 +68,16 @@ typedef enum {
GType mate_bg_get_type (void);
MateBG * mate_bg_new (void);
void mate_bg_load_from_preferences (MateBG *bg);
-void mate_bg_load_from_system_preferences (MateBG *bg);
+void mate_bg_load_from_system_preferences (MateBG *bg);
+void mate_bg_load_from_system_gsettings (MateBG *bg,
+ GSettings *settings,
+ gboolean reset_apply);
void mate_bg_load_from_gsettings (MateBG *bg,
GSettings *settings);
void mate_bg_save_to_preferences (MateBG *bg);
+void mate_bg_save_to_gsettings (MateBG *bg,
+ GSettings *settings);
+
/* 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 f6571d9..4b7ccf4 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -309,14 +309,30 @@ void
mate_bg_load_from_system_preferences (MateBG *bg)
{
GSettings *settings;
- gchar **keys;
- gchar **k;
/* FIXME: we need to bind system settings instead of user but
* that's currently impossible, not implemented yet.
* Hence, reset to system default values.
*/
settings = g_settings_new (MATE_BG_SCHEMA);
+
+ mate_bg_load_from_system_gsettings (bg, settings, FALSE);
+
+ g_object_unref (settings);
+}
+
+/* This function loads (and optionally resets to) default system settings */
+void
+mate_bg_load_from_system_gsettings (MateBG *bg,
+ GSettings *settings,
+ gboolean reset_apply)
+{
+ gchar **keys;
+ gchar **k;
+
+ g_return_if_fail (MATE_IS_BG (bg));
+ g_return_if_fail (G_IS_SETTINGS (settings));
+
g_settings_delay (settings);
keys = g_settings_list_keys (settings);
@@ -325,9 +341,13 @@ mate_bg_load_from_system_preferences (MateBG *bg)
}
g_strfreev (keys);
- mate_bg_load_from_gsettings (bg, settings);
- g_settings_revert (settings);
- g_object_unref (settings);
+ if (reset_apply) {
+ /* Apply changes atomically. */
+ g_settings_apply (settings);
+ } else {
+ mate_bg_load_from_gsettings (bg, settings);
+ g_settings_revert (settings);
+ }
}
void
@@ -397,16 +417,26 @@ mate_bg_load_from_gsettings (MateBG *bg,
void
mate_bg_save_to_preferences (MateBG *bg)
{
+ GSettings *settings;
+ settings = g_settings_new (MATE_BG_SCHEMA);
+
+ mate_bg_save_to_gsettings (bg, settings);
+ g_object_unref (settings);
+}
+
+void
+mate_bg_save_to_gsettings (MateBG *bg,
+ GSettings *settings)
+{
gchar *primary;
gchar *secondary;
- GSettings *settings;
g_return_if_fail (MATE_IS_BG (bg));
+ g_return_if_fail (G_IS_SETTINGS (settings));
primary = color_to_string (&bg->primary);
secondary = color_to_string (&bg->secondary);
- settings = g_settings_new (MATE_BG_SCHEMA);
g_settings_delay (settings);
g_settings_set_boolean (settings, BG_KEY_DRAW_BACKGROUND, bg->is_enabled);
@@ -419,8 +449,6 @@ mate_bg_save_to_preferences (MateBG *bg)
/* Apply changes atomically. */
g_settings_apply (settings);
- g_object_unref (settings);
-
g_free (primary);
g_free (secondary);
}