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