tools.c \
prefs.c \
prefs.h \
+ prefs-model.c \
+ prefs-model.h \
prefs-dialog.c \
prefs-dialog.h \
hig.c \
text-node.h \
prefs.c \
prefs.h \
+ prefs-model.c \
+ prefs-model.h \
util.c \
util.h \
debug.c \
if (GL_VIEW(window->view)->print_dialog) {
- gtk_window_present (GL_VIEW(window->view)->print_dialog);
+ gtk_window_present (GTK_WINDOW(GL_VIEW(window->view)->print_dialog));
} else {
gnome_window_icon_set_default_from_file (ICON_PIXMAP);
}
- /* Load user preferences */
- gl_prefs_init ();
- gl_prefs_load_settings ();
-
/* Initialize subsystems */
gl_paper_init();
+ gl_prefs_init ();
gl_template_init();
gl_merge_init();
gl_recent_init();
GtkWidget *dlg;
gl_debug (DEBUG_PREFS, "START");
+ gl_debug (DEBUG_PREFS, "page size = \"%s\"", gl_prefs->default_page_size);
dlg = GTK_WIDGET (g_object_new (GL_TYPE_PREFS_DIALOG, NULL));
G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg));
switch (gl_prefs->units) {
- case GL_PREFS_UNITS_PTS:
+ case GL_UNITS_PTS:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_points_radio),
TRUE);
break;
- case GL_PREFS_UNITS_INCHES:
+ case GL_UNITS_INCHES:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_inches_radio),
TRUE);
break;
- case GL_PREFS_UNITS_MM:
+ case GL_UNITS_MM:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_mm_radio),
TRUE);
/* PRIVATE. Update object page widgets from current prefs. */
/*--------------------------------------------------------------------------*/
static void
- update_object_page_from_prefs (glPrefsDialog *dlg)
+update_object_page_from_prefs (glPrefsDialog *dlg)
{
GList *family_names;
gchar *good_font_family;
{
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_points_radio))) {
- gl_prefs->units = GL_PREFS_UNITS_PTS;
+ gl_prefs->units = GL_UNITS_PTS;
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_inches_radio))) {
- gl_prefs->units = GL_PREFS_UNITS_INCHES;
+ gl_prefs->units = GL_UNITS_INCHES;
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dlg->priv->units_mm_radio))) {
- gl_prefs->units = GL_PREFS_UNITS_MM;
+ gl_prefs->units = GL_UNITS_MM;
}
if (gtk_toggle_button_get_active (
gl_prefs->default_page_size = A4_ID;
}
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
}
/*--------------------------------------------------------------------------*/
gl_prefs->default_fill_color = gl_color_from_gdk_color (gdk_color);
}
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
}
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * prefs-model.c: Application preferences model module
+ *
+ * Copyright (C) 2001-2003 Jim Evins <evins@snaught.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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <config.h>
+
+
+#include "marshal.h"
+#include "prefs-model.h"
+#include "util.h"
+#include "paper.h"
+#include "color.h"
+
+#include "debug.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_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_MAIN_TOOLBAR_BUTTONS_STYLE "/main-toolbar-buttons-style"
+#define PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS "/main-toolbar-view-tooltips"
+
+#define PREF_DRAWING_TOOLBAR_VISIBLE "/drawing-toolbar-visible"
+#define PREF_DRAWING_TOOLBAR_BUTTONS_STYLE "/drawing-toolbar-buttons-style"
+#define PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS "/drawing-toolbar-view-tooltips"
+
+#define PREF_GRID_VISIBLE "/grid-visible"
+#define PREF_MARKUP_VISIBLE "/markup-visible"
+
+#define PREF_MAX_RECENTS "/max-recents"
+
+/* Default values */
+#define DEFAULT_UNITS_STRING units_to_string (GL_UNITS_INCHES)
+#define DEFAULT_PAGE_SIZE "US-Letter"
+
+#define DEFAULT_FONT_FAMILY "Sans"
+#define DEFAULT_FONT_SIZE 14.0
+#define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (GNOME_FONT_BOOK)
+#define DEFAULT_FONT_ITALIC_FLAG FALSE
+#define DEFAULT_TEXT_JUST_STRING gl_util_just_to_string (GTK_JUSTIFY_LEFT)
+#define DEFAULT_TEXT_COLOR GNOME_CANVAS_COLOR (0,0,0)
+
+#define DEFAULT_LINE_WIDTH 1.0
+#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255)
+
+#define DEFAULT_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 255)
+
+/*========================================================*/
+/* Private types. */
+/*========================================================*/
+
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
+
+
+/*========================================================*/
+/* Private globals. */
+/*========================================================*/
+
+static GObjectClass *parent_class = NULL;
+
+static guint signals[LAST_SIGNAL] = {0};
+
+/*========================================================*/
+/* Private function prototypes. */
+/*========================================================*/
+
+static void gl_prefs_model_class_init (glPrefsModelClass *klass);
+static void gl_prefs_model_instance_init (glPrefsModel *object);
+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 glPrefsUnits string_to_units (const gchar *string);
+static const gchar *units_to_string (glPrefsUnits units);
+
+
+\f
+/*****************************************************************************/
+/* Boilerplate object stuff. */
+/*****************************************************************************/
+GType
+gl_prefs_model_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ GTypeInfo info = {
+ sizeof (glPrefsModelClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gl_prefs_model_class_init,
+ NULL,
+ NULL,
+ sizeof (glPrefsModel),
+ 0,
+ (GInstanceInitFunc) gl_prefs_model_instance_init,
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "glPrefsModel", &info, 0);
+ }
+
+ return type;
+}
+
+static void
+gl_prefs_model_class_init (glPrefsModelClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *) klass;
+
+ gl_debug (DEBUG_PREFS, "START");
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ 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);
+
+ gl_debug (DEBUG_PREFS, "END");
+}
+
+static void
+gl_prefs_model_instance_init (glPrefsModel *prefs_model)
+{
+ gl_debug (DEBUG_PREFS, "START");
+
+ prefs_model->gconf_client = gconf_client_get_default ();
+
+ g_return_if_fail (prefs_model->gconf_client != NULL);
+
+ gconf_client_add_dir (prefs_model->gconf_client,
+ BASE_KEY,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
+
+ gconf_client_notify_add (prefs_model->gconf_client,
+ BASE_KEY,
+ (GConfClientNotifyFunc)notify_cb, prefs_model,
+ NULL, NULL);
+
+ gl_debug (DEBUG_PREFS, "END");
+}
+
+static void
+gl_prefs_model_finalize (GObject *object)
+{
+ gl_debug (DEBUG_PREFS, "START");
+
+ g_return_if_fail (object && GL_IS_PREFS_MODEL (object));
+
+ g_object_unref (G_OBJECT(GL_PREFS_MODEL(object)->gconf_client));
+
+ g_free (GL_PREFS_MODEL(object)->default_page_size);
+ g_free (GL_PREFS_MODEL(object)->default_font_family);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+ gl_debug (DEBUG_PREFS, "END");
+}
+
+/*****************************************************************************/
+/* New prefs_model object. */
+/*****************************************************************************/
+glPrefsModel *
+gl_prefs_model_new (void)
+{
+ glPrefsModel *prefs_model;
+
+ gl_debug (DEBUG_PREFS, "START");
+
+ prefs_model = GL_PREFS_MODEL (g_object_new (gl_prefs_model_get_type(), NULL));
+
+ gl_debug (DEBUG_PREFS, "END");
+
+ return prefs_model;
+}
+
+
+
+/*****************************************************************************/
+/* Save all settings. */
+/*****************************************************************************/
+void
+gl_prefs_model_save_settings (glPrefsModel *prefs_model)
+{
+ gl_debug (DEBUG_PREFS, "START");
+
+ g_return_if_fail (prefs_model && GL_IS_PREFS_MODEL(prefs_model));
+ g_return_if_fail (prefs_model->gconf_client != NULL);
+
+ /* We are saving settings because presumably some of them have been changed. */
+ g_signal_emit (G_OBJECT(prefs_model), signals[CHANGED], 0);
+
+ /* Units */
+ gconf_client_set_string (prefs_model->gconf_client,
+ BASE_KEY PREF_UNITS,
+ units_to_string(prefs_model->units),
+ NULL);
+
+ /* Default page size */
+ gconf_client_set_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_PAGE_SIZE,
+ prefs_model->default_page_size,
+ NULL);
+
+
+ /* Text properties */
+ gconf_client_set_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_FAMILY,
+ prefs_model->default_font_family,
+ NULL);
+
+ gconf_client_set_float (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_SIZE,
+ prefs_model->default_font_size,
+ NULL);
+
+ gconf_client_set_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
+ gl_util_weight_to_string(prefs_model->default_font_weight),
+ NULL);
+
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_COLOR,
+ prefs_model->default_text_color,
+ NULL);
+
+ gconf_client_set_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
+ gl_util_just_to_string(prefs_model->default_text_alignment),
+ NULL);
+
+
+ /* Line properties */
+ gconf_client_set_float (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_WIDTH,
+ prefs_model->default_line_width,
+ NULL);
+
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_COLOR,
+ prefs_model->default_line_color,
+ NULL);
+
+
+ /* Fill properties */
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FILL_COLOR,
+ prefs_model->default_fill_color,
+ NULL);
+
+
+ /* Main Toolbar */
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
+ prefs_model->main_toolbar_visible,
+ NULL);
+
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
+ prefs_model->main_toolbar_buttons_style,
+ NULL);
+
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
+ prefs_model->main_toolbar_view_tooltips,
+ NULL);
+
+ /* Drawing Toolbar */
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
+ prefs_model->drawing_toolbar_visible,
+ NULL);
+
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_BUTTONS_STYLE,
+ prefs_model->drawing_toolbar_buttons_style,
+ NULL);
+
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
+ prefs_model->drawing_toolbar_view_tooltips,
+ NULL);
+
+ /* View properties */
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_GRID_VISIBLE,
+ prefs_model->grid_visible,
+ NULL);
+
+ gconf_client_set_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MARKUP_VISIBLE,
+ prefs_model->markup_visible,
+ NULL);
+
+ /* Recent files */
+ gconf_client_set_int (prefs_model->gconf_client,
+ BASE_KEY PREF_MAX_RECENTS,
+ prefs_model->max_recents,
+ NULL);
+
+
+ gconf_client_suggest_sync (prefs_model->gconf_client, NULL);
+
+ gl_debug (DEBUG_PREFS, "END");
+}
+
+/*****************************************************************************/
+/* Load all settings. */
+/*****************************************************************************/
+void
+gl_prefs_model_load_settings (glPrefsModel *prefs_model)
+{
+ gchar *string;
+ glPaper *paper;
+
+ gl_debug (DEBUG_PREFS, "START");
+
+ g_return_if_fail (prefs_model && GL_IS_PREFS_MODEL(prefs_model));
+ g_return_if_fail (prefs_model->gconf_client != NULL);
+
+ /* Units */
+ string =
+ get_string (prefs_model->gconf_client,
+ BASE_KEY PREF_UNITS,
+ DEFAULT_UNITS_STRING);
+ prefs_model->units = string_to_units( string );
+ g_free( string );
+
+
+ /* Page size */
+ prefs_model->default_page_size =
+ get_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_PAGE_SIZE,
+ DEFAULT_PAGE_SIZE);
+
+ /* Text properties */
+ prefs_model->default_font_family =
+ get_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_FAMILY,
+ DEFAULT_FONT_FAMILY);
+
+ prefs_model->default_font_size =
+ get_float (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_SIZE,
+ DEFAULT_FONT_SIZE);
+
+ string =
+ get_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
+ DEFAULT_FONT_WEIGHT_STRING);
+ prefs_model->default_font_weight = gl_util_string_to_weight( string );
+ g_free( string );
+
+ prefs_model->default_text_color =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_COLOR,
+ DEFAULT_TEXT_COLOR);
+
+ string =
+ get_string (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
+ DEFAULT_TEXT_JUST_STRING);
+ prefs_model->default_text_alignment = gl_util_string_to_just( string );
+ g_free( string );
+
+
+ /* Line properties */
+ prefs_model->default_line_width =
+ get_float (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_WIDTH,
+ DEFAULT_LINE_WIDTH);
+ prefs_model->default_line_color =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_COLOR,
+ DEFAULT_LINE_COLOR);
+
+ /* Fill properties */
+ prefs_model->default_fill_color =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DEFAULT_FILL_COLOR,
+ DEFAULT_FILL_COLOR);
+
+
+ /* User Inferface/Main Toolbar */
+ prefs_model->main_toolbar_visible =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
+ TRUE);
+
+ prefs_model->main_toolbar_buttons_style =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
+ GL_TOOLBAR_SYSTEM);
+
+ prefs_model->main_toolbar_view_tooltips =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
+ TRUE);
+
+ /* User Inferface/Drawing Toolbar */
+ prefs_model->drawing_toolbar_visible =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
+ TRUE);
+
+ prefs_model->drawing_toolbar_buttons_style =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_BUTTONS_STYLE,
+ GL_TOOLBAR_SYSTEM);
+
+ prefs_model->drawing_toolbar_view_tooltips =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
+ TRUE);
+
+
+ /* View properties */
+ prefs_model->grid_visible =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_GRID_VISIBLE,
+ TRUE);
+
+ prefs_model->markup_visible =
+ get_bool (prefs_model->gconf_client,
+ BASE_KEY PREF_MARKUP_VISIBLE,
+ TRUE);
+
+ /* Recent files */
+ prefs_model->max_recents =
+ get_int (prefs_model->gconf_client,
+ BASE_KEY PREF_MAX_RECENTS,
+ 4);
+
+
+ /* Proof read the default page size -- it must be a valid id. */
+ /* (For compatability with older versions.) */
+ /* Note: paper module must be initialized for this to work. */
+ paper = gl_paper_from_id (prefs_model->default_page_size);
+ if ( paper == NULL ) {
+ prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE);
+ } else {
+ gl_paper_free (&paper);
+ }
+
+ gl_debug (DEBUG_PREFS, "max_recents = %d", prefs_model->max_recents);
+
+
+ g_signal_emit (G_OBJECT(prefs_model), signals[CHANGED], 0);
+
+ gl_debug (DEBUG_PREFS, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Key changed callback. */
+/*---------------------------------------------------------------------------*/
+static void
+notify_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ glPrefsModel *prefs_model)
+{
+ gl_debug (DEBUG_PREFS, "Key was changed: %s", entry->key);
+
+ gl_prefs_model_load_settings (prefs_model);
+}
+
+/*---------------------------------------------------------------------------*/
+/* 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)
+{
+ 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;
+
+ }
+}
+
+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;
+
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Utilities to deal with units. */
+/*---------------------------------------------------------------------------*/
+static glPrefsUnits
+string_to_units (const gchar *string)
+{
+ glPrefsUnits units;
+
+ if (g_strcasecmp (string, "Points") == 0) {
+ units = GL_UNITS_PTS;
+ } else if (g_strcasecmp (string, "Inches") == 0) {
+ units = GL_UNITS_INCHES;
+ } else if (g_strcasecmp (string, "Millimeters") == 0) {
+ units = GL_UNITS_MM;
+ } else {
+ units = GL_UNITS_INCHES;
+ }
+
+ return units;
+}
+
+static const
+gchar *units_to_string (glPrefsUnits units)
+{
+ switch (units) {
+ case GL_UNITS_PTS:
+ return "Points";
+ break;
+ case GL_UNITS_INCHES:
+ return "Inches";
+ break;
+ case GL_UNITS_MM:
+ return "Millimeters";
+ break;
+ default:
+ return "Inches";
+ break;
+ }
+}
+
+
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * prefs-model.h: Application preferences model module header file
+ *
+ * Copyright (C) 2001-2003 Jim Evins <evins@snaught.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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PREFS_MODEL_H__
+#define __PREFS_MODEL_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+#include <libgnomeprint/gnome-font.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ GL_TOOLBAR_SYSTEM = 0,
+ GL_TOOLBAR_ICONS,
+ GL_TOOLBAR_ICONS_AND_TEXT
+} glToolbarSetting;
+
+typedef enum {
+ GL_UNITS_PTS,
+ GL_UNITS_INCHES,
+ GL_UNITS_MM,
+} glPrefsUnits;
+
+#define GL_TYPE_PREFS_MODEL (gl_prefs_model_get_type ())
+#define GL_PREFS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_PREFS_MODEL, glPrefsModel))
+#define GL_PREFS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_PREFS_MODEL, glPrefsModelClass))
+#define GL_IS_PREFS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_PREFS_MODEL))
+#define GL_IS_PREFS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_PREFS_MODEL))
+#define GL_PREFS_MODEL_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GL_TYPE_PREFS_MODEL, glPrefsModelClass))
+
+
+typedef struct _glPrefsModel glPrefsModel;
+typedef struct _glPrefsModelClass glPrefsModelClass;
+
+typedef struct _glPrefsModelPrivate glPrefsModelPrivate;
+
+
+struct _glPrefsModel {
+ GObject *object;
+
+ GConfClient *gconf_client;
+
+ /* Units */
+ glPrefsUnits units;
+
+ /* Page size */
+ gchar *default_page_size;
+
+ /* Text properties */
+ gchar *default_font_family;
+ gdouble default_font_size;
+ GnomeFontWeight default_font_weight;
+ gboolean default_font_italic_flag;
+ guint default_text_color;
+ GtkJustification default_text_alignment;
+
+ /* Line properties */
+ gdouble default_line_width;
+ guint default_line_color;
+
+ /* Fill properties */
+ guint default_fill_color;
+
+ /* User Interface/Main Toolbar */
+ gboolean main_toolbar_visible;
+ glToolbarSetting main_toolbar_buttons_style;
+ gboolean main_toolbar_view_tooltips;
+
+ /* User Interface/Drawing Toolbar */
+ gboolean drawing_toolbar_visible;
+ glToolbarSetting drawing_toolbar_buttons_style;
+ gboolean drawing_toolbar_view_tooltips;
+
+ /* View properties */
+ gboolean grid_visible;
+ gboolean markup_visible;
+
+ /* Recent files */
+ gint max_recents;
+};
+
+struct _glPrefsModelClass {
+ GObjectClass parent_class;
+
+ void (*changed) (glPrefsModel *prefs_model, gpointer user_data);
+};
+
+
+GType gl_prefs_model_get_type (void);
+
+glPrefsModel *gl_prefs_model_new (void);
+
+void gl_prefs_model_save_settings (glPrefsModel *prefs_model);
+
+void gl_prefs_model_load_settings (glPrefsModel *prefs_model);
+
+G_END_DECLS
+
+#endif /* __PREFS_MODEL_H__ */
+
/*
* (GLABELS) Label and Business Card Creation program for GNOME
*
- * prefs.h: Application preferences module header file
+ * prefs.c: Application preferences module
*
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
+ * Copyright (C) 2001-2003 Jim Evins <evins@snaught.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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <config.h>
-#include <libgnome/libgnome.h>
-#include <libgnomeui/libgnomeui.h>
+#include <gnome.h>
-#include <gconf/gconf-client.h>
-
-#include "prefs.h"
-#include "util.h"
-#include "paper.h"
+#include "prefs-model.h"
#include "debug.h"
-glPreferences *gl_prefs = NULL;
+glPrefsModel *gl_prefs = NULL;
/*========================================================*/
/* 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_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_MAIN_TOOLBAR_BUTTONS_STYLE "/main-toolbar-buttons-style"
-#define PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS "/main-toolbar-view-tooltips"
-
-#define PREF_DRAWING_TOOLBAR_VISIBLE "/drawing-toolbar-visible"
-#define PREF_DRAWING_TOOLBAR_BUTTONS_STYLE "/drawing-toolbar-buttons-style"
-#define PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS "/drawing-toolbar-view-tooltips"
-
-#define PREF_GRID_VISIBLE "/grid-visible"
-#define PREF_MARKUP_VISIBLE "/markup-visible"
-
-#define PREF_MAX_RECENTS "/max-recents"
-
-/* Default values */
-#define DEFAULT_UNITS_STRING units_to_string (GL_PREFS_UNITS_INCHES)
-#define DEFAULT_PAGE_SIZE "US-Letter"
-
-#define DEFAULT_FONT_FAMILY "Sans"
-#define DEFAULT_FONT_SIZE 14.0
-#define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (GNOME_FONT_BOOK)
-#define DEFAULT_FONT_ITALIC_FLAG FALSE
-#define DEFAULT_TEXT_JUST_STRING gl_util_just_to_string (GTK_JUSTIFY_LEFT)
-#define DEFAULT_TEXT_COLOR GNOME_CANVAS_COLOR (0,0,0)
-
-#define DEFAULT_LINE_WIDTH 1.0
-#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255)
-
-#define DEFAULT_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 255)
/*========================================================*/
/* Private types. */
/*========================================================*/
/* Private globals. */
/*========================================================*/
-static GConfClient *gconf_client = NULL;
+
/*========================================================*/
/* Private function prototypes. */
/*========================================================*/
-static void notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-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 glPrefsUnits string_to_units (const gchar *string);
-static const gchar *units_to_string (glPrefsUnits units);
-
\f
/*****************************************************************************/
/*****************************************************************************/
void
gl_prefs_init (void)
-{
- gl_debug (DEBUG_PREFS, "");
-
- gconf_client = gconf_client_get_default ();
-
- g_return_if_fail (gconf_client != NULL);
-
- gconf_client_add_dir (gconf_client,
- BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- gconf_client_notify_add (gconf_client,
- BASE_KEY,
- notify_cb,
- NULL, NULL, NULL);
-}
-
-
-/*****************************************************************************/
-/* Save all settings. */
-/*****************************************************************************/
-void
-gl_prefs_save_settings (void)
{
gl_debug (DEBUG_PREFS, "START");
-
- g_return_if_fail (gconf_client != NULL);
- g_return_if_fail (gl_prefs != NULL);
-
- /* Units */
- gconf_client_set_string (gconf_client,
- BASE_KEY PREF_UNITS,
- units_to_string(gl_prefs->units),
- NULL);
-
- /* Default page size */
- gconf_client_set_string (gconf_client,
- BASE_KEY PREF_DEFAULT_PAGE_SIZE,
- gl_prefs->default_page_size,
- NULL);
-
-
- /* Text properties */
- gconf_client_set_string (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_FAMILY,
- gl_prefs->default_font_family,
- NULL);
-
- gconf_client_set_float (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_SIZE,
- gl_prefs->default_font_size,
- NULL);
-
- gconf_client_set_string (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
- gl_util_weight_to_string(gl_prefs->default_font_weight),
- NULL);
-
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_COLOR,
- gl_prefs->default_text_color,
- NULL);
-
- gconf_client_set_string (gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
- gl_util_just_to_string(gl_prefs->default_text_alignment),
- NULL);
-
-
- /* Line properties */
- gconf_client_set_float (gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_WIDTH,
- gl_prefs->default_line_width,
- NULL);
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_COLOR,
- gl_prefs->default_line_color,
- NULL);
+ gl_prefs = gl_prefs_model_new ();
+ gl_prefs_model_load_settings (gl_prefs);
- /* Fill properties */
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- gl_prefs->default_fill_color,
- NULL);
-
-
- /* Main Toolbar */
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
- gl_prefs->main_toolbar_visible,
- NULL);
-
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
- gl_prefs->main_toolbar_buttons_style,
- NULL);
-
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
- gl_prefs->main_toolbar_view_tooltips,
- NULL);
-
- /* Drawing Toolbar */
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- gl_prefs->drawing_toolbar_visible,
- NULL);
-
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_BUTTONS_STYLE,
- gl_prefs->drawing_toolbar_buttons_style,
- NULL);
-
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
- gl_prefs->drawing_toolbar_view_tooltips,
- NULL);
-
- /* View properties */
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_GRID_VISIBLE,
- gl_prefs->grid_visible,
- NULL);
-
- gconf_client_set_bool (gconf_client,
- BASE_KEY PREF_MARKUP_VISIBLE,
- gl_prefs->markup_visible,
- NULL);
-
- /* Recent files */
- gconf_client_set_int (gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- gl_prefs->max_recents,
- NULL);
-
-
- gconf_client_suggest_sync (gconf_client, NULL);
-
gl_debug (DEBUG_PREFS, "END");
}
-/*****************************************************************************/
-/* Load all settings. */
-/*****************************************************************************/
-void
-gl_prefs_load_settings (void)
-{
- gchar *string;
- glPaper *paper;
-
- gl_debug (DEBUG_PREFS, "START");
-
- if (gl_prefs == NULL)
- gl_prefs = g_new0 (glPreferences, 1);
-
- if (gconf_client == NULL)
- {
- /* TODO: in any case set default values */
- g_warning ("Cannot load settings.");
- return;
- }
-
-
- /* Units */
- string =
- get_string (gconf_client,
- BASE_KEY PREF_UNITS,
- DEFAULT_UNITS_STRING);
- gl_prefs->units = string_to_units( string );
- g_free( string );
-
-
- /* Page size */
- gl_prefs->default_page_size =
- get_string (gconf_client,
- BASE_KEY PREF_DEFAULT_PAGE_SIZE,
- DEFAULT_PAGE_SIZE);
-
- /* Text properties */
- gl_prefs->default_font_family =
- get_string (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_FAMILY,
- DEFAULT_FONT_FAMILY);
-
- gl_prefs->default_font_size =
- get_float (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_SIZE,
- DEFAULT_FONT_SIZE);
-
- string =
- get_string (gconf_client,
- BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
- DEFAULT_FONT_WEIGHT_STRING);
- gl_prefs->default_font_weight = gl_util_string_to_weight( string );
- g_free( string );
-
- gl_prefs->default_text_color =
- get_int (gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_COLOR,
- DEFAULT_TEXT_COLOR);
-
- string =
- get_string (gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
- DEFAULT_TEXT_JUST_STRING);
- gl_prefs->default_text_alignment = gl_util_string_to_just( string );
- g_free( string );
-
-
- /* Line properties */
- gl_prefs->default_line_width =
- get_float (gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_WIDTH,
- DEFAULT_LINE_WIDTH);
- gl_prefs->default_line_color =
- get_int (gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_COLOR,
- DEFAULT_LINE_COLOR);
-
- /* Fill properties */
- gl_prefs->default_fill_color =
- get_int (gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- DEFAULT_FILL_COLOR);
-
-
- /* User Inferface/Main Toolbar */
- gl_prefs->main_toolbar_visible =
- get_bool (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
- TRUE);
-
- gl_prefs->main_toolbar_buttons_style =
- get_int (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
- GL_TOOLBAR_SYSTEM);
-
- gl_prefs->main_toolbar_view_tooltips =
- get_bool (gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
- TRUE);
-
- /* User Inferface/Drawing Toolbar */
- gl_prefs->drawing_toolbar_visible =
- get_bool (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- TRUE);
-
- gl_prefs->drawing_toolbar_buttons_style =
- get_int (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_BUTTONS_STYLE,
- GL_TOOLBAR_SYSTEM);
-
- gl_prefs->drawing_toolbar_view_tooltips =
- get_bool (gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
- TRUE);
-
-
- /* View properties */
- gl_prefs->grid_visible =
- get_bool (gconf_client,
- BASE_KEY PREF_GRID_VISIBLE,
- TRUE);
-
- gl_prefs->markup_visible =
- get_bool (gconf_client,
- BASE_KEY PREF_MARKUP_VISIBLE,
- TRUE);
-
- /* Recent files */
- gl_prefs->max_recents =
- get_int (gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- 4);
-
-
- /* Proof read the default page size -- it must be a valid id. */
- /* (For compatability with older versions.) */
- paper = gl_paper_from_id (gl_prefs->default_page_size);
- if ( paper == NULL ) {
- gl_prefs->default_page_size = g_strdup (DEFAULT_PAGE_SIZE);
- } else {
- gl_paper_free (&paper);
- }
-
- gl_debug (DEBUG_PREFS, "max_recents = %d", gl_prefs->max_recents);
-
- gl_debug (DEBUG_PREFS, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Key changed callback. */
-/*---------------------------------------------------------------------------*/
-static void
-notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- gl_debug (DEBUG_PREFS, "Key was changed: %s", entry->key);
-}
-
-/*---------------------------------------------------------------------------*/
-/* 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)
-{
- 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;
-
- }
-}
-
-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;
-
- }
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Utilities to deal with units. */
-/*---------------------------------------------------------------------------*/
-static glPrefsUnits string_to_units (const gchar *string)
-{
- glPrefsUnits units;
-
- if (g_strcasecmp (string, "Points") == 0) {
- units = GL_PREFS_UNITS_PTS;
- } else if (g_strcasecmp (string, "Inches") == 0) {
- units = GL_PREFS_UNITS_INCHES;
- } else if (g_strcasecmp (string, "Millimeters") == 0) {
- units = GL_PREFS_UNITS_MM;
- } else {
- units = GL_PREFS_UNITS_INCHES;
- }
-
- return units;
-}
-
-static const gchar *units_to_string (glPrefsUnits units)
-{
- switch (units) {
- case GL_PREFS_UNITS_PTS:
- return "Points";
- break;
- case GL_PREFS_UNITS_INCHES:
- return "Inches";
- break;
- case GL_PREFS_UNITS_MM:
- return "Millimeters";
- break;
- default:
- return "Inches";
- break;
- }
-}
-
-
\f
/****************************************************************************/
/* Get string representing desired units. */
{
switch (gl_prefs->units) {
- case GL_PREFS_UNITS_PTS:
+ case GL_UNITS_PTS:
return 1.0; /* points */
- case GL_PREFS_UNITS_INCHES:
+ case GL_UNITS_INCHES:
return 1.0 / 72.0; /* inches */
- case GL_PREFS_UNITS_MM:
+ case GL_UNITS_MM:
return 0.35277778; /* mm */
default:
g_warning ("Illegal units"); /* Should not happen */
{
switch (gl_prefs->units) {
- case GL_PREFS_UNITS_PTS:
+ case GL_UNITS_PTS:
return 1; /* points */
- case GL_PREFS_UNITS_INCHES:
+ case GL_UNITS_INCHES:
return 3; /* inches */
- case GL_PREFS_UNITS_MM:
+ case GL_UNITS_MM:
return 1; /* mm */
default:
g_warning ("Illegal units"); /* Should not happen */
{
switch (gl_prefs->units) {
- case GL_PREFS_UNITS_PTS:
+ case GL_UNITS_PTS:
return 0.1; /* points */
- case GL_PREFS_UNITS_INCHES:
+ case GL_UNITS_INCHES:
return 0.001; /* inches */
- case GL_PREFS_UNITS_MM:
+ case GL_UNITS_MM:
return 0.1; /* mm */
default:
g_warning ("Illegal units"); /* Should not happen */
{
switch (gl_prefs->units) {
- case GL_PREFS_UNITS_PTS:
+ case GL_UNITS_PTS:
return _("points");
- case GL_PREFS_UNITS_INCHES:
+ case GL_UNITS_INCHES:
return _("inches");
- case GL_PREFS_UNITS_MM:
+ case GL_UNITS_MM:
return _("mm");
default:
g_warning ("Illegal units"); /* Should not happen */
*
* prefs.h: Application preferences module header file
*
- * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
+ * Copyright (C) 2001-2003 Jim Evins <evins@snaught.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
#ifndef __PREFS_H__
#define __PREFS_H__
-#include <gtk/gtk.h>
-#include <libgnomeprint/gnome-font.h>
+#include "prefs-model.h"
G_BEGIN_DECLS
-typedef struct _glPreferences glPreferences;
-
-typedef enum {
- GL_TOOLBAR_SYSTEM = 0,
- GL_TOOLBAR_ICONS,
- GL_TOOLBAR_ICONS_AND_TEXT
-} glToolbarSetting;
-
-typedef enum {
- GL_PREFS_UNITS_PTS,
- GL_PREFS_UNITS_INCHES,
- GL_PREFS_UNITS_MM,
-} glPrefsUnits;
-
-struct _glPreferences
-{
- /* Units */
- glPrefsUnits units;
-
- /* Page size */
- gchar *default_page_size;
-
- /* Text properties */
- gchar *default_font_family;
- gdouble default_font_size;
- GnomeFontWeight default_font_weight;
- gboolean default_font_italic_flag;
- guint default_text_color;
- GtkJustification default_text_alignment;
-
- /* Line properties */
- gdouble default_line_width;
- guint default_line_color;
-
- /* Fill properties */
- guint default_fill_color;
-
- /* User Interface/Main Toolbar */
- gboolean main_toolbar_visible;
- glToolbarSetting main_toolbar_buttons_style;
- gboolean main_toolbar_view_tooltips;
-
- /* User Interface/Drawing Toolbar */
- gboolean drawing_toolbar_visible;
- glToolbarSetting drawing_toolbar_buttons_style;
- gboolean drawing_toolbar_view_tooltips;
-
- /* View properties */
- gboolean grid_visible;
- gboolean markup_visible;
-
- /* Recent files */
- gint max_recents;
-};
-
-glPreferences *gl_prefs;
-
-void gl_prefs_save_settings (void);
-
-void gl_prefs_load_settings (void);
-void gl_prefs_init (void);
+extern glPrefsModel *gl_prefs;
+
+
+
+void gl_prefs_init (void);
const gchar *gl_prefs_get_page_size (void);
switch (template->label.style) {
case GL_TEMPLATE_STYLE_RECT:
- if ( units == GL_PREFS_UNITS_INCHES ) {
+ if ( units == GL_UNITS_INCHES ) {
gchar *xstr, *ystr;
xstr = gl_util_fraction (template->label.rect.w * units_per_point);
}
break;
case GL_TEMPLATE_STYLE_ROUND:
- if ( units == GL_PREFS_UNITS_INCHES ) {
+ if ( units == GL_UNITS_INCHES ) {
gchar *dstr;
dstr = gl_util_fraction (2.0 * template->label.round.r * units_per_point);
}
break;
case GL_TEMPLATE_STYLE_CD:
- if ( units == GL_PREFS_UNITS_INCHES ) {
+ if ( units == GL_UNITS_INCHES ) {
gchar *dstr;
dstr = gl_util_fraction (2.0 * template->label.cd.r1 * units_per_point);
{
gl_prefs->main_toolbar_visible = s;
set_app_main_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
set_app_main_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS;
set_app_main_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
set_app_main_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->main_toolbar_view_tooltips = s;
set_app_main_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->drawing_toolbar_visible = s;
set_app_drawing_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
set_app_drawing_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS;
set_app_drawing_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->drawing_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
set_app_drawing_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
{
gl_prefs->drawing_toolbar_view_tooltips = s;
set_app_drawing_toolbar_style (ui_component);
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
} else {
gl_view_hide_grid (GL_VIEW(GL_WINDOW(win)->view));
}
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}
} else {
gl_view_hide_markup (GL_VIEW(GL_WINDOW(win)->view));
}
- gl_prefs_save_settings ();
+ gl_prefs_model_save_settings (gl_prefs);
return;
}