[gtranslator] Make GtrSettings inherit from GObject instead of GSettings.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Make GtrSettings inherit from GObject instead of GSettings.
- Date: Mon, 8 Nov 2010 09:23:58 +0000 (UTC)
commit f3f8cfae978716093f5474567e507b7e7cd6ae07
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Nov 6 23:10:50 2010 +0100
Make GtrSettings inherit from GObject instead of GSettings.
src/gtr-settings.c | 77 +++------------------------------------------------
src/gtr-settings.h | 20 ++++---------
2 files changed, 11 insertions(+), 86 deletions(-)
---
diff --git a/src/gtr-settings.c b/src/gtr-settings.c
index 6a253cf..cf27d5a 100644
--- a/src/gtr-settings.c
+++ b/src/gtr-settings.c
@@ -46,7 +46,7 @@ struct _GtrSettingsPrivate
gchar *old_scheme;
};
-G_DEFINE_TYPE (GtrSettings, gtr_settings, G_TYPE_SETTINGS)
+G_DEFINE_TYPE (GtrSettings, gtr_settings, G_TYPE_OBJECT)
static void
gtr_settings_finalize (GObject * object)
@@ -319,18 +319,10 @@ gtr_settings_init (GtrSettings * gs)
gs->priv = GTR_SETTINGS_GET_PRIVATE (gs);
gs->priv->old_scheme = NULL;
-}
-
-static void
-initialize (GtrSettings * gs)
-{
- GSettings *prefs;
- prefs = g_settings_get_child (G_SETTINGS (gs), "preferences");
- gs->priv->files = g_settings_get_child (prefs, "files");
- gs->priv->editor = g_settings_get_child (prefs, "editor");
- gs->priv->ui = g_settings_get_child (prefs, "ui");
- g_object_unref (prefs);
+ gs->priv->files = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ gs->priv->editor = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ gs->priv->ui = g_settings_new ("org.gnome.gtranslator.preferences.ui");
/* Load settings */
gs->priv->interface = g_settings_new ("org.gnome.desktop.interface");
@@ -383,14 +375,7 @@ gtr_settings_class_init (GtrSettingsClass * klass)
GSettings *
gtr_settings_new ()
{
- GtrSettings *settings;
-
- settings = g_object_new (GTR_TYPE_SETTINGS,
- "schema", "org.gnome.gtranslator", NULL);
-
- initialize (settings);
-
- return G_SETTINGS (settings);
+ return g_object_new (GTR_TYPE_SETTINGS, NULL);
}
gchar *
@@ -406,56 +391,4 @@ gtr_settings_get_system_font (GtrSettings * gs)
return system_font;
}
-GSList *
-gtr_settings_get_list (GSettings * settings, const gchar * key)
-{
- GSList *list = NULL;
- gchar **values;
- gsize i;
-
- g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
- g_return_val_if_fail (key != NULL, NULL);
-
- values = g_settings_get_strv (settings, key);
- i = 0;
-
- while (values[i] != NULL)
- {
- list = g_slist_prepend (list, values[i]);
- i++;
- }
-
- g_free (values);
-
- return g_slist_reverse (list);
-}
-
-void
-gtr_settings_set_list (GSettings * settings,
- const gchar * key, const GSList * list)
-{
- gchar **values = NULL;
- const GSList *l;
-
- g_return_if_fail (G_IS_SETTINGS (settings));
- g_return_if_fail (key != NULL);
-
- if (list != NULL)
- {
- gint i, len;
-
- len = g_slist_length ((GSList *) list);
- values = g_new (gchar *, len + 1);
-
- for (l = list, i = 0; l != NULL; l = g_slist_next (l), i++)
- {
- values[i] = l->data;
- }
- values[i] = NULL;
- }
-
- g_settings_set_strv (settings, key, (const gchar * const *) values);
- g_free (values);
-}
-
/* ex:ts=8:noet: */
diff --git a/src/gtr-settings.h b/src/gtr-settings.h
index d2b72a7..a4ccce4 100644
--- a/src/gtr-settings.h
+++ b/src/gtr-settings.h
@@ -45,29 +45,21 @@ typedef struct _GtrSettingsPrivate GtrSettingsPrivate;
struct _GtrSettings
{
- GSettings parent;
+ GObject parent;
- GtrSettingsPrivate *priv;
+ GtrSettingsPrivate *priv;
};
struct _GtrSettingsClass
{
- GSettingsClass parent_class;
+ GObjectClass parent_class;
};
-GType gtr_settings_get_type (void) G_GNUC_CONST;
+GType gtr_settings_get_type (void) G_GNUC_CONST;
-GSettings *gtr_settings_new (void);
+GSettings *gtr_settings_new (void);
-gchar *gtr_settings_get_system_font (GtrSettings *gs);
-
-/* Utility functions */
-GSList *gtr_settings_get_list (GSettings *settings,
- const gchar *key);
-
-void gtr_settings_set_list (GSettings *settings,
- const gchar *key,
- const GSList *list);
+gchar *gtr_settings_get_system_font (GtrSettings *gs);
/* key constants: IMPORTANT: keep them in the same order as the schema */
#define GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY "warn-if-contains-fuzzy"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]