#include "debug.h"
+#include "translation.h"
#include "tilda-config.h"
-GHashTable *config_defaults;
-GKeyFile *config_userprefs;
+GHashTable *config_defaults = NULL;
+GKeyFile *config_userprefs = NULL;
/*
* TODO:
gboolean
tilda_config_init (const gchar *filename)
{
+ GError *error = NULL;
+
/* Create the hashtable */
config_defaults = g_hash_table_new (g_str_hash, g_str_equal);
/* Create the key file */
config_userprefs = g_key_file_new ();
- /* TODO: load from a file! */
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+ {
+ g_warning (_("No config file found, using defaults\n"));
+ return TRUE;
+ }
+
+ if (!g_key_file_load_from_file (config_userprefs, filename, G_KEY_FILE_NONE, &error))
+ {
+ g_warning (_("Error reading from config file: %s\n"), error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* Everything went ok */
return TRUE;
}