]> Pileus Git - grits/blobdiff - src/gis-prefs.c
Update copyright and email address
[grits] / src / gis-prefs.c
index 4a1ee0d885bf977858df7ef77a46cc21053ea014..e66be1a2117ffa448bf5d44c1d9c3f666b048f24 100644 (file)
@@ -1,32 +1,32 @@
 /*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
- * 
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ *
  * 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/>.
  */
 
+#include <config.h>
+
 #include <glib.h>
 #include "gis-marshal.h"
 #include "gis-prefs.h"
 
-
 enum {
        SIG_PREF_CHANGED,
        NUM_SIGNALS,
 };
 static guint signals[NUM_SIGNALS];
 
-
 /***********
  * Methods *
  ***********/
@@ -38,12 +38,12 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
                self->key_path = g_strdup(config);
        else
                self->key_path = g_build_filename(g_get_user_config_dir(),
-                               "gis", "config.ini", NULL);
+                               PACKAGE, "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 && defaults) {
-               g_debug("GisPrefs: new - Trying %s defaults", defaults);
+               g_debug("GisPrefs: new - Trying defaults");
                g_clear_error(&error);
                g_key_file_load_from_file(self->key_file, defaults,
                                G_KEY_FILE_KEEP_COMMENTS, &error);
@@ -57,8 +57,7 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
                g_free(tmp);
        }
        if (error) {
-               g_clear_error(&error);
-               g_warning("GisPrefs: new - Unable to load key file `%s': %s",
+               g_debug("GisPrefs: new - Unable to load key file `%s': %s",
                        self->key_path, error->message);
        }
        return self;
@@ -66,19 +65,21 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
 
 #define make_pref_type(name, c_type, g_type)                                         \
 c_type gis_prefs_get_##name##_v(GisPrefs *self,                                      \
-               const gchar *group, const gchar *key)                                \
+               const gchar *group, const gchar *key, GError **_error)               \
 {                                                                                    \
        GError *error = NULL;                                                        \
        c_type value = g_key_file_get_##name(self->key_file, group, key, &error);    \
        if (error && error->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND)                \
                g_warning("GisPrefs: get_value_##name - error getting key %s: %s\n", \
                                key, error->message);                                \
+       if (error && _error)                                                         \
+               *_error = error;                                                     \
        return value;                                                                \
 }                                                                                    \
-c_type gis_prefs_get_##name(GisPrefs *self, const gchar *key)                        \
+c_type gis_prefs_get_##name(GisPrefs *self, const gchar *key, GError **error)        \
 {                                                                                    \
        gchar **keys  = g_strsplit(key, "/", 2);                                     \
-       c_type value = gis_prefs_get_##name##_v(self, keys[0], keys[1]);             \
+       c_type value = gis_prefs_get_##name##_v(self, keys[0], keys[1], error);      \
        g_strfreev(keys);                                                            \
        return value;                                                                \
 }                                                                                    \
@@ -114,13 +115,6 @@ static void gis_prefs_init(GisPrefs *self)
        g_debug("GisPrefs: init");
        self->key_file = g_key_file_new();
 }
-static GObject *gis_prefs_constructor(GType gtype, guint n_properties,
-               GObjectConstructParam *properties)
-{
-       g_debug("GisPrefs: constructor");
-       GObjectClass *parent_class = G_OBJECT_CLASS(gis_prefs_parent_class);
-       return  parent_class->constructor(gtype, n_properties, properties);
-}
 static void gis_prefs_dispose(GObject *_self)
 {
        g_debug("GisPrefs: dispose");
@@ -139,18 +133,11 @@ static void gis_prefs_dispose(GObject *_self)
        }
        G_OBJECT_CLASS(gis_prefs_parent_class)->dispose(_self);
 }
-static void gis_prefs_finalize(GObject *_self)
-{
-       g_debug("GisPrefs: finalize");
-       G_OBJECT_CLASS(gis_prefs_parent_class)->finalize(_self);
-}
 static void gis_prefs_class_init(GisPrefsClass *klass)
 {
        g_debug("GisPrefs: class_init");
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-       gobject_class->constructor  = gis_prefs_constructor;
        gobject_class->dispose      = gis_prefs_dispose;
-       gobject_class->finalize     = gis_prefs_finalize;
        signals[SIG_PREF_CHANGED] = g_signal_new(
                        "pref-changed",
                        G_TYPE_FROM_CLASS(gobject_class),