3 * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "ui-property-bar.h"
25 #include <glib/gi18n.h>
26 #include <gtk/gtkbuilder.h>
27 #include <gtk/gtkcombobox.h>
28 #include <gtk/gtkspinbutton.h>
29 #include <gtk/gtktoolbar.h>
30 #include <gtk/gtktoggletoolbutton.h>
34 #include "color-combo.h"
35 #include "stock-pixmaps/stockpixbufs.h"
42 /*===========================================================================*/
43 /* Private macros and constants. */
44 /*===========================================================================*/
47 /*===========================================================================*/
48 /* Private data types */
49 /*===========================================================================*/
51 struct _glUIPropertyBarPrivate {
60 GtkWidget *font_family_combo;
61 GtkWidget *font_size_spin;
62 GtkWidget *font_bold_toggle;
63 GtkWidget *font_italic_toggle;
65 /* Text alignemnt radios */
66 GtkWidget *text_align_left_radio;
67 GtkWidget *text_align_center_radio;
68 GtkWidget *text_align_right_radio;
71 GtkWidget *text_color_eventbox;
72 GtkWidget *text_color_combo;
73 GtkWidget *fill_color_combo;
74 GtkWidget *fill_color_eventbox;
75 GtkWidget *line_color_combo;
76 GtkWidget *line_color_eventbox;
79 GtkWidget *line_width_spin;
81 /* Prevent recursion */
82 gboolean stop_signals;
86 /*===========================================================================*/
88 /*===========================================================================*/
91 /*===========================================================================*/
92 /* Local function prototypes */
93 /*===========================================================================*/
95 static void gl_ui_property_bar_finalize (GObject *object);
97 static void gl_ui_property_bar_construct (glUIPropertyBar *this);
99 static void selection_changed_cb (glUIPropertyBar *this);
101 static void font_family_changed_cb (GtkComboBox *combo,
102 glUIPropertyBar *this);
104 static void font_size_changed_cb (GtkSpinButton *spin,
105 glUIPropertyBar *this);
107 static void text_color_changed_cb (glColorCombo *cc,
110 glUIPropertyBar *this);
112 static void fill_color_changed_cb (glColorCombo *cc,
115 glUIPropertyBar *this);
117 static void line_color_changed_cb (glColorCombo *cc,
120 glUIPropertyBar *this);
122 static void line_width_changed_cb (GtkSpinButton *spin,
123 glUIPropertyBar *this);
125 static void font_bold_toggled_cb (GtkToggleToolButton *toggle,
126 glUIPropertyBar *this);
128 static void font_italic_toggled_cb (GtkToggleToolButton *toggle,
129 glUIPropertyBar *this);
131 static void text_align_toggled_cb (GtkToggleToolButton *toggle,
132 glUIPropertyBar *this);
134 static void set_doc_items_sensitive (glUIPropertyBar *this,
137 static void set_text_items_sensitive (glUIPropertyBar *this,
140 static void set_fill_items_sensitive (glUIPropertyBar *this,
143 static void set_line_color_items_sensitive (glUIPropertyBar *this,
146 static void set_line_width_items_sensitive (glUIPropertyBar *this,
150 /****************************************************************************/
151 /* Boilerplate Object stuff. */
152 /****************************************************************************/
153 G_DEFINE_TYPE (glUIPropertyBar, gl_ui_property_bar, GTK_TYPE_HBOX);
157 gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
159 GObjectClass *object_class = G_OBJECT_CLASS (class);
161 gl_debug (DEBUG_PROPERTY_BAR, "START");
163 gl_ui_property_bar_parent_class = g_type_class_peek_parent (class);
165 object_class->finalize = gl_ui_property_bar_finalize;
167 gl_debug (DEBUG_PROPERTY_BAR, "END");
172 gl_ui_property_bar_init (glUIPropertyBar *this)
174 gl_debug (DEBUG_PROPERTY_BAR, "START");
176 this->priv = g_new0 (glUIPropertyBarPrivate, 1);
178 gl_debug (DEBUG_PROPERTY_BAR, "END");
183 gl_ui_property_bar_finalize (GObject *object)
185 glUIPropertyBar *this = GL_UI_PROPERTY_BAR (object);
187 gl_debug (DEBUG_PROPERTY_BAR, "START");
189 g_return_if_fail (object != NULL);
190 g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
192 if (this->priv->view)
194 g_object_unref (G_OBJECT(this->priv->view));
196 if (this->priv->builder)
198 g_object_unref (G_OBJECT(this->priv->builder));
202 G_OBJECT_CLASS (gl_ui_property_bar_parent_class)->finalize (object);
204 gl_debug (DEBUG_PROPERTY_BAR, "END");
208 /****************************************************************************/
209 /* Create a NEW property_bar. */
210 /****************************************************************************/
212 gl_ui_property_bar_new (void)
214 glUIPropertyBar *this;
216 gl_debug (DEBUG_PROPERTY_BAR, "START");
218 this = g_object_new (GL_TYPE_UI_PROPERTY_BAR, NULL);
220 gl_ui_property_bar_construct (this);
222 gl_debug (DEBUG_PROPERTY_BAR, "END");
224 return GTK_WIDGET (this);
228 /******************************************************************************/
229 /* Initialize property toolbar. */
230 /******************************************************************************/
232 gl_ui_property_bar_construct (glUIPropertyBar *this)
235 static gchar *object_ids[] = { "property_toolbar",
236 "adjustment1", "adjustment2",
238 GError *error = NULL;
239 GList *family_names = NULL;
241 GdkPixbuf *pixbuf = NULL;
243 gl_debug (DEBUG_PROPERTY_BAR, "START");
245 this->priv->stop_signals = TRUE;
247 builder = gtk_builder_new ();
248 gtk_builder_add_objects_from_file (builder,
249 GLABELS_BUILDER_DIR "property-bar.builder",
253 g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
254 g_error_free (error);
258 gl_util_get_builder_widgets (builder,
259 "property_toolbar", &this->priv->tool_bar,
260 "font_family_combo", &this->priv->font_family_combo,
261 "font_size_spin", &this->priv->font_size_spin,
262 "font_bold_toggle", &this->priv->font_bold_toggle,
263 "font_italic_toggle", &this->priv->font_italic_toggle,
264 "text_align_left_radio", &this->priv->text_align_left_radio,
265 "text_align_center_radio", &this->priv->text_align_center_radio,
266 "text_align_right_radio", &this->priv->text_align_right_radio,
267 "text_color_eventbox", &this->priv->text_color_eventbox,
268 "fill_color_eventbox", &this->priv->fill_color_eventbox,
269 "line_color_eventbox", &this->priv->line_color_eventbox,
270 "line_width_spin", &this->priv->line_width_spin,
273 gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar);
275 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
276 this->priv->text_color_combo =
277 gl_color_combo_new (pixbuf,
279 GL_COLOR_TEXT_DEFAULT,
280 gl_prefs->default_text_color);
281 gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->text_color_combo),
283 g_object_unref (G_OBJECT (pixbuf));
284 gtk_container_add (GTK_CONTAINER (this->priv->text_color_eventbox),
285 this->priv->text_color_combo);
287 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
288 this->priv->fill_color_combo =
289 gl_color_combo_new (pixbuf,
292 gl_prefs->default_fill_color);
293 gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->fill_color_combo),
295 g_object_unref (G_OBJECT (pixbuf));
296 gtk_container_add (GTK_CONTAINER (this->priv->fill_color_eventbox),
297 this->priv->fill_color_combo);
299 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
300 this->priv->line_color_combo =
301 gl_color_combo_new (pixbuf,
304 gl_prefs->default_line_color);
305 gl_color_combo_set_relief (GL_COLOR_COMBO(this->priv->line_color_combo),
307 g_object_unref (G_OBJECT (pixbuf));
308 gtk_container_add (GTK_CONTAINER (this->priv->line_color_eventbox),
309 this->priv->line_color_combo);
311 /* Save reference to gui tree so we don't lose tooltips */
312 this->priv->builder = builder;
314 set_doc_items_sensitive (this, FALSE);
316 /* Font family entry widget */
317 gl_util_combo_box_add_text_model (GTK_COMBO_BOX (this->priv->font_family_combo));
318 family_names = gl_util_get_font_family_list ();
319 gl_util_combo_box_set_strings (GTK_COMBO_BOX (this->priv->font_family_combo),
321 gtk_widget_set_size_request (this->priv->font_family_combo, 200, -1);
323 /* Make sure we have a valid font. if not provide a good default. */
324 family_node = g_list_find_custom (family_names,
325 gl_prefs->default_font_family,
326 (GCompareFunc)g_utf8_collate);
329 gtk_combo_box_set_active (GTK_COMBO_BOX (this->priv->font_family_combo),
330 g_list_position (family_names,
335 gtk_combo_box_set_active (GTK_COMBO_BOX (this->priv->font_family_combo), 0);
338 g_signal_connect (G_OBJECT (this->priv->font_family_combo),
339 "changed", G_CALLBACK (font_family_changed_cb), this);
341 /* Font size entry widget */
342 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
343 gl_prefs->default_font_size);
345 g_signal_connect (G_OBJECT (this->priv->font_size_spin),
346 "changed", G_CALLBACK (font_size_changed_cb), this);
349 /* Bold and Italic toggles */
350 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
351 (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
352 g_signal_connect (G_OBJECT (this->priv->font_bold_toggle),
353 "toggled", G_CALLBACK (font_bold_toggled_cb), this);
354 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
355 gl_prefs->default_font_italic_flag);
356 g_signal_connect (G_OBJECT (this->priv->font_italic_toggle),
357 "toggled", G_CALLBACK (font_italic_toggled_cb), this);
360 /* Text alignment radio group */
361 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
362 (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT));
363 g_signal_connect (G_OBJECT (this->priv->text_align_left_radio),
364 "toggled", G_CALLBACK (text_align_toggled_cb), this);
365 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
366 (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER));
367 g_signal_connect (G_OBJECT (this->priv->text_align_center_radio),
368 "toggled", G_CALLBACK (text_align_toggled_cb), this);
369 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
370 (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT));
371 g_signal_connect (G_OBJECT (this->priv->text_align_right_radio),
372 "toggled", G_CALLBACK (text_align_toggled_cb), this);
374 /* Text color widget */
375 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->text_color_combo), gl_prefs->default_text_color);
376 g_signal_connect (G_OBJECT (this->priv->text_color_combo),
378 G_CALLBACK (text_color_changed_cb), this);
380 /* Fill color widget */
381 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->fill_color_combo), gl_prefs->default_fill_color);
382 g_signal_connect (G_OBJECT (this->priv->fill_color_combo),
384 G_CALLBACK (fill_color_changed_cb), this);
386 /* Line color widget */
387 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->line_color_combo), gl_prefs->default_line_color);
388 g_signal_connect (G_OBJECT (this->priv->line_color_combo),
390 G_CALLBACK (line_color_changed_cb), this);
392 /* Line width entry widget */
393 g_signal_connect (G_OBJECT (this->priv->line_width_spin),
395 G_CALLBACK (line_width_changed_cb), this);
397 this->priv->stop_signals = FALSE;
399 gl_debug (DEBUG_PROPERTY_BAR, "END");
403 /****************************************************************************/
404 /* Fill widgets with default values. */
405 /****************************************************************************/
407 reset_to_default_properties (glView *view,
408 glUIPropertyBar *this)
411 gchar *good_font_family;
413 /* Make sure we have a valid font. if not provide a good default. */
414 family_names = gl_util_get_font_family_list ();
415 if (g_list_find_custom (family_names,
416 view->default_font_family,
417 (GCompareFunc)g_utf8_collate))
419 good_font_family = g_strdup (view->default_font_family);
423 if (family_names != NULL)
425 good_font_family = g_strdup (family_names->data); /* 1st entry */
429 good_font_family = NULL;
432 gl_util_combo_box_set_active_text (GTK_COMBO_BOX (this->priv->font_family_combo),
434 g_free (good_font_family);
436 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
437 view->default_font_size);
439 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
440 (view->default_font_weight == PANGO_WEIGHT_BOLD));
441 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
442 view->default_font_italic_flag);
444 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
445 (view->default_text_alignment == PANGO_ALIGN_LEFT));
446 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
447 (view->default_text_alignment == PANGO_ALIGN_CENTER));
448 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
449 (view->default_text_alignment == PANGO_ALIGN_RIGHT));
451 gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->text_color_combo), view->default_text_color);
453 gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->fill_color_combo), view->default_fill_color);
455 gl_color_combo_set_color (GL_COLOR_COMBO(this->priv->line_color_combo), view->default_line_color);
457 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->line_width_spin),
458 view->default_line_width);
462 /****************************************************************************/
463 /* Set view associated with property_bar. */
464 /****************************************************************************/
466 gl_ui_property_bar_set_view (glUIPropertyBar *this,
471 gl_debug (DEBUG_PROPERTY_BAR, "START");
473 g_return_if_fail (view && GL_IS_VIEW (view));
475 g_return_if_fail (label && GL_IS_LABEL (label));
477 set_doc_items_sensitive (this, TRUE);
479 this->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
481 reset_to_default_properties (view, this);
483 g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
484 G_CALLBACK(selection_changed_cb), this);
486 g_signal_connect_swapped (G_OBJECT(view->label), "changed",
487 G_CALLBACK(selection_changed_cb), this);
489 gl_debug (DEBUG_PROPERTY_BAR, "END");
493 /*---------------------------------------------------------------------------*/
494 /* PRIVATE. View "selection state changed" callback. */
495 /*---------------------------------------------------------------------------*/
497 update_text_properties (glView *view,
498 glUIPropertyBar *this)
500 gboolean can_text, is_first_object;
501 gboolean is_same_font_family, is_same_font_size;
502 gboolean is_same_text_color, is_same_is_italic;
503 gboolean is_same_is_bold, is_same_align;
505 glLabelObject *object;
506 gchar *selection_font_family, *font_family;
507 gdouble selection_font_size, font_size;
508 guint selection_text_color, text_color;
509 glColorNode *text_color_node;
510 gboolean selection_is_italic, is_italic;
511 gboolean selection_is_bold, is_bold;
512 PangoAlignment selection_align, align;
514 can_text = gl_view_can_selection_text (view);
515 set_text_items_sensitive (this, can_text);
525 is_same_font_family = TRUE;
526 selection_font_family = NULL;
527 selection_font_size = -1;
528 selection_align = PANGO_ALIGN_LEFT;
529 selection_is_italic = TRUE;
530 selection_is_bold = TRUE;
531 selection_text_color = 0;
533 is_first_object = TRUE;
535 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)
545 if (selection_font_family == NULL)
547 selection_font_family = g_strdup (font_family);
551 if (strcmp (font_family, selection_font_family) != 0)
553 is_same_font_family = FALSE;
556 g_free (font_family);
559 font_size = gl_label_object_get_font_size (object);
561 text_color_node = gl_label_object_get_text_color (object);
562 if (text_color_node->field_flag)
564 /* If a merge field is set we use the default color for merged color*/
565 text_color = GL_COLOR_MERGE_DEFAULT;
570 text_color = text_color_node->color;
572 gl_color_node_free (&text_color_node);
574 is_italic = gl_label_object_get_font_italic_flag (object);
575 is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD;
576 align = gl_label_object_get_text_alignment (object);
580 selection_font_size = font_size;
581 selection_text_color = text_color;
582 selection_is_italic = is_italic;
583 selection_is_bold = is_bold;
584 selection_align = align;
588 if (font_size != selection_font_size)
589 is_same_font_size = FALSE;
590 if (text_color != selection_text_color)
591 is_same_text_color = FALSE;
592 if (is_italic != selection_is_italic)
593 is_same_is_italic = FALSE;
594 if (is_bold != selection_is_bold)
595 is_same_is_bold = FALSE;
596 if (align != selection_align)
597 is_same_align = FALSE;
599 is_first_object = FALSE;
602 if (is_same_font_family && (selection_font_family != NULL))
603 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
604 selection_font_family);
605 gl_util_combo_box_set_active_text (GTK_COMBO_BOX (this->priv->font_family_combo),
606 is_same_font_family?selection_font_family:"");
607 g_free (selection_font_family);
609 if (is_same_font_size)
611 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g",
612 selection_font_size);
613 gtk_spin_button_set_value (GTK_SPIN_BUTTON (this->priv->font_size_spin),
614 selection_font_size);
618 gtk_entry_set_text (GTK_ENTRY (this->priv->font_size_spin), "");
621 if (is_same_text_color)
623 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
624 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->text_color_combo),
625 selection_text_color);
628 if (is_same_is_italic)
630 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
631 selection_is_italic);
633 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
634 selection_is_italic && is_same_is_italic);
638 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
641 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
642 selection_is_bold && is_same_is_bold);
645 gl_debug (DEBUG_PROPERTY_BAR, "same align");
646 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
647 (selection_align == PANGO_ALIGN_LEFT) &&
649 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
650 (selection_align == PANGO_ALIGN_CENTER) &&
652 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
653 (selection_align == PANGO_ALIGN_RIGHT) &&
659 update_fill_color (glView *view,
660 glUIPropertyBar *this)
662 gboolean can, is_first_object;
663 gboolean is_same_fill_color;
665 glLabelObject *object;
666 guint selection_fill_color, fill_color;
667 glColorNode *fill_color_node;
669 can = gl_view_can_selection_fill (view);
670 set_fill_items_sensitive (this, can);
675 is_same_fill_color = TRUE;
676 is_first_object = TRUE;
677 selection_fill_color = 0;
679 for (p = view->selected_object_list; p != NULL; p = p->next)
682 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
683 if (!gl_label_object_can_fill (object))
686 fill_color_node = gl_label_object_get_fill_color (object);
687 if (fill_color_node->field_flag)
689 /* If a merge field is set we use the default color for merged color*/
690 fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
695 fill_color = fill_color_node->color;
697 gl_color_node_free (&fill_color_node);
701 selection_fill_color = fill_color;
705 if (fill_color != selection_fill_color)
707 is_same_fill_color = FALSE;
710 is_first_object = FALSE;
713 if (is_same_fill_color)
715 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
716 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->fill_color_combo),
717 selection_fill_color);
723 update_line_color (glView *view,
724 glUIPropertyBar *this)
726 gboolean can, is_first_object;
727 gboolean is_same_line_color;
729 glLabelObject *object;
730 guint selection_line_color, line_color;
731 glColorNode *line_color_node;
733 can = gl_view_can_selection_line_color (view);
734 set_line_color_items_sensitive (this, can);
739 is_same_line_color = TRUE;
740 is_first_object = TRUE;
741 selection_line_color = 0;
743 for (p = view->selected_object_list; p != NULL; p = p->next)
746 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
747 if (!gl_label_object_can_line_color (object))
750 line_color_node = gl_label_object_get_line_color (object);
751 if (line_color_node->field_flag)
753 /* If a merge field is set we use the default color for merged color*/
754 line_color = GL_COLOR_MERGE_DEFAULT;
759 line_color = line_color_node->color;
761 gl_color_node_free (&line_color_node);
765 selection_line_color = line_color;
769 if (line_color != selection_line_color)
771 is_same_line_color = FALSE;
774 is_first_object = FALSE;
777 if (is_same_line_color)
779 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
780 gl_color_combo_set_color (GL_COLOR_COMBO (this->priv->line_color_combo),
781 selection_line_color);
787 update_line_width (glView *view,
788 glUIPropertyBar *this)
790 gboolean can, is_first_object;
791 gboolean is_same_line_width;
793 glLabelObject *object;
794 gdouble selection_line_width, line_width;
796 can = gl_view_can_selection_line_width (view);
797 set_line_width_items_sensitive (this, can);
802 is_same_line_width = TRUE;
803 is_first_object = TRUE;
804 selection_line_width = 0;
806 for (p = view->selected_object_list; p != NULL; p = p->next)
809 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
810 if (!gl_label_object_can_line_width (object))
813 line_width = gl_label_object_get_line_width (object);
817 selection_line_width = line_width;
821 if (line_width != selection_line_width)
823 is_same_line_width = FALSE;
826 is_first_object = FALSE;
829 if (is_same_line_width)
831 gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
832 gtk_spin_button_set_value (GTK_SPIN_BUTTON (this->priv->line_width_spin),
833 selection_line_width);
837 gtk_entry_set_text (GTK_ENTRY (this->priv->line_width_spin), "");
843 selection_changed_cb (glUIPropertyBar *this)
845 glView *view = this->priv->view;
847 g_return_if_fail (view && GL_IS_VIEW (view));
848 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
850 if (this->priv->stop_signals) return;
851 this->priv->stop_signals = TRUE;
853 gl_debug (DEBUG_PROPERTY_BAR, "START");
855 if (gl_view_is_selection_empty (view))
857 /* No selection: make all controls active. */
858 reset_to_default_properties (view, this);
859 set_doc_items_sensitive (this, TRUE);
863 update_text_properties (view, this);
864 update_fill_color (view, this);
865 update_line_color (view, this);
866 update_line_width (view, this);
869 gl_debug (DEBUG_PROPERTY_BAR, "END");
871 this->priv->stop_signals = FALSE;
875 /*--------------------------------------------------------------------------*/
876 /* PRIVATE. Font family entry changed. */
877 /*--------------------------------------------------------------------------*/
879 font_family_changed_cb (GtkComboBox *combo,
880 glUIPropertyBar *this)
884 if (this->priv->stop_signals) return;
885 this->priv->stop_signals = TRUE;
887 gl_debug (DEBUG_PROPERTY_BAR, "START");
889 font_family = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo));
890 if ( strlen(font_family) )
892 gl_view_set_selection_font_family (this->priv->view,
894 gl_view_set_default_font_family (this->priv->view,
897 g_free (font_family);
899 gl_debug (DEBUG_PROPERTY_BAR, "END");
901 this->priv->stop_signals = FALSE;
905 /*--------------------------------------------------------------------------*/
906 /* PRIVATE. Font size spin button changed. */
907 /*--------------------------------------------------------------------------*/
909 font_size_changed_cb (GtkSpinButton *spin,
910 glUIPropertyBar *this)
914 if (this->priv->stop_signals) return;
915 this->priv->stop_signals = TRUE;
917 gl_debug (DEBUG_PROPERTY_BAR, "START");
919 font_size = gtk_spin_button_get_value (spin);
921 gl_view_set_selection_font_size (this->priv->view,
923 gl_view_set_default_font_size (this->priv->view,
926 gl_debug (DEBUG_PROPERTY_BAR, "END");
928 this->priv->stop_signals = FALSE;
932 /*--------------------------------------------------------------------------*/
933 /* PRIVATE. Text color combo changed. */
934 /*--------------------------------------------------------------------------*/
936 text_color_changed_cb (glColorCombo *cc,
939 glUIPropertyBar *this)
941 glColorNode *text_color_node;
943 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
945 if (this->priv->stop_signals) return;
946 this->priv->stop_signals = TRUE;
948 gl_debug (DEBUG_PROPERTY_BAR, "START");
950 text_color_node = gl_color_node_new_default ();
951 text_color_node->color = color;
953 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
958 text_color_node->color = gl_prefs->default_text_color;
959 gl_view_set_selection_text_color (this->priv->view,
961 gl_view_set_default_text_color (this->priv->view,
962 gl_prefs->default_text_color);
966 gl_view_set_selection_text_color (this->priv->view,
968 gl_view_set_default_text_color (this->priv->view,
969 text_color_node->color);
972 gl_color_node_free (&text_color_node);
974 gl_debug (DEBUG_PROPERTY_BAR, "END");
976 this->priv->stop_signals = FALSE;
980 /*--------------------------------------------------------------------------*/
981 /* PRIVATE. Fill color combo changed. */
982 /*--------------------------------------------------------------------------*/
984 fill_color_changed_cb (glColorCombo *cc,
987 glUIPropertyBar *this)
989 glColorNode *fill_color_node;
991 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
993 if (this->priv->stop_signals) return;
994 this->priv->stop_signals = TRUE;
996 gl_debug (DEBUG_PROPERTY_BAR, "START");
998 fill_color_node = gl_color_node_new_default ();
1000 fill_color_node->color = color;
1002 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
1008 fill_color_node->color = GL_COLOR_NONE;
1009 gl_view_set_selection_fill_color (this->priv->view,
1011 gl_view_set_default_fill_color (this->priv->view,
1012 fill_color_node->color);
1016 gl_view_set_selection_fill_color (this->priv->view,
1018 gl_view_set_default_fill_color (this->priv->view,
1019 fill_color_node->color);
1021 gl_color_node_free (&fill_color_node);
1023 gl_debug (DEBUG_PROPERTY_BAR, "END");
1025 this->priv->stop_signals = FALSE;
1029 /*--------------------------------------------------------------------------*/
1030 /* PRIVATE. Line color combo changed. */
1031 /*--------------------------------------------------------------------------*/
1033 line_color_changed_cb (glColorCombo *cc,
1035 gboolean is_default,
1036 glUIPropertyBar *this)
1038 glColorNode *line_color_node;
1040 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
1042 if (this->priv->stop_signals) return;
1043 this->priv->stop_signals = TRUE;
1045 gl_debug (DEBUG_PROPERTY_BAR, "START");
1047 line_color_node = gl_color_node_new_default ();
1048 line_color_node->color = color;
1050 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
1055 line_color_node->color = GL_COLOR_NONE;
1056 gl_view_set_selection_line_color (this->priv->view,
1058 gl_view_set_default_line_color (this->priv->view,
1059 line_color_node->color);
1063 gl_view_set_selection_line_color (this->priv->view,
1065 gl_view_set_default_line_color (this->priv->view,
1066 line_color_node->color);
1068 gl_color_node_free (&line_color_node);
1070 gl_debug (DEBUG_PROPERTY_BAR, "END");
1072 this->priv->stop_signals = FALSE;
1076 /*--------------------------------------------------------------------------*/
1077 /* PRIVATE. Line width spin button changed. */
1078 /*--------------------------------------------------------------------------*/
1080 line_width_changed_cb (GtkSpinButton *spin,
1081 glUIPropertyBar *this)
1085 if (this->priv->stop_signals) return;
1086 this->priv->stop_signals = TRUE;
1088 gl_debug (DEBUG_PROPERTY_BAR, "START");
1090 if (this->priv->view)
1092 line_width = gtk_spin_button_get_value (spin);
1094 gl_view_set_selection_line_width (this->priv->view,
1096 gl_view_set_default_line_width (this->priv->view,
1100 gl_debug (DEBUG_PROPERTY_BAR, "END");
1102 this->priv->stop_signals = FALSE;
1106 /*---------------------------------------------------------------------------*/
1107 /* PRIVATE. Font bold toggled callback. */
1108 /*---------------------------------------------------------------------------*/
1110 font_bold_toggled_cb (GtkToggleToolButton *toggle,
1111 glUIPropertyBar *this)
1117 if (this->priv->stop_signals) return;
1118 this->priv->stop_signals = TRUE;
1120 gl_debug (DEBUG_PROPERTY_BAR, "START");
1122 state = gtk_toggle_tool_button_get_active (toggle);
1124 weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
1126 gl_view_set_selection_font_weight (this->priv->view, weight);
1127 gl_view_set_default_font_weight (this->priv->view, weight);
1129 gl_debug (DEBUG_PROPERTY_BAR, "END");
1131 this->priv->stop_signals = FALSE;
1135 /*---------------------------------------------------------------------------*/
1136 /* PRIVATE. Font italic toggled callback. */
1137 /*---------------------------------------------------------------------------*/
1139 font_italic_toggled_cb (GtkToggleToolButton *toggle,
1140 glUIPropertyBar *this)
1144 if (this->priv->stop_signals) return;
1145 this->priv->stop_signals = TRUE;
1147 gl_debug (DEBUG_PROPERTY_BAR, "START");
1149 state = gtk_toggle_tool_button_get_active (toggle);
1151 gl_view_set_selection_font_italic_flag (this->priv->view, state);
1152 gl_view_set_default_font_italic_flag (this->priv->view, state);
1154 gl_debug (DEBUG_PROPERTY_BAR, "END");
1156 this->priv->stop_signals = FALSE;
1160 /*---------------------------------------------------------------------------*/
1161 /* PRIVATE. Text align toggled callback. */
1162 /*---------------------------------------------------------------------------*/
1164 text_align_toggled_cb (GtkToggleToolButton *toggle,
1165 glUIPropertyBar *this)
1167 if (this->priv->stop_signals) return;
1168 this->priv->stop_signals = TRUE;
1170 gl_debug (DEBUG_PROPERTY_BAR, "START");
1172 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio)))
1174 gl_view_set_selection_text_alignment (this->priv->view,
1176 gl_view_set_default_text_alignment (this->priv->view,
1180 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio)))
1182 gl_view_set_selection_text_alignment (this->priv->view,
1183 PANGO_ALIGN_CENTER);
1184 gl_view_set_default_text_alignment (this->priv->view,
1185 PANGO_ALIGN_CENTER);
1188 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio)))
1190 gl_view_set_selection_text_alignment (this->priv->view,
1192 gl_view_set_default_text_alignment (this->priv->view,
1196 gl_debug (DEBUG_PROPERTY_BAR, "END");
1198 this->priv->stop_signals = FALSE;
1202 /*---------------------------------------------------------------------------*/
1203 /* PRIVATE. Set sensitivity of doc controls. */
1204 /*---------------------------------------------------------------------------*/
1206 set_doc_items_sensitive (glUIPropertyBar *this,
1209 gtk_widget_set_sensitive (this->priv->font_family_combo, state);
1210 gtk_widget_set_sensitive (this->priv->font_size_spin, state);
1211 gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
1212 gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
1213 gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
1214 gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
1215 gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
1216 gtk_widget_set_sensitive (this->priv->text_color_combo, state);
1217 gtk_widget_set_sensitive (this->priv->fill_color_combo, state);
1218 gtk_widget_set_sensitive (this->priv->line_color_combo, state);
1219 gtk_widget_set_sensitive (this->priv->line_width_spin, state);
1223 /*---------------------------------------------------------------------------*/
1224 /* PRIVATE. Set sensitivity of text related controls. */
1225 /*---------------------------------------------------------------------------*/
1227 set_text_items_sensitive (glUIPropertyBar *this,
1230 gtk_widget_set_sensitive (this->priv->font_family_combo, state);
1231 gtk_widget_set_sensitive (this->priv->font_size_spin, state);
1232 gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
1233 gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
1234 gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
1235 gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
1236 gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
1237 gtk_widget_set_sensitive (this->priv->text_color_combo, state);
1241 /*---------------------------------------------------------------------------*/
1242 /* PRIVATE. Set sensitivity of fill related controls. */
1243 /*---------------------------------------------------------------------------*/
1245 set_fill_items_sensitive (glUIPropertyBar *this,
1248 gtk_widget_set_sensitive (this->priv->fill_color_combo, state);
1252 /*---------------------------------------------------------------------------*/
1253 /* PRIVATE. Set sensitivity of line color related controls. */
1254 /*---------------------------------------------------------------------------*/
1256 set_line_color_items_sensitive (glUIPropertyBar *this,
1259 gtk_widget_set_sensitive (this->priv->line_color_combo, state);
1263 /*---------------------------------------------------------------------------*/
1264 /* PRIVATE. Set sensitivity of line width related controls. */
1265 /*---------------------------------------------------------------------------*/
1267 set_line_width_items_sensitive (glUIPropertyBar *this,
1270 gtk_widget_set_sensitive (this->priv->line_width_spin, state);
1276 * Local Variables: -- emacs
1278 * c-basic-offset: 8 -- emacs
1279 * tab-width: 8 -- emacs
1280 * indent-tabs-mode: nil -- emacs