]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtksourceview/ml_gtk_sourceview.c
ocaml 3.09 transition
[helm.git] / helm / DEVEL / lablgtksourceview / ml_gtk_sourceview.c
1 /*
2  * lablgtksourceview, OCaml binding for the GtkSourceView text widget
3  *
4  * Copyright (C) 2005  Stefano Zacchiroli <zack@cs.unibo.it>
5  * 
6  * This library is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as
8  * published by the Free Software Foundation; either version 2.1 of the
9  * License, or (at your option) any later version.
10  * 
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  * 
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  */
21
22 #include <assert.h>
23
24 #include <gtksourceview/gtksourceview.h>
25 #include <gtksourceview/gtksourcelanguagesmanager.h>
26
27 #include <caml/mlvalues.h>
28 #include <caml/alloc.h>
29 #include <caml/memory.h>
30 #include <caml/callback.h>
31 #include <caml/fail.h>
32 #include <caml/custom.h>
33 #include <caml/callback.h>
34
35 #include <wrappers.h>
36 #include <ml_glib.h>
37 #include <ml_gdk.h>
38 #include <ml_gtk.h>
39 #include <ml_gobject.h>
40 #include <ml_gdkpixbuf.h>
41 #include <ml_pango.h>
42 #include <gtk_tags.h>
43 #include <gdk_tags.h>
44
45 CAMLprim value ml_gtk_source_language_init(value unit)
46 {       /* Since these are declared const, must force gcc to call them! */
47     GType t = gtk_source_language_get_type();
48     return Val_GType(t);
49 }
50
51 CAMLprim value ml_gtk_source_languages_manager_init(value unit)
52 {       /* Since these are declared const, must force gcc to call them! */
53     GType t = gtk_source_languages_manager_get_type();
54     return Val_GType(t);
55 }
56
57 CAMLprim value ml_gtk_source_buffer_init(value unit)
58 {       /* Since these are declared const, must force gcc to call them! */
59     GType t = gtk_source_buffer_get_type();
60     return Val_GType(t);
61 }
62
63 CAMLprim value ml_gtk_source_view_init(value unit)
64 {       /* Since these are declared const, must force gcc to call them! */
65     GType t = gtk_source_view_get_type();
66     return Val_GType(t);
67 }
68
69 static gpointer string_val(value v)
70 {
71         return String_val(v);
72 }
73
74 GSList *ml_gslist_of_string_list(value list)
75 {
76         GSList_val(list, string_val);
77 }
78
79 /* CAMLprim value
80 ml_gtk_source_languages_manager_set_lang_files_dirs(GObject *obj, value list)
81 {
82         GSList *gslist = ml_gslist_of_string_list(list);
83         g_object_set_property(obj, "lang-files-dirs", gslist);
84         return Val_unit;
85 } */
86
87 #define GtkSourceLanguage_val(val) check_cast(GTK_SOURCE_LANGUAGE,val)
88 #define GtkSourceLanguagesManager_val(val)\
89         check_cast(GTK_SOURCE_LANGUAGES_MANAGER,val)
90 #define GtkSourceTagTable_val(val) check_cast(GTK_SOURCE_TAG_TABLE,val)
91 #define GtkSourceBuffer_val(val) check_cast(GTK_SOURCE_BUFFER,val)
92 #define GtkSourceView_val(val) check_cast(GTK_SOURCE_VIEW,val)
93 #define GtkTextIter_val(val) ((GtkTextIter*)MLPointer_val(val))
94 #define Val_option_GtkAny(v) Val_option(v,Val_GtkAny)
95 #define string_list_of_GSList(l) Val_GSList(l, (value_in) Val_string)
96 /* #define GSList_of_string_list(l) GSList_val(l, String_val) */
97 /* #define GSList_of_string_list(l) GSList_val(l, ml_string_val) */
98
99 ML_2 (_gtk_source_language_new_from_file, String_val,
100                 GtkSourceLanguagesManager_val, Val_option_GtkAny)
101 ML_1 (gtk_source_language_get_name, GtkSourceLanguage_val, Val_string)
102 ML_1 (gtk_source_language_get_section, GtkSourceLanguage_val, Val_string)
103 ML_1 (gtk_source_language_get_escape_char, GtkSourceLanguage_val, Val_int)
104
105 ML_0 (gtk_source_languages_manager_new, Val_GtkAny_sink)
106 ML_2 (gtk_source_languages_manager_get_language_from_mime_type,
107                 GtkSourceLanguagesManager_val, String_val,
108                 Val_option_GtkAny)
109 ML_1 (gtk_source_languages_manager_get_lang_files_dirs,
110                 GtkSourceLanguagesManager_val, string_list_of_GSList)
111
112 /* ML_0 (gtk_source_buffer_new, GtkSourceTagTable_val, Val_GtkAny_sink) */
113 /* ML_1 (gtk_source_buffer_new_with_language, GtkSourceLanguage_val,
114                 Val_GtkAny_sink) */
115 ML_1 (gtk_source_buffer_can_undo, GtkSourceBuffer_val, Val_bool)
116 ML_1 (gtk_source_buffer_can_redo, GtkSourceBuffer_val, Val_bool)
117 ML_1 (gtk_source_buffer_undo, GtkSourceBuffer_val, Unit)
118 ML_1 (gtk_source_buffer_redo, GtkSourceBuffer_val, Unit)
119 ML_1 (gtk_source_buffer_begin_not_undoable_action, GtkSourceBuffer_val, Unit)
120 ML_1 (gtk_source_buffer_end_not_undoable_action, GtkSourceBuffer_val, Unit)
121
122 ML_0 (gtk_source_view_new, Val_GtkWidget_sink)
123 ML_1 (gtk_source_view_new_with_buffer, GtkSourceBuffer_val, Val_GtkWidget_sink)
124
125 ML_1 (gtk_source_iter_find_matching_bracket, GtkTextIter_val, Val_bool)
126