1 /* gtktexttag.c - text tag object
3 * Copyright (c) 1992-1994 The Regents of the University of California.
4 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
5 * Copyright (c) 2000 Red Hat, Inc.
6 * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
8 * This software is copyrighted by the Regents of the University of
9 * California, Sun Microsystems, Inc., and other parties. The
10 * following terms apply to all files associated with the software
11 * unless explicitly disclaimed in individual files.
13 * The authors hereby grant permission to use, copy, modify,
14 * distribute, and license this software and its documentation for any
15 * purpose, provided that existing copyright notices are retained in
16 * all copies and that this notice is included verbatim in any
17 * distributions. No written agreement, license, or royalty fee is
18 * required for any of the authorized uses. Modifications to this
19 * software may be copyrighted by their authors and need not follow
20 * the licensing terms described here, provided that the new terms are
21 * clearly indicated on the first page of each file where they apply.
23 * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
24 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
25 * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
26 * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
27 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
30 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
32 * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
33 * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
34 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
36 * GOVERNMENT USE: If you are acquiring this software on behalf of the
37 * U.S. government, the Government shall have only "Restricted Rights"
38 * in the software and related documentation as defined in the Federal
39 * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
40 * are acquiring the software on behalf of the Department of Defense,
41 * the software shall be classified as "Commercial Computer Software"
42 * and the Government shall have only "Restricted Rights" as defined
43 * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
44 * foregoing, the authors grant the U.S. Government and others acting
45 * in its behalf permission to use and distribute the software in
46 * accordance with the terms specified in this license.
51 #include "gtktexttag.h"
52 #include "gtktexttypes.h"
53 #include "gtktexttagtable.h"
54 #include "gtksignal.h"
57 #include "gtktypebuiltins.h"
77 PROP_BACKGROUND_STIPPLE,
78 PROP_FOREGROUND_STIPPLE,
88 PROP_PIXELS_ABOVE_LINES,
89 PROP_PIXELS_BELOW_LINES,
90 PROP_PIXELS_INSIDE_WRAP,
106 /* Whether-a-style-arg-is-set args */
109 PROP_BACKGROUND_GDK_SET,
110 PROP_FOREGROUND_GDK_SET,
111 PROP_BACKGROUND_STIPPLE_SET,
112 PROP_FOREGROUND_STIPPLE_SET,
119 PROP_PIXELS_ABOVE_LINES_SET,
120 PROP_PIXELS_BELOW_LINES_SET,
121 PROP_PIXELS_INSIDE_WRAP_SET,
125 PROP_LEFT_MARGIN_SET,
127 PROP_STRIKETHROUGH_SET,
128 PROP_RIGHT_MARGIN_SET,
131 PROP_BG_FULL_HEIGHT_SET,
138 static void gtk_text_tag_init (GtkTextTag *text_tag);
139 static void gtk_text_tag_class_init (GtkTextTagClass *klass);
140 static void gtk_text_tag_finalize (GObject *object);
141 static void gtk_text_tag_set_property (GObject *object,
145 const gchar *trailer);
146 static void gtk_text_tag_get_property (GObject *object,
150 const gchar *trailer);
152 static GObjectClass *parent_class = NULL;
153 static guint signals[LAST_SIGNAL] = { 0 };
156 gtk_text_tag_get_type (void)
158 static GType our_type = 0;
162 static const GTypeInfo our_info =
164 sizeof (GtkTextTagClass),
165 (GBaseInitFunc) NULL,
166 (GBaseFinalizeFunc) NULL,
167 (GClassInitFunc) gtk_text_tag_class_init,
168 NULL, /* class_finalize */
169 NULL, /* class_data */
172 (GInstanceInitFunc) gtk_text_tag_init
175 our_type = g_type_register_static (G_TYPE_OBJECT,
185 gtk_text_tag_class_init (GtkTextTagClass *klass)
187 GObjectClass *object_class = G_OBJECT_CLASS (klass);
189 parent_class = g_type_class_peek_parent (klass);
191 object_class->set_property = gtk_text_tag_set_property;
192 object_class->get_property = gtk_text_tag_get_property;
194 object_class->finalize = gtk_text_tag_finalize;
197 g_object_class_install_property (object_class,
199 g_param_spec_string ("name",
201 _("Name used to refer to the text tag"),
203 G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
207 g_object_class_install_property (object_class,
209 g_param_spec_string ("background",
210 _("Background color name"),
211 _("Background color as a string"),
215 g_object_class_install_property (object_class,
217 g_param_spec_boxed ("background_gdk",
218 _("Background color"),
219 _("Background color as a GdkColor"),
221 G_PARAM_READABLE | G_PARAM_WRITABLE));
223 g_object_class_install_property (object_class,
225 g_param_spec_boolean ("background_full_height",
226 _("Background full height"),
227 _("Whether the background color fills the entire line height or only the height of the tagged characters"),
229 G_PARAM_READABLE | G_PARAM_WRITABLE));
232 g_object_class_install_property (object_class,
233 PROP_BACKGROUND_STIPPLE,
234 g_param_spec_object ("background_stipple",
235 _("Background stipple mask"),
236 _("Bitmap to use as a mask when drawing the text background"),
238 G_PARAM_READABLE | G_PARAM_WRITABLE));
241 g_object_class_install_property (object_class,
243 g_param_spec_string ("foreground",
244 _("Foreground color name"),
245 _("Foreground color as a string"),
249 g_object_class_install_property (object_class,
251 g_param_spec_boxed ("foreground_gdk",
252 _("Foreground color"),
253 _("Foreground color as a GdkColor"),
255 G_PARAM_READABLE | G_PARAM_WRITABLE));
258 g_object_class_install_property (object_class,
259 PROP_FOREGROUND_STIPPLE,
260 g_param_spec_object ("foreground_stipple",
261 _("Foreground stipple mask"),
262 _("Bitmap to use as a mask when drawing the text foreground"),
264 G_PARAM_READABLE | G_PARAM_WRITABLE));
266 g_object_class_install_property (object_class,
268 g_param_spec_enum ("direction",
270 _("Text direction, e.g. right-to-left or left-to-right"),
271 GTK_TYPE_TEXT_DIRECTION,
273 G_PARAM_READABLE | G_PARAM_WRITABLE));
275 g_object_class_install_property (object_class,
277 g_param_spec_boolean ("editable",
279 _("Whether the text can be modified by the user"),
281 G_PARAM_READABLE | G_PARAM_WRITABLE));
283 g_object_class_install_property (object_class,
285 g_param_spec_string ("font",
287 _("Font description as a string"),
289 G_PARAM_READABLE | G_PARAM_WRITABLE));
291 g_object_class_install_property (object_class,
293 g_param_spec_boxed ("font_desc",
295 _("Font description as a PangoFontDescription struct"),
296 GTK_TYPE_PANGO_FONT_DESCRIPTION,
297 G_PARAM_READABLE | G_PARAM_WRITABLE));
300 g_object_class_install_property (object_class,
302 g_param_spec_string ("family",
304 _("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
306 G_PARAM_READABLE | G_PARAM_WRITABLE));
308 g_object_class_install_property (object_class,
310 g_param_spec_enum ("style",
315 G_PARAM_READABLE | G_PARAM_WRITABLE));
317 g_object_class_install_property (object_class,
319 g_param_spec_enum ("variant",
323 PANGO_VARIANT_NORMAL,
324 G_PARAM_READABLE | G_PARAM_WRITABLE));
326 g_object_class_install_property (object_class,
328 g_param_spec_int ("weight",
334 G_PARAM_READABLE | G_PARAM_WRITABLE));
337 g_object_class_install_property (object_class,
339 g_param_spec_enum ("stretch",
343 PANGO_STRETCH_NORMAL,
344 G_PARAM_READABLE | G_PARAM_WRITABLE));
346 g_object_class_install_property (object_class,
348 g_param_spec_int ("size",
354 G_PARAM_READABLE | G_PARAM_WRITABLE));
356 g_object_class_install_property (object_class,
358 g_param_spec_double ("size_points",
360 _("Font size in points"),
364 G_PARAM_READABLE | G_PARAM_WRITABLE));
366 g_object_class_install_property (object_class,
368 g_param_spec_enum ("justify",
370 _("Left, right, or center justification"),
371 GTK_TYPE_JUSTIFICATION,
373 G_PARAM_READABLE | G_PARAM_WRITABLE));
375 g_object_class_install_property (object_class,
377 g_param_spec_string ("language",
379 _("Language engine code to use for rendering the text"),
381 G_PARAM_READABLE | G_PARAM_WRITABLE));
383 g_object_class_install_property (object_class,
385 g_param_spec_int ("left_margin",
387 _("Width of the left margin in pixels"),
391 G_PARAM_READABLE | G_PARAM_WRITABLE));
393 g_object_class_install_property (object_class,
395 g_param_spec_int ("right_margin",
397 _("Width of the right margin in pixels"),
401 G_PARAM_READABLE | G_PARAM_WRITABLE));
404 g_object_class_install_property (object_class,
406 g_param_spec_int ("indent",
408 _("Amount to indent the paragraph, in pixels"),
412 G_PARAM_READABLE | G_PARAM_WRITABLE));
415 g_object_class_install_property (object_class,
417 g_param_spec_int ("rise",
419 _("Offset of text above the baseline (below the baseline if rise is negative)"),
423 G_PARAM_READABLE | G_PARAM_WRITABLE));
425 g_object_class_install_property (object_class,
426 PROP_PIXELS_ABOVE_LINES,
427 g_param_spec_int ("pixels_above_lines",
428 _("Pixels above lines"),
429 _("Pixels of blank space above paragraphs"),
433 G_PARAM_READABLE | G_PARAM_WRITABLE));
435 g_object_class_install_property (object_class,
436 PROP_PIXELS_BELOW_LINES,
437 g_param_spec_int ("pixels_below_lines",
438 _("Pixels below lines"),
439 _("Pixels of blank space below paragraphs"),
443 G_PARAM_READABLE | G_PARAM_WRITABLE));
445 g_object_class_install_property (object_class,
446 PROP_PIXELS_INSIDE_WRAP,
447 g_param_spec_int ("pixels_inside_wrap",
448 _("Pixels inside wrap"),
449 _("Pixels of blank space between wrapped lines in a paragraph"),
453 G_PARAM_READABLE | G_PARAM_WRITABLE));
455 g_object_class_install_property (object_class,
457 g_param_spec_boolean ("strikethrough",
459 _("Whether to strike through the text"),
461 G_PARAM_READABLE | G_PARAM_WRITABLE));
463 g_object_class_install_property (object_class,
465 g_param_spec_enum ("underline",
467 _("Style of underline for this text"),
468 PANGO_TYPE_UNDERLINE,
469 PANGO_UNDERLINE_NONE,
470 G_PARAM_READABLE | G_PARAM_WRITABLE));
472 g_object_class_install_property (object_class,
474 g_param_spec_enum ("wrap_mode",
476 _("Whether to wrap lines never, at word boundaries, or at character boundaries"),
479 G_PARAM_READABLE | G_PARAM_WRITABLE));
482 g_object_class_install_property (object_class,
484 g_param_spec_boxed ("tabs",
486 _("Custom tabs for this text"),
487 GTK_TYPE_PANGO_TAB_ARRAY,
488 G_PARAM_READABLE | G_PARAM_WRITABLE));
490 g_object_class_install_property (object_class,
492 g_param_spec_boolean ("invisible",
494 _("Whether this text is hidden"),
496 G_PARAM_READABLE | G_PARAM_WRITABLE));
498 /* Style props are set or not */
500 #define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
502 ADD_SET_PROP ("background_set", PROP_BACKGROUND_SET,
504 _("Whether this tag affects the background color"));
506 ADD_SET_PROP ("background_full_height_set", PROP_BG_FULL_HEIGHT_SET,
507 _("Background full height set"),
508 _("Whether this tag affects background height"));
510 ADD_SET_PROP ("background_gdk_set", PROP_BACKGROUND_GDK_SET,
512 _("Whether this tag affects the background color"));
514 ADD_SET_PROP ("background_stipple_set", PROP_BACKGROUND_STIPPLE_SET,
515 _("Background stipple set"),
516 _("Whether this tag affects the background stipple"));
518 ADD_SET_PROP ("foreground_set", PROP_FOREGROUND_SET,
520 _("Whether this tag affects the foreground color"));
522 ADD_SET_PROP ("foreground_gdk_set", PROP_FOREGROUND_GDK_SET,
524 _("Whether this tag affects the foreground color"));
526 ADD_SET_PROP ("foreground_stipple_set", PROP_FOREGROUND_STIPPLE_SET,
527 _("Foreground stipple set"),
528 _("Whether this tag affects the foreground stipple"));
530 ADD_SET_PROP ("editable_set", PROP_EDITABLE_SET,
531 _("Editability set"),
532 _("Whether this tag affects text editability"));
534 ADD_SET_PROP ("family_set", PROP_FAMILY_SET,
535 _("Font family set"),
536 _("Whether this tag affects the font family"));
538 ADD_SET_PROP ("style_set", PROP_STYLE_SET,
540 _("Whether this tag affects the font style"));
542 ADD_SET_PROP ("variant_set", PROP_VARIANT_SET,
543 _("Font variant set"),
544 _("Whether this tag affects the font variant"));
546 ADD_SET_PROP ("weight_set", PROP_WEIGHT_SET,
547 _("Font weight set"),
548 _("Whether this tag affects the font weight"));
550 ADD_SET_PROP ("stretch_set", PROP_STRETCH_SET,
551 _("Font stretch set"),
552 _("Whether this tag affects the font stretch"));
554 ADD_SET_PROP ("size_set", PROP_SIZE_SET,
556 _("Whether this tag affects the font size"));
558 ADD_SET_PROP ("justify_set", PROP_JUSTIFY_SET,
559 _("Justification set"),
560 _("Whether this tag affects paragraph justification"));
562 ADD_SET_PROP ("language_set", PROP_LANGUAGE_SET,
564 _("Whether this tag affects the language the text is rendered as"));
566 ADD_SET_PROP ("left_margin_set", PROP_LEFT_MARGIN_SET,
567 _("Left margin set"),
568 _("Whether this tag affects the left margin"));
570 ADD_SET_PROP ("indent_set", PROP_INDENT_SET,
572 _("Whether this tag affects indentation"));
574 ADD_SET_PROP ("rise_set", PROP_RISE_SET,
576 _("Whether this tag affects the rise"));
578 ADD_SET_PROP ("pixels_above_lines_set", PROP_PIXELS_ABOVE_LINES_SET,
579 _("Pixels above lines set"),
580 _("Whether this tag affects the number of pixels above lines"));
582 ADD_SET_PROP ("pixels_below_lines_set", PROP_PIXELS_BELOW_LINES_SET,
583 _("Pixels below lines set"),
584 _("Whether this tag affects the number of pixels above lines"));
586 ADD_SET_PROP ("pixels_inside_wrap_set", PROP_PIXELS_INSIDE_WRAP_SET,
587 _("Pixels inside wrap set"),
588 _("Whether this tag affects the number of pixels between wrapped lines"));
590 ADD_SET_PROP ("strikethrough_set", PROP_STRIKETHROUGH_SET,
591 _("Strikethrough set"),
592 _("Whether this tag affects strikethrough"));
594 ADD_SET_PROP ("right_margin_set", PROP_RIGHT_MARGIN_SET,
595 _("Right margin set"),
596 _("Whether this tag affects the right margin"));
598 ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET,
600 _("Whether this tag affects underlining"));
602 ADD_SET_PROP ("wrap_mode_set", PROP_WRAP_MODE_SET,
604 _("Whether this tag affects line wrap mode"));
606 ADD_SET_PROP ("tabs_set", PROP_TABS_SET,
608 _("Whether this tag affects tabs"));
610 ADD_SET_PROP ("invisible_set", PROP_INVISIBLE_SET,
612 _("Whether this tag affects text visibility"));
615 g_signal_newc ("event",
616 G_TYPE_FROM_CLASS (object_class),
618 GTK_SIGNAL_OFFSET (GtkTextTagClass, event),
620 gtk_marshal_INT__OBJECT_BOXED_BOXED,
629 gtk_text_tag_init (GtkTextTag *text_tag)
631 /* 0 is basically a fine way to initialize everything in the
634 text_tag->values = gtk_text_attributes_new ();
639 * @name: tag name, or %NULL
641 * Creates a #GtkTextTag. Configure the tag using object arguments,
642 * i.e. using g_object_set().
644 * Return value: a new #GtkTextTag
647 gtk_text_tag_new (const gchar *name)
651 tag = GTK_TEXT_TAG (g_object_new (gtk_text_tag_get_type (),
659 gtk_text_tag_finalize (GObject *object)
661 GtkTextTag *text_tag;
663 text_tag = GTK_TEXT_TAG (object);
665 g_assert (!text_tag->values->realized);
668 gtk_text_tag_table_remove (text_tag->table, text_tag);
670 g_assert (text_tag->table == NULL);
672 gtk_text_attributes_unref (text_tag->values);
673 text_tag->values = NULL;
675 g_free (text_tag->name);
676 text_tag->name = NULL;
678 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
682 set_bg_color (GtkTextTag *tag, GdkColor *color)
686 if (!tag->bg_color_set)
688 tag->bg_color_set = TRUE;
689 g_object_notify (G_OBJECT (tag), "background_set");
692 tag->values->appearance.bg_color = *color;
696 if (tag->bg_color_set)
698 tag->bg_color_set = FALSE;
699 g_object_notify (G_OBJECT (tag), "background_set");
705 set_fg_color (GtkTextTag *tag, GdkColor *color)
709 if (!tag->fg_color_set)
711 tag->fg_color_set = TRUE;
712 g_object_notify (G_OBJECT (tag), "foreground_set");
714 tag->values->appearance.fg_color = *color;
718 if (tag->fg_color_set)
720 tag->fg_color_set = FALSE;
721 g_object_notify (G_OBJECT (tag), "foreground_set");
727 set_font_description (GtkTextTag *text_tag,
728 PangoFontDescription *font_desc)
730 if (font_desc != NULL)
732 /* pango_font_description_from_string() will sometimes return
733 * a NULL family or -1 size, so handle those cases.
736 if (font_desc->family_name)
737 g_object_set (G_OBJECT (text_tag),
738 "family", font_desc->family_name,
741 if (font_desc->size >= 0)
742 g_object_set (G_OBJECT (text_tag),
743 "size", font_desc->size,
746 g_object_set (G_OBJECT (text_tag),
747 "style", font_desc->style,
748 "variant", font_desc->variant,
749 "weight", font_desc->weight,
750 "stretch", font_desc->stretch,
755 if (text_tag->family_set)
757 text_tag->family_set = FALSE;
758 g_object_notify (G_OBJECT (text_tag), "family_set");
760 if (text_tag->style_set)
762 text_tag->style_set = FALSE;
763 g_object_notify (G_OBJECT (text_tag), "style_set");
765 if (text_tag->variant_set)
767 text_tag->variant_set = FALSE;
768 g_object_notify (G_OBJECT (text_tag), "variant_set");
770 if (text_tag->weight_set)
772 text_tag->weight_set = FALSE;
773 g_object_notify (G_OBJECT (text_tag), "weight_set");
775 if (text_tag->stretch_set)
777 text_tag->stretch_set = FALSE;
778 g_object_notify (G_OBJECT (text_tag), "stretch_set");
780 if (text_tag->size_set)
782 text_tag->size_set = FALSE;
783 g_object_notify (G_OBJECT (text_tag), "size_set");
789 gtk_text_tag_set_property (GObject *object,
793 const gchar *trailer)
795 GtkTextTag *text_tag;
796 gboolean size_changed = FALSE;
798 text_tag = GTK_TEXT_TAG (object);
800 g_return_if_fail (!text_tag->values->realized);
805 g_return_if_fail (text_tag->name == NULL);
806 text_tag->name = g_strdup (g_value_get_string (value));
809 case PROP_BACKGROUND:
813 if (gdk_color_parse (g_value_get_string (value), &color))
814 set_bg_color (text_tag, &color);
816 g_warning ("Don't know color `%s'", g_value_get_string (value));
820 case PROP_FOREGROUND:
824 if (gdk_color_parse (g_value_get_string (value), &color))
825 set_fg_color (text_tag, &color);
827 g_warning ("Don't know color `%s'", g_value_get_string (value));
831 case PROP_BACKGROUND_GDK:
833 GdkColor *color = g_value_get_as_pointer (value);
834 set_bg_color (text_tag, color);
838 case PROP_FOREGROUND_GDK:
840 GdkColor *color = g_value_get_as_pointer (value);
841 set_fg_color (text_tag, color);
845 case PROP_BACKGROUND_STIPPLE:
847 GdkBitmap *bitmap = g_value_get_as_pointer (value);
849 text_tag->bg_stipple_set = TRUE;
850 g_object_notify (G_OBJECT (text_tag), "bg_stipple_set");
852 if (text_tag->values->appearance.bg_stipple != bitmap)
855 gdk_bitmap_ref (bitmap);
857 if (text_tag->values->appearance.bg_stipple)
858 gdk_bitmap_unref (text_tag->values->appearance.bg_stipple);
860 text_tag->values->appearance.bg_stipple = bitmap;
865 case PROP_FOREGROUND_STIPPLE:
867 GdkBitmap *bitmap = g_value_get_as_pointer (value);
869 text_tag->fg_stipple_set = TRUE;
870 g_object_notify (G_OBJECT (text_tag), "fg_stipple_set");
872 if (text_tag->values->appearance.fg_stipple != bitmap)
875 gdk_bitmap_ref (bitmap);
877 if (text_tag->values->appearance.fg_stipple)
878 gdk_bitmap_unref (text_tag->values->appearance.fg_stipple);
880 text_tag->values->appearance.fg_stipple = bitmap;
887 PangoFontDescription *font_desc = NULL;
890 name = g_value_get_string (value);
893 font_desc = pango_font_description_from_string (name);
895 set_font_description (text_tag, font_desc);
898 pango_font_description_free (font_desc);
906 PangoFontDescription *font_desc;
908 font_desc = g_value_get_as_pointer (value);
910 set_font_description (text_tag, font_desc);
917 if (text_tag->values->font.family_name)
918 g_free (text_tag->values->font.family_name);
919 text_tag->values->font.family_name = g_strdup (g_value_get_string (value));
920 text_tag->family_set = TRUE;
921 g_object_notify (G_OBJECT (text_tag), "family_set");
926 text_tag->values->font.style = g_value_get_enum (value);
927 text_tag->style_set = TRUE;
928 g_object_notify (G_OBJECT (text_tag), "style_set");
933 text_tag->values->font.variant = g_value_get_enum (value);
934 text_tag->variant_set = TRUE;
935 g_object_notify (G_OBJECT (text_tag), "variant_set");
940 text_tag->values->font.weight = g_value_get_int (value);
941 text_tag->weight_set = TRUE;
942 g_object_notify (G_OBJECT (text_tag), "weight_set");
947 text_tag->values->font.stretch = g_value_get_enum (value);
948 text_tag->stretch_set = TRUE;
949 g_object_notify (G_OBJECT (text_tag), "stretch_set");
954 text_tag->values->font.size = g_value_get_int (value);
955 text_tag->size_set = TRUE;
956 g_object_notify (G_OBJECT (text_tag), "size_set");
960 case PROP_SIZE_POINTS:
961 text_tag->values->font.size = g_value_get_double (value) * PANGO_SCALE;
962 text_tag->size_set = TRUE;
963 g_object_notify (G_OBJECT (text_tag), "size_set");
967 case PROP_PIXELS_ABOVE_LINES:
968 text_tag->pixels_above_lines_set = TRUE;
969 text_tag->values->pixels_above_lines = g_value_get_int (value);
970 g_object_notify (G_OBJECT (text_tag), "pixels_above_lines_set");
974 case PROP_PIXELS_BELOW_LINES:
975 text_tag->pixels_below_lines_set = TRUE;
976 text_tag->values->pixels_below_lines = g_value_get_int (value);
977 g_object_notify (G_OBJECT (text_tag), "pixels_below_lines_set");
981 case PROP_PIXELS_INSIDE_WRAP:
982 text_tag->pixels_inside_wrap_set = TRUE;
983 text_tag->values->pixels_inside_wrap = g_value_get_int (value);
984 g_object_notify (G_OBJECT (text_tag), "pixels_inside_wrap_set");
989 text_tag->editable_set = TRUE;
990 text_tag->values->editable = g_value_get_boolean (value);
991 g_object_notify (G_OBJECT (text_tag), "editable_set");
995 text_tag->wrap_mode_set = TRUE;
996 text_tag->values->wrap_mode = g_value_get_enum (value);
997 g_object_notify (G_OBJECT (text_tag), "wrap_mode_set");
1002 text_tag->justify_set = TRUE;
1003 text_tag->values->justify = g_value_get_enum (value);
1004 g_object_notify (G_OBJECT (text_tag), "justify_set");
1005 size_changed = TRUE;
1008 case PROP_DIRECTION:
1009 text_tag->values->direction = g_value_get_enum (value);
1012 case PROP_LEFT_MARGIN:
1013 text_tag->left_margin_set = TRUE;
1014 text_tag->values->left_margin = g_value_get_int (value);
1015 g_object_notify (G_OBJECT (text_tag), "left_margin_set");
1016 size_changed = TRUE;
1020 text_tag->indent_set = TRUE;
1021 text_tag->values->indent = g_value_get_int (value);
1022 g_object_notify (G_OBJECT (text_tag), "indent_set");
1023 size_changed = TRUE;
1026 case PROP_STRIKETHROUGH:
1027 text_tag->strikethrough_set = TRUE;
1028 text_tag->values->appearance.strikethrough = g_value_get_boolean (value);
1029 g_object_notify (G_OBJECT (text_tag), "strikethrough_set");
1032 case PROP_RIGHT_MARGIN:
1033 text_tag->right_margin_set = TRUE;
1034 text_tag->values->right_margin = g_value_get_int (value);
1035 g_object_notify (G_OBJECT (text_tag), "right_margin_set");
1036 size_changed = TRUE;
1039 case PROP_UNDERLINE:
1040 text_tag->underline_set = TRUE;
1041 text_tag->values->appearance.underline = g_value_get_enum (value);
1042 g_object_notify (G_OBJECT (text_tag), "underline_set");
1046 text_tag->rise_set = TRUE;
1047 text_tag->values->appearance.rise = g_value_get_int (value);
1048 g_object_notify (G_OBJECT (text_tag), "rise_set");
1049 size_changed = TRUE;
1052 case PROP_BG_FULL_HEIGHT:
1053 text_tag->bg_full_height_set = TRUE;
1054 text_tag->values->bg_full_height = g_value_get_boolean (value);
1055 g_object_notify (G_OBJECT (text_tag), "bg_full_height_set");
1059 text_tag->language_set = TRUE;
1060 text_tag->values->language = g_strdup (g_value_get_string (value));
1061 g_object_notify (G_OBJECT (text_tag), "language_set");
1065 text_tag->tabs_set = TRUE;
1067 if (text_tag->values->tabs)
1068 pango_tab_array_free (text_tag->values->tabs);
1070 /* FIXME I'm not sure if this is a memleak or not */
1071 text_tag->values->tabs =
1072 pango_tab_array_copy (g_value_get_as_pointer (value));
1074 g_object_notify (G_OBJECT (text_tag), "tabs_set");
1076 size_changed = TRUE;
1079 case PROP_INVISIBLE:
1080 text_tag->invisible_set = TRUE;
1081 text_tag->values->invisible = g_value_get_boolean (value);
1082 g_object_notify (G_OBJECT (text_tag), "invisible_set");
1083 size_changed = TRUE;
1086 /* Whether the value should be used... */
1088 case PROP_BACKGROUND_SET:
1089 case PROP_BACKGROUND_GDK_SET:
1090 text_tag->bg_color_set = g_value_get_boolean (value);
1093 case PROP_FOREGROUND_SET:
1094 case PROP_FOREGROUND_GDK_SET:
1095 text_tag->fg_color_set = g_value_get_boolean (value);
1098 case PROP_BACKGROUND_STIPPLE_SET:
1099 text_tag->bg_stipple_set = g_value_get_boolean (value);
1100 if (!text_tag->bg_stipple_set &&
1101 text_tag->values->appearance.bg_stipple)
1103 g_object_unref (G_OBJECT (text_tag->values->appearance.bg_stipple));
1104 text_tag->values->appearance.bg_stipple = NULL;
1108 case PROP_FOREGROUND_STIPPLE_SET:
1109 text_tag->fg_stipple_set = g_value_get_boolean (value);
1110 if (!text_tag->fg_stipple_set &&
1111 text_tag->values->appearance.fg_stipple)
1113 g_object_unref (G_OBJECT (text_tag->values->appearance.fg_stipple));
1114 text_tag->values->appearance.fg_stipple = NULL;
1118 case PROP_FAMILY_SET:
1119 text_tag->family_set = g_value_get_boolean (value);
1120 size_changed = TRUE;
1123 case PROP_STYLE_SET:
1124 text_tag->style_set = g_value_get_boolean (value);
1125 size_changed = TRUE;
1128 case PROP_VARIANT_SET:
1129 text_tag->variant_set = g_value_get_boolean (value);
1130 size_changed = TRUE;
1133 case PROP_WEIGHT_SET:
1134 text_tag->weight_set = g_value_get_boolean (value);
1135 size_changed = TRUE;
1138 case PROP_STRETCH_SET:
1139 text_tag->stretch_set = g_value_get_boolean (value);
1140 size_changed = TRUE;
1144 text_tag->size_set = g_value_get_boolean (value);
1145 size_changed = TRUE;
1148 case PROP_PIXELS_ABOVE_LINES_SET:
1149 text_tag->pixels_above_lines_set = g_value_get_boolean (value);
1150 size_changed = TRUE;
1153 case PROP_PIXELS_BELOW_LINES_SET:
1154 text_tag->pixels_below_lines_set = g_value_get_boolean (value);
1155 size_changed = TRUE;
1158 case PROP_PIXELS_INSIDE_WRAP_SET:
1159 text_tag->pixels_inside_wrap_set = g_value_get_boolean (value);
1160 size_changed = TRUE;
1163 case PROP_EDITABLE_SET:
1164 text_tag->editable_set = g_value_get_boolean (value);
1167 case PROP_WRAP_MODE_SET:
1168 text_tag->wrap_mode_set = g_value_get_boolean (value);
1169 size_changed = TRUE;
1172 case PROP_JUSTIFY_SET:
1173 text_tag->justify_set = g_value_get_boolean (value);
1174 size_changed = TRUE;
1177 case PROP_LEFT_MARGIN_SET:
1178 text_tag->left_margin_set = g_value_get_boolean (value);
1179 size_changed = TRUE;
1182 case PROP_INDENT_SET:
1183 text_tag->indent_set = g_value_get_boolean (value);
1184 size_changed = TRUE;
1187 case PROP_STRIKETHROUGH_SET:
1188 text_tag->strikethrough_set = g_value_get_boolean (value);
1191 case PROP_RIGHT_MARGIN_SET:
1192 text_tag->right_margin_set = g_value_get_boolean (value);
1193 size_changed = TRUE;
1196 case PROP_UNDERLINE_SET:
1197 text_tag->underline_set = g_value_get_boolean (value);
1201 text_tag->rise_set = g_value_get_boolean (value);
1202 size_changed = TRUE;
1205 case PROP_BG_FULL_HEIGHT_SET:
1206 text_tag->bg_full_height_set = g_value_get_boolean (value);
1209 case PROP_LANGUAGE_SET:
1210 text_tag->language_set = g_value_get_boolean (value);
1211 size_changed = TRUE;
1215 text_tag->tabs_set = g_value_get_boolean (value);
1216 size_changed = TRUE;
1219 case PROP_INVISIBLE_SET:
1220 text_tag->invisible_set = g_value_get_boolean (value);
1221 size_changed = TRUE;
1225 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1229 /* FIXME I would like to do this after all set_property in a single
1230 * g_object_set () have been called. But an idle function won't
1231 * work; we need to emit when the tag is changed, not when we get
1232 * around to the event loop. So blah, we eat some inefficiency.
1235 /* This is also somewhat weird since we emit another object's
1236 * signal here, but the two objects are already tightly bound.
1239 if (text_tag->table)
1240 g_signal_emit_by_name (G_OBJECT (text_tag->table),
1242 text_tag, size_changed);
1246 get_color_arg (GValue *value, GdkColor *orig)
1250 color = g_new (GdkColor, 1);
1252 g_value_init (value, GTK_TYPE_GDK_COLOR);
1253 g_value_set_boxed (value, color);
1257 gtk_text_tag_get_property (GObject *object,
1261 const gchar *trailer)
1265 tag = GTK_TEXT_TAG (object);
1270 g_value_set_string (value, tag->name);
1273 case PROP_BACKGROUND_GDK:
1274 get_color_arg (value, &tag->values->appearance.bg_color);
1277 case PROP_FOREGROUND_GDK:
1278 get_color_arg (value, &tag->values->appearance.fg_color);
1281 case PROP_BACKGROUND_STIPPLE:
1282 if (tag->bg_stipple_set)
1283 g_value_set_boxed (value, tag->values->appearance.bg_stipple);
1286 case PROP_FOREGROUND_STIPPLE:
1287 if (tag->fg_stipple_set)
1288 g_value_set_boxed (value, tag->values->appearance.fg_stipple);
1292 if (tag->family_set &&
1299 /* FIXME GValue imposes a totally gratuitous string copy
1300 * here, we could just hand off string ownership
1302 gchar *str = pango_font_description_to_string (&tag->values->font);
1303 g_value_set_string (value, str);
1308 case PROP_FONT_DESC:
1309 if (tag->family_set &&
1315 g_value_set_boxed (value, &tag->values->font);
1319 g_value_set_string (value, tag->values->font.family_name);
1323 g_value_set_enum (value, tag->values->font.style);
1327 g_value_set_enum (value, tag->values->font.variant);
1331 g_value_set_int (value, tag->values->font.weight);
1335 g_value_set_enum (value, tag->values->font.stretch);
1339 g_value_set_int (value, tag->values->font.size);
1342 case PROP_SIZE_POINTS:
1343 g_value_set_double (value, ((double)tag->values->font.size) / (double)PANGO_SCALE);
1346 case PROP_PIXELS_ABOVE_LINES:
1347 g_value_set_int (value, tag->values->pixels_above_lines);
1350 case PROP_PIXELS_BELOW_LINES:
1351 g_value_set_int (value, tag->values->pixels_below_lines);
1354 case PROP_PIXELS_INSIDE_WRAP:
1355 g_value_set_int (value, tag->values->pixels_inside_wrap);
1359 g_value_set_boolean (value, tag->values->editable);
1362 case PROP_WRAP_MODE:
1363 g_value_set_enum (value, tag->values->wrap_mode);
1367 g_value_set_enum (value, tag->values->justify);
1370 case PROP_DIRECTION:
1371 g_value_set_enum (value, tag->values->direction);
1374 case PROP_LEFT_MARGIN:
1375 g_value_set_int (value, tag->values->left_margin);
1379 g_value_set_int (value, tag->values->indent);
1382 case PROP_STRIKETHROUGH:
1383 g_value_set_boolean (value, tag->values->appearance.strikethrough);
1386 case PROP_RIGHT_MARGIN:
1387 g_value_set_int (value, tag->values->right_margin);
1390 case PROP_UNDERLINE:
1391 g_value_set_enum (value, tag->values->appearance.underline);
1395 g_value_set_int (value, tag->values->appearance.rise);
1398 case PROP_BG_FULL_HEIGHT:
1399 g_value_set_boolean (value, tag->values->bg_full_height);
1403 g_value_set_string (value, tag->values->language);
1407 if (tag->values->tabs)
1408 g_value_set_boxed (value, tag->values->tabs);
1411 case PROP_INVISIBLE:
1412 g_value_set_boolean (value, tag->values->invisible);
1415 case PROP_BACKGROUND_SET:
1416 case PROP_BACKGROUND_GDK_SET:
1417 g_value_set_boolean (value, tag->bg_color_set);
1420 case PROP_FOREGROUND_SET:
1421 case PROP_FOREGROUND_GDK_SET:
1422 g_value_set_boolean (value, tag->fg_color_set);
1425 case PROP_BACKGROUND_STIPPLE_SET:
1426 g_value_set_boolean (value, tag->bg_stipple_set);
1429 case PROP_FOREGROUND_STIPPLE_SET:
1430 g_value_set_boolean (value, tag->fg_stipple_set);
1433 case PROP_FAMILY_SET:
1434 g_value_set_boolean (value, tag->family_set);
1437 case PROP_STYLE_SET:
1438 g_value_set_boolean (value, tag->style_set);
1441 case PROP_VARIANT_SET:
1442 g_value_set_boolean (value, tag->variant_set);
1445 case PROP_WEIGHT_SET:
1446 g_value_set_boolean (value, tag->weight_set);
1449 case PROP_STRETCH_SET:
1450 g_value_set_boolean (value, tag->stretch_set);
1454 g_value_set_boolean (value, tag->size_set);
1457 case PROP_PIXELS_ABOVE_LINES_SET:
1458 g_value_set_boolean (value, tag->pixels_above_lines_set);
1461 case PROP_PIXELS_BELOW_LINES_SET:
1462 g_value_set_boolean (value, tag->pixels_below_lines_set);
1465 case PROP_PIXELS_INSIDE_WRAP_SET:
1466 g_value_set_boolean (value, tag->pixels_inside_wrap_set);
1469 case PROP_EDITABLE_SET:
1470 g_value_set_boolean (value, tag->editable_set);
1473 case PROP_WRAP_MODE_SET:
1474 g_value_set_boolean (value, tag->wrap_mode_set);
1477 case PROP_JUSTIFY_SET:
1478 g_value_set_boolean (value, tag->justify_set);
1481 case PROP_LEFT_MARGIN_SET:
1482 g_value_set_boolean (value, tag->left_margin_set);
1485 case PROP_INDENT_SET:
1486 g_value_set_boolean (value, tag->indent_set);
1489 case PROP_STRIKETHROUGH_SET:
1490 g_value_set_boolean (value, tag->strikethrough_set);
1493 case PROP_RIGHT_MARGIN_SET:
1494 g_value_set_boolean (value, tag->right_margin_set);
1497 case PROP_UNDERLINE_SET:
1498 g_value_set_boolean (value, tag->underline_set);
1502 g_value_set_boolean (value, tag->rise_set);
1505 case PROP_BG_FULL_HEIGHT_SET:
1506 g_value_set_boolean (value, tag->bg_full_height_set);
1509 case PROP_LANGUAGE_SET:
1510 g_value_set_boolean (value, tag->language_set);
1514 g_value_set_boolean (value, tag->tabs_set);
1517 case PROP_INVISIBLE_SET:
1518 g_value_set_boolean (value, tag->invisible_set);
1521 case PROP_BACKGROUND:
1522 case PROP_FOREGROUND:
1523 g_warning ("'foreground' and 'background' properties are not readable, use 'foreground_gdk' and 'background_gdk'");
1525 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1541 delta_priority_foreach (GtkTextTag *tag, gpointer user_data)
1543 DeltaData *dd = user_data;
1545 if (tag->priority >= dd->low && tag->priority <= dd->high)
1546 tag->priority += dd->delta;
1550 * gtk_text_tag_get_priority:
1551 * @tag: a #GtkTextTag
1553 * Get the tag priority.
1555 * Return value: The tag's priority.
1558 gtk_text_tag_get_priority (GtkTextTag *tag)
1560 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), 0);
1562 return tag->priority;
1566 * gtk_text_tag_set_priority:
1567 * @tag: a #GtkTextTag
1568 * @priority: the new priority
1570 * Sets the priority of a #GtkTextTag. Valid priorities are
1571 * start at 0 and go to one less than gtk_text_tag_table_size().
1572 * Each tag in a table has a unique priority; setting the priority
1573 * of one tag shifts the priorities of all the other tags in the
1574 * table to maintain a unique priority for each tag. Higher priority
1575 * tags "win" if two tags both set the same text attribute. When adding
1576 * a tag to a tag table, it will be assigned the highest priority in
1577 * the table by default; so normally the precedence of a set of tags
1578 * is the order in which they were added to the table, or created with
1579 * gtk_text_buffer_create_tag(), which adds the tag to the buffer's table
1583 gtk_text_tag_set_priority (GtkTextTag *tag,
1588 g_return_if_fail (GTK_IS_TEXT_TAG (tag));
1589 g_return_if_fail (tag->table != NULL);
1590 g_return_if_fail (priority >= 0);
1591 g_return_if_fail (priority < gtk_text_tag_table_size (tag->table));
1593 if (priority == tag->priority)
1596 if (priority < tag->priority)
1599 dd.high = tag->priority - 1;
1604 dd.low = tag->priority + 1;
1609 gtk_text_tag_table_foreach (tag->table,
1610 delta_priority_foreach,
1613 tag->priority = priority;
1617 * gtk_text_tag_event:
1618 * @tag: a #GtkTextTag
1619 * @event_object: object that received the event, such as a widget
1621 * @iter: location where the event was received
1623 * Emits the "event" signal on the #GtkTextTag.
1625 * Return value: result of signal emission (whether the event was handled)
1628 gtk_text_tag_event (GtkTextTag *tag,
1629 GObject *event_object,
1631 const GtkTextIter *iter)
1633 gint retval = FALSE;
1635 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
1636 g_return_val_if_fail (GTK_IS_OBJECT (event_object), FALSE);
1637 g_return_val_if_fail (event != NULL, FALSE);
1639 g_signal_emit (G_OBJECT (tag),
1651 tag_sort_func (gconstpointer first, gconstpointer second)
1653 GtkTextTag *tag1, *tag2;
1655 tag1 = * (GtkTextTag **) first;
1656 tag2 = * (GtkTextTag **) second;
1657 return tag1->priority - tag2->priority;
1661 _gtk_text_tag_array_sort (GtkTextTag** tag_array_p,
1666 GtkTextTag **maxPtrPtr, *tmp;
1668 g_return_if_fail (tag_array_p != NULL);
1669 g_return_if_fail (len > 0);
1675 GtkTextTag **iter = tag_array_p;
1677 for (i = len-1; i > 0; i--, iter++) {
1678 maxPtrPtr = tag = iter;
1679 prio = tag[0]->priority;
1680 for (j = i, tag++; j > 0; j--, tag++) {
1681 if (tag[0]->priority < prio) {
1682 prio = tag[0]->priority;
1691 qsort ((void *) tag_array_p, (unsigned) len, sizeof (GtkTextTag *),
1697 printf ("Sorted tag array: \n");
1701 GtkTextTag *t = tag_array_p[i];
1702 printf (" %s priority %d\n", t->name, t->priority);
1715 * gtk_text_attributes_new:
1717 * Creates a #GtkTextAttributes, which describes
1718 * a set of properties on some text.
1720 * Return value: a new #GtkTextAttributes
1723 gtk_text_attributes_new (void)
1725 GtkTextAttributes *values;
1727 values = g_new0 (GtkTextAttributes, 1);
1729 /* 0 is a valid value for most of the struct */
1731 values->refcount = 1;
1733 values->language = gtk_get_default_language ();
1739 gtk_text_attributes_copy (GtkTextAttributes *src)
1741 GtkTextAttributes *dest;
1743 dest = gtk_text_attributes_new ();
1744 gtk_text_attributes_copy_values (src, dest);
1750 * gtk_text_attributes_copy_values:
1751 * @src: a #GtkTextAttributes
1752 * @dest: another #GtkTextAttributes
1754 * Copies the values from @src to @dest so that @dest has the same values
1758 gtk_text_attributes_copy_values (GtkTextAttributes *src,
1759 GtkTextAttributes *dest)
1761 guint orig_refcount;
1763 g_return_if_fail (!dest->realized);
1770 if (src->appearance.bg_stipple)
1771 gdk_bitmap_ref (src->appearance.bg_stipple);
1773 if (src->appearance.fg_stipple)
1774 gdk_bitmap_ref (src->appearance.fg_stipple);
1778 if (dest->appearance.bg_stipple)
1779 gdk_bitmap_unref (dest->appearance.bg_stipple);
1781 if (dest->appearance.fg_stipple)
1782 gdk_bitmap_unref (dest->appearance.fg_stipple);
1785 g_free (dest->language);
1787 if (dest->font.family_name)
1788 g_free (dest->font.family_name);
1791 orig_refcount = dest->refcount;
1796 dest->tabs = pango_tab_array_copy (src->tabs);
1798 dest->language = g_strdup (src->language);
1800 dest->font.family_name = g_strdup (src->font.family_name);
1802 dest->refcount = orig_refcount;
1803 dest->realized = FALSE;
1807 gtk_text_attributes_ref (GtkTextAttributes *values)
1809 g_return_if_fail (values != NULL);
1811 values->refcount += 1;
1815 gtk_text_attributes_unref (GtkTextAttributes *values)
1817 g_return_if_fail (values != NULL);
1818 g_return_if_fail (values->refcount > 0);
1820 values->refcount -= 1;
1822 if (values->refcount == 0)
1824 g_assert (!values->realized);
1826 if (values->appearance.bg_stipple)
1827 gdk_bitmap_unref (values->appearance.bg_stipple);
1829 if (values->appearance.fg_stipple)
1830 gdk_bitmap_unref (values->appearance.fg_stipple);
1833 pango_tab_array_free (values->tabs);
1835 if (values->language)
1836 g_free (values->language);
1838 if (values->font.family_name)
1839 g_free (values->font.family_name);
1846 _gtk_text_attributes_realize (GtkTextAttributes *values,
1850 g_return_if_fail (values != NULL);
1851 g_return_if_fail (values->refcount > 0);
1852 g_return_if_fail (!values->realized);
1854 /* It is wrong to use this colormap, FIXME */
1855 gdk_colormap_alloc_color (cmap,
1856 &values->appearance.fg_color,
1859 gdk_colormap_alloc_color (cmap,
1860 &values->appearance.bg_color,
1863 values->realized = TRUE;
1867 _gtk_text_attributes_unrealize (GtkTextAttributes *values,
1871 g_return_if_fail (values != NULL);
1872 g_return_if_fail (values->refcount > 0);
1873 g_return_if_fail (values->realized);
1875 gdk_colormap_free_colors (cmap,
1876 &values->appearance.fg_color, 1);
1879 gdk_colormap_free_colors (cmap,
1880 &values->appearance.bg_color, 1);
1882 values->appearance.fg_color.pixel = 0;
1883 values->appearance.bg_color.pixel = 0;
1885 values->realized = FALSE;
1889 _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
1895 g_return_if_fail (!dest->realized);
1899 GtkTextTag *tag = tags[n];
1900 GtkTextAttributes *vals = tag->values;
1903 g_assert (tags[n]->priority > tags[n-1]->priority);
1905 if (tag->bg_color_set)
1907 dest->appearance.bg_color = vals->appearance.bg_color;
1909 dest->appearance.draw_bg = TRUE;
1911 if (tag->fg_color_set)
1912 dest->appearance.fg_color = vals->appearance.fg_color;
1914 if (tag->bg_stipple_set)
1916 gdk_bitmap_ref (vals->appearance.bg_stipple);
1917 if (dest->appearance.bg_stipple)
1918 gdk_bitmap_unref (dest->appearance.bg_stipple);
1919 dest->appearance.bg_stipple = vals->appearance.bg_stipple;
1921 dest->appearance.draw_bg = TRUE;
1924 if (tag->fg_stipple_set)
1926 gdk_bitmap_ref (vals->appearance.fg_stipple);
1927 if (dest->appearance.fg_stipple)
1928 gdk_bitmap_unref (dest->appearance.fg_stipple);
1929 dest->appearance.fg_stipple = vals->appearance.fg_stipple;
1932 if (tag->family_set)
1934 if (dest->font.family_name)
1935 g_free (dest->font.family_name);
1937 dest->font.family_name = g_strdup (vals->font.family_name);
1941 dest->font.style = vals->font.style;
1943 if (tag->variant_set)
1944 dest->font.variant = vals->font.variant;
1946 if (tag->weight_set)
1947 dest->font.weight = vals->font.weight;
1949 if (tag->stretch_set)
1950 dest->font.stretch = vals->font.stretch;
1953 dest->font.size = vals->font.size;
1955 if (tag->justify_set)
1956 dest->justify = vals->justify;
1958 if (vals->direction != GTK_TEXT_DIR_NONE)
1959 dest->direction = vals->direction;
1961 if (tag->left_margin_set)
1962 dest->left_margin = vals->left_margin;
1964 if (tag->indent_set)
1965 dest->indent = vals->indent;
1968 dest->appearance.rise = vals->appearance.rise;
1970 if (tag->right_margin_set)
1971 dest->right_margin = vals->right_margin;
1973 if (tag->pixels_above_lines_set)
1974 dest->pixels_above_lines = vals->pixels_above_lines;
1976 if (tag->pixels_below_lines_set)
1977 dest->pixels_below_lines = vals->pixels_below_lines;
1979 if (tag->pixels_inside_wrap_set)
1980 dest->pixels_inside_wrap = vals->pixels_inside_wrap;
1985 pango_tab_array_free (dest->tabs);
1986 dest->tabs = pango_tab_array_copy (vals->tabs);
1989 if (tag->wrap_mode_set)
1990 dest->wrap_mode = vals->wrap_mode;
1992 if (tag->underline_set)
1993 dest->appearance.underline = vals->appearance.underline;
1995 if (tag->strikethrough_set)
1996 dest->appearance.strikethrough = vals->appearance.strikethrough;
1998 if (tag->invisible_set)
1999 dest->invisible = vals->invisible;
2001 if (tag->editable_set)
2002 dest->editable = vals->editable;
2004 if (tag->bg_full_height_set)
2005 dest->bg_full_height = vals->bg_full_height;
2007 if (tag->language_set)
2009 g_free (dest->language);
2010 dest->language = g_strdup (vals->language);
2018 _gtk_text_tag_affects_size (GtkTextTag *tag)
2020 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
2030 tag->left_margin_set ||
2033 tag->right_margin_set ||
2034 tag->pixels_above_lines_set ||
2035 tag->pixels_below_lines_set ||
2036 tag->pixels_inside_wrap_set ||
2038 tag->underline_set ||
2039 tag->wrap_mode_set ||
2044 _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag)
2046 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
2049 tag->bg_color_set ||
2050 tag->bg_stipple_set ||
2051 tag->fg_color_set ||
2052 tag->fg_stipple_set ||
2053 tag->strikethrough_set ||
2054 tag->bg_full_height_set;