]> Pileus Git - grits/blobdiff - src/grits-prefs.c
libgis -> grits: Update functions/types/etc
[grits] / src / grits-prefs.c
index 4e1b06489ce1c0fcb89ba808b2f16d5a4d433ac1..80a1d49f472095f93e3828a555e40f06c46688a5 100644 (file)
  */
 
 /**
- * SECTION:gis-prefs
+ * SECTION:grits-prefs
  * @short_description: Persistent preference handing
  *
- * #GisPrefs is used to store and access preferences in grits. It is mostly a
+ * #GritsPrefs is used to store and access preferences in grits. It is mostly a
  * wrapper around a #GKeyFile. Preferences can be stored for the application
  * using grits, but may also be stored by grits itself. An example of this are
- * whether grits is in online or offline mode. Many #GisPlugin<!-- -->s also
+ * whether grits is in online or offline mode. Many #GritsPlugin<!-- -->s also
  * store preferences.
  *
  * There are two variants of preference functions. The normal variant takes
@@ -46,19 +46,19 @@ static guint signals[NUM_SIGNALS];
  * Methods *
  ***********/
 /**
- * gis_prefs_new:
+ * grits_prefs_new:
  * @config:   the path to the config file
  * @defaults: the path to the default config file
  *
  * Create a new preference object for the given @config. If the config does not
  * exist the @defaults file is loaded.
  *
- * Returns: the new #GisPrefs
+ * Returns: the new #GritsPrefs
  */
-GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
+GritsPrefs *grits_prefs_new(const gchar *config, const gchar *defaults)
 {
-       g_debug("GisPrefs: new - %s, %s", config, defaults);
-       GisPrefs *prefs = g_object_new(GIS_TYPE_PREFS, NULL);
+       g_debug("GritsPrefs: new - %s, %s", config, defaults);
+       GritsPrefs *prefs = g_object_new(GRITS_TYPE_PREFS, NULL);
        if (config)
                prefs->key_path = g_strdup(config);
        else
@@ -68,13 +68,13 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
        g_key_file_load_from_file(prefs->key_file, prefs->key_path,
                        G_KEY_FILE_KEEP_COMMENTS, &error);
        if (error && defaults) {
-               g_debug("GisPrefs: new - Trying defaults");
+               g_debug("GritsPrefs: new - Trying defaults");
                g_clear_error(&error);
                g_key_file_load_from_file(prefs->key_file, defaults,
                                G_KEY_FILE_KEEP_COMMENTS, &error);
        }
        if (error) {
-               g_debug("GisPrefs: new - Trying GIS defaults");
+               g_debug("GritsPrefs: new - Trying GRITS defaults");
                g_clear_error(&error);
                gchar *tmp = g_build_filename(PKGDATADIR, "defaults.ini", NULL);
                g_key_file_load_from_file(prefs->key_file, tmp,
@@ -82,36 +82,36 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults)
                g_free(tmp);
        }
        if (error) {
-               g_debug("GisPrefs: new - Unable to load key file `%s': %s",
+               g_debug("GritsPrefs: new - Unable to load key file `%s': %s",
                        prefs->key_path, error->message);
        }
-       g_debug("GisPrefs: new - using %s", prefs->key_path);
+       g_debug("GritsPrefs: new - using %s", prefs->key_path);
        return prefs;
 }
 
 #define make_pref_type(name, c_type, g_type)                                         \
-c_type gis_prefs_get_##name##_v(GisPrefs *prefs,                                     \
+c_type grits_prefs_get_##name##_v(GritsPrefs *prefs,                                 \
                const gchar *group, const gchar *key, GError **_error)               \
 {                                                                                    \
        GError *error = NULL;                                                        \
        c_type value = g_key_file_get_##name(prefs->key_file, group, key, &error);   \
        if (error && error->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND &&              \
                     error->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND)                  \
-               g_warning("GisPrefs: get_"#name" - error getting key %s: %s\n",      \
+               g_warning("GritsPrefs: get_"#name" - error getting key %s: %s\n",    \
                                key, error->message);                                \
        if (error && _error)                                                         \
                *_error = error;                                                     \
        return value;                                                                \
 }                                                                                    \
-c_type gis_prefs_get_##name(GisPrefs *prefs, const gchar *key, GError **error)       \
+c_type grits_prefs_get_##name(GritsPrefs *prefs, const gchar *key, GError **error)   \
 {                                                                                    \
        gchar **keys  = g_strsplit(key, "/", 2);                                     \
-       c_type value = gis_prefs_get_##name##_v(prefs, keys[0], keys[1], error);     \
+       c_type value = grits_prefs_get_##name##_v(prefs, keys[0], keys[1], error);   \
        g_strfreev(keys);                                                            \
        return value;                                                                \
 }                                                                                    \
                                                                                      \
-void gis_prefs_set_##name##_v(GisPrefs *prefs,                                       \
+void grits_prefs_set_##name##_v(GritsPrefs *prefs,                                   \
                const gchar *group, const gchar *key, const c_type value)            \
 {                                                                                    \
        g_key_file_set_##name(prefs->key_file, group, key, value);                   \
@@ -120,10 +120,10 @@ void gis_prefs_set_##name##_v(GisPrefs *prefs,
                        all, g_type, &value);                                        \
        g_free(all);                                                                 \
 }                                                                                    \
-void gis_prefs_set_##name(GisPrefs *prefs, const gchar *key, const c_type value)     \
+void grits_prefs_set_##name(GritsPrefs *prefs, const gchar *key, const c_type value) \
 {                                                                                    \
        gchar **keys = g_strsplit(key, "/", 2);                                      \
-       gis_prefs_set_##name##_v(prefs, keys[0], keys[1], value);                    \
+       grits_prefs_set_##name##_v(prefs, keys[0], keys[1], value);                  \
        g_strfreev(keys);                                                            \
 }                                                                                    \
 
@@ -136,16 +136,16 @@ make_pref_type(double,  gdouble,  G_TYPE_DOUBLE)
 /****************
  * GObject code *
  ****************/
-G_DEFINE_TYPE(GisPrefs, gis_prefs, G_TYPE_OBJECT);
-static void gis_prefs_init(GisPrefs *prefs)
+G_DEFINE_TYPE(GritsPrefs, grits_prefs, G_TYPE_OBJECT);
+static void grits_prefs_init(GritsPrefs *prefs)
 {
-       g_debug("GisPrefs: init");
+       g_debug("GritsPrefs: init");
        prefs->key_file = g_key_file_new();
 }
-static void gis_prefs_dispose(GObject *_prefs)
+static void grits_prefs_dispose(GObject *_prefs)
 {
-       g_debug("GisPrefs: dispose");
-       GisPrefs *prefs = GIS_PREFS(_prefs);
+       g_debug("GritsPrefs: dispose");
+       GritsPrefs *prefs = GRITS_PREFS(_prefs);
        if (prefs->key_file) {
                gsize length;
                gchar *dir = g_path_get_dirname(prefs->key_path);
@@ -158,16 +158,16 @@ static void gis_prefs_dispose(GObject *_prefs)
                g_free(data);
                prefs->key_file = NULL;
        }
-       G_OBJECT_CLASS(gis_prefs_parent_class)->dispose(_prefs);
+       G_OBJECT_CLASS(grits_prefs_parent_class)->dispose(_prefs);
 }
-static void gis_prefs_class_init(GisPrefsClass *klass)
+static void grits_prefs_class_init(GritsPrefsClass *klass)
 {
-       g_debug("GisPrefs: class_init");
+       g_debug("GritsPrefs: class_init");
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-       gobject_class->dispose = gis_prefs_dispose;
+       gobject_class->dispose = grits_prefs_dispose;
 
        /**
-        * GisPrefs::pref-changed:
+        * GritsPrefs::pref-changed:
         * @prefs: the preference store.
         * @key:   the key to the preference.
         * @type:  the type of the preference that changed.