+let source_languages_manager () =
+ new source_languages_manager (SourceLanguagesManager.create [])
+
+let source_language_from_file ?languages_manager fname =
+ let languages_manager =
+ match languages_manager with
+ | None -> source_languages_manager ()
+ | Some lm -> lm
+ in
+ let manager_obj = languages_manager#as_source_languages_manager in
+ match SourceLanguage.new_from_file fname manager_obj with
+ | None -> None
+ | Some lang_obj -> Some (new source_language lang_obj)
+
+(** {2 GtkSourceBuffer} *)
+
+class source_buffer_signals obj' =
+object
+ inherit ['a] gobject_signals (obj' : [> Gtk_sourceview.source_buffer] obj)
+ inherit GText.buffer_signals obj'
+ inherit source_buffer_sigs
+end
+
+class source_buffer (obj: Gtk_sourceview.source_buffer obj) =
+object (self)
+ inherit GText.buffer_skel obj
+ method connect = new source_buffer_signals obj
+ method misc = new gobject_ops obj
+ method check_brackets = get_bool (self#misc#get_property "check-brackets")
+ method set_check_brackets x = self#misc#set_property "check-brackets" (bool x)
+ method highlight = get_bool (self#misc#get_property "highlight")
+ method set_highlight x = self#misc#set_property "highlight" (bool x)
+ method max_undo_levels = get_int (self#misc#get_property "max-undo-levels")
+ method set_max_undo_levels x =
+ self#misc#set_property "max-undo-levels" (int x)
+ method language =
+ match get_gobject (self#misc#get_property "language") with
+ | None -> None
+ | Some obj ->
+ Some (new source_language (Gobject.try_cast obj "GtkSourceLanguage"))
+ method set_language (x: source_language) =
+ self#misc#set_property "language" (gobject x#as_source_language)
+ method escape_char = get_uint (self#misc#get_property "escape-char")
+ method set_escape_char x = self#misc#set_property "escape-char" (uint x)
+ method can_undo = SourceBuffer.can_undo obj
+ method can_redo = SourceBuffer.can_redo obj
+ method undo () = SourceBuffer.undo obj
+ method redo () = SourceBuffer.redo obj
+ method begin_not_undoable_action () =
+ SourceBuffer.begin_not_undoable_action obj
+ method end_not_undoable_action () =
+ SourceBuffer.end_not_undoable_action obj
+end
+
+let source_buffer ?language ?text (* ?tag_table *) =
+ let language =
+ match language with
+ | None -> None
+ | Some source_language -> Some (source_language#as_source_language)
+ in
+ SourceBuffer.make_params [] ?language ~cont:(fun pl () ->
+ let buf = new source_buffer (SourceBuffer.create pl) in
+ (match text with
+ | None -> ()
+ | Some text -> buf#set_text text);
+ buf)
+
+ (* alias used below, needed because "source_buffer" is a name in scope *)
+let source_buffer' = source_buffer
+
+(** {2 GtkSourceView} *)
+
+class source_view_signals obj' =