Commit 55016f72 authored by Javier Jardón's avatar Javier Jardón Committed by Matthias Clasen

gtktexttag: Move public members to private header

And fix gail to not poke at GtkTextTag internals
parent 6a11c592
......@@ -59,6 +59,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "gtktexttag.h"
#include "gtktexttagprivate.h"
#include "gtktexttagtable.h"
#include "gtktextlayout.h"
#include "gtktextiterprivate.h"
......@@ -1778,7 +1779,7 @@ _gtk_text_btree_tag (const GtkTextIter *start_orig,
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
g_return_if_fail (_gtk_text_iter_get_btree (start_orig) ==
_gtk_text_iter_get_btree (end_orig));
g_return_if_fail (tag->table == _gtk_text_iter_get_btree (start_orig)->table);
g_return_if_fail (tag->priv->table == _gtk_text_iter_get_btree (start_orig)->table);
#if 0
printf ("%s tag %s from %d to %d\n",
......@@ -2505,10 +2506,10 @@ _gtk_text_btree_char_is_invisible (const GtkTextIter *iter)
|| (seg->type == &gtk_text_toggle_off_type))
{
tag = seg->body.toggle.info->tag;
if (tag->invisible_set)
if (tag->priv->invisible_set)
{
tags[tag->priority] = tag;
tagCnts[tag->priority]++;
tags[tag->priv->priority] = tag;
tagCnts[tag->priv->priority]++;
}
}
}
......@@ -2529,10 +2530,10 @@ _gtk_text_btree_char_is_invisible (const GtkTextIter *iter)
|| (seg->type == &gtk_text_toggle_off_type))
{
tag = seg->body.toggle.info->tag;
if (tag->invisible_set)
if (tag->priv->invisible_set)
{
tags[tag->priority] = tag;
tagCnts[tag->priority]++;
tags[tag->priv->priority] = tag;
tagCnts[tag->priv->priority]++;
}
}
}
......@@ -2558,10 +2559,10 @@ _gtk_text_btree_char_is_invisible (const GtkTextIter *iter)
if (summary->toggle_count & 1)
{
tag = summary->info->tag;
if (tag->invisible_set)
if (tag->priv->invisible_set)
{
tags[tag->priority] = tag;
tagCnts[tag->priority] += summary->toggle_count;
tags[tag->priv->priority] = tag;
tagCnts[tag->priv->priority] += summary->toggle_count;
}
}
}
......@@ -2588,7 +2589,7 @@ _gtk_text_btree_char_is_invisible (const GtkTextIter *iter)
}
#endif
#endif
invisible = tags[i]->values->invisible;
invisible = tags[i]->priv->values->invisible;
break;
}
}
......@@ -6798,7 +6799,7 @@ gtk_text_btree_node_check_consistency (GtkTextBTree *tree,
break;
}
g_error ("gtk_text_btree_node_check_consistency: GtkTextBTreeNode tag \"%s\" not %s",
summary->info->tag->name,
summary->info->tag->priv->name,
"present in parent summaries");
}
if (summary->info == summary2->info)
......@@ -6834,7 +6835,7 @@ gtk_text_btree_node_check_consistency (GtkTextBTree *tree,
if (summary->info->toggle_count == summary->toggle_count)
{
g_error ("gtk_text_btree_node_check_consistency: found unpruned root for \"%s\"",
summary->info->tag->name);
summary->info->tag->priv->name);
}
toggle_count = 0;
if (node->level == 0)
......@@ -6888,7 +6889,7 @@ gtk_text_btree_node_check_consistency (GtkTextBTree *tree,
if (summary2->info == summary->info)
{
g_error ("gtk_text_btree_node_check_consistency: duplicated GtkTextBTreeNode tag: %s",
summary->info->tag->name);
summary->info->tag->priv->name);
}
}
}
......@@ -6940,19 +6941,19 @@ _gtk_text_btree_check (GtkTextBTree *tree)
if (info->toggle_count != 0)
{
g_error ("_gtk_text_btree_check found \"%s\" with toggles (%d) but no root",
tag->name, info->toggle_count);
tag->priv->name, info->toggle_count);
}
continue; /* no ranges for the tag */
}
else if (info->toggle_count == 0)
{
g_error ("_gtk_text_btree_check found root for \"%s\" with no toggles",
tag->name);
tag->priv->name);
}
else if (info->toggle_count & 1)
{
g_error ("_gtk_text_btree_check found odd toggle count for \"%s\" (%d)",
tag->name, info->toggle_count);
tag->priv->name, info->toggle_count);
}
for (summary = node->summary; summary != NULL;
summary = summary->next)
......@@ -7007,7 +7008,7 @@ _gtk_text_btree_check (GtkTextBTree *tree)
if (count != info->toggle_count)
{
g_error ("_gtk_text_btree_check toggle_count (%d) wrong for \"%s\" should be (%d)",
info->toggle_count, tag->name, count);
info->toggle_count, tag->priv->name, count);
}
}
}
......@@ -7116,7 +7117,7 @@ _gtk_text_btree_spew (GtkTextBTree *tree)
info = list->data;
printf (" tag `%s': root at %p, toggle count %d\n",
info->tag->name, info->tag_root, info->toggle_count);
info->tag->priv->name, info->tag_root, info->toggle_count);
list = g_slist_next (list);
}
......@@ -7182,7 +7183,7 @@ _gtk_text_btree_spew_line_short (GtkTextLine *line, int indent)
seg->type == &gtk_text_toggle_off_type)
{
printf ("%s tag `%s' %s\n",
spaces, seg->body.toggle.info->tag->name,
spaces, seg->body.toggle.info->tag->priv->name,
seg->type == &gtk_text_toggle_off_type ? "off" : "on");
}
......@@ -7209,7 +7210,7 @@ _gtk_text_btree_spew_node (GtkTextBTreeNode *node, int indent)
while (s)
{
printf ("%s %d toggles of `%s' below this node\n",
spaces, s->toggle_count, s->info->tag->name);
spaces, s->toggle_count, s->info->tag->priv->name);
s = s->next;
}
......@@ -7284,7 +7285,7 @@ _gtk_text_btree_spew_segment (GtkTextBTree* tree, GtkTextLineSegment * seg)
seg->type == &gtk_text_toggle_off_type)
{
printf (" tag `%s' priority %d\n",
seg->body.toggle.info->tag->name,
seg->body.toggle.info->tag->priority);
seg->body.toggle.info->tag->priv->name,
seg->body.toggle.info->tag->priv->priority);
}
}
......@@ -38,6 +38,7 @@
#include "gtktextbufferrichtext.h"
#include "gtktextbtree.h"
#include "gtktextiterprivate.h"
#include "gtktexttagprivate.h"
#include "gtkprivate.h"
#include "gtkintl.h"
......@@ -2504,7 +2505,7 @@ gtk_text_buffer_real_apply_tag (GtkTextBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end)
{
if (tag->table != buffer->priv->tag_table)
if (tag->priv->table != buffer->priv->tag_table)
{
g_warning ("Can only apply tags that are in the tag table for the buffer");
return;
......@@ -2519,7 +2520,7 @@ gtk_text_buffer_real_remove_tag (GtkTextBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end)
{
if (tag->table != buffer->priv->tag_table)
if (tag->priv->table != buffer->priv->tag_table)
{
g_warning ("Can only remove tags that are in the tag table for the buffer");
return;
......@@ -2611,7 +2612,7 @@ gtk_text_buffer_apply_tag (GtkTextBuffer *buffer,
g_return_if_fail (end != NULL);
g_return_if_fail (gtk_text_iter_get_buffer (start) == buffer);
g_return_if_fail (gtk_text_iter_get_buffer (end) == buffer);
g_return_if_fail (tag->table == buffer->priv->tag_table);
g_return_if_fail (tag->priv->table == buffer->priv->tag_table);
gtk_text_buffer_emit_tag (buffer, tag, TRUE, start, end);
}
......@@ -2640,7 +2641,7 @@ gtk_text_buffer_remove_tag (GtkTextBuffer *buffer,
g_return_if_fail (end != NULL);
g_return_if_fail (gtk_text_iter_get_buffer (start) == buffer);
g_return_if_fail (gtk_text_iter_get_buffer (end) == buffer);
g_return_if_fail (tag->table == buffer->priv->tag_table);
g_return_if_fail (tag->priv->table == buffer->priv->tag_table);
gtk_text_buffer_emit_tag (buffer, tag, FALSE, start, end);
}
......
......@@ -32,6 +32,7 @@
#include "gdk-pixbuf/gdk-pixdata.h"
#include "gtktextbufferserialize.h"
#include "gtktexttagprivate.h"
#include "gtkintl.h"
......@@ -292,9 +293,9 @@ serialize_tag (gpointer key,
g_string_append (context->tag_table_str, " <tag ");
/* Handle anonymous tags */
if (tag->name)
if (tag->priv->name)
{
tag_name = g_markup_escape_text (tag->name, -1);
tag_name = g_markup_escape_text (tag->priv->name, -1);
g_string_append_printf (context->tag_table_str, "name=\"%s\"", tag_name);
g_free (tag_name);
}
......@@ -305,7 +306,7 @@ serialize_tag (gpointer key,
g_string_append_printf (context->tag_table_str, "id=\"%d\"", tag_id);
}
g_string_append_printf (context->tag_table_str, " priority=\"%d\">\n", tag->priority);
g_string_append_printf (context->tag_table_str, " priority=\"%d\">\n", tag->priv->priority);
/* Serialize properties */
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (tag), &n_pspecs);
......@@ -489,9 +490,9 @@ serialize_text (GtkTextBuffer *buffer,
/* Add it to the tag hash table */
g_hash_table_insert (context->tags, tag, tag);
if (tag->name)
if (tag->priv->name)
{
tag_name = g_markup_escape_text (tag->name, -1);
tag_name = g_markup_escape_text (tag->priv->name, -1);
g_string_append_printf (context->text_str, "<apply_tag name=\"%s\">", tag_name);
g_free (tag_name);
......@@ -1481,10 +1482,10 @@ end_element_handler (GMarkupParseContext *context,
pop_state (info);
g_assert (peek_state (info) == STATE_TAGS);
if (info->current_tag->name)
if (info->current_tag->priv->name)
{
/* Add tag to defined tags hash */
tmp = g_strdup (info->current_tag->name);
tmp = g_strdup (info->current_tag->priv->name);
g_hash_table_insert (info->defined_tags,
tmp, tmp);
}
......
......@@ -1283,8 +1283,8 @@ totally_invisible_line (GtkTextLayout *layout,
invalidate_cached_style (layout);
/* Bail out if an elision-unsetting tag begins */
if (seg->body.toggle.info->tag->invisible_set &&
!seg->body.toggle.info->tag->values->invisible)
if (seg->body.toggle.info->tag->priv->invisible_set &&
!seg->body.toggle.info->tag->priv->values->invisible)
break;
}
else if (seg->type == &gtk_text_toggle_off_type)
......@@ -1292,8 +1292,8 @@ totally_invisible_line (GtkTextLayout *layout,
invalidate_cached_style (layout);
/* Bail out if an elision-setting tag ends */
if (seg->body.toggle.info->tag->invisible_set &&
seg->body.toggle.info->tag->values->invisible)
if (seg->body.toggle.info->tag->priv->invisible_set &&
seg->body.toggle.info->tag->priv->values->invisible)
break;
}
......@@ -2103,7 +2103,7 @@ tags_array_toggle_tag (GPtrArray *array,
tags = (GtkTextTag**) array->pdata;
for (pos = 0; pos < array->len && tags[pos]->priority < tag->priority; pos++) ;
for (pos = 0; pos < array->len && tags[pos]->priv->priority < tag->priv->priority; pos++) ;
if (pos < array->len && tags[pos] == tag)
g_ptr_array_remove_index (array, pos);
......
This diff is collapsed.
......@@ -75,61 +75,15 @@ typedef struct _GtkTextAttributes GtkTextAttributes;
#define GTK_TYPE_TEXT_ATTRIBUTES (gtk_text_attributes_get_type ())
typedef struct _GtkTextTag GtkTextTag;
typedef struct _GtkTextTagClass GtkTextTagClass;
typedef struct _GtkTextTag GtkTextTag;
typedef struct _GtkTextTagPrivate GtkTextTagPrivate;
typedef struct _GtkTextTagClass GtkTextTagClass;
struct _GtkTextTag
{
GObject parent_instance;
GtkTextTagTable *GSEAL (table);
char *GSEAL (name); /* Name of this tag. This field is actually
* a pointer to the key from the entry in
* tkxt->tagTable, so it needn't be freed
* explicitly. */
int GSEAL (priority); /* Priority of this tag within widget. 0
* means lowest priority. Exactly one tag
* has each integer value between 0 and
* numTags-1. */
/*
* Information for displaying text with this tag. The information
* belows acts as an override on information specified by lower-priority
* tags. If no value is specified, then the next-lower-priority tag
* on the text determins the value. The text widget itself provides
* defaults if no tag specifies an override.
*/
GtkTextAttributes *GSEAL (values);
/* Flags for whether a given value is set; if a value is unset, then
* this tag does not affect it.
*/
guint GSEAL (bg_color_set) : 1;
guint GSEAL (fg_color_set) : 1;
guint GSEAL (scale_set) : 1;
guint GSEAL (justification_set) : 1;
guint GSEAL (left_margin_set) : 1;
guint GSEAL (indent_set) : 1;
guint GSEAL (rise_set) : 1;
guint GSEAL (strikethrough_set) : 1;
guint GSEAL (right_margin_set) : 1;
guint GSEAL (pixels_above_lines_set) : 1;
guint GSEAL (pixels_below_lines_set) : 1;
guint GSEAL (pixels_inside_wrap_set) : 1;
guint GSEAL (tabs_set) : 1;
guint GSEAL (underline_set) : 1;
guint GSEAL (wrap_mode_set) : 1;
guint GSEAL (bg_full_height_set) : 1;
guint GSEAL (invisible_set) : 1;
guint GSEAL (editable_set) : 1;
guint GSEAL (language_set) : 1;
guint GSEAL (pg_bg_color_set) : 1;
/* Whether these margins accumulate or override */
guint GSEAL (accumulative_margin) : 1;
guint GSEAL (pad1) : 1;
GtkTextTagPrivate *priv;
};
struct _GtkTextTagClass
......
......@@ -31,6 +31,60 @@
typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
struct _GtkTextTagPrivate
{
GtkTextTagTable *table;
char *name; /* Name of this tag. This field is actually
* a pointer to the key from the entry in
* tkxt->tagTable, so it needn't be freed
* explicitly. */
int priority; /* Priority of this tag within widget. 0
* means lowest priority. Exactly one tag
* has each integer value between 0 and
* numTags-1. */
/*
* Information for displaying text with this tag. The information
* belows acts as an override on information specified by lower-priority
* tags. If no value is specified, then the next-lower-priority tag
* on the text determins the value. The text widget itself provides
* defaults if no tag specifies an override.
*/
GtkTextAttributes *values;
/* Flags for whether a given value is set; if a value is unset, then
* this tag does not affect it.
*/
guint bg_color_set : 1;
guint fg_color_set : 1;
guint scale_set : 1;
guint justification_set : 1;
guint left_margin_set : 1;
guint indent_set : 1;
guint rise_set : 1;
guint strikethrough_set : 1;
guint right_margin_set : 1;
guint pixels_above_lines_set : 1;
guint pixels_below_lines_set : 1;
guint pixels_inside_wrap_set : 1;
guint tabs_set : 1;
guint underline_set : 1;
guint wrap_mode_set : 1;
guint bg_full_height_set : 1;
guint invisible_set : 1;
guint editable_set : 1;
guint language_set : 1;
guint pg_bg_color_set : 1;
/* Whether these margins accumulate or override */
guint accumulative_margin : 1;
guint pad1 : 1;
};
/* values should already have desired defaults; this function will override
* the defaults with settings in the given tags, which should be sorted in
* ascending order of priority
......
......@@ -25,7 +25,10 @@
*/
#include "config.h"
#include "gtktexttagtable.h"
#include "gtktexttagprivate.h"
#include "gtkmarshalers.h"
#include "gtktextbuffer.h" /* just for the lame notify_will_remove_tag hack */
#include "gtkintl.h"
......@@ -176,7 +179,7 @@ gtk_text_tag_table_new (void)
static void
foreach_unref (GtkTextTag *tag, gpointer data)
{
GtkTextTagTable *table = GTK_TEXT_TAG_TABLE (tag->table);
GtkTextTagTable *table = GTK_TEXT_TAG_TABLE (tag->priv->table);
GtkTextTagTablePrivate *priv = table->priv;
GSList *tmp;
......@@ -193,7 +196,7 @@ foreach_unref (GtkTextTag *tag, gpointer data)
tmp = tmp->next;
}
tag->table = NULL;
tag->priv->table = NULL;
g_object_unref (tag);
}
......@@ -263,35 +266,35 @@ gtk_text_tag_table_add (GtkTextTagTable *table,
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
g_return_if_fail (tag->table == NULL);
g_return_if_fail (tag->priv->table == NULL);
priv = table->priv;
if (tag->name && g_hash_table_lookup (priv->hash, tag->name))
if (tag->priv->name && g_hash_table_lookup (priv->hash, tag->priv->name))
{
g_warning ("A tag named '%s' is already in the tag table.",
tag->name);
tag->priv->name);
return;
}
g_object_ref (tag);
if (tag->name)
g_hash_table_insert (priv->hash, tag->name, tag);
if (tag->priv->name)
g_hash_table_insert (priv->hash, tag->priv->name, tag);
else
{
priv->anonymous = g_slist_prepend (priv->anonymous, tag);
priv->anon_count += 1;
}
tag->table = table;
tag->priv->table = table;
/* We get the highest tag priority, as the most-recently-added
tag. Note that we do NOT use gtk_text_tag_set_priority,
as it assumes the tag is already in the table. */
size = gtk_text_tag_table_get_size (table);
g_assert (size > 0);
tag->priority = size - 1;
tag->priv->priority = size - 1;
g_signal_emit (table, signals[TAG_ADDED], 0, tag);
}
......@@ -337,7 +340,7 @@ gtk_text_tag_table_remove (GtkTextTagTable *table,
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
g_return_if_fail (tag->table == table);
g_return_if_fail (tag->priv->table == table);
priv = table->priv;
......@@ -358,10 +361,10 @@ gtk_text_tag_table_remove (GtkTextTagTable *table,
priorities of the tags in the table. */
gtk_text_tag_set_priority (tag, gtk_text_tag_table_get_size (table) - 1);
tag->table = NULL;
tag->priv->table = NULL;
if (tag->name)
g_hash_table_remove (priv->hash, tag->name);
if (tag->priv->name)
g_hash_table_remove (priv->hash, tag->priv->name);
else
{
priv->anonymous = g_slist_remove (priv->anonymous, tag);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment