File: text_mark.go

package info (click to toggle)
golang-github-gotk3-gotk3 0.6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: ansic: 914; makefile: 4
file content (97 lines) | stat: -rw-r--r-- 2,385 bytes parent folder | download | duplicates (2)
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
// Same copyright and license as the rest of the files in this project

package gtk

// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"

import (
	"unsafe"

	"github.com/gotk3/gotk3/glib"
)

func init() {

	WrapMap["GtkTextMark"] = wrapTextMark
}

/*
 * GtkTextMark
 */

// TextMark is a representation of GTK's GtkTextMark.
// A position in the buffer preserved across buffer modifications
type TextMark struct {
	*glib.Object
}

// native returns a pointer to the underlying GtkTextMark.
func (v *TextMark) native() *C.GtkTextMark {
	if v == nil || v.GObject == nil {
		return nil
	}
	p := unsafe.Pointer(v.GObject)
	return C.toGtkTextMark(p)
}

func marshalTextMark(p uintptr) (interface{}, error) {
	c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
	obj := glib.Take(unsafe.Pointer(c))
	return wrapTextMark(obj), nil
}

func wrapTextMark(obj *glib.Object) *TextMark {
	if obj == nil {
		return nil
	}

	return &TextMark{obj}
}

// TextMarkNew is a wrapper around gtk_text_mark_new().
func TextMarkNew(name string, leftGravity bool) (*TextMark, error) {
	cstr := C.CString(name)
	defer C.free(unsafe.Pointer(cstr))

	c := C.gtk_text_mark_new((*C.gchar)(cstr), gbool(leftGravity))
	if c == nil {
		return nil, nilPtrErr
	}
	return wrapTextMark(glib.Take(unsafe.Pointer(c))), nil
}

// SetVisible is a wrapper around gtk_text_mark_set_visible().
func (v *TextMark) SetVisible(setting bool) {
	C.gtk_text_mark_set_visible(v.native(), gbool(setting))
}

// GetVisible is a wrapper around gtk_text_mark_get_visible().
func (v *TextMark) GetVisible() bool {
	return gobool(C.gtk_text_mark_get_visible(v.native()))
}

// GetDeleted is a wrapper around gtk_text_mark_get_deleted().
func (v *TextMark) GetDeleted() bool {
	return gobool(C.gtk_text_mark_get_deleted(v.native()))
}

// GetName is a wrapper around gtk_text_mark_get_name().
func (v *TextMark) GetName() string {
	return goString(C.gtk_text_mark_get_name(v.native()))
}

// GetBuffer is a wrapper around gtk_text_mark_get_buffer().
func (v *TextMark) GetBuffer() (*TextBuffer, error) {
	c := C.gtk_text_mark_get_buffer(v.native())
	if c == nil {
		return nil, nilPtrErr
	}
	return wrapTextBuffer(glib.Take(unsafe.Pointer(c))), nil
}

// GetLeftGravity is a wrapper around gtk_text_mark_get_left_gravity().
func (v *TextMark) GetLeftGravity() bool {
	return gobool(C.gtk_text_mark_get_left_gravity(v.native()))
}