]> git.sur5r.net Git - glabels/blob - glabels2/src/ui-property-bar.c
2007-03-23 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / ui-property-bar.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  *  property-bar.c:  gLabels property bar
7  *
8  *  Copyright (C) 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
25 #include <config.h>
26
27 #include "ui-property-bar.h"
28
29 #include <glib/gi18n.h>
30 #include <glade/glade-xml.h>
31 #include <gtk/gtkcombobox.h>
32 #include <gtk/gtkspinbutton.h>
33 #include <gtk/gtktoolbar.h>
34 #include <gtk/gtktoggletoolbutton.h>
35 #include <gtk/gtktooltips.h>
36 #include <string.h>
37
38 #include "util.h"
39 #include "mygal/widget-color-combo.h"
40 #include "stock-pixmaps/stockpixbufs.h"
41 #include "prefs.h"
42 #include "color.h"
43
44 #include "debug.h"
45
46 /*===========================================================================*/
47 /* Private macros and constants.                                             */
48 /*===========================================================================*/
49
50 /*===========================================================================*/
51 /* Private data types                                                        */
52 /*===========================================================================*/
53
54 struct _glUIPropertyBarPrivate {
55
56         glView     *view;
57
58         GladeXML   *gui;
59
60         GtkWidget  *tool_bar;
61
62         /* Font selection */
63         GtkWidget  *font_family_combo;
64         GtkWidget  *font_size_spin;
65         GtkWidget  *font_bold_toggle;
66         GtkWidget  *font_italic_toggle;
67
68         /* Text alignemnt radios */
69         GtkWidget  *text_align_left_radio;
70         GtkWidget  *text_align_center_radio;
71         GtkWidget  *text_align_right_radio;
72
73         /* Color combos */
74         GtkWidget  *text_color_combo;
75         GtkWidget  *fill_color_combo;
76         GtkWidget  *line_color_combo;
77
78         /* Line width */
79         GtkWidget  *line_width_spin;
80
81         gboolean    stop_signals;
82
83 };
84
85
86 /*===========================================================================*/
87 /* Private globals                                                           */
88 /*===========================================================================*/
89
90 /*===========================================================================*/
91 /* Local function prototypes                                                 */
92 /*===========================================================================*/
93
94 static void     gl_ui_property_bar_finalize      (GObject              *object);
95
96 static void     gl_ui_property_bar_construct     (glUIPropertyBar      *property_bar);
97
98 static void     selection_changed_cb             (glUIPropertyBar      *property_bar);
99
100 static void     font_family_changed_cb           (GtkComboBox          *combo,
101                                                   glUIPropertyBar      *property_bar);
102
103 static void     font_size_changed_cb             (GtkSpinButton        *spin,
104                                                   glUIPropertyBar      *property_bar);
105
106 static void     text_color_changed_cb            (ColorCombo           *cc,
107                                                   GdkColor             *gdk_color,
108                                                   gboolean              custom,
109                                                   gboolean              by_user,
110                                                   gboolean              is_default,
111                                                   glUIPropertyBar      *property_bar);
112
113 static void     fill_color_changed_cb            (ColorCombo           *cc,
114                                                   GdkColor             *gdk_color,
115                                                   gboolean              custom,
116                                                   gboolean              by_user,
117                                                   gboolean              is_default,
118                                                   glUIPropertyBar      *property_bar);
119
120 static void     line_color_changed_cb            (ColorCombo           *cc,
121                                                   GdkColor             *gdk_color,
122                                                   gboolean              custom,
123                                                   gboolean              by_user,
124                                                   gboolean              is_default,
125                                                   glUIPropertyBar      *property_bar);
126
127 static void     line_width_changed_cb            (GtkSpinButton        *spin,
128                                                   glUIPropertyBar      *property_bar);
129
130 static void     font_bold_toggled_cb             (GtkToggleToolButton  *toggle,
131                                                   glUIPropertyBar      *property_bar);
132                                                   
133 static void     font_italic_toggled_cb           (GtkToggleToolButton  *toggle,
134                                                   glUIPropertyBar      *property_bar);
135                                                   
136 static void     text_align_toggled_cb            (GtkToggleToolButton  *toggle,
137                                                   glUIPropertyBar      *property_bar);
138                                                   
139 static void     set_doc_items_sensitive          (glUIPropertyBar      *property_bar,
140                                                   gboolean              state);
141
142 static void     set_text_items_sensitive         (glUIPropertyBar      *property_bar,
143                                                   gboolean              state);
144
145 static void     set_fill_items_sensitive         (glUIPropertyBar      *property_bar,
146                                                   gboolean              state);
147
148 static void     set_line_color_items_sensitive   (glUIPropertyBar      *property_bar,
149                                                   gboolean              state);
150
151 static void     set_line_width_items_sensitive   (glUIPropertyBar      *property_bar,
152                                                   gboolean              state);
153
154 \f
155 /****************************************************************************/
156 /* Boilerplate Object stuff.                                                */
157 /****************************************************************************/
158 G_DEFINE_TYPE (glUIPropertyBar, gl_ui_property_bar, GTK_TYPE_HBOX);
159
160 static void
161 gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
162 {
163         GObjectClass   *object_class     = G_OBJECT_CLASS (class);
164
165         gl_debug (DEBUG_PROPERTY_BAR, "START");
166
167         gl_ui_property_bar_parent_class = g_type_class_peek_parent (class);
168
169         object_class->finalize = gl_ui_property_bar_finalize;
170
171         gl_debug (DEBUG_PROPERTY_BAR, "END");
172 }
173
174 static void
175 gl_ui_property_bar_init (glUIPropertyBar *property_bar)
176 {
177         gl_debug (DEBUG_PROPERTY_BAR, "START");
178
179         property_bar->priv = g_new0 (glUIPropertyBarPrivate, 1);
180
181         property_bar->priv->gui = glade_xml_new (GLABELS_GLADE_DIR "property-bar.glade",
182                                                  "property_toolbar",
183                                                  NULL);
184
185         if (!property_bar->priv->gui) {
186                 g_critical ("Could not open property-bar.glade. gLabels may not be installed correctly!");
187                 return;
188         }
189
190         gl_debug (DEBUG_PROPERTY_BAR, "END");
191 }
192
193 static void
194 gl_ui_property_bar_finalize (GObject *object)
195 {
196         glUIPropertyBar *property_bar = GL_UI_PROPERTY_BAR (object);
197
198         gl_debug (DEBUG_PROPERTY_BAR, "START");
199
200         g_return_if_fail (object != NULL);
201         g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
202
203         if (property_bar->priv->view) {
204                 g_object_unref (G_OBJECT(property_bar->priv->view));
205         }
206         g_free (property_bar->priv);
207
208         G_OBJECT_CLASS (gl_ui_property_bar_parent_class)->finalize (object);
209
210         gl_debug (DEBUG_PROPERTY_BAR, "END");
211 }
212
213 /****************************************************************************/
214 /* Create a NEW property_bar.                                               */
215 /****************************************************************************/
216 GtkWidget *
217 gl_ui_property_bar_new (void)
218 {
219         glUIPropertyBar *property_bar;
220
221         gl_debug (DEBUG_PROPERTY_BAR, "START");
222
223         property_bar = g_object_new (GL_TYPE_UI_PROPERTY_BAR, NULL);
224
225         gl_ui_property_bar_construct (property_bar);
226
227         gl_debug (DEBUG_PROPERTY_BAR, "END");
228
229         return GTK_WIDGET (property_bar);
230 }
231
232 /******************************************************************************/
233 /* Initialize property toolbar.                                               */
234 /******************************************************************************/
235 static void
236 gl_ui_property_bar_construct (glUIPropertyBar   *property_bar)
237 {
238         GList      *family_names = NULL;
239         GList      *family_node;
240         GdkColor   *gdk_color;
241
242         gl_debug (DEBUG_PROPERTY_BAR, "START");
243
244         property_bar->priv->stop_signals = TRUE;
245
246         property_bar->priv->tool_bar = glade_xml_get_widget (property_bar->priv->gui,
247                                                              "property_toolbar");
248         gtk_container_add (GTK_CONTAINER (property_bar), property_bar->priv->tool_bar);
249
250         property_bar->priv->font_family_combo =
251                 glade_xml_get_widget (property_bar->priv->gui, "font_family_combo");
252         property_bar->priv->font_size_spin =
253                 glade_xml_get_widget (property_bar->priv->gui, "font_size_spin");
254         property_bar->priv->font_bold_toggle =
255                 glade_xml_get_widget (property_bar->priv->gui, "font_bold_toggle");
256         property_bar->priv->font_italic_toggle =
257                 glade_xml_get_widget (property_bar->priv->gui, "font_italic_toggle");
258         property_bar->priv->text_align_left_radio =
259                 glade_xml_get_widget (property_bar->priv->gui, "text_align_left_radio");
260         property_bar->priv->text_align_center_radio =
261                 glade_xml_get_widget (property_bar->priv->gui, "text_align_center_radio");
262         property_bar->priv->text_align_right_radio =
263                 glade_xml_get_widget (property_bar->priv->gui, "text_align_right_radio");
264         property_bar->priv->text_color_combo =
265                 glade_xml_get_widget (property_bar->priv->gui, "text_color_combo");
266         property_bar->priv->fill_color_combo =
267                 glade_xml_get_widget (property_bar->priv->gui, "fill_color_combo");
268         property_bar->priv->line_color_combo =
269                 glade_xml_get_widget (property_bar->priv->gui, "line_color_combo");
270         property_bar->priv->line_width_spin =
271                 glade_xml_get_widget (property_bar->priv->gui, "line_width_spin");
272
273         set_doc_items_sensitive (property_bar, FALSE);
274
275         /* Font family entry widget */
276         gl_util_combo_box_add_text_model (GTK_COMBO_BOX (property_bar->priv->font_family_combo));
277         family_names = gl_util_get_font_family_list ();
278         gl_util_combo_box_set_strings (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
279                                        family_names);
280         gtk_widget_set_size_request (property_bar->priv->font_family_combo, 200, -1);
281
282         /* Make sure we have a valid font.  if not provide a good default. */
283         family_node = g_list_find_custom (family_names,
284                                           gl_prefs->default_font_family,
285                                           (GCompareFunc)g_utf8_collate);
286         if (family_node) {
287                 gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
288                                           g_list_position (family_names,
289                                                            family_node));
290         } else {
291                 gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo), 0);
292         }
293         gl_util_font_family_list_free (family_names);
294
295         g_signal_connect (G_OBJECT (property_bar->priv->font_family_combo),
296                           "changed", G_CALLBACK (font_family_changed_cb), property_bar);
297
298         /* Font size entry widget */
299         gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin),
300                                    gl_prefs->default_font_size);
301
302         g_signal_connect (G_OBJECT (property_bar->priv->font_size_spin),
303                           "changed", G_CALLBACK (font_size_changed_cb), property_bar);
304
305
306         /* Bold and Italic toggles */
307         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle),
308                                            (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
309         g_signal_connect (G_OBJECT (property_bar->priv->font_bold_toggle),
310                           "toggled", G_CALLBACK (font_bold_toggled_cb), property_bar);
311         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle),
312                                            gl_prefs->default_font_italic_flag);
313         g_signal_connect (G_OBJECT (property_bar->priv->font_italic_toggle),
314                           "toggled", G_CALLBACK (font_italic_toggled_cb), property_bar);
315
316
317         /* Text alignment radio group */
318         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio),
319                                            (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT));
320         g_signal_connect (G_OBJECT (property_bar->priv->text_align_left_radio),
321                           "toggled", G_CALLBACK (text_align_toggled_cb), property_bar);
322         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio),
323                                            (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER));
324         g_signal_connect (G_OBJECT (property_bar->priv->text_align_center_radio),
325                           "toggled", G_CALLBACK (text_align_toggled_cb), property_bar);
326         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio),
327                                            (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT));
328         g_signal_connect (G_OBJECT (property_bar->priv->text_align_right_radio),
329                           "toggled", G_CALLBACK (text_align_toggled_cb), property_bar);
330
331         /* Text color widget */
332         gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
333         color_combo_set_color (COLOR_COMBO (property_bar->priv->text_color_combo), gdk_color);
334         g_free (gdk_color);
335         g_signal_connect (G_OBJECT (property_bar->priv->text_color_combo),
336                           "color_changed",
337                           G_CALLBACK (text_color_changed_cb), property_bar);
338
339         /* Fill color widget */
340         gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color);
341         color_combo_set_color (COLOR_COMBO (property_bar->priv->fill_color_combo), gdk_color);
342         g_free (gdk_color);
343         g_signal_connect (G_OBJECT (property_bar->priv->fill_color_combo),
344                           "color_changed",
345                           G_CALLBACK (fill_color_changed_cb), property_bar);
346
347         /* Line color widget */
348         gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color);
349         color_combo_set_color (COLOR_COMBO (property_bar->priv->line_color_combo), gdk_color);
350         g_free (gdk_color);
351         g_signal_connect (G_OBJECT (property_bar->priv->line_color_combo),
352                           "color_changed",
353                           G_CALLBACK (line_color_changed_cb), property_bar);
354
355         /* Line width entry widget */
356         g_signal_connect (G_OBJECT (property_bar->priv->line_width_spin),
357                           "changed",
358                           G_CALLBACK (line_width_changed_cb), property_bar);
359
360         property_bar->priv->stop_signals = FALSE;
361
362         gl_debug (DEBUG_PROPERTY_BAR, "END");
363 }
364
365 /****************************************************************************/
366 /* Fill widgets with default values.                                        */
367 /****************************************************************************/
368 static void
369 reset_to_default_properties (glView *view,
370                              glUIPropertyBar *property_bar)
371 {
372         GList     *family_names;
373         gchar     *good_font_family;
374         GdkColor  *gdk_color;
375
376         /* Make sure we have a valid font.  if not provide a good default. */
377         family_names = gl_util_get_font_family_list ();
378         if (g_list_find_custom (family_names,
379                                 view->default_font_family,
380                                 (GCompareFunc)g_utf8_collate)) {
381                 good_font_family = g_strdup (view->default_font_family);
382         } else {
383                 if (family_names != NULL) {
384                         good_font_family = g_strdup (family_names->data); /* 1st entry */
385                 } else {
386                         good_font_family = NULL;
387                 }
388         }
389         gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
390                                            good_font_family);
391         g_free (good_font_family);
392         gl_util_font_family_list_free (family_names);
393
394         gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin),
395                                    view->default_font_size);
396
397         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle),
398                                            (view->default_font_weight == PANGO_WEIGHT_BOLD));
399         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle),
400                                            view->default_font_italic_flag);
401
402         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio),
403                                            (view->default_text_alignment == PANGO_ALIGN_LEFT));
404         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio),
405                                            (view->default_text_alignment == PANGO_ALIGN_CENTER));
406         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio),
407                                            (view->default_text_alignment == PANGO_ALIGN_RIGHT));
408
409         gdk_color = gl_color_to_gdk_color (view->default_text_color);
410         color_combo_set_color (COLOR_COMBO(property_bar->priv->text_color_combo), gdk_color);
411         g_free (gdk_color);
412
413         gdk_color = gl_color_to_gdk_color (view->default_fill_color);
414         color_combo_set_color (COLOR_COMBO(property_bar->priv->fill_color_combo), gdk_color);
415         g_free (gdk_color);
416
417         gdk_color = gl_color_to_gdk_color (view->default_line_color);
418         color_combo_set_color (COLOR_COMBO(property_bar->priv->line_color_combo), gdk_color);
419         g_free (gdk_color);
420
421         gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->line_width_spin),
422                                    view->default_line_width);
423 }
424
425 /****************************************************************************/
426 /* Set view associated with property_bar.                                   */
427 /****************************************************************************/
428 void
429 gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
430                              glView          *view)
431 {
432         glLabel   *label;
433
434         gl_debug (DEBUG_PROPERTY_BAR, "START");
435
436         g_return_if_fail (view && GL_IS_VIEW (view));
437         label = view->label;
438         g_return_if_fail (label && GL_IS_LABEL (label));
439
440         set_doc_items_sensitive (property_bar, TRUE);
441
442         property_bar->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
443
444         reset_to_default_properties (view, property_bar);
445
446         g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
447                                   G_CALLBACK(selection_changed_cb), property_bar);
448
449         g_signal_connect_swapped (G_OBJECT(view->label), "changed",
450                                   G_CALLBACK(selection_changed_cb), property_bar);
451
452         gl_debug (DEBUG_PROPERTY_BAR, "END");
453 }
454
455 /****************************************************************************/
456 /** Set visiblity of property bar's tooltips.                               */
457 /****************************************************************************/
458 void
459 gl_ui_property_bar_set_tooltips (glUIPropertyBar *property_bar,
460                                  gboolean         state)
461 {
462         GtkTooltipsData *data;
463
464         gl_debug (DEBUG_PROPERTY_BAR, "START");
465
466         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR(property_bar));
467
468         /* HACK: peek into one of our widgets to get the tooltips group created by libglade. */
469         data = gtk_tooltips_data_get (property_bar->priv->font_size_spin);
470         g_return_if_fail (data);
471
472         if (state) {
473                 gtk_tooltips_enable (data->tooltips);
474         } else {
475                 gtk_tooltips_disable (data->tooltips);
476         }
477
478         gl_debug (DEBUG_PROPERTY_BAR, "END");
479 }
480
481 /*---------------------------------------------------------------------------*/
482 /* PRIVATE.  View "selection state changed" callback.                        */
483 /*---------------------------------------------------------------------------*/
484 static void
485 update_text_properties (glView *view,
486                         glUIPropertyBar *property_bar)
487 {
488         gboolean        can_text, is_first_object;
489         gboolean        is_same_font_family, is_same_font_size;
490         gboolean        is_same_text_color, is_same_is_italic;
491         gboolean        is_same_is_bold, is_same_align;
492         GList          *p;
493         glLabelObject  *object;
494         gchar          *selection_font_family, *font_family;
495         gdouble         selection_font_size, font_size;
496         guint           selection_text_color, text_color;
497         glColorNode    *text_color_node;
498         gboolean        selection_is_italic, is_italic;
499         gboolean        selection_is_bold, is_bold;
500         PangoAlignment  selection_align, align;
501         GdkColor       *gdk_color;
502
503         can_text = gl_view_can_selection_text (view);
504         set_text_items_sensitive (property_bar, can_text);
505
506         if (!can_text) 
507                 return;
508
509         is_same_is_italic =
510         is_same_is_bold =
511         is_same_align =
512         is_same_text_color =
513         is_same_font_size =
514         is_same_font_family = TRUE;
515         selection_font_family = NULL;
516         selection_font_size = -1;
517         selection_align = PANGO_ALIGN_LEFT;
518         selection_is_italic = TRUE;
519         selection_is_bold = TRUE;
520         selection_text_color = 0;
521         
522         is_first_object = TRUE;
523         
524         for (p = view->selected_object_list; p != NULL; p = p->next) {
525
526                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
527                 if (!gl_label_object_can_text (object)) 
528                         continue;
529
530                 font_family = gl_label_object_get_font_family (object);
531                 if (font_family != NULL) {
532                         if (selection_font_family == NULL)
533                                 selection_font_family = g_strdup (font_family);
534                         else 
535                                 if (strcmp (font_family, selection_font_family) != 0) 
536                                         is_same_font_family = FALSE;
537                         g_free (font_family);
538                 }       
539
540                 font_size = gl_label_object_get_font_size (object);
541                 
542                 text_color_node = gl_label_object_get_text_color (object);
543                 if (text_color_node->field_flag) {
544                         /* If a merge field is set we use the default color for merged color*/
545                         text_color = GL_COLOR_MERGE_DEFAULT;
546                         
547                 } else {
548                         text_color = text_color_node->color;
549                 }
550                 gl_color_node_free (&text_color_node);
551                 
552                 is_italic = gl_label_object_get_font_italic_flag (object);
553                 is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD;
554                 align = gl_label_object_get_text_alignment (object);
555
556                 if (is_first_object) {
557                         selection_font_size = font_size;
558                         selection_text_color = text_color;
559                         selection_is_italic = is_italic;
560                         selection_is_bold = is_bold;
561                         selection_align = align;
562                 } else {
563                         if (font_size != selection_font_size) 
564                                 is_same_font_size = FALSE;
565                         if (text_color != selection_text_color)
566                                 is_same_text_color = FALSE;
567                         if (is_italic != selection_is_italic)
568                                 is_same_is_italic = FALSE;
569                         if (is_bold != selection_is_bold)
570                                 is_same_is_bold = FALSE;
571                         if (align != selection_align)
572                                 is_same_align = FALSE;
573                 }
574                 is_first_object = FALSE;
575         }
576
577         if (is_same_font_family && (selection_font_family != NULL)) 
578                 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s", 
579                           selection_font_family);
580         gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
581                                            is_same_font_family?selection_font_family:"");
582         g_free (selection_font_family);
583
584         if (is_same_font_size) {
585                 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g", 
586                           selection_font_size);
587                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->font_size_spin),
588                                            selection_font_size);
589         } else {
590                 gtk_entry_set_text (GTK_ENTRY (property_bar->priv->font_size_spin), "");
591         }
592
593         if (is_same_text_color) {
594                 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
595                 gdk_color = gl_color_to_gdk_color (selection_text_color);
596                 color_combo_set_color (COLOR_COMBO (property_bar->priv->text_color_combo),
597                                        gdk_color);
598                 g_free (gdk_color);
599         }
600
601         if (is_same_is_italic)  
602                 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d", 
603                           selection_is_italic);
604         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle),
605                                            selection_is_italic && is_same_is_italic);
606
607         if (is_same_is_bold)  
608                 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
609                           selection_is_bold);
610         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle),
611                                            selection_is_bold && is_same_is_bold);
612
613         if (is_same_align) 
614                 gl_debug (DEBUG_PROPERTY_BAR, "same align");
615         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio),
616                                            (selection_align == PANGO_ALIGN_LEFT) &&
617                                            is_same_align);
618         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio),
619                                            (selection_align == PANGO_ALIGN_CENTER) &&
620                                            is_same_align);
621         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio),
622                                            (selection_align == PANGO_ALIGN_RIGHT) &&
623                                            is_same_align);
624 }
625
626 static void
627 update_fill_color (glView *view,
628                    glUIPropertyBar *property_bar)
629 {
630         gboolean can, is_first_object;
631         gboolean is_same_fill_color;
632         GList *p;
633         glLabelObject *object;
634         guint selection_fill_color, fill_color;
635         GdkColor *gdk_color;
636         glColorNode *fill_color_node;
637
638         can = gl_view_can_selection_fill (view);
639         set_fill_items_sensitive (property_bar, can);
640
641         if (!can) 
642                 return;
643
644         is_same_fill_color = TRUE;
645         is_first_object = TRUE;
646         selection_fill_color = 0;
647         
648         for (p = view->selected_object_list; p != NULL; p = p->next) {
649
650                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
651                 if (!gl_label_object_can_fill (object)) 
652                         continue;
653
654                 fill_color_node = gl_label_object_get_fill_color (object);
655                 if (fill_color_node->field_flag) {
656                         /* If a merge field is set we use the default color for merged color*/
657                         fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
658                         
659                 } else {
660                         fill_color = fill_color_node->color;
661                 }
662                 gl_color_node_free (&fill_color_node);
663
664                 if (is_first_object) {
665                         selection_fill_color = fill_color;
666                 } else {
667                         if (fill_color != selection_fill_color)
668                                 is_same_fill_color = FALSE;
669                 }
670                 is_first_object = FALSE;
671         }
672
673         if (is_same_fill_color) {
674                 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
675                 gdk_color = gl_color_to_gdk_color (selection_fill_color);
676                 color_combo_set_color (COLOR_COMBO (property_bar->priv->fill_color_combo),
677                                        gdk_color);
678                 g_free (gdk_color);
679         }
680 }
681
682 static void
683 update_line_color (glView *view,
684                    glUIPropertyBar *property_bar)
685 {
686         gboolean can, is_first_object;
687         gboolean is_same_line_color;
688         GList *p;
689         glLabelObject *object;
690         guint selection_line_color, line_color;
691         glColorNode *line_color_node;
692         GdkColor *gdk_color;
693
694         can = gl_view_can_selection_line_color (view);
695         set_line_color_items_sensitive (property_bar, can);
696
697         if (!can) 
698                 return;
699
700         is_same_line_color = TRUE;
701         is_first_object = TRUE;
702         selection_line_color = 0;
703         
704         for (p = view->selected_object_list; p != NULL; p = p->next) {
705
706                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
707                 if (!gl_label_object_can_line_color (object)) 
708                         continue;
709
710                 line_color_node = gl_label_object_get_line_color (object);
711                 if (line_color_node->field_flag) {
712                         /* If a merge field is set we use the default color for merged color*/
713                         line_color = GL_COLOR_MERGE_DEFAULT;
714                         
715                 } else {
716                         line_color = line_color_node->color;
717                 }
718                 gl_color_node_free (&line_color_node);
719
720                 if (is_first_object) {
721                         selection_line_color = line_color;
722                 } else {
723                         if (line_color != selection_line_color)
724                                 is_same_line_color = FALSE;
725                 }
726                 is_first_object = FALSE;
727         }
728
729         if (is_same_line_color) {
730                 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
731                 gdk_color = gl_color_to_gdk_color (selection_line_color);
732                 color_combo_set_color (COLOR_COMBO (property_bar->priv->line_color_combo),
733                                        gdk_color);
734                 g_free (gdk_color);
735         }
736 }
737
738 static void
739 update_line_width (glView *view,
740                    glUIPropertyBar *property_bar)
741 {
742         gboolean can, is_first_object;
743         gboolean is_same_line_width;
744         GList *p;
745         glLabelObject *object;
746         gdouble selection_line_width, line_width;
747
748         can = gl_view_can_selection_line_width (view);
749         set_line_width_items_sensitive (property_bar, can);
750
751         if (!can) 
752                 return;
753
754         is_same_line_width = TRUE;
755         is_first_object = TRUE;
756         selection_line_width = 0;
757         
758         for (p = view->selected_object_list; p != NULL; p = p->next) {
759
760                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
761                 if (!gl_label_object_can_line_width (object)) 
762                         continue;
763
764                 line_width = gl_label_object_get_line_width (object);
765
766                 if (is_first_object) {
767                         selection_line_width = line_width;
768                 } else {
769                         if (line_width != selection_line_width)
770                                 is_same_line_width = FALSE;
771                 }
772                 is_first_object = FALSE;
773         }
774
775         if (is_same_line_width) {
776                 gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
777                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->line_width_spin),
778                                            selection_line_width);
779         } else {
780                 gtk_entry_set_text (GTK_ENTRY (property_bar->priv->line_width_spin), "");
781         }
782 }
783
784 static void 
785 selection_changed_cb (glUIPropertyBar *property_bar)
786 {
787         glView *view = property_bar->priv->view;
788         
789         gl_debug (DEBUG_PROPERTY_BAR, "START");
790
791         g_return_if_fail (view && GL_IS_VIEW (view));
792         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
793
794         property_bar->priv->stop_signals = TRUE;
795
796         if (gl_view_is_selection_empty (view)) {
797
798                 /* No selection: make all controls active. */
799                 reset_to_default_properties (view, property_bar);
800                 set_doc_items_sensitive (property_bar, TRUE);
801
802         } else {
803
804                 update_text_properties (view, property_bar);
805                 update_fill_color (view, property_bar);
806                 update_line_color (view, property_bar);
807                 update_line_width (view, property_bar);
808
809         }
810
811         property_bar->priv->stop_signals = FALSE;
812
813         gl_debug (DEBUG_PROPERTY_BAR, "END");
814 }
815
816 /*--------------------------------------------------------------------------*/
817 /* PRIVATE.  Font family entry changed.                                     */
818 /*--------------------------------------------------------------------------*/
819 static void
820 font_family_changed_cb (GtkComboBox     *combo,
821                         glUIPropertyBar *property_bar)
822 {
823         gchar *font_family;
824
825         if (property_bar->priv->stop_signals)
826                 return;
827
828         gl_debug (DEBUG_PROPERTY_BAR, "START");
829
830         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
831                                          selection_changed_cb,
832                                          property_bar);
833
834         font_family = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo));
835         if ( strlen(font_family) ) {
836                 gl_view_set_selection_font_family (property_bar->priv->view,
837                                                    font_family);
838                 gl_view_set_default_font_family   (property_bar->priv->view,
839                                                    font_family);
840         }
841         g_free (font_family);
842
843         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
844                                            selection_changed_cb,
845                                            property_bar);
846
847         gl_debug (DEBUG_PROPERTY_BAR, "END");
848 }
849
850 /*--------------------------------------------------------------------------*/
851 /* PRIVATE.  Font size spin button changed.                                 */
852 /*--------------------------------------------------------------------------*/
853 static void
854 font_size_changed_cb (GtkSpinButton        *spin,
855                       glUIPropertyBar      *property_bar)
856 {
857         gdouble font_size;
858
859         if (property_bar->priv->stop_signals)
860                 return;
861
862         gl_debug (DEBUG_PROPERTY_BAR, "START");
863
864         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
865                                          selection_changed_cb,
866                                          property_bar);
867
868         font_size = gtk_spin_button_get_value (spin);
869
870         gl_view_set_selection_font_size (property_bar->priv->view,
871                                          font_size);
872         gl_view_set_default_font_size   (property_bar->priv->view,
873                                          font_size);
874
875         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
876                                            selection_changed_cb,
877                                            property_bar);
878
879         gl_debug (DEBUG_PROPERTY_BAR, "END");
880 }
881
882 /*--------------------------------------------------------------------------*/
883 /* PRIVATE.  Text color combo changed.                                      */
884 /*--------------------------------------------------------------------------*/
885 static void
886 text_color_changed_cb (ColorCombo           *cc,
887                        GdkColor             *gdk_color,
888                        gboolean              custom,
889                        gboolean              by_user,
890                        gboolean              is_default,
891                        glUIPropertyBar      *property_bar)
892 {
893         glColorNode *text_color_node;
894
895         if (property_bar->priv->stop_signals)
896                 return;
897
898         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
899
900         gl_debug (DEBUG_PROPERTY_BAR, "START");
901
902         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
903                                          selection_changed_cb,
904                                          property_bar);
905
906         text_color_node = gl_color_node_new_default ();
907         text_color_node->color = gl_color_from_gdk_color (gdk_color);
908         
909         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
910                   text_color_node->color, custom, by_user, is_default);
911
912         if (is_default) {
913                 text_color_node->color = gl_prefs->default_text_color;
914                 gl_view_set_selection_text_color (property_bar->priv->view,
915                                                   text_color_node);
916                 gl_view_set_default_text_color   (property_bar->priv->view,
917                                                   gl_prefs->default_text_color);
918
919         } else {
920
921                 gl_view_set_selection_text_color (property_bar->priv->view,
922                                                   text_color_node);
923                 gl_view_set_default_text_color   (property_bar->priv->view,
924                                                   text_color_node->color);
925
926         }
927
928         gl_color_node_free (&text_color_node);
929         
930         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
931                                            selection_changed_cb,
932                                            property_bar);
933
934         gl_debug (DEBUG_PROPERTY_BAR, "END");
935 }
936
937 /*--------------------------------------------------------------------------*/
938 /* PRIVATE.  Fill color combo changed.                                      */
939 /*--------------------------------------------------------------------------*/
940 static void
941 fill_color_changed_cb (ColorCombo           *cc,
942                        GdkColor             *gdk_color,
943                        gboolean              custom,
944                        gboolean              by_user,
945                        gboolean              is_default,
946                        glUIPropertyBar      *property_bar)
947 {
948         glColorNode *fill_color_node;
949
950         if (property_bar->priv->stop_signals)
951                 return;
952
953         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
954
955         gl_debug (DEBUG_PROPERTY_BAR, "START");
956
957         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
958                                          selection_changed_cb,
959                                          property_bar);
960
961         fill_color_node = gl_color_node_new_default ();
962
963         fill_color_node->color = gl_color_from_gdk_color (gdk_color);
964
965         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
966                   fill_color_node->color, custom, by_user, is_default);
967
968         if (is_default) {
969
970                 fill_color_node->color = GL_COLOR_NONE;
971                 gl_view_set_selection_fill_color (property_bar->priv->view,
972                                                   fill_color_node);
973                 gl_view_set_default_fill_color   (property_bar->priv->view,
974                                                   fill_color_node->color);
975
976         } else {
977
978                 gl_view_set_selection_fill_color (property_bar->priv->view,
979                                                   fill_color_node);
980                 gl_view_set_default_fill_color   (property_bar->priv->view,
981                                                   fill_color_node->color);
982
983         }
984         gl_color_node_free (&fill_color_node);
985         
986         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
987                                            selection_changed_cb,
988                                            property_bar);
989
990         gl_debug (DEBUG_PROPERTY_BAR, "END");
991 }
992
993 /*--------------------------------------------------------------------------*/
994 /* PRIVATE.  Line color combo changed.                                      */
995 /*--------------------------------------------------------------------------*/
996 static void
997 line_color_changed_cb (ColorCombo           *cc,
998                        GdkColor             *gdk_color,
999                        gboolean              custom,
1000                        gboolean              by_user,
1001                        gboolean              is_default,
1002                        glUIPropertyBar      *property_bar)
1003 {
1004         glColorNode *line_color_node;
1005
1006         if (property_bar->priv->stop_signals)
1007                 return;
1008
1009         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
1010
1011         gl_debug (DEBUG_PROPERTY_BAR, "START");
1012
1013         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1014                                          selection_changed_cb,
1015                                          property_bar);
1016
1017         line_color_node = gl_color_node_new_default ();
1018         line_color_node->color = gl_color_from_gdk_color (gdk_color);
1019
1020         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
1021                   line_color_node->color, custom, by_user, is_default);
1022
1023         if (is_default) {
1024                 line_color_node->color = GL_COLOR_NONE;
1025                 gl_view_set_selection_line_color (property_bar->priv->view,
1026                                                   line_color_node);
1027                 gl_view_set_default_line_color   (property_bar->priv->view,
1028                                                   line_color_node->color);
1029
1030         } else {
1031
1032                 gl_view_set_selection_line_color (property_bar->priv->view,
1033                                                   line_color_node);
1034                 gl_view_set_default_line_color   (property_bar->priv->view,
1035                                                   line_color_node->color);
1036
1037         }
1038         gl_color_node_free (&line_color_node);
1039
1040         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1041                                            selection_changed_cb,
1042                                            property_bar);
1043
1044         gl_debug (DEBUG_PROPERTY_BAR, "END");
1045 }
1046
1047 /*--------------------------------------------------------------------------*/
1048 /* PRIVATE.  Line width spin button changed.                                */
1049 /*--------------------------------------------------------------------------*/
1050 static void
1051 line_width_changed_cb (GtkSpinButton        *spin,
1052                        glUIPropertyBar      *property_bar)
1053 {
1054         gdouble line_width;
1055
1056         if (property_bar->priv->stop_signals)
1057                 return;
1058
1059         gl_debug (DEBUG_PROPERTY_BAR, "START");
1060
1061         if (property_bar->priv->view) {
1062
1063                 g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1064                                                  selection_changed_cb,
1065                                                  property_bar);
1066
1067                 line_width = gtk_spin_button_get_value (spin);
1068
1069                 gl_view_set_selection_line_width (property_bar->priv->view,
1070                                                   line_width);
1071                 gl_view_set_default_line_width   (property_bar->priv->view,
1072                                                   line_width);
1073
1074                 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1075                                                    selection_changed_cb,
1076                                                    property_bar);
1077
1078         }
1079
1080         gl_debug (DEBUG_PROPERTY_BAR, "END");
1081 }
1082
1083 /*---------------------------------------------------------------------------*/
1084 /* PRIVATE.  Font bold toggled callback.                                     */
1085 /*---------------------------------------------------------------------------*/
1086 static void
1087 font_bold_toggled_cb (GtkToggleToolButton  *toggle,
1088                       glUIPropertyBar      *property_bar)
1089 {
1090         gboolean        state;
1091         PangoWeight     weight;
1092
1093
1094         if (property_bar->priv->stop_signals)
1095                 return;
1096
1097         gl_debug (DEBUG_PROPERTY_BAR, "START");
1098
1099         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1100                                          selection_changed_cb,
1101                                          property_bar);
1102
1103         state = gtk_toggle_tool_button_get_active (toggle);
1104
1105         weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
1106
1107         gl_view_set_selection_font_weight (property_bar->priv->view, weight);
1108         gl_view_set_default_font_weight   (property_bar->priv->view, weight);
1109
1110         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1111                                            selection_changed_cb,
1112                                            property_bar);
1113
1114         gl_debug (DEBUG_PROPERTY_BAR, "END");
1115 }
1116                                                   
1117 /*---------------------------------------------------------------------------*/
1118 /* PRIVATE.  Font italic toggled callback.                                   */
1119 /*---------------------------------------------------------------------------*/
1120 static void
1121 font_italic_toggled_cb (GtkToggleToolButton  *toggle,
1122                         glUIPropertyBar      *property_bar)
1123 {
1124         gboolean state;
1125
1126         if (property_bar->priv->stop_signals)
1127                 return;
1128
1129         gl_debug (DEBUG_PROPERTY_BAR, "START");
1130
1131         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1132                                          selection_changed_cb,
1133                                          property_bar);
1134
1135         state = gtk_toggle_tool_button_get_active (toggle);
1136
1137         gl_view_set_selection_font_italic_flag (property_bar->priv->view, state);
1138         gl_view_set_default_font_italic_flag   (property_bar->priv->view, state);
1139
1140         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1141                                            selection_changed_cb,
1142                                            property_bar);
1143
1144         gl_debug (DEBUG_PROPERTY_BAR, "END");
1145 }
1146                                                   
1147 /*---------------------------------------------------------------------------*/
1148 /* PRIVATE.  Text align toggled callback.                                    */
1149 /*---------------------------------------------------------------------------*/
1150 static void
1151 text_align_toggled_cb (GtkToggleToolButton  *toggle,
1152                        glUIPropertyBar      *property_bar)
1153 {
1154         if (property_bar->priv->stop_signals)
1155                 return;
1156
1157         gl_debug (DEBUG_PROPERTY_BAR, "START");
1158
1159         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1160                                          selection_changed_cb,
1161                                          property_bar);
1162
1163         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio)))
1164         {               
1165                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1166                                                       PANGO_ALIGN_LEFT);
1167                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1168                                                       PANGO_ALIGN_LEFT);
1169         }
1170
1171         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio)))
1172         {               
1173                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1174                                                       PANGO_ALIGN_CENTER);
1175                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1176                                                       PANGO_ALIGN_CENTER);
1177         }
1178
1179         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio)))
1180         {
1181                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1182                                                       PANGO_ALIGN_RIGHT);
1183                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1184                                                       PANGO_ALIGN_RIGHT);
1185         }
1186
1187         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1188                                            selection_changed_cb,
1189                                            property_bar);
1190
1191         gl_debug (DEBUG_PROPERTY_BAR, "END");
1192 }
1193
1194
1195 /*****************************************************************************/
1196 /* Construct color combo "Custom widget".                                    */
1197 /*****************************************************************************/
1198 GtkWidget *
1199 gl_ui_property_bar_construct_color_combo (gchar *name,
1200                                           gchar *string1,
1201                                           gchar *string2,
1202                                           gint   int1,
1203                                           gint   int2)
1204 {
1205         GtkWidget  *color_combo;
1206         ColorGroup *cg;
1207         gchar      *cg_name;
1208         guint       color;
1209         GdkColor   *gdk_color;
1210         gchar      *no_color;
1211         GdkPixbuf  *pixbuf = NULL;
1212
1213         switch (int1) {
1214
1215         case 0:
1216                 cg_name  = "text_color_group";
1217                 color    = gl_prefs->default_text_color;
1218                 no_color = _("Default");
1219                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
1220                 break;
1221
1222         case 2:
1223                 cg_name  = "line_color_group";
1224                 color    = gl_prefs->default_line_color;
1225                 no_color = _("No line");
1226                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
1227                 break;
1228
1229         case 1:
1230         default:
1231                 cg_name  = "fill_color_group";
1232                 color    = gl_prefs->default_fill_color;
1233                 no_color = _("No fill");
1234                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
1235                 break;
1236
1237         }
1238
1239         cg = color_group_fetch (cg_name, NULL);
1240         gdk_color = gl_color_to_gdk_color (color);
1241         color_combo = color_combo_new (pixbuf, no_color, gdk_color, cg);
1242         g_free (gdk_color);
1243
1244         color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL);
1245
1246         g_object_unref (G_OBJECT (pixbuf));
1247
1248         return color_combo;
1249 }
1250
1251 /*---------------------------------------------------------------------------*/
1252 /* PRIVATE.  Set sensitivity of doc controls.                                */
1253 /*---------------------------------------------------------------------------*/
1254 static void
1255 set_doc_items_sensitive (glUIPropertyBar      *property_bar,
1256                          gboolean              state)
1257 {
1258         gtk_widget_set_sensitive (property_bar->priv->font_family_combo,       state);
1259         gtk_widget_set_sensitive (property_bar->priv->font_size_spin,          state);
1260         gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle,        state);
1261         gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle,      state);
1262         gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio,   state);
1263         gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state);
1264         gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio,  state);
1265         gtk_widget_set_sensitive (property_bar->priv->text_color_combo,        state);
1266         gtk_widget_set_sensitive (property_bar->priv->fill_color_combo,        state);
1267         gtk_widget_set_sensitive (property_bar->priv->line_color_combo,        state);
1268         gtk_widget_set_sensitive (property_bar->priv->line_width_spin,         state);
1269 }
1270
1271 /*---------------------------------------------------------------------------*/
1272 /* PRIVATE.  Set sensitivity of text related controls.                       */
1273 /*---------------------------------------------------------------------------*/
1274 static void
1275 set_text_items_sensitive (glUIPropertyBar      *property_bar,
1276                           gboolean              state)
1277 {
1278         gtk_widget_set_sensitive (property_bar->priv->font_family_combo,       state);
1279         gtk_widget_set_sensitive (property_bar->priv->font_size_spin,          state);
1280         gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle,        state);
1281         gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle,      state);
1282         gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio,   state);
1283         gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state);
1284         gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio,  state);
1285         gtk_widget_set_sensitive (property_bar->priv->text_color_combo,        state);
1286 }
1287
1288 /*---------------------------------------------------------------------------*/
1289 /* PRIVATE.  Set sensitivity of fill related controls.                       */
1290 /*---------------------------------------------------------------------------*/
1291 static void
1292 set_fill_items_sensitive (glUIPropertyBar      *property_bar,
1293                           gboolean              state)
1294 {
1295         gtk_widget_set_sensitive (property_bar->priv->fill_color_combo,        state);
1296 }
1297
1298 /*---------------------------------------------------------------------------*/
1299 /* PRIVATE.  Set sensitivity of line color related controls.                 */
1300 /*---------------------------------------------------------------------------*/
1301 static void
1302 set_line_color_items_sensitive (glUIPropertyBar      *property_bar,
1303                                 gboolean              state)
1304 {
1305         gtk_widget_set_sensitive (property_bar->priv->line_color_combo,        state);
1306 }
1307
1308 /*---------------------------------------------------------------------------*/
1309 /* PRIVATE.  Set sensitivity of line width related controls.                 */
1310 /*---------------------------------------------------------------------------*/
1311 static void
1312 set_line_width_items_sensitive (glUIPropertyBar      *property_bar,
1313                                 gboolean              state)
1314 {
1315         gtk_widget_set_sensitive (property_bar->priv->line_width_spin,         state);
1316 }
1317
1318