-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_since_3_16.go
245 lines (200 loc) · 8.14 KB
/
source_since_3_16.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
// +build linux
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14
// Filename version number based on gtk_sourceview
// Limit > gtk_3_14 because libgtksourceview-3.0 start at gtk >= 3.16
// Latest gtksourceview_3_18 start with gtk_3_16
// Latest gtksourceview_4_0 start with gtk_3_22
// Same copyright and license as the rest of the files in this project
package source
// #include <gtk/gtk.h>
// #include <gtksourceview/gtksource.h>
// #include "source_since_3_16.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_source_style_scheme_chooser_button_get_type()), marshalSourceStyleSchemeChooserButton},
{glib.Type(C.gtk_source_style_scheme_chooser_widget_get_type()), marshalSourceStyleSchemeChooserWidget},
{glib.Type(C.gtk_source_background_pattern_type_get_type()), marshalSourceBackgroundPatternType},
}
glib.RegisterGValueMarshalers(tm)
gtk.WrapMap["GtkSourceStyleSchemeChooserButton"] = wrapSourceStyleSchemeChooserButton
gtk.WrapMap["GtkSourceStyleSchemeChooserWidget"] = wrapSourceStyleSchemeChooserWidget
}
/*
* GtkSourceStyleSchemeChooser (full)
* Interface implemented by widgets for choosing style schemes
*/
// SourceStyleSchemeChooser is a representation of GTK's GtkSourceStyleSchemeChooser.
type SourceStyleSchemeChooser struct {
*glib.Object
}
// native returns a pointer to the underlying GtkSourceStyleSchemeChooser.
func (v *SourceStyleSchemeChooser) native() *C.GtkSourceStyleSchemeChooser {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkSourceStyleSchemeChooser(p)
}
func marshalSourceStyleSchemeChooser(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := glib.Take(unsafe.Pointer(c))
return wrapSourceStyleSchemeChooser(obj), nil
}
func wrapSourceStyleSchemeChooser(obj *glib.Object) *SourceStyleSchemeChooser {
return &SourceStyleSchemeChooser{obj}
}
// GetStyleScheme is a wrapper around gtk_source_style_scheme_chooser_get_style_scheme().
func (v *SourceStyleSchemeChooser) GetStyleScheme() (*SourceStyleScheme, error) {
c := C.gtk_source_style_scheme_chooser_get_style_scheme(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapSourceStyleScheme(glib.Take(unsafe.Pointer(c))), nil
}
// SetStyleScheme is a wrapper around gtk_source_style_scheme_chooser_set_style_scheme().
func (v *SourceStyleSchemeChooser) SetStyleScheme(scheme *SourceStyleScheme) {
C.gtk_source_style_scheme_chooser_set_style_scheme(v.native(), scheme.native())
}
/*
* GtkSourceStyleSchemeChooserWidget (full)
* A widget for choosing style schemes
*/
// SourceStyleSchemeChooserWidget is a representation of GTK's GtkSourceStyleSchemeChooserWidget.
type SourceStyleSchemeChooserWidget struct {
gtk.Bin
SourceStyleSchemeChooser
}
// native returns a pointer to the underlying GtkSourceStyleSchemeChooserWidget.
func (v *SourceStyleSchemeChooserWidget) native() *C.GtkSourceStyleSchemeChooserWidget {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkSourceStyleSchemeChooserWidget(p)
}
func marshalSourceStyleSchemeChooserWidget(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := glib.Take(unsafe.Pointer(c))
return wrapSourceStyleSchemeChooserWidget(obj), nil
}
func wrapSourceStyleSchemeChooserWidget(obj *glib.Object) *SourceStyleSchemeChooserWidget {
c := wrapSourceStyleSchemeChooser(obj)
return &SourceStyleSchemeChooserWidget{gtk.Bin{gtk.Container{gtk.Widget{glib.InitiallyUnowned{obj}}}}, *c}
}
// SourceStyleSchemeChooserWidgetNew is a wrapper around gtk_source_style_scheme_chooser_widget_new().
func SourceStyleSchemeChooserWidgetNew() (*SourceStyleSchemeChooserWidget, error) {
c := C.gtk_source_style_scheme_chooser_widget_new()
if c == nil {
return nil, nilPtrErr
}
obj := (glib.Take(unsafe.Pointer(c)))
return wrapSourceStyleSchemeChooserWidget(obj), nil
}
/*
* GtkSourceStyleSchemeChooserButton (full)
* A button to launch a style scheme selection dialog
*/
// SourceStyleSchemeChooserButton is a representation of GTK's GtkSourceStyleSchemeChooserButton.
type SourceStyleSchemeChooserButton struct {
gtk.Button
SourceStyleSchemeChooser
}
// native returns a pointer to the underlying GtkSourceStyleSchemeChooserButton.
func (v *SourceStyleSchemeChooserButton) native() *C.GtkSourceStyleSchemeChooserButton {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkSourceStyleSchemeChooserButton(p)
}
func marshalSourceStyleSchemeChooserButton(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := glib.Take(unsafe.Pointer(c))
return wrapSourceStyleSchemeChooserButton(obj), nil
}
func wrapSourceStyleSchemeChooserButton(obj *glib.Object) *SourceStyleSchemeChooserButton {
c := wrapSourceStyleSchemeChooser(obj)
a := >k.Actionable{obj}
return &SourceStyleSchemeChooserButton{gtk.Button{gtk.Bin{gtk.Container{gtk.Widget{glib.InitiallyUnowned{obj}}}}, a}, *c}
}
// SourceStyleSchemeChooserButtonNew is a wrapper around gtk_source_style_scheme_chooser_button_new().
func SourceStyleSchemeChooserButtonNew() (*SourceStyleSchemeChooserButton, error) {
c := C.gtk_source_style_scheme_chooser_button_new()
if c == nil {
return nil, nilPtrErr
}
obj := (glib.Take(unsafe.Pointer(c)))
return wrapSourceStyleSchemeChooserButton(obj), nil
}
/*
* SourceView
*/
// SourceBackgroundPatternType is a representation of GTK's GtkSourceBackgroundPatternType.
type SourceBackgroundPatternType int
const (
SOURCE_BACKGROUND_PATTERN_TYPE_NONE SourceBackgroundPatternType = C.GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE
SOURCE_BACKGROUND_PATTERN_TYPE_GRID = C.GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID
)
func marshalSourceBackgroundPatternType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return SourceBackgroundPatternType(c), nil
}
// GetVersion same as GTK_SOURCE_CHECK_VERSION() macro. It is a personal
// implementation to check which version will be deployed in prod.
func SourceGetVersion() (int, int, int, bool) {
major := C.gtk_source_get_major_version()
minor := C.gtk_source_get_minor_version()
micro := C.gtk_source_get_micro_version()
return int(major),
int(minor),
int(micro),
gobool(C.gtk_source_check_version(
major,
minor,
micro))
}
// IndentLines is a wrapper around gtk_source_view_indent_lines().
func (v *SourceView) IndentLines(start, end *gtk.TextIter) {
C.gtk_source_view_indent_lines(v.native(), nativeTextIter(start), nativeTextIter(end))
}
// UnIndentLines is a wrapper around gtk_source_view_unindent_lines().
func (v *SourceView) UnIndentLines(start, end *gtk.TextIter) {
C.gtk_source_view_unindent_lines(v.native(), nativeTextIter(start), nativeTextIter(end))
}
// SetBackgroundPattern is a wrapper around gtk_source_view_set_background_pattern().
func (v *SourceView) SetBackgroundPattern(bp SourceBackgroundPatternType) {
C.gtk_source_view_set_background_pattern(v.native(), C.GtkSourceBackgroundPatternType(bp))
}
// GetBackgroundPattern is a wrapper around gtk_source_view_get_background_pattern().
func (v *SourceView) GetBackgroundPattern() SourceBackgroundPatternType {
return SourceBackgroundPatternType(C.gtk_source_view_get_background_pattern(v.native()))
}
/*
* SourceBuffer
*/
// JoinLines is a wrapper around gtk_source_buffer_join_lines().
func (v *SourceBuffer) JoinLines(caseType SourceChangeCaseType, start, end *gtk.TextIter) {
C.gtk_source_buffer_join_lines(v.native(), nativeTextIter(start), nativeTextIter(end))
}
/*
* SourceSearchContext
*/
// GetMatchStyle is a wrapper around gtk_source_search_context_get_match_style().
func (v *SourceSearchContext) GetMatchStyle() (*SourceStyle, error) {
c := C.gtk_source_search_context_get_match_style(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapSourceStyle(glib.Take(unsafe.Pointer(c))), nil
}
// SetMatchStyle is a wrapper around gtk_source_search_context_set_match_style().
func (v *SourceSearchContext) SetMatchStyle(style *SourceStyle) {
C.gtk_source_search_context_set_match_style(v.native(),
style.native())
}