]> git.sur5r.net Git - glabels/blob - src/prefs-dialog.c
Updated Spanish translation
[glabels] / src / prefs-dialog.c
1 /*
2  *  prefs-dialog.c
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 #include <config.h>
22
23 #include "prefs-dialog.h"
24
25 #include <glib/gi18n.h>
26 #include <gtk/gtk.h>
27
28 #include "prefs.h"
29 #include "color-combo.h"
30 #include "color.h"
31 #include "font-combo.h"
32 #include "font-util.h"
33 #include "builder-util.h"
34
35 #include "debug.h"
36
37
38 /*========================================================*/
39 /* Private macros and constants.                          */
40 /*========================================================*/
41
42 #define US_LETTER_ID "US-Letter"
43 #define A4_ID        "A4"
44
45
46 /*========================================================*/
47 /* Private types.                                         */
48 /*========================================================*/
49
50 struct _glPrefsDialogPrivate
51 {
52         GtkBuilder      *builder;
53
54         /* Units properties */
55         GtkWidget       *units_points_radio;
56         GtkWidget       *units_inches_radio;
57         GtkWidget       *units_mm_radio;
58
59         /* Page size properties */
60         GtkWidget       *page_size_us_letter_radio;
61         GtkWidget       *page_size_a4_radio;
62
63         /* Default text properties */
64         GtkWidget       *text_family_hbox;
65         GtkWidget       *text_family_combo;
66         GtkWidget       *text_size_spin;
67         GtkWidget       *text_bold_toggle;
68         GtkWidget       *text_italic_toggle;
69         GtkWidget       *text_color_hbox;
70         GtkWidget       *text_color_combo;
71         GtkWidget       *text_left_toggle;
72         GtkWidget       *text_center_toggle;
73         GtkWidget       *text_right_toggle;
74         GtkWidget       *text_line_spacing_spin;
75
76         /* Default line properties */
77         GtkWidget       *line_width_spin;
78         GtkWidget       *line_color_hbox;
79         GtkWidget       *line_color_combo;
80
81         /* Default fill properties */
82         GtkWidget       *fill_color_hbox;
83         GtkWidget       *fill_color_combo;
84
85         /* Prevent recursion */
86         gboolean    stop_signals;
87 };
88
89
90 /*========================================================*/
91 /* Private globals.                                       */
92 /*========================================================*/
93
94
95 /*========================================================*/
96 /* Private function prototypes.                           */
97 /*========================================================*/
98
99 static void gl_prefs_dialog_finalize      (GObject            *object);
100 static void gl_prefs_dialog_construct     (glPrefsDialog      *dialog);
101
102 static void response_cb                   (glPrefsDialog      *dialog,
103                                            gint                response,
104                                            gpointer            user_data);
105
106 static void construct_locale_page         (glPrefsDialog      *dialog);
107 static void construct_object_page         (glPrefsDialog      *dialog);
108
109 static void align_toggle_cb               (GtkToggleButton    *toggle,
110                                            glPrefsDialog      *dialog);
111                                                                                 
112 static void update_locale_page_from_prefs (glPrefsDialog      *dialog);
113 static void update_object_page_from_prefs (glPrefsDialog      *dialog);
114
115 static void update_prefs_from_locale_page (glPrefsDialog      *dialog);
116 static void update_prefs_from_object_page (glPrefsDialog      *dialog);
117
118
119 /*****************************************************************************/
120 /* Boilerplate object stuff.                                                 */
121 /*****************************************************************************/
122 G_DEFINE_TYPE (glPrefsDialog, gl_prefs_dialog, GTK_TYPE_DIALOG)
123
124
125 static void
126 gl_prefs_dialog_class_init (glPrefsDialogClass *class)
127 {
128         GObjectClass *object_class = G_OBJECT_CLASS (class);
129
130         gl_debug (DEBUG_PREFS, "");
131         
132         gl_prefs_dialog_parent_class = g_type_class_peek_parent (class);
133
134         object_class->finalize = gl_prefs_dialog_finalize;      
135 }
136
137
138 static void
139 gl_prefs_dialog_init (glPrefsDialog *dialog)
140 {
141         gchar        *builder_filename;
142         static gchar *object_ids[] = { "prefs_notebook",
143                                        "adjustment1",  "adjustment2",  "adjustment3",
144                                        NULL };
145         GError *error = NULL;
146
147         gl_debug (DEBUG_PREFS, "START");
148
149         dialog->priv = g_new0 (glPrefsDialogPrivate, 1);
150
151         dialog->priv->builder = gtk_builder_new ();
152         builder_filename = g_build_filename (GLABELS_DATA_DIR, "ui", "prefs-dialog.ui", NULL);
153         gtk_builder_add_objects_from_file (dialog->priv->builder, builder_filename, object_ids, &error);
154         g_free (builder_filename);
155         if (error) {
156                 g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
157                 g_error_free (error);
158                 return;
159         }
160
161         gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
162         gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
163
164         g_signal_connect(G_OBJECT (dialog), "response",
165                          G_CALLBACK (response_cb), NULL);
166
167         gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
168         gtk_window_set_title (GTK_WINDOW (dialog), _("gLabels Preferences"));
169         gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
170
171         gl_debug (DEBUG_PREFS, "END");
172 }
173
174
175 static void 
176 gl_prefs_dialog_finalize (GObject *object)
177 {
178         glPrefsDialog* dialog = GL_PREFS_DIALOG (object);
179         
180         gl_debug (DEBUG_PREFS, "START");
181
182         g_return_if_fail (object != NULL);
183         g_return_if_fail (GL_IS_PREFS_DIALOG (dialog));
184         g_return_if_fail (dialog->priv != NULL);
185
186         if (dialog->priv->builder)
187         {
188                 g_object_unref (G_OBJECT (dialog->priv->builder));
189         }
190         g_free (dialog->priv);
191
192         G_OBJECT_CLASS (gl_prefs_dialog_parent_class)->finalize (object);
193
194         gl_debug (DEBUG_PREFS, "END");
195 }
196
197
198 /*****************************************************************************/
199 /* NEW preferences dialog.                                                   */
200 /*****************************************************************************/
201 GtkWidget*
202 gl_prefs_dialog_new (GtkWindow *parent)
203 {
204         GtkWidget *dialog;
205
206         gl_debug (DEBUG_PREFS, "START");
207
208         dialog = GTK_WIDGET (g_object_new (GL_TYPE_PREFS_DIALOG, NULL));
209
210         if (parent)
211                 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
212         
213         gl_prefs_dialog_construct (GL_PREFS_DIALOG(dialog));
214
215
216         gl_debug (DEBUG_PREFS, "END");
217
218         return dialog;
219 }
220
221
222 /*---------------------------------------------------------------------------*/
223 /* PRIVATE.  Construct composite widget.                                     */
224 /*---------------------------------------------------------------------------*/
225 static void
226 gl_prefs_dialog_construct (glPrefsDialog *dialog)
227 {
228         GtkWidget *vbox;
229         GtkWidget *notebook;
230
231         g_return_if_fail (GL_IS_PREFS_DIALOG (dialog));
232         g_return_if_fail (dialog->priv != NULL);
233
234         vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
235
236         gl_builder_util_get_widgets (dialog->priv->builder,
237                                      "prefs_notebook", &notebook,
238                                      NULL);
239         gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
240
241         construct_locale_page (dialog);
242         construct_object_page (dialog);
243
244         update_locale_page_from_prefs (dialog);
245         update_object_page_from_prefs (dialog);
246
247         gtk_widget_show_all (vbox);   
248 }
249
250
251 /*---------------------------------------------------------------------------*/
252 /* PRIVATE.  "Response" callback.                                            */
253 /*---------------------------------------------------------------------------*/
254 static void
255 response_cb (glPrefsDialog *dialog,
256              gint          response,
257              gpointer      user_data)
258 {
259         gl_debug (DEBUG_VIEW, "START");
260
261         g_return_if_fail(dialog != NULL);
262         g_return_if_fail(GTK_IS_DIALOG(dialog));
263
264         switch(response) {
265         case GTK_RESPONSE_CLOSE:
266                 gtk_widget_hide (GTK_WIDGET(dialog));
267                 break;
268         case GTK_RESPONSE_DELETE_EVENT:
269                 break;
270         default:
271                 g_print ("response = %d", response);
272                 g_assert_not_reached ();
273         }
274
275         gl_debug (DEBUG_VIEW, "END");
276 }
277
278
279 /*--------------------------------------------------------------------------*/
280 /* PRIVATE.  Build Locale Properties Notebook Tab                           */
281 /*--------------------------------------------------------------------------*/
282 static void
283 construct_locale_page (glPrefsDialog *dialog)
284 {
285
286         gl_builder_util_get_widgets (dialog->priv->builder,
287                                      "units_points_radio",        &dialog->priv->units_points_radio,
288                                      "units_inches_radio",        &dialog->priv->units_inches_radio,
289                                      "units_mm_radio",            &dialog->priv->units_mm_radio,
290                                      "page_size_us_letter_radio", &dialog->priv->page_size_us_letter_radio,
291                                      "page_size_a4_radio",        &dialog->priv->page_size_a4_radio,
292                                      NULL);
293
294         g_signal_connect_swapped (
295                 G_OBJECT(dialog->priv->units_points_radio),
296                 "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dialog));
297         g_signal_connect_swapped (
298                 G_OBJECT(dialog->priv->units_inches_radio),
299                 "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dialog));
300         g_signal_connect_swapped (
301                 G_OBJECT(dialog->priv->units_mm_radio),
302                 "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dialog));
303         g_signal_connect_swapped (
304                 G_OBJECT(dialog->priv->page_size_us_letter_radio),
305                 "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dialog));
306         g_signal_connect_swapped (
307                 G_OBJECT(dialog->priv->page_size_a4_radio),
308                 "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dialog));
309 }
310
311
312 /*--------------------------------------------------------------------------*/
313 /* PRIVATE.  Build Default Object Properties Notebook Tab                   */
314 /*--------------------------------------------------------------------------*/
315 static void
316 construct_object_page (glPrefsDialog *dialog)
317 {
318         gl_builder_util_get_widgets (dialog->priv->builder,
319                                      "text_family_hbox",       &dialog->priv->text_family_hbox,
320                                      "text_size_spin",         &dialog->priv->text_size_spin,
321                                      "text_bold_toggle",       &dialog->priv->text_bold_toggle,
322                                      "text_italic_toggle",     &dialog->priv->text_italic_toggle,
323                                      "text_color_hbox",        &dialog->priv->text_color_hbox,
324                                      "text_left_toggle",       &dialog->priv->text_left_toggle,
325                                      "text_center_toggle",     &dialog->priv->text_center_toggle,
326                                      "text_right_toggle",      &dialog->priv->text_right_toggle,
327                                      "text_line_spacing_spin", &dialog->priv->text_line_spacing_spin,
328                                      "line_width_spin",        &dialog->priv->line_width_spin,
329                                      "line_color_hbox",        &dialog->priv->line_color_hbox,
330                                      "fill_color_hbox",        &dialog->priv->fill_color_hbox,
331                                      NULL);
332
333         dialog->priv->text_family_combo = gl_font_combo_new ("Sans");
334
335         dialog->priv->text_color_combo = gl_color_combo_new (_("Default"),
336                                                              GL_COLOR_TEXT_DEFAULT,
337                                                              gl_prefs_model_get_default_text_color (gl_prefs));
338         dialog->priv->line_color_combo = gl_color_combo_new (_("No Line"),
339                                                              GL_COLOR_NO_LINE,
340                                                              gl_prefs_model_get_default_line_color (gl_prefs));
341         dialog->priv->fill_color_combo = gl_color_combo_new (_("No Fill"),
342                                                              GL_COLOR_NO_FILL,
343                                                              gl_prefs_model_get_default_fill_color (gl_prefs));
344
345         gtk_box_pack_start (GTK_BOX (dialog->priv->text_family_hbox),
346                             dialog->priv->text_family_combo,
347                             FALSE, FALSE, 0);
348         gtk_box_pack_start (GTK_BOX (dialog->priv->text_color_hbox),
349                             dialog->priv->text_color_combo,
350                             FALSE, FALSE, 0);
351         gtk_box_pack_start (GTK_BOX (dialog->priv->line_color_hbox),
352                             dialog->priv->line_color_combo,
353                             FALSE, FALSE, 0);
354         gtk_box_pack_start (GTK_BOX (dialog->priv->fill_color_hbox),
355                             dialog->priv->fill_color_combo,
356                             FALSE, FALSE, 0);
357
358         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_family_combo),
359                                   "changed",
360                                   G_CALLBACK(update_prefs_from_object_page),
361                                   G_OBJECT(dialog));
362         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_size_spin),
363                                   "changed",
364                                   G_CALLBACK(update_prefs_from_object_page),
365                                   G_OBJECT(dialog));
366         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_bold_toggle),
367                                   "toggled",
368                                   G_CALLBACK(update_prefs_from_object_page),
369                                   G_OBJECT(dialog));
370         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_italic_toggle),
371                                   "toggled",
372                                   G_CALLBACK(update_prefs_from_object_page),
373                                   G_OBJECT(dialog));
374         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_color_combo),
375                                   "color_changed",
376                                   G_CALLBACK(update_prefs_from_object_page),
377                                   G_OBJECT(dialog));
378
379         g_signal_connect (G_OBJECT(dialog->priv->text_left_toggle),
380                           "toggled",
381                           G_CALLBACK(align_toggle_cb),
382                           G_OBJECT(dialog));
383         g_signal_connect (G_OBJECT(dialog->priv->text_center_toggle),
384                           "toggled",
385                           G_CALLBACK(align_toggle_cb),
386                           G_OBJECT(dialog));
387         g_signal_connect (G_OBJECT(dialog->priv->text_right_toggle),
388                           "toggled",
389                           G_CALLBACK(align_toggle_cb),
390                           G_OBJECT(dialog));
391
392         g_signal_connect_swapped (G_OBJECT(dialog->priv->text_line_spacing_spin),
393                                   "changed",
394                                   G_CALLBACK(update_prefs_from_object_page),
395                                   G_OBJECT(dialog));
396
397         g_signal_connect_swapped (G_OBJECT(dialog->priv->line_width_spin),
398                                   "changed",
399                                   G_CALLBACK(update_prefs_from_object_page),
400                                   G_OBJECT(dialog));
401         g_signal_connect_swapped (G_OBJECT(dialog->priv->line_color_combo),
402                                   "color_changed",
403                                   G_CALLBACK(update_prefs_from_object_page),
404                                   G_OBJECT(dialog));
405
406         g_signal_connect_swapped (G_OBJECT(dialog->priv->fill_color_combo),
407                                   "color_changed",
408                                   G_CALLBACK(update_prefs_from_object_page),
409                                   G_OBJECT(dialog));
410 }
411
412
413 /*--------------------------------------------------------------------------*/
414 /* PRIVATE.  Alignment togglebutton callback.                               */
415 /*--------------------------------------------------------------------------*/
416 static void
417 align_toggle_cb (GtkToggleButton *toggle,
418                  glPrefsDialog   *dialog)
419 {
420         if (gtk_toggle_button_get_active (toggle))
421         {
422   
423                 if (GTK_WIDGET (toggle) == GTK_WIDGET (dialog->priv->text_left_toggle))
424                 {
425                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
426                                                       (dialog->priv->text_center_toggle),
427                                                       FALSE);
428                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
429                                                       (dialog->priv->text_right_toggle),
430                                                       FALSE);
431                 }
432                 else if (GTK_WIDGET (toggle) == GTK_WIDGET (dialog->priv->text_center_toggle))
433                 {
434                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
435                                                       (dialog->priv->text_left_toggle),
436                                                       FALSE);
437                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
438                                                       (dialog->priv->text_right_toggle),
439                                                       FALSE);
440                 }
441                 else if (GTK_WIDGET (toggle) == GTK_WIDGET (dialog->priv->text_right_toggle))
442                 {
443                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
444                                                       (dialog->priv->text_left_toggle),
445                                                       FALSE);
446                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
447                                                       (dialog->priv->text_center_toggle),
448                                                       FALSE);
449                 }
450                                                                                 
451                 update_prefs_from_object_page (dialog);
452         }
453                                                                                 
454 }
455                                                                                 
456
457 /*--------------------------------------------------------------------------*/
458 /* PRIVATE.  Update locale page widgets from current prefs.                 */
459 /*--------------------------------------------------------------------------*/
460 static void
461 update_locale_page_from_prefs (glPrefsDialog *dialog)
462 {
463         dialog->priv->stop_signals = TRUE;
464
465         switch (gl_prefs_model_get_units (gl_prefs)) {
466         case LGL_UNITS_POINT:
467                 gtk_toggle_button_set_active (
468                         GTK_TOGGLE_BUTTON(dialog->priv->units_points_radio),
469                         TRUE);
470                 break;
471         case LGL_UNITS_INCH:
472                 gtk_toggle_button_set_active (
473                         GTK_TOGGLE_BUTTON(dialog->priv->units_inches_radio),
474                         TRUE);
475                 break;
476         case LGL_UNITS_MM:
477                 gtk_toggle_button_set_active (
478                         GTK_TOGGLE_BUTTON(dialog->priv->units_mm_radio),
479                         TRUE);
480                 break;
481         default:
482                 g_message ("Illegal units");    /* Should not happen */
483                 break;
484         }
485
486         if ( g_ascii_strcasecmp(gl_prefs_model_get_default_page_size (gl_prefs), US_LETTER_ID) == 0)
487         {
488                 gtk_toggle_button_set_active (
489                         GTK_TOGGLE_BUTTON(dialog->priv->page_size_us_letter_radio), TRUE);
490         }
491         else if ( g_ascii_strcasecmp(gl_prefs_model_get_default_page_size (gl_prefs), A4_ID) == 0)
492         {
493                 gtk_toggle_button_set_active (
494                         GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio), TRUE);
495         }
496         else
497         {
498                 g_message ("Unknown default page size"); /* Shouldn't happen */
499                 gtk_toggle_button_set_active (
500                         GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio), TRUE);
501         }
502
503         dialog->priv->stop_signals = FALSE;
504 }
505
506
507 /*--------------------------------------------------------------------------*/
508 /* PRIVATE.  Update object page widgets from current prefs.                 */
509 /*--------------------------------------------------------------------------*/
510 static void
511 update_object_page_from_prefs (glPrefsDialog *dialog)
512 {
513  
514         dialog->priv->stop_signals = TRUE;
515
516         gl_font_combo_set_family (GL_FONT_COMBO (dialog->priv->text_family_combo),
517                                   gl_prefs_model_get_default_font_family (gl_prefs));
518
519         gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->text_size_spin),
520                                    gl_prefs_model_get_default_font_size (gl_prefs));
521  
522         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_bold_toggle),
523                                       (gl_prefs_model_get_default_font_weight (gl_prefs) == PANGO_WEIGHT_BOLD));
524  
525         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_italic_toggle),
526                                       gl_prefs_model_get_default_font_italic_flag (gl_prefs));
527  
528         gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->text_color_combo),
529                                   gl_prefs_model_get_default_text_color (gl_prefs));
530
531         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_left_toggle),
532                                  (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_LEFT));
533         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_center_toggle),
534                                  (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_CENTER));
535         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->text_right_toggle),
536                                  (gl_prefs_model_get_default_text_alignment (gl_prefs) == PANGO_ALIGN_RIGHT));
537
538         gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->text_line_spacing_spin),
539                                    gl_prefs_model_get_default_text_line_spacing (gl_prefs));
540
541         gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->line_width_spin),
542                                    gl_prefs_model_get_default_line_width (gl_prefs));
543  
544         gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->line_color_combo),
545                                   gl_prefs_model_get_default_line_color (gl_prefs));
546
547
548         gl_color_combo_set_color (GL_COLOR_COMBO(dialog->priv->fill_color_combo),
549                                   gl_prefs_model_get_default_fill_color (gl_prefs));
550
551
552         dialog->priv->stop_signals = FALSE;
553 }
554
555
556 /*--------------------------------------------------------------------------*/
557 /* PRIVATE.  Update prefs from current state of locale page widgets.        */
558 /*--------------------------------------------------------------------------*/
559 static void
560 update_prefs_from_locale_page (glPrefsDialog *dialog)
561 {
562         if (dialog->priv->stop_signals) return;
563
564         if (gtk_toggle_button_get_active (
565                     GTK_TOGGLE_BUTTON(dialog->priv->units_points_radio)))
566         {
567                 gl_prefs_model_set_units  (gl_prefs, LGL_UNITS_POINT);
568         }
569         if (gtk_toggle_button_get_active (
570                     GTK_TOGGLE_BUTTON(dialog->priv->units_inches_radio)))
571         {
572                 gl_prefs_model_set_units  (gl_prefs, LGL_UNITS_INCH);
573         }
574         if (gtk_toggle_button_get_active (
575                     GTK_TOGGLE_BUTTON(dialog->priv->units_mm_radio)))
576         {
577                 gl_prefs_model_set_units  (gl_prefs, LGL_UNITS_MM);
578         }
579
580         if (gtk_toggle_button_get_active (
581                     GTK_TOGGLE_BUTTON(dialog->priv->page_size_us_letter_radio)))
582         {
583                 gl_prefs_model_set_default_page_size  (gl_prefs, US_LETTER_ID);
584         }
585         if (gtk_toggle_button_get_active (
586                     GTK_TOGGLE_BUTTON(dialog->priv->page_size_a4_radio)))
587         {
588                 gl_prefs_model_set_default_page_size  (gl_prefs, A4_ID);
589         }
590 }
591
592
593 /*--------------------------------------------------------------------------*/
594 /* PRIVATE.  Update prefs from current state of object page widgets.        */
595 /*--------------------------------------------------------------------------*/
596 static void
597 update_prefs_from_object_page (glPrefsDialog *dialog)
598 {
599         guint     color;
600         gboolean  is_default;
601
602         if (dialog->priv->stop_signals) return;
603
604         gl_prefs_model_set_default_font_family (gl_prefs,
605                 gl_font_combo_get_family (GL_FONT_COMBO (dialog->priv->text_family_combo)));
606         gl_prefs_model_set_default_font_size (gl_prefs,
607                 gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_size_spin)));
608
609         if (gtk_toggle_button_get_active
610             (GTK_TOGGLE_BUTTON (dialog->priv->text_bold_toggle)))
611         {
612                 gl_prefs_model_set_default_font_weight (gl_prefs, PANGO_WEIGHT_BOLD);
613         }
614         else
615         {
616                 gl_prefs_model_set_default_font_weight (gl_prefs, PANGO_WEIGHT_NORMAL);
617         }
618
619         gl_prefs_model_set_default_font_italic_flag (gl_prefs,
620                 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
621                                               (dialog->priv->text_italic_toggle)));
622
623         color = gl_color_combo_get_color (GL_COLOR_COMBO(dialog->priv->text_color_combo),
624                                           &is_default);
625         if (!is_default)
626         {
627                 gl_prefs_model_set_default_text_color (gl_prefs, color);
628         }
629
630         if (gtk_toggle_button_get_active
631             (GTK_TOGGLE_BUTTON (dialog->priv->text_left_toggle)))
632         {
633                 gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_LEFT);
634         }
635         else if (gtk_toggle_button_get_active
636                  (GTK_TOGGLE_BUTTON (dialog->priv->text_right_toggle)))
637         {
638                 gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_RIGHT);
639         }
640         else if (gtk_toggle_button_get_active
641                  (GTK_TOGGLE_BUTTON (dialog->priv->text_center_toggle)))
642         {
643                 gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_CENTER);
644         }
645         else
646         {
647                 /* Should not happen. */
648                 gl_prefs_model_set_default_text_alignment (gl_prefs, GTK_JUSTIFY_LEFT);
649         }
650                                                                                 
651
652         gl_prefs_model_set_default_text_line_spacing (gl_prefs,
653                 gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->text_line_spacing_spin)));
654
655         gl_prefs_model_set_default_line_width (gl_prefs,
656                 gtk_spin_button_get_value (GTK_SPIN_BUTTON(dialog->priv->line_width_spin)));
657
658         color = gl_color_combo_get_color (GL_COLOR_COMBO(dialog->priv->line_color_combo),
659                                           &is_default);
660         if (!is_default)
661         {
662                 gl_prefs_model_set_default_line_color (gl_prefs, color);
663         }
664
665
666         color = gl_color_combo_get_color (GL_COLOR_COMBO(dialog->priv->fill_color_combo),
667                                           &is_default);
668         if (!is_default)
669         {
670                 gl_prefs_model_set_default_fill_color (gl_prefs, color);
671         }
672 }
673
674
675
676 /*
677  * Local Variables:       -- emacs
678  * mode: C                -- emacs
679  * c-basic-offset: 8      -- emacs
680  * tab-width: 8           -- emacs
681  * indent-tabs-mode: nil  -- emacs
682  * End:                   -- emacs
683  */