2
* This file is part of GNAC - Gnome Audio Converter
4
* Copyright (C) 2007 - 2012 Gnac
6
* - DUPASQUIER Benoit <bdupasqu@src.gnome.org>
7
* - JOAQUIM David <djoaquim@src.gnome.org>
8
* - ROUX Alexandre <alexroux@src.gnome.org>
10
* GNAC is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 3 of the License, or
13
* (at your option) any later version.
15
* GNAC is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with GNAC; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor,
23
* Boston, MA 02110-1301 USA
26
#include "gnac-settings.h"
27
#include "libgnac-debug.h"
31
GSettings *settings_ui;
34
static gboolean gnac_settings_set(GSettings *settings,
39
gnac_settings_init(void)
41
settings = g_settings_new(GNAC_SCHEMA);
42
settings_ui = g_settings_new(GNAC_SCHEMA_UI);
47
gnac_settings_bind(const gchar *key,
50
g_settings_bind(settings, key, object, "active", G_SETTINGS_BIND_DEFAULT);
55
gnac_settings_ui_bind(const gchar *key,
58
g_settings_bind(settings_ui, key, object, "active", G_SETTINGS_BIND_DEFAULT);
63
gnac_settings_get_boolean(const gchar *key)
65
return g_settings_get_boolean(settings, key);
70
gnac_settings_ui_get_boolean(const gchar *key)
72
return g_settings_get_boolean(settings_ui, key);
77
gnac_settings_set_boolean(const gchar *key,
80
return gnac_settings_set(settings, key, g_variant_new_boolean(value));
85
gnac_settings_ui_set_boolean(const gchar *key,
88
return gnac_settings_set(settings_ui, key, g_variant_new_boolean(value));
93
gnac_settings_get_int(const gchar *key)
95
return g_settings_get_int(settings, key);
100
gnac_settings_set_int(const gchar *key,
103
return gnac_settings_set(settings, key, g_variant_new_int32(value));
108
gnac_settings_get_string(const gchar *key)
110
return g_settings_get_string(settings, key);
115
gnac_settings_set_string(const gchar *key,
118
if (!value) return FALSE;
119
return gnac_settings_set(settings, key, g_variant_new_string(value));
124
gnac_settings_set(GSettings *settings,
128
gchar *val_str = g_variant_print(value, FALSE);
129
gboolean ret = g_settings_set_value(settings, key, value);
132
libgnac_debug("Failed to set key \"%s\" to \"%s\"", key, val_str);
134
libgnac_debug("Key \"%s\" set to \"%s\"", key, val_str);