3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
25 #include <glib/gi18n.h>
26 #include <libglabels/libglabels.h>
30 glPrefsModel *gl_prefs = NULL;
32 /*========================================================*/
33 /* Private macros and constants. */
34 /*========================================================*/
37 /*========================================================*/
39 /*========================================================*/
42 /*========================================================*/
43 /* Private globals. */
44 /*========================================================*/
47 /*========================================================*/
48 /* Private function prototypes. */
49 /*========================================================*/
53 /*****************************************************************************/
54 /* Initialize preferences module. */
55 /*****************************************************************************/
59 gl_debug (DEBUG_PREFS, "START");
61 gl_prefs = gl_prefs_model_new ();
63 gl_prefs_model_load_settings (gl_prefs);
65 gl_debug (DEBUG_PREFS, "END");
69 /****************************************************************************/
70 /* Get string representing desired units. */
71 /****************************************************************************/
73 gl_prefs_get_page_size (void)
75 return (gl_prefs->default_page_size);
78 /****************************************************************************/
79 /* Get desired units. */
80 /****************************************************************************/
82 gl_prefs_get_units (void)
84 return gl_prefs->units;
87 /****************************************************************************/
88 /* Get desired units per point. */
89 /****************************************************************************/
91 gl_prefs_get_units_per_point (void)
94 switch (gl_prefs->units) {
96 return 1.0; /* points */
98 return 1.0 / 72.0; /* inches */
100 return 0.35277778; /* mm */
102 g_message ("Illegal units"); /* Should not happen */
107 /****************************************************************************/
108 /* Get precision for desired units. */
109 /****************************************************************************/
111 gl_prefs_get_units_precision (void)
114 switch (gl_prefs->units) {
115 case LGL_UNITS_POINT:
116 return 1; /* points */
118 return 3; /* inches */
122 g_message ("Illegal units"); /* Should not happen */
127 /****************************************************************************/
128 /* Get step size for desired units. */
129 /****************************************************************************/
131 gl_prefs_get_units_step_size (void)
134 switch (gl_prefs->units) {
135 case LGL_UNITS_POINT:
136 return 0.1; /* points */
138 return 0.001; /* inches */
142 g_message ("Illegal units"); /* Should not happen */
147 /****************************************************************************/
148 /* Get string representing desired units. */
149 /****************************************************************************/
151 gl_prefs_get_units_string (void)
154 switch (gl_prefs->units) {
155 case LGL_UNITS_POINT:
162 g_message ("Illegal units"); /* Should not happen */
167 /****************************************************************************/
168 /* Add template to recent template list. */
169 /****************************************************************************/
171 gl_prefs_add_recent_template (const gchar *name)
176 * If already in list, remove that entry.
178 p = g_slist_find_custom (gl_prefs->recent_templates,
180 (GCompareFunc)lgl_str_utf8_casecmp);
183 gl_prefs->recent_templates =
184 g_slist_remove_link (gl_prefs->recent_templates, p);
190 * Now prepend to list.
192 gl_prefs->recent_templates =
193 g_slist_prepend (gl_prefs->recent_templates, g_strdup (name));
196 * Truncate list to maximum size
198 while (g_slist_length (gl_prefs->recent_templates) > gl_prefs->max_recent_templates)
200 p = g_slist_last (gl_prefs->recent_templates);
201 gl_prefs->recent_templates =
202 g_slist_remove_link (gl_prefs->recent_templates, p);
210 gl_prefs_model_save_settings (gl_prefs);
217 * Local Variables: -- emacs
219 * c-basic-offset: 8 -- emacs
220 * tab-width: 8 -- emacs
221 * indent-tabs-mode: nil -- emacs