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
29G_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: (nullable): a newly-allocated array of guint8 which contains
44 * the serialized data, or %NULL if an error occurred
45 */
46typedef 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: (array length=length): 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 */
69typedef 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
78GDK_AVAILABLE_IN_ALL
79GdkAtom gtk_text_buffer_register_serialize_format (GtkTextBuffer *buffer,
80 const gchar *mime_type,
81 GtkTextBufferSerializeFunc function,
82 gpointer user_data,
83 GDestroyNotify user_data_destroy);
84GDK_AVAILABLE_IN_ALL
85GdkAtom gtk_text_buffer_register_serialize_tagset (GtkTextBuffer *buffer,
86 const gchar *tagset_name);
87
88GDK_AVAILABLE_IN_ALL
89GdkAtom gtk_text_buffer_register_deserialize_format (GtkTextBuffer *buffer,
90 const gchar *mime_type,
91 GtkTextBufferDeserializeFunc function,
92 gpointer user_data,
93 GDestroyNotify user_data_destroy);
94GDK_AVAILABLE_IN_ALL
95GdkAtom gtk_text_buffer_register_deserialize_tagset (GtkTextBuffer *buffer,
96 const gchar *tagset_name);
97
98GDK_AVAILABLE_IN_ALL
99void gtk_text_buffer_unregister_serialize_format (GtkTextBuffer *buffer,
100 GdkAtom format);
101GDK_AVAILABLE_IN_ALL
102void gtk_text_buffer_unregister_deserialize_format (GtkTextBuffer *buffer,
103 GdkAtom format);
104
105GDK_AVAILABLE_IN_ALL
106void gtk_text_buffer_deserialize_set_can_create_tags (GtkTextBuffer *buffer,
107 GdkAtom format,
108 gboolean can_create_tags);
109GDK_AVAILABLE_IN_ALL
110gboolean gtk_text_buffer_deserialize_get_can_create_tags (GtkTextBuffer *buffer,
111 GdkAtom format);
112
113GDK_AVAILABLE_IN_ALL
114GdkAtom * gtk_text_buffer_get_serialize_formats (GtkTextBuffer *buffer,
115 gint *n_formats);
116GDK_AVAILABLE_IN_ALL
117GdkAtom * gtk_text_buffer_get_deserialize_formats (GtkTextBuffer *buffer,
118 gint *n_formats);
119
120GDK_AVAILABLE_IN_ALL
121guint8 * gtk_text_buffer_serialize (GtkTextBuffer *register_buffer,
122 GtkTextBuffer *content_buffer,
123 GdkAtom format,
124 const GtkTextIter *start,
125 const GtkTextIter *end,
126 gsize *length);
127GDK_AVAILABLE_IN_ALL
128gboolean gtk_text_buffer_deserialize (GtkTextBuffer *register_buffer,
129 GtkTextBuffer *content_buffer,
130 GdkAtom format,
131 GtkTextIter *iter,
132 const guint8 *data,
133 gsize length,
134 GError **error);
135
136G_END_DECLS
137
138#endif /* __GTK_TEXT_BUFFER_RICH_TEXT_H__ */
139

source code of include/gtk-3.0/gtk/gtktextbufferrichtext.h