]> git.sur5r.net Git - glabels/blob - glabels2/src/prefs.c
2007-09-14 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / prefs.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (GLABELS) Label and Business Card Creation program for GNOME
5  *
6  *  prefs.c:  Application preferences module
7  *
8  *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  */
24 #include <config.h>
25
26 #include "prefs.h"
27
28 #include <glib/gi18n.h>
29
30 #include "debug.h"
31
32 glPrefsModel      *gl_prefs     = NULL;
33
34 /*========================================================*/
35 /* Private macros and constants.                          */
36 /*========================================================*/
37
38
39 /*========================================================*/
40 /* Private types.                                         */
41 /*========================================================*/
42
43
44 /*========================================================*/
45 /* Private globals.                                       */
46 /*========================================================*/
47
48
49 /*========================================================*/
50 /* Private function prototypes.                           */
51 /*========================================================*/
52
53
54 \f
55 /*****************************************************************************/
56 /* Initialize preferences module.                                            */
57 /*****************************************************************************/
58 void 
59 gl_prefs_init (void)
60 {
61         gl_debug (DEBUG_PREFS, "START");
62
63         gl_prefs = gl_prefs_model_new ();
64
65         gl_prefs_model_load_settings (gl_prefs);
66
67         gl_debug (DEBUG_PREFS, "END");
68 }
69
70 \f
71 /****************************************************************************/
72 /* Get string representing desired units.                                   */
73 /****************************************************************************/
74 const gchar *
75 gl_prefs_get_page_size (void)
76 {
77         return (gl_prefs->default_page_size);
78 }
79
80 /****************************************************************************/
81 /* Get desired units.                                                       */
82 /****************************************************************************/
83 glUnitsType
84 gl_prefs_get_units (void)
85 {
86         return gl_prefs->units;
87 }
88
89 /****************************************************************************/
90 /* Get desired units per point.                                             */
91 /****************************************************************************/
92 gdouble
93 gl_prefs_get_units_per_point (void)
94 {
95
96         switch (gl_prefs->units) {
97         case GL_UNITS_POINT:
98                 return 1.0;     /* points */
99         case GL_UNITS_INCH:
100                 return 1.0 / 72.0;      /* inches */
101         case GL_UNITS_MM:
102                 return 0.35277778;      /* mm */
103         default:
104                 g_message ("Illegal units");    /* Should not happen */
105                 return 1.0;
106         }
107 }
108
109 /****************************************************************************/
110 /* Get precision for desired units.                                         */
111 /****************************************************************************/
112 gint
113 gl_prefs_get_units_precision (void)
114 {
115
116         switch (gl_prefs->units) {
117         case GL_UNITS_POINT:
118                 return 1;       /* points */
119         case GL_UNITS_INCH:
120                 return 3;       /* inches */
121         case GL_UNITS_MM:
122                 return 1;       /* mm */
123         default:
124                 g_message ("Illegal units");    /* Should not happen */
125                 return 1.0;
126         }
127 }
128
129 /****************************************************************************/
130 /* Get step size for desired units.                                         */
131 /****************************************************************************/
132 gdouble
133 gl_prefs_get_units_step_size (void)
134 {
135
136         switch (gl_prefs->units) {
137         case GL_UNITS_POINT:
138                 return 0.1;     /* points */
139         case GL_UNITS_INCH:
140                 return 0.001;   /* inches */
141         case GL_UNITS_MM:
142                 return 0.1;     /* mm */
143         default:
144                 g_message ("Illegal units");    /* Should not happen */
145                 return 1.0;
146         }
147 }
148
149 /****************************************************************************/
150 /* Get string representing desired units.                                   */
151 /****************************************************************************/
152 const gchar *
153 gl_prefs_get_units_string (void)
154 {
155
156         switch (gl_prefs->units) {
157         case GL_UNITS_POINT:
158                 return _("points");
159         case GL_UNITS_INCH:
160                 return _("inches");
161         case GL_UNITS_MM:
162                 return _("mm");
163         default:
164                 g_message ("Illegal units");    /* Should not happen */
165                 return _("points");
166         }
167 }
168