Пример #1
0
static void
gimp_text_buffer_init (GimpTextBuffer *buffer)
{
  buffer->markup_atom =
    gtk_text_buffer_register_serialize_format (GTK_TEXT_BUFFER (buffer),
                                               "application/x-gimp-pango-markup",
                                               gimp_text_buffer_serialize,
                                               NULL, NULL);

  gtk_text_buffer_register_deserialize_format (GTK_TEXT_BUFFER (buffer),
                                               "application/x-gimp-pango-markup",
                                               gimp_text_buffer_deserialize,
                                               NULL, NULL);
}
Пример #2
0
/**
 * gtk_text_buffer_register_serialize_tagset:
 * @buffer: a #GtkTextBuffer
 * @tagset_name: (allow-none): an optional tagset name, on %NULL
 *
 * This function registers GTK+'s internal rich text serialization
 * format with the passed @buffer. The internal format does not comply
 * to any standard rich text format and only works between #GtkTextBuffer
 * instances. It is capable of serializing all of a text buffer's tags
 * and embedded pixbufs.
 *
 * This function is just a wrapper around
 * gtk_text_buffer_register_serialize_format(). The mime type used
 * for registering is "application/x-gtk-text-buffer-rich-text", or
 * "application/x-gtk-text-buffer-rich-text;format=@tagset_name" if a
 * @tagset_name was passed.
 *
 * The @tagset_name can be used to restrict the transfer of rich text
 * to buffers with compatible sets of tags, in order to avoid unknown
 * tags from being pasted. It is probably the common case to pass an
 * identifier != %NULL here, since the %NULL tagset requires the
 * receiving buffer to deal with with pasting of arbitrary tags.
 *
 * Return value: (transfer none): the #GdkAtom that corresponds to the
 *               newly registered format's mime-type.
 *
 * Since: 2.10
 **/
GdkAtom
gtk_text_buffer_register_serialize_tagset (GtkTextBuffer *buffer,
                                           const gchar   *tagset_name)
{
  gchar   *mime_type = "application/x-gtk-text-buffer-rich-text";
  GdkAtom  format;

  g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), GDK_NONE);
  g_return_val_if_fail (tagset_name == NULL || *tagset_name != '\0', GDK_NONE);

  if (tagset_name)
    mime_type =
      g_strdup_printf ("application/x-gtk-text-buffer-rich-text;format=%s",
                       tagset_name);

  format = gtk_text_buffer_register_serialize_format (buffer, mime_type,
                                                      _gtk_text_buffer_serialize_rich_text,
                                                      NULL, NULL);

  if (tagset_name)
    g_free (mime_type);

  return format;
}