Make GtkTextAttributes private

This is a problematic struct, and giving direct access to it
has kept us from making improvements to GtkTextView. Drop it
from the public API, together with the auxiliary APIs. If
it turns out that this functionality is needed, we should add
individual getters.
This commit is contained in:
Matthias Clasen 2016-10-27 13:39:01 -04:00
parent 72a9c53262
commit 745c348ff8
6 changed files with 34 additions and 69 deletions

View File

@ -302,7 +302,6 @@ gtk_public_h_sources = \
gtkstyleprovider.h \
gtkswitch.h \
gtktestutils.h \
gtktextattributes.h \
gtktextbuffer.h \
gtktextbufferrichtext.h \
gtktextchild.h \
@ -348,11 +347,6 @@ gtk_unix_print_public_h_sources = \
gtkunixprint.h
endif
# Installed header files without compatibility guarantees
# that are not included in gtk/gtk.h
gtk_semi_private_h_sources = \
gtktextlayout.h
gtk_private_type_h_sources = \
gtkcsstypesprivate.h \
gtktexthandleprivate.h
@ -553,12 +547,14 @@ gtk_private_h_sources = \
gtkstylepropertyprivate.h \
gtkstyleproviderprivate.h \
gtktextattributesprivate.h \
gtktextattributes.h \
gtktextbtree.h \
gtktextbufferprivate.h \
gtktextbufferserialize.h \
gtktextchildprivate.h \
gtktexthandleprivate.h \
gtktextiterprivate.h \
gtktextlayout.h \
gtktextmarkprivate.h \
gtktextsegment.h \
gtktexttagprivate.h \
@ -1364,7 +1360,7 @@ gtktestutils.c: gtktypefuncs.c
lib_LTLIBRARIES = libgtk-4.la
gtkincludedir = $(includedir)/gtk-4.0/gtk
gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_semi_private_h_sources) $(gtk_built_public_sources) gtkversion.h
gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_built_public_sources) gtkversion.h
a11yincludedir = $(includedir)/gtk-4.0/gtk/a11y
a11yinclude_HEADERS= $(a11y_h_sources)

View File

@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include "gtktextviewaccessibleprivate.h"
#include "gtktextbufferprivate.h"
#include "gtktextviewprivate.h"
#include "gtk/gtkwidgetprivate.h"
struct _GtkTextViewAccessiblePrivate

View File

@ -1458,6 +1458,32 @@ gtk_text_iter_can_insert (const GtkTextIter *iter,
}
}
gboolean
gtk_text_iter_get_attributes (const GtkTextIter *iter,
GtkTextAttributes *values)
{
GtkTextTag** tags;
gint tag_count = 0;
/* Get the tags at this spot */
tags = _gtk_text_btree_get_tags (iter, &tag_count);
/* No tags, use default style */
if (tags == NULL || tag_count == 0)
{
g_free (tags);
return FALSE;
}
_gtk_text_attributes_fill_from_tags (values,
tags,
tag_count);
g_free (tags);
return TRUE;
}
/**
* gtk_text_iter_get_language:
@ -1743,49 +1769,6 @@ gtk_text_iter_get_bytes_in_line (const GtkTextIter *iter)
return count;
}
/**
* gtk_text_iter_get_attributes:
* @iter: an iterator
* @values: (out): a #GtkTextAttributes to be filled in
*
* Computes the effect of any tags applied to this spot in the
* text. The @values parameter should be initialized to the default
* settings you wish to use if no tags are in effect. Youd typically
* obtain the defaults from gtk_text_view_get_default_attributes().
*
* gtk_text_iter_get_attributes() will modify @values, applying the
* effects of any tags present at @iter. If any tags affected @values,
* the function returns %TRUE.
*
* Returns: %TRUE if @values was modified
**/
gboolean
gtk_text_iter_get_attributes (const GtkTextIter *iter,
GtkTextAttributes *values)
{
GtkTextTag** tags;
gint tag_count = 0;
/* Get the tags at this spot */
tags = _gtk_text_btree_get_tags (iter, &tag_count);
/* No tags, use default style */
if (tags == NULL || tag_count == 0)
{
g_free (tags);
return FALSE;
}
_gtk_text_attributes_fill_from_tags (values,
tags,
tag_count);
g_free (tags);
return TRUE;
}
/*
* Increments/decrements
*/

View File

@ -7928,21 +7928,6 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
}
}
/**
* gtk_text_view_get_default_attributes:
* @text_view: a #GtkTextView
*
* Obtains a copy of the default text attributes. These are the
* attributes used for text unless a tag overrides them.
* Youd typically pass the default attributes in to
* gtk_text_iter_get_attributes() in order to get the
* attributes in effect at a given text position.
*
* The return value is a copy owned by the caller of this function,
* and should be freed with gtk_text_attributes_unref().
*
* Returns: a new #GtkTextAttributes
**/
GtkTextAttributes*
gtk_text_view_get_default_attributes (GtkTextView *text_view)
{

View File

@ -431,10 +431,6 @@ void gtk_text_view_set_tabs (GtkTextView *text_vi
GDK_AVAILABLE_IN_ALL
PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
/* note that the return value of this changes with the theme */
GDK_AVAILABLE_IN_ALL
GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView *text_view);
GDK_AVAILABLE_IN_3_6
void gtk_text_view_set_input_purpose (GtkTextView *text_view,
GtkInputPurpose purpose);

View File

@ -20,6 +20,7 @@
#define __GTK_TEXT_VIEW_PRIVATE_H__
#include "gtktextview.h"
#include "gtktextattributes.h"
#include "gtkcssnodeprivate.h"
G_BEGIN_DECLS
@ -27,6 +28,9 @@ G_BEGIN_DECLS
GtkCssNode * gtk_text_view_get_text_node (GtkTextView *text_view);
GtkCssNode * gtk_text_view_get_selection_node (GtkTextView *text_view);
GtkTextAttributes * gtk_text_view_get_default_attributes (GtkTextView *text_view);
G_END_DECLS
#endif /* __GTK_TEXT_VIEW_PRIVATE_H__ */