diff options
author | Jasmine Hassan <[email protected]> | 2012-12-01 23:44:53 +0200 |
---|---|---|
committer | Jasmine Hassan <[email protected]> | 2012-12-02 00:01:06 +0200 |
commit | 66994a9b25116e509512bdee0903d138f6ab802c (patch) | |
tree | 7f77dab3cbec3c8efe10bb60fcf46cd7bb1c91c3 /libmate-desktop/mate-bg.c | |
parent | e93b5be6cda47dcd0afbc280f494b236d076444f (diff) | |
download | mate-desktop-66994a9b25116e509512bdee0903d138f6ab802c.tar.bz2 mate-desktop-66994a9b25116e509512bdee0903d138f6ab802c.tar.xz |
[mate-bg] add 2 new gsettings functions
Because of the need to use now in Caja:
Add mate_bg_load_from_system_gsettings() and mate_bg_save_to_gsettings(),
making mate_bg_load_from_system_preferences() and mate_bg_save_to_preferences()
wrappers around them, respectively.
Both new funcs take GSettings argument, and the latter takes a boolean argument,
to optionally apply the reset-to-schema-defaults settings. This will be used for
desktop background reset-drop.
Diffstat (limited to 'libmate-desktop/mate-bg.c')
-rw-r--r-- | libmate-desktop/mate-bg.c | 46 |
1 files changed, 37 insertions, 9 deletions
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); } |