2012-05-09 22:29:48 -04:00
|
|
|
/*
|
|
|
|
* preferences.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 James Booth <boothj5@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-05-09 22:37:24 -04:00
|
|
|
#include <stdlib.h>
|
2012-05-09 22:29:48 -04:00
|
|
|
#include <glib.h>
|
|
|
|
|
2012-05-10 04:55:55 -04:00
|
|
|
static GKeyFile *prefs;
|
2012-05-09 22:29:48 -04:00
|
|
|
|
|
|
|
void prefs_load(void)
|
|
|
|
{
|
2012-05-09 22:37:24 -04:00
|
|
|
GString *prefs_loc = g_string_new(getenv("HOME"));
|
|
|
|
g_string_append(prefs_loc, "/.profanity");
|
2012-05-09 22:29:48 -04:00
|
|
|
|
2012-05-10 04:55:55 -04:00
|
|
|
prefs = g_key_file_new();
|
|
|
|
g_key_file_load_from_file(prefs, prefs_loc->str, G_KEY_FILE_NONE, NULL);
|
2012-05-09 22:29:48 -04:00
|
|
|
|
|
|
|
// g_key_file_set_string(g_prefs, "settings", "somekey2", "someothervalue");
|
|
|
|
// gsize g_data_len;
|
|
|
|
// char *g_prefs_data = g_key_file_to_data(g_prefs, &g_data_len, NULL);
|
|
|
|
// g_file_set_contents("/home/james/.profanity", g_prefs_data, g_data_len, NULL);
|
|
|
|
}
|
2012-05-10 04:55:55 -04:00
|
|
|
|
|
|
|
gboolean prefs_get_beep(void)
|
|
|
|
{
|
|
|
|
return g_key_file_get_boolean(prefs, "ui", "beep", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void prefs_set_beep(gboolean value)
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(prefs, "ui", "beep", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean prefs_get_flash(void)
|
|
|
|
{
|
|
|
|
return g_key_file_get_boolean(prefs, "ui", "flash", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void prefs_set_flash(gboolean value)
|
|
|
|
{
|
|
|
|
g_key_file_set_boolean(prefs, "ui", "flash", value);
|
|
|
|
}
|