]> Pileus Git - ~andy/gtk/blob - gtk/gtktextbufferrichtext.h
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtktextbufferrichtext.h
1 /* gtkrichtext.h
2  *
3  * Copyright (C) 2006 Imendio AB
4  * Contact: Michael Natterer <mitch@imendio.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __GTK_TEXT_BUFFER_RICH_TEXT_H__
21 #define __GTK_TEXT_BUFFER_RICH_TEXT_H__
22
23 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24 #error "Only <gtk/gtk.h> can be included directly."
25 #endif
26
27 #include <gtk/gtktextbuffer.h>
28
29 G_BEGIN_DECLS
30
31 /**
32  * GtkTextBufferSerializeFunc:
33  * @register_buffer: the #GtkTextBuffer for which the format is registered
34  * @content_buffer: the #GtkTextBuffer to serialize
35  * @start: start of the block of text to serialize
36  * @end: end of the block of text to serialize
37  * @length: Return location for the length of the serialized data
38  * @user_data: user data that was specified when registering the format
39  *
40  * A function that is called to serialize the content of a text buffer.
41  * It must return the serialized form of the content.
42  *
43  * Returns: a newly-allocated array of guint8 which contains the serialized
44  *   data, or %NULL if an error occurred
45  */
46 typedef guint8 * (* GtkTextBufferSerializeFunc)   (GtkTextBuffer     *register_buffer,
47                                                    GtkTextBuffer     *content_buffer,
48                                                    const GtkTextIter *start,
49                                                    const GtkTextIter *end,
50                                                    gsize             *length,
51                                                    gpointer           user_data);
52
53 /**
54  * GtkTextBufferDeserializeFunc:
55  * @register_buffer: the #GtkTextBuffer the format is registered with
56  * @content_buffer: the #GtkTextBuffer to deserialize into
57  * @iter: insertion point for the deserialized text
58  * @data: data to deserialize
59  * @length: length of %data
60  * @create_tags: %TRUE if deserializing may create tags
61  * @user_data: user data that was specified when registering the format
62  * @error: return location for a #GError
63  *
64  * A function that is called to deserialize rich text that has been
65  * serialized with gtk_text_buffer_serialize(), and insert it at @iter.
66  *
67  * Returns: %TRUE on success, %FALSE otherwise
68  */
69 typedef gboolean (* GtkTextBufferDeserializeFunc) (GtkTextBuffer     *register_buffer,
70                                                    GtkTextBuffer     *content_buffer,
71                                                    GtkTextIter       *iter,
72                                                    const guint8      *data,
73                                                    gsize              length,
74                                                    gboolean           create_tags,
75                                                    gpointer           user_data,
76                                                    GError           **error);
77
78 GdkAtom   gtk_text_buffer_register_serialize_format   (GtkTextBuffer                *buffer,
79                                                        const gchar                  *mime_type,
80                                                        GtkTextBufferSerializeFunc    function,
81                                                        gpointer                      user_data,
82                                                        GDestroyNotify                user_data_destroy);
83 GdkAtom   gtk_text_buffer_register_serialize_tagset   (GtkTextBuffer                *buffer,
84                                                        const gchar                  *tagset_name);
85
86 GdkAtom   gtk_text_buffer_register_deserialize_format (GtkTextBuffer                *buffer,
87                                                        const gchar                  *mime_type,
88                                                        GtkTextBufferDeserializeFunc  function,
89                                                        gpointer                      user_data,
90                                                        GDestroyNotify                user_data_destroy);
91 GdkAtom   gtk_text_buffer_register_deserialize_tagset (GtkTextBuffer                *buffer,
92                                                        const gchar                  *tagset_name);
93
94 void    gtk_text_buffer_unregister_serialize_format   (GtkTextBuffer                *buffer,
95                                                        GdkAtom                       format);
96 void    gtk_text_buffer_unregister_deserialize_format (GtkTextBuffer                *buffer,
97                                                        GdkAtom                       format);
98
99 void     gtk_text_buffer_deserialize_set_can_create_tags (GtkTextBuffer             *buffer,
100                                                           GdkAtom                    format,
101                                                           gboolean                   can_create_tags);
102 gboolean gtk_text_buffer_deserialize_get_can_create_tags (GtkTextBuffer             *buffer,
103                                                           GdkAtom                    format);
104
105 GdkAtom * gtk_text_buffer_get_serialize_formats       (GtkTextBuffer                *buffer,
106                                                        gint                         *n_formats);
107 GdkAtom * gtk_text_buffer_get_deserialize_formats     (GtkTextBuffer                *buffer,
108                                                        gint                         *n_formats);
109
110 guint8  * gtk_text_buffer_serialize                   (GtkTextBuffer                *register_buffer,
111                                                        GtkTextBuffer                *content_buffer,
112                                                        GdkAtom                       format,
113                                                        const GtkTextIter            *start,
114                                                        const GtkTextIter            *end,
115                                                        gsize                        *length);
116 gboolean  gtk_text_buffer_deserialize                 (GtkTextBuffer                *register_buffer,
117                                                        GtkTextBuffer                *content_buffer,
118                                                        GdkAtom                       format,
119                                                        GtkTextIter                  *iter,
120                                                        const guint8                 *data,
121                                                        gsize                         length,
122                                                        GError                      **error);
123
124 G_END_DECLS
125
126 #endif /* __GTK_TEXT_BUFFER_RICH_TEXT_H__ */