File: settings_schema_source.go

package info (click to toggle)
golang-github-gotk3-gotk3 0.0~GOTK3~0~2~0%2Bgit20170418.0.96d4110-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,368 kB
  • sloc: ansic: 1,056; makefile: 4
file content (70 lines) | stat: -rw-r--r-- 2,407 bytes parent folder | download | duplicates (3)
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
package glib

// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <gio/gio.h>
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
import "unsafe"

// SettingsSchemaSource is a representation of GSettingsSchemaSource.
type SettingsSchemaSource struct {
	source *C.GSettingsSchemaSource
}

func wrapSettingsSchemaSource(obj *C.GSettingsSchemaSource) *SettingsSchemaSource {
	if obj == nil {
		return nil
	}
	return &SettingsSchemaSource{obj}
}

func (v *SettingsSchemaSource) Native() uintptr {
	return uintptr(unsafe.Pointer(v.source))
}

func (v *SettingsSchemaSource) native() *C.GSettingsSchemaSource {
	if v == nil || v.source == nil {
		return nil
	}
	return v.source
}

// SettingsSchemaSourceGetDefault is a wrapper around g_settings_schema_source_get_default().
func SettingsSchemaSourceGetDefault() *SettingsSchemaSource {
	return wrapSettingsSchemaSource(C.g_settings_schema_source_get_default())
}

// Ref() is a wrapper around g_settings_schema_source_ref().
func (v *SettingsSchemaSource) Ref() *SettingsSchemaSource {
	return wrapSettingsSchemaSource(C.g_settings_schema_source_ref(v.native()))
}

// Unref() is a wrapper around g_settings_schema_source_unref().
func (v *SettingsSchemaSource) Unref() {
	C.g_settings_schema_source_unref(v.native())
}

// SettingsSchemaSourceNewFromDirectory() is a wrapper around g_settings_schema_source_new_from_directory().
func SettingsSchemaSourceNewFromDirectory(dir string, parent *SettingsSchemaSource, trusted bool) *SettingsSchemaSource {
	cstr := (*C.gchar)(C.CString(dir))
	defer C.free(unsafe.Pointer(cstr))

	return wrapSettingsSchemaSource(C.g_settings_schema_source_new_from_directory(cstr, parent.native(), gbool(trusted), nil))
}

// Lookup() is a wrapper around g_settings_schema_source_lookup().
func (v *SettingsSchemaSource) Lookup(schema string, recursive bool) *SettingsSchema {
	cstr := (*C.gchar)(C.CString(schema))
	defer C.free(unsafe.Pointer(cstr))

	return wrapSettingsSchema(C.g_settings_schema_source_lookup(v.native(), cstr, gbool(recursive)))
}

// ListSchemas is a wrapper around 	g_settings_schema_source_list_schemas().
func (v *SettingsSchemaSource) ListSchemas(recursive bool) (nonReolcatable, relocatable []string) {
	var nonRel, rel **C.gchar
	C.g_settings_schema_source_list_schemas(v.native(), gbool(recursive), &nonRel, &rel)
	return toGoStringArray(nonRel), toGoStringArray(rel)
}