2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * property-bar.c: gLabels property bar
6 * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <libgnomeprint/gnome-font.h>
27 #include "ui-property-bar.h"
29 #include "mygal/widget-color-combo.h"
30 #include "stock-pixmaps/stockpixbufs.h"
36 /*============================================================================*/
37 /* Private macros and constants. */
38 /*============================================================================*/
40 /*============================================================================*/
42 /*============================================================================*/
44 static GObjectClass *parent_class;
46 static gchar* doc_verbs [] = {
47 "/commands/PropFontName",
48 "/commands/PropFontSize",
49 "/commands/PropFontBold",
50 "/commands/PropFontItalic",
51 "/commands/PropTextAlignLeft",
52 "/commands/PropTextAlignCenter",
53 "/commands/PropTextAlignRight",
54 "/commands/PropFillColor",
55 "/commands/PropLineColor",
56 "/commands/PropTextColor",
57 "/commands/PropLineWidth",
62 static gchar* text_verbs [] = {
63 "/commands/PropFontName",
64 "/commands/PropFontSize",
65 "/commands/PropFontBold",
66 "/commands/PropFontItalic",
67 "/commands/PropTextAlignLeft",
68 "/commands/PropTextAlignCenter",
69 "/commands/PropTextAlignRight",
70 "/commands/PropTextColor",
75 static gchar* fill_verbs [] = {
76 "/commands/PropFillColor",
81 static gchar* line_color_verbs [] = {
82 "/commands/PropLineColor",
87 static gchar* line_width_verbs [] = {
88 "/commands/PropLineWidth",
94 /*============================================================================*/
95 /* Local function prototypes */
96 /*============================================================================*/
98 static void gl_ui_property_bar_class_init (glUIPropertyBarClass *class);
99 static void gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar);
100 static void gl_ui_property_bar_finalize (GObject *object);
102 static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
103 BonoboUIComponent *ui_component);
105 static void selection_changed_cb (glUIPropertyBar *property_bar);
107 static void font_family_changed_cb (GtkEntry *entry,
108 glUIPropertyBar *property_bar);
110 static void font_size_changed_cb (GtkSpinButton *spin,
111 glUIPropertyBar *property_bar);
113 static void text_color_changed_cb (ColorCombo *cc,
118 glUIPropertyBar *property_bar);
120 static void fill_color_changed_cb (ColorCombo *cc,
125 glUIPropertyBar *property_bar);
127 static void line_color_changed_cb (ColorCombo *cc,
132 glUIPropertyBar *property_bar);
134 static void line_width_changed_cb (GtkSpinButton *spin,
135 glUIPropertyBar *property_bar);
137 static void prop_item_toggled_cb (BonoboUIComponent *ui_component,
139 Bonobo_UIComponent_EventType type,
141 glUIPropertyBar *property_bar);
143 static void null_cmd (BonoboUIComponent *ui_component,
145 const gchar *verbname);
150 /****************************************************************************/
151 /* Boilerplate Object stuff. */
152 /****************************************************************************/
154 gl_ui_property_bar_get_type (void)
156 static GType type = 0;
159 static const GTypeInfo info = {
160 sizeof (glUIPropertyBarClass),
163 (GClassInitFunc) gl_ui_property_bar_class_init,
166 sizeof (glUIPropertyBar),
168 (GInstanceInitFunc) gl_ui_property_bar_instance_init,
172 type = g_type_register_static (G_TYPE_OBJECT,
173 "glUIPropertyBar", &info, 0);
180 gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
182 GObjectClass *object_class = (GObjectClass *) class;
184 gl_debug (DEBUG_PROPERTY_BAR, "START");
186 parent_class = g_type_class_peek_parent (class);
188 object_class->finalize = gl_ui_property_bar_finalize;
190 gl_debug (DEBUG_PROPERTY_BAR, "END");
194 gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar)
196 gl_debug (DEBUG_PROPERTY_BAR, "START");
198 property_bar->view = NULL;
200 gl_debug (DEBUG_PROPERTY_BAR, "END");
204 gl_ui_property_bar_finalize (GObject *object)
206 glUIPropertyBar *property_bar;
208 gl_debug (DEBUG_PROPERTY_BAR, "START");
210 g_return_if_fail (object != NULL);
211 g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
213 property_bar = GL_UI_PROPERTY_BAR (object);
215 if (property_bar->view) {
216 g_object_unref (G_OBJECT(property_bar->view));
220 G_OBJECT_CLASS (parent_class)->finalize (object);
222 gl_debug (DEBUG_PROPERTY_BAR, "END");
225 /****************************************************************************/
226 /* Create a NEW property_bar. */
227 /****************************************************************************/
229 gl_ui_property_bar_new (BonoboUIComponent *ui_component)
231 glUIPropertyBar *property_bar;
233 gl_debug (DEBUG_PROPERTY_BAR, "START");
235 property_bar = g_object_new (gl_ui_property_bar_get_type (), NULL);
237 gl_ui_property_bar_construct (property_bar, ui_component);
239 gl_debug (DEBUG_PROPERTY_BAR, "END");
241 return G_OBJECT(property_bar);
244 /******************************************************************************/
245 /* Initialize property toolbar. */
246 /******************************************************************************/
248 gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
249 BonoboUIComponent *ui_component)
252 GList *family_names = NULL;
256 gchar *good_font_family;
259 gl_debug (DEBUG_PROPERTY_BAR, "START");
261 property_bar->stop_signals = TRUE;
262 property_bar->ui_component = ui_component;
264 /* Font family entry widget */
265 wcombo = gtk_combo_new ();
266 family_names = gnome_font_family_list ();
267 gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), family_names);
268 property_bar->font_family_entry = GTK_COMBO (wcombo)->entry;
269 gtk_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, TRUE);
270 gtk_entry_set_editable (GTK_ENTRY (property_bar->font_family_entry), FALSE);
271 gtk_widget_set_size_request (wcombo, 200, -1);
273 /* Make sure we have a valid font family. if not provide a good default. */
274 if (g_list_find_custom (family_names,
275 gl_prefs->default_font_family,
276 (GCompareFunc)g_utf8_collate)) {
277 good_font_family = g_strdup (gl_prefs->default_font_family);
279 if (family_names != NULL) {
280 good_font_family = g_strdup (family_names->data); /* 1st entry */
282 good_font_family = NULL;
285 gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
286 g_free (good_font_family);
287 gnome_font_family_list_free (family_names);
289 g_signal_connect (G_OBJECT (property_bar->font_family_entry),
290 "changed", G_CALLBACK (font_family_changed_cb), property_bar);
292 gl_ui_util_insert_widget (ui_component, wcombo, "/PropertyToolbar/PropFontName");
294 /* Font size entry widget */
295 adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0);
296 property_bar->font_size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust),
298 gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
299 gl_prefs->default_font_size);
301 g_signal_connect (G_OBJECT (property_bar->font_size_spin),
302 "changed", G_CALLBACK (font_size_changed_cb), property_bar);
304 gl_ui_util_insert_widget (ui_component, property_bar->font_size_spin,
305 "/PropertyToolbar/PropFontSize");
307 /* Bold and Italic toggles */
308 bonobo_ui_component_add_verb (ui_component, "PropFontBold", null_cmd, NULL);
309 gl_ui_util_set_verb_state (ui_component, "/commands/PropFontBold",
310 (gl_prefs->default_font_weight == GNOME_FONT_BOLD));
311 bonobo_ui_component_add_listener (ui_component, "PropFontBold",
312 (BonoboUIListenerFn)prop_item_toggled_cb,
313 (gpointer)property_bar);
314 bonobo_ui_component_add_verb (ui_component, "PropFontItalic", null_cmd, NULL);
315 gl_ui_util_set_verb_state (ui_component, "/commands/PropFontItalic",
316 gl_prefs->default_font_italic_flag);
317 bonobo_ui_component_add_listener (ui_component, "PropFontItalic",
318 (BonoboUIListenerFn)prop_item_toggled_cb,
319 (gpointer)property_bar);
321 /* Text alignment radio group */
322 bonobo_ui_component_add_verb (ui_component, "PropTextAlignLeft", null_cmd, NULL);
323 gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignLeft",
324 (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT));
325 bonobo_ui_component_add_listener (ui_component, "PropTextAlignLeft",
326 (BonoboUIListenerFn)prop_item_toggled_cb,
327 (gpointer)property_bar);
328 bonobo_ui_component_add_verb (ui_component, "PropTextAlignCenter", null_cmd, NULL);
329 gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignCenter",
330 (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER));
331 bonobo_ui_component_add_listener (ui_component, "PropTextAlignCenter",
332 (BonoboUIListenerFn)prop_item_toggled_cb,
333 (gpointer)property_bar);
334 bonobo_ui_component_add_verb (ui_component, "PropTextAlignRight", null_cmd, NULL);
335 gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignRight",
336 (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT));
337 bonobo_ui_component_add_listener (ui_component, "PropTextAlignRight",
338 (BonoboUIListenerFn)prop_item_toggled_cb,
339 (gpointer)property_bar);
341 /* Text color widget */
342 cg = color_group_fetch ("text_color_group", NULL);
343 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
344 gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
345 property_bar->text_color_combo = color_combo_new (pixbuf, _("Default"),
349 g_signal_connect (G_OBJECT (property_bar->text_color_combo),
351 G_CALLBACK (text_color_changed_cb), property_bar);
353 gl_ui_util_insert_widget (ui_component, property_bar->text_color_combo,
354 "/PropertyToolbar/PropTextColor");
356 /* Fill color widget */
357 cg = color_group_fetch ("fill_color_group", NULL);
358 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
359 gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color);
360 property_bar->fill_color_combo = color_combo_new (pixbuf, _("No fill"),
364 g_signal_connect (G_OBJECT (property_bar->fill_color_combo),
366 G_CALLBACK (fill_color_changed_cb), property_bar);
368 gl_ui_util_insert_widget (ui_component, property_bar->fill_color_combo,
369 "/PropertyToolbar/PropFillColor");
371 /* Line color widget */
372 cg = color_group_fetch ("line_color_group", NULL);
373 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
374 gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color);
375 property_bar->line_color_combo = color_combo_new (pixbuf, _("No line"),
379 g_signal_connect (G_OBJECT (property_bar->line_color_combo),
381 G_CALLBACK (line_color_changed_cb), property_bar);
383 gl_ui_util_insert_widget (ui_component, property_bar->line_color_combo,
384 "/PropertyToolbar/PropLineColor");
386 /* Line width entry widget */
387 adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0);
388 property_bar->line_width_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 0.25, 2);
390 g_signal_connect (G_OBJECT (property_bar->line_width_spin),
392 G_CALLBACK (line_width_changed_cb), property_bar);
394 gl_ui_util_insert_widget (ui_component, property_bar->line_width_spin,
395 "/PropertyToolbar/PropLineWidth");
397 gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
399 property_bar->stop_signals = FALSE;
401 gl_debug (DEBUG_PROPERTY_BAR, "END");
404 /****************************************************************************/
405 /* Fill widgets with default values. */
406 /****************************************************************************/
408 reset_to_default_properties (glView *view,
409 glUIPropertyBar *property_bar)
412 gchar *good_font_family;
415 /* Make sure we have a valid font family. if not provide a good default. */
416 family_names = gnome_font_family_list ();
417 if (g_list_find_custom (family_names,
418 view->default_font_family,
419 (GCompareFunc)g_utf8_collate)) {
420 good_font_family = g_strdup (view->default_font_family);
422 if (family_names != NULL) {
423 good_font_family = g_strdup (family_names->data); /* 1st entry */
425 good_font_family = NULL;
428 gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
429 g_free (good_font_family);
431 gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
432 view->default_font_size);
434 gl_ui_util_set_verb_state (property_bar->ui_component,
435 "/commands/PropFontBold",
436 (view->default_font_weight == GNOME_FONT_BOLD));
437 gl_ui_util_set_verb_state (property_bar->ui_component,
438 "/commands/PropFontItalic",
439 view->default_font_italic_flag);
441 gl_ui_util_set_verb_state (property_bar->ui_component,
442 "/commands/PropTextAlignLeft",
443 (view->default_text_alignment == GTK_JUSTIFY_LEFT));
444 gl_ui_util_set_verb_state (property_bar->ui_component,
445 "/commands/PropTextAlignCenter",
446 (view->default_text_alignment == GTK_JUSTIFY_CENTER));
447 gl_ui_util_set_verb_state (property_bar->ui_component,
448 "/commands/PropTextAlignRight",
449 (view->default_text_alignment == GTK_JUSTIFY_RIGHT));
451 gdk_color = gl_color_to_gdk_color (view->default_text_color);
452 color_combo_set_color (COLOR_COMBO(property_bar->text_color_combo), gdk_color);
455 gdk_color = gl_color_to_gdk_color (view->default_fill_color);
456 color_combo_set_color (COLOR_COMBO(property_bar->fill_color_combo), gdk_color);
459 gdk_color = gl_color_to_gdk_color (view->default_line_color);
460 color_combo_set_color (COLOR_COMBO(property_bar->line_color_combo), gdk_color);
463 gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->line_width_spin),
464 view->default_line_width);
467 /****************************************************************************/
468 /* Set view associated with property_bar. */
469 /****************************************************************************/
471 gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
476 gl_debug (DEBUG_PROPERTY_BAR, "START");
478 g_return_if_fail (view && GL_IS_VIEW (view));
480 g_return_if_fail (label && GL_IS_LABEL (label));
482 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, doc_verbs, TRUE);
484 property_bar->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
486 reset_to_default_properties (view, property_bar);
488 g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
489 G_CALLBACK(selection_changed_cb), property_bar);
491 g_signal_connect_swapped (G_OBJECT(view->label), "changed",
492 G_CALLBACK(selection_changed_cb), property_bar);
494 gl_debug (DEBUG_PROPERTY_BAR, "END");
497 /*---------------------------------------------------------------------------*/
498 /* PRIVATE. View "selection state changed" callback. */
499 /*---------------------------------------------------------------------------*/
502 update_text_properties (glView *view,
503 glUIPropertyBar *property_bar)
505 gboolean can_text, is_first_object;
506 gboolean is_same_font_family, is_same_font_size;
507 gboolean is_same_text_color, is_same_is_italic;
508 gboolean is_same_is_bold, is_same_justification;
510 glLabelObject *object;
511 gchar *selection_font_family, *font_family;
512 gdouble selection_font_size, font_size;
513 guint selection_text_color, text_color;
514 glColorNode *text_color_node;
515 gboolean selection_is_italic, is_italic;
516 gboolean selection_is_bold, is_bold;
517 GtkJustification selection_justification, justification;
520 can_text = gl_view_can_selection_text (view);
521 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
529 is_same_justification =
532 is_same_font_family = TRUE;
533 selection_font_family = NULL;
534 selection_font_size = -1;
535 is_first_object = TRUE;
537 for (p = view->selected_object_list; p != NULL; p = p->next) {
539 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
540 if (!gl_label_object_can_text (object))
543 font_family = gl_label_object_get_font_family (object);
544 if (font_family != NULL) {
545 if (selection_font_family == NULL)
546 selection_font_family = g_strdup (font_family);
548 if (strcmp (font_family, selection_font_family) != 0)
549 is_same_font_family = FALSE;
550 g_free (font_family);
553 font_size = gl_label_object_get_font_size (object);
555 text_color_node = gl_label_object_get_text_color (object);
556 if (text_color_node->field_flag) {
557 /* If a merge field is set we use the default color for merged color*/
558 text_color = GL_COLOR_MERGE_DEFAULT;
561 text_color = text_color_node->color;
563 gl_color_node_free (&text_color_node);
565 is_italic = gl_label_object_get_font_italic_flag (object);
566 is_bold = gl_label_object_get_font_weight (object) == GNOME_FONT_BOLD;
567 justification = gl_label_object_get_text_alignment (object);
569 if (is_first_object) {
570 selection_font_size = font_size;
571 selection_text_color = text_color;
572 selection_is_italic = is_italic;
573 selection_is_bold = is_bold;
574 selection_justification = justification;
576 if (font_size != selection_font_size)
577 is_same_font_size = FALSE;
578 if (text_color != selection_text_color)
579 is_same_text_color = FALSE;
580 if (is_italic != selection_is_italic)
581 is_same_is_italic = FALSE;
582 if (is_bold != selection_is_bold)
583 is_same_is_bold = FALSE;
584 if (justification != selection_justification)
585 is_same_justification = FALSE;
587 is_first_object = FALSE;
590 if (is_same_font_family && (selection_font_family != NULL))
591 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
592 selection_font_family);
593 gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry),
594 is_same_font_family?selection_font_family:"");
595 g_free (selection_font_family);
597 if (is_same_font_size) {
598 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g",
599 selection_font_size);
600 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->font_size_spin),
601 selection_font_size);
603 gtk_entry_set_text (GTK_ENTRY (property_bar->font_size_spin), "");
606 if (is_same_text_color) {
607 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
608 gdk_color = gl_color_to_gdk_color (selection_text_color);
609 color_combo_set_color (COLOR_COMBO (property_bar->text_color_combo),
614 if (is_same_is_italic)
615 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
616 selection_is_italic);
617 gl_ui_util_set_verb_state (property_bar->ui_component,
618 "/commands/PropFontItalic",
619 selection_is_italic && is_same_is_italic);
622 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
624 gl_ui_util_set_verb_state (property_bar->ui_component,
625 "/commands/PropFontBold",
626 selection_is_bold && is_same_is_bold);
628 if (is_same_justification)
629 gl_debug (DEBUG_PROPERTY_BAR, "same justification");
630 gl_ui_util_set_verb_state (property_bar->ui_component,
631 "/commands/PropTextAlignRight",
632 (selection_justification == GTK_JUSTIFY_RIGHT) &&
633 is_same_justification);
634 gl_ui_util_set_verb_state (property_bar->ui_component,
635 "/commands/PropTextAlignLeft",
636 (selection_justification == GTK_JUSTIFY_LEFT) &&
637 is_same_justification);
638 gl_ui_util_set_verb_state (property_bar->ui_component,
639 "/commands/PropTextAlignCenter",
640 (selection_justification == GTK_JUSTIFY_CENTER) &&
641 is_same_justification);
645 update_fill_color (glView *view,
646 glUIPropertyBar *property_bar)
648 gboolean can, is_first_object;
649 gboolean is_same_fill_color;
651 glLabelObject *object;
652 guint selection_fill_color, fill_color;
654 glColorNode *fill_color_node;
656 can = gl_view_can_selection_fill (view);
657 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
663 is_same_fill_color = TRUE;
664 is_first_object = TRUE;
666 for (p = view->selected_object_list; p != NULL; p = p->next) {
668 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
669 if (!gl_label_object_can_fill (object))
672 fill_color_node = gl_label_object_get_fill_color (object);
673 if (fill_color_node->field_flag) {
674 /* If a merge field is set we use the default color for merged color*/
675 fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
678 fill_color = fill_color_node->color;
680 gl_color_node_free (&fill_color_node);
682 if (is_first_object) {
683 selection_fill_color = fill_color;
685 if (fill_color != selection_fill_color)
686 is_same_fill_color = FALSE;
688 is_first_object = FALSE;
691 if (is_same_fill_color) {
692 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
693 gdk_color = gl_color_to_gdk_color (selection_fill_color);
694 color_combo_set_color (COLOR_COMBO (property_bar->fill_color_combo),
701 update_line_color (glView *view,
702 glUIPropertyBar *property_bar)
704 gboolean can, is_first_object;
705 gboolean is_same_line_color;
707 glLabelObject *object;
708 guint selection_line_color, line_color;
709 glColorNode *line_color_node;
712 can = gl_view_can_selection_line_color (view);
713 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
719 is_same_line_color = TRUE;
720 is_first_object = TRUE;
722 for (p = view->selected_object_list; p != NULL; p = p->next) {
724 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
725 if (!gl_label_object_can_line_color (object))
728 line_color_node = gl_label_object_get_line_color (object);
729 if (line_color_node->field_flag) {
730 /* If a merge field is set we use the default color for merged color*/
731 line_color = GL_COLOR_MERGE_DEFAULT;
734 line_color = line_color_node->color;
736 gl_color_node_free (&line_color_node);
738 if (is_first_object) {
739 selection_line_color = line_color;
741 if (line_color != selection_line_color)
742 is_same_line_color = FALSE;
744 is_first_object = FALSE;
747 if (is_same_line_color) {
748 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
749 gdk_color = gl_color_to_gdk_color (selection_line_color);
750 color_combo_set_color (COLOR_COMBO (property_bar->line_color_combo),
757 update_line_width (glView *view,
758 glUIPropertyBar *property_bar)
760 gboolean can, is_first_object;
761 gboolean is_same_line_width;
763 glLabelObject *object;
764 gdouble selection_line_width, line_width;
766 can = gl_view_can_selection_line_width (view);
767 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
773 is_same_line_width = TRUE;
774 is_first_object = TRUE;
776 for (p = view->selected_object_list; p != NULL; p = p->next) {
778 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
779 if (!gl_label_object_can_line_width (object))
782 line_width = gl_label_object_get_line_width (object);
784 if (is_first_object) {
785 selection_line_width = line_width;
787 if (line_width != selection_line_width)
788 is_same_line_width = FALSE;
790 is_first_object = FALSE;
793 if (is_same_line_width) {
794 gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
795 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->line_width_spin),
796 selection_line_width);
798 gtk_entry_set_text (GTK_ENTRY (property_bar->line_width_spin), "");
803 selection_changed_cb (glUIPropertyBar *property_bar)
805 glView *view = property_bar->view;
807 gl_debug (DEBUG_PROPERTY_BAR, "START");
809 g_return_if_fail (view && GL_IS_VIEW (view));
810 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
812 property_bar->stop_signals = TRUE;
814 if (gl_view_is_selection_empty (view)) {
816 /* No selection: make all controls active. */
817 reset_to_default_properties (view, property_bar);
818 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
823 update_text_properties (view, property_bar);
824 update_fill_color (view, property_bar);
825 update_line_color (view, property_bar);
826 update_line_width (view, property_bar);
830 property_bar->stop_signals = FALSE;
832 gl_debug (DEBUG_PROPERTY_BAR, "END");
835 /*--------------------------------------------------------------------------*/
836 /* PRIVATE. Font family entry changed. */
837 /*--------------------------------------------------------------------------*/
839 font_family_changed_cb (GtkEntry *entry,
840 glUIPropertyBar *property_bar)
844 if (property_bar->stop_signals)
847 gl_debug (DEBUG_PROPERTY_BAR, "START");
849 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
850 selection_changed_cb,
853 font_family = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
854 if ( strlen(font_family) ) {
855 gl_view_set_selection_font_family (property_bar->view,
857 gl_view_set_default_font_family (property_bar->view,
860 g_free (font_family);
862 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
863 selection_changed_cb,
866 gl_debug (DEBUG_PROPERTY_BAR, "END");
869 /*--------------------------------------------------------------------------*/
870 /* PRIVATE. Font size spin button changed. */
871 /*--------------------------------------------------------------------------*/
873 font_size_changed_cb (GtkSpinButton *spin,
874 glUIPropertyBar *property_bar)
878 if (property_bar->stop_signals)
881 gl_debug (DEBUG_PROPERTY_BAR, "START");
883 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
884 selection_changed_cb,
887 font_size = gtk_spin_button_get_value (spin);
889 gl_view_set_selection_font_size (property_bar->view,
891 gl_view_set_default_font_size (property_bar->view,
894 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
895 selection_changed_cb,
898 gl_debug (DEBUG_PROPERTY_BAR, "END");
901 /*--------------------------------------------------------------------------*/
902 /* PRIVATE. Text color combo changed. */
903 /*--------------------------------------------------------------------------*/
905 text_color_changed_cb (ColorCombo *cc,
910 glUIPropertyBar *property_bar)
912 glColorNode *text_color_node;
914 if (property_bar->stop_signals)
917 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
919 gl_debug (DEBUG_PROPERTY_BAR, "START");
921 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
922 selection_changed_cb,
925 text_color_node = gl_color_node_new_default ();
926 text_color_node->color = gl_color_from_gdk_color (gdk_color);
928 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
929 text_color_node->color, custom, by_user, is_default);
932 text_color_node->color = gl_prefs->default_text_color;
933 gl_view_set_selection_text_color (property_bar->view,
935 gl_view_set_default_text_color (property_bar->view,
936 gl_prefs->default_text_color);
940 gl_view_set_selection_text_color (property_bar->view,
942 gl_view_set_default_text_color (property_bar->view,
943 text_color_node->color);
947 gl_color_node_free (&text_color_node);
949 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
950 selection_changed_cb,
953 gl_debug (DEBUG_PROPERTY_BAR, "END");
956 /*--------------------------------------------------------------------------*/
957 /* PRIVATE. Fill color combo changed. */
958 /*--------------------------------------------------------------------------*/
960 fill_color_changed_cb (ColorCombo *cc,
965 glUIPropertyBar *property_bar)
967 glColorNode *fill_color_node;
969 if (property_bar->stop_signals)
972 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
974 gl_debug (DEBUG_PROPERTY_BAR, "START");
976 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
977 selection_changed_cb,
980 fill_color_node = gl_color_node_new_default ();
982 fill_color_node->color = gl_color_from_gdk_color (gdk_color);
984 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
985 fill_color_node->color, custom, by_user, is_default);
989 fill_color_node->color = GL_COLOR_NONE;
990 gl_view_set_selection_fill_color (property_bar->view,
992 gl_view_set_default_fill_color (property_bar->view,
993 fill_color_node->color);
997 gl_view_set_selection_fill_color (property_bar->view,
999 gl_view_set_default_fill_color (property_bar->view,
1000 fill_color_node->color);
1003 gl_color_node_free (&fill_color_node);
1005 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1006 selection_changed_cb,
1009 gl_debug (DEBUG_PROPERTY_BAR, "END");
1012 /*--------------------------------------------------------------------------*/
1013 /* PRIVATE. Line color combo changed. */
1014 /*--------------------------------------------------------------------------*/
1016 line_color_changed_cb (ColorCombo *cc,
1017 GdkColor *gdk_color,
1020 gboolean is_default,
1021 glUIPropertyBar *property_bar)
1023 glColorNode *line_color_node;
1025 if (property_bar->stop_signals)
1028 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
1030 gl_debug (DEBUG_PROPERTY_BAR, "START");
1032 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
1033 selection_changed_cb,
1036 line_color_node = gl_color_node_new_default ();
1037 line_color_node->color = gl_color_from_gdk_color (gdk_color);
1039 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
1040 line_color_node->color, custom, by_user, is_default);
1043 line_color_node->color = GL_COLOR_NONE;
1044 gl_view_set_selection_line_color (property_bar->view,
1046 gl_view_set_default_line_color (property_bar->view,
1047 line_color_node->color);
1051 gl_view_set_selection_line_color (property_bar->view,
1053 gl_view_set_default_line_color (property_bar->view,
1054 line_color_node->color);
1057 gl_color_node_free (&line_color_node);
1059 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1060 selection_changed_cb,
1063 gl_debug (DEBUG_PROPERTY_BAR, "END");
1066 /*--------------------------------------------------------------------------*/
1067 /* PRIVATE. Line width spin button changed. */
1068 /*--------------------------------------------------------------------------*/
1070 line_width_changed_cb (GtkSpinButton *spin,
1071 glUIPropertyBar *property_bar)
1075 if (property_bar->stop_signals)
1078 gl_debug (DEBUG_PROPERTY_BAR, "START");
1080 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
1081 selection_changed_cb,
1084 line_width = gtk_spin_button_get_value (spin);
1086 gl_view_set_selection_line_width (property_bar->view,
1088 gl_view_set_default_line_width (property_bar->view,
1091 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1092 selection_changed_cb,
1095 gl_debug (DEBUG_PROPERTY_BAR, "END");
1098 /*---------------------------------------------------------------------------*/
1099 /* PRIVATE. Property bar item toggled callback. */
1100 /*---------------------------------------------------------------------------*/
1102 prop_item_toggled_cb (BonoboUIComponent *ui_component,
1104 Bonobo_UIComponent_EventType type,
1106 glUIPropertyBar *property_bar)
1110 if (property_bar->stop_signals)
1113 gl_debug (DEBUG_PROPERTY_BAR, "");
1115 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
1116 selection_changed_cb,
1119 s = (strcmp (state, "1") == 0);
1122 * Font properties: Bold & Italic
1124 if (strcmp (path, "PropFontBold") == 0)
1126 GnomeFontWeight weight = s ? GNOME_FONT_BOLD : GNOME_FONT_BOOK;
1128 gl_view_set_selection_font_weight (property_bar->view, weight);
1129 gl_view_set_default_font_weight (property_bar->view, weight);
1132 if (strcmp (path, "PropFontItalic") == 0)
1134 gl_view_set_selection_font_italic_flag (property_bar->view, s);
1135 gl_view_set_default_font_italic_flag (property_bar->view, s);
1140 * Text alignment group
1142 if (s && (strcmp (path, "PropTextAlignLeft") == 0))
1144 gl_view_set_selection_text_alignment (property_bar->view,
1146 gl_view_set_default_text_alignment (property_bar->view,
1149 /* Adjust state of siblings */
1150 gl_ui_util_set_verb_state (ui_component,
1151 "/commands/PropTextAlignCenter",
1153 gl_ui_util_set_verb_state (ui_component,
1154 "/commands/PropTextAlignRight",
1158 if (s && (strcmp (path, "PropTextAlignCenter") == 0))
1160 gl_view_set_selection_text_alignment (property_bar->view,
1161 GTK_JUSTIFY_CENTER);
1162 gl_view_set_default_text_alignment (property_bar->view,
1163 GTK_JUSTIFY_CENTER);
1165 /* Adjust state of siblings */
1166 gl_ui_util_set_verb_state (ui_component,
1167 "/commands/PropTextAlignLeft",
1169 gl_ui_util_set_verb_state (ui_component,
1170 "/commands/PropTextAlignRight",
1174 if (s && (strcmp (path, "PropTextAlignRight") == 0))
1176 gl_view_set_selection_text_alignment (property_bar->view,
1178 gl_view_set_default_text_alignment (property_bar->view,
1181 /* Adjust state of siblings */
1182 gl_ui_util_set_verb_state (ui_component,
1183 "/commands/PropTextAlignLeft",
1185 gl_ui_util_set_verb_state (ui_component,
1186 "/commands/PropTextAlignCenter",
1190 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1191 selection_changed_cb,
1196 /*---------------------------------------------------------------------------------------*/
1197 /* NULL command handler -- hides bogus "verb not found" errors for toggle toolbar items. */
1198 /*---------------------------------------------------------------------------------------*/
1200 null_cmd (BonoboUIComponent *ui_component,
1202 const gchar *verbname)