]> git.sur5r.net Git - glabels/blob - glabels2/src/ui-property-bar.c
2007-02-14 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         is_first_object = TRUE;
518         
519         for (p = view->selected_object_list; p != NULL; p = p->next) {
520
521                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
522                 if (!gl_label_object_can_text (object)) 
523                         continue;
524
525                 font_family = gl_label_object_get_font_family (object);
526                 if (font_family != NULL) {
527                         if (selection_font_family == NULL)
528                                 selection_font_family = g_strdup (font_family);
529                         else 
530                                 if (strcmp (font_family, selection_font_family) != 0) 
531                                         is_same_font_family = FALSE;
532                         g_free (font_family);
533                 }       
534
535                 font_size = gl_label_object_get_font_size (object);
536                 
537                 text_color_node = gl_label_object_get_text_color (object);
538                 if (text_color_node->field_flag) {
539                         /* If a merge field is set we use the default color for merged color*/
540                         text_color = GL_COLOR_MERGE_DEFAULT;
541                         
542                 } else {
543                         text_color = text_color_node->color;
544                 }
545                 gl_color_node_free (&text_color_node);
546                 
547                 is_italic = gl_label_object_get_font_italic_flag (object);
548                 is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD;
549                 align = gl_label_object_get_text_alignment (object);
550
551                 if (is_first_object) {
552                         selection_font_size = font_size;
553                         selection_text_color = text_color;
554                         selection_is_italic = is_italic;
555                         selection_is_bold = is_bold;
556                         selection_align = align;
557                 } else {
558                         if (font_size != selection_font_size) 
559                                 is_same_font_size = FALSE;
560                         if (text_color != selection_text_color)
561                                 is_same_text_color = FALSE;
562                         if (is_italic != selection_is_italic)
563                                 is_same_is_italic = FALSE;
564                         if (is_bold != selection_is_bold)
565                                 is_same_is_bold = FALSE;
566                         if (align != selection_align)
567                                 is_same_align = FALSE;
568                 }
569                 is_first_object = FALSE;
570         }
571
572         if (is_same_font_family && (selection_font_family != NULL)) 
573                 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s", 
574                           selection_font_family);
575         gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
576                                            is_same_font_family?selection_font_family:"");
577         g_free (selection_font_family);
578
579         if (is_same_font_size) {
580                 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g", 
581                           selection_font_size);
582                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->font_size_spin),
583                                            selection_font_size);
584         } else {
585                 gtk_entry_set_text (GTK_ENTRY (property_bar->priv->font_size_spin), "");
586         }
587
588         if (is_same_text_color) {
589                 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
590                 gdk_color = gl_color_to_gdk_color (selection_text_color);
591                 color_combo_set_color (COLOR_COMBO (property_bar->priv->text_color_combo),
592                                        gdk_color);
593                 g_free (gdk_color);
594         }
595
596         if (is_same_is_italic)  
597                 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d", 
598                           selection_is_italic);
599         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle),
600                                            selection_is_italic && is_same_is_italic);
601
602         if (is_same_is_bold)  
603                 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
604                           selection_is_bold);
605         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle),
606                                            selection_is_bold && is_same_is_bold);
607
608         if (is_same_align) 
609                 gl_debug (DEBUG_PROPERTY_BAR, "same align");
610         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio),
611                                            (selection_align == PANGO_ALIGN_LEFT) &&
612                                            is_same_align);
613         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio),
614                                            (selection_align == PANGO_ALIGN_CENTER) &&
615                                            is_same_align);
616         gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio),
617                                            (selection_align == PANGO_ALIGN_RIGHT) &&
618                                            is_same_align);
619 }
620
621 static void
622 update_fill_color (glView *view,
623                    glUIPropertyBar *property_bar)
624 {
625         gboolean can, is_first_object;
626         gboolean is_same_fill_color;
627         GList *p;
628         glLabelObject *object;
629         guint selection_fill_color, fill_color;
630         GdkColor *gdk_color;
631         glColorNode *fill_color_node;
632
633         can = gl_view_can_selection_fill (view);
634         set_fill_items_sensitive (property_bar, can);
635
636         if (!can) 
637                 return;
638
639         is_same_fill_color = TRUE;
640         is_first_object = TRUE;
641         
642         for (p = view->selected_object_list; p != NULL; p = p->next) {
643
644                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
645                 if (!gl_label_object_can_fill (object)) 
646                         continue;
647
648                 fill_color_node = gl_label_object_get_fill_color (object);
649                 if (fill_color_node->field_flag) {
650                         /* If a merge field is set we use the default color for merged color*/
651                         fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
652                         
653                 } else {
654                         fill_color = fill_color_node->color;
655                 }
656                 gl_color_node_free (&fill_color_node);
657
658                 if (is_first_object) {
659                         selection_fill_color = fill_color;
660                 } else {
661                         if (fill_color != selection_fill_color)
662                                 is_same_fill_color = FALSE;
663                 }
664                 is_first_object = FALSE;
665         }
666
667         if (is_same_fill_color) {
668                 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
669                 gdk_color = gl_color_to_gdk_color (selection_fill_color);
670                 color_combo_set_color (COLOR_COMBO (property_bar->priv->fill_color_combo),
671                                        gdk_color);
672                 g_free (gdk_color);
673         }
674 }
675
676 static void
677 update_line_color (glView *view,
678                    glUIPropertyBar *property_bar)
679 {
680         gboolean can, is_first_object;
681         gboolean is_same_line_color;
682         GList *p;
683         glLabelObject *object;
684         guint selection_line_color, line_color;
685         glColorNode *line_color_node;
686         GdkColor *gdk_color;
687
688         can = gl_view_can_selection_line_color (view);
689         set_line_color_items_sensitive (property_bar, can);
690
691         if (!can) 
692                 return;
693
694         is_same_line_color = TRUE;
695         is_first_object = TRUE;
696         
697         for (p = view->selected_object_list; p != NULL; p = p->next) {
698
699                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
700                 if (!gl_label_object_can_line_color (object)) 
701                         continue;
702
703                 line_color_node = gl_label_object_get_line_color (object);
704                 if (line_color_node->field_flag) {
705                         /* If a merge field is set we use the default color for merged color*/
706                         line_color = GL_COLOR_MERGE_DEFAULT;
707                         
708                 } else {
709                         line_color = line_color_node->color;
710                 }
711                 gl_color_node_free (&line_color_node);
712
713                 if (is_first_object) {
714                         selection_line_color = line_color;
715                 } else {
716                         if (line_color != selection_line_color)
717                                 is_same_line_color = FALSE;
718                 }
719                 is_first_object = FALSE;
720         }
721
722         if (is_same_line_color) {
723                 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
724                 gdk_color = gl_color_to_gdk_color (selection_line_color);
725                 color_combo_set_color (COLOR_COMBO (property_bar->priv->line_color_combo),
726                                        gdk_color);
727                 g_free (gdk_color);
728         }
729 }
730
731 static void
732 update_line_width (glView *view,
733                    glUIPropertyBar *property_bar)
734 {
735         gboolean can, is_first_object;
736         gboolean is_same_line_width;
737         GList *p;
738         glLabelObject *object;
739         gdouble selection_line_width, line_width;
740
741         can = gl_view_can_selection_line_width (view);
742         set_line_width_items_sensitive (property_bar, can);
743
744         if (!can) 
745                 return;
746
747         is_same_line_width = TRUE;
748         is_first_object = TRUE;
749         
750         for (p = view->selected_object_list; p != NULL; p = p->next) {
751
752                 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
753                 if (!gl_label_object_can_line_width (object)) 
754                         continue;
755
756                 line_width = gl_label_object_get_line_width (object);
757
758                 if (is_first_object) {
759                         selection_line_width = line_width;
760                 } else {
761                         if (line_width != selection_line_width)
762                                 is_same_line_width = FALSE;
763                 }
764                 is_first_object = FALSE;
765         }
766
767         if (is_same_line_width) {
768                 gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
769                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->line_width_spin),
770                                            selection_line_width);
771         } else {
772                 gtk_entry_set_text (GTK_ENTRY (property_bar->priv->line_width_spin), "");
773         }
774 }
775
776 static void 
777 selection_changed_cb (glUIPropertyBar *property_bar)
778 {
779         glView *view = property_bar->priv->view;
780         
781         gl_debug (DEBUG_PROPERTY_BAR, "START");
782
783         g_return_if_fail (view && GL_IS_VIEW (view));
784         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
785
786         property_bar->priv->stop_signals = TRUE;
787
788         if (gl_view_is_selection_empty (view)) {
789
790                 /* No selection: make all controls active. */
791                 reset_to_default_properties (view, property_bar);
792                 set_doc_items_sensitive (property_bar, TRUE);
793
794         } else {
795
796                 update_text_properties (view, property_bar);
797                 update_fill_color (view, property_bar);
798                 update_line_color (view, property_bar);
799                 update_line_width (view, property_bar);
800
801         }
802
803         property_bar->priv->stop_signals = FALSE;
804
805         gl_debug (DEBUG_PROPERTY_BAR, "END");
806 }
807
808 /*--------------------------------------------------------------------------*/
809 /* PRIVATE.  Font family entry changed.                                     */
810 /*--------------------------------------------------------------------------*/
811 static void
812 font_family_changed_cb (GtkComboBox     *combo,
813                         glUIPropertyBar *property_bar)
814 {
815         gchar *font_family;
816
817         if (property_bar->priv->stop_signals)
818                 return;
819
820         gl_debug (DEBUG_PROPERTY_BAR, "START");
821
822         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
823                                          selection_changed_cb,
824                                          property_bar);
825
826         font_family = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo));
827         if ( strlen(font_family) ) {
828                 gl_view_set_selection_font_family (property_bar->priv->view,
829                                                    font_family);
830                 gl_view_set_default_font_family   (property_bar->priv->view,
831                                                    font_family);
832         }
833         g_free (font_family);
834
835         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
836                                            selection_changed_cb,
837                                            property_bar);
838
839         gl_debug (DEBUG_PROPERTY_BAR, "END");
840 }
841
842 /*--------------------------------------------------------------------------*/
843 /* PRIVATE.  Font size spin button changed.                                 */
844 /*--------------------------------------------------------------------------*/
845 static void
846 font_size_changed_cb (GtkSpinButton        *spin,
847                       glUIPropertyBar      *property_bar)
848 {
849         gdouble font_size;
850
851         if (property_bar->priv->stop_signals)
852                 return;
853
854         gl_debug (DEBUG_PROPERTY_BAR, "START");
855
856         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
857                                          selection_changed_cb,
858                                          property_bar);
859
860         font_size = gtk_spin_button_get_value (spin);
861
862         gl_view_set_selection_font_size (property_bar->priv->view,
863                                          font_size);
864         gl_view_set_default_font_size   (property_bar->priv->view,
865                                          font_size);
866
867         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
868                                            selection_changed_cb,
869                                            property_bar);
870
871         gl_debug (DEBUG_PROPERTY_BAR, "END");
872 }
873
874 /*--------------------------------------------------------------------------*/
875 /* PRIVATE.  Text color combo changed.                                      */
876 /*--------------------------------------------------------------------------*/
877 static void
878 text_color_changed_cb (ColorCombo           *cc,
879                        GdkColor             *gdk_color,
880                        gboolean              custom,
881                        gboolean              by_user,
882                        gboolean              is_default,
883                        glUIPropertyBar      *property_bar)
884 {
885         glColorNode *text_color_node;
886
887         if (property_bar->priv->stop_signals)
888                 return;
889
890         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
891
892         gl_debug (DEBUG_PROPERTY_BAR, "START");
893
894         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
895                                          selection_changed_cb,
896                                          property_bar);
897
898         text_color_node = gl_color_node_new_default ();
899         text_color_node->color = gl_color_from_gdk_color (gdk_color);
900         
901         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
902                   text_color_node->color, custom, by_user, is_default);
903
904         if (is_default) {
905                 text_color_node->color = gl_prefs->default_text_color;
906                 gl_view_set_selection_text_color (property_bar->priv->view,
907                                                   text_color_node);
908                 gl_view_set_default_text_color   (property_bar->priv->view,
909                                                   gl_prefs->default_text_color);
910
911         } else {
912
913                 gl_view_set_selection_text_color (property_bar->priv->view,
914                                                   text_color_node);
915                 gl_view_set_default_text_color   (property_bar->priv->view,
916                                                   text_color_node->color);
917
918         }
919
920         gl_color_node_free (&text_color_node);
921         
922         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
923                                            selection_changed_cb,
924                                            property_bar);
925
926         gl_debug (DEBUG_PROPERTY_BAR, "END");
927 }
928
929 /*--------------------------------------------------------------------------*/
930 /* PRIVATE.  Fill color combo changed.                                      */
931 /*--------------------------------------------------------------------------*/
932 static void
933 fill_color_changed_cb (ColorCombo           *cc,
934                        GdkColor             *gdk_color,
935                        gboolean              custom,
936                        gboolean              by_user,
937                        gboolean              is_default,
938                        glUIPropertyBar      *property_bar)
939 {
940         glColorNode *fill_color_node;
941
942         if (property_bar->priv->stop_signals)
943                 return;
944
945         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
946
947         gl_debug (DEBUG_PROPERTY_BAR, "START");
948
949         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
950                                          selection_changed_cb,
951                                          property_bar);
952
953         fill_color_node = gl_color_node_new_default ();
954
955         fill_color_node->color = gl_color_from_gdk_color (gdk_color);
956
957         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
958                   fill_color_node->color, custom, by_user, is_default);
959
960         if (is_default) {
961
962                 fill_color_node->color = GL_COLOR_NONE;
963                 gl_view_set_selection_fill_color (property_bar->priv->view,
964                                                   fill_color_node);
965                 gl_view_set_default_fill_color   (property_bar->priv->view,
966                                                   fill_color_node->color);
967
968         } else {
969
970                 gl_view_set_selection_fill_color (property_bar->priv->view,
971                                                   fill_color_node);
972                 gl_view_set_default_fill_color   (property_bar->priv->view,
973                                                   fill_color_node->color);
974
975         }
976         gl_color_node_free (&fill_color_node);
977         
978         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
979                                            selection_changed_cb,
980                                            property_bar);
981
982         gl_debug (DEBUG_PROPERTY_BAR, "END");
983 }
984
985 /*--------------------------------------------------------------------------*/
986 /* PRIVATE.  Line color combo changed.                                      */
987 /*--------------------------------------------------------------------------*/
988 static void
989 line_color_changed_cb (ColorCombo           *cc,
990                        GdkColor             *gdk_color,
991                        gboolean              custom,
992                        gboolean              by_user,
993                        gboolean              is_default,
994                        glUIPropertyBar      *property_bar)
995 {
996         glColorNode *line_color_node;
997
998         if (property_bar->priv->stop_signals)
999                 return;
1000
1001         g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
1002
1003         gl_debug (DEBUG_PROPERTY_BAR, "START");
1004
1005         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1006                                          selection_changed_cb,
1007                                          property_bar);
1008
1009         line_color_node = gl_color_node_new_default ();
1010         line_color_node->color = gl_color_from_gdk_color (gdk_color);
1011
1012         gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
1013                   line_color_node->color, custom, by_user, is_default);
1014
1015         if (is_default) {
1016                 line_color_node->color = GL_COLOR_NONE;
1017                 gl_view_set_selection_line_color (property_bar->priv->view,
1018                                                   line_color_node);
1019                 gl_view_set_default_line_color   (property_bar->priv->view,
1020                                                   line_color_node->color);
1021
1022         } else {
1023
1024                 gl_view_set_selection_line_color (property_bar->priv->view,
1025                                                   line_color_node);
1026                 gl_view_set_default_line_color   (property_bar->priv->view,
1027                                                   line_color_node->color);
1028
1029         }
1030         gl_color_node_free (&line_color_node);
1031
1032         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1033                                            selection_changed_cb,
1034                                            property_bar);
1035
1036         gl_debug (DEBUG_PROPERTY_BAR, "END");
1037 }
1038
1039 /*--------------------------------------------------------------------------*/
1040 /* PRIVATE.  Line width spin button changed.                                */
1041 /*--------------------------------------------------------------------------*/
1042 static void
1043 line_width_changed_cb (GtkSpinButton        *spin,
1044                        glUIPropertyBar      *property_bar)
1045 {
1046         gdouble line_width;
1047
1048         if (property_bar->priv->stop_signals)
1049                 return;
1050
1051         gl_debug (DEBUG_PROPERTY_BAR, "START");
1052
1053         if (property_bar->priv->view) {
1054
1055                 g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1056                                                  selection_changed_cb,
1057                                                  property_bar);
1058
1059                 line_width = gtk_spin_button_get_value (spin);
1060
1061                 gl_view_set_selection_line_width (property_bar->priv->view,
1062                                                   line_width);
1063                 gl_view_set_default_line_width   (property_bar->priv->view,
1064                                                   line_width);
1065
1066                 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1067                                                    selection_changed_cb,
1068                                                    property_bar);
1069
1070         }
1071
1072         gl_debug (DEBUG_PROPERTY_BAR, "END");
1073 }
1074
1075 /*---------------------------------------------------------------------------*/
1076 /* PRIVATE.  Font bold toggled callback.                                     */
1077 /*---------------------------------------------------------------------------*/
1078 static void
1079 font_bold_toggled_cb (GtkToggleToolButton  *toggle,
1080                       glUIPropertyBar      *property_bar)
1081 {
1082         gboolean        state;
1083         PangoWeight     weight;
1084
1085
1086         if (property_bar->priv->stop_signals)
1087                 return;
1088
1089         gl_debug (DEBUG_PROPERTY_BAR, "START");
1090
1091         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1092                                          selection_changed_cb,
1093                                          property_bar);
1094
1095         state = gtk_toggle_tool_button_get_active (toggle);
1096
1097         weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
1098
1099         gl_view_set_selection_font_weight (property_bar->priv->view, weight);
1100         gl_view_set_default_font_weight   (property_bar->priv->view, weight);
1101
1102         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1103                                            selection_changed_cb,
1104                                            property_bar);
1105
1106         gl_debug (DEBUG_PROPERTY_BAR, "END");
1107 }
1108                                                   
1109 /*---------------------------------------------------------------------------*/
1110 /* PRIVATE.  Font italic toggled callback.                                   */
1111 /*---------------------------------------------------------------------------*/
1112 static void
1113 font_italic_toggled_cb (GtkToggleToolButton  *toggle,
1114                         glUIPropertyBar      *property_bar)
1115 {
1116         gboolean state;
1117
1118         if (property_bar->priv->stop_signals)
1119                 return;
1120
1121         gl_debug (DEBUG_PROPERTY_BAR, "START");
1122
1123         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1124                                          selection_changed_cb,
1125                                          property_bar);
1126
1127         state = gtk_toggle_tool_button_get_active (toggle);
1128
1129         gl_view_set_selection_font_italic_flag (property_bar->priv->view, state);
1130         gl_view_set_default_font_italic_flag   (property_bar->priv->view, state);
1131
1132         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1133                                            selection_changed_cb,
1134                                            property_bar);
1135
1136         gl_debug (DEBUG_PROPERTY_BAR, "END");
1137 }
1138                                                   
1139 /*---------------------------------------------------------------------------*/
1140 /* PRIVATE.  Text align toggled callback.                                    */
1141 /*---------------------------------------------------------------------------*/
1142 static void
1143 text_align_toggled_cb (GtkToggleToolButton  *toggle,
1144                        glUIPropertyBar      *property_bar)
1145 {
1146         if (property_bar->priv->stop_signals)
1147                 return;
1148
1149         gl_debug (DEBUG_PROPERTY_BAR, "START");
1150
1151         g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label),
1152                                          selection_changed_cb,
1153                                          property_bar);
1154
1155         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio)))
1156         {               
1157                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1158                                                       PANGO_ALIGN_LEFT);
1159                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1160                                                       PANGO_ALIGN_LEFT);
1161         }
1162
1163         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio)))
1164         {               
1165                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1166                                                       PANGO_ALIGN_CENTER);
1167                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1168                                                       PANGO_ALIGN_CENTER);
1169         }
1170
1171         if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio)))
1172         {
1173                 gl_view_set_selection_text_alignment (property_bar->priv->view,
1174                                                       PANGO_ALIGN_RIGHT);
1175                 gl_view_set_default_text_alignment   (property_bar->priv->view,
1176                                                       PANGO_ALIGN_RIGHT);
1177         }
1178
1179         g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label),
1180                                            selection_changed_cb,
1181                                            property_bar);
1182
1183         gl_debug (DEBUG_PROPERTY_BAR, "END");
1184 }
1185
1186
1187 /*****************************************************************************/
1188 /* Construct color combo "Custom widget".                                    */
1189 /*****************************************************************************/
1190 GtkWidget *
1191 gl_ui_property_bar_construct_color_combo (gchar *name,
1192                                           gchar *string1,
1193                                           gchar *string2,
1194                                           gint   int1,
1195                                           gint   int2)
1196 {
1197         GtkWidget  *color_combo;
1198         ColorGroup *cg;
1199         gchar      *cg_name;
1200         guint       color;
1201         GdkColor   *gdk_color;
1202         gchar      *no_color;
1203         GdkPixbuf  *pixbuf = NULL;
1204
1205         switch (int1) {
1206
1207         case 0:
1208                 cg_name  = "text_color_group";
1209                 color    = gl_prefs->default_text_color;
1210                 no_color = _("Default");
1211                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
1212                 break;
1213
1214         case 2:
1215                 cg_name  = "line_color_group";
1216                 color    = gl_prefs->default_line_color;
1217                 no_color = _("No line");
1218                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
1219                 break;
1220
1221         case 1:
1222         default:
1223                 cg_name  = "fill_color_group";
1224                 color    = gl_prefs->default_fill_color;
1225                 no_color = _("No fill");
1226                 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
1227                 break;
1228
1229         }
1230
1231         cg = color_group_fetch (cg_name, NULL);
1232         gdk_color = gl_color_to_gdk_color (color);
1233         color_combo = color_combo_new (pixbuf, no_color, gdk_color, cg);
1234         g_free (gdk_color);
1235
1236         color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL);
1237
1238         g_object_unref (G_OBJECT (pixbuf));
1239
1240         return color_combo;
1241 }
1242
1243 /*---------------------------------------------------------------------------*/
1244 /* PRIVATE.  Set sensitivity of doc controls.                                */
1245 /*---------------------------------------------------------------------------*/
1246 static void
1247 set_doc_items_sensitive (glUIPropertyBar      *property_bar,
1248                          gboolean              state)
1249 {
1250         gtk_widget_set_sensitive (property_bar->priv->font_family_combo,       state);
1251         gtk_widget_set_sensitive (property_bar->priv->font_size_spin,          state);
1252         gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle,        state);
1253         gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle,      state);
1254         gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio,   state);
1255         gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state);
1256         gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio,  state);
1257         gtk_widget_set_sensitive (property_bar->priv->text_color_combo,        state);
1258         gtk_widget_set_sensitive (property_bar->priv->fill_color_combo,        state);
1259         gtk_widget_set_sensitive (property_bar->priv->line_color_combo,        state);
1260         gtk_widget_set_sensitive (property_bar->priv->line_width_spin,         state);
1261 }
1262
1263 /*---------------------------------------------------------------------------*/
1264 /* PRIVATE.  Set sensitivity of text related controls.                       */
1265 /*---------------------------------------------------------------------------*/
1266 static void
1267 set_text_items_sensitive (glUIPropertyBar      *property_bar,
1268                           gboolean              state)
1269 {
1270         gtk_widget_set_sensitive (property_bar->priv->font_family_combo,       state);
1271         gtk_widget_set_sensitive (property_bar->priv->font_size_spin,          state);
1272         gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle,        state);
1273         gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle,      state);
1274         gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio,   state);
1275         gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state);
1276         gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio,  state);
1277         gtk_widget_set_sensitive (property_bar->priv->text_color_combo,        state);
1278 }
1279
1280 /*---------------------------------------------------------------------------*/
1281 /* PRIVATE.  Set sensitivity of fill related controls.                       */
1282 /*---------------------------------------------------------------------------*/
1283 static void
1284 set_fill_items_sensitive (glUIPropertyBar      *property_bar,
1285                           gboolean              state)
1286 {
1287         gtk_widget_set_sensitive (property_bar->priv->fill_color_combo,        state);
1288 }
1289
1290 /*---------------------------------------------------------------------------*/
1291 /* PRIVATE.  Set sensitivity of line color related controls.                 */
1292 /*---------------------------------------------------------------------------*/
1293 static void
1294 set_line_color_items_sensitive (glUIPropertyBar      *property_bar,
1295                                 gboolean              state)
1296 {
1297         gtk_widget_set_sensitive (property_bar->priv->line_color_combo,        state);
1298 }
1299
1300 /*---------------------------------------------------------------------------*/
1301 /* PRIVATE.  Set sensitivity of line width related controls.                 */
1302 /*---------------------------------------------------------------------------*/
1303 static void
1304 set_line_width_items_sensitive (glUIPropertyBar      *property_bar,
1305                                 gboolean              state)
1306 {
1307         gtk_widget_set_sensitive (property_bar->priv->line_width_spin,         state);
1308 }
1309
1310