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.
53 * @Short_description: A tag that can be applied to text in a GtkTextBuffer
55 * You may wish to begin by reading the <link linkend="TextWidget">text widget
56 * conceptual overview</link> which gives an overview of all the objects and
57 * data types related to the text widget and how they work together.
59 * Tags should be in the #GtkTextTagTable for a given #GtkTextBuffer
60 * before using them with that buffer.
62 * gtk_text_buffer_create_tag() is the best way to create tags.
63 * See <application>gtk3-demo</application> for numerous examples.
71 #include "gtkmainprivate.h"
72 #include "gtktexttag.h"
73 #include "gtktexttypes.h"
74 #include "gtktexttagtable.h"
76 #include "gtkmarshalers.h"
77 #include "gtkprivate.h"
78 #include "gtktypebuiltins.h"
105 PROP_PIXELS_ABOVE_LINES,
106 PROP_PIXELS_BELOW_LINES,
107 PROP_PIXELS_INSIDE_WRAP,
118 PROP_BACKGROUND_FULL_HEIGHT,
122 PROP_PARAGRAPH_BACKGROUND,
123 PROP_PARAGRAPH_BACKGROUND_GDK,
126 PROP_ACCUMULATIVE_MARGIN,
128 /* Whether-a-style-arg-is-set args */
138 PROP_PIXELS_ABOVE_LINES_SET,
139 PROP_PIXELS_BELOW_LINES_SET,
140 PROP_PIXELS_INSIDE_WRAP_SET,
143 PROP_JUSTIFICATION_SET,
144 PROP_LEFT_MARGIN_SET,
146 PROP_STRIKETHROUGH_SET,
147 PROP_RIGHT_MARGIN_SET,
150 PROP_BACKGROUND_FULL_HEIGHT_SET,
154 PROP_PARAGRAPH_BACKGROUND_SET,
158 static void gtk_text_tag_finalize (GObject *object);
159 static void gtk_text_tag_set_property (GObject *object,
163 static void gtk_text_tag_get_property (GObject *object,
168 static guint signals[LAST_SIGNAL] = { 0 };
170 G_DEFINE_TYPE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT)
173 gtk_text_tag_class_init (GtkTextTagClass *klass)
175 GObjectClass *object_class = G_OBJECT_CLASS (klass);
177 object_class->set_property = gtk_text_tag_set_property;
178 object_class->get_property = gtk_text_tag_get_property;
180 object_class->finalize = gtk_text_tag_finalize;
183 g_object_class_install_property (object_class,
185 g_param_spec_string ("name",
187 P_("Name used to refer to the text tag. NULL for anonymous tags"),
189 GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
193 g_object_class_install_property (object_class,
195 g_param_spec_string ("background",
196 P_("Background color name"),
197 P_("Background color as a string"),
199 GTK_PARAM_WRITABLE));
201 g_object_class_install_property (object_class,
203 g_param_spec_boxed ("background-gdk",
204 P_("Background color"),
205 P_("Background color as a (possibly unallocated) GdkColor"),
207 GTK_PARAM_READWRITE));
209 g_object_class_install_property (object_class,
210 PROP_BACKGROUND_FULL_HEIGHT,
211 g_param_spec_boolean ("background-full-height",
212 P_("Background full height"),
213 P_("Whether the background color fills the entire line height or only the height of the tagged characters"),
215 GTK_PARAM_READWRITE));
217 g_object_class_install_property (object_class,
219 g_param_spec_string ("foreground",
220 P_("Foreground color name"),
221 P_("Foreground color as a string"),
223 GTK_PARAM_WRITABLE));
225 g_object_class_install_property (object_class,
227 g_param_spec_boxed ("foreground-gdk",
228 P_("Foreground color"),
229 P_("Foreground color as a (possibly unallocated) GdkColor"),
231 GTK_PARAM_READWRITE));
233 g_object_class_install_property (object_class,
235 g_param_spec_enum ("direction",
236 P_("Text direction"),
237 P_("Text direction, e.g. right-to-left or left-to-right"),
238 GTK_TYPE_TEXT_DIRECTION,
240 GTK_PARAM_READWRITE));
242 g_object_class_install_property (object_class,
244 g_param_spec_boolean ("editable",
246 P_("Whether the text can be modified by the user"),
248 GTK_PARAM_READWRITE));
253 * Font description as string, e.g. \"Sans Italic 12\".
255 * Note that the initial value of this property depends on
256 * the internals of #PangoFontDescription.
258 g_object_class_install_property (object_class,
260 g_param_spec_string ("font",
262 P_("Font description as a string, e.g. \"Sans Italic 12\""),
264 GTK_PARAM_READWRITE));
266 g_object_class_install_property (object_class,
268 g_param_spec_boxed ("font-desc",
270 P_("Font description as a PangoFontDescription struct"),
271 PANGO_TYPE_FONT_DESCRIPTION,
272 GTK_PARAM_READWRITE));
274 g_object_class_install_property (object_class,
276 g_param_spec_string ("family",
278 P_("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
280 GTK_PARAM_READWRITE));
282 g_object_class_install_property (object_class,
284 g_param_spec_enum ("style",
286 P_("Font style as a PangoStyle, e.g. PANGO_STYLE_ITALIC"),
289 GTK_PARAM_READWRITE));
291 g_object_class_install_property (object_class,
293 g_param_spec_enum ("variant",
295 P_("Font variant as a PangoVariant, e.g. PANGO_VARIANT_SMALL_CAPS"),
297 PANGO_VARIANT_NORMAL,
298 GTK_PARAM_READWRITE));
300 g_object_class_install_property (object_class,
302 g_param_spec_int ("weight",
304 P_("Font weight as an integer, see predefined values in PangoWeight; for example, PANGO_WEIGHT_BOLD"),
308 GTK_PARAM_READWRITE));
311 g_object_class_install_property (object_class,
313 g_param_spec_enum ("stretch",
315 P_("Font stretch as a PangoStretch, e.g. PANGO_STRETCH_CONDENSED"),
317 PANGO_STRETCH_NORMAL,
318 GTK_PARAM_READWRITE));
320 g_object_class_install_property (object_class,
322 g_param_spec_int ("size",
324 P_("Font size in Pango units"),
328 GTK_PARAM_READWRITE));
330 g_object_class_install_property (object_class,
332 g_param_spec_double ("scale",
334 P_("Font size as a scale factor relative to the default font size. This properly adapts to theme changes etc. so is recommended. Pango predefines some scales such as PANGO_SCALE_X_LARGE"),
338 GTK_PARAM_READWRITE));
340 g_object_class_install_property (object_class,
342 g_param_spec_double ("size-points",
344 P_("Font size in points"),
348 GTK_PARAM_READWRITE));
350 g_object_class_install_property (object_class,
352 g_param_spec_enum ("justification",
354 P_("Left, right, or center justification"),
355 GTK_TYPE_JUSTIFICATION,
357 GTK_PARAM_READWRITE));
360 * GtkTextTag:language:
362 * The language this text is in, as an ISO code. Pango can use this as a
363 * hint when rendering the text. If not set, an appropriate default will be
366 * Note that the initial value of this property depends on the current
367 * locale, see also gtk_get_default_language().
369 g_object_class_install_property (object_class,
371 g_param_spec_string ("language",
373 P_("The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If not set, an appropriate default will be used."),
375 GTK_PARAM_READWRITE));
377 g_object_class_install_property (object_class,
379 g_param_spec_int ("left-margin",
381 P_("Width of the left margin in pixels"),
385 GTK_PARAM_READWRITE));
387 g_object_class_install_property (object_class,
389 g_param_spec_int ("right-margin",
391 P_("Width of the right margin in pixels"),
395 GTK_PARAM_READWRITE));
398 g_object_class_install_property (object_class,
400 g_param_spec_int ("indent",
402 P_("Amount to indent the paragraph, in pixels"),
406 GTK_PARAM_READWRITE));
409 g_object_class_install_property (object_class,
411 g_param_spec_int ("rise",
413 P_("Offset of text above the baseline (below the baseline if rise is negative) in Pango units"),
417 GTK_PARAM_READWRITE));
419 g_object_class_install_property (object_class,
420 PROP_PIXELS_ABOVE_LINES,
421 g_param_spec_int ("pixels-above-lines",
422 P_("Pixels above lines"),
423 P_("Pixels of blank space above paragraphs"),
427 GTK_PARAM_READWRITE));
429 g_object_class_install_property (object_class,
430 PROP_PIXELS_BELOW_LINES,
431 g_param_spec_int ("pixels-below-lines",
432 P_("Pixels below lines"),
433 P_("Pixels of blank space below paragraphs"),
437 GTK_PARAM_READWRITE));
439 g_object_class_install_property (object_class,
440 PROP_PIXELS_INSIDE_WRAP,
441 g_param_spec_int ("pixels-inside-wrap",
442 P_("Pixels inside wrap"),
443 P_("Pixels of blank space between wrapped lines in a paragraph"),
447 GTK_PARAM_READWRITE));
449 g_object_class_install_property (object_class,
451 g_param_spec_boolean ("strikethrough",
453 P_("Whether to strike through the text"),
455 GTK_PARAM_READWRITE));
457 g_object_class_install_property (object_class,
459 g_param_spec_enum ("underline",
461 P_("Style of underline for this text"),
462 PANGO_TYPE_UNDERLINE,
463 PANGO_UNDERLINE_NONE,
464 GTK_PARAM_READWRITE));
466 g_object_class_install_property (object_class,
468 g_param_spec_enum ("wrap-mode",
470 P_("Whether to wrap lines never, at word boundaries, or at character boundaries"),
473 GTK_PARAM_READWRITE));
476 g_object_class_install_property (object_class,
478 g_param_spec_boxed ("tabs",
480 P_("Custom tabs for this text"),
481 PANGO_TYPE_TAB_ARRAY,
482 GTK_PARAM_READWRITE));
485 * GtkTextTag:invisible:
487 * Whether this text is hidden.
489 * Note that there may still be problems with the support for invisible
490 * text, in particular when navigating programmatically inside a buffer
491 * containing invisible segments.
495 g_object_class_install_property (object_class,
497 g_param_spec_boolean ("invisible",
499 P_("Whether this text is hidden."),
501 GTK_PARAM_READWRITE));
504 * GtkTextTag:paragraph-background:
506 * The paragraph background color as a string.
510 g_object_class_install_property (object_class,
511 PROP_PARAGRAPH_BACKGROUND,
512 g_param_spec_string ("paragraph-background",
513 P_("Paragraph background color name"),
514 P_("Paragraph background color as a string"),
516 GTK_PARAM_WRITABLE));
519 * GtkTextTag:paragraph-background-gdk:
521 * The paragraph background color as a as a (possibly unallocated)
526 g_object_class_install_property (object_class,
527 PROP_PARAGRAPH_BACKGROUND_GDK,
528 g_param_spec_boxed ("paragraph-background-gdk",
529 P_("Paragraph background color"),
530 P_("Paragraph background color as a (possibly unallocated) GdkColor"),
532 GTK_PARAM_READWRITE));
535 * GtkTextTag:accumulative-margin:
537 * Whether the margins accumulate or override each other.
539 * When set to %TRUE the margins of this tag are added to the margins
540 * of any other non-accumulative margins present. When set to %FALSE
541 * the margins override one another (the default).
545 g_object_class_install_property (object_class,
546 PROP_ACCUMULATIVE_MARGIN,
547 g_param_spec_boolean ("accumulative-margin",
548 P_("Margin Accumulates"),
549 P_("Whether left and right margins accumulate."),
551 GTK_PARAM_READWRITE));
553 /* Style props are set or not */
555 #define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
557 ADD_SET_PROP ("background-set", PROP_BACKGROUND_SET,
558 P_("Background set"),
559 P_("Whether this tag affects the background color"));
561 ADD_SET_PROP ("background-full-height-set", PROP_BACKGROUND_FULL_HEIGHT_SET,
562 P_("Background full height set"),
563 P_("Whether this tag affects background height"));
565 ADD_SET_PROP ("foreground-set", PROP_FOREGROUND_SET,
566 P_("Foreground set"),
567 P_("Whether this tag affects the foreground color"));
569 ADD_SET_PROP ("editable-set", PROP_EDITABLE_SET,
570 P_("Editability set"),
571 P_("Whether this tag affects text editability"));
573 ADD_SET_PROP ("family-set", PROP_FAMILY_SET,
574 P_("Font family set"),
575 P_("Whether this tag affects the font family"));
577 ADD_SET_PROP ("style-set", PROP_STYLE_SET,
578 P_("Font style set"),
579 P_("Whether this tag affects the font style"));
581 ADD_SET_PROP ("variant-set", PROP_VARIANT_SET,
582 P_("Font variant set"),
583 P_("Whether this tag affects the font variant"));
585 ADD_SET_PROP ("weight-set", PROP_WEIGHT_SET,
586 P_("Font weight set"),
587 P_("Whether this tag affects the font weight"));
589 ADD_SET_PROP ("stretch-set", PROP_STRETCH_SET,
590 P_("Font stretch set"),
591 P_("Whether this tag affects the font stretch"));
593 ADD_SET_PROP ("size-set", PROP_SIZE_SET,
595 P_("Whether this tag affects the font size"));
597 ADD_SET_PROP ("scale-set", PROP_SCALE_SET,
598 P_("Font scale set"),
599 P_("Whether this tag scales the font size by a factor"));
601 ADD_SET_PROP ("justification-set", PROP_JUSTIFICATION_SET,
602 P_("Justification set"),
603 P_("Whether this tag affects paragraph justification"));
605 ADD_SET_PROP ("language-set", PROP_LANGUAGE_SET,
607 P_("Whether this tag affects the language the text is rendered as"));
609 ADD_SET_PROP ("left-margin-set", PROP_LEFT_MARGIN_SET,
610 P_("Left margin set"),
611 P_("Whether this tag affects the left margin"));
613 ADD_SET_PROP ("indent-set", PROP_INDENT_SET,
615 P_("Whether this tag affects indentation"));
617 ADD_SET_PROP ("rise-set", PROP_RISE_SET,
619 P_("Whether this tag affects the rise"));
621 ADD_SET_PROP ("pixels-above-lines-set", PROP_PIXELS_ABOVE_LINES_SET,
622 P_("Pixels above lines set"),
623 P_("Whether this tag affects the number of pixels above lines"));
625 ADD_SET_PROP ("pixels-below-lines-set", PROP_PIXELS_BELOW_LINES_SET,
626 P_("Pixels below lines set"),
627 P_("Whether this tag affects the number of pixels above lines"));
629 ADD_SET_PROP ("pixels-inside-wrap-set", PROP_PIXELS_INSIDE_WRAP_SET,
630 P_("Pixels inside wrap set"),
631 P_("Whether this tag affects the number of pixels between wrapped lines"));
633 ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
634 P_("Strikethrough set"),
635 P_("Whether this tag affects strikethrough"));
637 ADD_SET_PROP ("right-margin-set", PROP_RIGHT_MARGIN_SET,
638 P_("Right margin set"),
639 P_("Whether this tag affects the right margin"));
641 ADD_SET_PROP ("underline-set", PROP_UNDERLINE_SET,
643 P_("Whether this tag affects underlining"));
645 ADD_SET_PROP ("wrap-mode-set", PROP_WRAP_MODE_SET,
647 P_("Whether this tag affects line wrap mode"));
649 ADD_SET_PROP ("tabs-set", PROP_TABS_SET,
651 P_("Whether this tag affects tabs"));
653 ADD_SET_PROP ("invisible-set", PROP_INVISIBLE_SET,
655 P_("Whether this tag affects text visibility"));
657 ADD_SET_PROP ("paragraph-background-set", PROP_PARAGRAPH_BACKGROUND_SET,
658 P_("Paragraph background set"),
659 P_("Whether this tag affects the paragraph background color"));
663 * @tag: the #GtkTextTag on which the signal is emitted
664 * @object: the object the event was fired from (typically a #GtkTextView)
665 * @event: the event which triggered the signal
666 * @iter: a #GtkTextIter pointing at the location the event occured
668 * The ::event signal is emitted when an event occurs on a region of the
669 * buffer marked with this tag.
671 * Returns: %TRUE to stop other handlers from being invoked for the
672 * event. %FALSE to propagate the event further.
675 g_signal_new (I_("event"),
676 G_OBJECT_CLASS_TYPE (object_class),
678 G_STRUCT_OFFSET (GtkTextTagClass, event),
679 _gtk_boolean_handled_accumulator, NULL,
680 _gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
684 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
687 g_type_class_add_private (klass, sizeof (GtkTextTagPrivate));
691 gtk_text_tag_init (GtkTextTag *text_tag)
693 GtkTextTagPrivate *priv;
695 text_tag->priv = G_TYPE_INSTANCE_GET_PRIVATE (text_tag,
698 priv = text_tag->priv;
700 priv->values = gtk_text_attributes_new ();
705 * @name: (allow-none): tag name, or %NULL
707 * Creates a #GtkTextTag. Configure the tag using object arguments,
708 * i.e. using g_object_set().
710 * Return value: a new #GtkTextTag
713 gtk_text_tag_new (const gchar *name)
717 tag = g_object_new (GTK_TYPE_TEXT_TAG, "name", name, NULL);
723 gtk_text_tag_finalize (GObject *object)
725 GtkTextTag *text_tag = GTK_TEXT_TAG (object);
726 GtkTextTagPrivate *priv = text_tag->priv;
729 gtk_text_tag_table_remove (priv->table, text_tag);
731 g_assert (priv->table == NULL);
733 gtk_text_attributes_unref (priv->values);
739 G_OBJECT_CLASS (gtk_text_tag_parent_class)->finalize (object);
743 set_bg_color (GtkTextTag *tag, GdkColor *color)
745 GtkTextTagPrivate *priv = tag->priv;
749 if (!priv->bg_color_set)
751 priv->bg_color_set = TRUE;
752 g_object_notify (G_OBJECT (tag), "background-set");
755 priv->values->appearance.bg_color = *color;
759 if (priv->bg_color_set)
761 priv->bg_color_set = FALSE;
762 g_object_notify (G_OBJECT (tag), "background-set");
768 set_fg_color (GtkTextTag *tag, GdkColor *color)
770 GtkTextTagPrivate *priv = tag->priv;
774 if (!priv->fg_color_set)
776 priv->fg_color_set = TRUE;
777 g_object_notify (G_OBJECT (tag), "foreground-set");
779 priv->values->appearance.fg_color = *color;
783 if (priv->fg_color_set)
785 priv->fg_color_set = FALSE;
786 g_object_notify (G_OBJECT (tag), "foreground-set");
792 set_pg_bg_color (GtkTextTag *tag, GdkColor *color)
794 GtkTextTagPrivate *priv = tag->priv;
798 if (!priv->pg_bg_color_set)
800 priv->pg_bg_color_set = TRUE;
801 g_object_notify (G_OBJECT (tag), "paragraph-background-set");
804 gdk_color_free (priv->values->pg_bg_color);
806 priv->values->pg_bg_color = gdk_color_copy (color);
810 if (priv->pg_bg_color_set)
812 priv->pg_bg_color_set = FALSE;
813 g_object_notify (G_OBJECT (tag), "paragraph-background-set");
814 gdk_color_free (priv->values->pg_bg_color);
817 priv->values->pg_bg_color = NULL;
822 get_property_font_set_mask (guint prop_id)
826 case PROP_FAMILY_SET:
827 return PANGO_FONT_MASK_FAMILY;
829 return PANGO_FONT_MASK_STYLE;
830 case PROP_VARIANT_SET:
831 return PANGO_FONT_MASK_VARIANT;
832 case PROP_WEIGHT_SET:
833 return PANGO_FONT_MASK_WEIGHT;
834 case PROP_STRETCH_SET:
835 return PANGO_FONT_MASK_STRETCH;
837 return PANGO_FONT_MASK_SIZE;
844 set_font_desc_fields (PangoFontDescription *desc,
845 PangoFontMask to_set)
847 PangoFontMask changed_mask = 0;
849 if (to_set & PANGO_FONT_MASK_FAMILY)
851 const char *family = pango_font_description_get_family (desc);
855 changed_mask |= PANGO_FONT_MASK_FAMILY;
858 pango_font_description_set_family (desc, family);
860 if (to_set & PANGO_FONT_MASK_STYLE)
861 pango_font_description_set_style (desc, pango_font_description_get_style (desc));
862 if (to_set & PANGO_FONT_MASK_VARIANT)
863 pango_font_description_set_variant (desc, pango_font_description_get_variant (desc));
864 if (to_set & PANGO_FONT_MASK_WEIGHT)
865 pango_font_description_set_weight (desc, pango_font_description_get_weight (desc));
866 if (to_set & PANGO_FONT_MASK_STRETCH)
867 pango_font_description_set_stretch (desc, pango_font_description_get_stretch (desc));
868 if (to_set & PANGO_FONT_MASK_SIZE)
870 gint size = pango_font_description_get_size (desc);
873 size = 10 * PANGO_SCALE;
874 changed_mask |= PANGO_FONT_MASK_SIZE;
877 pango_font_description_set_size (desc, size);
884 notify_set_changed (GObject *object,
885 PangoFontMask changed_mask)
887 if (changed_mask & PANGO_FONT_MASK_FAMILY)
888 g_object_notify (object, "family-set");
889 if (changed_mask & PANGO_FONT_MASK_STYLE)
890 g_object_notify (object, "style-set");
891 if (changed_mask & PANGO_FONT_MASK_VARIANT)
892 g_object_notify (object, "variant-set");
893 if (changed_mask & PANGO_FONT_MASK_WEIGHT)
894 g_object_notify (object, "weight-set");
895 if (changed_mask & PANGO_FONT_MASK_STRETCH)
896 g_object_notify (object, "stretch-set");
897 if (changed_mask & PANGO_FONT_MASK_SIZE)
898 g_object_notify (object, "size-set");
902 notify_fields_changed (GObject *object,
903 PangoFontMask changed_mask)
905 if (changed_mask & PANGO_FONT_MASK_FAMILY)
906 g_object_notify (object, "family");
907 if (changed_mask & PANGO_FONT_MASK_STYLE)
908 g_object_notify (object, "style");
909 if (changed_mask & PANGO_FONT_MASK_VARIANT)
910 g_object_notify (object, "variant");
911 if (changed_mask & PANGO_FONT_MASK_WEIGHT)
912 g_object_notify (object, "weight");
913 if (changed_mask & PANGO_FONT_MASK_STRETCH)
914 g_object_notify (object, "stretch");
915 if (changed_mask & PANGO_FONT_MASK_SIZE)
916 g_object_notify (object, "size");
920 set_font_description (GtkTextTag *text_tag,
921 PangoFontDescription *font_desc)
923 GtkTextTagPrivate *priv = text_tag->priv;
924 GObject *object = G_OBJECT (text_tag);
925 PangoFontDescription *new_font_desc;
926 PangoFontMask old_mask, new_mask, changed_mask, set_changed_mask;
929 new_font_desc = pango_font_description_copy (font_desc);
931 new_font_desc = pango_font_description_new ();
933 if (priv->values->font)
934 old_mask = pango_font_description_get_set_fields (priv->values->font);
938 new_mask = pango_font_description_get_set_fields (new_font_desc);
940 changed_mask = old_mask | new_mask;
941 set_changed_mask = old_mask ^ new_mask;
943 if (priv->values->font)
944 pango_font_description_free (priv->values->font);
945 priv->values->font = new_font_desc;
947 g_object_freeze_notify (object);
949 g_object_notify (object, "font-desc");
950 g_object_notify (object, "font");
952 if (changed_mask & PANGO_FONT_MASK_FAMILY)
953 g_object_notify (object, "family");
954 if (changed_mask & PANGO_FONT_MASK_STYLE)
955 g_object_notify (object, "style");
956 if (changed_mask & PANGO_FONT_MASK_VARIANT)
957 g_object_notify (object, "variant");
958 if (changed_mask & PANGO_FONT_MASK_WEIGHT)
959 g_object_notify (object, "weight");
960 if (changed_mask & PANGO_FONT_MASK_STRETCH)
961 g_object_notify (object, "stretch");
962 if (changed_mask & PANGO_FONT_MASK_SIZE)
964 g_object_notify (object, "size");
965 g_object_notify (object, "size-points");
968 notify_set_changed (object, set_changed_mask);
970 g_object_thaw_notify (object);
974 gtk_text_tag_ensure_font (GtkTextTag *text_tag)
976 GtkTextTagPrivate *priv = text_tag->priv;
978 if (!priv->values->font)
979 priv->values->font = pango_font_description_new ();
983 gtk_text_tag_set_property (GObject *object,
988 GtkTextTag *text_tag = GTK_TEXT_TAG (object);
989 GtkTextTagPrivate *priv = text_tag->priv;
990 gboolean size_changed = FALSE;
995 g_return_if_fail (priv->name == NULL);
996 priv->name = g_value_dup_string (value);
999 case PROP_BACKGROUND:
1003 if (!g_value_get_string (value))
1004 set_bg_color (text_tag, NULL); /* reset to background_set to FALSE */
1005 else if (gdk_color_parse (g_value_get_string (value), &color))
1006 set_bg_color (text_tag, &color);
1008 g_warning ("Don't know color `%s'", g_value_get_string (value));
1010 g_object_notify (object, "background-gdk");
1014 case PROP_FOREGROUND:
1018 if (!g_value_get_string (value))
1019 set_fg_color (text_tag, NULL); /* reset to foreground_set to FALSE */
1020 else if (gdk_color_parse (g_value_get_string (value), &color))
1021 set_fg_color (text_tag, &color);
1023 g_warning ("Don't know color `%s'", g_value_get_string (value));
1025 g_object_notify (object, "foreground-gdk");
1029 case PROP_BACKGROUND_GDK:
1031 GdkColor *color = g_value_get_boxed (value);
1033 set_bg_color (text_tag, color);
1037 case PROP_FOREGROUND_GDK:
1039 GdkColor *color = g_value_get_boxed (value);
1041 set_fg_color (text_tag, color);
1047 PangoFontDescription *font_desc = NULL;
1050 name = g_value_get_string (value);
1053 font_desc = pango_font_description_from_string (name);
1055 set_font_description (text_tag, font_desc);
1057 pango_font_description_free (font_desc);
1059 size_changed = TRUE;
1063 case PROP_FONT_DESC:
1065 PangoFontDescription *font_desc;
1067 font_desc = g_value_get_boxed (value);
1069 set_font_description (text_tag, font_desc);
1071 size_changed = TRUE;
1081 case PROP_SIZE_POINTS:
1083 PangoFontMask old_set_mask;
1085 gtk_text_tag_ensure_font (text_tag);
1086 old_set_mask = pango_font_description_get_set_fields (priv->values->font);
1091 pango_font_description_set_family (priv->values->font,
1092 g_value_get_string (value));
1095 pango_font_description_set_style (priv->values->font,
1096 g_value_get_enum (value));
1099 pango_font_description_set_variant (priv->values->font,
1100 g_value_get_enum (value));
1103 pango_font_description_set_weight (priv->values->font,
1104 g_value_get_int (value));
1107 pango_font_description_set_stretch (priv->values->font,
1108 g_value_get_enum (value));
1111 pango_font_description_set_size (priv->values->font,
1112 g_value_get_int (value));
1113 g_object_notify (object, "size-points");
1115 case PROP_SIZE_POINTS:
1116 pango_font_description_set_size (priv->values->font,
1117 g_value_get_double (value) * PANGO_SCALE);
1118 g_object_notify (object, "size");
1122 size_changed = TRUE;
1123 notify_set_changed (object, old_set_mask & pango_font_description_get_set_fields (priv->values->font));
1124 g_object_notify (object, "font-desc");
1125 g_object_notify (object, "font");
1131 priv->values->font_scale = g_value_get_double (value);
1132 priv->scale_set = TRUE;
1133 g_object_notify (object, "scale-set");
1134 size_changed = TRUE;
1137 case PROP_PIXELS_ABOVE_LINES:
1138 priv->pixels_above_lines_set = TRUE;
1139 priv->values->pixels_above_lines = g_value_get_int (value);
1140 g_object_notify (object, "pixels-above-lines-set");
1141 size_changed = TRUE;
1144 case PROP_PIXELS_BELOW_LINES:
1145 priv->pixels_below_lines_set = TRUE;
1146 priv->values->pixels_below_lines = g_value_get_int (value);
1147 g_object_notify (object, "pixels-below-lines-set");
1148 size_changed = TRUE;
1151 case PROP_PIXELS_INSIDE_WRAP:
1152 priv->pixels_inside_wrap_set = TRUE;
1153 priv->values->pixels_inside_wrap = g_value_get_int (value);
1154 g_object_notify (object, "pixels-inside-wrap-set");
1155 size_changed = TRUE;
1159 priv->editable_set = TRUE;
1160 priv->values->editable = g_value_get_boolean (value);
1161 g_object_notify (object, "editable-set");
1164 case PROP_WRAP_MODE:
1165 priv->wrap_mode_set = TRUE;
1166 priv->values->wrap_mode = g_value_get_enum (value);
1167 g_object_notify (object, "wrap-mode-set");
1168 size_changed = TRUE;
1171 case PROP_JUSTIFICATION:
1172 priv->justification_set = TRUE;
1173 priv->values->justification = g_value_get_enum (value);
1174 g_object_notify (object, "justification-set");
1175 size_changed = TRUE;
1178 case PROP_DIRECTION:
1179 priv->values->direction = g_value_get_enum (value);
1182 case PROP_LEFT_MARGIN:
1183 priv->left_margin_set = TRUE;
1184 priv->values->left_margin = g_value_get_int (value);
1185 g_object_notify (object, "left-margin-set");
1186 size_changed = TRUE;
1190 priv->indent_set = TRUE;
1191 priv->values->indent = g_value_get_int (value);
1192 g_object_notify (object, "indent-set");
1193 size_changed = TRUE;
1196 case PROP_STRIKETHROUGH:
1197 priv->strikethrough_set = TRUE;
1198 priv->values->appearance.strikethrough = g_value_get_boolean (value);
1199 g_object_notify (object, "strikethrough-set");
1202 case PROP_RIGHT_MARGIN:
1203 priv->right_margin_set = TRUE;
1204 priv->values->right_margin = g_value_get_int (value);
1205 g_object_notify (object, "right-margin-set");
1206 size_changed = TRUE;
1209 case PROP_UNDERLINE:
1210 priv->underline_set = TRUE;
1211 priv->values->appearance.underline = g_value_get_enum (value);
1212 g_object_notify (object, "underline-set");
1216 priv->rise_set = TRUE;
1217 priv->values->appearance.rise = g_value_get_int (value);
1218 g_object_notify (object, "rise-set");
1219 size_changed = TRUE;
1222 case PROP_BACKGROUND_FULL_HEIGHT:
1223 priv->bg_full_height_set = TRUE;
1224 priv->values->bg_full_height = g_value_get_boolean (value);
1225 g_object_notify (object, "background-full-height-set");
1229 priv->language_set = TRUE;
1230 priv->values->language = pango_language_from_string (g_value_get_string (value));
1231 g_object_notify (object, "language-set");
1235 priv->tabs_set = TRUE;
1237 if (priv->values->tabs)
1238 pango_tab_array_free (priv->values->tabs);
1240 /* FIXME I'm not sure if this is a memleak or not */
1241 priv->values->tabs =
1242 pango_tab_array_copy (g_value_get_boxed (value));
1244 g_object_notify (object, "tabs-set");
1246 size_changed = TRUE;
1249 case PROP_INVISIBLE:
1250 priv->invisible_set = TRUE;
1251 priv->values->invisible = g_value_get_boolean (value);
1252 g_object_notify (object, "invisible-set");
1253 size_changed = TRUE;
1256 case PROP_PARAGRAPH_BACKGROUND:
1260 if (!g_value_get_string (value))
1261 set_pg_bg_color (text_tag, NULL); /* reset to paragraph_background_set to FALSE */
1262 else if (gdk_color_parse (g_value_get_string (value), &color))
1263 set_pg_bg_color (text_tag, &color);
1265 g_warning ("Don't know color `%s'", g_value_get_string (value));
1267 g_object_notify (object, "paragraph-background-gdk");
1271 case PROP_PARAGRAPH_BACKGROUND_GDK:
1273 GdkColor *color = g_value_get_boxed (value);
1275 set_pg_bg_color (text_tag, color);
1279 case PROP_ACCUMULATIVE_MARGIN:
1280 priv->accumulative_margin = g_value_get_boolean (value);
1281 g_object_notify (object, "accumulative-margin");
1282 size_changed = TRUE;
1285 /* Whether the value should be used... */
1287 case PROP_BACKGROUND_SET:
1288 priv->bg_color_set = g_value_get_boolean (value);
1291 case PROP_FOREGROUND_SET:
1292 priv->fg_color_set = g_value_get_boolean (value);
1295 case PROP_FAMILY_SET:
1296 case PROP_STYLE_SET:
1297 case PROP_VARIANT_SET:
1298 case PROP_WEIGHT_SET:
1299 case PROP_STRETCH_SET:
1301 if (!g_value_get_boolean (value))
1303 if (priv->values->font)
1304 pango_font_description_unset_fields (priv->values->font,
1305 get_property_font_set_mask (prop_id));
1309 PangoFontMask changed_mask;
1311 gtk_text_tag_ensure_font (text_tag);
1312 changed_mask = set_font_desc_fields (priv->values->font,
1313 get_property_font_set_mask (prop_id));
1314 notify_fields_changed (G_OBJECT (text_tag), changed_mask);
1318 case PROP_SCALE_SET:
1319 priv->scale_set = g_value_get_boolean (value);
1320 size_changed = TRUE;
1323 case PROP_PIXELS_ABOVE_LINES_SET:
1324 priv->pixels_above_lines_set = g_value_get_boolean (value);
1325 size_changed = TRUE;
1328 case PROP_PIXELS_BELOW_LINES_SET:
1329 priv->pixels_below_lines_set = g_value_get_boolean (value);
1330 size_changed = TRUE;
1333 case PROP_PIXELS_INSIDE_WRAP_SET:
1334 priv->pixels_inside_wrap_set = g_value_get_boolean (value);
1335 size_changed = TRUE;
1338 case PROP_EDITABLE_SET:
1339 priv->editable_set = g_value_get_boolean (value);
1342 case PROP_WRAP_MODE_SET:
1343 priv->wrap_mode_set = g_value_get_boolean (value);
1344 size_changed = TRUE;
1347 case PROP_JUSTIFICATION_SET:
1348 priv->justification_set = g_value_get_boolean (value);
1349 size_changed = TRUE;
1352 case PROP_LEFT_MARGIN_SET:
1353 priv->left_margin_set = g_value_get_boolean (value);
1354 size_changed = TRUE;
1357 case PROP_INDENT_SET:
1358 priv->indent_set = g_value_get_boolean (value);
1359 size_changed = TRUE;
1362 case PROP_STRIKETHROUGH_SET:
1363 priv->strikethrough_set = g_value_get_boolean (value);
1366 case PROP_RIGHT_MARGIN_SET:
1367 priv->right_margin_set = g_value_get_boolean (value);
1368 size_changed = TRUE;
1371 case PROP_UNDERLINE_SET:
1372 priv->underline_set = g_value_get_boolean (value);
1376 priv->rise_set = g_value_get_boolean (value);
1377 size_changed = TRUE;
1380 case PROP_BACKGROUND_FULL_HEIGHT_SET:
1381 priv->bg_full_height_set = g_value_get_boolean (value);
1384 case PROP_LANGUAGE_SET:
1385 priv->language_set = g_value_get_boolean (value);
1386 size_changed = TRUE;
1390 priv->tabs_set = g_value_get_boolean (value);
1391 size_changed = TRUE;
1394 case PROP_INVISIBLE_SET:
1395 priv->invisible_set = g_value_get_boolean (value);
1396 size_changed = TRUE;
1399 case PROP_PARAGRAPH_BACKGROUND_SET:
1400 priv->pg_bg_color_set = g_value_get_boolean (value);
1404 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1408 /* FIXME I would like to do this after all set_property in a single
1409 * g_object_set () have been called. But an idle function won't
1410 * work; we need to emit when the tag is changed, not when we get
1411 * around to the event loop. So blah, we eat some inefficiency.
1414 /* This is also somewhat weird since we emit another object's
1415 * signal here, but the two objects are already tightly bound.
1419 g_signal_emit_by_name (priv->table,
1421 text_tag, size_changed);
1425 gtk_text_tag_get_property (GObject *object,
1430 GtkTextTag *tag = GTK_TEXT_TAG (object);
1431 GtkTextTagPrivate *priv = tag->priv;
1436 g_value_set_string (value, priv->name);
1439 case PROP_BACKGROUND_GDK:
1440 g_value_set_boxed (value, &priv->values->appearance.bg_color);
1443 case PROP_FOREGROUND_GDK:
1444 g_value_set_boxed (value, &priv->values->appearance.fg_color);
1451 gtk_text_tag_ensure_font (tag);
1453 str = pango_font_description_to_string (priv->values->font);
1454 g_value_take_string (value, str);
1458 case PROP_FONT_DESC:
1459 gtk_text_tag_ensure_font (tag);
1460 g_value_set_boxed (value, priv->values->font);
1469 case PROP_SIZE_POINTS:
1470 gtk_text_tag_ensure_font (tag);
1474 g_value_set_string (value, pango_font_description_get_family (priv->values->font));
1478 g_value_set_enum (value, pango_font_description_get_style (priv->values->font));
1482 g_value_set_enum (value, pango_font_description_get_variant (priv->values->font));
1486 g_value_set_int (value, pango_font_description_get_weight (priv->values->font));
1490 g_value_set_enum (value, pango_font_description_get_stretch (priv->values->font));
1494 g_value_set_int (value, pango_font_description_get_size (priv->values->font));
1497 case PROP_SIZE_POINTS:
1498 g_value_set_double (value, ((double)pango_font_description_get_size (priv->values->font)) / (double)PANGO_SCALE);
1504 g_value_set_double (value, priv->values->font_scale);
1507 case PROP_PIXELS_ABOVE_LINES:
1508 g_value_set_int (value, priv->values->pixels_above_lines);
1511 case PROP_PIXELS_BELOW_LINES:
1512 g_value_set_int (value, priv->values->pixels_below_lines);
1515 case PROP_PIXELS_INSIDE_WRAP:
1516 g_value_set_int (value, priv->values->pixels_inside_wrap);
1520 g_value_set_boolean (value, priv->values->editable);
1523 case PROP_WRAP_MODE:
1524 g_value_set_enum (value, priv->values->wrap_mode);
1527 case PROP_JUSTIFICATION:
1528 g_value_set_enum (value, priv->values->justification);
1531 case PROP_DIRECTION:
1532 g_value_set_enum (value, priv->values->direction);
1535 case PROP_LEFT_MARGIN:
1536 g_value_set_int (value, priv->values->left_margin);
1540 g_value_set_int (value, priv->values->indent);
1543 case PROP_STRIKETHROUGH:
1544 g_value_set_boolean (value, priv->values->appearance.strikethrough);
1547 case PROP_RIGHT_MARGIN:
1548 g_value_set_int (value, priv->values->right_margin);
1551 case PROP_UNDERLINE:
1552 g_value_set_enum (value, priv->values->appearance.underline);
1556 g_value_set_int (value, priv->values->appearance.rise);
1559 case PROP_BACKGROUND_FULL_HEIGHT:
1560 g_value_set_boolean (value, priv->values->bg_full_height);
1564 g_value_set_string (value, pango_language_to_string (priv->values->language));
1568 if (priv->values->tabs)
1569 g_value_set_boxed (value, priv->values->tabs);
1572 case PROP_INVISIBLE:
1573 g_value_set_boolean (value, priv->values->invisible);
1576 case PROP_PARAGRAPH_BACKGROUND_GDK:
1577 g_value_set_boxed (value, priv->values->pg_bg_color);
1580 case PROP_ACCUMULATIVE_MARGIN:
1581 g_value_set_boolean (value, priv->accumulative_margin);
1584 case PROP_BACKGROUND_SET:
1585 g_value_set_boolean (value, priv->bg_color_set);
1588 case PROP_FOREGROUND_SET:
1589 g_value_set_boolean (value, priv->fg_color_set);
1592 case PROP_FAMILY_SET:
1593 case PROP_STYLE_SET:
1594 case PROP_VARIANT_SET:
1595 case PROP_WEIGHT_SET:
1596 case PROP_STRETCH_SET:
1599 PangoFontMask set_mask = priv->values->font ? pango_font_description_get_set_fields (priv->values->font) : 0;
1600 PangoFontMask test_mask = get_property_font_set_mask (prop_id);
1601 g_value_set_boolean (value, (set_mask & test_mask) != 0);
1606 case PROP_SCALE_SET:
1607 g_value_set_boolean (value, priv->scale_set);
1610 case PROP_PIXELS_ABOVE_LINES_SET:
1611 g_value_set_boolean (value, priv->pixels_above_lines_set);
1614 case PROP_PIXELS_BELOW_LINES_SET:
1615 g_value_set_boolean (value, priv->pixels_below_lines_set);
1618 case PROP_PIXELS_INSIDE_WRAP_SET:
1619 g_value_set_boolean (value, priv->pixels_inside_wrap_set);
1622 case PROP_EDITABLE_SET:
1623 g_value_set_boolean (value, priv->editable_set);
1626 case PROP_WRAP_MODE_SET:
1627 g_value_set_boolean (value, priv->wrap_mode_set);
1630 case PROP_JUSTIFICATION_SET:
1631 g_value_set_boolean (value, priv->justification_set);
1634 case PROP_LEFT_MARGIN_SET:
1635 g_value_set_boolean (value, priv->left_margin_set);
1638 case PROP_INDENT_SET:
1639 g_value_set_boolean (value, priv->indent_set);
1642 case PROP_STRIKETHROUGH_SET:
1643 g_value_set_boolean (value, priv->strikethrough_set);
1646 case PROP_RIGHT_MARGIN_SET:
1647 g_value_set_boolean (value, priv->right_margin_set);
1650 case PROP_UNDERLINE_SET:
1651 g_value_set_boolean (value, priv->underline_set);
1655 g_value_set_boolean (value, priv->rise_set);
1658 case PROP_BACKGROUND_FULL_HEIGHT_SET:
1659 g_value_set_boolean (value, priv->bg_full_height_set);
1662 case PROP_LANGUAGE_SET:
1663 g_value_set_boolean (value, priv->language_set);
1667 g_value_set_boolean (value, priv->tabs_set);
1670 case PROP_INVISIBLE_SET:
1671 g_value_set_boolean (value, priv->invisible_set);
1674 case PROP_PARAGRAPH_BACKGROUND_SET:
1675 g_value_set_boolean (value, priv->pg_bg_color_set);
1678 case PROP_BACKGROUND:
1679 case PROP_FOREGROUND:
1680 case PROP_PARAGRAPH_BACKGROUND:
1681 g_warning ("'foreground', 'background' and 'paragraph_background' properties are not readable, use 'foreground_gdk', 'background_gdk' and 'paragraph_background_gdk'");
1683 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1699 delta_priority_foreach (GtkTextTag *tag, gpointer user_data)
1701 GtkTextTagPrivate *priv = tag->priv;
1702 DeltaData *dd = user_data;
1704 if (priv->priority >= dd->low && priv->priority <= dd->high)
1705 priv->priority += dd->delta;
1709 * gtk_text_tag_get_priority:
1710 * @tag: a #GtkTextTag
1712 * Get the tag priority.
1714 * Return value: The tag's priority.
1717 gtk_text_tag_get_priority (GtkTextTag *tag)
1719 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), 0);
1721 return tag->priv->priority;
1725 * gtk_text_tag_set_priority:
1726 * @tag: a #GtkTextTag
1727 * @priority: the new priority
1729 * Sets the priority of a #GtkTextTag. Valid priorities are
1730 * start at 0 and go to one less than gtk_text_tag_table_get_size().
1731 * Each tag in a table has a unique priority; setting the priority
1732 * of one tag shifts the priorities of all the other tags in the
1733 * table to maintain a unique priority for each tag. Higher priority
1734 * tags "win" if two tags both set the same text attribute. When adding
1735 * a tag to a tag table, it will be assigned the highest priority in
1736 * the table by default; so normally the precedence of a set of tags
1737 * is the order in which they were added to the table, or created with
1738 * gtk_text_buffer_create_tag(), which adds the tag to the buffer's table
1742 gtk_text_tag_set_priority (GtkTextTag *tag,
1745 GtkTextTagPrivate *priv;
1748 g_return_if_fail (GTK_IS_TEXT_TAG (tag));
1752 g_return_if_fail (priv->table != NULL);
1753 g_return_if_fail (priority >= 0);
1754 g_return_if_fail (priority < gtk_text_tag_table_get_size (priv->table));
1756 if (priority == priv->priority)
1759 if (priority < priv->priority)
1762 dd.high = priv->priority - 1;
1767 dd.low = priv->priority + 1;
1772 gtk_text_tag_table_foreach (priv->table,
1773 delta_priority_foreach,
1776 priv->priority = priority;
1780 * gtk_text_tag_event:
1781 * @tag: a #GtkTextTag
1782 * @event_object: object that received the event, such as a widget
1784 * @iter: location where the event was received
1786 * Emits the "event" signal on the #GtkTextTag.
1788 * Return value: result of signal emission (whether the event was handled)
1791 gtk_text_tag_event (GtkTextTag *tag,
1792 GObject *event_object,
1794 const GtkTextIter *iter)
1796 gboolean retval = FALSE;
1798 g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
1799 g_return_val_if_fail (G_IS_OBJECT (event_object), FALSE);
1800 g_return_val_if_fail (event != NULL, FALSE);
1814 tag_sort_func (gconstpointer first, gconstpointer second)
1816 GtkTextTag *tag1, *tag2;
1818 tag1 = * (GtkTextTag **) first;
1819 tag2 = * (GtkTextTag **) second;
1820 return tag1->priv->priority - tag2->priv->priority;
1824 _gtk_text_tag_array_sort (GtkTextTag** tag_array_p,
1829 GtkTextTag **maxPtrPtr, *tmp;
1831 g_return_if_fail (tag_array_p != NULL);
1832 g_return_if_fail (len > 0);
1838 GtkTextTag **iter = tag_array_p;
1840 for (i = len-1; i > 0; i--, iter++) {
1841 maxPtrPtr = tag = iter;
1842 prio = tag[0]->priv->priority;
1843 for (j = i, tag++; j > 0; j--, tag++) {
1844 if (tag[0]->priv->priority < prio) {
1845 prio = tag[0]->priv->priority;
1854 qsort ((void *) tag_array_p, (unsigned) len, sizeof (GtkTextTag *),
1860 printf ("Sorted tag array: \n");
1864 GtkTextTag *t = tag_array_p[i];
1865 printf (" %s priority %d\n", t->name, t->priority);