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 gboolean selection_is_italic, is_italic;
515 gboolean selection_is_bold, is_bold;
516 GtkJustification selection_justification, justification;
519 can_text = gl_view_can_selection_text (view);
520 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
528 is_same_justification =
531 is_same_font_family = TRUE;
532 selection_font_family = NULL;
533 selection_font_size = -1;
534 is_first_object = TRUE;
536 for (p = view->selected_object_list; p != NULL; p = p->next) {
538 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
539 if (!gl_label_object_can_text (object))
542 font_family = gl_label_object_get_font_family (object);
543 if (font_family != NULL) {
544 if (selection_font_family == NULL)
545 selection_font_family = g_strdup (font_family);
547 if (strcmp (font_family, selection_font_family) != 0)
548 is_same_font_family = FALSE;
549 g_free (font_family);
552 font_size = gl_label_object_get_font_size (object);
553 text_color = gl_label_object_get_text_color (object);
554 is_italic = gl_label_object_get_font_italic_flag (object);
555 is_bold = gl_label_object_get_font_weight (object) == GNOME_FONT_BOLD;
556 justification = gl_label_object_get_text_alignment (object);
558 if (is_first_object) {
559 selection_font_size = font_size;
560 selection_text_color = text_color;
561 selection_is_italic = is_italic;
562 selection_is_bold = is_bold;
563 selection_justification = justification;
565 if (font_size != selection_font_size)
566 is_same_font_size = FALSE;
567 if (text_color != selection_text_color)
568 is_same_text_color = FALSE;
569 if (is_italic != selection_is_italic)
570 is_same_is_italic = FALSE;
571 if (is_bold != selection_is_bold)
572 is_same_is_bold = FALSE;
573 if (justification != selection_justification)
574 is_same_justification = FALSE;
576 is_first_object = FALSE;
579 if (is_same_font_family && (selection_font_family != NULL))
580 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
581 selection_font_family);
582 gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry),
583 is_same_font_family?selection_font_family:"");
584 g_free (selection_font_family);
586 if (is_same_font_size) {
587 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g",
588 selection_font_size);
589 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->font_size_spin),
590 selection_font_size);
592 gtk_entry_set_text (GTK_ENTRY (property_bar->font_size_spin), "");
595 if (is_same_text_color) {
596 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
597 gdk_color = gl_color_to_gdk_color (selection_text_color);
598 color_combo_set_color (COLOR_COMBO (property_bar->text_color_combo),
603 if (is_same_is_italic)
604 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
605 selection_is_italic);
606 gl_ui_util_set_verb_state (property_bar->ui_component,
607 "/commands/PropFontItalic",
608 selection_is_italic && is_same_is_italic);
611 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
613 gl_ui_util_set_verb_state (property_bar->ui_component,
614 "/commands/PropFontBold",
615 selection_is_bold && is_same_is_bold);
617 if (is_same_justification)
618 gl_debug (DEBUG_PROPERTY_BAR, "same justification");
619 gl_ui_util_set_verb_state (property_bar->ui_component,
620 "/commands/PropTextAlignRight",
621 (selection_justification == GTK_JUSTIFY_RIGHT) &&
622 is_same_justification);
623 gl_ui_util_set_verb_state (property_bar->ui_component,
624 "/commands/PropTextAlignLeft",
625 (selection_justification == GTK_JUSTIFY_LEFT) &&
626 is_same_justification);
627 gl_ui_util_set_verb_state (property_bar->ui_component,
628 "/commands/PropTextAlignCenter",
629 (selection_justification == GTK_JUSTIFY_CENTER) &&
630 is_same_justification);
634 update_fill_color (glView *view,
635 glUIPropertyBar *property_bar)
637 gboolean can, is_first_object;
638 gboolean is_same_fill_color;
640 glLabelObject *object;
641 guint selection_fill_color, fill_color;
644 can = gl_view_can_selection_fill (view);
645 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
651 is_same_fill_color = TRUE;
652 is_first_object = TRUE;
654 for (p = view->selected_object_list; p != NULL; p = p->next) {
656 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
657 if (!gl_label_object_can_fill (object))
660 fill_color = gl_label_object_get_fill_color (object);
662 if (is_first_object) {
663 selection_fill_color = fill_color;
665 if (fill_color != selection_fill_color)
666 is_same_fill_color = FALSE;
668 is_first_object = FALSE;
671 if (is_same_fill_color) {
672 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
673 gdk_color = gl_color_to_gdk_color (selection_fill_color);
674 color_combo_set_color (COLOR_COMBO (property_bar->fill_color_combo),
681 update_line_color (glView *view,
682 glUIPropertyBar *property_bar)
684 gboolean can, is_first_object;
685 gboolean is_same_line_color;
687 glLabelObject *object;
688 guint selection_line_color, line_color;
691 can = gl_view_can_selection_line_color (view);
692 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
698 is_same_line_color = TRUE;
699 is_first_object = TRUE;
701 for (p = view->selected_object_list; p != NULL; p = p->next) {
703 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
704 if (!gl_label_object_can_line_color (object))
707 line_color = gl_label_object_get_line_color (object);
709 if (is_first_object) {
710 selection_line_color = line_color;
712 if (line_color != selection_line_color)
713 is_same_line_color = FALSE;
715 is_first_object = FALSE;
718 if (is_same_line_color) {
719 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
720 gdk_color = gl_color_to_gdk_color (selection_line_color);
721 color_combo_set_color (COLOR_COMBO (property_bar->line_color_combo),
728 update_line_width (glView *view,
729 glUIPropertyBar *property_bar)
731 gboolean can, is_first_object;
732 gboolean is_same_line_width;
734 glLabelObject *object;
735 gdouble selection_line_width, line_width;
737 can = gl_view_can_selection_line_width (view);
738 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
744 is_same_line_width = TRUE;
745 is_first_object = TRUE;
747 for (p = view->selected_object_list; p != NULL; p = p->next) {
749 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
750 if (!gl_label_object_can_line_width (object))
753 line_width = gl_label_object_get_line_width (object);
755 if (is_first_object) {
756 selection_line_width = line_width;
758 if (line_width != selection_line_width)
759 is_same_line_width = FALSE;
761 is_first_object = FALSE;
764 if (is_same_line_width) {
765 gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
766 gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->line_width_spin),
767 selection_line_width);
769 gtk_entry_set_text (GTK_ENTRY (property_bar->line_width_spin), "");
774 selection_changed_cb (glUIPropertyBar *property_bar)
776 glView *view = property_bar->view;
778 gl_debug (DEBUG_PROPERTY_BAR, "START");
780 g_return_if_fail (view && GL_IS_VIEW (view));
781 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
783 property_bar->stop_signals = TRUE;
785 if (gl_view_is_selection_empty (view)) {
787 /* No selection: make all controls active. */
788 reset_to_default_properties (view, property_bar);
789 gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
794 update_text_properties (view, property_bar);
795 update_fill_color (view, property_bar);
796 update_line_color (view, property_bar);
797 update_line_width (view, property_bar);
801 property_bar->stop_signals = FALSE;
803 gl_debug (DEBUG_PROPERTY_BAR, "END");
806 /*--------------------------------------------------------------------------*/
807 /* PRIVATE. Font family entry changed. */
808 /*--------------------------------------------------------------------------*/
810 font_family_changed_cb (GtkEntry *entry,
811 glUIPropertyBar *property_bar)
815 if (property_bar->stop_signals)
818 gl_debug (DEBUG_PROPERTY_BAR, "START");
820 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
821 selection_changed_cb,
824 font_family = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
825 if ( strlen(font_family) ) {
826 gl_view_set_selection_font_family (property_bar->view,
828 gl_view_set_default_font_family (property_bar->view,
831 g_free (font_family);
833 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
834 selection_changed_cb,
837 gl_debug (DEBUG_PROPERTY_BAR, "END");
840 /*--------------------------------------------------------------------------*/
841 /* PRIVATE. Font size spin button changed. */
842 /*--------------------------------------------------------------------------*/
844 font_size_changed_cb (GtkSpinButton *spin,
845 glUIPropertyBar *property_bar)
849 if (property_bar->stop_signals)
852 gl_debug (DEBUG_PROPERTY_BAR, "START");
854 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
855 selection_changed_cb,
858 font_size = gtk_spin_button_get_value (spin);
860 gl_view_set_selection_font_size (property_bar->view,
862 gl_view_set_default_font_size (property_bar->view,
865 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
866 selection_changed_cb,
869 gl_debug (DEBUG_PROPERTY_BAR, "END");
872 /*--------------------------------------------------------------------------*/
873 /* PRIVATE. Text color combo changed. */
874 /*--------------------------------------------------------------------------*/
876 text_color_changed_cb (ColorCombo *cc,
881 glUIPropertyBar *property_bar)
885 if (property_bar->stop_signals)
888 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
890 gl_debug (DEBUG_PROPERTY_BAR, "START");
892 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
893 selection_changed_cb,
896 text_color = gl_color_from_gdk_color (gdk_color);
898 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
899 text_color, custom, by_user, is_default);
903 gl_view_set_selection_text_color (property_bar->view,
904 gl_prefs->default_text_color);
905 gl_view_set_default_text_color (property_bar->view,
906 gl_prefs->default_text_color);
910 gl_view_set_selection_text_color (property_bar->view,
912 gl_view_set_default_text_color (property_bar->view,
917 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
918 selection_changed_cb,
921 gl_debug (DEBUG_PROPERTY_BAR, "END");
924 /*--------------------------------------------------------------------------*/
925 /* PRIVATE. Fill color combo changed. */
926 /*--------------------------------------------------------------------------*/
928 fill_color_changed_cb (ColorCombo *cc,
933 glUIPropertyBar *property_bar)
937 if (property_bar->stop_signals)
940 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
942 gl_debug (DEBUG_PROPERTY_BAR, "START");
944 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
945 selection_changed_cb,
948 fill_color = gl_color_from_gdk_color (gdk_color);
950 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
951 fill_color, custom, by_user, is_default);
955 gl_view_set_selection_fill_color (property_bar->view,
957 gl_view_set_default_fill_color (property_bar->view,
962 gl_view_set_selection_fill_color (property_bar->view,
964 gl_view_set_default_fill_color (property_bar->view,
969 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
970 selection_changed_cb,
973 gl_debug (DEBUG_PROPERTY_BAR, "END");
976 /*--------------------------------------------------------------------------*/
977 /* PRIVATE. Line color combo changed. */
978 /*--------------------------------------------------------------------------*/
980 line_color_changed_cb (ColorCombo *cc,
985 glUIPropertyBar *property_bar)
989 if (property_bar->stop_signals)
992 g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
994 gl_debug (DEBUG_PROPERTY_BAR, "START");
996 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
997 selection_changed_cb,
1000 line_color = gl_color_from_gdk_color (gdk_color);
1002 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
1003 line_color, custom, by_user, is_default);
1007 gl_view_set_selection_line_color (property_bar->view,
1009 gl_view_set_default_line_color (property_bar->view,
1014 gl_view_set_selection_line_color (property_bar->view,
1016 gl_view_set_default_line_color (property_bar->view,
1021 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1022 selection_changed_cb,
1025 gl_debug (DEBUG_PROPERTY_BAR, "END");
1028 /*--------------------------------------------------------------------------*/
1029 /* PRIVATE. Line width spin button changed. */
1030 /*--------------------------------------------------------------------------*/
1032 line_width_changed_cb (GtkSpinButton *spin,
1033 glUIPropertyBar *property_bar)
1037 if (property_bar->stop_signals)
1040 gl_debug (DEBUG_PROPERTY_BAR, "START");
1042 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
1043 selection_changed_cb,
1046 line_width = gtk_spin_button_get_value (spin);
1048 gl_view_set_selection_line_width (property_bar->view,
1050 gl_view_set_default_line_width (property_bar->view,
1053 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1054 selection_changed_cb,
1057 gl_debug (DEBUG_PROPERTY_BAR, "END");
1060 /*---------------------------------------------------------------------------*/
1061 /* PRIVATE. Property bar item toggled callback. */
1062 /*---------------------------------------------------------------------------*/
1064 prop_item_toggled_cb (BonoboUIComponent *ui_component,
1066 Bonobo_UIComponent_EventType type,
1068 glUIPropertyBar *property_bar)
1072 if (property_bar->stop_signals)
1075 gl_debug (DEBUG_PROPERTY_BAR, "");
1077 g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
1078 selection_changed_cb,
1081 s = (strcmp (state, "1") == 0);
1084 * Font properties: Bold & Italic
1086 if (strcmp (path, "PropFontBold") == 0)
1088 GnomeFontWeight weight = s ? GNOME_FONT_BOLD : GNOME_FONT_BOOK;
1090 gl_view_set_selection_font_weight (property_bar->view, weight);
1091 gl_view_set_default_font_weight (property_bar->view, weight);
1094 if (strcmp (path, "PropFontItalic") == 0)
1096 gl_view_set_selection_font_italic_flag (property_bar->view, s);
1097 gl_view_set_default_font_italic_flag (property_bar->view, s);
1102 * Text alignment group
1104 if (s && (strcmp (path, "PropTextAlignLeft") == 0))
1106 gl_view_set_selection_text_alignment (property_bar->view,
1108 gl_view_set_default_text_alignment (property_bar->view,
1111 /* Adjust state of siblings */
1112 gl_ui_util_set_verb_state (ui_component,
1113 "/commands/PropTextAlignCenter",
1115 gl_ui_util_set_verb_state (ui_component,
1116 "/commands/PropTextAlignRight",
1120 if (s && (strcmp (path, "PropTextAlignCenter") == 0))
1122 gl_view_set_selection_text_alignment (property_bar->view,
1123 GTK_JUSTIFY_CENTER);
1124 gl_view_set_default_text_alignment (property_bar->view,
1125 GTK_JUSTIFY_CENTER);
1127 /* Adjust state of siblings */
1128 gl_ui_util_set_verb_state (ui_component,
1129 "/commands/PropTextAlignLeft",
1131 gl_ui_util_set_verb_state (ui_component,
1132 "/commands/PropTextAlignRight",
1136 if (s && (strcmp (path, "PropTextAlignRight") == 0))
1138 gl_view_set_selection_text_alignment (property_bar->view,
1140 gl_view_set_default_text_alignment (property_bar->view,
1143 /* Adjust state of siblings */
1144 gl_ui_util_set_verb_state (ui_component,
1145 "/commands/PropTextAlignLeft",
1147 gl_ui_util_set_verb_state (ui_component,
1148 "/commands/PropTextAlignCenter",
1152 g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
1153 selection_changed_cb,
1158 /*---------------------------------------------------------------------------------------*/
1159 /* NULL command handler -- hides bogus "verb not found" errors for toggle toolbar items. */
1160 /*---------------------------------------------------------------------------------------*/
1162 null_cmd (BonoboUIComponent *ui_component,
1164 const gchar *verbname)