[gtk+] Get rid of the rest of variables exported from libgtk



commit 87141cf4c8f6d8cb3bfa1745e0dafa582fd0431e
Author: Tor Lillqvist <tml iki fi>
Date:   Wed Sep 8 20:33:30 2010 +0300

    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.

 gtk/gtk.symbols        |   13 +------------
 gtk/gtktextbtree.c     |    4 ++--
 gtk/gtktextchild.c     |    7 ++++---
 gtk/gtktextlayout.c    |    4 ++--
 gtk/gtktextlayout.h    |    2 ++
 gtk/gtktexttypes.c     |    9 ++++++++-
 gtk/gtktexttypes.h     |   14 +++-----------
 gtk/tests/textbuffer.c |    5 +++--
 8 files changed, 25 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index d761f30..5e5b9ab 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index 72abfc5..b07a04e 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -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);
 
         }
     }
diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c
index ad23def..dd7d3a4 100644
--- a/gtk/gtktextchild.c
+++ b/gtk/gtktextchild.c
@@ -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;
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index fba9de5..74b3dd3 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -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;
diff --git a/gtk/gtktextlayout.h b/gtk/gtktextlayout.h
index a2e8aa3..3be12a3 100644
--- a/gtk/gtktextlayout.h
+++ b/gtk/gtktextlayout.h
@@ -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;
 
diff --git a/gtk/gtktexttypes.c b/gtk/gtktexttypes.c
index df8f6f5..740cb79 100644
--- a/gtk/gtktexttypes.c
+++ b/gtk/gtktexttypes.c
@@ -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)
diff --git a/gtk/gtktexttypes.h b/gtk/gtktexttypes.h
index c624aea..b8f8278 100644
--- a/gtk/gtktexttypes.h
+++ b/gtk/gtktexttypes.h
@@ -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);
 
diff --git a/gtk/tests/textbuffer.c b/gtk/tests/textbuffer.c
index d104358..19986f2 100644
--- a/gtk/tests/textbuffer.c
+++ b/gtk/tests/textbuffer.c
@@ -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);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]