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>
29 #include "builder-util.h"
30 #include "font-combo.h"
31 #include "color-combo-button.h"
32 #include "stock-pixmaps/stockpixbufs.h"
39 /*===========================================================================*/
40 /* Private macros and constants. */
41 /*===========================================================================*/
44 /*===========================================================================*/
45 /* Private data types */
46 /*===========================================================================*/
48 struct _glUIPropertyBarPrivate {
57 GtkWidget *font_family_eventbox;
58 GtkWidget *font_family_combo;
59 GtkWidget *font_size_spin;
60 GtkWidget *font_bold_toggle;
61 GtkWidget *font_italic_toggle;
63 /* Text alignemnt radios */
64 GtkWidget *text_align_left_radio;
65 GtkWidget *text_align_center_radio;
66 GtkWidget *text_align_right_radio;
69 GtkWidget *text_color_eventbox;
70 GtkWidget *text_color_button;
71 GtkWidget *fill_color_eventbox;
72 GtkWidget *fill_color_button;
73 GtkWidget *line_color_eventbox;
74 GtkWidget *line_color_button;
77 GtkWidget *line_width_spin;
79 /* Prevent recursion */
80 gboolean stop_signals;
84 /*===========================================================================*/
86 /*===========================================================================*/
89 /*===========================================================================*/
90 /* Local function prototypes */
91 /*===========================================================================*/
93 static void gl_ui_property_bar_finalize (GObject *object);
95 static void gl_ui_property_bar_construct (glUIPropertyBar *this);
97 static void selection_changed_cb (glUIPropertyBar *this);
99 static void font_family_changed_cb (GtkComboBox *combo,
100 glUIPropertyBar *this);
102 static void font_size_changed_cb (GtkSpinButton *spin,
103 glUIPropertyBar *this);
105 static void text_color_changed_cb (glColorComboButton *cc,
108 glUIPropertyBar *this);
110 static void fill_color_changed_cb (glColorComboButton *cc,
113 glUIPropertyBar *this);
115 static void line_color_changed_cb (glColorComboButton *cc,
118 glUIPropertyBar *this);
120 static void line_width_changed_cb (GtkSpinButton *spin,
121 glUIPropertyBar *this);
123 static void font_bold_toggled_cb (GtkToggleToolButton *toggle,
124 glUIPropertyBar *this);
126 static void font_italic_toggled_cb (GtkToggleToolButton *toggle,
127 glUIPropertyBar *this);
129 static void text_align_toggled_cb (GtkToggleToolButton *toggle,
130 glUIPropertyBar *this);
132 static void set_doc_items_sensitive (glUIPropertyBar *this,
135 static void set_text_items_sensitive (glUIPropertyBar *this,
138 static void set_fill_items_sensitive (glUIPropertyBar *this,
141 static void set_line_color_items_sensitive (glUIPropertyBar *this,
144 static void set_line_width_items_sensitive (glUIPropertyBar *this,
148 /****************************************************************************/
149 /* Boilerplate Object stuff. */
150 /****************************************************************************/
151 G_DEFINE_TYPE (glUIPropertyBar, gl_ui_property_bar, GTK_TYPE_HBOX);
155 gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
157 GObjectClass *object_class = G_OBJECT_CLASS (class);
159 gl_debug (DEBUG_PROPERTY_BAR, "START");
161 gl_ui_property_bar_parent_class = g_type_class_peek_parent (class);
163 object_class->finalize = gl_ui_property_bar_finalize;
165 gl_debug (DEBUG_PROPERTY_BAR, "END");
170 gl_ui_property_bar_init (glUIPropertyBar *this)
172 gl_debug (DEBUG_PROPERTY_BAR, "START");
174 this->priv = g_new0 (glUIPropertyBarPrivate, 1);
176 gl_debug (DEBUG_PROPERTY_BAR, "END");
181 gl_ui_property_bar_finalize (GObject *object)
183 glUIPropertyBar *this = GL_UI_PROPERTY_BAR (object);
185 gl_debug (DEBUG_PROPERTY_BAR, "START");
187 g_return_if_fail (object != NULL);
188 g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
190 if (this->priv->view)
192 g_object_unref (G_OBJECT(this->priv->view));
194 if (this->priv->builder)
196 g_object_unref (G_OBJECT(this->priv->builder));
200 G_OBJECT_CLASS (gl_ui_property_bar_parent_class)->finalize (object);
202 gl_debug (DEBUG_PROPERTY_BAR, "END");
206 /****************************************************************************/
207 /* Create a NEW property_bar. */
208 /****************************************************************************/
210 gl_ui_property_bar_new (void)
212 glUIPropertyBar *this;
214 gl_debug (DEBUG_PROPERTY_BAR, "START");
216 this = g_object_new (GL_TYPE_UI_PROPERTY_BAR, NULL);
218 gl_ui_property_bar_construct (this);
220 gl_debug (DEBUG_PROPERTY_BAR, "END");
222 return GTK_WIDGET (this);
226 /******************************************************************************/
227 /* Initialize property toolbar. */
228 /******************************************************************************/
230 gl_ui_property_bar_construct (glUIPropertyBar *this)
233 static gchar *object_ids[] = { "property_toolbar",
234 "adjustment1", "adjustment2",
236 GError *error = NULL;
237 GdkPixbuf *pixbuf = NULL;
239 gl_debug (DEBUG_PROPERTY_BAR, "START");
241 this->priv->stop_signals = TRUE;
243 builder = gtk_builder_new ();
244 gtk_builder_add_objects_from_file (builder,
245 GLABELS_BUILDER_DIR "property-bar.builder",
249 g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
250 g_error_free (error);
254 gl_builder_util_get_widgets (builder,
255 "property_toolbar", &this->priv->tool_bar,
256 "font_family_eventbox", &this->priv->font_family_eventbox,
257 "font_size_spin", &this->priv->font_size_spin,
258 "font_bold_toggle", &this->priv->font_bold_toggle,
259 "font_italic_toggle", &this->priv->font_italic_toggle,
260 "text_align_left_radio", &this->priv->text_align_left_radio,
261 "text_align_center_radio", &this->priv->text_align_center_radio,
262 "text_align_right_radio", &this->priv->text_align_right_radio,
263 "text_color_eventbox", &this->priv->text_color_eventbox,
264 "fill_color_eventbox", &this->priv->fill_color_eventbox,
265 "line_color_eventbox", &this->priv->line_color_eventbox,
266 "line_width_spin", &this->priv->line_width_spin,
269 gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar);
271 this->priv->font_family_combo = gl_font_combo_new (gl_prefs->default_font_family);
272 gtk_container_add (GTK_CONTAINER (this->priv->font_family_eventbox),
273 this->priv->font_family_combo);
275 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
276 this->priv->text_color_button =
277 gl_color_combo_button_new (pixbuf,
279 GL_COLOR_TEXT_DEFAULT,
280 gl_prefs->default_text_color);
281 gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button),
283 g_object_unref (G_OBJECT (pixbuf));
284 gtk_container_add (GTK_CONTAINER (this->priv->text_color_eventbox),
285 this->priv->text_color_button);
287 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
288 this->priv->fill_color_button =
289 gl_color_combo_button_new (pixbuf,
292 gl_prefs->default_fill_color);
293 gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->fill_color_button),
295 g_object_unref (G_OBJECT (pixbuf));
296 gtk_container_add (GTK_CONTAINER (this->priv->fill_color_eventbox),
297 this->priv->fill_color_button);
299 pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
300 this->priv->line_color_button =
301 gl_color_combo_button_new (pixbuf,
304 gl_prefs->default_line_color);
305 gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->line_color_button),
307 g_object_unref (G_OBJECT (pixbuf));
308 gtk_container_add (GTK_CONTAINER (this->priv->line_color_eventbox),
309 this->priv->line_color_button);
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 g_signal_connect (G_OBJECT (this->priv->font_family_combo),
318 "changed", G_CALLBACK (font_family_changed_cb), this);
320 /* Font size entry widget */
321 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
322 gl_prefs->default_font_size);
324 g_signal_connect (G_OBJECT (this->priv->font_size_spin),
325 "changed", G_CALLBACK (font_size_changed_cb), this);
328 /* Bold and Italic toggles */
329 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
330 (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
331 g_signal_connect (G_OBJECT (this->priv->font_bold_toggle),
332 "toggled", G_CALLBACK (font_bold_toggled_cb), this);
333 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
334 gl_prefs->default_font_italic_flag);
335 g_signal_connect (G_OBJECT (this->priv->font_italic_toggle),
336 "toggled", G_CALLBACK (font_italic_toggled_cb), this);
339 /* Text alignment radio group */
340 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
341 (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT));
342 g_signal_connect (G_OBJECT (this->priv->text_align_left_radio),
343 "toggled", G_CALLBACK (text_align_toggled_cb), this);
344 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
345 (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER));
346 g_signal_connect (G_OBJECT (this->priv->text_align_center_radio),
347 "toggled", G_CALLBACK (text_align_toggled_cb), this);
348 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
349 (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT));
350 g_signal_connect (G_OBJECT (this->priv->text_align_right_radio),
351 "toggled", G_CALLBACK (text_align_toggled_cb), this);
353 /* Text color widget */
354 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button),
355 gl_prefs->default_text_color);
356 g_signal_connect (G_OBJECT (this->priv->text_color_button),
358 G_CALLBACK (text_color_changed_cb), this);
360 /* Fill color widget */
361 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->fill_color_button),
362 gl_prefs->default_fill_color);
363 g_signal_connect (G_OBJECT (this->priv->fill_color_button),
365 G_CALLBACK (fill_color_changed_cb), this);
367 /* Line color widget */
368 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->line_color_button),
369 gl_prefs->default_line_color);
370 g_signal_connect (G_OBJECT (this->priv->line_color_button),
372 G_CALLBACK (line_color_changed_cb), this);
374 /* Line width entry widget */
375 g_signal_connect (G_OBJECT (this->priv->line_width_spin),
377 G_CALLBACK (line_width_changed_cb), this);
379 this->priv->stop_signals = FALSE;
381 gl_debug (DEBUG_PROPERTY_BAR, "END");
385 /****************************************************************************/
386 /* Fill widgets with default values. */
387 /****************************************************************************/
389 reset_to_default_properties (glView *view,
390 glUIPropertyBar *this)
393 gl_font_combo_set_family (GL_FONT_COMBO (this->priv->font_family_combo),
394 view->default_font_family);
396 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
397 view->default_font_size);
399 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
400 (view->default_font_weight == PANGO_WEIGHT_BOLD));
401 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
402 view->default_font_italic_flag);
404 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
405 (view->default_text_alignment == PANGO_ALIGN_LEFT));
406 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
407 (view->default_text_alignment == PANGO_ALIGN_CENTER));
408 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
409 (view->default_text_alignment == PANGO_ALIGN_RIGHT));
411 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button),
412 view->default_text_color);
414 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->fill_color_button),
415 view->default_fill_color);
417 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->line_color_button),
418 view->default_line_color);
420 gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->line_width_spin),
421 view->default_line_width);
425 /****************************************************************************/
426 /* Set view associated with property_bar. */
427 /****************************************************************************/
429 gl_ui_property_bar_set_view (glUIPropertyBar *this,
434 gl_debug (DEBUG_PROPERTY_BAR, "START");
436 g_return_if_fail (view && GL_IS_VIEW (view));
438 g_return_if_fail (label && GL_IS_LABEL (label));
440 set_doc_items_sensitive (this, TRUE);
442 this->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
444 reset_to_default_properties (view, this);
446 g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
447 G_CALLBACK(selection_changed_cb), this);
449 g_signal_connect_swapped (G_OBJECT(view->label), "changed",
450 G_CALLBACK(selection_changed_cb), this);
452 gl_debug (DEBUG_PROPERTY_BAR, "END");
456 /*---------------------------------------------------------------------------*/
457 /* PRIVATE. View "selection state changed" callback. */
458 /*---------------------------------------------------------------------------*/
460 update_text_properties (glView *view,
461 glUIPropertyBar *this)
463 gboolean can_text, is_first_object;
464 gboolean is_same_font_family, is_same_font_size;
465 gboolean is_same_text_color, is_same_is_italic;
466 gboolean is_same_is_bold, is_same_align;
468 glLabelObject *object;
469 gchar *selection_font_family, *font_family;
470 gdouble selection_font_size, font_size;
471 guint selection_text_color, text_color;
472 glColorNode *text_color_node;
473 gboolean selection_is_italic, is_italic;
474 gboolean selection_is_bold, is_bold;
475 PangoAlignment selection_align, align;
477 can_text = gl_view_can_selection_text (view);
478 set_text_items_sensitive (this, can_text);
488 is_same_font_family = TRUE;
489 selection_font_family = NULL;
490 selection_font_size = -1;
491 selection_align = PANGO_ALIGN_LEFT;
492 selection_is_italic = TRUE;
493 selection_is_bold = TRUE;
494 selection_text_color = 0;
496 is_first_object = TRUE;
498 for (p = view->selected_object_list; p != NULL; p = p->next)
501 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
502 if (!gl_label_object_can_text (object))
505 font_family = gl_label_object_get_font_family (object);
506 if (font_family != NULL)
508 if (selection_font_family == NULL)
510 selection_font_family = g_strdup (font_family);
514 if (strcmp (font_family, selection_font_family) != 0)
516 is_same_font_family = FALSE;
519 g_free (font_family);
522 font_size = gl_label_object_get_font_size (object);
524 text_color_node = gl_label_object_get_text_color (object);
525 if (text_color_node->field_flag)
527 /* If a merge field is set we use the default color for merged color*/
528 text_color = GL_COLOR_MERGE_DEFAULT;
533 text_color = text_color_node->color;
535 gl_color_node_free (&text_color_node);
537 is_italic = gl_label_object_get_font_italic_flag (object);
538 is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD;
539 align = gl_label_object_get_text_alignment (object);
543 selection_font_size = font_size;
544 selection_text_color = text_color;
545 selection_is_italic = is_italic;
546 selection_is_bold = is_bold;
547 selection_align = align;
551 if (font_size != selection_font_size)
552 is_same_font_size = FALSE;
553 if (text_color != selection_text_color)
554 is_same_text_color = FALSE;
555 if (is_italic != selection_is_italic)
556 is_same_is_italic = FALSE;
557 if (is_bold != selection_is_bold)
558 is_same_is_bold = FALSE;
559 if (align != selection_align)
560 is_same_align = FALSE;
562 is_first_object = FALSE;
565 if (is_same_font_family && (selection_font_family != NULL))
566 gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
567 selection_font_family);
568 gl_font_combo_set_family (GL_FONT_COMBO (this->priv->font_family_combo),
569 is_same_font_family?selection_font_family:"");
570 g_free (selection_font_family);
572 if (is_same_font_size)
574 gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g",
575 selection_font_size);
576 gtk_spin_button_set_value (GTK_SPIN_BUTTON (this->priv->font_size_spin),
577 selection_font_size);
581 gtk_entry_set_text (GTK_ENTRY (this->priv->font_size_spin), "");
584 if (is_same_text_color)
586 gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
587 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button),
588 selection_text_color);
591 if (is_same_is_italic)
593 gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
594 selection_is_italic);
596 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
597 selection_is_italic && is_same_is_italic);
601 gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
604 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
605 selection_is_bold && is_same_is_bold);
608 gl_debug (DEBUG_PROPERTY_BAR, "same align");
609 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
610 (selection_align == PANGO_ALIGN_LEFT) &&
612 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
613 (selection_align == PANGO_ALIGN_CENTER) &&
615 gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
616 (selection_align == PANGO_ALIGN_RIGHT) &&
622 update_fill_color (glView *view,
623 glUIPropertyBar *this)
625 gboolean can, is_first_object;
626 gboolean is_same_fill_color;
628 glLabelObject *object;
629 guint selection_fill_color, fill_color;
630 glColorNode *fill_color_node;
632 can = gl_view_can_selection_fill (view);
633 set_fill_items_sensitive (this, can);
638 is_same_fill_color = TRUE;
639 is_first_object = TRUE;
640 selection_fill_color = 0;
642 for (p = view->selected_object_list; p != NULL; p = p->next)
645 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
646 if (!gl_label_object_can_fill (object))
649 fill_color_node = gl_label_object_get_fill_color (object);
650 if (fill_color_node->field_flag)
652 /* If a merge field is set we use the default color for merged color*/
653 fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
658 fill_color = fill_color_node->color;
660 gl_color_node_free (&fill_color_node);
664 selection_fill_color = fill_color;
668 if (fill_color != selection_fill_color)
670 is_same_fill_color = FALSE;
673 is_first_object = FALSE;
676 if (is_same_fill_color)
678 gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
679 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->fill_color_button),
680 selection_fill_color);
686 update_line_color (glView *view,
687 glUIPropertyBar *this)
689 gboolean can, is_first_object;
690 gboolean is_same_line_color;
692 glLabelObject *object;
693 guint selection_line_color, line_color;
694 glColorNode *line_color_node;
696 can = gl_view_can_selection_line_color (view);
697 set_line_color_items_sensitive (this, can);
702 is_same_line_color = TRUE;
703 is_first_object = TRUE;
704 selection_line_color = 0;
706 for (p = view->selected_object_list; p != NULL; p = p->next)
709 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
710 if (!gl_label_object_can_line_color (object))
713 line_color_node = gl_label_object_get_line_color (object);
714 if (line_color_node->field_flag)
716 /* If a merge field is set we use the default color for merged color*/
717 line_color = GL_COLOR_MERGE_DEFAULT;
722 line_color = line_color_node->color;
724 gl_color_node_free (&line_color_node);
728 selection_line_color = line_color;
732 if (line_color != selection_line_color)
734 is_same_line_color = FALSE;
737 is_first_object = FALSE;
740 if (is_same_line_color)
742 gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
743 gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->line_color_button),
744 selection_line_color);
750 update_line_width (glView *view,
751 glUIPropertyBar *this)
753 gboolean can, is_first_object;
754 gboolean is_same_line_width;
756 glLabelObject *object;
757 gdouble selection_line_width, line_width;
759 can = gl_view_can_selection_line_width (view);
760 set_line_width_items_sensitive (this, can);
765 is_same_line_width = TRUE;
766 is_first_object = TRUE;
767 selection_line_width = 0;
769 for (p = view->selected_object_list; p != NULL; p = p->next)
772 object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
773 if (!gl_label_object_can_line_width (object))
776 line_width = gl_label_object_get_line_width (object);
780 selection_line_width = line_width;
784 if (line_width != selection_line_width)
786 is_same_line_width = FALSE;
789 is_first_object = FALSE;
792 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 (this->priv->line_width_spin),
796 selection_line_width);
800 gtk_entry_set_text (GTK_ENTRY (this->priv->line_width_spin), "");
806 selection_changed_cb (glUIPropertyBar *this)
808 glView *view = this->priv->view;
810 g_return_if_fail (view && GL_IS_VIEW (view));
811 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
813 if (this->priv->stop_signals) return;
814 this->priv->stop_signals = TRUE;
816 gl_debug (DEBUG_PROPERTY_BAR, "START");
818 if (gl_view_is_selection_empty (view))
820 /* No selection: make all controls active. */
821 reset_to_default_properties (view, this);
822 set_doc_items_sensitive (this, TRUE);
826 update_text_properties (view, this);
827 update_fill_color (view, this);
828 update_line_color (view, this);
829 update_line_width (view, this);
832 gl_debug (DEBUG_PROPERTY_BAR, "END");
834 this->priv->stop_signals = FALSE;
838 /*--------------------------------------------------------------------------*/
839 /* PRIVATE. Font family entry changed. */
840 /*--------------------------------------------------------------------------*/
842 font_family_changed_cb (GtkComboBox *combo,
843 glUIPropertyBar *this)
847 if (this->priv->stop_signals) return;
848 this->priv->stop_signals = TRUE;
850 gl_debug (DEBUG_PROPERTY_BAR, "START");
852 font_family = gl_font_combo_get_family (GL_FONT_COMBO (combo));
853 if ( strlen(font_family) )
855 gl_view_set_selection_font_family (this->priv->view,
857 gl_view_set_default_font_family (this->priv->view,
860 g_free (font_family);
862 gl_debug (DEBUG_PROPERTY_BAR, "END");
864 this->priv->stop_signals = FALSE;
868 /*--------------------------------------------------------------------------*/
869 /* PRIVATE. Font size spin button changed. */
870 /*--------------------------------------------------------------------------*/
872 font_size_changed_cb (GtkSpinButton *spin,
873 glUIPropertyBar *this)
877 if (this->priv->stop_signals) return;
878 this->priv->stop_signals = TRUE;
880 gl_debug (DEBUG_PROPERTY_BAR, "START");
882 font_size = gtk_spin_button_get_value (spin);
884 gl_view_set_selection_font_size (this->priv->view,
886 gl_view_set_default_font_size (this->priv->view,
889 gl_debug (DEBUG_PROPERTY_BAR, "END");
891 this->priv->stop_signals = FALSE;
895 /*--------------------------------------------------------------------------*/
896 /* PRIVATE. Text color combo changed. */
897 /*--------------------------------------------------------------------------*/
899 text_color_changed_cb (glColorComboButton *cc,
902 glUIPropertyBar *this)
904 glColorNode *text_color_node;
906 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
908 if (this->priv->stop_signals) return;
909 this->priv->stop_signals = TRUE;
911 gl_debug (DEBUG_PROPERTY_BAR, "START");
913 text_color_node = gl_color_node_new_default ();
914 text_color_node->color = color;
916 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
921 text_color_node->color = gl_prefs->default_text_color;
922 gl_view_set_selection_text_color (this->priv->view,
924 gl_view_set_default_text_color (this->priv->view,
925 gl_prefs->default_text_color);
929 gl_view_set_selection_text_color (this->priv->view,
931 gl_view_set_default_text_color (this->priv->view,
932 text_color_node->color);
935 gl_color_node_free (&text_color_node);
937 gl_debug (DEBUG_PROPERTY_BAR, "END");
939 this->priv->stop_signals = FALSE;
943 /*--------------------------------------------------------------------------*/
944 /* PRIVATE. Fill color combo changed. */
945 /*--------------------------------------------------------------------------*/
947 fill_color_changed_cb (glColorComboButton *cc,
950 glUIPropertyBar *this)
952 glColorNode *fill_color_node;
954 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
956 if (this->priv->stop_signals) return;
957 this->priv->stop_signals = TRUE;
959 gl_debug (DEBUG_PROPERTY_BAR, "START");
961 fill_color_node = gl_color_node_new_default ();
963 fill_color_node->color = color;
965 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
971 fill_color_node->color = GL_COLOR_NONE;
972 gl_view_set_selection_fill_color (this->priv->view,
974 gl_view_set_default_fill_color (this->priv->view,
975 fill_color_node->color);
979 gl_view_set_selection_fill_color (this->priv->view,
981 gl_view_set_default_fill_color (this->priv->view,
982 fill_color_node->color);
984 gl_color_node_free (&fill_color_node);
986 gl_debug (DEBUG_PROPERTY_BAR, "END");
988 this->priv->stop_signals = FALSE;
992 /*--------------------------------------------------------------------------*/
993 /* PRIVATE. Line color combo changed. */
994 /*--------------------------------------------------------------------------*/
996 line_color_changed_cb (glColorComboButton *cc,
999 glUIPropertyBar *this)
1001 glColorNode *line_color_node;
1003 g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
1005 if (this->priv->stop_signals) return;
1006 this->priv->stop_signals = TRUE;
1008 gl_debug (DEBUG_PROPERTY_BAR, "START");
1010 line_color_node = gl_color_node_new_default ();
1011 line_color_node->color = color;
1013 gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
1018 line_color_node->color = GL_COLOR_NONE;
1019 gl_view_set_selection_line_color (this->priv->view,
1021 gl_view_set_default_line_color (this->priv->view,
1022 line_color_node->color);
1026 gl_view_set_selection_line_color (this->priv->view,
1028 gl_view_set_default_line_color (this->priv->view,
1029 line_color_node->color);
1031 gl_color_node_free (&line_color_node);
1033 gl_debug (DEBUG_PROPERTY_BAR, "END");
1035 this->priv->stop_signals = FALSE;
1039 /*--------------------------------------------------------------------------*/
1040 /* PRIVATE. Line width spin button changed. */
1041 /*--------------------------------------------------------------------------*/
1043 line_width_changed_cb (GtkSpinButton *spin,
1044 glUIPropertyBar *this)
1048 if (this->priv->stop_signals) return;
1049 this->priv->stop_signals = TRUE;
1051 gl_debug (DEBUG_PROPERTY_BAR, "START");
1053 if (this->priv->view)
1055 line_width = gtk_spin_button_get_value (spin);
1057 gl_view_set_selection_line_width (this->priv->view,
1059 gl_view_set_default_line_width (this->priv->view,
1063 gl_debug (DEBUG_PROPERTY_BAR, "END");
1065 this->priv->stop_signals = FALSE;
1069 /*---------------------------------------------------------------------------*/
1070 /* PRIVATE. Font bold toggled callback. */
1071 /*---------------------------------------------------------------------------*/
1073 font_bold_toggled_cb (GtkToggleToolButton *toggle,
1074 glUIPropertyBar *this)
1080 if (this->priv->stop_signals) return;
1081 this->priv->stop_signals = TRUE;
1083 gl_debug (DEBUG_PROPERTY_BAR, "START");
1085 state = gtk_toggle_tool_button_get_active (toggle);
1087 weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
1089 gl_view_set_selection_font_weight (this->priv->view, weight);
1090 gl_view_set_default_font_weight (this->priv->view, weight);
1092 gl_debug (DEBUG_PROPERTY_BAR, "END");
1094 this->priv->stop_signals = FALSE;
1098 /*---------------------------------------------------------------------------*/
1099 /* PRIVATE. Font italic toggled callback. */
1100 /*---------------------------------------------------------------------------*/
1102 font_italic_toggled_cb (GtkToggleToolButton *toggle,
1103 glUIPropertyBar *this)
1107 if (this->priv->stop_signals) return;
1108 this->priv->stop_signals = TRUE;
1110 gl_debug (DEBUG_PROPERTY_BAR, "START");
1112 state = gtk_toggle_tool_button_get_active (toggle);
1114 gl_view_set_selection_font_italic_flag (this->priv->view, state);
1115 gl_view_set_default_font_italic_flag (this->priv->view, state);
1117 gl_debug (DEBUG_PROPERTY_BAR, "END");
1119 this->priv->stop_signals = FALSE;
1123 /*---------------------------------------------------------------------------*/
1124 /* PRIVATE. Text align toggled callback. */
1125 /*---------------------------------------------------------------------------*/
1127 text_align_toggled_cb (GtkToggleToolButton *toggle,
1128 glUIPropertyBar *this)
1130 if (this->priv->stop_signals) return;
1131 this->priv->stop_signals = TRUE;
1133 gl_debug (DEBUG_PROPERTY_BAR, "START");
1135 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio)))
1137 gl_view_set_selection_text_alignment (this->priv->view,
1139 gl_view_set_default_text_alignment (this->priv->view,
1143 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio)))
1145 gl_view_set_selection_text_alignment (this->priv->view,
1146 PANGO_ALIGN_CENTER);
1147 gl_view_set_default_text_alignment (this->priv->view,
1148 PANGO_ALIGN_CENTER);
1151 if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio)))
1153 gl_view_set_selection_text_alignment (this->priv->view,
1155 gl_view_set_default_text_alignment (this->priv->view,
1159 gl_debug (DEBUG_PROPERTY_BAR, "END");
1161 this->priv->stop_signals = FALSE;
1165 /*---------------------------------------------------------------------------*/
1166 /* PRIVATE. Set sensitivity of doc controls. */
1167 /*---------------------------------------------------------------------------*/
1169 set_doc_items_sensitive (glUIPropertyBar *this,
1172 gtk_widget_set_sensitive (this->priv->font_family_combo, state);
1173 gtk_widget_set_sensitive (this->priv->font_size_spin, state);
1174 gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
1175 gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
1176 gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
1177 gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
1178 gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
1179 gtk_widget_set_sensitive (this->priv->text_color_button, state);
1180 gtk_widget_set_sensitive (this->priv->fill_color_button, state);
1181 gtk_widget_set_sensitive (this->priv->line_color_button, state);
1182 gtk_widget_set_sensitive (this->priv->line_width_spin, state);
1186 /*---------------------------------------------------------------------------*/
1187 /* PRIVATE. Set sensitivity of text related controls. */
1188 /*---------------------------------------------------------------------------*/
1190 set_text_items_sensitive (glUIPropertyBar *this,
1193 gtk_widget_set_sensitive (this->priv->font_family_combo, state);
1194 gtk_widget_set_sensitive (this->priv->font_size_spin, state);
1195 gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
1196 gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
1197 gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
1198 gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
1199 gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
1200 gtk_widget_set_sensitive (this->priv->text_color_button, state);
1204 /*---------------------------------------------------------------------------*/
1205 /* PRIVATE. Set sensitivity of fill related controls. */
1206 /*---------------------------------------------------------------------------*/
1208 set_fill_items_sensitive (glUIPropertyBar *this,
1211 gtk_widget_set_sensitive (this->priv->fill_color_button, state);
1215 /*---------------------------------------------------------------------------*/
1216 /* PRIVATE. Set sensitivity of line color related controls. */
1217 /*---------------------------------------------------------------------------*/
1219 set_line_color_items_sensitive (glUIPropertyBar *this,
1222 gtk_widget_set_sensitive (this->priv->line_color_button, state);
1226 /*---------------------------------------------------------------------------*/
1227 /* PRIVATE. Set sensitivity of line width related controls. */
1228 /*---------------------------------------------------------------------------*/
1230 set_line_width_items_sensitive (glUIPropertyBar *this,
1233 gtk_widget_set_sensitive (this->priv->line_width_spin, state);
1239 * Local Variables: -- emacs
1241 * c-basic-offset: 8 -- emacs
1242 * tab-width: 8 -- emacs
1243 * indent-tabs-mode: nil -- emacs