Refactored glPrefsModel, reconciling its style with glFontsHistory, etc.
Added Units module to libglabels, consolidating most utilities associated
with units into this module. Also created a units-util module in
glabels for utilities that do not belong in libglabels.
lgl_xml_paper_parse_paper_node
</SECTION>
-<SECTION>
-<FILE>enums</FILE>
-lglUnitsType
-</SECTION>
-
<SECTION>
<FILE>xml-category</FILE>
lgl_xml_category_read_categories_from_file
lgl_db_print_aliases
</SECTION>
+<SECTION>
+<FILE>units</FILE>
+lglUnits
+lgl_units_get_id
+lgl_units_from_id
+lgl_units_get_name
+lgl_units_from_name
+lgl_units_get_points_per_unit
+lgl_units_get_units_per_point
+</SECTION>
+
<SECTION>
<FILE>str</FILE>
lgl_str_utf8_casecmp
<chapter>
<title>Miscellaneous</title>
- <xi:include href="xml/enums.xml"/>
+ <xi:include href="xml/units.xml"/>
<xi:include href="xml/str.xml"/>
</chapter>
</SECTION>
<SECTION>
-<FILE>enums</FILE>
-<INCLUDE>libglabels/enums.h</INCLUDE>
-lglUnitsType
+<FILE>units</FILE>
+<INCLUDE>libglabels/units.h</INCLUDE>
+lglUnits
+lgl_units_get_id
+lgl_units_from_id
+lgl_units_get_name
+lgl_units_from_name
+lgl_units_get_points_per_unit
+lgl_units_get_units_per_point
</SECTION>
<SECTION>
+++ /dev/null
-99% symbol docs coverage.
-141 symbols documented.
-1 symbols incomplete.
-1 not documented.
-
-
-LGL_XML_NAME_SPACE
-lglPaper (pwg_size)
-
-
+++ /dev/null
-<!-- ##### SECTION Title ##### -->
-Enumerations
-
-<!-- ##### SECTION Short_Description ##### -->
-Common enumerations used by libglabels
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
-This section defines enumerations used to interact with libglabels.
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
-
-</para>
-
-<!-- ##### SECTION Stability_Level ##### -->
-
-
-<!-- ##### ENUM lglUnitsType ##### -->
-<para>
-This enumeration defines a set of units of distance supported by the libglabels XML distance
-attributes.
-</para>
-
-@LGL_UNITS_POINT: Points. Encoded as "pt" in XML distance attributes.
-@LGL_UNITS_INCH: Inches. Encoded as "in" in XML distance attributes.
-@LGL_UNITS_MM: Millmeters. Encoded as "mm" in XML distance attributes.
-@LGL_UNITS_CM: Centimeters. Encoded as "cm" in XML distance attributes.
-@LGL_UNITS_PICA: Picas. Encoded as "pc" in XML distance attributes.
-@LGL_UNITS_FIRST: First enumeration. Used for generic iteration through supported units..
-@LGL_UNITS_LAST: Last enumeration. Used for generic iteration through supported units.
-
+<!-- ##### SECTION ./tmpl/enums.sgml:Long_Description ##### -->
+<para>
+This section defines enumerations used to interact with libglabels.
+</para>
+
+
+<!-- ##### SECTION ./tmpl/enums.sgml:See_Also ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### SECTION ./tmpl/enums.sgml:Short_Description ##### -->
+Common enumerations used by libglabels
+
+
+<!-- ##### SECTION ./tmpl/enums.sgml:Stability_Level ##### -->
+
+
+
+<!-- ##### SECTION ./tmpl/enums.sgml:Title ##### -->
+Enumerations
+
+
<!-- ##### SECTION ./tmpl/init.sgml:Long_Description ##### -->
<para>
@templates:
@utf8_filename:
+<!-- ##### ENUM lglUnitsType ##### -->
+<para>
+This enumeration defines a set of units of distance supported by the libglabels XML distance
+attributes.
+</para>
+
+@LGL_UNITS_POINT: Points. Encoded as "pt" in XML distance attributes.
+@LGL_UNITS_INCH: Inches. Encoded as "in" in XML distance attributes.
+@LGL_UNITS_MM: Millmeters. Encoded as "mm" in XML distance attributes.
+@LGL_UNITS_CM: Centimeters. Encoded as "cm" in XML distance attributes.
+@LGL_UNITS_PICA: Picas. Encoded as "pc" in XML distance attributes.
+@LGL_UNITS_FIRST: First enumeration. Used for generic iteration through supported units..
+@LGL_UNITS_LAST: Last enumeration. Used for generic iteration through supported units.
+
<!-- ##### FUNCTION lgl_category_free_id_list ##### -->
<para>
@name: Localized paper size name.
@width: Width of paper in points.
@height: Height of paper in points.
-@pwg_size:
+@pwg_size: Paper size string as defined in PWG 5101.1-2002.
<!-- ##### FUNCTION lgl_paper_new ##### -->
<para>
--- /dev/null
+<!-- ##### SECTION Title ##### -->
+Units
+
+<!-- ##### SECTION Short_Description ##### -->
+Type to represent units of distance supported by libglabels
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+This section defines a type to represent the varios units of distance
+supported by libglabels. It also defines a set of related functions.
+
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### ENUM lglUnits ##### -->
+<para>
+This enumeration defines supported units of distance.
+</para>
+
+@LGL_UNITS_POINT: Points.
+@LGL_UNITS_INCH: Inches.
+@LGL_UNITS_MM: Millimeters
+@LGL_UNITS_CM: Centimeters
+@LGL_UNITS_PICA: Picas
+@LGL_UNITS_FIRST: First supported unit. (Used for bounds checking and iteration through supported units.)
+@LGL_UNITS_LAST: Last supported unit. (Used for bounds checking and iteration through supported units.)
+@LGL_UNITS_INVALID: Invalid unit. (Returned by libglabels units functions when a supported unit cannot be determined.)
+
+<!-- ##### FUNCTION lgl_units_get_id ##### -->
+<para>
+
+</para>
+
+@units:
+@Returns:
+
+
+<!-- ##### FUNCTION lgl_units_from_id ##### -->
+<para>
+
+</para>
+
+@id:
+@Returns:
+
+
+<!-- ##### FUNCTION lgl_units_get_name ##### -->
+<para>
+
+</para>
+
+@units:
+@Returns:
+
+
+<!-- ##### FUNCTION lgl_units_from_name ##### -->
+<para>
+
+</para>
+
+@name:
+@Returns:
+
+
+<!-- ##### FUNCTION lgl_units_get_points_per_unit ##### -->
+<para>
+
+</para>
+
+@units:
+@Returns:
+
+
+<!-- ##### FUNCTION lgl_units_get_units_per_point ##### -->
+<para>
+
+</para>
+
+@units:
+@Returns:
+
+
libglabels-private.h \
db.h \
db.c \
- enums.h \
+ units.h \
+ units.c \
paper.h \
paper.c \
category.h \
libglabelsinclude_HEADERS = \
libglabels.h \
db.h \
- enums.h \
+ units.h \
paper.h \
category.h \
template.h \
+++ /dev/null
-/*
- * enums.h
- * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
- *
- * This file is part of libglabels.
- *
- * libglabels is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * libglabels 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __ENUMS_H__
-#define __ENUMS_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/* Units of distance */
-typedef enum {
- LGL_UNITS_POINT, /* encoded as "pt" */
- LGL_UNITS_INCH, /* encoded as "in" */
- LGL_UNITS_MM, /* encoded as "mm" */
- LGL_UNITS_CM, /* encoded as "cm" */
- LGL_UNITS_PICA, /* encoded as "pc" */
-
- LGL_UNITS_FIRST = LGL_UNITS_POINT,
- LGL_UNITS_LAST = LGL_UNITS_PICA,
-} lglUnitsType;
-
-
-G_END_DECLS
-
-
-#endif /* __ENUMS_H__ */
-
-
-
-/*
- * Local Variables: -- emacs
- * mode: C -- emacs
- * c-basic-offset: 8 -- emacs
- * tab-width: 8 -- emacs
- * indent-tabs-mode: nil -- emacs
- * End: -- emacs
- */
#include <libglabels/paper.h>
#include <libglabels/category.h>
#include <libglabels/template.h>
-#include <libglabels/enums.h>
+#include <libglabels/units.h>
#include <libglabels/str.h>
#include <libglabels/xml-paper.h>
#include <libglabels/xml-category.h>
--- /dev/null
+/*
+ * units.c
+ * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
+ *
+ * This file is part of libglabels.
+ *
+ * libglabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libglabels 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "units.h"
+
+#include <glib/gi18n.h>
+#include <glib.h>
+#include <string.h>
+
+#include "libglabels-private.h"
+
+
+/*========================================================*/
+/* Private macros and constants. */
+/*========================================================*/
+
+#define POINTS_PER_POINT 1.0 /* internal units are points. */
+#define POINTS_PER_INCH 72.0
+#define POINTS_PER_MM 2.83464566929
+#define POINTS_PER_CM (10.0*POINTS_PER_MM)
+#define POINTS_PER_PICA (1.0/12.0)
+
+
+/*========================================================*/
+/* Private types. */
+/*========================================================*/
+
+typedef struct {
+ gchar *id;
+ gchar *name;
+ gdouble points_per_unit;
+} UnitTableEntry;
+
+
+/*========================================================*/
+/* Private globals. */
+/*========================================================*/
+
+static UnitTableEntry unit_table[] = {
+
+ /* The ids are identical to the absolute length units supported in
+ the CSS2 Specification (Section 4.3.2) */
+
+ /* This table must be sorted exactly as the enumerations in lglUnits */
+
+ /* [LGL_UNITS_POINT] */ {"pt", N_("points"), POINTS_PER_POINT},
+ /* [LGL_UNITS_INCH] */ {"in", N_("inches"), POINTS_PER_INCH},
+ /* [LGL_UNITS_MM] */ {"mm", N_("mm"), POINTS_PER_MM},
+ /* [LGL_UNITS_CM] */ {"cm", N_("cm"), POINTS_PER_CM},
+ /* [LGL_UNITS_PICA] */ {"pc", N_("picas"), POINTS_PER_PICA},
+
+};
+
+
+
+/**
+ * lgl_units_get_id:
+ * @units: Units (#lglUnits)
+ *
+ * Return a unique ID string for the given units. This ID is how units
+ * are encoded in libglabels XML files and will remain constant across
+ * all locales. IDs are identical to the absolute length units supported
+ * in the CSS2 Specification (Section 4.3.2).
+ *
+ * Returns: ID string.
+ *
+ */
+const gchar *
+lgl_units_get_id (lglUnits units)
+{
+ if ( (units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST) )
+ {
+ return unit_table[units].id;
+ }
+ else
+ {
+ /* Default to "pt", if invalid. */
+ return unit_table[LGL_UNITS_POINT].id;
+ }
+}
+
+
+/**
+ * lgl_units_from_id:
+ * @id: ID string
+ *
+ * Return the unique #lglUnits for the given ID string.
+ * This ID is how units are encoded in libglabels XML files and will remain
+ * constant across all locales. IDs are identical to the absolute length
+ * units supported in the CSS2 Specification (Section 4.3.2).
+ *
+ * Returns: units (#lglUnits).
+ *
+ */
+lglUnits
+lgl_units_from_id (const gchar *id)
+{
+ lglUnits units;
+
+ /* An empty or missing id defaults to points. */
+ if ( (id == NULL) || (strlen (id) == 0) )
+ {
+ return LGL_UNITS_POINT;
+ }
+
+ for ( units = LGL_UNITS_FIRST; units <= LGL_UNITS_LAST; units++) {
+ if (g_ascii_strcasecmp (id, unit_table[units].id) == 0) {
+ return units;
+ }
+ }
+
+ /* Try name as a fallback. (Will catch some legacy preferences.) */
+ for ( units = LGL_UNITS_FIRST; units <= LGL_UNITS_LAST; units++) {
+ if (g_ascii_strcasecmp (id, unit_table[units].name) == 0) {
+ return units;
+ }
+ }
+
+ /* For compatibility with old preferences. */
+ if (g_ascii_strcasecmp (id, "Millimeters") == 0) {
+ return LGL_UNITS_MM;
+ }
+
+ return LGL_UNITS_INVALID;
+}
+
+
+/**
+ * lgl_units_get_name:
+ * @units: Units (#lglUnits)
+ *
+ * Return a unique name string for the given units. This name is human
+ * readable and will be translated to the current locale.
+ *
+ * Returns: name string.
+ *
+ */
+const gchar *
+lgl_units_get_name (lglUnits units)
+{
+ if ( (units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST) )
+ {
+ return gettext ((char *)unit_table[units].name);
+ }
+ else
+ {
+ /* Default to "points", if invalid. */
+ return gettext ((char *)unit_table[LGL_UNITS_POINT].name);
+ }
+}
+
+
+/**
+ * lgl_units_from_name:
+ * @name: NAME string
+ *
+ * Return the unique #lglUnits for the given name string. This name is
+ * human readable and is expected to be translated to the current locale.
+ *
+ * Returns: units (#lglUnits).
+ *
+ */
+lglUnits
+lgl_units_from_name (const gchar *name)
+{
+ lglUnits units;
+
+ for ( units = LGL_UNITS_FIRST; units <= LGL_UNITS_LAST; units++) {
+ if (g_ascii_strcasecmp (name, gettext ((char *)unit_table[units].name) ) == 0) {
+ return units;
+ }
+ }
+
+ return LGL_UNITS_INVALID;
+}
+
+
+/**
+ * lgl_units_get_points_per_unit:
+ * @units: Units (#lglUnits)
+ *
+ * Return a scale factor for the given units in points/unit.
+ *
+ * Returns: scale factor.
+ *
+ */
+gdouble
+lgl_units_get_points_per_unit (lglUnits units)
+{
+ if ( (units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST) )
+ {
+ return unit_table[units].points_per_unit;
+ }
+ else
+ {
+ /* Default to "points", if invalid. */
+ return 1.0;
+ }
+}
+
+
+/**
+ * lgl_units_get_units_per_point:
+ * @units: Units (#lglUnits)
+ *
+ * Return a scale factor for the given units in units/point.
+ *
+ * Returns: scale factor.
+ *
+ */
+gdouble
+lgl_units_get_units_per_point (lglUnits units)
+{
+ if ( (units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST) )
+ {
+ return 1.0 / unit_table[units].points_per_unit;
+ }
+ else
+ {
+ /* Default to "points", if invalid. */
+ return 1.0;
+ }
+}
+
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */
--- /dev/null
+/*
+ * units.h
+ * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
+ *
+ * This file is part of libglabels.
+ *
+ * libglabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libglabels 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LGL_UNITS_H__
+#define __LGL_UNITS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+/*
+ * Units of distance
+ */
+typedef enum {
+ LGL_UNITS_POINT, /* encoded as "pt" */
+ LGL_UNITS_INCH, /* encoded as "in" */
+ LGL_UNITS_MM, /* encoded as "mm" */
+ LGL_UNITS_CM, /* encoded as "cm" */
+ LGL_UNITS_PICA, /* encoded as "pc" */
+
+ LGL_UNITS_FIRST = LGL_UNITS_POINT,
+ LGL_UNITS_LAST = LGL_UNITS_PICA,
+
+ LGL_UNITS_INVALID = -1,
+} lglUnits;
+
+
+const gchar *lgl_units_get_id (lglUnits units);
+lglUnits lgl_units_from_id (const gchar *id);
+
+const gchar *lgl_units_get_name (lglUnits units);
+lglUnits lgl_units_from_name (const gchar *name);
+
+gdouble lgl_units_get_points_per_unit (lglUnits units);
+gdouble lgl_units_get_units_per_point (lglUnits units);
+
+
+G_END_DECLS
+
+
+#endif /* __LGL_UNITS_H__ */
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */
/* Private macros and constants. */
/*========================================================*/
-#define POINTS_PER_POINT 1.0 /* internal units are points. */
-#define POINTS_PER_INCH 72.0
-#define POINTS_PER_MM 2.83464566929
-#define POINTS_PER_CM (10.0*POINTS_PER_MM)
-#define POINTS_PER_PICA (1.0/12.0)
-
/*========================================================*/
/* Private types. */
/*========================================================*/
-typedef struct {
- xmlChar *name;
- gdouble points_per_unit;
-} UnitTableEntry;
-
/*========================================================*/
/* Private globals. */
/*========================================================*/
-static UnitTableEntry unit_table[] = {
-
- /* These names are identical to the absolute length units supported in
- the CSS2 Specification (Section 4.3.2) */
-
- /* This table must be sorted exactly as the enumerations in lglUnitsType */
-
- /* [LGL_UNITS_POINT] */ {(xmlChar *)"pt", POINTS_PER_POINT},
- /* [LGL_UNITS_INCH] */ {(xmlChar *)"in", POINTS_PER_INCH},
- /* [LGL_UNITS_MM] */ {(xmlChar *)"mm", POINTS_PER_MM},
- /* [LGL_UNITS_CM] */ {(xmlChar *)"cm", POINTS_PER_CM},
- /* [LGL_UNITS_PICA] */ {(xmlChar *)"pc", POINTS_PER_PICA},
-
-};
-
-static lglUnitsType default_units = LGL_UNITS_POINT;
+static lglUnits default_units = LGL_UNITS_POINT;
/****************************************************************************/
{
gdouble val;
xmlChar *string;
- xmlChar *unit;
- gint i;
+ xmlChar *unit_id;
+ lglUnits units;
string = xmlGetProp (node, (xmlChar *)property);
if ( string != NULL ) {
- val = g_strtod ((gchar *)string, (gchar **)&unit);
-
- if (unit != string) {
- unit = (xmlChar *)g_strchug ((gchar *)unit);
- if (strlen ((char *)unit) > 0 ) {
- for (i=LGL_UNITS_FIRST; i<=LGL_UNITS_LAST; i++) {
- if (xmlStrcasecmp (unit, unit_table[i].name) == 0) {
- val *= unit_table[i].points_per_unit;
- break;
- }
- }
- if (i>LGL_UNITS_LAST) {
- g_message ("Line %ld, Node \"%s\", Property \"%s\": Unknown unit \"%s\", assuming points",
- xmlGetLineNo (node), node->name, property,
- unit);
- }
- }
+ val = g_strtod ((gchar *)string, (gchar **)&unit_id);
+
+ if (unit_id != string) {
+ unit_id = (xmlChar *)g_strchug ((gchar *)unit_id);
+ units = lgl_units_from_id ((gchar *)unit_id);
+ if (units != LGL_UNITS_INVALID)
+ {
+ val *= lgl_units_get_points_per_unit (units);
+ }
+ else
+ {
+ g_message ("Line %ld, Node \"%s\", Property \"%s\": Unknown unit \"%s\", assuming points",
+ xmlGetLineNo (node), node->name, property, unit_id);
+ }
}
else {
val = 0.0;
gchar *string_unit;
/* Convert to default units */
- val /= unit_table[default_units].points_per_unit;
+ val *= lgl_units_get_units_per_point (default_units);
/* Guarantee "C" locale by use of g_ascii_formatd */
string = g_ascii_formatd (buffer, G_ASCII_DTOSTR_BUF_SIZE, "%g", val);
- string_unit = g_strdup_printf ("%s%s", string, unit_table[default_units].name);
+ string_unit = g_strdup_printf ("%s%s", string, lgl_units_get_id (default_units));
xmlSetProp (node, (xmlChar *)property, (xmlChar *)string_unit);
g_free (string_unit);
}
/**
* lgl_xml_set_default_units:
- * @units: default units selection (#lglUnitsType)
+ * @units: default units selection (#lglUnits)
*
* Set the default units when formatting lengths. See
* lgl_xml_set_prop_length().
*
*/
void
-lgl_xml_set_default_units (lglUnitsType units)
+lgl_xml_set_default_units (lglUnits units)
{
g_return_if_fail ((units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST));
#include <glib.h>
#include <libxml/tree.h>
-#include "enums.h"
+#include "units.h"
#define LGL_XML_NAME_SPACE "http://snaught.com/glabels/2.2/"
/*
* Misc functions
*/
-void lgl_xml_set_default_units (lglUnitsType units);
+void lgl_xml_set_default_units (lglUnits units);
G_END_DECLS
src/ui-sidebar.h
src/ui-util.c
src/ui-util.h
+src/units-util.c
+src/units-util.h
src/view.c
src/view.h
src/view-barcode.c
libglabels/category.h
libglabels/db.c
libglabels/db.h
-libglabels/enums.h
libglabels/libglabels-private.h
libglabels/paper.c
libglabels/paper.h
libglabels/str.h
libglabels/template.c
libglabels/template.h
+libglabels/units.c
+libglabels/units.h
libglabels/xml.c
libglabels/xml.h
libglabels/xml-category.c
combo-util.h \
builder-util.c \
builder-util.h \
+ units-util.c \
+ units-util.h \
str-util.c \
str-util.h \
color.c \
waste = 0.0;
}
+ cairo_new_path (cr);
cairo_arc (cr, w/2, h/2, w/2+waste, 0.0, 2*G_PI);
cairo_close_path (cr);
GtkWidget *menu_item;
GtkWidget *sub_menu;
const GList *list;
- GList *p;
this->priv = g_new0 (glFontComboMenuPrivate, 1);
#include <gconf/gconf-client.h>
#include <libglabels/libglabels.h>
+#include "font-util.h"
#include "marshal.h"
#include "mini-preview-pixbuf-cache.h"
#include "prefs.h"
#include "font-history.h"
+#include "template-history.h"
#include "debug.h"
#include "window.h"
#include "file.h"
editor->priv->bc_color_combo = gl_color_combo_new (_("Default"),
GL_COLOR_BC_DEFAULT,
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
gtk_box_pack_start (GTK_BOX (editor->priv->bc_color_hbox),
editor->priv->bc_color_combo,
FALSE, FALSE, 0);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_key_radio))) {
color_node->field_flag = TRUE;
- color_node->color = gl_prefs->default_line_color;
+ color_node->color = gl_prefs_model_get_default_line_color (gl_prefs);
color_node->key =
gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_key_combo));
} else {
&is_default);
if (is_default) {
- color_node->color = gl_prefs->default_line_color;
+ color_node->color = gl_prefs_model_get_default_line_color (gl_prefs);
} else {
color_node->color = color;
}
editor->priv->fill_color_combo = gl_color_combo_new (_("No Fill"),
GL_COLOR_NO_FILL,
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
gtk_box_pack_start (GTK_BOX (editor->priv->fill_color_hbox),
editor->priv->fill_color_combo,
FALSE, FALSE, 0);
gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE);
gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE);
gl_color_combo_set_color (GL_COLOR_COMBO(editor->priv->fill_color_combo),
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
/* Un-hide */
gtk_widget_show_all (editor->priv->fill_page_vbox);
editor->priv->line_color_combo = gl_color_combo_new (_("No Line"),
GL_COLOR_NO_LINE,
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
gtk_box_pack_start (GTK_BOX (editor->priv->line_color_hbox),
editor->priv->line_color_combo,
FALSE, FALSE, 0);
gtk_widget_set_sensitive (editor->priv->line_color_combo, TRUE);
gtk_widget_set_sensitive (editor->priv->line_key_combo, FALSE);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->line_width_spin),
- gl_prefs->default_line_width);
+ gl_prefs_model_get_default_line_width (gl_prefs));
gl_color_combo_set_color (GL_COLOR_COMBO(editor->priv->line_color_combo),
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
/* Un-hide */
gtk_widget_show_all (editor->priv->line_page_vbox);
#include "prefs.h"
#include "builder-util.h"
+#include "units-util.h"
#include "object-editor-private.h"
void
gl_object_editor_prepare_lsize_page (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
NULL);
/* Get configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Modify widgets based on configuration */
gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->lsize_r_spin), digits);
void
lsize_prefs_changed_cb (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
gl_debug (DEBUG_EDITOR, "START");
/* Get new configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Update characteristics of r_spin */
editor->priv->stop_signals = TRUE;
#include "prefs.h"
#include "builder-util.h"
+#include "units-util.h"
#include "object-editor-private.h"
void
gl_object_editor_prepare_position_page (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
NULL);
/* Get configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Modify widgets based on configuration */
gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), digits);
void
position_prefs_changed_cb (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
gl_debug (DEBUG_EDITOR, "START");
/* Get new configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Update characteristics of x_spin/y_spin */
editor->priv->stop_signals = TRUE;
#include "color.h"
#include "combo-util.h"
#include "builder-util.h"
+#include "units-util.h"
#include "object-editor-private.h"
void
gl_object_editor_prepare_shadow_page (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->shadow_key_combo));
/* Get configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Modify widgets based on configuration */
gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->shadow_x_spin), digits);
void
shadow_prefs_changed_cb (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
gl_debug (DEBUG_EDITOR, "START");
/* Get new configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Update characteristics of x_spin/y_spin */
editor->priv->stop_signals = TRUE;
#include "prefs.h"
#include "wdgt-chain-button.h"
#include "builder-util.h"
+#include "units-util.h"
#include "object-editor-private.h"
gl_object_editor_prepare_size_page (glObjectEditor *editor,
glObjectEditorOption option)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
/* Get configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Modify widgets based on configuration */
gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->size_w_spin), digits);
void
size_prefs_changed_cb (glObjectEditor *editor)
{
+ lglUnits units;
const gchar *units_string;
gdouble climb_rate;
gint digits;
gl_debug (DEBUG_EDITOR, "START");
/* Get new configuration information */
- units_string = gl_prefs_get_units_string ();
- editor->priv->units_per_point = gl_prefs_get_units_per_point ();
- climb_rate = gl_prefs_get_units_step_size ();
- digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ editor->priv->units_per_point = lgl_units_get_units_per_point (units);
+ climb_rate = gl_units_util_get_step_size (units);
+ digits = gl_units_util_get_precision (units);
/* Update characteristics of w_spin/h_spin */
editor->priv->stop_signals = TRUE;
editor->priv->text_color_combo = gl_color_combo_new (_("Default"),
GL_COLOR_TEXT_DEFAULT,
- gl_prefs->default_text_color);
+ gl_prefs_model_get_default_text_color (gl_prefs));
gtk_box_pack_start (GTK_BOX (editor->priv->text_color_hbox),
editor->priv->text_color_combo,
FALSE, FALSE, 0);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_key_radio))) {
color_node->field_flag = TRUE;
- color_node->color = gl_prefs->default_text_color;
+ color_node->color = gl_prefs_model_get_default_text_color (gl_prefs);
color_node->key =
gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->text_color_key_combo));
} else {
&is_default);
if (is_default) {
- color_node->color = gl_prefs->default_text_color;
+ color_node->color = gl_prefs_model_get_default_text_color (gl_prefs);
} else {
color_node->color = color;
}
GtkWidget *dialog;
gl_debug (DEBUG_PREFS, "START");
- gl_debug (DEBUG_PREFS, "page size = \"%s\"", gl_prefs->default_page_size);
dialog = GTK_WIDGET (g_object_new (GL_TYPE_PREFS_DIALOG, NULL));
dialog->priv->text_color_combo = gl_color_combo_new (_("Default"),
GL_COLOR_TEXT_DEFAULT,
- gl_prefs->default_text_color);
+ gl_prefs_model_get_default_text_color (gl_prefs));
dialog->priv->line_color_combo = gl_color_combo_new (_("No Line"),
GL_COLOR_NO_LINE,
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
dialog->priv->fill_color_combo = gl_color_combo_new (_("No Fill"),
GL_COLOR_NO_FILL,
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
gtk_box_pack_start (GTK_BOX (dialog->priv->text_family_hbox),
dialog->priv->text_family_combo,
{
dialog->priv->stop_signals = TRUE;
- switch (gl_prefs->units) {
+ switch (gl_prefs_model_get_units (gl_prefs)) {
case LGL_UNITS_POINT:
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dialog->priv->units_points_radio),
break;
}
- if ( g_ascii_strcasecmp(gl_prefs->default_page_size, US_LETTER_ID) == 0)
+ if ( g_ascii_strcasecmp(gl_prefs_model_get_default_page_size (gl_prefs), US_LETTER_ID) == 0)
{
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dialog->priv->page_size_us_letter_radio), TRUE);
}
- else if ( g_ascii_strcasecmp(gl_prefs->default_page_size, A4_ID) == 0)
+ else if ( g_ascii_strcasecmp(gl_prefs_model_get_default_page_size (gl_prefs), A4_ID) == 0)
{
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio), TRUE);
else
{
g_message ("Unknown default page size"); /* Shouldn't happen */
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio), TRUE);
}
dialog->priv->stop_signals = FALSE;
dialog->priv->stop_signals = TRUE;
gl_font_combo_set_family (GL_FONT_COMBO (dialog->priv->text_family_combo),
- gl_prefs->default_font_family);
+ gl_prefs_model_get_default_font_family (gl_prefs));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->text_size_spin),
- gl_prefs->default_font_size);
+ gl_prefs_model_get_default_font_size (gl_prefs));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_bold_toggle),
- (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
+ (gl_prefs_model_get_default_font_weight (gl_prefs) == PANGO_WEIGHT_BOLD));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_italic_toggle),
- gl_prefs->default_font_italic_flag);
+ gl_prefs_model_get_default_font_italic_flag (gl_prefs));
gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->text_color_combo),
- gl_prefs->default_text_color);
+ gl_prefs_model_get_default_text_color (gl_prefs));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_left_toggle),
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == GTK_JUSTIFY_LEFT));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_center_toggle),
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == GTK_JUSTIFY_CENTER));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_right_toggle),
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == GTK_JUSTIFY_RIGHT));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->text_line_spacing_spin),
- gl_prefs->default_text_line_spacing);
+ gl_prefs_model_get_default_text_line_spacing (gl_prefs));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->line_width_spin),
- gl_prefs->default_line_width);
+ gl_prefs_model_get_default_line_width (gl_prefs));
gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->line_color_combo),
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->fill_color_combo),
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
dialog->priv->stop_signals = FALSE;
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dialog->priv->units_points_radio)))
{
- gl_prefs->units = LGL_UNITS_POINT;
+ gl_prefs_model_set_units (gl_prefs, LGL_UNITS_POINT);
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dialog->priv->units_inches_radio)))
{
- gl_prefs->units = LGL_UNITS_INCH;
+ gl_prefs_model_set_units (gl_prefs, LGL_UNITS_INCH);
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dialog->priv->units_mm_radio)))
{
- gl_prefs->units = LGL_UNITS_MM;
+ gl_prefs_model_set_units (gl_prefs, LGL_UNITS_MM);
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dialog->priv->page_size_us_letter_radio)))
{
- g_free (gl_prefs->default_page_size);
- gl_prefs->default_page_size = g_strdup (US_LETTER_ID);
+ gl_prefs_model_set_default_page_size (gl_prefs, US_LETTER_ID);
}
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio)))
{
- g_free (gl_prefs->default_page_size);
- gl_prefs->default_page_size = g_strdup (A4_ID);
+ gl_prefs_model_set_default_page_size (gl_prefs, A4_ID);
}
-
- gl_prefs_model_save_settings (gl_prefs);
}
if (dialog->priv->stop_signals) return;
- g_free (gl_prefs->default_font_family);
- gl_prefs->default_font_family =
- gl_font_combo_get_family (GL_FONT_COMBO (dialog->priv->text_family_combo));
- gl_prefs->default_font_size =
- gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_size_spin));
+ gl_prefs_model_set_default_font_family (gl_prefs,
+ gl_font_combo_get_family (GL_FONT_COMBO (dialog->priv->text_family_combo)));
+ gl_prefs_model_set_default_font_size (gl_prefs,
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_size_spin)));
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (dialog->priv->text_bold_toggle)))
{
- gl_prefs->default_font_weight = PANGO_WEIGHT_BOLD;
+ gl_prefs_model_set_default_font_weight (gl_prefs, PANGO_WEIGHT_BOLD);
}
else
{
- gl_prefs->default_font_weight = PANGO_WEIGHT_NORMAL;
+ gl_prefs_model_set_default_font_weight (gl_prefs, PANGO_WEIGHT_NORMAL);
}
- gl_prefs->default_font_italic_flag =
+ gl_prefs_model_set_default_font_italic_flag (gl_prefs,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->text_italic_toggle));
+ (dialog->priv->text_italic_toggle)));
color = gl_color_combo_get_color (GL_COLOR_COMBO(dialog->priv->text_color_combo),
&is_default);
if (!is_default)
{
- gl_prefs->default_text_color = color;
+ gl_prefs_model_set_default_text_color (gl_prefs, color);
}
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (dialog->priv->text_left_toggle)))
{
- gl_prefs->default_text_alignment = GTK_JUSTIFY_LEFT;
+ gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_LEFT);
}
else if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (dialog->priv->text_right_toggle)))
{
- gl_prefs->default_text_alignment = GTK_JUSTIFY_RIGHT;
+ gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_RIGHT);
}
else if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (dialog->priv->text_center_toggle)))
{
- gl_prefs->default_text_alignment = GTK_JUSTIFY_CENTER;
+ gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_CENTER);
}
else
{
/* Should not happen. */
- gl_prefs->default_text_alignment = GTK_JUSTIFY_LEFT;
+ gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_LEFT);
}
- gl_prefs->default_text_line_spacing =
- gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_line_spacing_spin));
+ gl_prefs_model_set_default_text_line_spacing (gl_prefs,
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_line_spacing_spin)));
- gl_prefs->default_line_width =
- gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->line_width_spin));
+ gl_prefs_model_set_default_line_width (gl_prefs,
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->line_width_spin)));
color = gl_color_combo_get_color (GL_COLOR_COMBO(dialog->priv->line_color_combo),
&is_default);
if (!is_default)
{
- gl_prefs->default_line_color = color;
+ gl_prefs_model_set_default_line_color (gl_prefs, color);
}
&is_default);
if (!is_default)
{
- gl_prefs->default_fill_color = color;
+ gl_prefs_model_set_default_fill_color (gl_prefs, color);
}
-
- gl_prefs_model_save_settings (gl_prefs);
}
#include <glib.h>
#include <gtk/gtk.h>
#include <string.h>
+#include <gconf/gconf-client.h>
#include <libglabels/libglabels.h>
#include "marshal.h"
#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_DRAWING_TOOLBAR_VISIBLE "/drawing-toolbar-visible"
/* Default values */
-#define DEFAULT_UNITS_STRING_US units_to_string (LGL_UNITS_INCH)
-#define DEFAULT_PAGE_SIZE_US "US-Letter"
+#define DEFAULT_UNITS_STRING_US lgl_units_get_id (LGL_UNITS_INCH)
+#define DEFAULT_PAGE_SIZE_US "US-Letter"
-#define DEFAULT_UNITS_STRING_METRIC units_to_string (LGL_UNITS_MM)
-#define DEFAULT_PAGE_SIZE_METRIC "A4"
+#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
/* Private types. */
/*========================================================*/
+struct _glPrefsModelPrivate {
+
+ GConfClient *gconf_client;
+
+};
+
enum {
CHANGED,
LAST_SIGNAL
const gchar *key,
gdouble def);
-static lglUnitsType string_to_units (const gchar *string);
-static const gchar *units_to_string (lglUnitsType units);
-
/*****************************************************************************/
/* Boilerplate object stuff. */
static void
-gl_prefs_model_init (glPrefsModel *prefs_model)
+gl_prefs_model_init (glPrefsModel *this)
{
gl_debug (DEBUG_PREFS, "START");
- prefs_model->gconf_client = gconf_client_get_default ();
+ this->priv = g_new0 (glPrefsModelPrivate, 1);
+
+ this->priv->gconf_client = gconf_client_get_default ();
- g_return_if_fail (prefs_model->gconf_client != NULL);
+ g_return_if_fail (this->priv->gconf_client != NULL);
- gconf_client_add_dir (prefs_model->gconf_client,
+ gconf_client_add_dir (this->priv->gconf_client,
BASE_KEY,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
- gconf_client_notify_add (prefs_model->gconf_client,
+ gconf_client_notify_add (this->priv->gconf_client,
BASE_KEY,
- (GConfClientNotifyFunc)notify_cb, prefs_model,
+ (GConfClientNotifyFunc)notify_cb, this,
NULL, NULL);
gl_debug (DEBUG_PREFS, "END");
static void
gl_prefs_model_finalize (GObject *object)
{
- glPrefsModel *prefs_model = GL_PREFS_MODEL (object);
+ glPrefsModel *this = GL_PREFS_MODEL (object);
gl_debug (DEBUG_PREFS, "START");
g_return_if_fail (object && GL_IS_PREFS_MODEL (object));
- g_object_unref (G_OBJECT(prefs_model->gconf_client));
- g_free (prefs_model->default_page_size);
- g_free (prefs_model->default_font_family);
+ g_object_unref (G_OBJECT(this->priv->gconf_client));
+ g_free (this->priv);
G_OBJECT_CLASS (gl_prefs_model_parent_class)->finalize (object);
glPrefsModel *
gl_prefs_model_new (void)
{
- glPrefsModel *prefs_model;
+ glPrefsModel *this;
gl_debug (DEBUG_PREFS, "START");
- prefs_model = 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");
- return prefs_model;
+ return this;
}
/*****************************************************************************/
-/* Save all settings. */
+/* Set units. */
/*****************************************************************************/
-void
-gl_prefs_model_save_settings (glPrefsModel *prefs_model)
+void
+gl_prefs_model_set_units (glPrefsModel *this,
+ lglUnits units)
{
- 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,
+ gconf_client_set_string (this->priv->gconf_client,
BASE_KEY PREF_UNITS,
- units_to_string(prefs_model->units),
+ lgl_units_get_id (units),
NULL);
- lgl_xml_set_default_units (prefs_model->units);
+}
- /* Default page size */
- gconf_client_set_string (prefs_model->gconf_client,
+
+/*****************************************************************************/
+/* Get units. */
+/*****************************************************************************/
+lglUnits
+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
+ {
+ default_units_string = 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);
+
+ /* If invalid, make an educated guess from locale. */
+ if (units == LGL_UNITS_INVALID)
+ {
+ if ( strcmp (pgsize, GTK_PAPER_NAME_LETTER) == 0 )
+ {
+ units = LGL_UNITS_INCH;
+ }
+ else
+ {
+ units = LGL_UNITS_MM;
+ }
+ }
+
+ return units;
+}
+
+
+/*****************************************************************************/
+/* Set default page size. */
+/*****************************************************************************/
+void
+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,
- prefs_model->default_page_size,
+ page_size,
NULL);
+}
+
+/*****************************************************************************/
+/* Get default page size. */
+/*****************************************************************************/
+gchar *
+gl_prefs_model_get_default_page_size (glPrefsModel *this)
+{
+ const gchar *pgsize;
+ const gchar *default_page_size;
+ gchar *page_size;
+ lglPaper *paper;
- /* Text properties */
- gconf_client_set_string (prefs_model->gconf_client,
+ /* 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
+ {
+ default_page_size = 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 ) {
+ g_free (page_size);
+ page_size = g_strdup (DEFAULT_PAGE_SIZE_US);
+ } else {
+ lgl_paper_free (paper);
+ }
+
+ return page_size;
+}
+
+
+/*****************************************************************************/
+/* Set default font family. */
+/*****************************************************************************/
+void
+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,
- prefs_model->default_font_family,
+ 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,
+/*****************************************************************************/
+/* Get default font family. */
+/*****************************************************************************/
+gchar *
+gl_prefs_model_get_default_font_family (glPrefsModel *this)
+{
+ gchar *family;
+
+ family = get_string (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_FAMILY,
+ DEFAULT_FONT_FAMILY);
+
+ return family;
+}
+
+
+/*****************************************************************************/
+/* Set default font size. */
+/*****************************************************************************/
+void
+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);
+}
+
+
+/*****************************************************************************/
+/* Get default font size. */
+/*****************************************************************************/
+gdouble
+gl_prefs_model_get_default_font_size (glPrefsModel *this)
+{
+ gdouble size;
+
+ size = get_float (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_SIZE,
+ DEFAULT_FONT_SIZE);
+
+ return size;
+}
+
+
+/*****************************************************************************/
+/* Set default font weight. */
+/*****************************************************************************/
+void
+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(prefs_model->default_font_weight),
+ gl_str_util_weight_to_string(weight),
NULL);
+}
+
+
+/*****************************************************************************/
+/* Get default font weight. */
+/*****************************************************************************/
+PangoWeight
+gl_prefs_model_get_default_font_weight (glPrefsModel *this)
+{
+ 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);
+
+ return weight;
+}
- gconf_client_set_int (prefs_model->gconf_client,
+
+/*****************************************************************************/
+/* Set default font italic flag. */
+/*****************************************************************************/
+void
+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);
+}
+
+
+/*****************************************************************************/
+/* Get default font italic flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_default_font_italic_flag (glPrefsModel *this)
+{
+ gboolean italic_flag;
+
+ italic_flag = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_FONT_ITALIC_FLAG,
+ DEFAULT_FONT_ITALIC_FLAG);
+
+ return italic_flag;
+}
+
+
+/*****************************************************************************/
+/* Set default text color. */
+/*****************************************************************************/
+void
+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,
- prefs_model->default_text_color,
+ color,
NULL);
+}
+
+
+/*****************************************************************************/
+/* Get default text color. */
+/*****************************************************************************/
+guint
+gl_prefs_model_get_default_text_color (glPrefsModel *this)
+{
+ guint color;
+
+ color = get_int (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_COLOR,
+ DEFAULT_TEXT_COLOR);
- gconf_client_set_string (prefs_model->gconf_client,
+ return color;
+}
+
+
+/*****************************************************************************/
+/* Set default text alignment. */
+/*****************************************************************************/
+void
+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(prefs_model->default_text_alignment),
+ gl_str_util_align_to_string(alignment),
NULL);
+}
+
+
+/*****************************************************************************/
+/* Get default text alignment. */
+/*****************************************************************************/
+PangoAlignment
+gl_prefs_model_get_default_text_alignment (glPrefsModel *this)
+{
+ 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);
+
+ return alignment;
+}
+
- gconf_client_set_float (prefs_model->gconf_client,
+/*****************************************************************************/
+/* Set default text line spacing. */
+/*****************************************************************************/
+void
+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,
- prefs_model->default_text_line_spacing,
+ spacing,
NULL);
+}
+
+
+/*****************************************************************************/
+/* Get default text line spacing. */
+/*****************************************************************************/
+gdouble
+gl_prefs_model_get_default_text_line_spacing (glPrefsModel *this)
+{
+ gdouble spacing;
+
+ spacing = get_float (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
+ DEFAULT_TEXT_LINE_SPACING);
+
+ return spacing;
+}
- /* Line properties */
- gconf_client_set_float (prefs_model->gconf_client,
+
+/*****************************************************************************/
+/* Set default line width. */
+/*****************************************************************************/
+void
+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,
- prefs_model->default_line_width,
+ width,
NULL);
+}
- gconf_client_set_int (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_LINE_COLOR,
- prefs_model->default_line_color,
- NULL);
+/*****************************************************************************/
+/* Get default line width. */
+/*****************************************************************************/
+gdouble
+gl_prefs_model_get_default_line_width (glPrefsModel *this)
+{
+ gdouble width;
- /* Fill properties */
- gconf_client_set_int (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- prefs_model->default_fill_color,
- NULL);
+ width = get_float (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_WIDTH,
+ DEFAULT_LINE_WIDTH);
+
+ return width;
+}
+
+
+/*****************************************************************************/
+/* Set default line color. */
+/*****************************************************************************/
+void
+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);
+}
+
+
+/*****************************************************************************/
+/* Get default line color. */
+/*****************************************************************************/
+guint
+gl_prefs_model_get_default_line_color (glPrefsModel *this)
+{
+ guint color;
+
+ color = get_int (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_LINE_COLOR,
+ DEFAULT_LINE_COLOR);
+
+ return color;
+}
+
+
+/*****************************************************************************/
+/* Set default fill color. */
+/*****************************************************************************/
+void
+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);
+}
- /* Main Toolbar */
- gconf_client_set_bool (prefs_model->gconf_client,
+/*****************************************************************************/
+/* Get default fill color. */
+/*****************************************************************************/
+guint
+gl_prefs_model_get_default_fill_color (glPrefsModel *this)
+{
+ guint color;
+
+ color = get_int (this->priv->gconf_client,
+ BASE_KEY PREF_DEFAULT_FILL_COLOR,
+ DEFAULT_FILL_COLOR);
+
+ return color;
+}
+
+
+/*****************************************************************************/
+/* Set main toolbar visible flag. */
+/*****************************************************************************/
+void
+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,
- prefs_model->main_toolbar_visible,
+ visible,
NULL);
+}
- gconf_client_set_int (prefs_model->gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
- prefs_model->main_toolbar_buttons_style,
- NULL);
- /* Drawing Toolbar */
- gconf_client_set_bool (prefs_model->gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- prefs_model->drawing_toolbar_visible,
- NULL);
+/*****************************************************************************/
+/* Get main toolbar visible flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_main_toolbar_visible (glPrefsModel *this)
+{
+ gboolean visible;
- /* Property Toolbar */
- gconf_client_set_bool (prefs_model->gconf_client,
- BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
- prefs_model->property_toolbar_visible,
- NULL);
+ visible = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
+ TRUE);
- /* View properties */
- gconf_client_set_bool (prefs_model->gconf_client,
- BASE_KEY PREF_GRID_VISIBLE,
- prefs_model->grid_visible,
- NULL);
+ return visible;
+}
- gconf_client_set_bool (prefs_model->gconf_client,
- BASE_KEY PREF_MARKUP_VISIBLE,
- prefs_model->markup_visible,
+
+/*****************************************************************************/
+/* Set drawing toolbar visible flag. */
+/*****************************************************************************/
+void
+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);
+}
- /* Recent files */
- gconf_client_set_int (prefs_model->gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- prefs_model->max_recents,
- NULL);
+/*****************************************************************************/
+/* Get drawing toolbar visible flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_drawing_toolbar_visible (glPrefsModel *this)
+{
+ gboolean visible;
- gconf_client_suggest_sync (prefs_model->gconf_client, NULL);
-
- gl_debug (DEBUG_PREFS, "END");
+ visible = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
+ TRUE);
+
+ return visible;
}
/*****************************************************************************/
-/* Load all settings. */
+/* Set property toolbar visible flag. */
/*****************************************************************************/
void
-gl_prefs_model_load_settings (glPrefsModel *prefs_model)
+gl_prefs_model_set_property_toolbar_visible (glPrefsModel *this,
+ gboolean visible)
{
- const gchar *pgsize, *default_units_string, *default_page_size;
- gchar *string;
- lglPaper *paper;
- GSList *p, *p_next;
-
- 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);
+ gconf_client_set_bool (this->priv->gconf_client,
+ BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
+ visible,
+ NULL);
+}
- /* Make educated guess about locale defaults. */
- pgsize = gtk_paper_size_get_default ();
- if ( strcmp (pgsize,GTK_PAPER_NAME_LETTER) == 0 )
- {
- default_units_string = DEFAULT_UNITS_STRING_US;
- default_page_size = DEFAULT_PAGE_SIZE_US;
- }
- else
- {
- default_units_string = DEFAULT_UNITS_STRING_METRIC;
- default_page_size = DEFAULT_PAGE_SIZE_METRIC;
- }
- /* 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 );
- lgl_xml_set_default_units (prefs_model->units);
-
-
- /* Page size */
- g_free (prefs_model->default_page_size);
- prefs_model->default_page_size =
- get_string (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_PAGE_SIZE,
- default_page_size);
-
- /* Text properties */
- g_free (prefs_model->default_font_family);
- 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_str_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);
+/*****************************************************************************/
+/* Get property toolbar visible flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_property_toolbar_visible (glPrefsModel *this)
+{
+ gboolean visible;
- string =
- get_string (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
- DEFAULT_TEXT_ALIGN_STRING);
- prefs_model->default_text_alignment = gl_str_util_string_to_align( string );
- g_free( string );
+ visible = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
+ TRUE);
- prefs_model->default_text_line_spacing =
- get_float (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
- DEFAULT_TEXT_LINE_SPACING);
+ return visible;
+}
- gl_debug (DEBUG_PREFS, "text_line_spacing = %f", prefs_model->default_text_line_spacing);
- /* 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);
+/*****************************************************************************/
+/* Set grid visible flag. */
+/*****************************************************************************/
+void
+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);
+}
- /* Fill properties */
- prefs_model->default_fill_color =
- get_int (prefs_model->gconf_client,
- BASE_KEY PREF_DEFAULT_FILL_COLOR,
- DEFAULT_FILL_COLOR);
+/*****************************************************************************/
+/* Get grid visible flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_grid_visible (glPrefsModel *this)
+{
+ gboolean visible;
- /* User Inferface/Main Toolbar */
- prefs_model->main_toolbar_visible =
- get_bool (prefs_model->gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
- TRUE);
+ visible = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_GRID_VISIBLE,
+ TRUE);
- prefs_model->main_toolbar_buttons_style =
- get_int (prefs_model->gconf_client,
- BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
- GL_TOOLBAR_SYSTEM);
+ return visible;
+}
- /* User Inferface/Drawing Toolbar */
- prefs_model->drawing_toolbar_visible =
- get_bool (prefs_model->gconf_client,
- BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
- TRUE);
- /* User Inferface/Property Toolbar */
- prefs_model->property_toolbar_visible =
- get_bool (prefs_model->gconf_client,
- BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
- TRUE);
+/*****************************************************************************/
+/* Set markup visible flag. */
+/*****************************************************************************/
+void
+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);
+}
- /* 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);
+/*****************************************************************************/
+/* Get markup visible flag. */
+/*****************************************************************************/
+gboolean
+gl_prefs_model_get_markup_visible (glPrefsModel *this)
+{
+ gboolean visible;
- /* Recent files */
- prefs_model->max_recents =
- get_int (prefs_model->gconf_client,
- BASE_KEY PREF_MAX_RECENTS,
- -1);
+ visible = get_bool (this->priv->gconf_client,
+ BASE_KEY PREF_MARKUP_VISIBLE,
+ TRUE);
+ return visible;
+}
- /* Proof read the default page size -- it must be a valid id. */
- /* (For compatability with older versions.) */
- paper = lgl_db_lookup_paper_from_id (prefs_model->default_page_size);
- if ( paper == NULL ) {
- prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE_US);
- } else {
- lgl_paper_free (paper);
- paper = NULL;
- }
+/*****************************************************************************/
+/* Set max recents. */
+/*****************************************************************************/
+void
+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);
+}
- gl_debug (DEBUG_PREFS, "max_recents = %d", prefs_model->max_recents);
+/*****************************************************************************/
+/* Get max recents. */
+/*****************************************************************************/
+gint
+gl_prefs_model_get_max_recents (glPrefsModel *this)
+{
+ gint max_recents;
- g_signal_emit (G_OBJECT(prefs_model), signals[CHANGED], 0);
+ max_recents = get_int (this->priv->gconf_client,
+ BASE_KEY PREF_MAX_RECENTS,
+ -1);
- gl_debug (DEBUG_PREFS, "END");
+ return max_recents;
}
notify_cb (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
- glPrefsModel *prefs_model)
+ glPrefsModel *this)
{
gl_debug (DEBUG_PREFS, "Key was changed: %s", entry->key);
- gl_prefs_model_load_settings (prefs_model);
+ g_signal_emit (G_OBJECT(this), signals[CHANGED], 0);
}
}
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Utilities to deal with units. */
-/*---------------------------------------------------------------------------*/
-static lglUnitsType
-string_to_units (const gchar *string)
-{
- lglUnitsType units;
-
- if (g_ascii_strcasecmp (string, "Points") == 0) {
- units = LGL_UNITS_POINT;
- } else if (g_ascii_strcasecmp (string, "Inches") == 0) {
- units = LGL_UNITS_INCH;
- } else if (g_ascii_strcasecmp (string, "Millimeters") == 0) {
- units = LGL_UNITS_MM;
- } else {
- units = LGL_UNITS_INCH;
- }
-
- return units;
-}
-
-
-static const
-gchar *units_to_string (lglUnitsType units)
-{
- switch (units) {
- case LGL_UNITS_POINT:
- return "Points";
- break;
- case LGL_UNITS_INCH:
- return "Inches";
- break;
- case LGL_UNITS_MM:
- return "Millimeters";
- break;
- default:
- return "Inches";
- break;
- }
-}
-
-
#define __PREFS_MODEL_H__
#include <glib-object.h>
-#include <gconf/gconf-client.h>
#include <pango/pango.h>
#include <libglabels/libglabels.h>
G_BEGIN_DECLS
-typedef enum {
- GL_TOOLBAR_SYSTEM = 0,
- GL_TOOLBAR_ICONS,
- GL_TOOLBAR_ICONS_AND_TEXT
-} glToolbarSetting;
#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))
typedef struct _glPrefsModel glPrefsModel;
typedef struct _glPrefsModelClass glPrefsModelClass;
-
typedef struct _glPrefsModelPrivate glPrefsModelPrivate;
struct _glPrefsModel {
- GObject *object;
+ GObject parent;
- GConfClient *gconf_client;
+ glPrefsModelPrivate *priv;
+};
- /* Units */
- lglUnitsType units;
+struct _glPrefsModelClass {
+ GObjectClass parent_class;
- /* Page size */
- gchar *default_page_size;
+ void (*changed) (glPrefsModel *prefs_model,
+ gpointer user_data);
+};
- /* Text properties */
- gchar *default_font_family;
- gdouble default_font_size;
- PangoWeight default_font_weight;
- gboolean default_font_italic_flag;
- guint default_text_color;
- PangoAlignment default_text_alignment;
- gdouble default_text_line_spacing;
-
- /* 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;
+GType gl_prefs_model_get_type (void) G_GNUC_CONST;
- /* User Interface/Drawing Toolbar */
- gboolean drawing_toolbar_visible;
+glPrefsModel *gl_prefs_model_new (void);
- /* User Interface/Property Toolbar */
- gboolean property_toolbar_visible;
- /* View properties */
- gboolean grid_visible;
- gboolean markup_visible;
+void gl_prefs_model_set_units (glPrefsModel *this,
+ lglUnits units);
- /* Recent files */
- gint max_recents;
+lglUnits gl_prefs_model_get_units (glPrefsModel *this);
-};
-struct _glPrefsModelClass {
- GObjectClass parent_class;
+void gl_prefs_model_set_default_page_size (glPrefsModel *this,
+ const gchar *page_size);
- void (*changed) (glPrefsModel *prefs_model, gpointer user_data);
-};
+gchar *gl_prefs_model_get_default_page_size (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_font_family (glPrefsModel *this,
+ const gchar *family);
+
+gchar *gl_prefs_model_get_default_font_family (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_font_size (glPrefsModel *this,
+ gdouble size);
+
+gdouble gl_prefs_model_get_default_font_size (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_font_weight (glPrefsModel *this,
+ PangoWeight weight);
+
+PangoWeight gl_prefs_model_get_default_font_weight (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_font_italic_flag (glPrefsModel *this,
+ gboolean italic_flag);
+
+gboolean gl_prefs_model_get_default_font_italic_flag (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_text_color (glPrefsModel *this,
+ guint color);
+
+guint gl_prefs_model_get_default_text_color (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_text_alignment (glPrefsModel *this,
+ PangoAlignment alignment);
+
+PangoAlignment gl_prefs_model_get_default_text_alignment (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_text_line_spacing (glPrefsModel *this,
+ gdouble spacing);
+
+gdouble gl_prefs_model_get_default_text_line_spacing (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_line_width (glPrefsModel *this,
+ gdouble width);
+
+gdouble gl_prefs_model_get_default_line_width (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_line_color (glPrefsModel *this,
+ guint color);
+
+guint gl_prefs_model_get_default_line_color (glPrefsModel *this);
+
+
+void gl_prefs_model_set_default_fill_color (glPrefsModel *this,
+ guint color);
+
+guint gl_prefs_model_get_default_fill_color (glPrefsModel *this);
+
+
+void gl_prefs_model_set_main_toolbar_visible (glPrefsModel *this,
+ gboolean visible);
+
+gboolean gl_prefs_model_get_main_toolbar_visible (glPrefsModel *this);
+
+
+void gl_prefs_model_set_drawing_toolbar_visible (glPrefsModel *this,
+ gboolean visible);
+
+gboolean gl_prefs_model_get_drawing_toolbar_visible (glPrefsModel *this);
+
+
+void gl_prefs_model_set_property_toolbar_visible (glPrefsModel *this,
+ gboolean visible);
+
+gboolean gl_prefs_model_get_property_toolbar_visible (glPrefsModel *this);
+
+
+void gl_prefs_model_set_grid_visible (glPrefsModel *this,
+ gboolean visible);
+
+gboolean gl_prefs_model_get_grid_visible (glPrefsModel *this);
+
+
+void gl_prefs_model_set_markup_visible (glPrefsModel *this,
+ gboolean visible);
+gboolean gl_prefs_model_get_markup_visible (glPrefsModel *this);
-GType gl_prefs_model_get_type (void) G_GNUC_CONST;
-glPrefsModel *gl_prefs_model_new (void);
+void gl_prefs_model_set_max_recents (glPrefsModel *this,
+ gint max_recents);
-void gl_prefs_model_save_settings (glPrefsModel *prefs_model);
+gint gl_prefs_model_get_max_recents (glPrefsModel *this);
-void gl_prefs_model_load_settings (glPrefsModel *prefs_model);
G_END_DECLS
/*========================================================*/
-\f
/*****************************************************************************/
/* Initialize preferences module. */
/*****************************************************************************/
gl_prefs = gl_prefs_model_new ();
- gl_prefs_model_load_settings (gl_prefs);
-
gl_debug (DEBUG_PREFS, "END");
}
-\f
-/****************************************************************************/
-/* Get string representing desired units. */
-/****************************************************************************/
-const gchar *
-gl_prefs_get_page_size (void)
-{
- return (gl_prefs->default_page_size);
-}
-
-/****************************************************************************/
-/* Get desired units. */
-/****************************************************************************/
-lglUnitsType
-gl_prefs_get_units (void)
-{
- return gl_prefs->units;
-}
-
-/****************************************************************************/
-/* Get desired units per point. */
-/****************************************************************************/
-gdouble
-gl_prefs_get_units_per_point (void)
-{
-
- switch (gl_prefs->units) {
- case LGL_UNITS_POINT:
- return 1.0; /* points */
- case LGL_UNITS_INCH:
- return 1.0 / 72.0; /* inches */
- case LGL_UNITS_MM:
- return 0.35277778; /* mm */
- default:
- g_message ("Illegal units"); /* Should not happen */
- return 1.0;
- }
-}
-
-/****************************************************************************/
-/* Get precision for desired units. */
-/****************************************************************************/
-gint
-gl_prefs_get_units_precision (void)
-{
-
- switch (gl_prefs->units) {
- case LGL_UNITS_POINT:
- return 1; /* points */
- case LGL_UNITS_INCH:
- return 3; /* inches */
- case LGL_UNITS_MM:
- return 1; /* mm */
- default:
- g_message ("Illegal units"); /* Should not happen */
- return 1.0;
- }
-}
-
-/****************************************************************************/
-/* Get step size for desired units. */
-/****************************************************************************/
-gdouble
-gl_prefs_get_units_step_size (void)
-{
-
- switch (gl_prefs->units) {
- case LGL_UNITS_POINT:
- return 0.1; /* points */
- case LGL_UNITS_INCH:
- return 0.001; /* inches */
- case LGL_UNITS_MM:
- return 0.1; /* mm */
- default:
- g_message ("Illegal units"); /* Should not happen */
- return 1.0;
- }
-}
-
-/****************************************************************************/
-/* Get string representing desired units. */
-/****************************************************************************/
-const gchar *
-gl_prefs_get_units_string (void)
-{
-
- switch (gl_prefs->units) {
- case LGL_UNITS_POINT:
- return _("points");
- case LGL_UNITS_INCH:
- return _("inches");
- case LGL_UNITS_MM:
- return _("mm");
- default:
- g_message ("Illegal units"); /* Should not happen */
- return _("points");
- }
-}
-
/*
G_BEGIN_DECLS
-
extern glPrefsModel *gl_prefs;
-
void gl_prefs_init (void);
-const gchar *gl_prefs_get_page_size (void);
-
-lglUnitsType gl_prefs_get_units (void);
-
-const gchar *gl_prefs_get_units_string (void);
-
-gdouble gl_prefs_get_units_per_point (void);
-
-gdouble gl_prefs_get_units_step_size (void);
-
-gint gl_prefs_get_units_precision (void);
-
G_END_DECLS
gtk_recent_chooser_menu_new_for_manager (model);
gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (recent_menu), FALSE);
gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), TRUE);
- gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (recent_menu), gl_prefs->max_recents);
+ gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (recent_menu),
+ gl_prefs_model_get_max_recents (gl_prefs));
gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu), GTK_RECENT_SORT_MRU);
gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (recent_menu), TRUE);
#include "print-op-dialog.h"
#include "combo-util.h"
#include "builder-util.h"
+#include "units-util.h"
#include "debug.h"
static void
gl_template_designer_construct (glTemplateDesigner *dialog)
{
+ lglUnits units;
GdkPixbuf *logo;
gl_debug (DEBUG_TEMPLATE, "START");
g_return_if_fail (dialog->priv != NULL);
/* Initialize units stuff from prefs */
- dialog->priv->units_string = gl_prefs_get_units_string ();
- dialog->priv->units_per_point = gl_prefs_get_units_per_point ();
- dialog->priv->climb_rate = gl_prefs_get_units_step_size ();
- dialog->priv->digits = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ dialog->priv->units_string = lgl_units_get_name (units);
+ dialog->priv->units_per_point = lgl_units_get_units_per_point (units);
+ dialog->priv->climb_rate = gl_units_util_get_step_size (units);
+ dialog->priv->digits = gl_units_util_get_precision (units);
gtk_window_set_title (GTK_WINDOW(dialog), _("gLabels Template Designer"));
page_sizes = lgl_db_get_paper_name_list ();
gl_combo_util_set_strings (GTK_COMBO_BOX (dialog->priv->pg_size_combo), page_sizes);
lgl_db_free_paper_name_list (page_sizes);
- default_page_size_id = gl_prefs_get_page_size ();
+ default_page_size_id = gl_prefs_model_get_default_page_size (gl_prefs);
default_page_size_name = lgl_db_lookup_paper_name_from_id (default_page_size_id);
gl_combo_util_set_active_text (GTK_COMBO_BOX (dialog->priv->pg_size_combo), default_page_size_name);
g_free (default_page_size_name);
static void
apply_cb (glTemplateDesigner *dialog)
{
+ lglUnits units;
lglTemplate *template;
gchar *name;
+
+ units = gl_prefs_model_get_units (gl_prefs);
+ lgl_xml_set_default_units (units);
template = build_template (dialog);
lgl_db_register_template (template);
state = gtk_toggle_action_get_active (action);
- gl_prefs->property_toolbar_visible = state;
+ gl_prefs_model_set_property_toolbar_visible (gl_prefs, state);
if (state) {
gtk_widget_show (GTK_WIDGET (window->property_bar));
} else {
gtk_widget_hide (GTK_WIDGET (window->property_bar));
}
- gl_prefs_model_save_settings (gl_prefs);
gl_debug (DEBUG_COMMANDS, "END");
}
}
}
- gl_prefs->grid_visible = state;
- gl_prefs_model_save_settings (gl_prefs);
+ gl_prefs_model_set_grid_visible (gl_prefs, state);
gl_debug (DEBUG_COMMANDS, "END");
}
}
}
- gl_prefs->markup_visible = state;
- gl_prefs_model_save_settings (gl_prefs);
+ gl_prefs_model_set_markup_visible (gl_prefs, state);
gl_debug (DEBUG_COMMANDS, "END");
}
gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar);
- this->priv->font_family_combo = gl_font_combo_new (gl_prefs->default_font_family);
+ this->priv->font_family_combo =
+ gl_font_combo_new (gl_prefs_model_get_default_font_family (gl_prefs));
gtk_container_add (GTK_CONTAINER (this->priv->font_family_eventbox),
this->priv->font_family_combo);
gl_color_combo_button_new (pixbuf,
_("Default"),
GL_COLOR_TEXT_DEFAULT,
- gl_prefs->default_text_color);
+ gl_prefs_model_get_default_text_color (gl_prefs));
gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button),
GTK_RELIEF_NONE);
g_object_unref (G_OBJECT (pixbuf));
gl_color_combo_button_new (pixbuf,
_("No Fill"),
GL_COLOR_NO_FILL,
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->fill_color_button),
GTK_RELIEF_NONE);
g_object_unref (G_OBJECT (pixbuf));
gl_color_combo_button_new (pixbuf,
_("No Line"),
GL_COLOR_NO_LINE,
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->line_color_button),
GTK_RELIEF_NONE);
g_object_unref (G_OBJECT (pixbuf));
/* Font size entry widget */
gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
- gl_prefs->default_font_size);
+ gl_prefs_model_get_default_font_size (gl_prefs));
g_signal_connect (G_OBJECT (this->priv->font_size_spin),
"changed", G_CALLBACK (font_size_changed_cb), this);
/* Bold and Italic toggles */
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
- (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
+ (gl_prefs_model_get_default_font_weight (gl_prefs) == PANGO_WEIGHT_BOLD));
g_signal_connect (G_OBJECT (this->priv->font_bold_toggle),
"toggled", G_CALLBACK (font_bold_toggled_cb), this);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
- gl_prefs->default_font_italic_flag);
+ gl_prefs_model_get_default_font_italic_flag (gl_prefs));
g_signal_connect (G_OBJECT (this->priv->font_italic_toggle),
"toggled", G_CALLBACK (font_italic_toggled_cb), this);
/* Text alignment radio group */
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
- (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_LEFT));
g_signal_connect (G_OBJECT (this->priv->text_align_left_radio),
"toggled", G_CALLBACK (text_align_toggled_cb), this);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
- (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_CENTER));
g_signal_connect (G_OBJECT (this->priv->text_align_center_radio),
"toggled", G_CALLBACK (text_align_toggled_cb), this);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
- (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT));
+ (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_RIGHT));
g_signal_connect (G_OBJECT (this->priv->text_align_right_radio),
"toggled", G_CALLBACK (text_align_toggled_cb), this);
/* Text color widget */
gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button),
- gl_prefs->default_text_color);
+ gl_prefs_model_get_default_text_color (gl_prefs));
g_signal_connect (G_OBJECT (this->priv->text_color_button),
"color_changed",
G_CALLBACK (text_color_changed_cb), this);
/* Fill color widget */
gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->fill_color_button),
- gl_prefs->default_fill_color);
+ gl_prefs_model_get_default_fill_color (gl_prefs));
g_signal_connect (G_OBJECT (this->priv->fill_color_button),
"color_changed",
G_CALLBACK (fill_color_changed_cb), this);
/* Line color widget */
gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->line_color_button),
- gl_prefs->default_line_color);
+ gl_prefs_model_get_default_line_color (gl_prefs));
g_signal_connect (G_OBJECT (this->priv->line_color_button),
"color_changed",
G_CALLBACK (line_color_changed_cb), this);
if (is_default)
{
- text_color_node->color = gl_prefs->default_text_color;
+ text_color_node->color = gl_prefs_model_get_default_text_color (gl_prefs);
gl_view_set_selection_text_color (this->priv->view,
text_color_node);
gl_view_set_default_text_color (this->priv->view,
- gl_prefs->default_text_color);
+ text_color_node->color);
}
else
{
if (strcmp (name, "ViewMainToolBar") == 0)
{
- gl_prefs->main_toolbar_visible = state;
+ gl_prefs_model_set_main_toolbar_visible (gl_prefs, state);
set_app_main_toolbar_style (ui);
- gl_prefs_model_save_settings (gl_prefs);
}
if (strcmp (name, "ViewDrawingToolBar") == 0)
{
- gl_prefs->drawing_toolbar_visible = state;
+ gl_prefs_model_set_drawing_toolbar_visible (gl_prefs, state);
set_app_drawing_toolbar_style (ui);
- gl_prefs_model_save_settings (gl_prefs);
}
gl_debug (DEBUG_UI, "");
/* Updated view menu */
gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBar",
- gl_prefs->main_toolbar_visible);
+ gl_prefs_model_get_main_toolbar_visible (gl_prefs));
toolbar = gtk_ui_manager_get_widget (ui, "/MainToolBar");
- if (gl_prefs->main_toolbar_visible) {
+ if (gl_prefs_model_get_main_toolbar_visible (gl_prefs)) {
gtk_widget_show_all (toolbar);
} else {
gtk_widget_hide (toolbar);
/* Updated view menu */
gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBar",
- gl_prefs->drawing_toolbar_visible);
+ gl_prefs_model_get_drawing_toolbar_visible (gl_prefs));
toolbar = gtk_ui_manager_get_widget (ui, "/DrawingToolBar");
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
- if (gl_prefs->drawing_toolbar_visible) {
+ if (gl_prefs_model_get_drawing_toolbar_visible (gl_prefs)) {
gtk_widget_show_all (toolbar);
} else {
gtk_widget_hide (toolbar);
g_return_if_fail (ui && GTK_IS_UI_MANAGER(ui));
gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewGrid",
- gl_prefs->grid_visible);
+ gl_prefs_model_get_grid_visible (gl_prefs));
gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewMarkup",
- gl_prefs->markup_visible);
+ gl_prefs_model_get_markup_visible (gl_prefs));
gl_debug (DEBUG_UI, "END");
}
--- /dev/null
+/*
+ * units-util.c
+ * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
+ *
+ * This file is part of gLabels.
+ *
+ * gLabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gLabels 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 gLabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "units-util.h"
+
+#include "debug.h"
+
+
+/*========================================================*/
+/* Private macros and constants. */
+/*========================================================*/
+
+
+/*========================================================*/
+/* Private types. */
+/*========================================================*/
+
+
+/*========================================================*/
+/* Private globals. */
+/*========================================================*/
+
+
+/*========================================================*/
+/* Private function prototypes. */
+/*========================================================*/
+
+
+/****************************************************************************/
+/* Get step size for desired units. */
+/****************************************************************************/
+gdouble
+gl_units_util_get_step_size (lglUnits units)
+{
+
+ switch (units) {
+ case LGL_UNITS_POINT:
+ return 0.1; /* points */
+ case LGL_UNITS_INCH:
+ return 0.001; /* inches */
+ case LGL_UNITS_MM:
+ return 0.1; /* mm */
+ default:
+ g_message ("Illegal units"); /* Should not happen */
+ return 1.0;
+ }
+}
+
+
+/****************************************************************************/
+/* Get precision for desired units. */
+/****************************************************************************/
+gint
+gl_units_util_get_precision (lglUnits units)
+{
+
+ switch (units) {
+ case LGL_UNITS_POINT:
+ return 1; /* points */
+ case LGL_UNITS_INCH:
+ return 3; /* inches */
+ case LGL_UNITS_MM:
+ return 1; /* mm */
+ default:
+ g_message ("Illegal units"); /* Should not happen */
+ return 1.0;
+ }
+}
+
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */
--- /dev/null
+/*
+ * units-util.h
+ * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
+ *
+ * This file is part of gLabels.
+ *
+ * gLabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gLabels 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 gLabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __UNITS_UTIL_H__
+#define __UNITS_UTIL_H__
+
+#include <libglabels/libglabels.h>
+
+G_BEGIN_DECLS
+
+
+gdouble gl_units_util_get_step_size (lglUnits units);
+
+gint gl_units_util_get_precision (lglUnits units);
+
+
+G_END_DECLS
+
+#endif /* __UNITS_UTIL_H__ */
+
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */
/*
* Defaults from preferences
*/
- gl_view_set_default_font_family (view, gl_prefs->default_font_family);
- gl_view_set_default_font_size (view, gl_prefs->default_font_size);
- gl_view_set_default_font_weight (view, gl_prefs->default_font_weight);
- gl_view_set_default_font_italic_flag (view, gl_prefs->default_font_italic_flag);
- gl_view_set_default_text_color (view, gl_prefs->default_text_color);
- gl_view_set_default_text_alignment (view, gl_prefs->default_text_alignment);
- gl_view_set_default_text_line_spacing (view, gl_prefs->default_text_line_spacing);
- gl_view_set_default_line_width (view, gl_prefs->default_line_width);
- gl_view_set_default_line_color (view, gl_prefs->default_line_color);
- gl_view_set_default_fill_color (view, gl_prefs->default_fill_color);
+ gl_view_set_default_font_family (view, gl_prefs_model_get_default_font_family (gl_prefs));
+ gl_view_set_default_font_size (view, gl_prefs_model_get_default_font_size (gl_prefs));
+ gl_view_set_default_font_weight (view, gl_prefs_model_get_default_font_weight (gl_prefs));
+ gl_view_set_default_font_italic_flag (view, gl_prefs_model_get_default_font_italic_flag (gl_prefs));
+ gl_view_set_default_text_color (view, gl_prefs_model_get_default_text_color (gl_prefs));
+ gl_view_set_default_text_alignment (view, gl_prefs_model_get_default_text_alignment (gl_prefs));
+ gl_view_set_default_text_line_spacing (view, gl_prefs_model_get_default_text_line_spacing (gl_prefs));
+ gl_view_set_default_line_width (view, gl_prefs_model_get_default_line_width (gl_prefs));
+ gl_view_set_default_line_color (view, gl_prefs_model_get_default_line_color (gl_prefs));
+ gl_view_set_default_fill_color (view, gl_prefs_model_get_default_fill_color (gl_prefs));
gl_debug (DEBUG_VIEW, "END");
}
recent_list = gl_template_history_model_get_name_list (gl_template_history);
load_recent_list (media_select->priv->recent_store, recent_selection, recent_list);
- page_size_id = gl_prefs_get_page_size ();
+ page_size_id = gl_prefs_model_get_default_page_size (gl_prefs);
page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id);
/* Brand selection control */
static gchar *
get_label_size_desc (const lglTemplate *template)
{
- lglUnitsType units;
+ lglUnits units;
const gchar *units_string;
gdouble units_per_point;
const lglTemplateFrame *frame;
gchar *string = NULL;
- units = gl_prefs_get_units ();
- units_string = gl_prefs_get_units_string ();
- units_per_point = gl_prefs_get_units_per_point ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_string = lgl_units_get_name (units);
+ units_per_point = lgl_units_get_units_per_point (units);
frame = (lglTemplateFrame *)template->frames->data;
#include "xml-label.h"
#include "prefs.h"
#include "file.h"
+#include "units-util.h"
#include "debug.h"
gl_view_zoom_to_fit (GL_VIEW(window->view));
- if (gl_prefs->grid_visible) {
+ if (gl_prefs_model_get_grid_visible (gl_prefs)) {
gl_view_show_grid (GL_VIEW(window->view));
} else {
gl_view_hide_grid (GL_VIEW(window->view));
}
- if (gl_prefs->markup_visible) {
+ if (gl_prefs_model_get_markup_visible (gl_prefs)) {
gl_view_show_markup (GL_VIEW(window->view));
} else {
gl_view_hide_markup (GL_VIEW(window->view));
gdouble y,
glWindow *window)
{
- gchar *string;
- gdouble units_per_point;
- gint units_precision;
+ gchar *string;
+ lglUnits units;
+ gdouble units_per_point;
+ gint units_precision;
gl_debug (DEBUG_WINDOW, "START");
g_return_if_fail (view && GL_IS_VIEW (view));
g_return_if_fail (window && GL_IS_WINDOW (window));
- units_per_point = gl_prefs_get_units_per_point ();
- units_precision = gl_prefs_get_units_precision ();
+ units = gl_prefs_model_get_units (gl_prefs);
+ units_per_point = lgl_units_get_units_per_point (units);
+ units_precision = gl_units_util_get_precision (units);
string = g_strdup_printf ("%.*f, %.*f",
units_precision, x*units_per_point,
#include "label-barcode.h"
#include "xml-label-04.h"
#include "str-util.h"
+#include "prefs.h"
#include "debug.h"
xml_label_to_doc (glLabel *label,
glXMLLabelStatus *status)
{
+ lglUnits units;
xmlDocPtr doc;
xmlNsPtr ns;
glMerge *merge;
LIBXML_TEST_VERSION;
+ units = gl_prefs_model_get_units (gl_prefs);
+ lgl_xml_set_default_units (units);
+
doc = xmlNewDoc ((xmlChar *)"1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, (xmlChar *)"Glabels-document", NULL);