Top | ![]() |
![]() |
![]() |
![]() |
GQuark | rtf_error_quark () |
GdkAtom | rtf_register_serialize_format () |
GdkAtom | rtf_register_deserialize_format () |
gboolean | rtf_text_buffer_import_file () |
gboolean | rtf_text_buffer_import () |
gboolean | rtf_text_buffer_import_from_string () |
gboolean | rtf_text_buffer_export_file () |
gboolean | rtf_text_buffer_export () |
gchar * | rtf_text_buffer_export_to_string () |
Rich Text Format is a file format for storing marked-up text. It has been around for more than twenty years at the time of writing, but is still used as a native format by various programs and controls on Mac OS X, Windows, and NeXTSTEP.
For more information, see the Wikipedia page on RTF.
GdkAtom
rtf_register_serialize_format (GtkTextBuffer *buffer
);
Registers the RTF text serialization format with buffer
. This allows the
contents of buffer
to be exported to Rich Text Format (MIME type text/rtf).
GdkAtom
rtf_register_deserialize_format (GtkTextBuffer *buffer
);
Registers the RTF text deserialization format with buffer
. This allows
Rich Text Format files to be imported into buffer
. See
rtf_register_serialize_format()
.
gboolean rtf_text_buffer_import_file (GtkTextBuffer *buffer
,GFile *file
,GCancellable *cancellable
,GError **error
);
Deserializes the contents of file
to buffer
. Only a small subset of RTF
features are supported: those corresponding to features of GtkTextBuffer or those that can be emulated in
a GtkTextBuffer. All unsupported
features are ignored.
This function automatically registers the RTF deserialization format and
deregisters it afterwards, so there is no need to call
rtf_register_deserialize_format()
.
This function also supports OS X and NeXTSTEP's RTFD packages. If filename
ends in “.rtfd”, is a directory, and contains a file called
“TXT.rtf”, then it is assumed to be an RTFD package.
If cancellable
is triggered from another thread, the operation is cancelled.
buffer |
the text buffer into which to import text |
|
file |
a GFile pointing to an RTF text file |
|
cancellable |
optional GCancellable object, or |
[allow-none] |
error |
return location for an error, or |
Since: 1.1
gboolean rtf_text_buffer_import (GtkTextBuffer *buffer
,const gchar *filename
,GError **error
);
Deserializes the contents of filename
to buffer
. For more information, see
rtf_text_buffer_import_file()
.
gboolean rtf_text_buffer_import_from_string (GtkTextBuffer *buffer
,const gchar *string
,GError **error
);
Deserializes the contents of string
to buffer
. See
rtf_text_buffer_import_file()
for details.
If string
contains references to external files, such as images, then
these will be resolved relative to the current working directory.
That's usually not what you want.
If you want to load images, then you must change the current working
directory appropriately before calling this function, or embed the images
in the RTF code, or use rtf_text_buffer_import()
or
rtf_text_buffer_import_file()
.
gboolean rtf_text_buffer_export_file (GtkTextBuffer *buffer
,GFile *file
,GCancellable *cancellable
,GError **error
);
Serializes the contents of buffer
to an RTF text file, file
. Any formatting
and embedded pixbufs in buffer
are preserved, but embedded widgets will not
be. If the buffer was imported from RTF text written by another application,
the result will be quite different; none of the advanced formatting features
that RTF is capable of representing, such as styles, are preserved across
loading and saving.
This function automatically registers the RTF serialization format and
deregisters it afterwards, so there is no need to call
rtf_register_serialize_format()
.
The operation can be cancelled by triggering cancellable
from another
thread.
buffer |
the text buffer to export |
|
file |
a GFile to export to |
|
cancellable |
optional GCancellable object, or |
[allow-none] |
error |
return location for an error, or |
Since: 1.1
gboolean rtf_text_buffer_export (GtkTextBuffer *buffer
,const gchar *filename
,GError **error
);
Serializes the contents of buffer
to an RTF text file, filename
. See
rtf_text_buffer_export_file()
for more information.
gchar *
rtf_text_buffer_export_to_string (GtkTextBuffer *buffer
);
Serializes the contents of buffer
to a string in RTF format. See
rtf_text_buffer_export()
for details.
The different codes which can be thrown in the RTF_ERROR domain.
A generic error. |
||
The file was not correct RTF. |
||
A numerical parameter was missing from a control word which requires one. |
||
Not all groups were closed before the end of the file. |
||
There was junk after the last '}'. |
||
The RTF file was an incompatible version. |
||
A color was used which was not defined in the color table. |
||
A font was used which was not defined in the font table. |
||
A style was used which was not defined in the stylesheet. |
||
Incorrect characters were encountered when expecting hexadecimal digits (0-9, A-F) |
||
An invalid type of bitmap was specified. |
||
A negative font size was specified. |
||
A character set with no iconv equivalent was specified. |