diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-10-27 13:39:01 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-11-01 13:58:10 -0400 |
commit | 745c348ff8f07815abaf8b437fb5c914f5c60c85 (patch) | |
tree | ee664a1884146e663c4c24fd21e9f66122ca0dd7 | |
parent | 72a9c532620e42f2381b62c592327af5082e6790 (diff) | |
download | gtk+-745c348ff8f07815abaf8b437fb5c914f5c60c85.tar.gz |
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.
-rw-r--r-- | gtk/Makefile.am | 10 | ||||
-rw-r--r-- | gtk/a11y/gtktextviewaccessible.c | 1 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 69 | ||||
-rw-r--r-- | gtk/gtktextview.c | 15 | ||||
-rw-r--r-- | gtk/gtktextview.h | 4 | ||||
-rw-r--r-- | gtk/gtktextviewprivate.h | 4 |
6 files changed, 34 insertions, 69 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8e17336e25..8078bcb68a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -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) diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c index 7adcc62d22..9ff6e141b4 100644 --- a/gtk/a11y/gtktextviewaccessible.c +++ b/gtk/a11y/gtktextviewaccessible.c @@ -30,6 +30,7 @@ #include <gtk/gtk.h> #include "gtktextviewaccessibleprivate.h" #include "gtktextbufferprivate.h" +#include "gtktextviewprivate.h" #include "gtk/gtkwidgetprivate.h" struct _GtkTextViewAccessiblePrivate diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index 3e13d801ec..e02bf8985f 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -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. You’d 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 */ diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index f0d8cb3bc0..75b50b95cb 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -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. - * You’d 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) { diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h index cf57944873..7d1f9be5b0 100644 --- a/gtk/gtktextview.h +++ b/gtk/gtktextview.h @@ -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); diff --git a/gtk/gtktextviewprivate.h b/gtk/gtktextviewprivate.h index 9eddfd81c0..1f23cc45c9 100644 --- a/gtk/gtktextviewprivate.h +++ b/gtk/gtktextviewprivate.h @@ -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__ */ |