--- /dev/null
+<schemalist>
+
+
+ <schema id="org.gnome.glabels-3" path="/apps/glabels-3/" gettext-domain="@GETTEXT_PACKAGE@">
+ <child name="ui" schema="org.gnome.glabels.ui"/>
+ <child name="locale" schema="org.gnome.glabels.locale"/>
+ <child name="objects" schema="org.gnome.glabels.objects"/>
+ <child name="history" schema="org.gnome.glabels.history"/>
+ </schema>
+
+
+ <schema id="org.gnome.glabels-3.ui" path="/apps/glabels-3/ui/" gettext-domain="@GETTEXT_PACKAGE@">
+
+ <key name="main-toolbar-visible" type="b">
+ <default>true</default>
+ <_summary>Show/hide main toolbar.</_summary>
+ <_description>Controls visibility of main toolbar.</_description>
+ </key>
+
+ <key name="drawing-toolbar-visible" type="b">
+ <default>true</default>
+ <_summary>Show/hide drawing toolbar.</_summary>
+ <_description>Controls visibility of drawing toolbar.</_description>
+ </key>
+
+ <key name="property-toolbar-visible" type="b">
+ <default>true</default>
+ <_summary>Show/hide property toolbar.</_summary>
+ <_description>Controls visibility of property toolbar.</_description>
+ </key>
+
+ <key name="grid-visible" type="b">
+ <default>false</default>
+ <_summary>Show/hide grid.</_summary>
+ <_description>Controls visibility of grid.</_description>
+ </key>
+
+ <key name="markup-visible" type="b">
+ <default>true</default>
+ <_summary>Show/hide markup.</_summary>
+ <_description>Controls visibility of markup lines.</_description>
+ </key>
+
+ <key name="max-recents" type="i">
+ <default>-1</default>
+ <_summary>Maximum recent files.</_summary>
+ <_description>Controls maximum number of recent files tracked.</_description>
+ </key>
+
+ </schema>
+
+
+ <schema id="org.gnome.glabels-3.locale" path="/apps/glabels-3/locale/" gettext-domain="@GETTEXT_PACKAGE@">
+
+ <key name="units" type="s">
+ <choices>
+ <choice value=""/>
+ <choice value="pt"/>
+ <choice value="in"/>
+ <choice value="mm"/>
+ </choices>
+ <default>''</default>
+ <_summary>Units.</_summary>
+ <_description>The default unit of measurement.</_description>
+ </key>
+
+ <key name="default-page-size" type="s">
+ <choices>
+ <choice value=""/>
+ <choice value="A4"/>
+ <choice value="US-Letter"/>
+ </choices>
+ <default>''</default>
+ <_summary>Default page size.</_summary>
+ <_description>The prefered page size when searching templates.</_description>
+ </key>
+
+ </schema>
+
+
+ <schema id="org.gnome.glabels-3.objects" path="/apps/glabels-3/objects/" gettext-domain="@GETTEXT_PACKAGE@">
+ <key name="default-font-family" type="s">
+ <default>'Sans'</default>
+ <_summary>Default font family.</_summary>
+ <_description>The default font family for new text objects.</_description>
+ </key>
+
+ <key name="default-font-size" type="d">
+ <range min="0.01" max="250"/>
+ <default>12</default>
+ <_summary>Default font size.</_summary>
+ <_description>The default font size for new text objects.</_description>
+ </key>
+
+ <key name="default-font-weight" type="s">
+ <choices>
+ <choice value="Regular"/>
+ <choice value="Bold"/>
+ </choices>
+ <default>'Regular'</default>
+ <_summary>Default font weight.</_summary>
+ <_description>The default font weight for new text objects.</_description>
+ </key>
+
+ <key name="default-font-italic-flag" type="b">
+ <default>false</default>
+ <_summary>Default font italic flag.</_summary>
+ <_description>The default font italic state for new text objects.</_description>
+ </key>
+
+ <key name="default-text-color" type="u">
+ <default>0x000000ff</default>
+ <_summary>Default text color.</_summary>
+ <_description>The default color of text for new text objects (0xRRGGBBAA).</_description>
+ </key>
+
+ <key name="default-text-alignment" type="s">
+ <choices>
+ <choice value="Left"/>
+ <choice value="Center"/>
+ <choice value="Right"/>
+ </choices>
+ <default>'Left'</default>
+ <_summary>Default text alignment.</_summary>
+ <_description>The default text alignment for new text objects.</_description>
+ </key>
+
+ <key name="default-text-line-spacing" type="d">
+ <range min="0.1" max="5"/>
+ <default>1.0</default>
+ <_summary>Default text line spacing.</_summary>
+ <_description>The default line spacing for new text objects.</_description>
+ </key>
+
+ <key name="default-line-width" type="d">
+ <range min="0.25" max="10"/>
+ <default>1.0</default>
+ <_summary>Default line width.</_summary>
+ <_description>The default line width for new objects.</_description>
+ </key>
+
+ <key name="default-line-color" type="u">
+ <default>0x000000ff</default>
+ <_summary>Default line color.</_summary>
+ <_description>The default line color new objects (0xRRGGBBAA).</_description>
+ </key>
+
+ <key name="default-fill-color" type="u">
+ <default>0x00ff00ff</default>
+ <_summary>Default fill color.</_summary>
+ <_description>The default fill color new objects (0xRRGGBBAA).</_description>
+ </key>
+
+ </schema>
+
+
+ <schema id="org.gnome.glabels-3.history" path="/apps/glabels-3/history/" gettext-domain="@GETTEXT_PACKAGE@">
+
+ <key name="recent-templates" type="as">
+ <default>[]</default>
+ <_summary>Recent templates.</_summary>
+ <_description>Recently used templates.</_description>
+ </key>
+
+ <key name="recent-fonts" type="as">
+ <default>[]</default>
+ <_summary>Recent fonts.</_summary>
+ <_description>Recently used font families.</_description>
+ </key>
+
+ <key name="recent-colors" type="au">
+ <default>[]</default>
+ <_summary>Recent colors.</_summary>
+ <_description>Recently created custom colors.</_description>
+ </key>
+
+ </schema>
+
+
+</schemalist>
#include "color-history-model.h"
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include "marshal.h"
-#define BASE_KEY "/apps/glabels"
-#define RECENT_COLORS_KEY BASE_KEY "/recent-colors"
-
-
/*========================================================*/
/* Private types. */
/*========================================================*/
-/** GL_COLOR_HISTORY_MODEL Private fields */
struct _glColorHistoryModelPrivate {
- GConfClient *gconf_client;
+ GSettings *history;
guint max_n;
};
enum {
- CHANGED,
- LAST_SIGNAL
+ CHANGED,
+ LAST_SIGNAL
};
/* Private function prototypes. */
/*========================================================*/
-static void gl_color_history_model_finalize (GObject *object);
+static void gl_color_history_model_finalize (GObject *object);
-static void conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glColorHistoryModel *this);
+static void history_changed_cb (glColorHistoryModel *this);
-static GSList *get_color_list (glColorHistoryModel *this);
+static guint *get_color_array (glColorHistoryModel *this,
+ guint *n_elements);
+static void set_color_array (glColorHistoryModel *this,
+ guint *array,
+ guint n_elements);
/*****************************************************************************/
gobject_class->finalize = gl_color_history_model_finalize;
- signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (glColorHistoryModelClass, changed),
- NULL, NULL,
- gl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glColorHistoryModelClass, changed),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
{
this->priv = g_new0 (glColorHistoryModelPrivate, 1);
- this->priv->gconf_client = gconf_client_get_default ();
+ this->priv->history = g_settings_new ("org.gnome.glabels-3.history");
- g_return_if_fail (this->priv->gconf_client != NULL);
+ g_return_if_fail (this->priv->history != NULL);
- gconf_client_add_dir (this->priv->gconf_client,
- BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- gconf_client_notify_add (this->priv->gconf_client,
- RECENT_COLORS_KEY,
- (GConfClientNotifyFunc)conf_notify_cb, this,
- NULL, NULL);
+ g_signal_connect_swapped (G_OBJECT (this->priv->history),
+ "changed::recent-colors",
+ G_CALLBACK (history_changed_cb), this);
}
g_return_if_fail (object && IS_GL_COLOR_HISTORY_MODEL (object));
this = GL_COLOR_HISTORY_MODEL (object);
- g_object_unref (G_OBJECT(this->priv->gconf_client));
+ g_object_unref (G_OBJECT(this->priv->history));
g_free (this->priv);
G_OBJECT_CLASS (gl_color_history_model_parent_class)->finalize (object);
gl_color_history_model_add_color (glColorHistoryModel *this,
guint color)
{
- GSList *list = NULL;
- GSList *old_list;
- GSList *p;
-
- /*
- * Start new list with this color.
- */
- list = g_slist_append (list, GINT_TO_POINTER (color));
-
- /*
- * Transfer old list to new list, ignoring any duplicate of this color
- */
- old_list = get_color_list (this);
- for ( p = old_list; p; p=p->next )
- {
- if ( color != (guint)GPOINTER_TO_INT (p->data) )
- {
- list = g_slist_append (list, p->data);
- }
- }
- g_slist_free (old_list);
+ guint *old;
+ guint *new;
+ guint i, n;
+
+ old = get_color_array (this, &n);
+
+ new = g_new0 (guint, this->priv->max_n);
- /*
- * Truncate list to maximum size
- */
- while (g_slist_length (list) > this->priv->max_n)
+ new[0] = color;
+
+ for ( i = 0; (i < (this->priv->max_n-1)) && (i < n); i++ )
{
- p = g_slist_last (list);
- list = g_slist_remove_link (list, p);
- g_slist_free_1 (p);
+ new[i+1] = old[i];
}
- /*
- * Update conf
- */
- gconf_client_set_list (this->priv->gconf_client,
- RECENT_COLORS_KEY,
- GCONF_VALUE_INT,
- list,
- NULL);
+ set_color_array (this, new, i+1);
+
+ g_free (old);
+ g_free (new);
}
/*****************************************************************************/
-/* GConf notify callback. */
+/* History changed callback. */
/*****************************************************************************/
static void
-conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glColorHistoryModel *this)
+history_changed_cb (glColorHistoryModel *this)
{
g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
}
/*****************************************************************************/
/* Get list of colors. */
/*****************************************************************************/
-static GSList *
-get_color_list (glColorHistoryModel *this)
+static guint *
+get_color_array (glColorHistoryModel *this,
+ guint *n_elements)
{
- GSList *list;
-
- /*
- * Get color list.
- */
- list = gconf_client_get_list (this->priv->gconf_client,
- RECENT_COLORS_KEY,
- GCONF_VALUE_INT,
- NULL);
- return list;
+ GVariant *value;
+ GVariant *child_value;
+ gsize i;
+ guint *array;
+
+ value = g_settings_get_value (this->priv->history, "recent-colors");
+ *n_elements = g_variant_n_children (value);
+
+ array = g_new0 (guint, *n_elements);
+
+ for ( i = 0; i < *n_elements; i++ )
+ {
+ child_value = g_variant_get_child_value (value, i);
+ array[i] = g_variant_get_uint32 (child_value);
+ g_variant_unref (child_value);
+ }
+
+ g_variant_unref (value);
+
+ return array;
+}
+
+
+/*****************************************************************************/
+/* Set list of colors. */
+/*****************************************************************************/
+static void
+set_color_array (glColorHistoryModel *this,
+ guint *array,
+ guint n_elements)
+{
+ GVariant *value;
+ GVariant **child_values;
+ gsize i;
+
+ child_values = g_new (GVariant *, n_elements);
+
+ for ( i = 0; i < n_elements; i++ )
+ {
+ child_values[i] = g_variant_new_uint32 (array[i]);
+ }
+
+ value = g_variant_new_array (G_VARIANT_TYPE_UINT32, child_values, n_elements);
+
+ g_settings_set_value (this->priv->history, "recent-colors", value);
+
+ g_free (child_values);
}
gl_color_history_model_get_color (glColorHistoryModel *this,
guint i)
{
+ guint *array;
guint color = 0;
- GSList *list;
- GSList *p;
+ guint n;
- list = get_color_list (this);
- p = g_slist_nth (list, i);
- if (p)
+ array = get_color_array (this, &n);
+ if ( array && (i < n) )
{
- color = GPOINTER_TO_INT (p->data);
+ color = array[i];
}
- g_slist_free (list);
+ g_free (array);
return color;
}
#include "font-history-model.h"
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include <libglabels.h>
#include "font-util.h"
#include "marshal.h"
-#define BASE_KEY "/apps/glabels"
-#define RECENT_FONTS_KEY BASE_KEY "/recent-fonts"
-
-
/*========================================================*/
/* Private types. */
/*========================================================*/
-/** GL_FONT_HISTORY_MODEL Private fields */
struct _glFontHistoryModelPrivate {
- GConfClient *gconf_client;
+ GSettings *history;
guint max_n;
};
enum {
- CHANGED,
- LAST_SIGNAL
+ CHANGED,
+ LAST_SIGNAL
};
static void gl_font_history_model_finalize (GObject *object);
-static void conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glFontHistoryModel *this);
+static void history_changed_cb (glFontHistoryModel *this);
/*****************************************************************************/
gobject_class->finalize = gl_font_history_model_finalize;
- signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (glFontHistoryModelClass, changed),
- NULL, NULL,
- gl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glFontHistoryModelClass, changed),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
{
this->priv = g_new0 (glFontHistoryModelPrivate, 1);
- this->priv->gconf_client = gconf_client_get_default ();
-
- g_return_if_fail (this->priv->gconf_client != NULL);
+ this->priv->history = g_settings_new ("org.gnome.glabels-3.history");
- gconf_client_add_dir (this->priv->gconf_client,
- BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ g_return_if_fail (this->priv->history != NULL);
- gconf_client_notify_add (this->priv->gconf_client,
- RECENT_FONTS_KEY,
- (GConfClientNotifyFunc)conf_notify_cb, this,
- NULL, NULL);
+ g_signal_connect_swapped (G_OBJECT (this->priv->history),
+ "changed::recent-fonts",
+ G_CALLBACK (history_changed_cb), this);
}
g_return_if_fail (object && IS_GL_FONT_HISTORY_MODEL (object));
this = GL_FONT_HISTORY_MODEL (object);
- g_object_unref (G_OBJECT(this->priv->gconf_client));
+ g_object_unref (G_OBJECT(this->priv->history));
g_free (this->priv);
G_OBJECT_CLASS (gl_font_history_model_parent_class)->finalize (object);
gl_font_history_model_add_family (glFontHistoryModel *this,
const gchar *family)
{
- GSList *list = NULL;
- GList *old_list;
- GList *p;
- GSList *ps;
+ gchar **old;
+ gchar **new;
+ gint i, j;
- /*
- * Start new list with this family.
- */
- list = g_slist_append (list, (gchar *)family);
+ old = g_settings_get_strv (this->priv->history, "recent-fonts");
+
+ new = g_new0 (gchar *, this->priv->max_n+1);
- /*
- * Transfer old list to new list, ignoring any duplicate of this family
- */
- old_list = gl_font_history_model_get_family_list (this);
- for ( p = old_list; p; p=p->next )
+ /* Put in first slot. */
+ new[0] = g_strdup (family);
+
+ /* Push everthing else down, pruning any duplicate found. */
+ for ( i = 0, j = 1; (j < (this->priv->max_n-1)) && old[i]; i++ )
{
- if ( lgl_str_utf8_casecmp (family, p->data) )
- {
- list = g_slist_append (list, p->data);
- }
- else
+ if ( lgl_str_utf8_casecmp (family, old[i]) != 0 )
{
- g_free (p->data);
+ new[j++] = g_strdup (old[i]);
}
}
- g_list_free (old_list);
- /*
- * Truncate list to maximum size
- */
- while (g_slist_length (list) > this->priv->max_n)
- {
- ps = g_slist_last (list);
- list = g_slist_remove_link (list, ps);
- g_slist_free_1 (ps);
- }
+ g_settings_set_strv (this->priv->history, "recent-fonts",
+ (const gchar * const *)new);
- /*
- * Update conf
- */
- gconf_client_set_list (this->priv->gconf_client,
- RECENT_FONTS_KEY,
- GCONF_VALUE_STRING,
- list,
- NULL);
+ g_strfreev (old);
+ g_strfreev (new);
}
/*****************************************************************************/
-/* GConf notify callback. */
+/* History changed callback. */
/*****************************************************************************/
static void
-conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glFontHistoryModel *this)
+history_changed_cb (glFontHistoryModel *this)
{
g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
}
GList *
gl_font_history_model_get_family_list (glFontHistoryModel *this)
{
+ gchar **strv;
GList *list = NULL;
- GSList *tmp_list;
- GSList *p;
+ gint i;
- /*
- * Get family list.
- */
- tmp_list = gconf_client_get_list (this->priv->gconf_client,
- RECENT_FONTS_KEY,
- GCONF_VALUE_STRING,
- NULL);
+ strv = g_settings_get_strv (this->priv->history, "recent-fonts");
/*
- * Proof read family list; transfer storage to new list.
+ * Proof read name list; transfer storage to new list.
*/
- for (p=tmp_list; p != NULL; p=p->next)
+ for ( i = 0; strv[i]; i++ )
{
- if ( gl_font_util_is_family_installed (p->data) )
- {
- list = g_list_append (list, p->data);
- }
- else
+ if ( gl_font_util_is_family_installed (strv[i]) )
{
- g_free (p->data);
+ list = g_list_append (list, g_strdup (strv[i]));
}
}
- g_slist_free (tmp_list);
+ g_strfreev (strv);
return list;
}
#include "prefs-model.h"
-#include <glib.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <string.h>
-#include <gconf/gconf-client.h>
#include <libglabels.h>
#include "marshal.h"
/* Private macros and constants. */
/*========================================================*/
-/* GConf keys */
-#define BASE_KEY "/apps/glabels"
-
-#define PREF_UNITS "/units"
-#define PREF_DEFAULT_PAGE_SIZE "/default-page-size"
-
-#define PREF_DEFAULT_FONT_FAMILY "/default-font-family"
-#define PREF_DEFAULT_FONT_SIZE "/default-font-size"
-#define PREF_DEFAULT_FONT_WEIGHT "/default-font-weight"
-#define PREF_DEFAULT_FONT_ITALIC_FLAG "/default-font-italic-flag"
-#define PREF_DEFAULT_TEXT_COLOR "/default-text-color"
-#define PREF_DEFAULT_TEXT_ALIGNMENT "/default-text-alignment"
-#define PREF_DEFAULT_TEXT_LINE_SPACING "/default-text-line-spacing"
-
-#define PREF_DEFAULT_LINE_WIDTH "/default-line-width"
-#define PREF_DEFAULT_LINE_COLOR "/default-line-color"
-
-#define PREF_DEFAULT_FILL_COLOR "/default-fill-color"
-
-#define PREF_MAIN_TOOLBAR_VISIBLE "/main-toolbar-visible"
-
-#define PREF_DRAWING_TOOLBAR_VISIBLE "/drawing-toolbar-visible"
-
-#define PREF_PROPERTY_TOOLBAR_VISIBLE "/property-toolbar-visible"
-
-#define PREF_GRID_VISIBLE "/grid-visible"
-#define PREF_MARKUP_VISIBLE "/markup-visible"
-
-#define PREF_MAX_RECENTS "/max-recents"
-
-
/* Default values */
#define DEFAULT_UNITS_STRING_US lgl_units_get_id (LGL_UNITS_INCH)
#define DEFAULT_PAGE_SIZE_US "US-Letter"
#define DEFAULT_UNITS_STRING_METRIC lgl_units_get_id (LGL_UNITS_MM)
#define DEFAULT_PAGE_SIZE_METRIC "A4"
-#define DEFAULT_FONT_FAMILY "Sans"
-#define DEFAULT_FONT_SIZE 14.0
-#define DEFAULT_FONT_WEIGHT_STRING gl_str_util_weight_to_string (PANGO_WEIGHT_NORMAL)
-#define DEFAULT_FONT_ITALIC_FLAG FALSE
-#define DEFAULT_TEXT_ALIGN_STRING gl_str_util_align_to_string (PANGO_ALIGN_LEFT)
-#define DEFAULT_TEXT_COLOR GL_COLOR (0,0,0)
-#define DEFAULT_TEXT_LINE_SPACING 1.0
-
-#define DEFAULT_LINE_WIDTH 1.0
-#define DEFAULT_LINE_COLOR GL_COLOR_A (0, 0, 0, 255)
-
-#define DEFAULT_FILL_COLOR GL_COLOR_A (0, 255, 0, 255)
-
/*========================================================*/
/* Private types. */
struct _glPrefsModelPrivate {
- GConfClient *gconf_client;
+ GSettings *locale;
+ GSettings *objects;
+ GSettings *ui;
};
enum {
- CHANGED,
- LAST_SIGNAL
+ CHANGED,
+ LAST_SIGNAL
};
static void gl_prefs_model_finalize (GObject *object);
-static void notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glPrefsModel *prefs_model);
-
-static gchar *get_string (GConfClient *client,
- const gchar *key,
- const gchar *def);
-
-static gboolean get_bool (GConfClient *client,
- const gchar *key,
- gboolean def);
-
-static gint get_int (GConfClient *client,
- const gchar *key,
- gint def);
-
-static gdouble get_float (GConfClient *client,
- const gchar *key,
- gdouble def);
+static void gsettings_changed_cb (glPrefsModel *prefs_model);
/*****************************************************************************/
static void
gl_prefs_model_class_init (glPrefsModelClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
- gl_debug (DEBUG_PREFS, "START");
+ gl_debug (DEBUG_PREFS, "START");
- gl_prefs_model_parent_class = g_type_class_peek_parent (class);
+ gl_prefs_model_parent_class = g_type_class_peek_parent (class);
- object_class->finalize = gl_prefs_model_finalize;
+ object_class->finalize = gl_prefs_model_finalize;
- signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (glPrefsModelClass, changed),
- NULL, NULL,
- gl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ signals[CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glPrefsModelClass, changed),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
- gl_debug (DEBUG_PREFS, "END");
+ gl_debug (DEBUG_PREFS, "END");
}
static void
gl_prefs_model_init (glPrefsModel *this)
{
- gl_debug (DEBUG_PREFS, "START");
+ gl_debug (DEBUG_PREFS, "START");
this->priv = g_new0 (glPrefsModelPrivate, 1);
- this->priv->gconf_client = gconf_client_get_default ();
+ this->priv->locale = g_settings_new ("org.gnome.glabels-3.locale");
+ this->priv->objects = g_settings_new ("org.gnome.glabels-3.objects");
+ this->priv->ui = g_settings_new ("org.gnome.glabels-3.ui");
- g_return_if_fail (this->priv->gconf_client != NULL);
+ g_return_if_fail (this->priv->locale != NULL);
+ g_return_if_fail (this->priv->objects != NULL);
+ g_return_if_fail (this->priv->ui != NULL);
- gconf_client_add_dir (this->priv->gconf_client,
- BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- gconf_client_notify_add (this->priv->gconf_client,
- BASE_KEY,
- (GConfClientNotifyFunc)notify_cb, this,
- NULL, NULL);
+ g_signal_connect_swapped (G_OBJECT (this->priv->locale), "changed",
+ G_CALLBACK (gsettings_changed_cb), this);
+ g_signal_connect_swapped (G_OBJECT (this->priv->objects), "changed",
+ G_CALLBACK (gsettings_changed_cb), this);
+ g_signal_connect_swapped (G_OBJECT (this->priv->ui), "changed",
+ G_CALLBACK (gsettings_changed_cb), this);
- gl_debug (DEBUG_PREFS, "END");
+ gl_debug (DEBUG_PREFS, "END");
}
static void
gl_prefs_model_finalize (GObject *object)
{
- glPrefsModel *this = GL_PREFS_MODEL (object);
+ glPrefsModel *this = GL_PREFS_MODEL (object);
- gl_debug (DEBUG_PREFS, "START");
+ gl_debug (DEBUG_PREFS, "START");
- g_return_if_fail (object && GL_IS_PREFS_MODEL (object));
+ g_return_if_fail (object && GL_IS_PREFS_MODEL (object));
- g_object_unref (G_OBJECT(this->priv->gconf_client));
+ g_object_unref (G_OBJECT(this->priv->locale));
+ g_object_unref (G_OBJECT(this->priv->objects));
+ g_object_unref (G_OBJECT(this->priv->ui));
g_free (this->priv);
- G_OBJECT_CLASS (gl_prefs_model_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gl_prefs_model_parent_class)->finalize (object);
- gl_debug (DEBUG_PREFS, "END");
+ gl_debug (DEBUG_PREFS, "END");
}
glPrefsModel *
gl_prefs_model_new (void)
{
- glPrefsModel *this;
+ glPrefsModel *this;
- gl_debug (DEBUG_PREFS, "START");
+ gl_debug (DEBUG_PREFS, "START");
- this = GL_PREFS_MODEL (g_object_new (gl_prefs_model_get_type(), NULL));
+ this = GL_PREFS_MODEL (g_object_new (gl_prefs_model_get_type(), NULL));
- gl_debug (DEBUG_PREFS, "END");
+ gl_debug (DEBUG_PREFS, "END");
- return this;
+ return this;
}
gl_prefs_model_set_units (glPrefsModel *this,
lglUnits units)
{
- gconf_client_set_string (this->priv->gconf_client,
- BASE_KEY PREF_UNITS,
- lgl_units_get_id (units),
- NULL);
+ g_settings_set_string (this->priv->locale,
+ "units",
+ lgl_units_get_id (units));
}
gl_prefs_model_get_units (glPrefsModel *this)
{
const gchar *pgsize;
- const gchar *default_units_string;
gchar *string;
lglUnits units;
- /* Make educated guess about locale default. */
- pgsize = gtk_paper_size_get_default ();
- if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
- {
- default_units_string = DEFAULT_UNITS_STRING_US;
- }
- else
+ string = g_settings_get_string (this->priv->locale, "units");
+
+ /* If not set, make educated guess about locale default. */
+ if ( !string || !strlen(string) )
{
- default_units_string = DEFAULT_UNITS_STRING_METRIC;
+ pgsize = gtk_paper_size_get_default ();
+ if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
+ {
+ string = g_strdup (DEFAULT_UNITS_STRING_US);
+ }
+ else
+ {
+ string = g_strdup (DEFAULT_UNITS_STRING_METRIC);
+ }
}
- string = get_string (this->priv->gconf_client,
- BASE_KEY PREF_UNITS,
- default_units_string);
- units = lgl_units_from_id (string);
- g_free (string);
+ units = lgl_units_from_id (string);
+ g_free (string);
/* If invalid, make an educated guess from locale. */
if (units == LGL_UNITS_INVALID)
{
+ pgsize = gtk_paper_size_get_default ();
if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
{
units = LGL_UNITS_INCH;
gl_prefs_model_set_default_page_size (glPrefsModel *this,
const gchar *page_size)
{
- gconf_client_set_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_PAGE_SIZE,
- page_size,
- NULL);
+ g_settings_set_string (this->priv->locale,
+ "default-page-size",
+ page_size);
}
gl_prefs_model_get_default_page_size (glPrefsModel *this)
{
const gchar *pgsize;
- const gchar *default_page_size;
gchar *page_size;
- lglPaper *paper;
+ lglPaper *paper;
- /* Make educated guess about locale default. */
- pgsize = gtk_paper_size_get_default ();
- if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
- {
- default_page_size = DEFAULT_PAGE_SIZE_US;
- }
- else
+ page_size = g_settings_get_string (this->priv->locale, "default-page-size");
+
+ /* If not set, make educated guess about locale default. */
+ if ( !page_size || !strlen(page_size) )
{
- default_page_size = DEFAULT_PAGE_SIZE_METRIC;
+ pgsize = gtk_paper_size_get_default ();
+ if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
+ {
+ page_size = g_strdup (DEFAULT_PAGE_SIZE_US);
+ }
+ else
+ {
+ page_size = g_strdup (DEFAULT_PAGE_SIZE_METRIC);
+ }
}
- page_size = get_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_PAGE_SIZE,
- default_page_size);
-
- /* Proof read the default page size -- it must be a valid id. */
- /* (For compatability with older versions.) */
- paper = lgl_db_lookup_paper_from_id (page_size);
- if ( paper == NULL ) {
+ /* Proof read the default page size -- it must be a valid id. */
+ /* (For compatability with older versions.) */
+ paper = lgl_db_lookup_paper_from_id (page_size);
+ if ( paper == NULL ) {
g_free (page_size);
- page_size = g_strdup (DEFAULT_PAGE_SIZE_US);
- } else {
- lgl_paper_free (paper);
- }
+ page_size = g_strdup (DEFAULT_PAGE_SIZE_US);
+ } else {
+ lgl_paper_free (paper);
+ }
return page_size;
}
gl_prefs_model_set_default_font_family (glPrefsModel *this,
const gchar *family)
{
- gconf_client_set_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_FAMILY,
- family,
- NULL);
+ g_settings_set_string (this->priv->objects,
+ "default-font-family",
+ family);
}
{
gchar *family;
- family = get_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_FAMILY,
- DEFAULT_FONT_FAMILY);
+ family = g_settings_get_string (this->priv->objects,
+ "default-font-family");
return family;
}
gl_prefs_model_set_default_font_size (glPrefsModel *this,
gdouble size)
{
- gconf_client_set_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_SIZE,
- size,
- NULL);
+ g_settings_set_double (this->priv->objects,
+ "default-font-size",
+ size);
}
{
gdouble size;
- size = get_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_SIZE,
- DEFAULT_FONT_SIZE);
+ size = g_settings_get_double (this->priv->objects,
+ "default-font-size");
return size;
}
gl_prefs_model_set_default_font_weight (glPrefsModel *this,
PangoWeight weight)
{
- gconf_client_set_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
- gl_str_util_weight_to_string(weight),
- NULL);
+ g_settings_set_string (this->priv->objects,
+ "default-font-weight",
+ gl_str_util_weight_to_string(weight));
}
gchar *string;
PangoWeight weight;
- string = get_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
- DEFAULT_FONT_WEIGHT_STRING);
- weight = gl_str_util_string_to_weight (string);
- g_free (string);
+ string = g_settings_get_string (this->priv->objects,
+ "default-font-weight");
+ weight = gl_str_util_string_to_weight (string);
+ g_free (string);
return weight;
}
gl_prefs_model_set_default_font_italic_flag (glPrefsModel *this,
gboolean italic_flag)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_ITALIC_FLAG,
- italic_flag,
- NULL);
+ g_settings_set_boolean (this->priv->objects,
+ "default-font-italic-flag",
+ italic_flag);
}
{
gboolean italic_flag;
- italic_flag = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_ITALIC_FLAG,
- DEFAULT_FONT_ITALIC_FLAG);
+ italic_flag = g_settings_get_boolean (this->priv->objects,
+ "default-font-italic-flag");
return italic_flag;
}
gl_prefs_model_set_default_text_color (glPrefsModel *this,
guint color)
{
- gconf_client_set_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_COLOR,
- color,
- NULL);
+ g_settings_set_value (this->priv->objects,
+ "default-text-color",
+ g_variant_new_uint32 (color));
}
guint
gl_prefs_model_get_default_text_color (glPrefsModel *this)
{
- guint color;
+ GVariant *value;
+ guint color;
- color = get_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_COLOR,
- DEFAULT_TEXT_COLOR);
+ value = g_settings_get_value (this->priv->objects, "default-text-color");
+ color = g_variant_get_uint32 (value);
+ g_variant_unref (value);
return color;
}
gl_prefs_model_set_default_text_alignment (glPrefsModel *this,
PangoAlignment alignment)
{
- gconf_client_set_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
- gl_str_util_align_to_string(alignment),
- NULL);
+ g_settings_set_string (this->priv->objects,
+ "default-text-alignment",
+ gl_str_util_align_to_string(alignment));
}
gchar *string;
PangoAlignment alignment;
- string = get_string (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
- DEFAULT_TEXT_ALIGN_STRING);
- alignment = gl_str_util_string_to_align (string);
- g_free (string);
+ string = g_settings_get_string (this->priv->objects,
+ "default-text-alignment");
+ alignment = gl_str_util_string_to_align (string);
+ g_free (string);
return alignment;
}
gl_prefs_model_set_default_text_line_spacing (glPrefsModel *this,
gdouble spacing)
{
- gconf_client_set_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
- spacing,
- NULL);
+ g_settings_set_double (this->priv->objects,
+ "default-text-line-spacing",
+ spacing);
}
{
gdouble spacing;
- spacing = get_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
- DEFAULT_TEXT_LINE_SPACING);
+ spacing = g_settings_get_double (this->priv->objects,
+ "default-text-line-spacing");
return spacing;
}
gl_prefs_model_set_default_line_width (glPrefsModel *this,
gdouble width)
{
- gconf_client_set_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_WIDTH,
- width,
- NULL);
+ g_settings_set_double (this->priv->objects,
+ "default-line-width",
+ width);
}
{
gdouble width;
- width = get_float (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_WIDTH,
- DEFAULT_LINE_WIDTH);
+ width = g_settings_get_double (this->priv->objects,
+ "default-line-width");
return width;
}
gl_prefs_model_set_default_line_color (glPrefsModel *this,
guint color)
{
- gconf_client_set_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_COLOR,
- color,
- NULL);
+ g_settings_set_value (this->priv->objects,
+ "default-line-color",
+ g_variant_new_uint32 (color));
}
guint
gl_prefs_model_get_default_line_color (glPrefsModel *this)
{
- guint color;
+ GVariant *value;
+ guint color;
- color = get_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_COLOR,
- DEFAULT_LINE_COLOR);
+ value = g_settings_get_value (this->priv->objects, "default-line-color");
+ color = g_variant_get_uint32 (value);
+ g_variant_unref (value);
return color;
}
gl_prefs_model_set_default_fill_color (glPrefsModel *this,
guint color)
{
- gconf_client_set_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- color,
- NULL);
+ g_settings_set_value (this->priv->objects,
+ "default-fill-color",
+ g_variant_new_uint32 (color));
}
guint
gl_prefs_model_get_default_fill_color (glPrefsModel *this)
{
- guint color;
+ GVariant *value;
+ guint color;
- color = get_int (this->priv->gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- DEFAULT_FILL_COLOR);
+ value = g_settings_get_value (this->priv->objects, "default-fill-color");
+ color = g_variant_get_uint32 (value);
+ g_variant_unref (value);
return color;
}
gl_prefs_model_set_main_toolbar_visible (glPrefsModel *this,
gboolean visible)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
- visible,
- NULL);
+ g_settings_set_boolean (this->priv->ui,
+ "main-toolbar-visible",
+ visible);
}
{
gboolean visible;
- visible = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
- TRUE);
+ visible = g_settings_get_boolean (this->priv->ui,
+ "main-toolbar-visible");
return visible;
}
gl_prefs_model_set_drawing_toolbar_visible (glPrefsModel *this,
gboolean visible)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- visible,
- NULL);
+ g_settings_set_boolean (this->priv->ui,
+ "drawing-toolbar-visible",
+ visible);
}
{
gboolean visible;
- visible = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- TRUE);
+ visible = g_settings_get_boolean (this->priv->ui,
+ "drawing-toolbar-visible");
return visible;
}
gl_prefs_model_set_property_toolbar_visible (glPrefsModel *this,
gboolean visible)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
- visible,
- NULL);
+ g_settings_set_boolean (this->priv->ui,
+ "property-toolbar-visible",
+ visible);
}
{
gboolean visible;
- visible = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
- TRUE);
+ visible = g_settings_get_boolean (this->priv->ui,
+ "property-toolbar-visible");
return visible;
}
gl_prefs_model_set_grid_visible (glPrefsModel *this,
gboolean visible)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_GRID_VISIBLE,
- visible,
- NULL);
+ g_settings_set_boolean (this->priv->ui,
+ "grid-visible",
+ visible);
}
{
gboolean visible;
- visible = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_GRID_VISIBLE,
- TRUE);
+ visible = g_settings_get_boolean (this->priv->ui,
+ "grid-visible");
return visible;
}
gl_prefs_model_set_markup_visible (glPrefsModel *this,
gboolean visible)
{
- gconf_client_set_bool (this->priv->gconf_client,
- BASE_KEY PREF_MARKUP_VISIBLE,
- visible,
- NULL);
+ g_settings_set_boolean (this->priv->ui,
+ "markup-visible",
+ visible);
}
{
gboolean visible;
- visible = get_bool (this->priv->gconf_client,
- BASE_KEY PREF_MARKUP_VISIBLE,
- TRUE);
+ visible = g_settings_get_boolean (this->priv->ui,
+ "markup-visible");
return visible;
}
gl_prefs_model_set_max_recents (glPrefsModel *this,
gint max_recents)
{
- gconf_client_set_int (this->priv->gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- max_recents,
- NULL);
+ g_settings_set_int (this->priv->ui,
+ "max-recents",
+ max_recents);
}
{
gint max_recents;
- max_recents = get_int (this->priv->gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- -1);
+ max_recents = g_settings_get_int (this->priv->ui,
+ "max-recents");
return max_recents;
}
/* PRIVATE. Key changed callback. */
/*---------------------------------------------------------------------------*/
static void
-notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glPrefsModel *this)
-{
- gl_debug (DEBUG_PREFS, "Key was changed: %s", entry->key);
-
- g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
-}
-
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Utilities to get values with defaults. */
-/*---------------------------------------------------------------------------*/
-static gchar*
-get_string (GConfClient *client,
- const gchar *key,
- const gchar *def)
-{
- gchar* val;
-
- val = gconf_client_get_string (client, key, NULL);
-
- if (val != NULL) {
-
- return val;
-
- } else {
-
- return def ? g_strdup (def) : NULL;
-
- }
-}
-
-
-static gboolean
-get_bool (GConfClient *client,
- const gchar *key,
- gboolean def)
+gsettings_changed_cb (glPrefsModel *this)
{
- GConfValue* val;
- gboolean retval;
-
- val = gconf_client_get (client, key, NULL);
-
- if (val != NULL) {
-
- if ( val->type == GCONF_VALUE_BOOL ) {
- retval = gconf_value_get_bool (val);
- } else {
- retval = def;
- }
-
- gconf_value_free (val);
-
- return retval;
-
- } else {
-
- return def;
-
- }
+ g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
}
-static gint
-get_int (GConfClient *client,
- const gchar *key,
- gint def)
-{
- GConfValue* val;
- gint retval;
-
- val = gconf_client_get (client, key, NULL);
-
- if (val != NULL) {
-
- if ( val->type == GCONF_VALUE_INT) {
- retval = gconf_value_get_int(val);
- } else {
- retval = def;
- }
-
- gconf_value_free (val);
-
- return retval;
-
- } else {
-
- return def;
-
- }
-}
-
-
-static gdouble
-get_float (GConfClient *client,
- const gchar *key,
- gdouble def)
-{
- GConfValue* val;
- gdouble retval;
-
- val = gconf_client_get (client, key, NULL);
-
- if (val != NULL) {
-
- if ( val->type == GCONF_VALUE_FLOAT ) {
- retval = gconf_value_get_float(val);
- } else {
- retval = def;
- }
-
- gconf_value_free (val);
-
- return retval;
-
- } else {
- return def;
-
- }
-}
-
-
-
/*
#include "template-history-model.h"
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include <libglabels.h>
#include "marshal.h"
-#define BASE_KEY "/apps/glabels"
-#define RECENT_TEMPLATES_KEY BASE_KEY "/recent-templates"
-
-
/*========================================================*/
/* Private types. */
/*========================================================*/
-/** GL_TEMPLATE_HISTORY_MODEL Private fields */
struct _glTemplateHistoryModelPrivate {
- GConfClient *gconf_client;
+ GSettings *history;
guint max_n;
};
static void gl_template_history_model_finalize (GObject *object);
-static void conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glTemplateHistoryModel *this);
+static void history_changed_cb (glTemplateHistoryModel *this);
/*****************************************************************************/
{
this->priv = g_new0 (glTemplateHistoryModelPrivate, 1);
- this->priv->gconf_client = gconf_client_get_default ();
-
- g_return_if_fail (this->priv->gconf_client != NULL);
+ this->priv->history = g_settings_new ("org.gnome.glabels-3.history");
- gconf_client_add_dir (this->priv->gconf_client,
- BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ g_return_if_fail (this->priv->history != NULL);
- gconf_client_notify_add (this->priv->gconf_client,
- RECENT_TEMPLATES_KEY,
- (GConfClientNotifyFunc)conf_notify_cb, this,
- NULL, NULL);
+ g_signal_connect_swapped (G_OBJECT (this->priv->history),
+ "changed::recent-templates",
+ G_CALLBACK (history_changed_cb), this);
}
g_return_if_fail (object && IS_GL_TEMPLATE_HISTORY_MODEL (object));
this = GL_TEMPLATE_HISTORY_MODEL (object);
- g_object_unref (G_OBJECT(this->priv->gconf_client));
+ g_object_unref (G_OBJECT(this->priv->history));
g_free (this->priv);
G_OBJECT_CLASS (gl_template_history_model_parent_class)->finalize (object);
/*****************************************************************************/
-/* Add template to history. */
+/* Add template to history. */
/*****************************************************************************/
void
gl_template_history_model_add_name (glTemplateHistoryModel *this,
const gchar *name)
{
- GSList *list = NULL;
- GList *old_list;
- GList *p;
- GSList *ps;
+ gchar **old;
+ gchar **new;
+ gint i, j;
- /*
- * Start new list with this name.
- */
- list = g_slist_append (list, (gchar *)name);
+ old = g_settings_get_strv (this->priv->history, "recent-templates");
+
+ new = g_new0 (gchar *, this->priv->max_n+1);
- /*
- * Transfer old list to new list, ignoring any duplicate of this name
- */
- old_list = gl_template_history_model_get_name_list (this);
- for ( p = old_list; p; p=p->next )
+ /* Put in first slot. */
+ new[0] = g_strdup (name);
+
+ /* Push everthing else down, pruning any duplicate found. */
+ for ( i = 0, j = 1; (j < (this->priv->max_n-1)) && old[i]; i++ )
{
- if ( lgl_str_utf8_casecmp (name, p->data) )
- {
- list = g_slist_append (list, p->data);
- }
- else
+ if ( lgl_str_utf8_casecmp (name, old[i]) != 0 )
{
- g_free (p->data);
+ new[j++] = g_strdup (old[i]);
}
}
- g_list_free (old_list);
- /*
- * Truncate list to maximum size
- */
- while (g_slist_length (list) > this->priv->max_n)
- {
- ps = g_slist_last (list);
- list = g_slist_remove_link (list, ps);
- g_slist_free_1 (ps);
- }
+ g_settings_set_strv (this->priv->history, "recent-templates",
+ (const gchar * const *)new);
- /*
- * Update conf
- */
- gconf_client_set_list (this->priv->gconf_client,
- RECENT_TEMPLATES_KEY,
- GCONF_VALUE_STRING,
- list,
- NULL);
+ g_strfreev (old);
+ g_strfreev (new);
}
/*****************************************************************************/
-/* GConf notify callback. */
+/* History changed callback. */
/*****************************************************************************/
static void
-conf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- glTemplateHistoryModel *this)
+history_changed_cb (glTemplateHistoryModel *this)
{
g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
}
GList *
gl_template_history_model_get_name_list (glTemplateHistoryModel *this)
{
+ gchar **strv;
GList *list = NULL;
- GSList *tmp_list;
- GSList *p;
+ gint i;
- /*
- * Get name list.
- */
- tmp_list = gconf_client_get_list (this->priv->gconf_client,
- RECENT_TEMPLATES_KEY,
- GCONF_VALUE_STRING,
- NULL);
+ strv = g_settings_get_strv (this->priv->history, "recent-templates");
/*
* Proof read name list; transfer storage to new list.
*/
- for (p=tmp_list; p != NULL; p=p->next)
+ for ( i = 0; strv[i]; i++ )
{
- if ( lgl_db_does_template_name_exist (p->data) )
- {
- list = g_list_append (list, p->data);
- }
- else
+ if ( lgl_db_does_template_name_exist (strv[i]) )
{
- g_free (p->data);
+ list = g_list_append (list, g_strdup (strv[i]));
}
}
- g_slist_free (tmp_list);
+ g_strfreev (strv);
return list;
}