Get rid of the rest of variables exported from libgtk

Especially the gtk_*_type ones in gtktexttypes.h were mentioned in
gtk.symbols presumably by accident. That header isn't even installed,
so no way can they be supposed to be public.

gtk_text_attr_appearance_type is from the installed but "semi-private"
gtktextlayout.h, so drop that one too from gtk.symbols for now.

The use of gtk_text_unknown_char_utf8 is bit of a mess. Code in a few
files knew implicitly that it is three bytes. Define a symbolic name
for the length of it instead. Add an exported function
gtk_text_unknown_char_utf8_gtk_tests_only() that returns a pointer to
it just for the sake of gtk/tests/textbuffer.c. Prefix the variable
with an underscore.

I doubt the usefulness of the test_utf8() in textbuffer.c. If it could
be dropped, gtk_text_unknown_char_utf8_gtk_tests_only() could be
dropped, too.
This commit is contained in:
Tor Lillqvist 2010-09-08 20:33:30 +03:00
parent 801875b805
commit 87141cf4c8
8 changed files with 25 additions and 33 deletions

View File

@ -3274,6 +3274,7 @@ gtk_text_buffer_set_text
#if IN_HEADER(__GTK_TEXT_TYPES_H__)
#if IN_FILE(__GTK_TEXT_TYPES_C__)
gtk_text_unknown_char_utf8_gtk_tests_only
gtk_text_byte_begins_utf8_char
#endif
#endif
@ -4540,15 +4541,3 @@ gtk_info_bar_set_message_type
gtk_info_bar_get_message_type
#endif
#endif
#ifdef INCLUDE_VARIABLES
gtk_text_attr_appearance_type
gtk_text_char_type
gtk_text_child_type
gtk_text_left_mark_type
gtk_text_pixbuf_type
gtk_text_right_mark_type
gtk_text_toggle_off_type
gtk_text_toggle_on_type
gtk_text_unknown_char_utf8
#endif

View File

@ -2389,8 +2389,8 @@ copy_segment (GString *string,
if (copy)
{
g_string_append_len (string,
gtk_text_unknown_char_utf8,
3);
_gtk_text_unknown_char_utf8,
GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN);
}
}

View File

@ -134,9 +134,10 @@ _gtk_pixbuf_segment_new (GdkPixbuf *pixbuf)
seg->next = NULL;
seg->byte_count = 3; /* We convert to the 0xFFFC "unknown character",
* a 3-byte sequence in UTF-8
*/
/* We convert to the 0xFFFC "unknown character",
* a 3-byte sequence in UTF-8.
*/
seg->byte_count = GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN;
seg->char_count = 1;
seg->body.pixbuf.pixbuf = pixbuf;

View File

@ -2310,7 +2310,7 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
size_only, FALSE);
add_pixbuf_attrs (layout, display, style,
seg, attrs, layout_byte_offset);
memcpy (text + layout_byte_offset, gtk_text_unknown_char_utf8,
memcpy (text + layout_byte_offset, _gtk_text_unknown_char_utf8,
seg->byte_count);
layout_byte_offset += seg->byte_count;
buffer_byte_offset += seg->byte_count;
@ -2325,7 +2325,7 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
size_only, FALSE);
add_child_attrs (layout, display, style,
seg, attrs, layout_byte_offset);
memcpy (text + layout_byte_offset, gtk_text_unknown_char_utf8,
memcpy (text + layout_byte_offset, _gtk_text_unknown_char_utf8,
seg->byte_count);
layout_byte_offset += seg->byte_count;
buffer_byte_offset += seg->byte_count;

View File

@ -265,7 +265,9 @@ struct _GtkTextLineDisplay
guint cursor_at_line_end : 1;
};
#ifdef GTK_COMPILATION
extern PangoAttrType gtk_text_attr_appearance_type;
#endif
GType gtk_text_layout_get_type (void) G_GNUC_CONST;

View File

@ -30,7 +30,14 @@
/* These are used to represent embedded non-character objects
* if you return a string representation of a text buffer
*/
const gchar gtk_text_unknown_char_utf8[] = { '\xEF', '\xBF', '\xBC', '\0' };
const gchar _gtk_text_unknown_char_utf8[] = { '\xEF', '\xBF', '\xBC', '\0' };
/* This is to be used only by libgtk test programs */
const gchar *
gtk_text_unknown_char_utf8_gtk_tests_only (void)
{
return _gtk_text_unknown_char_utf8;
}
static inline gboolean
inline_byte_begins_utf8_char (const gchar *byte)

View File

@ -42,16 +42,6 @@ typedef struct _GtkTextMarkBody GtkTextMarkBody;
* Declarations for variables shared among the text-related files:
*/
#ifdef G_OS_WIN32
#ifdef GTK_COMPILATION
#define VARIABLE __declspec(dllexport)
#else
#define VARIABLE extern __declspec(dllimport)
#endif
#else
#define VARIABLE extern
#endif
/* In gtktextbtree.c */
extern const GtkTextLineSegmentClass gtk_text_char_type;
extern const GtkTextLineSegmentClass gtk_text_toggle_on_type;
@ -70,7 +60,9 @@ extern const GtkTextLineSegmentClass gtk_text_child_type;
*/
#define GTK_TEXT_UNKNOWN_CHAR 0xFFFC
VARIABLE const gchar gtk_text_unknown_char_utf8[];
#define GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN 3
const gchar *gtk_text_unknown_char_utf8_gtk_tests_only (void);
const gchar _gtk_text_unknown_char_utf8[GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN+1];
gboolean gtk_text_byte_begins_utf8_char (const gchar *byte);

View File

@ -1211,8 +1211,9 @@ test_utf8 (void)
gunichar ch;
/* Check UTF8 unknown char thing */
g_assert (g_utf8_strlen (gtk_text_unknown_char_utf8, 3) == 1);
ch = g_utf8_get_char (gtk_text_unknown_char_utf8);
g_assert (GTK_TEXT_UNKNOWN_CHAR_UTF8_LEN == 3);
g_assert (g_utf8_strlen (gtk_text_unknown_char_utf8_gtk_tests_only (), 3) == 1);
ch = g_utf8_get_char (gtk_text_unknown_char_utf8_gtk_tests_only ());
g_assert (ch == GTK_TEXT_UNKNOWN_CHAR);
}