]> git.sur5r.net Git - glabels/blob - glabels2/src/prefs-model.c
2007-09-14 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / prefs-model.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-model.c:  Application preferences model 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-model.h"
27
28 #include <libglabels/paper.h>
29
30 #include "marshal.h"
31 #include "util.h"
32 #include "color.h"
33
34 #include "debug.h"
35
36 /*========================================================*/
37 /* Private macros and constants.                          */
38 /*========================================================*/
39
40 /* GConf keys */
41 #define BASE_KEY                            "/apps/glabels"
42
43 #define PREF_UNITS                          "/units"
44 #define PREF_DEFAULT_PAGE_SIZE              "/default-page-size"
45
46 #define PREF_DEFAULT_FONT_FAMILY            "/default-font-family"
47 #define PREF_DEFAULT_FONT_SIZE              "/default-font-size"
48 #define PREF_DEFAULT_FONT_WEIGHT            "/default-font-weight"
49 #define PREF_DEFAULT_FONT_ITALIC_FLAG       "/default-font-italic-flag"
50 #define PREF_DEFAULT_TEXT_COLOR             "/default-text-color"
51 #define PREF_DEFAULT_TEXT_ALIGNMENT         "/default-text-alignment"
52 #define PREF_DEFAULT_TEXT_LINE_SPACING      "/default-text-line-spacing"
53
54 #define PREF_DEFAULT_LINE_WIDTH             "/default-line-width"
55 #define PREF_DEFAULT_LINE_COLOR             "/default-line-color"
56
57 #define PREF_DEFAULT_FILL_COLOR             "/default-fill-color"
58
59 #define PREF_MAIN_TOOLBAR_VISIBLE           "/main-toolbar-visible"
60 #define PREF_MAIN_TOOLBAR_BUTTONS_STYLE     "/main-toolbar-buttons-style"
61 #define PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS     "/main-toolbar-view-tooltips"
62
63 #define PREF_DRAWING_TOOLBAR_VISIBLE        "/drawing-toolbar-visible"
64 #define PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS  "/drawing-toolbar-view-tooltips"
65
66 #define PREF_PROPERTY_TOOLBAR_VISIBLE        "/property-toolbar-visible"
67 #define PREF_PROPERTY_TOOLBAR_VIEW_TOOLTIPS  "/property-toolbar-view-tooltips"
68
69 #define PREF_GRID_VISIBLE                   "/grid-visible"
70 #define PREF_MARKUP_VISIBLE                 "/markup-visible"
71
72 #define PREF_MAX_RECENTS                    "/max-recents"
73
74 /* Default values */
75 #define DEFAULT_UNITS_STRING       units_to_string (GL_UNITS_INCH)
76 #define DEFAULT_PAGE_SIZE          "US-Letter"
77
78 #define DEFAULT_FONT_FAMILY        "Sans"
79 #define DEFAULT_FONT_SIZE          14.0
80 #define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (PANGO_WEIGHT_NORMAL)
81 #define DEFAULT_FONT_ITALIC_FLAG   FALSE
82 #define DEFAULT_TEXT_ALIGN_STRING  gl_util_align_to_string (PANGO_ALIGN_LEFT)
83 #define DEFAULT_TEXT_COLOR         GL_COLOR (0,0,0)
84 #define DEFAULT_TEXT_LINE_SPACING  1.0
85
86 #define DEFAULT_LINE_WIDTH         1.0
87 #define DEFAULT_LINE_COLOR         GL_COLOR_A (0, 0, 0, 255)
88
89 #define DEFAULT_FILL_COLOR         GL_COLOR_A (0, 255, 0, 255)
90
91 /*========================================================*/
92 /* Private types.                                         */
93 /*========================================================*/
94
95 enum {
96         CHANGED,
97         LAST_SIGNAL
98 };
99
100
101
102 /*========================================================*/
103 /* Private globals.                                       */
104 /*========================================================*/
105
106 static guint signals[LAST_SIGNAL] = {0};
107
108 /*========================================================*/
109 /* Private function prototypes.                           */
110 /*========================================================*/
111
112 static void           gl_prefs_model_finalize      (GObject             *object);
113
114 static void           notify_cb                    (GConfClient         *client,
115                                                     guint                cnxn_id,
116                                                     GConfEntry          *entry,
117                                                     glPrefsModel        *prefs_model);
118
119 static gchar         *get_string                   (GConfClient         *client,
120                                                     const gchar         *key,
121                                                     const gchar         *def);
122
123 static gboolean       get_bool                     (GConfClient         *client,
124                                                     const gchar         *key,
125                                                     gboolean             def);
126
127 static gint           get_int                      (GConfClient         *client,
128                                                     const gchar         *key,
129                                                     gint                 def);
130
131 static gdouble        get_float                    (GConfClient         *client,
132                                                     const gchar         *key,
133                                                     gdouble              def);
134
135 static glUnitsType    string_to_units              (const gchar         *string);
136 static const gchar   *units_to_string              (glUnitsType          units);
137
138
139 \f
140 /*****************************************************************************/
141 /* Boilerplate object stuff.                                                 */
142 /*****************************************************************************/
143 G_DEFINE_TYPE (glPrefsModel, gl_prefs_model, G_TYPE_OBJECT);
144
145 static void
146 gl_prefs_model_class_init (glPrefsModelClass *class)
147 {
148         GObjectClass *object_class = G_OBJECT_CLASS (class);
149
150         gl_debug (DEBUG_PREFS, "START");
151
152         gl_prefs_model_parent_class = g_type_class_peek_parent (class);
153
154         object_class->finalize = gl_prefs_model_finalize;
155
156         signals[CHANGED] =
157                 g_signal_new ("changed",
158                               G_OBJECT_CLASS_TYPE (object_class),
159                               G_SIGNAL_RUN_LAST,
160                               G_STRUCT_OFFSET (glPrefsModelClass, changed),
161                               NULL, NULL,
162                               gl_marshal_VOID__VOID,
163                               G_TYPE_NONE,
164                               0);
165
166         gl_debug (DEBUG_PREFS, "END");
167 }
168
169 static void
170 gl_prefs_model_init (glPrefsModel *prefs_model)
171 {
172         gl_debug (DEBUG_PREFS, "START");
173
174         prefs_model->gconf_client = gconf_client_get_default ();
175
176         g_return_if_fail (prefs_model->gconf_client != NULL);
177  
178         gconf_client_add_dir (prefs_model->gconf_client,
179                               BASE_KEY,
180                               GCONF_CLIENT_PRELOAD_ONELEVEL,
181                               NULL);
182          
183         gconf_client_notify_add (prefs_model->gconf_client,
184                                  BASE_KEY,
185                                  (GConfClientNotifyFunc)notify_cb, prefs_model,
186                                  NULL, NULL);
187
188         gl_debug (DEBUG_PREFS, "END");
189 }
190
191 static void
192 gl_prefs_model_finalize (GObject *object)
193 {
194         glPrefsModel *prefs_model = GL_PREFS_MODEL (object);
195
196         gl_debug (DEBUG_PREFS, "START");
197
198         g_return_if_fail (object && GL_IS_PREFS_MODEL (object));
199
200         g_object_unref (G_OBJECT(prefs_model->gconf_client));
201         g_free (prefs_model->default_page_size);
202         g_free (prefs_model->default_font_family);
203
204         G_OBJECT_CLASS (gl_prefs_model_parent_class)->finalize (object);
205
206         gl_debug (DEBUG_PREFS, "END");
207 }
208
209 /*****************************************************************************/
210 /* New prefs_model object.                                                   */
211 /*****************************************************************************/
212 glPrefsModel *
213 gl_prefs_model_new (void)
214 {
215         glPrefsModel *prefs_model;
216
217         gl_debug (DEBUG_PREFS, "START");
218
219         prefs_model = GL_PREFS_MODEL (g_object_new (gl_prefs_model_get_type(), NULL));
220
221         gl_debug (DEBUG_PREFS, "END");
222
223         return prefs_model;
224 }
225
226
227
228 /*****************************************************************************/
229 /* Save all settings.                                                        */
230 /*****************************************************************************/
231 void 
232 gl_prefs_model_save_settings (glPrefsModel *prefs_model)
233 {
234         gl_debug (DEBUG_PREFS, "START");
235         
236         g_return_if_fail (prefs_model && GL_IS_PREFS_MODEL(prefs_model));
237         g_return_if_fail (prefs_model->gconf_client != NULL);
238
239         /* We are saving settings because presumably some of them have been changed. */
240         g_signal_emit (G_OBJECT(prefs_model), signals[CHANGED], 0);
241
242         /* Units */
243         gconf_client_set_string (prefs_model->gconf_client,
244                                  BASE_KEY PREF_UNITS,
245                                  units_to_string(prefs_model->units),
246                                  NULL);
247
248         /* Default page size */
249         gconf_client_set_string (prefs_model->gconf_client,
250                                  BASE_KEY PREF_DEFAULT_PAGE_SIZE,
251                                  prefs_model->default_page_size,
252                                  NULL);
253
254
255         /* Text properties */
256         gconf_client_set_string (prefs_model->gconf_client,
257                                  BASE_KEY PREF_DEFAULT_FONT_FAMILY,
258                                  prefs_model->default_font_family,
259                                  NULL);
260
261         gconf_client_set_float  (prefs_model->gconf_client,
262                                  BASE_KEY PREF_DEFAULT_FONT_SIZE,
263                                  prefs_model->default_font_size,
264                                  NULL);
265
266         gconf_client_set_string (prefs_model->gconf_client,
267                                  BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
268                                  gl_util_weight_to_string(prefs_model->default_font_weight),
269                                  NULL);
270
271         gconf_client_set_int    (prefs_model->gconf_client,
272                                  BASE_KEY PREF_DEFAULT_TEXT_COLOR,
273                                  prefs_model->default_text_color,
274                                  NULL);
275
276         gconf_client_set_string (prefs_model->gconf_client,
277                                  BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
278                                  gl_util_align_to_string(prefs_model->default_text_alignment),
279                                  NULL);
280
281         gconf_client_set_float  (prefs_model->gconf_client,
282                                  BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
283                                  prefs_model->default_text_line_spacing,
284                                  NULL);
285
286         /* Line properties */
287         gconf_client_set_float  (prefs_model->gconf_client,
288                                  BASE_KEY PREF_DEFAULT_LINE_WIDTH,
289                                  prefs_model->default_line_width,
290                                  NULL);
291
292         gconf_client_set_int    (prefs_model->gconf_client,
293                                  BASE_KEY PREF_DEFAULT_LINE_COLOR,
294                                  prefs_model->default_line_color,
295                                  NULL);
296
297
298         /* Fill properties */
299         gconf_client_set_int    (prefs_model->gconf_client,
300                                  BASE_KEY PREF_DEFAULT_FILL_COLOR,
301                                  prefs_model->default_fill_color,
302                                  NULL);
303
304
305         /* Main Toolbar */
306         gconf_client_set_bool (prefs_model->gconf_client,
307                                BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
308                                prefs_model->main_toolbar_visible,
309                                NULL);
310
311         gconf_client_set_int (prefs_model->gconf_client,
312                               BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
313                               prefs_model->main_toolbar_buttons_style,
314                               NULL);
315
316         gconf_client_set_bool (prefs_model->gconf_client,
317                                BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
318                                prefs_model->main_toolbar_view_tooltips,
319                                NULL);
320
321         /* Drawing Toolbar */
322         gconf_client_set_bool (prefs_model->gconf_client,
323                                BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
324                                prefs_model->drawing_toolbar_visible,
325                                NULL);
326
327         gconf_client_set_bool (prefs_model->gconf_client,
328                                BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
329                                prefs_model->drawing_toolbar_view_tooltips,
330                                NULL);
331
332         /* Property Toolbar */
333         gconf_client_set_bool (prefs_model->gconf_client,
334                                BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
335                                prefs_model->property_toolbar_visible,
336                                NULL);
337
338         gconf_client_set_bool (prefs_model->gconf_client,
339                                BASE_KEY PREF_PROPERTY_TOOLBAR_VIEW_TOOLTIPS,
340                                prefs_model->property_toolbar_view_tooltips,
341                                NULL);
342
343         /* View properties */
344         gconf_client_set_bool (prefs_model->gconf_client,
345                                BASE_KEY PREF_GRID_VISIBLE,
346                                prefs_model->grid_visible,
347                                NULL);
348
349         gconf_client_set_bool (prefs_model->gconf_client,
350                                BASE_KEY PREF_MARKUP_VISIBLE,
351                                prefs_model->markup_visible,
352                                NULL);
353
354         /* Recent files */
355         gconf_client_set_int (prefs_model->gconf_client,
356                               BASE_KEY PREF_MAX_RECENTS,
357                               prefs_model->max_recents,
358                               NULL);
359
360
361         gconf_client_suggest_sync (prefs_model->gconf_client, NULL);
362         
363         gl_debug (DEBUG_PREFS, "END");
364 }
365
366 /*****************************************************************************/
367 /* Load all settings.                                                        */
368 /*****************************************************************************/
369 void
370 gl_prefs_model_load_settings (glPrefsModel *prefs_model)
371 {
372         gchar   *string;
373         glPaper *paper;
374
375         gl_debug (DEBUG_PREFS, "START");
376         
377         g_return_if_fail (prefs_model && GL_IS_PREFS_MODEL(prefs_model));
378         g_return_if_fail (prefs_model->gconf_client != NULL);
379
380         /* Units */
381         string =
382                 get_string (prefs_model->gconf_client,
383                             BASE_KEY PREF_UNITS,
384                             DEFAULT_UNITS_STRING);
385         prefs_model->units = string_to_units( string );
386         g_free( string );
387
388
389         /* Page size */
390         prefs_model->default_page_size =
391                 get_string (prefs_model->gconf_client,
392                             BASE_KEY PREF_DEFAULT_PAGE_SIZE,
393                             DEFAULT_PAGE_SIZE);
394
395         /* Text properties */
396         prefs_model->default_font_family =
397                 get_string (prefs_model->gconf_client,
398                             BASE_KEY PREF_DEFAULT_FONT_FAMILY,
399                             DEFAULT_FONT_FAMILY);
400
401         prefs_model->default_font_size =
402                 get_float (prefs_model->gconf_client,
403                            BASE_KEY PREF_DEFAULT_FONT_SIZE,
404                            DEFAULT_FONT_SIZE);
405
406         string =
407                 get_string (prefs_model->gconf_client,
408                             BASE_KEY PREF_DEFAULT_FONT_WEIGHT,
409                             DEFAULT_FONT_WEIGHT_STRING);
410         prefs_model->default_font_weight = gl_util_string_to_weight( string );
411         g_free( string );
412
413         prefs_model->default_text_color =
414                 get_int (prefs_model->gconf_client,
415                          BASE_KEY PREF_DEFAULT_TEXT_COLOR,
416                          DEFAULT_TEXT_COLOR);
417
418         string =
419                 get_string (prefs_model->gconf_client,
420                             BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT,
421                             DEFAULT_TEXT_ALIGN_STRING);
422         prefs_model->default_text_alignment = gl_util_string_to_align( string );
423         g_free( string );
424
425         prefs_model->default_text_line_spacing =
426                 get_float (prefs_model->gconf_client,
427                            BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING,
428                            DEFAULT_TEXT_LINE_SPACING);
429
430         gl_debug (DEBUG_PREFS, "text_line_spacing = %f", prefs_model->default_text_line_spacing);
431
432         /* Line properties */
433         prefs_model->default_line_width =
434                 get_float (prefs_model->gconf_client,
435                            BASE_KEY PREF_DEFAULT_LINE_WIDTH,
436                            DEFAULT_LINE_WIDTH);
437         prefs_model->default_line_color =
438                 get_int (prefs_model->gconf_client,
439                          BASE_KEY PREF_DEFAULT_LINE_COLOR,
440                          DEFAULT_LINE_COLOR);
441
442         /* Fill properties */
443         prefs_model->default_fill_color =
444                 get_int (prefs_model->gconf_client,
445                          BASE_KEY PREF_DEFAULT_FILL_COLOR,
446                          DEFAULT_FILL_COLOR);
447
448
449         /* User Inferface/Main Toolbar */
450         prefs_model->main_toolbar_visible =
451                 get_bool (prefs_model->gconf_client,
452                           BASE_KEY PREF_MAIN_TOOLBAR_VISIBLE,
453                           TRUE);
454
455         prefs_model->main_toolbar_buttons_style =
456                 get_int (prefs_model->gconf_client,
457                          BASE_KEY PREF_MAIN_TOOLBAR_BUTTONS_STYLE,
458                          GL_TOOLBAR_SYSTEM);
459
460         prefs_model->main_toolbar_view_tooltips =
461                 get_bool (prefs_model->gconf_client,
462                           BASE_KEY PREF_MAIN_TOOLBAR_VIEW_TOOLTIPS,
463                           TRUE);
464
465         /* User Inferface/Drawing Toolbar */
466         prefs_model->drawing_toolbar_visible =
467                 get_bool (prefs_model->gconf_client,
468                           BASE_KEY PREF_DRAWING_TOOLBAR_VISIBLE,
469                           TRUE);
470
471         prefs_model->drawing_toolbar_view_tooltips =
472                 get_bool (prefs_model->gconf_client,
473                           BASE_KEY PREF_DRAWING_TOOLBAR_VIEW_TOOLTIPS,
474                           TRUE);
475
476         /* User Inferface/Property Toolbar */
477         prefs_model->property_toolbar_visible =
478                 get_bool (prefs_model->gconf_client,
479                           BASE_KEY PREF_PROPERTY_TOOLBAR_VISIBLE,
480                           TRUE);
481
482         prefs_model->property_toolbar_view_tooltips =
483                 get_bool (prefs_model->gconf_client,
484                           BASE_KEY PREF_PROPERTY_TOOLBAR_VIEW_TOOLTIPS,
485                           TRUE);
486
487
488         /* View properties */
489         prefs_model->grid_visible =
490                 get_bool (prefs_model->gconf_client,
491                           BASE_KEY PREF_GRID_VISIBLE,
492                           TRUE);
493
494         prefs_model->markup_visible =
495                 get_bool (prefs_model->gconf_client,
496                           BASE_KEY PREF_MARKUP_VISIBLE,
497                           TRUE);
498
499         /* Recent files */
500         prefs_model->max_recents =
501                 get_int (prefs_model->gconf_client,
502                          BASE_KEY PREF_MAX_RECENTS,
503                          -1);
504
505
506         /* Proof read the default page size -- it must be a valid id. */
507         /* (For compatability with older versions.) */
508         /* Note: paper module must be initialized for this to work. */
509         paper = gl_paper_from_id (prefs_model->default_page_size);
510         if ( paper == NULL ) {
511                 prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE);
512         } else {
513                 gl_paper_free (paper);
514                 paper = NULL;
515         }
516
517         gl_debug (DEBUG_PREFS, "max_recents = %d", prefs_model->max_recents);
518
519
520         g_signal_emit (G_OBJECT(prefs_model), signals[CHANGED], 0);
521
522         gl_debug (DEBUG_PREFS, "END");
523 }
524
525 /*---------------------------------------------------------------------------*/
526 /* PRIVATE.  Key changed callback.                                           */
527 /*---------------------------------------------------------------------------*/
528 static void 
529 notify_cb (GConfClient  *client,
530            guint         cnxn_id,
531            GConfEntry   *entry,
532            glPrefsModel *prefs_model)
533 {
534         gl_debug (DEBUG_PREFS, "Key was changed: %s", entry->key);
535
536         gl_prefs_model_load_settings (prefs_model);
537 }
538
539 /*---------------------------------------------------------------------------*/
540 /* PRIVATE.  Utilities to get values with defaults.                          */
541 /*---------------------------------------------------------------------------*/
542 static gchar*
543 get_string (GConfClient *client,
544             const gchar *key,
545             const gchar *def)
546 {
547         gchar* val;
548
549         val = gconf_client_get_string (client, key, NULL);
550
551         if (val != NULL) {
552
553                 return val;
554
555         } else {
556
557                 return def ? g_strdup (def) : NULL;
558
559         }
560 }
561
562 static gboolean
563 get_bool (GConfClient *client,
564           const gchar *key,
565           gboolean     def)
566 {
567         GConfValue* val;
568         gboolean retval;
569
570         val = gconf_client_get (client, key, NULL);
571
572         if (val != NULL) {
573
574                 if ( val->type == GCONF_VALUE_BOOL ) {
575                         retval = gconf_value_get_bool (val);
576                 } else {
577                         retval = def;
578                 }
579
580                 gconf_value_free (val);
581
582                 return retval;
583
584         } else {
585
586                 return def;
587
588         }
589 }
590
591 static gint
592 get_int (GConfClient *client,
593          const gchar *key,
594          gint         def)
595 {
596         GConfValue* val;
597         gint retval;
598
599         val = gconf_client_get (client, key, NULL);
600
601         if (val != NULL) {
602
603                 if ( val->type == GCONF_VALUE_INT) {
604                         retval = gconf_value_get_int(val);
605                 } else {
606                         retval = def;
607                 }
608
609                 gconf_value_free (val);
610
611                 return retval;
612
613         } else {
614
615                 return def;
616
617         }
618 }
619
620 static gdouble
621 get_float (GConfClient *client,
622            const gchar *key,
623            gdouble      def)
624 {
625         GConfValue* val;
626         gdouble retval;
627
628         val = gconf_client_get (client, key, NULL);
629
630         if (val != NULL) {
631
632                 if ( val->type == GCONF_VALUE_FLOAT ) {
633                         retval = gconf_value_get_float(val);
634                 } else {
635                         retval = def;
636                 }
637
638                 gconf_value_free (val);
639
640                 return retval;
641
642         } else {
643                 return def;
644
645         }
646 }
647
648 /*---------------------------------------------------------------------------*/
649 /* PRIVATE.  Utilities to deal with units.                                   */
650 /*---------------------------------------------------------------------------*/
651 static glUnitsType
652 string_to_units (const gchar *string)
653 {
654         glUnitsType units;
655
656         if (g_strcasecmp (string, "Points") == 0) {
657                 units = GL_UNITS_POINT;
658         } else if (g_strcasecmp (string, "Inches") == 0) {
659                 units = GL_UNITS_INCH;
660         } else if (g_strcasecmp (string, "Millimeters") == 0) {
661                 units = GL_UNITS_MM;
662         } else {
663                 units = GL_UNITS_INCH;
664         }
665
666         return units;
667 }
668
669 static const
670 gchar *units_to_string (glUnitsType units)
671 {
672         switch (units) {
673         case GL_UNITS_POINT:
674                 return "Points";
675                 break;
676         case GL_UNITS_INCH:
677                 return "Inches";
678                 break;
679         case GL_UNITS_MM:
680                 return "Millimeters";
681                 break;
682         default:
683                 return "Inches";
684                 break;
685         }
686 }
687
688