forked from conformal/gotk3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtk_3_12.go
156 lines (133 loc) · 4.56 KB
/
gtk_3_12.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
// Copyright (c) 2013-2014 Conformal Systems <info@conformal.com>
//
// This file originated from: http://opensource.conformal.com/
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// This file includes wrapers for symbols included since GTK 3.12, and
// and should not be included in a build intended to target any older GTK
// versions. To target an older build, such as 3.10, use
// 'go build -tags gtk_3_10'. Otherwise, if no build tags are used, GTK 3.12
// is assumed and this file is built.
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_3_12.go.h"
import "C"
import (
"github.com/conformal/gotk3/glib"
"runtime"
"unsafe"
)
func init() {
tm := []glib.TypeMarshaler{
// Objects/Interfaces
{glib.Type(C.gtk_popover_get_type()), marshalPopover},
}
glib.RegisterGValueMarshalers(tm)
}
/*
* GtkPopover
*/
// Popover is a representation of GTK's GtkPopover.
type Popover struct {
Bin
}
// native returns a pointer to the underlying GtkPopover.
func (v *Popover) native() *C.GtkPopover {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkPopover(p)
}
func marshalPopover(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
return wrapPopover(obj), nil
}
func wrapPopover(obj *glib.Object) *Popover {
return &Popover{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// PopoverNew is a wrapper around gtk_popover_new().
func PopoverNew(relativeTo IWidget) (*Popover, error) {
c := C.gtk_popover_new(relativeTo.toWidget())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
a := wrapPopover(obj)
obj.RefSink()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return a, nil
}
// TODO: gtk_popover_new_from_model
// TODO: gtk_popover_bind_model
// SetRelativeTo is a wrapper around gtk_popover_set_relative_to().
func (v *Popover) SetRelativeTo(relativeTo IWidget) {
C.gtk_popover_set_relative_to(v.native(), relativeTo.toWidget())
}
// GetRelativeTo is a wrapper around gtk_popover_get_relative_to().
func (v *Popover) GetRelativeTo() (*Widget, error) {
c := C.gtk_popover_get_relative_to(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
w := wrapWidget(obj)
obj.RefSink()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return w, nil
}
// TODO: gtk_popover_set_pointing_to
// TODO: gtk_popover_get_pointing_to
// SetPosition is a wrapper around gtk_popover_set_position().
func (v *Popover) SetPosition(position PositionType) {
C.gtk_popover_set_position(v.native(), C.GtkPositionType(position))
}
// GetPosition is a wrapper around gtk_popover_get_position().
func (v *Popover) GetPosition() PositionType {
c := C.gtk_popover_get_position(v.native())
return PositionType(c)
}
// SetModal is a wrapper around gtk_popover_set_modal().
func (v *Popover) SetModal(modal bool) {
C.gtk_popover_set_modal(v.native(), gbool(modal))
}
// GetModal is a wrapper around gtk_popover_get_modal().
func (v *Popover) GetModal() bool {
c := C.gtk_popover_get_modal(v.native())
return gobool(c)
}
/*
* GtkWidget
*/
// GetMarginStart is a wrapper around gtk_widget_get_margin_start().
func (v *Widget) GetMarginStart() int {
c := C.gtk_widget_get_margin_start(v.native())
return int(c)
}
// SetMarginStart is a wrapper around gtk_widget_set_margin_start().
func (v *Widget) SetMarginStart(margin int) {
C.gtk_widget_set_margin_start(v.native(), C.gint(margin))
}
// GetMarginEnd is a wrapper around gtk_widget_get_margin_end().
func (v *Widget) GetMarginEnd() int {
c := C.gtk_widget_get_margin_end(v.native())
return int(c)
}
// SetMarginEnd is a wrapper around gtk_widget_set_margin_end().
func (v *Widget) SetMarginEnd(margin int) {
C.gtk_widget_set_margin_end(v.native(), C.gint(margin))
}