/*
* Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
- *
+ *
* This program 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.
- *
+ *
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***********
* Methods *
***********/
-GisPrefs *gis_prefs_new(const gchar *prog)
+GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
{
- g_debug("GisPrefs: new - %s", prog);
+ g_debug("GisPrefs: new - %s, %s", config, defaults);
GisPrefs *self = g_object_new(GIS_TYPE_PREFS, NULL);
- self->key_path = g_build_filename(g_get_user_config_dir(),
- prog, "config.ini", NULL);
+ if (config)
+ self->key_path = g_strdup(config);
+ else
+ self->key_path = g_build_filename(g_get_user_config_dir(),
+ "gis", "config.ini", NULL);
GError *error = NULL;
g_key_file_load_from_file(self->key_file, self->key_path,
G_KEY_FILE_KEEP_COMMENTS, &error);
- if (error) {
- g_debug("GisPrefs: new - Trying %s defaults", prog);
+ if (error && defaults) {
+ g_debug("GisPrefs: new - Trying %s defaults", defaults);
g_clear_error(&error);
- gchar *tmp = g_build_filename(DATADIR, prog, "defaults.ini", NULL);
- g_key_file_load_from_file(self->key_file, tmp,
+ g_key_file_load_from_file(self->key_file, defaults,
G_KEY_FILE_KEEP_COMMENTS, &error);
- g_free(tmp);
}
if (error) {
g_debug("GisPrefs: new - Trying GIS defaults");
g_clear_error(&error);
- gchar *tmp = g_build_filename(DATADIR, "gis", "defaults.ini", NULL);
+ gchar *tmp = g_build_filename(PKGDATADIR, "defaults.ini", NULL);
g_key_file_load_from_file(self->key_file, tmp,
G_KEY_FILE_KEEP_COMMENTS, &error);
g_free(tmp);
static GObject *gis_prefs_constructor(GType gtype, guint n_properties,
GObjectConstructParam *properties)
{
- g_debug("gis_prefs: constructor");
+ g_debug("GisPrefs: constructor");
GObjectClass *parent_class = G_OBJECT_CLASS(gis_prefs_parent_class);
return parent_class->constructor(gtype, n_properties, properties);
}