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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,!gtk_3_16,!gtk_3_18
// See: https://developer.gnome.org/gtk3/3.20/api-index-3-20.html
package gtk
// #include <gtk/gtk.h>
// #include "gtk_since_3_20.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
{glib.Type(C.gtk_popover_constraint_get_type()), marshalPopoverConstraint},
}
glib.RegisterGValueMarshalers(tm)
}
/*
* Constants
*/
// PopoverConstraint is a representation of GTK's GtkPopoverConstraint.
type PopoverConstraint int
const (
POPOVER_CONSTRAINT_NONE PopoverConstraint = C.GTK_POPOVER_CONSTRAINT_NONE
POPOVER_CONSTRAINT_WINDOW PopoverConstraint = C.GTK_POPOVER_CONSTRAINT_WINDOW
)
func marshalPopoverConstraint(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return PopoverConstraint(c), nil
}
const (
STATE_FLAG_DROP_ACTIVE StateFlags = C.GTK_STATE_FLAG_DROP_ACTIVE
)
/*
* GtkNativeDialog
*/
// NativeDialog is a representation of GTK's GtkNativeDialog.
type NativeDialog struct {
glib.InitiallyUnowned
}
// native returns a pointer to the underlying GObject as a GtkNativeDialog.
func (v *NativeDialog) native() *C.GtkNativeDialog {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkNativeDialog(p)
}
func wrapNativeDialog(obj *glib.Object) *NativeDialog {
if obj == nil {
return nil
}
return &NativeDialog{glib.InitiallyUnowned{obj}}
}
// Run() is a wrapper around gtk_native_dialog_run().
func (v *NativeDialog) Run() int {
c := C.gtk_native_dialog_run(v.native())
return int(c)
}
// Destroy() is a wrapper around gtk_native_dialog_destroy().
func (v *NativeDialog) Destroy() {
C.gtk_native_dialog_destroy(v.native())
}
// SetModal is a wrapper around gtk_native_dialog_set_modal().
func (v *NativeDialog) SetModal(modal bool) {
C.gtk_native_dialog_set_modal(v.native(), gbool(modal))
}
// GetModal is a wrapper around gtk_native_dialog_get_modal().
func (v *NativeDialog) GetModal() bool {
c := C.gtk_native_dialog_get_modal(v.native())
return gobool(c)
}
// SetTitle is a wrapper around gtk_native_dialog_set_title().
func (v *NativeDialog) SetTitle(title string) {
cstr := C.CString(title)
defer C.free(unsafe.Pointer(cstr))
C.gtk_native_dialog_set_title(v.native(), (*C.char)(cstr))
}
// GetTitle is a wrapper around gtk_native_dialog_get_title().
func (v *NativeDialog) GetTitle() (string, error) {
return stringReturn((*C.gchar)(C.gtk_native_dialog_get_title(v.native())))
}
// SetTransientFor is a wrapper around gtk_native_dialog_set_transient_for().
func (v *NativeDialog) SetTransientFor(parent IWindow) {
var pw *C.GtkWindow = nil
if parent != nil {
pw = parent.toWindow()
}
C.gtk_native_dialog_set_transient_for(v.native(), pw)
}
// GetTransientFor is a wrapper around gtk_native_dialog_get_transient_for().
func (v *NativeDialog) GetTransientFor() (*Window, error) {
c := C.gtk_native_dialog_get_transient_for(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWindow(glib.Take(unsafe.Pointer(c))), nil
}
// GetVisible() is a wrapper around gtk_native_dialog_get_visible().
func (v *NativeDialog) GetVisible() bool {
c := C.gtk_native_dialog_get_visible(v.native())
return gobool(c)
}
// Show() is a wrapper around gtk_native_dialog_show().
func (v *NativeDialog) Show() {
C.gtk_native_dialog_show(v.native())
}
// Hide() is a wrapper around gtk_native_dialog_hide().
func (v *NativeDialog) Hide() {
C.gtk_native_dialog_hide(v.native())
}
/*
* GtkFileChooserNative
*/
// FileChooserNativeDialog is a representation of GTK's GtkFileChooserNative.
type FileChooserNativeDialog struct {
NativeDialog
// Interfaces
FileChooser
}
// native returns a pointer to the underlying GObject as a GtkNativeDialog.
func (v *FileChooserNativeDialog) native() *C.GtkFileChooserNative {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkFileChooserNative(p)
}
func wrapFileChooserNativeDialog(obj *glib.Object) *FileChooserNativeDialog {
if obj == nil {
return nil
}
fc := wrapFileChooser(obj)
return &FileChooserNativeDialog{NativeDialog{glib.InitiallyUnowned{obj}}, *fc}
}
// FileChooserNativeDialogNew is a wrapper around gtk_file_chooser_native_new().
func FileChooserNativeDialogNew(title string, parent IWindow, action FileChooserAction,
accept_label string, cancel_label string) (*FileChooserNativeDialog, error) {
c_title := C.CString(title)
defer C.free(unsafe.Pointer(c_title))
c_accept_label := C.CString(accept_label)
defer C.free(unsafe.Pointer(c_accept_label))
c_cancel_label := C.CString(cancel_label)
defer C.free(unsafe.Pointer(c_cancel_label))
var w *C.GtkWindow = nil
if parent != nil {
w = parent.toWindow()
}
c := C.gtk_file_chooser_native_new(
(*C.gchar)(c_title), w, C.GtkFileChooserAction(action),
(*C.gchar)(c_accept_label), (*C.gchar)(c_cancel_label))
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(unsafe.Pointer(c))
return wrapFileChooserNativeDialog(obj), nil
}
/*
* FileChooserNative
*/
func OpenFileChooserNative(title string, parent IWindow) *string {
c_title := C.CString(title)
var native *C.GtkFileChooserNative
var w *C.GtkWindow = nil
if parent != nil {
w = parent.toWindow()
}
native = C.gtk_file_chooser_native_new((*C.gchar)(c_title),
w,
C.GtkFileChooserAction(FILE_CHOOSER_ACTION_OPEN),
(*C.gchar)(C.CString("_Open")),
(*C.gchar)(C.CString("_Cancel")))
p := unsafe.Pointer(unsafe.Pointer(native))
dlg := C.toGtkNativeDialog(p)
res := C.gtk_native_dialog_run(dlg)
if res == C.GTK_RESPONSE_ACCEPT {
c := C.gtk_file_chooser_get_filename(C.toGtkFileChooser(p))
s := goString(c)
defer C.g_free((C.gpointer)(c))
return &s
}
return nil
}
// SetAcceptLabel is a wrapper around gtk_file_chooser_native_set_accept_label().
func (v *FileChooserNativeDialog) SetAcceptLabel(accept_label string) {
cstr := C.CString(accept_label)
defer C.free(unsafe.Pointer(cstr))
C.gtk_file_chooser_native_set_accept_label(v.native(), (*C.char)(cstr))
}
// GetAcceptLabel is a wrapper around gtk_file_chooser_native_get_accept_label().
func (v *FileChooserNativeDialog) GetAcceptLabel() (string, error) {
return stringReturn((*C.gchar)(C.gtk_file_chooser_native_get_accept_label(v.native())))
}
// SetCancelLabel is a wrapper around gtk_file_chooser_native_set_cancel_label().
func (v *FileChooserNativeDialog) SetCancelLabel(cancel_label string) {
cstr := C.CString(cancel_label)
defer C.free(unsafe.Pointer(cstr))
C.gtk_file_chooser_native_set_cancel_label(v.native(), (*C.char)(cstr))
}
// GetCancelLabel is a wrapper around gtk_file_chooser_native_get_cancel_label().
func (v *FileChooserNativeDialog) GetCancelLabel() (string, error) {
return stringReturn((*C.gchar)(C.gtk_file_chooser_native_get_cancel_label(v.native())))
}
/*
* GtkTextView
*/
// TODO:
// gtk_text_view_reset_cursor_blink().
/*
* GtkExpander
*/
// TODO:
// gtk_expander_set_spacing().
// gtk_expander_get_spacing().
/*
* GtkPopover
*/
// SetConstrainTo is a wrapper gtk_popover_set_constrain_to().
func (v *Popover) SetConstrainTo(constrain PopoverConstraint) {
C.gtk_popover_set_constrain_to(v.native(), C.GtkPopoverConstraint(constrain))
}
// GetConstrainTo is a wrapper gtk_popover_get_constrain_to().
func (v *Popover) GetConstrainTo() PopoverConstraint {
return PopoverConstraint(C.gtk_popover_get_constrain_to(v.native()))
}
|