(define-object TextBuffer
  (in-module "Gtk")
  (parent "GObject")
  (c-name "GtkTextBuffer")
  (gtype-id "GTK_TYPE_TEXT_BUFFER")
  (fields
    '("GtkTextTagTable*" "tag_table")
  )
)

(define-function gtk_text_buffer_new
  (is-constructor-of "GtkTextBuffer")
  (c-name "gtk_text_buffer_new")
  (caller-owns-return #t)
  (return-type "GtkTextBuffer*")
  (parameters
    '("GtkTextTagTable*" "table")
  )
)

(define-method get_line_count
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_line_count")
  (return-type "gint")
)

(define-method get_char_count
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_char_count")
  (return-type "gint")
)

(define-method get_tag_table
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_tag_table")
  (return-type "GtkTextTagTable*")
)

(define-method set_text
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_set_text")
  (return-type "none")
  (parameters
    '("const-gchar*" "text")
    '("gint" "len")
  )
)

(define-method insert
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-gchar*" "text")
    '("gint" "len" (default "-1"))
  )
)

(define-method insert_at_cursor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_at_cursor")
  (return-type "none")
  (parameters
    '("const-gchar*" "text")
    '("gint" "len" (default "-1"))
  )
)

(define-method insert_interactive
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_interactive")
  (return-type "gboolean")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-gchar*" "text")
    '("gint" "len")
    '("gboolean" "default_editable")
  )
)

(define-method insert_interactive_at_cursor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_interactive_at_cursor")
  (return-type "gboolean")
  (parameters
    '("const-gchar*" "text")
    '("gint" "len")
    '("gboolean" "default_editable")
  )
)

(define-method insert_range
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_range")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method insert_range_interactive
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_range_interactive")
  (return-type "gboolean")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
    '("gboolean" "default_editable")
  )
)

(define-method insert_with_tags
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_with_tags")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-gchar*" "text")
    '("gint" "len")
    '("GtkTextTag*" "first_tag" (null-ok))
  )
  (varargs #t)
)

(define-method insert_with_tags_by_name
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_with_tags_by_name")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("const-gchar*" "text")
    '("gint" "len")
    '("const-gchar*" "first_tag_name")
  )
  (varargs #t)
)

(define-method delete
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_delete")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "start")
    '("GtkTextIter*" "end")
  )
)

(define-method delete_interactive
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_delete_interactive")
  (return-type "gboolean")
  (parameters
    '("GtkTextIter*" "start_iter")
    '("GtkTextIter*" "end_iter")
    '("gboolean" "default_editable")
  )
)

(define-method get_text
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_text")
  (caller-owns-return #t)
  (return-type "gchar*")
  (parameters
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
    '("gboolean" "include_hidden_chars" (default "TRUE"))
  )
)

(define-method get_slice
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_slice")
  (caller-owns-return #t)
  (return-type "gchar*")
  (parameters
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
    '("gboolean" "include_hidden_chars" (default "TRUE"))
  )
)

(define-method insert_pixbuf
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_pixbuf")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("GdkPixbuf*" "pixbuf")
  )
)

(define-method insert_child_anchor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_insert_child_anchor")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("GtkTextChildAnchor*" "anchor")
  )
)

(define-method create_child_anchor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_create_child_anchor")
  (return-type "GtkTextChildAnchor*")
  (parameters
    '("GtkTextIter*" "iter")
  )
)

(define-method create_mark
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_create_mark")
  (return-type "GtkTextMark*")
  (parameters
    '("const-gchar*" "mark_name" (null-ok))
    '("const-GtkTextIter*" "where")
    '("gboolean" "left_gravity" (default "FALSE"))
  )
)

(define-method move_mark
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_move_mark")
  (return-type "none")
  (parameters
    '("GtkTextMark*" "mark")
    '("const-GtkTextIter*" "where")
  )
)

(define-method delete_mark
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_delete_mark")
  (return-type "none")
  (parameters
    '("GtkTextMark*" "mark")
  )
)

(define-method get_mark
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_mark")
  (return-type "GtkTextMark*")
  (parameters
    '("const-gchar*" "name")
  )
)

(define-method move_mark_by_name
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_move_mark_by_name")
  (return-type "none")
  (parameters
    '("const-gchar*" "name")
    '("const-GtkTextIter*" "where")
  )
)

(define-method delete_mark_by_name
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_delete_mark_by_name")
  (return-type "none")
  (parameters
    '("const-gchar*" "name")
  )
)

(define-method get_insert
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_insert")
  (return-type "GtkTextMark*")
)

(define-method get_selection_bound
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_selection_bound")
  (return-type "GtkTextMark*")
)

(define-method place_cursor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_place_cursor")
  (return-type "none")
  (parameters
    '("const-GtkTextIter*" "where")
  )
)

(define-method select_range
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_select_range")
  (return-type "none")
  (parameters
    '("const-GtkTextIter*" "ins")
    '("const-GtkTextIter*" "bound")
  )
)

(define-method apply_tag
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_apply_tag")
  (return-type "none")
  (parameters
    '("GtkTextTag*" "tag")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method remove_tag
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_remove_tag")
  (return-type "none")
  (parameters
    '("GtkTextTag*" "tag")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method apply_tag_by_name
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_apply_tag_by_name")
  (return-type "none")
  (parameters
    '("const-gchar*" "name")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method remove_tag_by_name
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_remove_tag_by_name")
  (return-type "none")
  (parameters
    '("const-gchar*" "name")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method remove_all_tags
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_remove_all_tags")
  (return-type "none")
  (parameters
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
  )
)

(define-method create_tag
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_create_tag")
  (return-type "GtkTextTag*")
  (parameters
    '("const-gchar*" "tag_name")
    '("const-gchar*" "first_property_name")
  )
  (varargs #t)
)

(define-method get_iter_at_line_offset
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_line_offset")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("gint" "line_number")
    '("gint" "char_offset")
  )
)

(define-method get_iter_at_line_index
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_line_index")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("gint" "line_number")
    '("gint" "byte_index")
  )
)

(define-method get_iter_at_offset
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_offset")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("gint" "char_offset")
  )
)

(define-method get_iter_at_line
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_line")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("gint" "line_number")
  )
)

(define-method get_start_iter
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_start_iter")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
  )
)

(define-method get_end_iter
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_end_iter")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
  )
)

(define-method get_bounds
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_bounds")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "start")
    '("GtkTextIter*" "end")
  )
)

(define-method get_iter_at_mark
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_mark")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("GtkTextMark*" "mark")
  )
)

(define-method get_iter_at_child_anchor
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_iter_at_child_anchor")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "iter")
    '("GtkTextChildAnchor*" "anchor")
  )
)

(define-method get_modified
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_modified")
  (return-type "gboolean")
)

(define-method set_modified
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_set_modified")
  (return-type "none")
  (parameters
    '("gboolean" "setting")
  )
)

(define-method add_selection_clipboard
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_add_selection_clipboard")
  (return-type "none")
  (parameters
    '("GtkClipboard*" "clipboard")
  )
)

(define-method remove_selection_clipboard
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_remove_selection_clipboard")
  (return-type "none")
  (parameters
    '("GtkClipboard*" "clipboard")
  )
)

(define-method cut_clipboard
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_cut_clipboard")
  (return-type "none")
  (parameters
    '("GtkClipboard*" "clipboard")
    '("gboolean" "default_editable")
  )
)

(define-method copy_clipboard
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_copy_clipboard")
  (return-type "none")
  (parameters
    '("GtkClipboard*" "clipboard")
  )
)

(define-method paste_clipboard
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_paste_clipboard")
  (return-type "none")
  (parameters
    '("GtkClipboard*" "clipboard")
    '("GtkTextIter*" "override_location" (null-ok))
    '("gboolean" "default_editable")
  )
)

(define-method get_selection_bounds
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_selection_bounds")
  (return-type "gboolean")
  (parameters
    '("GtkTextIter*" "start" (null-ok))
    '("GtkTextIter*" "end" (null-ok))
  )
)

(define-method delete_selection
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_delete_selection")
  (return-type "gboolean")
  (parameters
    '("gboolean" "interactive")
    '("gboolean" "default_editable")
  )
)

(define-method begin_user_action
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_begin_user_action")
  (return-type "none")
)

(define-method end_user_action
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_end_user_action")
  (return-type "none")
)

(define-method backspace
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_backspace")
  (return-type "gboolean")
  (parameters
    '("GtkTextIter*" "iter")
    '("gboolean" "interactive")
    '("gboolean" "default_editable")
  )
)

(define-virtual insert_text
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "pos")
    '("const-gchar*" "text")
    '("gint" "length")
  )
)

(define-virtual insert_pixbuf
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "pos")
    '("GdkPixbuf*" "pixbuf")
  )
)

;; As things stand right now we'll never need this. After all, how on earth
;; could you possibly paste a Widget into a TextBuffer? Text, sure, but a
;; Widget? Don't think so.

(define-virtual insert_child_anchor
  (of-object "GtkTextBuffer")
  (unnecessary)
  (return-type "none")
  (parameters
    '("GtkTextIter*" "pos")
    '("GtkTextChildAnchor*" "anchor")
  )
)

(define-virtual delete_range
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextIter*" "start")
    '("GtkTextIter*" "end")
  )
)

(define-virtual changed
  (of-object "GtkTextBuffer")
  (return-type "none")
)

(define-virtual modified_changed
  (of-object "GtkTextBuffer")
  (return-type "none")
)

(define-virtual mark_set
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("const-GtkTextIter*" "location")
    '("GtkTextMark*" "mark")
  )
)

(define-virtual mark_deleted
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextMark*" "mark")
  )
)

(define-virtual apply_tag
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextTag*" "tag")
    '("const-GtkTextIter*" "start_char")
    '("const-GtkTextIter*" "end_char")
  )
)

(define-virtual remove_tag
  (of-object "GtkTextBuffer")
  (return-type "none")
  (parameters
    '("GtkTextTag*" "tag")
    '("const-GtkTextIter*" "start_char")
    '("const-GtkTextIter*" "end_char")
  )
)

(define-virtual begin_user_action
  (of-object "GtkTextBuffer")
  (return-type "none")
)

(define-virtual end_user_action
  (of-object "GtkTextBuffer")
  (return-type "none")
)

(define-method get_has_selection
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_has_selection")
  (return-type "gboolean")
)

(define-method get_copy_target_list
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_copy_target_list")
  (return-type "GtkTargetList*")
)

(define-method get_paste_target_list
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_paste_target_list")
  (return-type "GtkTargetList*")
)

(define-method register_serialize_format
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_register_serialize_format")
  (return-type "GdkAtom")
  (parameters
    '("const-gchar*" "mime_type")
    '("GtkTextBufferSerializeFunc" "function")
    '("gpointer" "user_data")
    '("GDestroyNotify" "user_data_destroy")
  )
)

(define-method register_serialize_tagset
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_register_serialize_tagset")
  (return-type "GdkAtom")
  (parameters
    '("const-gchar*" "tagset_name" (default "NULL") (null-ok))
  )
)

(define-method register_deserialize_format
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_register_deserialize_format")
  (return-type "GdkAtom")
  (parameters
    '("const-gchar*" "mime_type")
    '("GtkTextBufferDeserializeFunc" "function")
    '("gpointer" "user_data")
    '("GDestroyNotify" "user_data_destroy")
  )
)

(define-method register_deserialize_tagset
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_register_deserialize_tagset")
  (return-type "GdkAtom")
  (parameters
    '("const-gchar*" "tagset_name" (default "NULL") (null-ok))
  )
)

(define-method unregister_serialize_format
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_unregister_serialize_format")
  (return-type "none")
  (parameters
    '("GdkAtom" "format")
  )
)

(define-method unregister_deserialize_format
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_unregister_deserialize_format")
  (return-type "none")
  (parameters
    '("GdkAtom" "format")
  )
)

(define-method deserialize_set_can_create_tags
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_deserialize_set_can_create_tags")
  (return-type "none")
  (parameters
    '("GdkAtom" "format")
    '("gboolean" "can_create_tags")
  )
)

(define-method deserialize_get_can_create_tags
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_deserialize_get_can_create_tags")
  (return-type "gboolean")
  (parameters
    '("GdkAtom" "format")
  )
)

(define-method get_serialize_formats
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_serialize_formats")
  (return-type "GdkAtom*")
  (parameters
    '("gint*" "n_formats")
  )
)

(define-method get_deserialize_formats
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_get_deserialize_formats")
  (return-type "GdkAtom*")
  (parameters
    '("gint*" "n_formats")
  )
)

(define-method serialize
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_serialize")
  (return-type "guint8*")
  (parameters
    '("GtkTextBuffer*" "content_buffer")
    '("GdkAtom" "format")
    '("const-GtkTextIter*" "start")
    '("const-GtkTextIter*" "end")
    '("gsize*" "length")
  )
)

(define-method deserialize
  (of-object "GtkTextBuffer")
  (c-name "gtk_text_buffer_deserialize")
  (return-type "gboolean")
  (parameters
    '("GtkTextBuffer*" "content_buffer")
    '("GdkAtom" "format")
    '("GtkTextIter*" "iter")
    '("const-guint8*" "data")
    '("gsize" "length")
    '("GError**" "error")
  )
)

