Lots of work to establish basic support for approving/denying rules.

Updated gotk3 vendor dependency (fixed some bug conditions).
shw_dev
shw 8 years ago
parent e3833190bf
commit aba795fa97

@ -67,7 +67,14 @@ func (ds *dbusServer) RequestPrompt(application, icon, path, address string, por
optstring string, expanded, expert bool, action int32) (int32, string, *dbus.Error) {
log.Printf("REALLY GOT IT!")
log.Printf("app = %s, icon = %s, path = %s, address = %s, action = %v\n", application, icon, path, address, action)
addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, optstring)
decision := addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, optstring)
log.Print("Waiting on decision...")
decision.Cond.L.Lock()
for !decision.Ready {
decision.Cond.Wait()
}
log.Print("Decision returned: ", decision.Rule)
decision.Cond.L.Unlock()
// glib.IdleAdd(func, data)
return 0, "bla bla bla", nil
return int32(decision.Scope), decision.Rule, nil
}

@ -6,13 +6,18 @@ import (
"github.com/gotk3/gotk3/glib"
"log"
"fmt"
"strconv"
"os"
"io/ioutil"
"encoding/json"
"os/user"
"strconv"
"sync"
"errors"
"github.com/subgraph/fw-daemon/sgfw"
)
type fpPreferences struct {
Winheight uint
Winwidth uint
@ -20,13 +25,52 @@ type fpPreferences struct {
Winleft uint
}
type decisionWaiter struct {
Cond *sync.Cond
Lock sync.Locker
Ready bool
Scope int
Rule string
}
type ruleColumns struct {
Path string
Proto string
Pid int
Target string
Hostname string
Port int
UID int
GID int
Origin string
}
var userPrefs fpPreferences
var mainWin *gtk.Window
var Notebook *gtk.Notebook
var globalLS *gtk.ListStore
var globalTV *gtk.TreeView
var decisionWaiters []*decisionWaiter
var editApp, editTarget, editPort *gtk.Entry
var comboProto *gtk.ComboBoxText
func dumpDecisions() {
fmt.Println("Total of decisions pending: ", len(decisionWaiters))
for i := 0; i < len(decisionWaiters); i++ {
fmt.Printf("%d ready = %v, rule = %v\n", i+1, decisionWaiters[i].Ready, decisionWaiters[i].Rule)
}
}
func addDecision() *decisionWaiter {
decision := decisionWaiter{Lock: &sync.Mutex{}, Ready: false, Scope: int(sgfw.APPLY_ONCE), Rule: ""}
decision.Cond = sync.NewCond(decision.Lock)
decisionWaiters = append(decisionWaiters, &decision)
return &decision
}
func promptInfo(msg string) {
dialog := gtk.MessageDialogNew(mainWin, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Displaying full log info:")
// dialog.SetDefaultGeometry(500, 200)
@ -160,6 +204,64 @@ func get_hbox() *gtk.Box {
return hbox
}
func get_vbox() *gtk.Box {
vbox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
if err != nil {
log.Fatal("Unable to create vertical box:", err)
}
return vbox
}
func get_combobox() *gtk.ComboBoxText {
combo, err := gtk.ComboBoxTextNew()
if err != nil {
log.Fatal("Unable to create combo box:", err)
}
combo.Append("tcp", "TCP")
combo.Append("udp", "UDP")
combo.Append("icmp", "ICMP")
combo.SetActive(0)
return combo
}
func get_radiobutton(group *gtk.RadioButton, label string, activated bool) *gtk.RadioButton {
if group == nil {
radiobutton, err := gtk.RadioButtonNewWithLabel(nil, label)
if err != nil {
log.Fatal("Unable to create radio button:", err)
}
radiobutton.SetActive(activated)
return radiobutton
}
radiobutton, err := gtk.RadioButtonNewWithLabelFromWidget(group, label)
if err != nil {
log.Fatal("Unable to create radio button in group:", err)
}
radiobutton.SetActive(activated)
return radiobutton
}
func get_entry(text string) *gtk.Entry {
entry, err := gtk.EntryNew()
if err != nil {
log.Fatal("Unable to create text entry:", err)
}
entry.SetText(text)
return entry
}
func get_label(text string) *gtk.Label {
label, err := gtk.LabelNew(text)
@ -200,7 +302,7 @@ func createListStore(general bool) *gtk.ListStore {
return listStore
}
func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin, optstring string) {
func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin, optstring string) *decisionWaiter {
if listStore == nil {
listStore = globalLS
}
@ -232,6 +334,9 @@ func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, h
log.Fatal("Unable to add row:", err)
}
decision := addDecision()
dumpDecisions()
return decision
}
func setup_settings() {
@ -296,7 +401,185 @@ func setup_settings() {
Notebook.AppendPage(scrollbox, hLabel)
}
func lsGetStr(ls *gtk.ListStore, iter *gtk.TreeIter, idx int) (string, error) {
val, err := globalLS.GetValue(iter, idx)
if err != nil {
return "", err
}
sval, err := val.GetString()
if err != nil {
return "", err
}
return sval, nil
}
func lsGetInt(ls *gtk.ListStore, iter *gtk.TreeIter, idx int) (int, error) {
val, err := globalLS.GetValue(iter, idx)
if err != nil {
return 0, err
}
ival, err := val.GoValue()
if err != nil {
return 0, err
}
return ival.(int), nil
}
func makeDecision(idx int, rule string, scope int) {
decisionWaiters[idx].Cond.L.Lock()
decisionWaiters[idx].Rule = rule
decisionWaiters[idx].Scope = scope
decisionWaiters[idx].Ready = true
decisionWaiters[idx].Cond.Signal()
decisionWaiters[idx].Cond.L.Unlock()
}
func createCurrentRule() (ruleColumns, error) {
rule := ruleColumns{}
var err error = nil
rule.Path, err = editApp.GetText()
if err != nil {
return rule, err
}
ports, err := editPort.GetText()
if err != nil {
return rule, err
}
rule.Port, err = strconv.Atoi(ports)
if err != nil {
return rule, err
}
rule.Target, err = editTarget.GetText()
if err != nil {
return rule, err
}
rule.Proto = comboProto.GetActiveID()
rule.UID, rule.GID = 0, 0
/* Pid int
Origin string */
return rule, nil
}
func clearEditor() {
editApp.SetText("")
editTarget.SetText("")
editPort.SetText("")
comboProto.SetActive(0)
/* ronce.SetActive(true)
rprocess.SetActive(false)
rparent.SetActive(false)
rsession.SetActive(false)
rpermanent.SetActive(false) */
}
func removeSelectedRule(idx int) error {
fmt.Println("XXX: attempting to remove idx = ", idx)
path, err := gtk.TreePathNewFromString(fmt.Sprintf("%d", idx))
if err != nil {
return err
}
iter, err := globalLS.GetIter(path)
if err != nil {
return err
}
ok := globalLS.Remove(iter)
// XXX: hmmm? why does this work? shouldn't it be the opposite?
if ok {
return errors.New("Unexpected error removing rule from list")
}
decisionWaiters = append(decisionWaiters[:idx], decisionWaiters[idx+1:]...)
return nil
}
func getSelectedRule() (ruleColumns, int, error) {
rule := ruleColumns{}
sel, err := globalTV.GetSelection()
if err != nil {
return rule, -1, err
}
rows := sel.GetSelectedRows(globalLS)
fmt.Println("RETURNED ROWS: ", rows.Length())
if rows.Length() <= 0 {
return rule, -1, errors.New("No selection was made")
}
rdata := rows.NthData(0)
lIndex, err := strconv.Atoi(rdata.(*gtk.TreePath).String())
if err != nil {
return rule, -1, err
}
fmt.Println("lindex = ", lIndex)
path, err := gtk.TreePathNewFromString(fmt.Sprintf("%d", lIndex))
if err != nil {
return rule, -1, err
}
iter, err := globalLS.GetIter(path)
if err != nil {
return rule, -1, err
}
rule.Path, err = lsGetStr(globalLS, iter, 1)
if err != nil {
return rule, -1, err
}
rule.Proto, err = lsGetStr(globalLS, iter, 2)
if err != nil {
return rule, -1, err
}
rule.Pid, err = lsGetInt(globalLS, iter, 3)
if err != nil {
return rule, -1, err
}
rule.Target, err = lsGetStr(globalLS, iter, 4)
if err != nil {
return rule, -1, err
}
rule.Hostname, err = lsGetStr(globalLS, iter, 5)
if err != nil {
return rule, -1, err
}
rule.Port, err = lsGetInt(globalLS, iter, 6)
if err != nil {
return rule, -1, err
}
rule.UID, rule.GID = 0, 0
rule.Origin, err = lsGetStr(globalLS, iter, 9)
if err != nil {
return rule, -1, err
}
return rule, lIndex, nil
}
func main() {
decisionWaiters = make([]*decisionWaiter, 0)
_, err := newDbusServer();
if err != nil {
log.Fatal("Error:", err)
@ -365,6 +648,7 @@ func main() {
log.Fatal("Unable to create treeview:", err)
}
globalTV = tv
tv.SetSizeRequest(300, 300)
tv.SetHeadersClickable(true)
@ -388,8 +672,46 @@ func main() {
bb.PackStart(db, false, false, 5)
bb.PackStart(ib, false, false, 5)
// box.Add(tv)
editbox := get_vbox()
hbox := get_hbox()
lbl := get_label("Application path:")
editApp = get_entry("")
hbox.PackStart(lbl, false, false, 10)
hbox.PackStart(editApp, false, false, 5)
editbox.PackStart(hbox, false, false, 5)
hbox = get_hbox()
lbl = get_label("Target host/IP:")
editTarget = get_entry("")
hbox.PackStart(lbl, false, false, 10)
hbox.PackStart(editTarget, false, false, 5)
lbl = get_label("Port:")
editPort = get_entry("")
hbox.PackStart(lbl, false, false, 5)
hbox.PackStart(editPort, false, false, 5)
lbl = get_label("Protocol:")
comboProto = get_combobox()
hbox.PackStart(lbl, false, true, 5)
hbox.PackStart(comboProto, false, false, 5)
editbox.PackStart(hbox, false, false, 5)
hbox = get_hbox()
lbl = get_label("Apply rule:")
ronce := get_radiobutton(nil, "Once", true)
rprocess := get_radiobutton(ronce, "This Process", false)
rparent := get_radiobutton(ronce, "Parent Process", false)
rsession := get_radiobutton(ronce, "Session", false)
rpermanent := get_radiobutton(ronce, "Permanent", false)
hbox.PackStart(lbl, false, false, 10)
hbox.PackStart(ronce, false, false, 5)
hbox.PackStart(rprocess, false, false, 5)
hbox.PackStart(rparent, false, false, 5)
hbox.PackStart(rsession, false, false, 5)
hbox.PackStart(rpermanent, false, false, 5)
editbox.PackStart(hbox, false, false, 5)
box.PackStart(bb, false, false, 5)
box.PackStart(editbox, false, false, 5)
box.PackStart(tv, false, true, 5)
tv.AppendColumn(createColumn("#", 0))
@ -410,80 +732,97 @@ func main() {
tv.SetModel(listStore)
ab.Connect("clicked", func() {
promptError("Approving firewall request.")
/* choice := promptChoice("hmm?")
rule, idx, err := getSelectedRule()
if err != nil {
promptError("Error occurred processing request: "+err.Error())
return
}
if choice != int(gtk.RESPONSE_YES) {
rule, err = createCurrentRule()
if err != nil {
promptError("Error occurred constructing new rule: "+err.Error())
return
} */
}
fmt.Println("rule = ", rule)
rulestr := "ALLOW|" + rule.Proto + ":" + rule.Target + ":" + strconv.Itoa(rule.Port)
fmt.Println("RULESTR = ", rulestr)
makeDecision(idx, rulestr, int(sgfw.APPLY_ONCE))
fmt.Println("Decision made.")
err = removeSelectedRule(idx)
if err == nil {
clearEditor()
} else {
promptError("Error setting new rule: "+err.Error())
}
})
db.Connect("clicked", func() {
promptError("Denying firewall request.")
rule, idx, err := getSelectedRule()
if err != nil {
promptError("Error occurred processing request: "+err.Error())
return
}
rule, err = createCurrentRule()
if err != nil {
promptError("Error occurred constructing new rule: "+err.Error())
return
}
fmt.Println("rule = ", rule)
rulestr := "DENY|" + rule.Proto + ":" + rule.Target + ":" + strconv.Itoa(rule.Port)
fmt.Println("RULESTR = ", rulestr)
makeDecision(idx, rulestr, int(sgfw.APPLY_ONCE))
fmt.Println("Decision made.")
err = removeSelectedRule(idx)
if err == nil {
clearEditor()
} else {
promptError("Error setting new rule: "+err.Error())
}
})
db.Connect("clicked", func() {
ib.Connect("clicked", func() {
promptError("Ignoring firewall request.")
return
/* promptError("Ignoring firewall request.")
fmt.Println("LOCKING")
decisionWaiters[0].Cond.L.Lock()
decisionWaiters[0].Ready = true
decisionWaiters[0].Rule = "bloop done"
fmt.Println("SIGNALING")
decisionWaiters[0].Cond.Signal()
fmt.Println("SIGNALED")
fmt.Println("UNLOCKING")
decisionWaiters[0].Cond.L.Unlock() */
})
tv.Connect("row-activated", func() {
fmt.Println("DOUBLE CLICK")
sel, err := tv.GetSelection()
seldata, _, err := getSelectedRule()
if err != nil {
promptError("Unexpected error retrieving selection: "+err.Error())
promptError("Unexpected error reading selected rule: "+err.Error())
return
}
rows := sel.GetSelectedRows(listStore)
// func (v *TreeSelection) GetSelected() (model ITreeModel, iter *TreeIter, ok bool) ???
fmt.Println("RETURNED ROWS: ", rows.Length())
if rows.Length() > 0 {
rdata := rows.NthData(0)
lIndex, err := strconv.Atoi(rdata.(*gtk.TreePath).String())
if err != nil {
promptError("Unexpected error reading selection data: "+err.Error())
return
}
editApp.SetText(seldata.Path)
path, err := gtk.TreePathNewFromString(fmt.Sprintf("%d", lIndex))
if err != nil {
promptError("Unexpected error reading data from selection: "+err.Error())
return
}
iter, err := listStore.GetIter(path)
if err != nil {
promptError("Unexpected error looking up log entry: "+err.Error())
return
}
val, err := listStore.GetValue(iter, 6)
if err != nil {
promptError("Unexpected error getting data from log entry: "+err.Error())
return
}
sval, err := val.GetString()
if err != nil {
promptError("Unexpected error reading data from log entry: "+err.Error())
return
}
fmt.Println("HEH: ", sval)
promptInfo(sval)
if seldata.Hostname != "" {
editTarget.SetText(seldata.Hostname)
} else {
editTarget.SetText(seldata.Target)
}
editPort.SetText(strconv.Itoa(seldata.Port))
ronce.SetActive(true)
rprocess.SetActive(false)
rparent.SetActive(false)
rsession.SetActive(false)
rpermanent.SetActive(false)
comboProto.SetActiveID(seldata.Proto)
return
// promptInfo(sval)
})
@ -503,7 +842,6 @@ func main() {
mainWin.Move(int(userPrefs.Winleft), int(userPrefs.Wintop))
}
// addRequest(listStore, "/bin/bla", "proto", 666, "loglevel", "provider", 23, 100, 1000)
mainWin.ShowAll()
mainWin.SetKeepAbove(true)
gtk.Main()

@ -0,0 +1,13 @@
Copyright (c) 2013-2014 Conformal Systems LLC.
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.

@ -0,0 +1,28 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// Antialias is a representation of Cairo's cairo_antialias_t.
type Antialias int
const (
ANTIALIAS_DEFAULT Antialias = C.CAIRO_ANTIALIAS_DEFAULT
ANTIALIAS_NONE Antialias = C.CAIRO_ANTIALIAS_NONE
ANTIALIAS_GRAY Antialias = C.CAIRO_ANTIALIAS_GRAY
ANTIALIAS_SUBPIXEL Antialias = C.CAIRO_ANTIALIAS_SUBPIXEL
// ANTIALIAS_FAST Antialias = C.CAIRO_ANTIALIAS_FAST (since 1.12)
// ANTIALIAS_GOOD Antialias = C.CAIRO_ANTIALIAS_GOOD (since 1.12)
// ANTIALIAS_BEST Antialias = C.CAIRO_ANTIALIAS_BEST (since 1.12)
)
func marshalAntialias(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Antialias(c), nil
}

@ -0,0 +1,65 @@
// 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.
// Package cairo implements Go bindings for Cairo. Supports version 1.10 and
// later.
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
{glib.Type(C.cairo_gobject_antialias_get_type()), marshalAntialias},
{glib.Type(C.cairo_gobject_content_get_type()), marshalContent},
{glib.Type(C.cairo_gobject_fill_rule_get_type()), marshalFillRule},
{glib.Type(C.cairo_gobject_line_cap_get_type()), marshalLineCap},
{glib.Type(C.cairo_gobject_line_join_get_type()), marshalLineJoin},
{glib.Type(C.cairo_gobject_operator_get_type()), marshalOperator},
{glib.Type(C.cairo_gobject_status_get_type()), marshalStatus},
{glib.Type(C.cairo_gobject_surface_type_get_type()), marshalSurfaceType},
// Boxed
{glib.Type(C.cairo_gobject_context_get_type()), marshalContext},
{glib.Type(C.cairo_gobject_surface_get_type()), marshalSurface},
}
glib.RegisterGValueMarshalers(tm)
}
// Constants
// Content is a representation of Cairo's cairo_content_t.
type Content int
const (
CONTENT_COLOR Content = C.CAIRO_CONTENT_COLOR
CONTENT_ALPHA Content = C.CAIRO_CONTENT_ALPHA
CONTENT_COLOR_ALPHA Content = C.CAIRO_CONTENT_COLOR_ALPHA
)
func marshalContent(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Content(c), nil
}

@ -0,0 +1,401 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"reflect"
"runtime"
"unsafe"
)
// Context is a representation of Cairo's cairo_t.
type Context struct {
context *C.cairo_t
}
// native returns a pointer to the underlying cairo_t.
func (v *Context) native() *C.cairo_t {
if v == nil {
return nil
}
return v.context
}
func (v *Context) GetCContext() *C.cairo_t {
return v.native()
}
// Native returns a pointer to the underlying cairo_t.
func (v *Context) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalContext(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
context := (*C.cairo_t)(unsafe.Pointer(c))
return wrapContext(context), nil
}
func wrapContext(context *C.cairo_t) *Context {
return &Context{context}
}
// Create is a wrapper around cairo_create().
func Create(target *Surface) *Context {
c := C.cairo_create(target.native())
ctx := wrapContext(c)
runtime.SetFinalizer(ctx, (*Context).destroy)
return ctx
}
// reference is a wrapper around cairo_reference().
func (v *Context) reference() {
v.context = C.cairo_reference(v.native())
}
// destroy is a wrapper around cairo_destroy().
func (v *Context) destroy() {
C.cairo_destroy(v.native())
}
// Status is a wrapper around cairo_status().
func (v *Context) Status() Status {
c := C.cairo_status(v.native())
return Status(c)
}
// Save is a wrapper around cairo_save().
func (v *Context) Save() {
C.cairo_save(v.native())
}
// Restore is a wrapper around cairo_restore().
func (v *Context) Restore() {
C.cairo_restore(v.native())
}
// GetTarget is a wrapper around cairo_get_target().
func (v *Context) GetTarget() *Surface {
c := C.cairo_get_target(v.native())
s := wrapSurface(c)
s.reference()
runtime.SetFinalizer(s, (*Surface).destroy)
return s
}
// PushGroup is a wrapper around cairo_push_group().
func (v *Context) PushGroup() {
C.cairo_push_group(v.native())
}
// PushGroupWithContent is a wrapper around cairo_push_group_with_content().
func (v *Context) PushGroupWithContent(content Content) {
C.cairo_push_group_with_content(v.native(), C.cairo_content_t(content))
}
// TODO(jrick) PopGroup (depends on Pattern)
// PopGroupToSource is a wrapper around cairo_pop_group_to_source().
func (v *Context) PopGroupToSource() {
C.cairo_pop_group_to_source(v.native())
}
// GetGroupTarget is a wrapper around cairo_get_group_target().
func (v *Context) GetGroupTarget() *Surface {
c := C.cairo_get_group_target(v.native())
s := wrapSurface(c)
s.reference()
runtime.SetFinalizer(s, (*Surface).destroy)
return s
}
// SetSourceRGB is a wrapper around cairo_set_source_rgb().
func (v *Context) SetSourceRGB(red, green, blue float64) {
C.cairo_set_source_rgb(v.native(), C.double(red), C.double(green),
C.double(blue))
}
// SetSourceRGBA is a wrapper around cairo_set_source_rgba().
func (v *Context) SetSourceRGBA(red, green, blue, alpha float64) {
C.cairo_set_source_rgba(v.native(), C.double(red), C.double(green),
C.double(blue), C.double(alpha))
}
// TODO(jrick) SetSource (depends on Pattern)
// SetSourceSurface is a wrapper around cairo_set_source_surface().
func (v *Context) SetSourceSurface(surface *Surface, x, y float64) {
C.cairo_set_source_surface(v.native(), surface.native(), C.double(x),
C.double(y))
}
// TODO(jrick) GetSource (depends on Pattern)
// SetAntialias is a wrapper around cairo_set_antialias().
func (v *Context) SetAntialias(antialias Antialias) {
C.cairo_set_antialias(v.native(), C.cairo_antialias_t(antialias))
}
// GetAntialias is a wrapper around cairo_get_antialias().
func (v *Context) GetAntialias() Antialias {
c := C.cairo_get_antialias(v.native())
return Antialias(c)
}
// SetDash is a wrapper around cairo_set_dash().
func (v *Context) SetDash(dashes []float64, offset float64) {
header := (*reflect.SliceHeader)(unsafe.Pointer(&dashes))
cdashes := (*C.double)(unsafe.Pointer(header.Data))
C.cairo_set_dash(v.native(), cdashes, C.int(header.Len),
C.double(offset))
}
// GetDashCount is a wrapper around cairo_get_dash_count().
func (v *Context) GetDashCount() int {
c := C.cairo_get_dash_count(v.native())
return int(c)
}
// GetDash is a wrapper around cairo_get_dash().
func (v *Context) GetDash() (dashes []float64, offset float64) {
dashCount := v.GetDashCount()
cdashes := (*C.double)(C.calloc(8, C.size_t(dashCount)))
var coffset C.double
C.cairo_get_dash(v.native(), cdashes, &coffset)
header := (*reflect.SliceHeader)((unsafe.Pointer(&dashes)))
header.Data = uintptr(unsafe.Pointer(cdashes))
header.Len = dashCount
header.Cap = dashCount
return dashes, float64(coffset)
}
// SetFillRule is a wrapper around cairo_set_fill_rule().
func (v *Context) SetFillRule(fillRule FillRule) {
C.cairo_set_fill_rule(v.native(), C.cairo_fill_rule_t(fillRule))
}
// GetFillRule is a wrapper around cairo_get_fill_rule().
func (v *Context) GetFillRule() FillRule {
c := C.cairo_get_fill_rule(v.native())
return FillRule(c)
}
// SetLineCap is a wrapper around cairo_set_line_cap().
func (v *Context) SetLineCap(lineCap LineCap) {
C.cairo_set_line_cap(v.native(), C.cairo_line_cap_t(lineCap))
}
// GetLineCap is a wrapper around cairo_get_line_cap().
func (v *Context) GetLineCap() LineCap {
c := C.cairo_get_line_cap(v.native())
return LineCap(c)
}
// SetLineJoin is a wrapper around cairo_set_line_join().
func (v *Context) SetLineJoin(lineJoin LineJoin) {
C.cairo_set_line_join(v.native(), C.cairo_line_join_t(lineJoin))
}
// GetLineJoin is a wrapper around cairo_get_line_join().
func (v *Context) GetLineJoin() LineJoin {
c := C.cairo_get_line_join(v.native())
return LineJoin(c)
}
// SetLineWidth is a wrapper around cairo_set_line_width().
func (v *Context) SetLineWidth(width float64) {
C.cairo_set_line_width(v.native(), C.double(width))
}
// GetLineWidth is a wrapper cairo_get_line_width().
func (v *Context) GetLineWidth() float64 {
c := C.cairo_get_line_width(v.native())
return float64(c)
}
// SetMiterLimit is a wrapper around cairo_set_miter_limit().
func (v *Context) SetMiterLimit(limit float64) {
C.cairo_set_miter_limit(v.native(), C.double(limit))
}
// GetMiterLimit is a wrapper around cairo_get_miter_limit().
func (v *Context) GetMiterLimit() float64 {
c := C.cairo_get_miter_limit(v.native())
return float64(c)
}
// SetOperator is a wrapper around cairo_set_operator().
func (v *Context) SetOperator(op Operator) {
C.cairo_set_operator(v.native(), C.cairo_operator_t(op))
}
// GetOperator is a wrapper around cairo_get_operator().
func (v *Context) GetOperator() Operator {
c := C.cairo_get_operator(v.native())
return Operator(c)
}
// SetTolerance is a wrapper around cairo_set_tolerance().
func (v *Context) SetTolerance(tolerance float64) {
C.cairo_set_tolerance(v.native(), C.double(tolerance))
}
// GetTolerance is a wrapper around cairo_get_tolerance().
func (v *Context) GetTolerance() float64 {
c := C.cairo_get_tolerance(v.native())
return float64(c)
}
// Clip is a wrapper around cairo_clip().
func (v *Context) Clip() {
C.cairo_clip(v.native())
}
// ClipPreserve is a wrapper around cairo_clip_preserve().
func (v *Context) ClipPreserve() {
C.cairo_clip_preserve(v.native())
}
// ClipExtents is a wrapper around cairo_clip_extents().
func (v *Context) ClipExtents() (x1, y1, x2, y2 float64) {
var cx1, cy1, cx2, cy2 C.double
C.cairo_clip_extents(v.native(), &cx1, &cy1, &cx2, &cy2)
return float64(cx1), float64(cy1), float64(cx2), float64(cy2)
}
// InClip is a wrapper around cairo_in_clip().
func (v *Context) InClip(x, y float64) bool {
c := C.cairo_in_clip(v.native(), C.double(x), C.double(y))
return gobool(c)
}
// ResetClip is a wrapper around cairo_reset_clip().
func (v *Context) ResetClip() {
C.cairo_reset_clip(v.native())
}
// Rectangle is a wrapper around cairo_rectangle().
func (v *Context) Rectangle(x, y, w, h float64) {
C.cairo_rectangle(v.native(), C.double(x), C.double(y), C.double(w), C.double(h))
}
// Arc is a wrapper around cairo_arc().
func (v *Context) Arc(xc, yc, radius, angle1, angle2 float64) {
C.cairo_arc(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2))
}
// ArcNegative is a wrapper around cairo_arc_negative().
func (v *Context) ArcNegative(xc, yc, radius, angle1, angle2 float64) {
C.cairo_arc_negative(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2))
}
// LineTo is a wrapper around cairo_line_to().
func (v *Context) LineTo(x, y float64) {
C.cairo_line_to(v.native(), C.double(x), C.double(y))
}
// CurveTo is a wrapper around cairo_curve_to().
func (v *Context) CurveTo(x1, y1, x2, y2, x3, y3 float64) {
C.cairo_curve_to(v.native(), C.double(x1), C.double(y1), C.double(x2), C.double(y2), C.double(x3), C.double(y3))
}
// MoveTo is a wrapper around cairo_move_to().
func (v *Context) MoveTo(x, y float64) {
C.cairo_move_to(v.native(), C.double(x), C.double(y))
}
// TODO(jrick) CopyRectangleList (depends on RectangleList)
// Fill is a wrapper around cairo_fill().
func (v *Context) Fill() {
C.cairo_fill(v.native())
}
// ClosePath is a wrapper around cairo_close_path().
func (v *Context) ClosePath() {
C.cairo_close_path(v.native())
}
// NewPath is a wrapper around cairo_new_path().
func (v *Context) NewPath() {
C.cairo_new_path(v.native())
}
// GetCurrentPoint is a wrapper around cairo_get_current_point().
func (v *Context) GetCurrentPoint() (x, y float64) {
C.cairo_get_current_point(v.native(), (*C.double)(&x), (*C.double)(&y))
return
}
// FillPreserve is a wrapper around cairo_fill_preserve().
func (v *Context) FillPreserve() {
C.cairo_fill_preserve(v.native())
}
// FillExtents is a wrapper around cairo_fill_extents().
func (v *Context) FillExtents() (x1, y1, x2, y2 float64) {
var cx1, cy1, cx2, cy2 C.double
C.cairo_fill_extents(v.native(), &cx1, &cy1, &cx2, &cy2)
return float64(cx1), float64(cy1), float64(cx2), float64(cy2)
}
// InFill is a wrapper around cairo_in_fill().
func (v *Context) InFill(x, y float64) bool {
c := C.cairo_in_fill(v.native(), C.double(x), C.double(y))
return gobool(c)
}
// TODO(jrick) Mask (depends on Pattern)
// MaskSurface is a wrapper around cairo_mask_surface().
func (v *Context) MaskSurface(surface *Surface, surfaceX, surfaceY float64) {
C.cairo_mask_surface(v.native(), surface.native(), C.double(surfaceX),
C.double(surfaceY))
}
// Paint is a wrapper around cairo_paint().
func (v *Context) Paint() {
C.cairo_paint(v.native())
}
// PaintWithAlpha is a wrapper around cairo_paint_with_alpha().
func (v *Context) PaintWithAlpha(alpha float64) {
C.cairo_paint_with_alpha(v.native(), C.double(alpha))
}
// Stroke is a wrapper around cairo_stroke().
func (v *Context) Stroke() {
C.cairo_stroke(v.native())
}
// StrokePreserve is a wrapper around cairo_stroke_preserve().
func (v *Context) StrokePreserve() {
C.cairo_stroke_preserve(v.native())
}
// StrokeExtents is a wrapper around cairo_stroke_extents().
func (v *Context) StrokeExtents() (x1, y1, x2, y2 float64) {
var cx1, cy1, cx2, cy2 C.double
C.cairo_stroke_extents(v.native(), &cx1, &cy1, &cx2, &cy2)
return float64(cx1), float64(cy1), float64(cx2), float64(cy2)
}
// InStroke is a wrapper around cairo_in_stroke().
func (v *Context) InStroke(x, y float64) bool {
c := C.cairo_in_stroke(v.native(), C.double(x), C.double(y))
return gobool(c)
}
// CopyPage is a wrapper around cairo_copy_page().
func (v *Context) CopyPage() {
C.cairo_copy_page(v.native())
}
// ShowPage is a wrapper around cairo_show_page().
func (v *Context) ShowPage() {
C.cairo_show_page(v.native())
}

@ -0,0 +1,7 @@
package cairo
type ErrorStatus Status
func (e ErrorStatus) Error() string {
return StatusToString(Status(e))
}

@ -0,0 +1,23 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// FillRule is a representation of Cairo's cairo_fill_rule_t.
type FillRule int
const (
FILL_RULE_WINDING FillRule = C.CAIRO_FILL_RULE_WINDING
FILL_RULE_EVEN_ODD FillRule = C.CAIRO_FILL_RULE_EVEN_ODD
)
func marshalFillRule(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return FillRule(c), nil
}

@ -0,0 +1,28 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// Format is a representation of Cairo's cairo_format_t.
type Format int
const (
FORMAT_INVALID Format = C.CAIRO_FORMAT_INVALID
FORMAT_ARGB32 Format = C.CAIRO_FORMAT_ARGB32
FORMAT_RGB24 Format = C.CAIRO_FORMAT_RGB24
FORMAT_A8 Format = C.CAIRO_FORMAT_A8
FORMAT_A1 Format = C.CAIRO_FORMAT_A1
FORMAT_RGB16_565 Format = C.CAIRO_FORMAT_RGB16_565
FORMAT_RGB30 Format = C.CAIRO_FORMAT_RGB30
)
func marshalFormat(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Format(c), nil
}

@ -0,0 +1,24 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// LineCap is a representation of Cairo's cairo_line_cap_t.
type LineCap int
const (
LINE_CAP_BUTT LineCap = C.CAIRO_LINE_CAP_BUTT
LINE_CAP_ROUND LineCap = C.CAIRO_LINE_CAP_ROUND
LINE_CAP_SQUARE LineCap = C.CAIRO_LINE_CAP_SQUARE
)
func marshalLineCap(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return LineCap(c), nil
}

@ -0,0 +1,24 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// LineJoin is a representation of Cairo's cairo_line_join_t.
type LineJoin int
const (
LINE_JOIN_MITER LineJoin = C.CAIRO_LINE_JOIN_MITER
LINE_JOIN_ROUND LineJoin = C.CAIRO_LINE_JOIN_ROUND
LINE_JOIN_BEVEL LineJoin = C.CAIRO_LINE_JOIN_BEVEL
)
func marshalLineJoin(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return LineJoin(c), nil
}

@ -0,0 +1,13 @@
package cairo
// MimeType is a representation of Cairo's CAIRO_MIME_TYPE_*
// preprocessor constants.
type MimeType string
const (
MIME_TYPE_JP2 MimeType = "image/jp2"
MIME_TYPE_JPEG MimeType = "image/jpeg"
MIME_TYPE_PNG MimeType = "image/png"
MIME_TYPE_URI MimeType = "image/x-uri"
MIME_TYPE_UNIQUE_ID MimeType = "application/x-cairo.uuid"
)

@ -0,0 +1,50 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// Operator is a representation of Cairo's cairo_operator_t.
type Operator int
const (
OPERATOR_CLEAR Operator = C.CAIRO_OPERATOR_CLEAR
OPERATOR_SOURCE Operator = C.CAIRO_OPERATOR_SOURCE
OPERATOR_OVER Operator = C.CAIRO_OPERATOR_OVER
OPERATOR_IN Operator = C.CAIRO_OPERATOR_IN
OPERATOR_OUT Operator = C.CAIRO_OPERATOR_OUT
OPERATOR_ATOP Operator = C.CAIRO_OPERATOR_ATOP
OPERATOR_DEST Operator = C.CAIRO_OPERATOR_DEST
OPERATOR_DEST_OVER Operator = C.CAIRO_OPERATOR_DEST_OVER
OPERATOR_DEST_IN Operator = C.CAIRO_OPERATOR_DEST_IN
OPERATOR_DEST_OUT Operator = C.CAIRO_OPERATOR_DEST_OUT
OPERATOR_DEST_ATOP Operator = C.CAIRO_OPERATOR_DEST_ATOP
OPERATOR_XOR Operator = C.CAIRO_OPERATOR_XOR
OPERATOR_ADD Operator = C.CAIRO_OPERATOR_ADD
OPERATOR_SATURATE Operator = C.CAIRO_OPERATOR_SATURATE
OPERATOR_MULTIPLY Operator = C.CAIRO_OPERATOR_MULTIPLY
OPERATOR_SCREEN Operator = C.CAIRO_OPERATOR_SCREEN
OPERATOR_OVERLAY Operator = C.CAIRO_OPERATOR_OVERLAY
OPERATOR_DARKEN Operator = C.CAIRO_OPERATOR_DARKEN
OPERATOR_LIGHTEN Operator = C.CAIRO_OPERATOR_LIGHTEN
OPERATOR_COLOR_DODGE Operator = C.CAIRO_OPERATOR_COLOR_DODGE
OPERATOR_COLOR_BURN Operator = C.CAIRO_OPERATOR_COLOR_BURN
OPERATOR_HARD_LIGHT Operator = C.CAIRO_OPERATOR_HARD_LIGHT
OPERATOR_SOFT_LIGHT Operator = C.CAIRO_OPERATOR_SOFT_LIGHT
OPERATOR_DIFFERENCE Operator = C.CAIRO_OPERATOR_DIFFERENCE
OPERATOR_EXCLUSION Operator = C.CAIRO_OPERATOR_EXCLUSION
OPERATOR_HSL_HUE Operator = C.CAIRO_OPERATOR_HSL_HUE
OPERATOR_HSL_SATURATION Operator = C.CAIRO_OPERATOR_HSL_SATURATION
OPERATOR_HSL_COLOR Operator = C.CAIRO_OPERATOR_HSL_COLOR
OPERATOR_HSL_LUMINOSITY Operator = C.CAIRO_OPERATOR_HSL_LUMINOSITY
)
func marshalOperator(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Operator(c), nil
}

@ -0,0 +1,109 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// Status is a representation of Cairo's cairo_status_t.
type Status int
const (
STATUS_SUCCESS Status = C.CAIRO_STATUS_SUCCESS
STATUS_NO_MEMORY Status = C.CAIRO_STATUS_NO_MEMORY
STATUS_INVALID_RESTORE Status = C.CAIRO_STATUS_INVALID_RESTORE
STATUS_INVALID_POP_GROUP Status = C.CAIRO_STATUS_INVALID_POP_GROUP
STATUS_NO_CURRENT_POINT Status = C.CAIRO_STATUS_NO_CURRENT_POINT
STATUS_INVALID_MATRIX Status = C.CAIRO_STATUS_INVALID_MATRIX
STATUS_INVALID_STATUS Status = C.CAIRO_STATUS_INVALID_STATUS
STATUS_NULL_POINTER Status = C.CAIRO_STATUS_NULL_POINTER
STATUS_INVALID_STRING Status = C.CAIRO_STATUS_INVALID_STRING
STATUS_INVALID_PATH_DATA Status = C.CAIRO_STATUS_INVALID_PATH_DATA
STATUS_READ_ERROR Status = C.CAIRO_STATUS_READ_ERROR
STATUS_WRITE_ERROR Status = C.CAIRO_STATUS_WRITE_ERROR
STATUS_SURFACE_FINISHED Status = C.CAIRO_STATUS_SURFACE_FINISHED
STATUS_SURFACE_TYPE_MISMATCH Status = C.CAIRO_STATUS_SURFACE_TYPE_MISMATCH
STATUS_PATTERN_TYPE_MISMATCH Status = C.CAIRO_STATUS_PATTERN_TYPE_MISMATCH
STATUS_INVALID_CONTENT Status = C.CAIRO_STATUS_INVALID_CONTENT
STATUS_INVALID_FORMAT Status = C.CAIRO_STATUS_INVALID_FORMAT
STATUS_INVALID_VISUAL Status = C.CAIRO_STATUS_INVALID_VISUAL
STATUS_FILE_NOT_FOUND Status = C.CAIRO_STATUS_FILE_NOT_FOUND
STATUS_INVALID_DASH Status = C.CAIRO_STATUS_INVALID_DASH
STATUS_INVALID_DSC_COMMENT Status = C.CAIRO_STATUS_INVALID_DSC_COMMENT
STATUS_INVALID_INDEX Status = C.CAIRO_STATUS_INVALID_INDEX
STATUS_CLIP_NOT_REPRESENTABLE Status = C.CAIRO_STATUS_CLIP_NOT_REPRESENTABLE
STATUS_TEMP_FILE_ERROR Status = C.CAIRO_STATUS_TEMP_FILE_ERROR
STATUS_INVALID_STRIDE Status = C.CAIRO_STATUS_INVALID_STRIDE
STATUS_FONT_TYPE_MISMATCH Status = C.CAIRO_STATUS_FONT_TYPE_MISMATCH
STATUS_USER_FONT_IMMUTABLE Status = C.CAIRO_STATUS_USER_FONT_IMMUTABLE
STATUS_USER_FONT_ERROR Status = C.CAIRO_STATUS_USER_FONT_ERROR
STATUS_NEGATIVE_COUNT Status = C.CAIRO_STATUS_NEGATIVE_COUNT
STATUS_INVALID_CLUSTERS Status = C.CAIRO_STATUS_INVALID_CLUSTERS
STATUS_INVALID_SLANT Status = C.CAIRO_STATUS_INVALID_SLANT
STATUS_INVALID_WEIGHT Status = C.CAIRO_STATUS_INVALID_WEIGHT
STATUS_INVALID_SIZE Status = C.CAIRO_STATUS_INVALID_SIZE
STATUS_USER_FONT_NOT_IMPLEMENTED Status = C.CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
STATUS_DEVICE_TYPE_MISMATCH Status = C.CAIRO_STATUS_DEVICE_TYPE_MISMATCH
STATUS_DEVICE_ERROR Status = C.CAIRO_STATUS_DEVICE_ERROR
// STATUS_INVALID_MESH_CONSTRUCTION Status = C.CAIRO_STATUS_INVALID_MESH_CONSTRUCTION (since 1.12)
// STATUS_DEVICE_FINISHED Status = C.CAIRO_STATUS_DEVICE_FINISHED (since 1.12)
)
var key_Status = map[Status]string{
STATUS_SUCCESS: "CAIRO_STATUS_SUCCESS",
STATUS_NO_MEMORY: "CAIRO_STATUS_NO_MEMORY",
STATUS_INVALID_RESTORE: "CAIRO_STATUS_INVALID_RESTORE",
STATUS_INVALID_POP_GROUP: "CAIRO_STATUS_INVALID_POP_GROUP",
STATUS_NO_CURRENT_POINT: "CAIRO_STATUS_NO_CURRENT_POINT",
STATUS_INVALID_MATRIX: "CAIRO_STATUS_INVALID_MATRIX",
STATUS_INVALID_STATUS: "CAIRO_STATUS_INVALID_STATUS",
STATUS_NULL_POINTER: "CAIRO_STATUS_NULL_POINTER",
STATUS_INVALID_STRING: "CAIRO_STATUS_INVALID_STRING",
STATUS_INVALID_PATH_DATA: "CAIRO_STATUS_INVALID_PATH_DATA",
STATUS_READ_ERROR: "CAIRO_STATUS_READ_ERROR",
STATUS_WRITE_ERROR: "CAIRO_STATUS_WRITE_ERROR",
STATUS_SURFACE_FINISHED: "CAIRO_STATUS_SURFACE_FINISHED",
STATUS_SURFACE_TYPE_MISMATCH: "CAIRO_STATUS_SURFACE_TYPE_MISMATCH",
STATUS_PATTERN_TYPE_MISMATCH: "CAIRO_STATUS_PATTERN_TYPE_MISMATCH",
STATUS_INVALID_CONTENT: "CAIRO_STATUS_INVALID_CONTENT",
STATUS_INVALID_FORMAT: "CAIRO_STATUS_INVALID_FORMAT",
STATUS_INVALID_VISUAL: "CAIRO_STATUS_INVALID_VISUAL",
STATUS_FILE_NOT_FOUND: "CAIRO_STATUS_FILE_NOT_FOUND",
STATUS_INVALID_DASH: "CAIRO_STATUS_INVALID_DASH",
STATUS_INVALID_DSC_COMMENT: "CAIRO_STATUS_INVALID_DSC_COMMENT",
STATUS_INVALID_INDEX: "CAIRO_STATUS_INVALID_INDEX",
STATUS_CLIP_NOT_REPRESENTABLE: "CAIRO_STATUS_CLIP_NOT_REPRESENTABLE",
STATUS_TEMP_FILE_ERROR: "CAIRO_STATUS_TEMP_FILE_ERROR",
STATUS_INVALID_STRIDE: "CAIRO_STATUS_INVALID_STRIDE",
STATUS_FONT_TYPE_MISMATCH: "CAIRO_STATUS_FONT_TYPE_MISMATCH",
STATUS_USER_FONT_IMMUTABLE: "CAIRO_STATUS_USER_FONT_IMMUTABLE",
STATUS_USER_FONT_ERROR: "CAIRO_STATUS_USER_FONT_ERROR",
STATUS_NEGATIVE_COUNT: "CAIRO_STATUS_NEGATIVE_COUNT",
STATUS_INVALID_CLUSTERS: "CAIRO_STATUS_INVALID_CLUSTERS",
STATUS_INVALID_SLANT: "CAIRO_STATUS_INVALID_SLANT",
STATUS_INVALID_WEIGHT: "CAIRO_STATUS_INVALID_WEIGHT",
STATUS_INVALID_SIZE: "CAIRO_STATUS_INVALID_SIZE",
STATUS_USER_FONT_NOT_IMPLEMENTED: "CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED",
STATUS_DEVICE_TYPE_MISMATCH: "CAIRO_STATUS_DEVICE_TYPE_MISMATCH",
STATUS_DEVICE_ERROR: "CAIRO_STATUS_DEVICE_ERROR",
}
func StatusToString(status Status) string {
s, ok := key_Status[status]
if !ok {
s = "CAIRO_STATUS_UNDEFINED"
}
return s
}
func marshalStatus(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Status(c), nil
}

@ -0,0 +1,215 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"runtime"
"unsafe"
)
// TODO(jrick) SetUserData (depends on UserDataKey and DestroyFunc)
// TODO(jrick) GetUserData (depends on UserDataKey)
/*
* cairo_surface_t
*/
// Surface is a representation of Cairo's cairo_surface_t.
type Surface struct {
surface *C.cairo_surface_t
}
func NewSurfaceFromPNG(fileName string) (*Surface, error) {
cstr := C.CString(fileName)
defer C.free(unsafe.Pointer(cstr))
surfaceNative := C.cairo_image_surface_create_from_png(cstr)
status := Status(C.cairo_surface_status(surfaceNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
return &Surface{surfaceNative}, nil
}
// CreateImageSurface is a wrapper around cairo_image_surface_create().
func CreateImageSurface(format Format, width, height int) *Surface {
c := C.cairo_image_surface_create(C.cairo_format_t(format),
C.int(width), C.int(height))
s := wrapSurface(c)
runtime.SetFinalizer(s, (*Surface).destroy)
return s
}
// native returns a pointer to the underlying cairo_surface_t.
func (v *Surface) native() *C.cairo_surface_t {
if v == nil {
return nil
}
return v.surface
}
// Native returns a pointer to the underlying cairo_surface_t.
func (v *Surface) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalSurface(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
surface := (*C.cairo_surface_t)(unsafe.Pointer(c))
return wrapSurface(surface), nil
}
func wrapSurface(surface *C.cairo_surface_t) *Surface {
return &Surface{surface}
}
// NewSurface creates a gotk3 cairo Surface from a pointer to a
// C cairo_surface_t. This is primarily designed for use with other
// gotk3 packages and should be avoided by applications.
func NewSurface(s uintptr, needsRef bool) *Surface {
ptr := (*C.cairo_surface_t)(unsafe.Pointer(s))
surface := wrapSurface(ptr)
if needsRef {
surface.reference()
}
runtime.SetFinalizer(surface, (*Surface).destroy)
return surface
}
// CreateSimilar is a wrapper around cairo_surface_create_similar().
func (v *Surface) CreateSimilar(content Content, width, height int) *Surface {
c := C.cairo_surface_create_similar(v.native(),
C.cairo_content_t(content), C.int(width), C.int(height))
s := wrapSurface(c)
runtime.SetFinalizer(s, (*Surface).destroy)
return s
}
// TODO cairo_surface_create_similar_image (since 1.12)
// CreateForRectangle is a wrapper around cairo_surface_create_for_rectangle().
func (v *Surface) CreateForRectangle(x, y, width, height float64) *Surface {
c := C.cairo_surface_create_for_rectangle(v.native(), C.double(x),
C.double(y), C.double(width), C.double(height))
s := wrapSurface(c)
runtime.SetFinalizer(s, (*Surface).destroy)
return s
}
// reference is a wrapper around cairo_surface_reference().
func (v *Surface) reference() {
v.surface = C.cairo_surface_reference(v.native())
}
// destroy is a wrapper around cairo_surface_destroy().
func (v *Surface) destroy() {
C.cairo_surface_destroy(v.native())
}
// Status is a wrapper around cairo_surface_status().
func (v *Surface) Status() Status {
c := C.cairo_surface_status(v.native())
return Status(c)
}
// Flush is a wrapper around cairo_surface_flush().
func (v *Surface) Flush() {
C.cairo_surface_flush(v.native())
}
// TODO(jrick) GetDevice (requires Device bindings)
// TODO(jrick) GetFontOptions (require FontOptions bindings)
// TODO(jrick) GetContent (requires Content bindings)
// MarkDirty is a wrapper around cairo_surface_mark_dirty().
func (v *Surface) MarkDirty() {
C.cairo_surface_mark_dirty(v.native())
}
// MarkDirtyRectangle is a wrapper around cairo_surface_mark_dirty_rectangle().
func (v *Surface) MarkDirtyRectangle(x, y, width, height int) {
C.cairo_surface_mark_dirty_rectangle(v.native(), C.int(x), C.int(y),
C.int(width), C.int(height))
}
// SetDeviceOffset is a wrapper around cairo_surface_set_device_offset().
func (v *Surface) SetDeviceOffset(x, y float64) {
C.cairo_surface_set_device_offset(v.native(), C.double(x), C.double(y))
}
// GetDeviceOffset is a wrapper around cairo_surface_get_device_offset().
func (v *Surface) GetDeviceOffset() (x, y float64) {
var xOffset, yOffset C.double
C.cairo_surface_get_device_offset(v.native(), &xOffset, &yOffset)
return float64(xOffset), float64(yOffset)
}
// SetFallbackResolution is a wrapper around
// cairo_surface_set_fallback_resolution().
func (v *Surface) SetFallbackResolution(xPPI, yPPI float64) {
C.cairo_surface_set_fallback_resolution(v.native(), C.double(xPPI),
C.double(yPPI))
}
// GetFallbackResolution is a wrapper around
// cairo_surface_get_fallback_resolution().
func (v *Surface) GetFallbackResolution() (xPPI, yPPI float64) {
var x, y C.double
C.cairo_surface_get_fallback_resolution(v.native(), &x, &y)
return float64(x), float64(y)
}
// GetType is a wrapper around cairo_surface_get_type().
func (v *Surface) GetType() SurfaceType {
c := C.cairo_surface_get_type(v.native())
return SurfaceType(c)
}
// TODO(jrick) SetUserData (depends on UserDataKey and DestroyFunc)
// TODO(jrick) GetUserData (depends on UserDataKey)
// CopyPage is a wrapper around cairo_surface_copy_page().
func (v *Surface) CopyPage() {
C.cairo_surface_copy_page(v.native())
}
// ShowPage is a wrapper around cairo_surface_show_page().
func (v *Surface) ShowPage() {
C.cairo_surface_show_page(v.native())
}
// HasShowTextGlyphs is a wrapper around cairo_surface_has_show_text_glyphs().
func (v *Surface) HasShowTextGlyphs() bool {
c := C.cairo_surface_has_show_text_glyphs(v.native())
return gobool(c)
}
// TODO(jrick) SetMimeData (depends on DestroyFunc)
// GetMimeData is a wrapper around cairo_surface_get_mime_data(). The
// returned mimetype data is returned as a Go byte slice.
func (v *Surface) GetMimeData(mimeType MimeType) []byte {
cstr := C.CString(string(mimeType))
defer C.free(unsafe.Pointer(cstr))
var data *C.uchar
var length C.ulong
C.cairo_surface_get_mime_data(v.native(), cstr, &data, &length)
return C.GoBytes(unsafe.Pointer(data), C.int(length))
}
// TODO(jrick) SupportsMimeType (since 1.12)
// TODO(jrick) MapToImage (since 1.12)
// TODO(jrick) UnmapImage (since 1.12)

@ -0,0 +1,46 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// SurfaceType is a representation of Cairo's cairo_surface_type_t.
type SurfaceType int
const (
SURFACE_TYPE_IMAGE SurfaceType = C.CAIRO_SURFACE_TYPE_IMAGE
SURFACE_TYPE_PDF SurfaceType = C.CAIRO_SURFACE_TYPE_PDF
SURFACE_TYPE_PS SurfaceType = C.CAIRO_SURFACE_TYPE_PS
SURFACE_TYPE_XLIB SurfaceType = C.CAIRO_SURFACE_TYPE_XLIB
SURFACE_TYPE_XCB SurfaceType = C.CAIRO_SURFACE_TYPE_XCB
SURFACE_TYPE_GLITZ SurfaceType = C.CAIRO_SURFACE_TYPE_GLITZ
SURFACE_TYPE_QUARTZ SurfaceType = C.CAIRO_SURFACE_TYPE_QUARTZ
SURFACE_TYPE_WIN32 SurfaceType = C.CAIRO_SURFACE_TYPE_WIN32
SURFACE_TYPE_BEOS SurfaceType = C.CAIRO_SURFACE_TYPE_BEOS
SURFACE_TYPE_DIRECTFB SurfaceType = C.CAIRO_SURFACE_TYPE_DIRECTFB
SURFACE_TYPE_SVG SurfaceType = C.CAIRO_SURFACE_TYPE_SVG
SURFACE_TYPE_OS2 SurfaceType = C.CAIRO_SURFACE_TYPE_OS2
SURFACE_TYPE_WIN32_PRINTING SurfaceType = C.CAIRO_SURFACE_TYPE_WIN32_PRINTING
SURFACE_TYPE_QUARTZ_IMAGE SurfaceType = C.CAIRO_SURFACE_TYPE_QUARTZ_IMAGE
SURFACE_TYPE_SCRIPT SurfaceType = C.CAIRO_SURFACE_TYPE_SCRIPT
SURFACE_TYPE_QT SurfaceType = C.CAIRO_SURFACE_TYPE_QT
SURFACE_TYPE_RECORDING SurfaceType = C.CAIRO_SURFACE_TYPE_RECORDING
SURFACE_TYPE_VG SurfaceType = C.CAIRO_SURFACE_TYPE_VG
SURFACE_TYPE_GL SurfaceType = C.CAIRO_SURFACE_TYPE_GL
SURFACE_TYPE_DRM SurfaceType = C.CAIRO_SURFACE_TYPE_DRM
SURFACE_TYPE_TEE SurfaceType = C.CAIRO_SURFACE_TYPE_TEE
SURFACE_TYPE_XML SurfaceType = C.CAIRO_SURFACE_TYPE_XML
SURFACE_TYPE_SKIA SurfaceType = C.CAIRO_SURFACE_TYPE_SKIA
SURFACE_TYPE_SUBSURFACE SurfaceType = C.CAIRO_SURFACE_TYPE_SUBSURFACE
// SURFACE_TYPE_COGL SurfaceType = C.CAIRO_SURFACE_TYPE_COGL (since 1.12)
)
func marshalSurfaceType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return SurfaceType(c), nil
}

@ -0,0 +1,127 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"unsafe"
)
// FontSlant is a representation of Cairo's cairo_font_slant_t
type FontSlant int
const (
FONT_SLANT_NORMAL FontSlant = C.CAIRO_FONT_SLANT_NORMAL
FONT_SLANT_ITALIC FontSlant = C.CAIRO_FONT_SLANT_ITALIC
FONT_SLANT_OBLIQUE FontSlant = C.CAIRO_FONT_SLANT_OBLIQUE
)
// FontWeight is a representation of Cairo's cairo_font_weight_t
type FontWeight int
const (
FONT_WEIGHT_NORMAL FontWeight = C.CAIRO_FONT_WEIGHT_NORMAL
FONT_WEIGHT_BOLD FontWeight = C.CAIRO_FONT_WEIGHT_BOLD
)
func (v *Context) SelectFontFace(family string, slant FontSlant, weight FontWeight) {
cstr := C.CString(family)
defer C.free(unsafe.Pointer(cstr))
C.cairo_select_font_face(v.native(), (*C.char)(cstr), C.cairo_font_slant_t(slant), C.cairo_font_weight_t(weight))
}
func (v *Context) SetFontSize(size float64) {
C.cairo_set_font_size(v.native(), C.double(size))
}
// TODO: cairo_set_font_matrix
// TODO: cairo_get_font_matrix
// TODO: cairo_set_font_options
// TODO: cairo_get_font_options
// TODO: cairo_set_font_face
// TODO: cairo_get_font_face
// TODO: cairo_set_scaled_font
// TODO: cairo_get_scaled_font
func (v *Context) ShowText(utf8 string) {
cstr := C.CString(utf8)
defer C.free(unsafe.Pointer(cstr))
C.cairo_show_text(v.native(), (*C.char)(cstr))
}
// TODO: cairo_show_glyphs
// TODO: cairo_show_text_glyphs
type FontExtents struct {
Ascent float64
Descent float64
Height float64
MaxXAdvance float64
MaxYAdvance float64
}
func (v *Context) FontExtents() FontExtents {
var extents C.cairo_font_extents_t
C.cairo_font_extents(v.native(), &extents)
return FontExtents{
Ascent: float64(extents.ascent),
Descent: float64(extents.descent),
Height: float64(extents.height),
MaxXAdvance: float64(extents.max_x_advance),
MaxYAdvance: float64(extents.max_y_advance),
}
}
type TextExtents struct {
XBearing float64
YBearing float64
Width float64
Height float64
XAdvance float64
YAdvance float64
}
func (v *Context) TextExtents(utf8 string) TextExtents {
cstr := C.CString(utf8)
defer C.free(unsafe.Pointer(cstr))
var extents C.cairo_text_extents_t
C.cairo_text_extents(v.native(), (*C.char)(cstr), &extents)
return TextExtents{
XBearing: float64(extents.x_bearing),
YBearing: float64(extents.y_bearing),
Width: float64(extents.width),
Height: float64(extents.height),
XAdvance: float64(extents.x_advance),
YAdvance: float64(extents.y_advance),
}
}
// TODO: cairo_glyph_extents
// TODO: cairo_toy_font_face_create
// TODO: cairo_toy_font_face_get_family
// TODO: cairo_toy_font_face_get_slant
// TODO: cairo_toy_font_face_get_weight
// TODO: cairo_glyph_allocate
// TODO: cairo_glyph_free
// TODO: cairo_text_cluster_allocate
// TODO: cairo_text_cluster_free

@ -0,0 +1,32 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
// Translate is a wrapper around cairo_translate.
func (v *Context) Translate(tx, ty float64) {
C.cairo_translate(v.native(), C.double(tx), C.double(ty))
}
// Scale is a wrapper around cairo_scale.
func (v *Context) Scale(sx, sy float64) {
C.cairo_scale(v.native(), C.double(sx), C.double(sy))
}
// Rotate is a wrapper around cairo_rotate.
func (v *Context) Rotate(angle float64) {
C.cairo_rotate(v.native(), C.double(angle))
}
// TODO: The following depend on cairo_matrix_t:
//void cairo_transform ()
//void cairo_set_matrix ()
//void cairo_get_matrix ()
//void cairo_identity_matrix ()
//void cairo_user_to_device ()
//void cairo_user_to_device_distance ()
//void cairo_device_to_user ()
//void cairo_device_to_user_distance ()

@ -0,0 +1,21 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
func cairobool(b bool) C.cairo_bool_t {
if b {
return C.cairo_bool_t(1)
}
return C.cairo_bool_t(0)
}
func gobool(b C.cairo_bool_t) bool {
if b != 0 {
return true
}
return false
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,100 @@
/*
* 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.
*/
#include <stdlib.h>
// Type Casting
static GdkAtom
toGdkAtom(void *p)
{
return ((GdkAtom)p);
}
static GdkDevice *
toGdkDevice(void *p)
{
return (GDK_DEVICE(p));
}
static GdkCursor *
toGdkCursor(void *p)
{
return (GDK_CURSOR(p));
}
static GdkDeviceManager *
toGdkDeviceManager(void *p)
{
return (GDK_DEVICE_MANAGER(p));
}
static GdkDisplay *
toGdkDisplay(void *p)
{
return (GDK_DISPLAY(p));
}
static GdkDragContext *
toGdkDragContext(void *p)
{
return (GDK_DRAG_CONTEXT(p));
}
static GdkPixbuf *
toGdkPixbuf(void *p)
{
return (GDK_PIXBUF(p));
}
static gboolean
_gdk_pixbuf_save_png(GdkPixbuf *pixbuf,
const char *filename, GError ** err, const char *compression)
{
return gdk_pixbuf_save(pixbuf, filename, "png", err, "compression", compression, NULL);
}
static gboolean
_gdk_pixbuf_save_jpeg(GdkPixbuf *pixbuf,
const char *filename, GError ** err, const char *quality)
{
return gdk_pixbuf_save(pixbuf, filename, "jpeg", err, "quality", quality, NULL);
}
static GdkPixbufLoader *
toGdkPixbufLoader(void *p)
{
return (GDK_PIXBUF_LOADER(p));
}
static GdkScreen *
toGdkScreen(void *p)
{
return (GDK_SCREEN(p));
}
static GdkVisual *
toGdkVisual(void *p)
{
return (GDK_VISUAL(p));
}
static GdkWindow *
toGdkWindow(void *p)
{
return (GDK_WINDOW(p));
}

@ -0,0 +1,34 @@
// 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 deprecated beginning with GTK 3.10,
// and should only be included in a build targeted intended to target GTK
// 3.8 or earlier. To target an earlier build build, use the build tag
// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run
// 'go build -tags gtk_3_8'.
// +build gtk_3_6 gtk_3_8
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
import "C"
// GetNScreens is a wrapper around gdk_display_get_n_screens().
func (v *Display) GetNScreens() int {
c := C.gdk_display_get_n_screens(v.native())
return int(c)
}

@ -0,0 +1,13 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
import "C"
// SupportsComposite() is a wrapper around gdk_display_supports_composite().
func (v *Display) SupportsComposite() bool {
c := C.gdk_display_supports_composite(v.native())
return gobool(c)
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,198 @@
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
// #include "gdk.go.h"
import "C"
import (
"runtime"
"unsafe"
"github.com/gotk3/gotk3/glib"
)
/*
* GdkScreen
*/
// Screen is a representation of GDK's GdkScreen.
type Screen struct {
*glib.Object
}
// native returns a pointer to the underlying GdkScreen.
func (v *Screen) native() *C.GdkScreen {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGdkScreen(p)
}
// Native returns a pointer to the underlying GdkScreen.
func (v *Screen) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalScreen(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
return &Screen{obj}, nil
}
func toScreen(s *C.GdkScreen) (*Screen, error) {
if s == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))}
return &Screen{obj}, nil
}
// GetRGBAVisual is a wrapper around gdk_screen_get_rgba_visual().
func (v *Screen) GetRGBAVisual() (*Visual, error) {
c := C.gdk_screen_get_rgba_visual(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
visual := &Visual{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return visual, nil
}
// GetSystemVisual is a wrapper around gdk_screen_get_system_visual().
func (v *Screen) GetSystemVisual() (*Visual, error) {
c := C.gdk_screen_get_system_visual(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
visual := &Visual{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return visual, nil
}
// GetWidth is a wrapper around gdk_screen_get_width().
func (v *Screen) GetWidth() int {
c := C.gdk_screen_get_width(v.native())
return int(c)
}
// GetHeight is a wrapper around gdk_screen_get_height().
func (v *Screen) GetHeight() int {
c := C.gdk_screen_get_height(v.native())
return int(c)
}
// ScreenGetDefault is a wrapper aroud gdk_screen_get_default().
func ScreenGetDefault() (*Screen, error) {
return toScreen(C.gdk_screen_get_default())
}
// IsComposited is a wrapper around gdk_screen_is_composited().
func (v *Screen) IsComposited() bool {
return gobool(C.gdk_screen_is_composited(v.native()))
}
// GetRootWindow is a wrapper around gdk_screen_get_root_window().
func (v *Screen) GetRootWindow() (*Window, error) {
return toWindow(C.gdk_screen_get_root_window(v.native()))
}
// GetDisplay is a wrapper around gdk_screen_get_display().
func (v *Screen) GetDisplay() (*Display, error) {
return toDisplay(C.gdk_screen_get_display(v.native()))
}
// GetNumber is a wrapper around gdk_screen_get_number().
func (v *Screen) GetNumber() int {
return int(C.gdk_screen_get_number(v.native()))
}
// GetWidthMM is a wrapper around gdk_screen_get_width_mm().
func (v *Screen) GetWidthMM() int {
return int(C.gdk_screen_get_width_mm(v.native()))
}
// GetHeightMM is a wrapper around gdk_screen_get_height_mm().
func (v *Screen) GetHeightMM() int {
return int(C.gdk_screen_get_height_mm(v.native()))
}
func toString(c *C.gchar) (string, error) {
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// MakeDisplayName is a wrapper around gdk_screen_make_display_name().
func (v *Screen) MakeDisplayName() (string, error) {
return toString(C.gdk_screen_make_display_name(v.native()))
}
// GetNMonitors is a wrapper around gdk_screen_get_n_monitors().
func (v *Screen) GetNMonitors() int {
return int(C.gdk_screen_get_n_monitors(v.native()))
}
// GetPrimaryMonitor is a wrapper around gdk_screen_get_primary_monitor().
func (v *Screen) GetPrimaryMonitor() int {
return int(C.gdk_screen_get_primary_monitor(v.native()))
}
// GetMonitorAtPoint is a wrapper around gdk_screen_get_monitor_at_point().
func (v *Screen) GetMonitorAtPoint(x, y int) int {
return int(C.gdk_screen_get_monitor_at_point(v.native(), C.gint(x), C.gint(y)))
}
// GetMonitorAtWindow is a wrapper around gdk_screen_get_monitor_at_window().
func (v *Screen) GetMonitorAtWindow(w *Window) int {
return int(C.gdk_screen_get_monitor_at_window(v.native(), w.native()))
}
// GetMonitorHeightMM is a wrapper around gdk_screen_get_monitor_height_mm().
func (v *Screen) GetMonitorHeightMM(m int) int {
return int(C.gdk_screen_get_monitor_height_mm(v.native(), C.gint(m)))
}
// GetMonitorWidthMM is a wrapper around gdk_screen_get_monitor_width_mm().
func (v *Screen) GetMonitorWidthMM(m int) int {
return int(C.gdk_screen_get_monitor_width_mm(v.native(), C.gint(m)))
}
// GetMonitorPlugName is a wrapper around gdk_screen_get_monitor_plug_name().
func (v *Screen) GetMonitorPlugName(m int) (string, error) {
return toString(C.gdk_screen_get_monitor_plug_name(v.native(), C.gint(m)))
}
// GetMonitorScaleFactor is a wrapper around gdk_screen_get_monitor_scale_factor().
func (v *Screen) GetMonitorScaleFactor(m int) int {
return int(C.gdk_screen_get_monitor_scale_factor(v.native(), C.gint(m)))
}
// GetResolution is a wrapper around gdk_screen_get_resolution().
func (v *Screen) GetResolution() float64 {
return float64(C.gdk_screen_get_resolution(v.native()))
}
// SetResolution is a wrapper around gdk_screen_set_resolution().
func (v *Screen) SetResolution(r float64) {
C.gdk_screen_set_resolution(v.native(), C.gdouble(r))
}
// GetActiveWindow is a wrapper around gdk_screen_get_active_window().
func (v *Screen) GetActiveWindow() (*Window, error) {
return toWindow(C.gdk_screen_get_active_window(v.native()))
}
// void gdk_screen_set_font_options ()
// gboolean gdk_screen_get_setting ()
// const cairo_font_options_t * gdk_screen_get_font_options ()
// GList * gdk_screen_get_window_stack ()
// GList * gdk_screen_list_visuals ()
// GList * gdk_screen_get_toplevel_windows ()
// void gdk_screen_get_monitor_geometry ()
// void gdk_screen_get_monitor_workarea ()

@ -0,0 +1,25 @@
// +build !linux no_x11
package gdk
func WorkspaceControlSupported() bool {
return false
}
// GetScreenNumber is a wrapper around gdk_x11_screen_get_screen_number().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetScreenNumber() int {
return -1
}
// GetNumberOfDesktops is a wrapper around gdk_x11_screen_get_number_of_desktops().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetNumberOfDesktops() uint32 {
return 0
}
// GetCurrentDesktop is a wrapper around gdk_x11_screen_get_current_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetCurrentDesktop() uint32 {
return 0
}

@ -0,0 +1,31 @@
// +build linux
// +build !no_x11
package gdk
// #cgo pkg-config: gdk-x11-3.0
// #include <gdk/gdk.h>
// #include <gdk/gdkx.h>
import "C"
func WorkspaceControlSupported() bool {
return true
}
// GetScreenNumber is a wrapper around gdk_x11_screen_get_screen_number().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetScreenNumber() int {
return int(C.gdk_x11_screen_get_screen_number(v.native()))
}
// GetNumberOfDesktops is a wrapper around gdk_x11_screen_get_number_of_desktops().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetNumberOfDesktops() uint32 {
return uint32(C.gdk_x11_screen_get_number_of_desktops(v.native()))
}
// GetCurrentDesktop is a wrapper around gdk_x11_screen_get_current_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Screen) GetCurrentDesktop() uint32 {
return uint32(C.gdk_x11_screen_get_current_desktop(v.native()))
}

@ -0,0 +1,17 @@
// +build !linux no_x11
package gdk
func (v *Window) MoveToCurrentDesktop() {
}
// GetDesktop is a wrapper around gdk_x11_window_get_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Window) GetDesktop() uint32 {
return 0
}
// MoveToDesktop is a wrapper around gdk_x11_window_move_to_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Window) MoveToDesktop(d uint32) {
}

@ -0,0 +1,27 @@
// +build linux
// +build !no_x11
package gdk
// #cgo pkg-config: gdk-x11-3.0
// #include <gdk/gdk.h>
// #include <gdk/gdkx.h>
import "C"
// MoveToCurrentDesktop is a wrapper around gdk_x11_window_move_to_current_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Window) MoveToCurrentDesktop() {
C.gdk_x11_window_move_to_current_desktop(v.native())
}
// GetDesktop is a wrapper around gdk_x11_window_get_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Window) GetDesktop() uint32 {
return uint32(C.gdk_x11_window_get_desktop(v.native()))
}
// MoveToDesktop is a wrapper around gdk_x11_window_move_to_desktop().
// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false
func (v *Window) MoveToDesktop(d uint32) {
C.gdk_x11_window_move_to_desktop(v.native(), C.guint32(d))
}

@ -0,0 +1,216 @@
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"
// Application is a representation of GApplication.
type Application struct {
*Object
}
// native() returns a pointer to the underlying GApplication.
func (v *Application) native() *C.GApplication {
if v == nil || v.GObject == nil {
return nil
}
return C.toGApplication(unsafe.Pointer(v.GObject))
}
func (v *Application) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalApplication(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapApplication(wrapObject(unsafe.Pointer(c))), nil
}
func wrapApplication(obj *Object) *Application {
return &Application{obj}
}
// ApplicationIDIsValid is a wrapper around g_application_id_is_valid().
func ApplicationIDIsValid(id string) bool {
cstr1 := (*C.gchar)(C.CString(id))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_application_id_is_valid(cstr1))
}
// ApplicationNew is a wrapper around g_application_new().
func ApplicationNew(appID string, flags ApplicationFlags) *Application {
cstr1 := (*C.gchar)(C.CString(appID))
defer C.free(unsafe.Pointer(cstr1))
c := C.g_application_new(cstr1, C.GApplicationFlags(flags))
if c == nil {
return nil
}
return wrapApplication(wrapObject(unsafe.Pointer(c)))
}
// GetApplicationID is a wrapper around g_application_get_application_id().
func (v *Application) GetApplicationID() string {
c := C.g_application_get_application_id(v.native())
return C.GoString((*C.char)(c))
}
// SetApplicationID is a wrapper around g_application_set_application_id().
func (v *Application) SetApplicationID(id string) {
cstr1 := (*C.gchar)(C.CString(id))
defer C.free(unsafe.Pointer(cstr1))
C.g_application_set_application_id(v.native(), cstr1)
}
// GetInactivityTimeout is a wrapper around g_application_get_inactivity_timeout().
func (v *Application) GetInactivityTimeout() uint {
return uint(C.g_application_get_inactivity_timeout(v.native()))
}
// SetInactivityTimeout is a wrapper around g_application_set_inactivity_timeout().
func (v *Application) SetInactivityTimeout(timeout uint) {
C.g_application_set_inactivity_timeout(v.native(), C.guint(timeout))
}
// GetFlags is a wrapper around g_application_get_flags().
func (v *Application) GetFlags() ApplicationFlags {
return ApplicationFlags(C.g_application_get_flags(v.native()))
}
// SetFlags is a wrapper around g_application_set_flags().
func (v *Application) SetFlags(flags ApplicationFlags) {
C.g_application_set_flags(v.native(), C.GApplicationFlags(flags))
}
// Only available in GLib 2.42+
// // GetResourceBasePath is a wrapper around g_application_get_resource_base_path().
// func (v *Application) GetResourceBasePath() string {
// c := C.g_application_get_resource_base_path(v.native())
// return C.GoString((*C.char)(c))
// }
// Only available in GLib 2.42+
// // SetResourceBasePath is a wrapper around g_application_set_resource_base_path().
// func (v *Application) SetResourceBasePath(bp string) {
// cstr1 := (*C.gchar)(C.CString(bp))
// defer C.free(unsafe.Pointer(cstr1))
// C.g_application_set_resource_base_path(v.native(), cstr1)
// }
// GetDbusObjectPath is a wrapper around g_application_get_dbus_object_path().
func (v *Application) GetDbusObjectPath() string {
c := C.g_application_get_dbus_object_path(v.native())
return C.GoString((*C.char)(c))
}
// GetIsRegistered is a wrapper around g_application_get_is_registered().
func (v *Application) GetIsRegistered() bool {
return gobool(C.g_application_get_is_registered(v.native()))
}
// GetIsRemote is a wrapper around g_application_get_is_remote().
func (v *Application) GetIsRemote() bool {
return gobool(C.g_application_get_is_remote(v.native()))
}
// Hold is a wrapper around g_application_hold().
func (v *Application) Hold() {
C.g_application_hold(v.native())
}
// Release is a wrapper around g_application_release().
func (v *Application) Release() {
C.g_application_release(v.native())
}
// Quit is a wrapper around g_application_quit().
func (v *Application) Quit() {
C.g_application_quit(v.native())
}
// Activate is a wrapper around g_application_activate().
func (v *Application) Activate() {
C.g_application_activate(v.native())
}
// SendNotification is a wrapper around g_application_send_notification().
func (v *Application) SendNotification(id string, notification *Notification) {
cstr1 := (*C.gchar)(C.CString(id))
defer C.free(unsafe.Pointer(cstr1))
C.g_application_send_notification(v.native(), cstr1, notification.native())
}
// WithdrawNotification is a wrapper around g_application_withdraw_notification().
func (v *Application) WithdrawNotification(id string) {
cstr1 := (*C.gchar)(C.CString(id))
defer C.free(unsafe.Pointer(cstr1))
C.g_application_withdraw_notification(v.native(), cstr1)
}
// SetDefault is a wrapper around g_application_set_default().
func (v *Application) SetDefault() {
C.g_application_set_default(v.native())
}
// ApplicationGetDefault is a wrapper around g_application_get_default().
func ApplicationGetDefault() *Application {
c := C.g_application_get_default()
if c == nil {
return nil
}
return wrapApplication(wrapObject(unsafe.Pointer(c)))
}
// MarkBusy is a wrapper around g_application_mark_busy().
func (v *Application) MarkBusy() {
C.g_application_mark_busy(v.native())
}
// UnmarkBusy is a wrapper around g_application_unmark_busy().
func (v *Application) UnmarkBusy() {
C.g_application_unmark_busy(v.native())
}
// Run is a wrapper around g_application_run().
func (v *Application) Run(args []string) int {
cargs := C.make_strings(C.int(len(args)))
defer C.destroy_strings(cargs)
for i, arg := range args {
cstr := C.CString(arg)
defer C.free(unsafe.Pointer(cstr))
C.set_string(cargs, C.int(i), (*C.char)(cstr))
}
C.set_string(cargs, C.int(len(args)), nil)
return int(C.g_application_run(v.native(), C.int(len(args)), cargs))
}
// Only available in GLib 2.44+
// // GetIsBusy is a wrapper around g_application_get_is_busy().
// func (v *Application) GetIsBusy() bool {
// return gobool(C.g_application_get_is_busy(v.native()))
// }
// void g_application_bind_busy_property ()
// void g_application_unbind_busy_property ()
// gboolean g_application_register () // requires GCancellable
// void g_application_set_action_group () // Deprecated since 2.32
// GDBusConnection * g_application_get_dbus_connection () // No support for GDBusConnection
// void g_application_open () // Needs GFile
// void g_application_add_main_option_entries () //Needs GOptionEntry
// void g_application_add_main_option () //Needs GOptionFlags and GOptionArg
// void g_application_add_option_group () // Needs GOptionGroup

@ -0,0 +1,117 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
import (
"errors"
"reflect"
"unsafe"
)
/*
* Events
*/
type SignalHandle uint
func (v *Object) connectClosure(after bool, detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) {
if len(userData) > 1 {
return 0, errors.New("userData len must be 0 or 1")
}
cstr := C.CString(detailedSignal)
defer C.free(unsafe.Pointer(cstr))
closure, err := ClosureNew(f, userData...)
if err != nil {
return 0, err
}
C._g_closure_add_finalize_notifier(closure)
c := C.g_signal_connect_closure(C.gpointer(v.native()),
(*C.gchar)(cstr), closure, gbool(after))
handle := SignalHandle(c)
// Map the signal handle to the closure.
signals[handle] = closure
return handle, nil
}
// Connect is a wrapper around g_signal_connect_closure(). f must be
// a function with a signaure matching the callback signature for
// detailedSignal. userData must either 0 or 1 elements which can
// be optionally passed to f. If f takes less arguments than it is
// passed from the GLib runtime, the extra arguments are ignored.
//
// Arguments for f must be a matching Go equivalent type for the
// C callback, or an interface type which the value may be packed in.
// If the type is not suitable, a runtime panic will occur when the
// signal is emitted.
func (v *Object) Connect(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) {
return v.connectClosure(false, detailedSignal, f, userData...)
}
// ConnectAfter is a wrapper around g_signal_connect_closure(). f must be
// a function with a signaure matching the callback signature for
// detailedSignal. userData must either 0 or 1 elements which can
// be optionally passed to f. If f takes less arguments than it is
// passed from the GLib runtime, the extra arguments are ignored.
//
// Arguments for f must be a matching Go equivalent type for the
// C callback, or an interface type which the value may be packed in.
// If the type is not suitable, a runtime panic will occur when the
// signal is emitted.
//
// The difference between Connect and ConnectAfter is that the latter
// will be invoked after the default handler, not before.
func (v *Object) ConnectAfter(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) {
return v.connectClosure(true, detailedSignal, f, userData...)
}
// ClosureNew creates a new GClosure and adds its callback function
// to the internally-maintained map. It's exported for visibility to other
// gotk3 packages and shouldn't be used in application code.
func ClosureNew(f interface{}, marshalData ...interface{}) (*C.GClosure, error) {
// Create a reflect.Value from f. This is called when the
// returned GClosure runs.
rf := reflect.ValueOf(f)
// Create closure context which points to the reflected func.
cc := closureContext{rf: rf}
// Closures can only be created from funcs.
if rf.Type().Kind() != reflect.Func {
return nil, errors.New("value is not a func")
}
if len(marshalData) > 0 {
cc.userData = reflect.ValueOf(marshalData[0])
}
c := C._g_closure_new()
// Associate the GClosure with rf. rf will be looked up in this
// map by the closure when the closure runs.
closures.Lock()
closures.m[c] = cc
closures.Unlock()
return c, nil
}
// removeClosure removes a closure from the internal closures map. This is
// needed to prevent a leak where Go code can access the closure context
// (along with rf and userdata) even after an object has been destroyed and
// the GClosure is invalidated and will never run.
//
//export removeClosure
func removeClosure(_ C.gpointer, closure *C.GClosure) {
closures.Lock()
delete(closures.m, closure)
closures.Unlock()
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,219 @@
/*
* 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.
*/
#ifndef __GLIB_GO_H__
#define __GLIB_GO_H__
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <gio/gio.h>
#define G_SETTINGS_ENABLE_BACKEND
#include <gio/gsettingsbackend.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n.h>
#include <locale.h>
/* GObject Type Casting */
static GObject *
toGObject(void *p)
{
return (G_OBJECT(p));
}
static GMenuModel *
toGMenuModel(void *p)
{
return (G_MENU_MODEL(p));
}
static GMenu *
toGMenu(void *p)
{
return (G_MENU(p));
}
static GMenuItem *
toGMenuItem(void *p)
{
return (G_MENU_ITEM(p));
}
static GNotification *
toGNotification(void *p)
{
return (G_NOTIFICATION(p));
}
static GApplication *
toGApplication(void *p)
{
return (G_APPLICATION(p));
}
static GSettings *
toGSettings(void *p)
{
return (G_SETTINGS(p));
}
static GSettingsBackend *
toGSettingsBackend(void *p)
{
return (G_SETTINGS_BACKEND(p));
}
static GType
_g_type_from_instance(gpointer instance)
{
return (G_TYPE_FROM_INSTANCE(instance));
}
/* Wrapper to avoid variable arg list */
static void
_g_object_set_one(gpointer object, const gchar *property_name, void *val)
{
g_object_set(object, property_name, *(gpointer **)val, NULL);
}
static GValue *
alloc_gvalue_list(int n)
{
GValue *valv;
valv = g_new0(GValue, n);
return (valv);
}
static void
val_list_insert(GValue *valv, int i, GValue *val)
{
valv[i] = *val;
}
/*
* GValue
*/
static GValue *
_g_value_alloc()
{
return (g_new0(GValue, 1));
}
static GValue *
_g_value_init(GType g_type)
{
GValue *value;
value = g_new0(GValue, 1);
return (g_value_init(value, g_type));
}
static gboolean
_g_is_value(GValue *val)
{
return (G_IS_VALUE(val));
}
static GType
_g_value_type(GValue *val)
{
return (G_VALUE_TYPE(val));
}
static GType
_g_value_fundamental(GType type)
{
return (G_TYPE_FUNDAMENTAL(type));
}
static GObjectClass *
_g_object_get_class (GObject *object)
{
return (G_OBJECT_GET_CLASS(object));
}
/*
* Closure support
*/
extern void goMarshal(GClosure *, GValue *, guint, GValue *, gpointer, GValue *);
static GClosure *
_g_closure_new()
{
GClosure *closure;
closure = g_closure_new_simple(sizeof(GClosure), NULL);
g_closure_set_marshal(closure, (GClosureMarshal)(goMarshal));
return (closure);
}
extern void removeClosure(gpointer, GClosure *);
static void
_g_closure_add_finalize_notifier(GClosure *closure)
{
g_closure_add_finalize_notifier(closure, NULL, removeClosure);
}
static inline guint _g_signal_new(const gchar *name) {
return g_signal_new(name,
G_TYPE_OBJECT,
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE,
1,
G_TYPE_POINTER);
}
static void init_i18n(const char *domain, const char *dir) {
setlocale(LC_ALL, "");
bindtextdomain(domain, dir);
bind_textdomain_codeset(domain, "UTF-8");
textdomain(domain);
}
static const char* localize(const char *string) {
return _(string);
}
static inline char** make_strings(int count) {
return (char**)malloc(sizeof(char*) * count);
}
static inline void destroy_strings(char** strings) {
free(strings);
}
static inline char* get_string(char** strings, int n) {
return strings[n];
}
static inline void set_string(char** strings, int n, char* str) {
strings[n] = str;
}
static inline gchar** next_gcharptr(gchar** s) { return (s+1); }
#endif

@ -0,0 +1,18 @@
//glib_extension contains definitions and functions to interface between glib/gtk/gio and go universe
package glib
import (
"reflect"
)
// Should be implemented by any class which need special conversion like
// gtk.Application -> gio.Application
type IGlibConvert interface {
// If convertion can't be done, function have to panic with a message that it can't convert to type
Convert(reflect.Type) reflect.Value
}
var (
IGlibConvertType reflect.Type
)

@ -0,0 +1,32 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0
// #include <gio/gio.h>
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
type MainContext C.GMainContext
// native returns a pointer to the underlying GMainContext.
func (v *MainContext) native() *C.GMainContext {
if v == nil {
return nil
}
return (*C.GMainContext)(v)
}
// MainContextDefault is a wrapper around g_main_context_default().
func MainContextDefault() *MainContext {
c := C.g_main_context_default()
if c == nil {
return nil
}
return (*MainContext)(c)
}
// MainDepth is a wrapper around g_main_depth().
func MainDepth() int {
return int(C.g_main_depth())
}

@ -0,0 +1,27 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0
// #include <gio/gio.h>
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
type Source C.GSource
// native returns a pointer to the underlying GSource.
func (v *Source) native() *C.GSource {
if v == nil {
return nil
}
return (*C.GSource)(v)
}
// MainCurrentSource is a wrapper around g_main_current_source().
func MainCurrentSource() *Source {
c := C.g_main_current_source()
if c == nil {
return nil
}
return (*Source)(c)
}

@ -0,0 +1,186 @@
//GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
// #include "gvariant.go.h"
//import "C"
//import "unsafe"
/*
* GVariant
*/
// IVariant is an interface type implemented by Variant and all types which embed
// an Variant. It is meant to be used as a type for function arguments which
// require GVariants or any subclasses thereof.
/* todo fix bugs
type IVariant interface {
ToGVariant() *C.GVariant
ToVariant() *Variant
}
// Variant is a representation of GLib's GVariant.
type Variant struct {
GVariant *C.GVariant
}
func (v *Variant) ToGVariant() *C.GVariant {
if v == nil {
return nil
}
return v.native()
}
func (v *Variant) ToVariant() *Variant {
return v
}
// newVariant creates a new Variant from a GVariant pointer.
func newVariant(p *C.GVariant) *Variant {
return &Variant{GVariant: p}
}
func VariantFromUnsafePointer(p unsafe.Pointer) *Variant {
return &Variant{C.toGVariant(p)}
}
// native returns a pointer to the underlying GVariant.
func (v *Variant) native() *C.GVariant {
if v == nil || v.GVariant == nil {
return nil
}
p := unsafe.Pointer(v.GVariant)
return C.toGVariant(p)
}
// Native returns a pointer to the underlying GVariant.
func (v *Variant) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
*/
//void g_variant_unref ()
//GVariant * g_variant_ref ()
//GVariant * g_variant_ref_sink ()
//gboolean g_variant_is_floating ()
//GVariant * g_variant_take_ref ()
//const GVariantType * g_variant_get_type ()
//const gchar * g_variant_get_type_string ()
//gboolean g_variant_is_of_type ()
//gboolean g_variant_is_container ()
//gint g_variant_compare ()
//GVariantClass g_variant_classify ()
//gboolean g_variant_check_format_string ()
//void g_variant_get ()
//void g_variant_get_va ()
//GVariant * g_variant_new ()
//GVariant * g_variant_new_va ()
//GVariant * g_variant_new_boolean ()
//GVariant * g_variant_new_byte ()
//GVariant * g_variant_new_int16 ()
//GVariant * g_variant_new_uint16 ()
//GVariant * g_variant_new_int32 ()
//GVariant * g_variant_new_uint32 ()
//GVariant * g_variant_new_int64 ()
//GVariant * g_variant_new_uint64 ()
//GVariant * g_variant_new_handle ()
//GVariant * g_variant_new_double ()
//GVariant * g_variant_new_string ()
//GVariant * g_variant_new_take_string ()
//GVariant * g_variant_new_printf ()
//GVariant * g_variant_new_object_path ()
//gboolean g_variant_is_object_path ()
//GVariant * g_variant_new_signature ()
//gboolean g_variant_is_signature ()
//GVariant * g_variant_new_variant ()
//GVariant * g_variant_new_strv ()
//GVariant * g_variant_new_objv ()
//GVariant * g_variant_new_bytestring ()
//GVariant * g_variant_new_bytestring_array ()
//gboolean g_variant_get_boolean ()
//guchar g_variant_get_byte ()
//gint16 g_variant_get_int16 ()
//guint16 g_variant_get_uint16 ()
//gint32 g_variant_get_int32 ()
//guint32 g_variant_get_uint32 ()
//gint64 g_variant_get_int64 ()
//guint64 g_variant_get_uint64 ()
//gint32 g_variant_get_handle ()
//gdouble g_variant_get_double ()
//const gchar * g_variant_get_string ()
//gchar * g_variant_dup_string ()
//GVariant * g_variant_get_variant ()
//const gchar ** g_variant_get_strv ()
//gchar ** g_variant_dup_strv ()
//const gchar ** g_variant_get_objv ()
//gchar ** g_variant_dup_objv ()
//const gchar * g_variant_get_bytestring ()
//gchar * g_variant_dup_bytestring ()
//const gchar ** g_variant_get_bytestring_array ()
//gchar ** g_variant_dup_bytestring_array ()
//GVariant * g_variant_new_maybe ()
//GVariant * g_variant_new_array ()
//GVariant * g_variant_new_tuple ()
//GVariant * g_variant_new_dict_entry ()
//GVariant * g_variant_new_fixed_array ()
//GVariant * g_variant_get_maybe ()
//gsize g_variant_n_children ()
//GVariant * g_variant_get_child_value ()
//void g_variant_get_child ()
//GVariant * g_variant_lookup_value ()
//gboolean g_variant_lookup ()
//gconstpointer g_variant_get_fixed_array ()
//gsize g_variant_get_size ()
//gconstpointer g_variant_get_data ()
//GBytes * g_variant_get_data_as_bytes ()
//void g_variant_store ()
//GVariant * g_variant_new_from_data ()
//GVariant * g_variant_new_from_bytes ()
//GVariant * g_variant_byteswap ()
//GVariant * g_variant_get_normal_form ()
//gboolean g_variant_is_normal_form ()
//guint g_variant_hash ()
//gboolean g_variant_equal ()
//gchar * g_variant_print ()
//GString * g_variant_print_string ()
//GVariantIter * g_variant_iter_copy ()
//void g_variant_iter_free ()
//gsize g_variant_iter_init ()
//gsize g_variant_iter_n_children ()
//GVariantIter * g_variant_iter_new ()
//GVariant * g_variant_iter_next_value ()
//gboolean g_variant_iter_next ()
//gboolean g_variant_iter_loop ()
//void g_variant_builder_unref ()
//GVariantBuilder * g_variant_builder_ref ()
//GVariantBuilder * g_variant_builder_new ()
//void g_variant_builder_init ()
//void g_variant_builder_clear ()
//void g_variant_builder_add_value ()
//void g_variant_builder_add ()
//void g_variant_builder_add_parsed ()
//GVariant * g_variant_builder_end ()
//void g_variant_builder_open ()
//void g_variant_builder_close ()
//void g_variant_dict_unref ()
//GVariantDict * g_variant_dict_ref ()
//GVariantDict * g_variant_dict_new ()
//void g_variant_dict_init ()
//void g_variant_dict_clear ()
//gboolean g_variant_dict_contains ()
//gboolean g_variant_dict_lookup ()
//GVariant * g_variant_dict_lookup_value ()
//void g_variant_dict_insert ()
//void g_variant_dict_insert_value ()
//gboolean g_variant_dict_remove ()
//GVariant * g_variant_dict_end ()
//#define G_VARIANT_PARSE_ERROR
//GVariant * g_variant_parse ()
//GVariant * g_variant_new_parsed_va ()
//GVariant * g_variant_new_parsed ()
//gchar * g_variant_parse_error_print_context ()

@ -0,0 +1,41 @@
// Same copyright and license as the rest of the files in this project
//GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
/* todo fix bugs
#ifndef __GVARIANT_GO_H__
#define __GVARIANT_GO_H__
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib/gvariant.h>
// Type Casting
static GVariant *
toGVariant(void *p)
{
return (_GVariant(p));
}
static GVariantBuilder *
toGVariantBuilder(void *p)
{
return (GVariantBuilder(p));
}
static GVariantDict *
toGVariantDict(void *p)
{
return (_GVariantDict(p));
}
static GVariantIter *
toGVariantIter(void *p)
{
return (_GVariantIter(p));
}
#endif
*/

@ -0,0 +1,54 @@
// Same copyright and license as the rest of the files in this project
// GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
// #include "gvariant.go.h"
//import "C"
//import "unsafe"
/*
* GVariantBuilder
*/
/* todo fix bugs
// VariantBuilder is a representation of GLib's VariantBuilder.
type VariantBuilder struct {
GVariantBuilder *C.GVariantBuilder
}
func (v *VariantBuilder) toGVariantBuilder() *C.GVariantBuilder {
if v == nil {
return nil
}
return v.native()
}
func (v *VariantBuilder) toVariantBuilder() *VariantBuilder {
return v
}
// newVariantBuilder creates a new VariantBuilder from a GVariantBuilder pointer.
func newVariantBuilder(p *C.GVariantBuilder) *VariantBuilder {
return &VariantBuilder{GVariantBuilder: p}
}
// native returns a pointer to the underlying GVariantBuilder.
func (v *VariantBuilder) native() *C.GVariantBuilder {
if v == nil || v.GVariantBuilder == nil {
return nil
}
p := unsafe.Pointer(v.GVariantBuilder)
return C.toGVariantBuilder(p)
}
// Native returns a pointer to the underlying GVariantBuilder.
func (v *VariantBuilder) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
*/

@ -0,0 +1,39 @@
// Same copyright and license as the rest of the files in this project
//GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
/*
* GVariantClass
*/
type VariantClass int
const (
VARIANT_CLASS_BOOLEAN VariantClass = C.G_VARIANT_CLASS_BOOLEAN //The GVariant is a boolean.
VARIANT_CLASS_BYTE VariantClass = C.G_VARIANT_CLASS_BYTE //The GVariant is a byte.
VARIANT_CLASS_INT16 VariantClass = C.G_VARIANT_CLASS_INT16 //The GVariant is a signed 16 bit integer.
VARIANT_CLASS_UINT16 VariantClass = C.G_VARIANT_CLASS_UINT16 //The GVariant is an unsigned 16 bit integer.
VARIANT_CLASS_INT32 VariantClass = C.G_VARIANT_CLASS_INT32 //The GVariant is a signed 32 bit integer.
VARIANT_CLASS_UINT32 VariantClass = C.G_VARIANT_CLASS_UINT32 //The GVariant is an unsigned 32 bit integer.
VARIANT_CLASS_INT64 VariantClass = C.G_VARIANT_CLASS_INT64 //The GVariant is a signed 64 bit integer.
VARIANT_CLASS_UINT64 VariantClass = C.G_VARIANT_CLASS_UINT64 //The GVariant is an unsigned 64 bit integer.
VARIANT_CLASS_HANDLE VariantClass = C.G_VARIANT_CLASS_HANDLE //The GVariant is a file handle index.
VARIANT_CLASS_DOUBLE VariantClass = C.G_VARIANT_CLASS_DOUBLE //The GVariant is a double precision floating point value.
VARIANT_CLASS_STRING VariantClass = C.G_VARIANT_CLASS_STRING //The GVariant is a normal string.
VARIANT_CLASS_OBJECT_PATH VariantClass = C.G_VARIANT_CLASS_OBJECT_PATH //The GVariant is a D-Bus object path string.
VARIANT_CLASS_SIGNATURE VariantClass = C.G_VARIANT_CLASS_SIGNATURE //The GVariant is a D-Bus signature string.
VARIANT_CLASS_VARIANT VariantClass = C.G_VARIANT_CLASS_VARIANT //The GVariant is a variant.
VARIANT_CLASS_MAYBE VariantClass = C.G_VARIANT_CLASS_MAYBE //The GVariant is a maybe-typed value.
VARIANT_CLASS_ARRAY VariantClass = C.G_VARIANT_CLASS_ARRAY //The GVariant is an array.
VARIANT_CLASS_TUPLE VariantClass = C.G_VARIANT_CLASS_TUPLE //The GVariant is a tuple.
VARIANT_CLASS_DICT_ENTRY VariantClass = C.G_VARIANT_CLASS_DICT_ENTRY //The GVariant is a dictionary entry.
)

@ -0,0 +1,54 @@
// Same copyright and license as the rest of the files in this project
//GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
// #include "gvariant.go.h"
//import "C"
//import "unsafe"
/*
* GVariantDict
*/
/* todo fix bugs
// VariantDict is a representation of GLib's VariantDict.
type VariantDict struct {
GVariantDict *C.GVariantDict
}
func (v *VariantDict) toGVariantDict() *C.GVariantDict {
if v == nil {
return nil
}
return v.native()
}
func (v *VariantDict) toVariantDict() *VariantDict {
return v
}
// newVariantDict creates a new VariantDict from a GVariantDict pointer.
func newVariantDict(p *C.GVariantDict) *VariantDict {
return &VariantDict{GVariantDict: p}
}
// native returns a pointer to the underlying GVariantDict.
func (v *VariantDict) native() *C.GVariantDict {
if v == nil || v.GVariantDict == nil {
return nil
}
p := unsafe.Pointer(v.GVariantDict)
return C.toGVariantDict(p)
}
// Native returns a pointer to the underlying GVariantDict.
func (v *VariantDict) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
*/

@ -0,0 +1,54 @@
// Same copyright and license as the rest of the files in this project
//GVariant : GVariant — strongly typed value datatype
// https://developer.gnome.org/glib/2.26/glib-GVariant.html
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
// #include "gvariant.go.h"
//import "C"
//import "unsafe"
/*
* GVariantIter
*/
/* todo fix bugs
// VariantIter is a representation of GLib's GVariantIter.
type VariantIter struct {
GVariantIter *C.GVariantIter
}
func (v *VariantIter) toGVariantIter() *C.GVariantIter {
if v == nil {
return nil
}
return v.native()
}
func (v *VariantIter) toVariantIter() *VariantIter {
return v
}
// newVariantIter creates a new VariantIter from a GVariantIter pointer.
func newVariantIter(p *C.GVariantIter) *VariantIter {
return &VariantIter{GVariantIter: p}
}
// native returns a pointer to the underlying GVariantIter.
func (v *VariantIter) native() *C.GVariantIter {
if v == nil || v.GVariantIter == nil {
return nil
}
p := unsafe.Pointer(v.GVariantIter)
return C.toGVariantIter(p)
}
// Native returns a pointer to the underlying GVariantIter.
func (v *VariantIter) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
*/

@ -0,0 +1,156 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
import "unsafe"
/*
* Linked Lists
*/
// List is a representation of Glib's GList.
type List struct {
list *C.struct__GList
// If set, dataWrap is called every time NthDataWrapped()
// or DataWrapped() is called to wrap raw underlying
// value into appropriate type.
dataWrap func(unsafe.Pointer) interface{}
}
func WrapList(obj uintptr) *List {
return wrapList((*C.struct__GList)(unsafe.Pointer(obj)))
}
func wrapList(obj *C.struct__GList) *List {
if obj == nil {
return nil
}
return &List{list: obj}
}
func (v *List) wrapNewHead(obj *C.struct__GList) *List {
if obj == nil {
return nil
}
return &List{
list: obj,
dataWrap: v.dataWrap,
}
}
func (v *List) Native() uintptr {
return uintptr(unsafe.Pointer(v.list))
}
func (v *List) native() *C.struct__GList {
if v == nil || v.list == nil {
return nil
}
return v.list
}
// DataWapper sets wrap functions, which is called during NthDataWrapped()
// and DataWrapped(). It's used to cast raw C data into appropriate
// Go structures and types every time that data is retreived.
func (v *List) DataWrapper(fn func(unsafe.Pointer) interface{}) {
if v == nil {
return
}
v.dataWrap = fn
}
// Append is a wrapper around g_list_append().
func (v *List) Append(data uintptr) *List {
glist := C.g_list_append(v.native(), C.gpointer(data))
return v.wrapNewHead(glist)
}
// Prepend is a wrapper around g_list_prepend().
func (v *List) Prepend(data uintptr) *List {
glist := C.g_list_prepend(v.native(), C.gpointer(data))
return v.wrapNewHead(glist)
}
// Insert is a wrapper around g_list_insert().
func (v *List) Insert(data uintptr, position int) *List {
glist := C.g_list_insert(v.native(), C.gpointer(data), C.gint(position))
return v.wrapNewHead(glist)
}
// Length is a wrapper around g_list_length().
func (v *List) Length() uint {
return uint(C.g_list_length(v.native()))
}
// nthDataRaw is a wrapper around g_list_nth_data().
func (v *List) nthDataRaw(n uint) unsafe.Pointer {
return unsafe.Pointer(C.g_list_nth_data(v.native(), C.guint(n)))
}
// Nth() is a wrapper around g_list_nth().
func (v *List) Nth(n uint) *List {
list := wrapList(C.g_list_nth(v.native(), C.guint(n)))
list.DataWrapper(v.dataWrap)
return list
}
// NthDataWrapped acts the same as g_list_nth_data(), but passes
// retrieved value before returning through wrap function, set by DataWrapper().
// If no wrap function is set, it returns raw unsafe.Pointer.
func (v *List) NthData(n uint) interface{} {
ptr := v.nthDataRaw(n)
if v.dataWrap != nil {
return v.dataWrap(ptr)
}
return ptr
}
// Free is a wrapper around g_list_free().
func (v *List) Free() {
C.g_list_free(v.native())
}
// Next is a wrapper around the next struct field
func (v *List) Next() *List {
return v.wrapNewHead(v.native().next)
}
// Previous is a wrapper around the prev struct field
func (v *List) Previous() *List {
return v.wrapNewHead(v.native().prev)
}
// dataRaw is a wrapper around the data struct field
func (v *List) dataRaw() unsafe.Pointer {
return unsafe.Pointer(v.native().data)
}
// DataWrapped acts the same as data struct field, but passes
// retrieved value before returning through wrap function, set by DataWrapper().
// If no wrap function is set, it returns raw unsafe.Pointer.
func (v *List) Data() interface{} {
ptr := v.dataRaw()
if v.dataWrap != nil {
return v.dataWrap(ptr)
}
return ptr
}
// Foreach acts the same as g_list_foreach().
// No user_data arguement is implemented because of Go clojure capabilities.
func (v *List) Foreach(fn func(item interface{})) {
for l := v; l != nil; l = l.Next() {
fn(l.Data())
}
}
// FreeFull acts the same as g_list_free_full().
// Calling list.FreeFull(fn) is equivalent to calling list.Foreach(fn) and
// list.Free() sequentially.
func (v *List) FreeFull(fn func(item interface{})) {
v.Foreach(fn)
v.Free()
}

@ -0,0 +1,333 @@
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"
// MenuModel is a representation of GMenuModel.
type MenuModel struct {
*Object
}
// native() returns a pointer to the underlying GMenuModel.
func (v *MenuModel) native() *C.GMenuModel {
if v == nil || v.GObject == nil {
return nil
}
return C.toGMenuModel(unsafe.Pointer(v.GObject))
}
func (v *MenuModel) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalMenuModel(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapMenuModel(wrapObject(unsafe.Pointer(c))), nil
}
func wrapMenuModel(obj *Object) *MenuModel {
return &MenuModel{obj}
}
// IsMutable is a wrapper around g_menu_model_is_mutable().
func (v *MenuModel) IsMutable() bool {
return gobool(C.g_menu_model_is_mutable(v.native()))
}
// GetNItems is a wrapper around g_menu_model_get_n_items().
func (v *MenuModel) GetNItems() int {
return int(C.g_menu_model_get_n_items(v.native()))
}
// GetItemLink is a wrapper around g_menu_model_get_item_link().
func (v *MenuModel) GetItemLink(index int, link string) *MenuModel {
cstr := (*C.gchar)(C.CString(link))
defer C.free(unsafe.Pointer(cstr))
c := C.g_menu_model_get_item_link(v.native(), C.gint(index), cstr)
if c == nil {
return nil
}
return wrapMenuModel(wrapObject(unsafe.Pointer(c)))
}
// ItemsChanged is a wrapper around g_menu_model_items_changed().
func (v *MenuModel) ItemsChanged(position, removed, added int) {
C.g_menu_model_items_changed(v.native(), C.gint(position), C.gint(removed), C.gint(added))
}
// GVariant * g_menu_model_get_item_attribute_value ()
// gboolean g_menu_model_get_item_attribute ()
// GMenuAttributeIter * g_menu_model_iterate_item_attributes ()
// GMenuLinkIter * g_menu_model_iterate_item_links ()
// Menu is a representation of GMenu.
type Menu struct {
MenuModel
}
// native() returns a pointer to the underlying GMenu.
func (m *Menu) native() *C.GMenu {
if m == nil || m.GObject == nil {
return nil
}
p := unsafe.Pointer(m.GObject)
return C.toGMenu(p)
}
func marshalMenu(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapMenu(wrapObject(unsafe.Pointer(c))), nil
}
func wrapMenu(obj *Object) *Menu {
return &Menu{MenuModel{obj}}
}
// MenuNew is a wrapper around g_menu_new().
func MenuNew() *Menu {
c := C.g_menu_new()
if c == nil {
return nil
}
return wrapMenu(wrapObject(unsafe.Pointer(c)))
}
// Freeze is a wrapper around g_menu_freeze().
func (v *Menu) Freeze() {
C.g_menu_freeze(v.native())
}
// Insert is a wrapper around g_menu_insert().
func (v *Menu) Insert(position int, label, detailed_action string) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(detailed_action))
defer C.free(unsafe.Pointer(cstr2))
C.g_menu_insert(v.native(), C.gint(position), cstr1, cstr2)
}
// Prepend is a wrapper around g_menu_prepend().
func (v *Menu) Prepend(label, detailed_action string) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(detailed_action))
defer C.free(unsafe.Pointer(cstr2))
C.g_menu_prepend(v.native(), cstr1, cstr2)
}
// Append is a wrapper around g_menu_append().
func (v *Menu) Append(label, detailed_action string) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(detailed_action))
defer C.free(unsafe.Pointer(cstr2))
C.g_menu_append(v.native(), cstr1, cstr2)
}
// InsertItem is a wrapper around g_menu_insert_item().
func (v *Menu) InsertItem(position int, item *MenuItem) {
C.g_menu_insert_item(v.native(), C.gint(position), item.native())
}
// AppendItem is a wrapper around g_menu_append_item().
func (v *Menu) AppendItem(item *MenuItem) {
C.g_menu_append_item(v.native(), item.native())
}
// PrependItem is a wrapper around g_menu_prepend_item().
func (v *Menu) PrependItem(item *MenuItem) {
C.g_menu_prepend_item(v.native(), item.native())
}
// InsertSection is a wrapper around g_menu_insert_section().
func (v *Menu) InsertSection(position int, label string, section *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_insert_section(v.native(), C.gint(position), cstr1, section.native())
}
// PrependSection is a wrapper around g_menu_prepend_section().
func (v *Menu) PrependSection(label string, section *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_prepend_section(v.native(), cstr1, section.native())
}
// AppendSection is a wrapper around g_menu_append_section().
func (v *Menu) AppendSection(label string, section *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_append_section(v.native(), cstr1, section.native())
}
// InsertSubmenu is a wrapper around g_menu_insert_submenu().
func (v *Menu) InsertSubmenu(position int, label string, submenu *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_insert_submenu(v.native(), C.gint(position), cstr1, submenu.native())
}
// PrependSubmenu is a wrapper around g_menu_prepend_submenu().
func (v *Menu) PrependSubmenu(label string, submenu *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_prepend_submenu(v.native(), cstr1, submenu.native())
}
// AppendSubmenu is a wrapper around g_menu_append_submenu().
func (v *Menu) AppendSubmenu(label string, submenu *MenuModel) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_append_submenu(v.native(), cstr1, submenu.native())
}
// Remove is a wrapper around g_menu_remove().
func (v *Menu) Remove(position int) {
C.g_menu_remove(v.native(), C.gint(position))
}
// RemoveAll is a wrapper around g_menu_remove_all().
func (v *Menu) RemoveAll() {
C.g_menu_remove_all(v.native())
}
// MenuItem is a representation of GMenuItem.
type MenuItem struct {
*Object
}
// native() returns a pointer to the underlying GMenuItem.
func (m *MenuItem) native() *C.GMenuItem {
if m == nil || m.GObject == nil {
return nil
}
p := unsafe.Pointer(m.GObject)
return C.toGMenuItem(p)
}
func marshalMenuItem(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil
}
func wrapMenuItem(obj *Object) *MenuItem {
return &MenuItem{obj}
}
// MenuItemNew is a wrapper around g_menu_item_new().
func MenuItemNew(label, detailed_action string) *MenuItem {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(detailed_action))
defer C.free(unsafe.Pointer(cstr2))
c := C.g_menu_item_new(cstr1, cstr2)
if c == nil {
return nil
}
return wrapMenuItem(wrapObject(unsafe.Pointer(c)))
}
// MenuItemNewSection is a wrapper around g_menu_item_new_section().
func MenuItemNewSection(label string, section *MenuModel) *MenuItem {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
c := C.g_menu_item_new_section(cstr1, section.native())
if c == nil {
return nil
}
return wrapMenuItem(wrapObject(unsafe.Pointer(c)))
}
// MenuItemNewSubmenu is a wrapper around g_menu_item_new_submenu().
func MenuItemNewSubmenu(label string, submenu *MenuModel) *MenuItem {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
c := C.g_menu_item_new_submenu(cstr1, submenu.native())
if c == nil {
return nil
}
return wrapMenuItem(wrapObject(unsafe.Pointer(c)))
}
// MenuItemNewFromModel is a wrapper around g_menu_item_new_from_model().
func MenuItemNewFromModel(model *MenuModel, index int) *MenuItem {
c := C.g_menu_item_new_from_model(model.native(), C.gint(index))
if c == nil {
return nil
}
return wrapMenuItem(wrapObject(unsafe.Pointer(c)))
}
//SetLabel is a wrapper around g_menu_item_set_label().
func (v *MenuItem) SetLabel(label string) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_item_set_label(v.native(), cstr1)
}
//SetDetailedAction is a wrapper around g_menu_item_set_detailed_action().
func (v *MenuItem) SetDetailedAction(act string) {
cstr1 := (*C.gchar)(C.CString(act))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_item_set_detailed_action(v.native(), cstr1)
}
//SetSection is a wrapper around g_menu_item_set_section().
func (v *MenuItem) SetSection(section *MenuModel) {
C.g_menu_item_set_section(v.native(), section.native())
}
//SetSubmenu is a wrapper around g_menu_item_set_submenu().
func (v *MenuItem) SetSubmenu(submenu *MenuModel) {
C.g_menu_item_set_submenu(v.native(), submenu.native())
}
//GetLink is a wrapper around g_menu_item_get_link().
func (v *MenuItem) GetLink(link string) *MenuModel {
cstr1 := (*C.gchar)(C.CString(link))
defer C.free(unsafe.Pointer(cstr1))
c := C.g_menu_item_get_link(v.native(), cstr1)
if c == nil {
return nil
}
return wrapMenuModel(wrapObject(unsafe.Pointer(c)))
}
//SetLink is a wrapper around g_menu_item_Set_link().
func (v *MenuItem) SetLink(link string, model *MenuModel) {
cstr1 := (*C.gchar)(C.CString(link))
defer C.free(unsafe.Pointer(cstr1))
C.g_menu_item_set_link(v.native(), cstr1, model.native())
}
// void g_menu_item_set_action_and_target_value ()
// void g_menu_item_set_action_and_target ()
// GVariant * g_menu_item_get_attribute_value ()
// gboolean g_menu_item_get_attribute ()
// void g_menu_item_set_attribute_value ()
// void g_menu_item_set_attribute ()

@ -0,0 +1,106 @@
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"
// Only available from 2.42
// // NotificationPriority is a representation of GLib's GNotificationPriority.
// type NotificationPriority int
// const (
// NOTIFICATION_PRIORITY_NORMAL NotificationPriority = C.G_NOTIFICATION_PRIORITY_NORMAL
// NOTIFICATION_PRIORITY_LOW NotificationPriority = C.G_NOTIFICATION_PRIORITY_LOW
// NOTIFICATION_PRIORITY_HIGH NotificationPriority = C.G_NOTIFICATION_PRIORITY_HIGH
// NOTIFICATION_PRIORITY_URGENT NotificationPriority = C.G_NOTIFICATION_PRIORITY_URGENT
// )
// Notification is a representation of GNotification.
type Notification struct {
*Object
}
// native() returns a pointer to the underlying GNotification.
func (v *Notification) native() *C.GNotification {
if v == nil || v.GObject == nil {
return nil
}
return C.toGNotification(unsafe.Pointer(v.GObject))
}
func (v *Notification) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalNotification(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapNotification(wrapObject(unsafe.Pointer(c))), nil
}
func wrapNotification(obj *Object) *Notification {
return &Notification{obj}
}
// NotificationNew is a wrapper around g_notification_new().
func NotificationNew(title string) *Notification {
cstr1 := (*C.gchar)(C.CString(title))
defer C.free(unsafe.Pointer(cstr1))
c := C.g_notification_new(cstr1)
if c == nil {
return nil
}
return wrapNotification(wrapObject(unsafe.Pointer(c)))
}
// SetTitle is a wrapper around g_notification_set_title().
func (v *Notification) SetTitle(title string) {
cstr1 := (*C.gchar)(C.CString(title))
defer C.free(unsafe.Pointer(cstr1))
C.g_notification_set_title(v.native(), cstr1)
}
// SetBody is a wrapper around g_notification_set_body().
func (v *Notification) SetBody(body string) {
cstr1 := (*C.gchar)(C.CString(body))
defer C.free(unsafe.Pointer(cstr1))
C.g_notification_set_body(v.native(), cstr1)
}
// Only available from 2.42
// // SetPriority is a wrapper around g_notification_set_priority().
// func (v *Notification) SetPriority(prio NotificationPriority) {
// C.g_notification_set_priority(v.native(), C.GNotificationPriority(prio))
// }
// SetDefaultAction is a wrapper around g_notification_set_default_action().
func (v *Notification) SetDefaultAction(detailedAction string) {
cstr1 := (*C.gchar)(C.CString(detailedAction))
defer C.free(unsafe.Pointer(cstr1))
C.g_notification_set_default_action(v.native(), cstr1)
}
// AddButton is a wrapper around g_notification_add_button().
func (v *Notification) AddButton(label, detailedAction string) {
cstr1 := (*C.gchar)(C.CString(label))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(detailedAction))
defer C.free(unsafe.Pointer(cstr2))
C.g_notification_add_button(v.native(), cstr1, cstr2)
}
// void g_notification_set_default_action_and_target () // requires varargs
// void g_notification_set_default_action_and_target_value () // requires variant
// void g_notification_add_button_with_target () // requires varargs
// void g_notification_add_button_with_target_value () //requires variant
// void g_notification_set_urgent () // Deprecated, so not implemented
// void g_notification_set_icon () // Requires support for GIcon, which we don't have yet.

@ -0,0 +1,277 @@
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"
// Settings is a representation of GSettings.
type Settings struct {
*Object
}
// native() returns a pointer to the underlying GSettings.
func (v *Settings) native() *C.GSettings {
if v == nil || v.GObject == nil {
return nil
}
return C.toGSettings(unsafe.Pointer(v.GObject))
}
func (v *Settings) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalSettings(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapSettings(wrapObject(unsafe.Pointer(c))), nil
}
func wrapSettings(obj *Object) *Settings {
return &Settings{obj}
}
func wrapFullSettings(obj *C.GSettings) *Settings {
if obj == nil {
return nil
}
return wrapSettings(wrapObject(unsafe.Pointer(obj)))
}
// SettingsNew is a wrapper around g_settings_new().
func SettingsNew(schemaID string) *Settings {
cstr := (*C.gchar)(C.CString(schemaID))
defer C.free(unsafe.Pointer(cstr))
return wrapFullSettings(C.g_settings_new(cstr))
}
// SettingsNewWithPath is a wrapper around g_settings_new_with_path().
func SettingsNewWithPath(schemaID, path string) *Settings {
cstr1 := (*C.gchar)(C.CString(schemaID))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(path))
defer C.free(unsafe.Pointer(cstr2))
return wrapFullSettings(C.g_settings_new_with_path(cstr1, cstr2))
}
// SettingsNewWithBackend is a wrapper around g_settings_new_with_backend().
func SettingsNewWithBackend(schemaID string, backend *SettingsBackend) *Settings {
cstr1 := (*C.gchar)(C.CString(schemaID))
defer C.free(unsafe.Pointer(cstr1))
return wrapFullSettings(C.g_settings_new_with_backend(cstr1, backend.native()))
}
// SettingsNewWithBackendAndPath is a wrapper around g_settings_new_with_backend_and_path().
func SettingsNewWithBackendAndPath(schemaID string, backend *SettingsBackend, path string) *Settings {
cstr1 := (*C.gchar)(C.CString(schemaID))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(path))
defer C.free(unsafe.Pointer(cstr2))
return wrapFullSettings(C.g_settings_new_with_backend_and_path(cstr1, backend.native(), cstr2))
}
// SettingsNewFull is a wrapper around g_settings_new_full().
func SettingsNewFull(schema *SettingsSchema, backend *SettingsBackend, path string) *Settings {
cstr1 := (*C.gchar)(C.CString(path))
defer C.free(unsafe.Pointer(cstr1))
return wrapFullSettings(C.g_settings_new_full(schema.native(), backend.native(), cstr1))
}
// SettingsSync is a wrapper around g_settings_sync().
func SettingsSync() {
C.g_settings_sync()
}
// IsWritable is a wrapper around g_settings_is_writable().
func (v *Settings) IsWritable(name string) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_is_writable(v.native(), cstr1))
}
// Delay is a wrapper around g_settings_delay().
func (v *Settings) Delay() {
C.g_settings_delay(v.native())
}
// Apply is a wrapper around g_settings_apply().
func (v *Settings) Apply() {
C.g_settings_apply(v.native())
}
// Revert is a wrapper around g_settings_revert().
func (v *Settings) Revert() {
C.g_settings_revert(v.native())
}
// GetHasUnapplied is a wrapper around g_settings_get_has_unapplied().
func (v *Settings) GetHasUnapplied() bool {
return gobool(C.g_settings_get_has_unapplied(v.native()))
}
// GetChild is a wrapper around g_settings_get_child().
func (v *Settings) GetChild(name string) *Settings {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return wrapFullSettings(C.g_settings_get_child(v.native(), cstr1))
}
// Reset is a wrapper around g_settings_reset().
func (v *Settings) Reset(name string) {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
C.g_settings_reset(v.native(), cstr1)
}
// ListChildren is a wrapper around g_settings_list_children().
func (v *Settings) ListChildren() []string {
return toGoStringArray(C.g_settings_list_children(v.native()))
}
// GetBoolean is a wrapper around g_settings_get_boolean().
func (v *Settings) GetBoolean(name string) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_get_boolean(v.native(), cstr1))
}
// SetBoolean is a wrapper around g_settings_set_boolean().
func (v *Settings) SetBoolean(name string, value bool) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_boolean(v.native(), cstr1, gbool(value)))
}
// GetInt is a wrapper around g_settings_get_int().
func (v *Settings) GetInt(name string) int {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return int(C.g_settings_get_int(v.native(), cstr1))
}
// SetInt is a wrapper around g_settings_set_int().
func (v *Settings) SetInt(name string, value int) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_int(v.native(), cstr1, C.gint(value)))
}
// GetUInt is a wrapper around g_settings_get_uint().
func (v *Settings) GetUInt(name string) uint {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return uint(C.g_settings_get_uint(v.native(), cstr1))
}
// SetUInt is a wrapper around g_settings_set_uint().
func (v *Settings) SetUInt(name string, value uint) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_uint(v.native(), cstr1, C.guint(value)))
}
// GetDouble is a wrapper around g_settings_get_double().
func (v *Settings) GetDouble(name string) float64 {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return float64(C.g_settings_get_double(v.native(), cstr1))
}
// SetDouble is a wrapper around g_settings_set_double().
func (v *Settings) SetDouble(name string, value float64) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_double(v.native(), cstr1, C.gdouble(value)))
}
// GetString is a wrapper around g_settings_get_string().
func (v *Settings) GetString(name string) string {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return C.GoString((*C.char)(C.g_settings_get_string(v.native(), cstr1)))
}
// SetString is a wrapper around g_settings_set_string().
func (v *Settings) SetString(name string, value string) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(value))
defer C.free(unsafe.Pointer(cstr2))
return gobool(C.g_settings_set_string(v.native(), cstr1, cstr2))
}
// GetEnum is a wrapper around g_settings_get_enum().
func (v *Settings) GetEnum(name string) int {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return int(C.g_settings_get_enum(v.native(), cstr1))
}
// SetEnum is a wrapper around g_settings_set_enum().
func (v *Settings) SetEnum(name string, value int) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_enum(v.native(), cstr1, C.gint(value)))
}
// GetFlags is a wrapper around g_settings_get_flags().
func (v *Settings) GetFlags(name string) uint {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return uint(C.g_settings_get_flags(v.native(), cstr1))
}
// SetFlags is a wrapper around g_settings_set_flags().
func (v *Settings) SetFlags(name string, value uint) bool {
cstr1 := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr1))
return gobool(C.g_settings_set_flags(v.native(), cstr1, C.guint(value)))
}
// GVariant * g_settings_get_value ()
// gboolean g_settings_set_value ()
// GVariant * g_settings_get_user_value ()
// GVariant * g_settings_get_default_value ()
// const gchar * const * g_settings_list_schemas ()
// const gchar * const * g_settings_list_relocatable_schemas ()
// gchar ** g_settings_list_keys ()
// GVariant * g_settings_get_range ()
// gboolean g_settings_range_check ()
// void g_settings_get ()
// gboolean g_settings_set ()
// gpointer g_settings_get_mapped ()
// void g_settings_bind ()
// void g_settings_bind_with_mapping ()
// void g_settings_bind_writable ()
// void g_settings_unbind ()
// gaction * g_settings_create_action ()
// gchar ** g_settings_get_strv ()
// gboolean g_settings_set_strv ()

@ -0,0 +1,71 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
import "unsafe"
// SettingsBackend is a representation of GSettingsBackend.
type SettingsBackend struct {
*Object
}
// native() returns a pointer to the underlying GSettingsBackend.
func (v *SettingsBackend) native() *C.GSettingsBackend {
if v == nil || v.GObject == nil {
return nil
}
return C.toGSettingsBackend(unsafe.Pointer(v.GObject))
}
func (v *SettingsBackend) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalSettingsBackend(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapSettingsBackend(wrapObject(unsafe.Pointer(c))), nil
}
func wrapSettingsBackend(obj *Object) *SettingsBackend {
return &SettingsBackend{obj}
}
// SettingsBackendGetDefault is a wrapper around g_settings_backend_get_default().
func SettingsBackendGetDefault() *SettingsBackend {
return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_settings_backend_get_default())))
}
// KeyfileSettingsBackendNew is a wrapper around g_keyfile_settings_backend_new().
func KeyfileSettingsBackendNew(filename, rootPath, rootGroup string) *SettingsBackend {
cstr1 := (*C.gchar)(C.CString(filename))
defer C.free(unsafe.Pointer(cstr1))
cstr2 := (*C.gchar)(C.CString(rootPath))
defer C.free(unsafe.Pointer(cstr2))
cstr3 := (*C.gchar)(C.CString(rootGroup))
defer C.free(unsafe.Pointer(cstr3))
return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_keyfile_settings_backend_new(cstr1, cstr2, cstr3))))
}
// MemorySettingsBackendNew is a wrapper around g_memory_settings_backend_new().
func MemorySettingsBackendNew() *SettingsBackend {
return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_memory_settings_backend_new())))
}
// NullSettingsBackendNew is a wrapper around g_null_settings_backend_new().
func NullSettingsBackendNew() *SettingsBackend {
return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_null_settings_backend_new())))
}
// void g_settings_backend_changed ()
// void g_settings_backend_path_changed ()
// void g_settings_backend_keys_changed ()
// void g_settings_backend_path_writable_changed ()
// void g_settings_backend_writable_changed ()
// void g_settings_backend_changed_tree ()
// void g_settings_backend_flatten_tree ()

@ -0,0 +1,96 @@
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"
// SettingsSchema is a representation of GSettingsSchema.
type SettingsSchema struct {
schema *C.GSettingsSchema
}
func wrapSettingsSchema(obj *C.GSettingsSchema) *SettingsSchema {
if obj == nil {
return nil
}
return &SettingsSchema{obj}
}
func (v *SettingsSchema) Native() uintptr {
return uintptr(unsafe.Pointer(v.schema))
}
func (v *SettingsSchema) native() *C.GSettingsSchema {
if v == nil || v.schema == nil {
return nil
}
return v.schema
}
// Ref() is a wrapper around g_settings_schema_ref().
func (v *SettingsSchema) Ref() *SettingsSchema {
return wrapSettingsSchema(C.g_settings_schema_ref(v.native()))
}
// Unref() is a wrapper around g_settings_schema_unref().
func (v *SettingsSchema) Unref() {
C.g_settings_schema_unref(v.native())
}
// GetID() is a wrapper around g_settings_schema_get_id().
func (v *SettingsSchema) GetID() string {
return C.GoString((*C.char)(C.g_settings_schema_get_id(v.native())))
}
// GetPath() is a wrapper around g_settings_schema_get_path().
func (v *SettingsSchema) GetPath() string {
return C.GoString((*C.char)(C.g_settings_schema_get_path(v.native())))
}
// HasKey() is a wrapper around g_settings_schema_has_key().
func (v *SettingsSchema) HasKey(v1 string) bool {
cstr := (*C.gchar)(C.CString(v1))
defer C.free(unsafe.Pointer(cstr))
return gobool(C.g_settings_schema_has_key(v.native(), cstr))
}
func toGoStringArray(c **C.gchar) []string {
var strs []string
originalc := c
defer C.g_strfreev(originalc)
for *c != nil {
strs = append(strs, C.GoString((*C.char)(*c)))
c = C.next_gcharptr(c)
}
return strs
}
// // ListChildren() is a wrapper around g_settings_schema_list_children().
// func (v *SettingsSchema) ListChildren() []string {
// return toGoStringArray(C.g_settings_schema_list_children(v.native()))
// }
// // ListKeys() is a wrapper around g_settings_schema_list_keys().
// func (v *SettingsSchema) ListKeys() []string {
// return toGoStringArray(C.g_settings_schema_list_keys(v.native()))
// }
// const GVariantType * g_settings_schema_key_get_value_type ()
// GVariant * g_settings_schema_key_get_default_value ()
// GVariant * g_settings_schema_key_get_range ()
// gboolean g_settings_schema_key_range_check ()
// const gchar * g_settings_schema_key_get_name ()
// const gchar * g_settings_schema_key_get_summary ()
// const gchar * g_settings_schema_key_get_description ()
// GSettingsSchemaKey * g_settings_schema_get_key ()
// GSettingsSchemaKey * g_settings_schema_key_ref ()
// void g_settings_schema_key_unref ()

@ -0,0 +1,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)
}

@ -0,0 +1,71 @@
package glib
// #cgo pkg-config: glib-2.0 gobject-2.0
// #include <glib.h>
// #include <glib-object.h>
// #include "glib.go.h"
import "C"
import "unsafe"
// SList is a representation of Glib's GSList.
type SList struct {
list *C.struct__GSList
}
func WrapSList(obj uintptr) *SList {
return wrapSList((*C.struct__GSList)(unsafe.Pointer(obj)))
}
func wrapSList(obj *C.struct__GSList) *SList {
return &SList{obj}
}
func (v *SList) Native() uintptr {
return uintptr(unsafe.Pointer(v.list))
}
func (v *SList) native() *C.struct__GSList {
if v == nil || v.list == nil {
return nil
}
return v.list
}
func (v *SList) Append(data uintptr) *SList {
ret := C.g_slist_append(v.native(), C.gpointer(data))
if ret == v.native() {
return v
} else {
return wrapSList(ret)
}
}
// GSList * g_slist_alloc ()
// GSList * g_slist_prepend ()
// GSList * g_slist_insert ()
// GSList * g_slist_insert_before ()
// GSList * g_slist_insert_sorted ()
// GSList * g_slist_remove ()
// GSList * g_slist_remove_link ()
// GSList * g_slist_delete_link ()
// GSList * g_slist_remove_all ()
// void g_slist_free ()
// void g_slist_free_full ()
// void g_slist_free_1 ()
// guint g_slist_length ()
// GSList * g_slist_copy ()
// GSList * g_slist_copy_deep ()
// GSList * g_slist_reverse ()
// GSList * g_slist_insert_sorted_with_data ()
// GSList * g_slist_sort ()
// GSList * g_slist_sort_with_data ()
// GSList * g_slist_concat ()
// void g_slist_foreach ()
// GSList * g_slist_last ()
// #define g_slist_next()
// GSList * g_slist_nth ()
// gpointer g_slist_nth_data ()
// GSList * g_slist_find ()
// GSList * g_slist_find_custom ()
// gint g_slist_position ()
// gint g_slist_index ()

@ -0,0 +1,313 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_about_dialog_get_type()), marshalAboutDialog},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkAboutDialog"] = wrapAboutDialog
}
/*
* GtkAboutDialog
*/
// AboutDialog is a representation of GTK's GtkAboutDialog.
type AboutDialog struct {
Dialog
}
// native returns a pointer to the underlying GtkAboutDialog.
func (v *AboutDialog) native() *C.GtkAboutDialog {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAboutDialog(p)
}
func marshalAboutDialog(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapAboutDialog(obj), nil
}
func wrapAboutDialog(obj *glib.Object) *AboutDialog {
return &AboutDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}}
}
// AboutDialogNew is a wrapper around gtk_about_dialog_new().
func AboutDialogNew() (*AboutDialog, error) {
c := C.gtk_about_dialog_new()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapAboutDialog(obj), nil
}
// GetComments is a wrapper around gtk_about_dialog_get_comments().
func (v *AboutDialog) GetComments() string {
c := C.gtk_about_dialog_get_comments(v.native())
return C.GoString((*C.char)(c))
}
// SetComments is a wrapper around gtk_about_dialog_set_comments().
func (v *AboutDialog) SetComments(comments string) {
cstr := C.CString(comments)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_comments(v.native(), (*C.gchar)(cstr))
}
// GetCopyright is a wrapper around gtk_about_dialog_get_copyright().
func (v *AboutDialog) GetCopyright() string {
c := C.gtk_about_dialog_get_copyright(v.native())
return C.GoString((*C.char)(c))
}
// SetCopyright is a wrapper around gtk_about_dialog_set_copyright().
func (v *AboutDialog) SetCopyright(copyright string) {
cstr := C.CString(copyright)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_copyright(v.native(), (*C.gchar)(cstr))
}
// GetLicense is a wrapper around gtk_about_dialog_get_license().
func (v *AboutDialog) GetLicense() string {
c := C.gtk_about_dialog_get_license(v.native())
return C.GoString((*C.char)(c))
}
// SetLicense is a wrapper around gtk_about_dialog_set_license().
func (v *AboutDialog) SetLicense(license string) {
cstr := C.CString(license)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_license(v.native(), (*C.gchar)(cstr))
}
// GetLicenseType is a wrapper around gtk_about_dialog_get_license_type().
func (v *AboutDialog) GetLicenseType() License {
c := C.gtk_about_dialog_get_license_type(v.native())
return License(c)
}
// SetLicenseType is a wrapper around gtk_about_dialog_set_license_type().
func (v *AboutDialog) SetLicenseType(license License) {
C.gtk_about_dialog_set_license_type(v.native(), C.GtkLicense(license))
}
// SetLogo is a wrapper around gtk_about_dialog_set_logo().
func (v *AboutDialog) SetLogo(logo *gdk.Pixbuf) {
logoPtr := (*C.GdkPixbuf)(unsafe.Pointer(logo.Native()))
C.gtk_about_dialog_set_logo(v.native(), logoPtr)
}
// GetLogoIconName is a wrapper around gtk_about_dialog_get_logo_icon_name().
func (v *AboutDialog) GetLogoIconName() string {
c := C.gtk_about_dialog_get_logo_icon_name(v.native())
return C.GoString((*C.char)(c))
}
// SetLogoIconName is a wrapper around gtk_about_dialog_set_logo_icon_name().
func (v *AboutDialog) SetLogoIconName(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_logo_icon_name(v.native(), (*C.gchar)(cstr))
}
// GetProgramName is a wrapper around gtk_about_dialog_get_program_name().
func (v *AboutDialog) GetProgramName() string {
c := C.gtk_about_dialog_get_program_name(v.native())
return C.GoString((*C.char)(c))
}
// SetProgramName is a wrapper around gtk_about_dialog_set_program_name().
func (v *AboutDialog) SetProgramName(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_program_name(v.native(), (*C.gchar)(cstr))
}
// GetAuthors is a wrapper around gtk_about_dialog_get_authors().
func (v *AboutDialog) GetAuthors() []string {
var authors []string
cauthors := C.gtk_about_dialog_get_authors(v.native())
if cauthors == nil {
return nil
}
for {
if *cauthors == nil {
break
}
authors = append(authors, C.GoString((*C.char)(*cauthors)))
cauthors = C.next_gcharptr(cauthors)
}
return authors
}
// SetAuthors is a wrapper around gtk_about_dialog_set_authors().
func (v *AboutDialog) SetAuthors(authors []string) {
cauthors := C.make_strings(C.int(len(authors) + 1))
for i, author := range authors {
cstr := C.CString(author)
defer C.free(unsafe.Pointer(cstr))
C.set_string(cauthors, C.int(i), (*C.gchar)(cstr))
}
C.set_string(cauthors, C.int(len(authors)), nil)
C.gtk_about_dialog_set_authors(v.native(), cauthors)
C.destroy_strings(cauthors)
}
// GetArtists is a wrapper around gtk_about_dialog_get_artists().
func (v *AboutDialog) GetArtists() []string {
var artists []string
cartists := C.gtk_about_dialog_get_artists(v.native())
if cartists == nil {
return nil
}
for {
if *cartists == nil {
break
}
artists = append(artists, C.GoString((*C.char)(*cartists)))
cartists = C.next_gcharptr(cartists)
}
return artists
}
// SetArtists is a wrapper around gtk_about_dialog_set_artists().
func (v *AboutDialog) SetArtists(artists []string) {
cartists := C.make_strings(C.int(len(artists) + 1))
for i, artist := range artists {
cstr := C.CString(artist)
defer C.free(unsafe.Pointer(cstr))
C.set_string(cartists, C.int(i), (*C.gchar)(cstr))
}
C.set_string(cartists, C.int(len(artists)), nil)
C.gtk_about_dialog_set_artists(v.native(), cartists)
C.destroy_strings(cartists)
}
// GetDocumenters is a wrapper around gtk_about_dialog_get_documenters().
func (v *AboutDialog) GetDocumenters() []string {
var documenters []string
cdocumenters := C.gtk_about_dialog_get_documenters(v.native())
if cdocumenters == nil {
return nil
}
for {
if *cdocumenters == nil {
break
}
documenters = append(documenters, C.GoString((*C.char)(*cdocumenters)))
cdocumenters = C.next_gcharptr(cdocumenters)
}
return documenters
}
// SetDocumenters is a wrapper around gtk_about_dialog_set_documenters().
func (v *AboutDialog) SetDocumenters(documenters []string) {
cdocumenters := C.make_strings(C.int(len(documenters) + 1))
for i, doc := range documenters {
cstr := C.CString(doc)
defer C.free(unsafe.Pointer(cstr))
C.set_string(cdocumenters, C.int(i), (*C.gchar)(cstr))
}
C.set_string(cdocumenters, C.int(len(documenters)), nil)
C.gtk_about_dialog_set_documenters(v.native(), cdocumenters)
C.destroy_strings(cdocumenters)
}
// GetTranslatorCredits is a wrapper around gtk_about_dialog_get_translator_credits().
func (v *AboutDialog) GetTranslatorCredits() string {
c := C.gtk_about_dialog_get_translator_credits(v.native())
return C.GoString((*C.char)(c))
}
// SetTranslatorCredits is a wrapper around gtk_about_dialog_set_translator_credits().
func (v *AboutDialog) SetTranslatorCredits(translatorCredits string) {
cstr := C.CString(translatorCredits)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_translator_credits(v.native(), (*C.gchar)(cstr))
}
// GetVersion is a wrapper around gtk_about_dialog_get_version().
func (v *AboutDialog) GetVersion() string {
c := C.gtk_about_dialog_get_version(v.native())
return C.GoString((*C.char)(c))
}
// SetVersion is a wrapper around gtk_about_dialog_set_version().
func (v *AboutDialog) SetVersion(version string) {
cstr := C.CString(version)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_version(v.native(), (*C.gchar)(cstr))
}
// GetWebsite is a wrapper around gtk_about_dialog_get_website().
func (v *AboutDialog) GetWebsite() string {
c := C.gtk_about_dialog_get_website(v.native())
return C.GoString((*C.char)(c))
}
// SetWebsite is a wrapper around gtk_about_dialog_set_website().
func (v *AboutDialog) SetWebsite(website string) {
cstr := C.CString(website)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_website(v.native(), (*C.gchar)(cstr))
}
// GetWebsiteLabel is a wrapper around gtk_about_dialog_get_website_label().
func (v *AboutDialog) GetWebsiteLabel() string {
c := C.gtk_about_dialog_get_website_label(v.native())
return C.GoString((*C.char)(c))
}
// SetWebsiteLabel is a wrapper around gtk_about_dialog_set_website_label().
func (v *AboutDialog) SetWebsiteLabel(websiteLabel string) {
cstr := C.CString(websiteLabel)
defer C.free(unsafe.Pointer(cstr))
C.gtk_about_dialog_set_website_label(v.native(), (*C.gchar)(cstr))
}
// GetWrapLicense is a wrapper around gtk_about_dialog_get_wrap_license().
func (v *AboutDialog) GetWrapLicense() bool {
return gobool(C.gtk_about_dialog_get_wrap_license(v.native()))
}
// SetWrapLicense is a wrapper around gtk_about_dialog_set_wrap_license().
func (v *AboutDialog) SetWrapLicense(wrapLicense bool) {
C.gtk_about_dialog_set_wrap_license(v.native(), gbool(wrapLicense))
}
// AddCreditSection is a wrapper around gtk_about_dialog_add_credit_section().
func (v *AboutDialog) AddCreditSection(sectionName string, people []string) {
cname := (*C.gchar)(C.CString(sectionName))
defer C.free(unsafe.Pointer(cname))
cpeople := C.make_strings(C.int(len(people)) + 1)
defer C.destroy_strings(cpeople)
for i, p := range people {
cp := (*C.gchar)(C.CString(p))
defer C.free(unsafe.Pointer(cp))
C.set_string(cpeople, C.int(i), cp)
}
C.set_string(cpeople, C.int(len(people)), nil)
C.gtk_about_dialog_add_credit_section(v.native(), cname, cpeople)
}

@ -0,0 +1,435 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
// AccelFlags is a representation of GTK's GtkAccelFlags
type AccelFlags int
const (
ACCEL_VISIBLE AccelFlags = C.GTK_ACCEL_VISIBLE
ACCEL_LOCKED AccelFlags = C.GTK_ACCEL_LOCKED
ACCEL_MASK AccelFlags = C.GTK_ACCEL_MASK
)
func marshalAccelFlags(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return AccelFlags(c), nil
}
// AcceleratorName is a wrapper around gtk_accelerator_name().
func AcceleratorName(key uint, mods gdk.ModifierType) string {
c := C.gtk_accelerator_name(C.guint(key), C.GdkModifierType(mods))
defer C.free(unsafe.Pointer(c))
return C.GoString((*C.char)(c))
}
// AcceleratorValid is a wrapper around gtk_accelerator_valid().
func AcceleratorValid(key uint, mods gdk.ModifierType) bool {
return gobool(C.gtk_accelerator_valid(C.guint(key), C.GdkModifierType(mods)))
}
// AcceleratorGetDefaultModMask is a wrapper around gtk_accelerator_get_default_mod_mask().
func AcceleratorGetDefaultModMask() gdk.ModifierType {
return gdk.ModifierType(C.gtk_accelerator_get_default_mod_mask())
}
// AcceleratorParse is a wrapper around gtk_accelerator_parse().
func AcceleratorParse(acc string) (key uint, mods gdk.ModifierType) {
cstr := C.CString(acc)
defer C.free(unsafe.Pointer(cstr))
k := C.guint(0)
m := C.GdkModifierType(0)
C.gtk_accelerator_parse((*C.gchar)(cstr), &k, &m)
return uint(k), gdk.ModifierType(m)
}
// AcceleratorGetLabel is a wrapper around gtk_accelerator_get_label().
func AcceleratorGetLabel(key uint, mods gdk.ModifierType) string {
c := C.gtk_accelerator_get_label(C.guint(key), C.GdkModifierType(mods))
defer C.free(unsafe.Pointer(c))
return C.GoString((*C.char)(c))
}
// AcceleratorSetDefaultModMask is a wrapper around gtk_accelerator_set_default_mod_mask().
func AcceleratorSetDefaultModMask(mods gdk.ModifierType) {
C.gtk_accelerator_set_default_mod_mask(C.GdkModifierType(mods))
}
/*
* GtkAccelGroup
*/
// AccelGroup is a representation of GTK's GtkAccelGroup.
type AccelGroup struct {
*glib.Object
}
// native returns a pointer to the underlying GtkAccelGroup.
func (v *AccelGroup) native() *C.GtkAccelGroup {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAccelGroup(p)
}
func marshalAccelGroup(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapAccelGroup(obj), nil
}
func wrapAccelGroup(obj *glib.Object) *AccelGroup {
return &AccelGroup{obj}
}
// AccelGroup is a wrapper around gtk_accel_group_new().
func AccelGroupNew() (*AccelGroup, error) {
c := C.gtk_accel_group_new()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapAccelGroup(obj), nil
}
// Connect is a wrapper around gtk_accel_group_connect().
func (v *AccelGroup) Connect(key uint, mods gdk.ModifierType, flags AccelFlags, f interface{}) {
closure, _ := glib.ClosureNew(f)
cl := (*C.struct__GClosure)(unsafe.Pointer(closure))
C.gtk_accel_group_connect(
v.native(),
C.guint(key),
C.GdkModifierType(mods),
C.GtkAccelFlags(flags),
cl)
}
// ConnectByPath is a wrapper around gtk_accel_group_connect_by_path().
func (v *AccelGroup) ConnectByPath(path string, f interface{}) {
closure, _ := glib.ClosureNew(f)
cl := (*C.struct__GClosure)(unsafe.Pointer(closure))
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_group_connect_by_path(
v.native(),
(*C.gchar)(cstr),
cl)
}
// Disconnect is a wrapper around gtk_accel_group_disconnect().
func (v *AccelGroup) Disconnect(f interface{}) {
closure, _ := glib.ClosureNew(f)
cl := (*C.struct__GClosure)(unsafe.Pointer(closure))
C.gtk_accel_group_disconnect(v.native(), cl)
}
// DisconnectKey is a wrapper around gtk_accel_group_disconnect_key().
func (v *AccelGroup) DisconnectKey(key uint, mods gdk.ModifierType) {
C.gtk_accel_group_disconnect_key(v.native(), C.guint(key), C.GdkModifierType(mods))
}
// Lock is a wrapper around gtk_accel_group_lock().
func (v *AccelGroup) Lock() {
C.gtk_accel_group_lock(v.native())
}
// Unlock is a wrapper around gtk_accel_group_unlock().
func (v *AccelGroup) Unlock() {
C.gtk_accel_group_unlock(v.native())
}
// IsLocked is a wrapper around gtk_accel_group_get_is_locked().
func (v *AccelGroup) IsLocked() bool {
return gobool(C.gtk_accel_group_get_is_locked(v.native()))
}
// AccelGroupFromClosure is a wrapper around gtk_accel_group_from_accel_closure().
func AccelGroupFromClosure(f interface{}) *AccelGroup {
closure, _ := glib.ClosureNew(f)
cl := (*C.struct__GClosure)(unsafe.Pointer(closure))
c := C.gtk_accel_group_from_accel_closure(cl)
if c == nil {
return nil
}
return wrapAccelGroup(wrapObject(unsafe.Pointer(c)))
}
// GetModifierMask is a wrapper around gtk_accel_group_get_modifier_mask().
func (v *AccelGroup) GetModifierMask() gdk.ModifierType {
return gdk.ModifierType(C.gtk_accel_group_get_modifier_mask(v.native()))
}
// AccelGroupsActivate is a wrapper around gtk_accel_groups_activate().
func AccelGroupsActivate(obj *glib.Object, key uint, mods gdk.ModifierType) bool {
return gobool(C.gtk_accel_groups_activate((*C.GObject)(unsafe.Pointer(obj.Native())), C.guint(key), C.GdkModifierType(mods)))
}
// Activate is a wrapper around gtk_accel_group_activate().
func (v *AccelGroup) Activate(quark glib.Quark, acceleratable *glib.Object, key uint, mods gdk.ModifierType) bool {
return gobool(C.gtk_accel_group_activate(v.native(), C.GQuark(quark), (*C.GObject)(unsafe.Pointer(acceleratable.Native())), C.guint(key), C.GdkModifierType(mods)))
}
// AccelGroupsFromObject is a wrapper around gtk_accel_groups_from_object().
func AccelGroupsFromObject(obj *glib.Object) *glib.SList {
res := C.gtk_accel_groups_from_object((*C.GObject)(unsafe.Pointer(obj.Native())))
if res == nil {
return nil
}
return (*glib.SList)(unsafe.Pointer(res))
}
/*
* GtkAccelMap
*/
// AccelMap is a representation of GTK's GtkAccelMap.
type AccelMap struct {
*glib.Object
}
// native returns a pointer to the underlying GtkAccelMap.
func (v *AccelMap) native() *C.GtkAccelMap {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAccelMap(p)
}
func marshalAccelMap(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapAccelMap(obj), nil
}
func wrapAccelMap(obj *glib.Object) *AccelMap {
return &AccelMap{obj}
}
// AccelMapAddEntry is a wrapper around gtk_accel_map_add_entry().
func AccelMapAddEntry(path string, key uint, mods gdk.ModifierType) {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_add_entry((*C.gchar)(cstr), C.guint(key), C.GdkModifierType(mods))
}
type AccelKey struct {
key uint
mods gdk.ModifierType
flags uint16
}
func (v *AccelKey) native() *C.struct__GtkAccelKey {
if v == nil {
return nil
}
var val C.struct__GtkAccelKey
val.accel_key = C.guint(v.key)
val.accel_mods = C.GdkModifierType(v.mods)
val.accel_flags = v.flags
return &val
}
func wrapAccelKey(obj *C.struct__GtkAccelKey) *AccelKey {
var v AccelKey
v.key = uint(obj.accel_key)
v.mods = gdk.ModifierType(obj.accel_mods)
v.flags = uint16(obj.accel_flags)
return &v
}
// AccelMapLookupEntry is a wrapper around gtk_accel_map_lookup_entry().
func AccelMapLookupEntry(path string) *AccelKey {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
var v *C.struct__GtkAccelKey
C.gtk_accel_map_lookup_entry((*C.gchar)(cstr), v)
return wrapAccelKey(v)
}
// AccelMapChangeEntry is a wrapper around gtk_accel_map_change_entry().
func AccelMapChangeEntry(path string, key uint, mods gdk.ModifierType, replace bool) bool {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
return gobool(C.gtk_accel_map_change_entry((*C.gchar)(cstr), C.guint(key), C.GdkModifierType(mods), gbool(replace)))
}
// AccelMapLoad is a wrapper around gtk_accel_map_load().
func AccelMapLoad(fileName string) {
cstr := C.CString(fileName)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_load((*C.gchar)(cstr))
}
// AccelMapSave is a wrapper around gtk_accel_map_save().
func AccelMapSave(fileName string) {
cstr := C.CString(fileName)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_save((*C.gchar)(cstr))
}
// AccelMapLoadFD is a wrapper around gtk_accel_map_load_fd().
func AccelMapLoadFD(fd int) {
C.gtk_accel_map_load_fd(C.gint(fd))
}
// AccelMapSaveFD is a wrapper around gtk_accel_map_save_fd().
func AccelMapSaveFD(fd int) {
C.gtk_accel_map_save_fd(C.gint(fd))
}
// AccelMapAddFilter is a wrapper around gtk_accel_map_add_filter().
func AccelMapAddFilter(filter string) {
cstr := C.CString(filter)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_add_filter((*C.gchar)(cstr))
}
// AccelMapGet is a wrapper around gtk_accel_map_get().
func AccelMapGet() *AccelMap {
c := C.gtk_accel_map_get()
if c == nil {
return nil
}
return wrapAccelMap(wrapObject(unsafe.Pointer(c)))
}
// AccelMapLockPath is a wrapper around gtk_accel_map_lock_path().
func AccelMapLockPath(path string) {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_lock_path((*C.gchar)(cstr))
}
// AccelMapUnlockPath is a wrapper around gtk_accel_map_unlock_path().
func AccelMapUnlockPath(path string) {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_accel_map_unlock_path((*C.gchar)(cstr))
}
// SetAccelGroup is a wrapper around gtk_menu_set_accel_group().
func (v *Menu) SetAccelGroup(accelGroup *AccelGroup) {
C.gtk_menu_set_accel_group(v.native(), accelGroup.native())
}
// GetAccelGroup is a wrapper around gtk_menu_get_accel_group().
func (v *Menu) GetAccelGroup() *AccelGroup {
c := C.gtk_menu_get_accel_group(v.native())
if c == nil {
return nil
}
return wrapAccelGroup(wrapObject(unsafe.Pointer(c)))
}
// SetAccelPath is a wrapper around gtk_menu_set_accel_path().
func (v *Menu) SetAccelPath(path string) {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_menu_set_accel_path(v.native(), (*C.gchar)(cstr))
}
// GetAccelPath is a wrapper around gtk_menu_get_accel_path().
func (v *Menu) GetAccelPath() string {
c := C.gtk_menu_get_accel_path(v.native())
return C.GoString((*C.char)(c))
}
// SetAccelPath is a wrapper around gtk_menu_item_set_accel_path().
func (v *MenuItem) SetAccelPath(path string) {
cstr := C.CString(path)
defer C.free(unsafe.Pointer(cstr))
C.gtk_menu_item_set_accel_path(v.native(), (*C.gchar)(cstr))
}
// GetAccelPath is a wrapper around gtk_menu_item_get_accel_path().
func (v *MenuItem) GetAccelPath() string {
c := C.gtk_menu_item_get_accel_path(v.native())
return C.GoString((*C.char)(c))
}
// AddAccelerator is a wrapper around gtk_widget_add_accelerator().
func (v *Widget) AddAccelerator(signal string, group *AccelGroup, key uint, mods gdk.ModifierType, flags AccelFlags) {
csignal := (*C.gchar)(C.CString(signal))
defer C.free(unsafe.Pointer(csignal))
C.gtk_widget_add_accelerator(v.native(),
csignal,
group.native(),
C.guint(key),
C.GdkModifierType(mods),
C.GtkAccelFlags(flags))
}
// RemoveAccelerator is a wrapper around gtk_widget_remove_accelerator().
func (v *Widget) RemoveAccelerator(group *AccelGroup, key uint, mods gdk.ModifierType) bool {
return gobool(C.gtk_widget_remove_accelerator(v.native(),
group.native(),
C.guint(key),
C.GdkModifierType(mods)))
}
// SetAccelPath is a wrapper around gtk_widget_set_accel_path().
func (v *Widget) SetAccelPath(path string, group *AccelGroup) {
cstr := (*C.gchar)(C.CString(path))
defer C.free(unsafe.Pointer(cstr))
C.gtk_widget_set_accel_path(v.native(), cstr, group.native())
}
// CanActivateAccel is a wrapper around gtk_widget_can_activate_accel().
func (v *Widget) CanActivateAccel(signalId uint) bool {
return gobool(C.gtk_widget_can_activate_accel(v.native(), C.guint(signalId)))
}
// AddAccelGroup() is a wrapper around gtk_window_add_accel_group().
func (v *Window) AddAccelGroup(accelGroup *AccelGroup) {
C.gtk_window_add_accel_group(v.native(), accelGroup.native())
}
// RemoveAccelGroup() is a wrapper around gtk_window_add_accel_group().
func (v *Window) RemoveAccelGroup(accelGroup *AccelGroup) {
C.gtk_window_remove_accel_group(v.native(), accelGroup.native())
}
// These three functions are for system level access - thus not as high priority to implement
// TODO: void gtk_accelerator_parse_with_keycode ()
// TODO: gchar * gtk_accelerator_name_with_keycode ()
// TODO: gchar * gtk_accelerator_get_label_with_keycode ()
// TODO: GtkAccelKey * gtk_accel_group_find () - this function uses a function type - I don't know how to represent it in cgo
// TODO: gtk_accel_map_foreach_unfiltered - can't be done without a function type
// TODO: gtk_accel_map_foreach - can't be done without a function type
// TODO: gtk_accel_map_load_scanner
// TODO: gtk_widget_list_accel_closures

@ -0,0 +1,106 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10
// 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 <gtk/gtk.h>
// #include "actionbar_since_3_12.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_action_bar_get_type()), marshalActionBar},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkActionBar"] = wrapActionBar
}
//GtkActionBar
type ActionBar struct {
Bin
}
func (v *ActionBar) native() *C.GtkActionBar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkActionBar(p)
}
func marshalActionBar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapActionBar(wrapObject(unsafe.Pointer(c))), nil
}
func wrapActionBar(obj *glib.Object) *ActionBar {
return &ActionBar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
//gtk_action_bar_new()
func ActionBarNew() (*ActionBar, error) {
c := C.gtk_action_bar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapActionBar(wrapObject(unsafe.Pointer(c))), nil
}
//gtk_action_bar_pack_start(GtkActionBar *action_bar,GtkWidget *child)
func (a *ActionBar) PackStart(child IWidget) {
C.gtk_action_bar_pack_start(a.native(), child.toWidget())
}
//gtk_action_bar_pack_end(GtkActionBar *action_bar,GtkWidget *child)
func (a *ActionBar) PackEnd(child IWidget) {
C.gtk_action_bar_pack_end(a.native(), child.toWidget())
}
//gtk_action_bar_set_center_widget(GtkActionBar *action_bar,GtkWidget *center_widget)
func (a *ActionBar) SetCenterWidget(child IWidget) {
if child == nil {
C.gtk_action_bar_set_center_widget(a.native(), nil)
} else {
C.gtk_action_bar_set_center_widget(a.native(), child.toWidget())
}
}
//gtk_action_bar_get_center_widget(GtkActionBar *action_bar)
func (a *ActionBar) GetCenterWidget() *Widget {
w := C.gtk_action_bar_get_center_widget(a.native())
if w == nil {
return nil
}
return &Widget{glib.InitiallyUnowned{wrapObject(unsafe.Pointer(w))}}
}

@ -0,0 +1,25 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12
/*
* 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.
*/
static GtkActionBar *
toGtkActionBar(void *p)
{
return (GTK_ACTION_BAR(p));
}

@ -0,0 +1,378 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_app_chooser_get_type()), marshalAppChooser},
{glib.Type(C.gtk_app_chooser_button_get_type()), marshalAppChooserButton},
{glib.Type(C.gtk_app_chooser_widget_get_type()), marshalAppChooserWidget},
{glib.Type(C.gtk_app_chooser_dialog_get_type()), marshalAppChooserDialog},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkAppChooser"] = wrapAppChooser
WrapMap["GtkAppChooserButton"] = wrapAppChooserButton
WrapMap["GtkAppChooserWidget"] = wrapAppChooserWidget
WrapMap["GtkAppChooserDialog"] = wrapAppChooserDialog
}
/*
* GtkAppChooser
*/
// AppChooser is a representation of GTK's GtkAppChooser GInterface.
type AppChooser struct {
*glib.Object
}
// IAppChooser is an interface type implemented by all structs
// embedding an AppChooser. It is meant to be used as an argument type
// for wrapper functions that wrap around a C GTK function taking a
// GtkAppChooser.
type IAppChooser interface {
toAppChooser() *C.GtkAppChooser
}
// native returns a pointer to the underlying GtkAppChooser.
func (v *AppChooser) native() *C.GtkAppChooser {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAppChooser(p)
}
func marshalAppChooser(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapAppChooser(obj), nil
}
func wrapAppChooser(obj *glib.Object) *AppChooser {
return &AppChooser{obj}
}
func (v *AppChooser) toAppChooser() *C.GtkAppChooser {
if v == nil {
return nil
}
return v.native()
}
// TODO: Needs gio/GAppInfo implementation first
// gtk_app_chooser_get_app_info ()
// GetContentType is a wrapper around gtk_app_chooser_get_content_type().
func (v *AppChooser) GetContentType() string {
cstr := C.gtk_app_chooser_get_content_type(v.native())
defer C.free(unsafe.Pointer(cstr))
return C.GoString((*C.char)(cstr))
}
// Refresh is a wrapper around gtk_app_chooser_refresh().
func (v *AppChooser) Refresh() {
C.gtk_app_chooser_refresh(v.native())
}
/*
* GtkAppChooserButton
*/
// AppChooserButton is a representation of GTK's GtkAppChooserButton.
type AppChooserButton struct {
ComboBox
// Interfaces
AppChooser
}
// native returns a pointer to the underlying GtkAppChooserButton.
func (v *AppChooserButton) native() *C.GtkAppChooserButton {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAppChooserButton(p)
}
func marshalAppChooserButton(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapAppChooserButton(wrapObject(unsafe.Pointer(c))), nil
}
func wrapAppChooserButton(obj *glib.Object) *AppChooserButton {
cl := wrapCellLayout(obj)
ac := wrapAppChooser(obj)
return &AppChooserButton{ComboBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}, *cl}, *ac}
}
// AppChooserButtonNew() is a wrapper around gtk_app_chooser_button_new().
func AppChooserButtonNew(content_type string) (*AppChooserButton, error) {
cstr := C.CString(content_type)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_app_chooser_button_new((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapAppChooserButton(wrapObject(unsafe.Pointer(c))), nil
}
// TODO: Needs gio/GIcon implemented first
// gtk_app_chooser_button_append_custom_item ()
// AppendSeparator() is a wrapper around gtk_app_chooser_button_append_separator().
func (v *AppChooserButton) AppendSeparator() {
C.gtk_app_chooser_button_append_separator(v.native())
}
// SetActiveCustomItem() is a wrapper around gtk_app_chooser_button_set_active_custom_item().
func (v *AppChooserButton) SetActiveCustomItem(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_app_chooser_button_set_active_custom_item(v.native(), (*C.gchar)(cstr))
}
// GetShowDefaultItem() is a wrapper around gtk_app_chooser_button_get_show_default_item().
func (v *AppChooserButton) GetShowDefaultItem() bool {
return gobool(C.gtk_app_chooser_button_get_show_default_item(v.native()))
}
// SetShowDefaultItem() is a wrapper around gtk_app_chooser_button_set_show_default_item().
func (v *AppChooserButton) SetShowDefaultItem(setting bool) {
C.gtk_app_chooser_button_set_show_default_item(v.native(), gbool(setting))
}
// GetShowDialogItem() is a wrapper around gtk_app_chooser_button_get_show_dialog_item().
func (v *AppChooserButton) GetShowDialogItem() bool {
return gobool(C.gtk_app_chooser_button_get_show_dialog_item(v.native()))
}
// SetShowDialogItem() is a wrapper around gtk_app_chooser_button_set_show_dialog_item().
func (v *AppChooserButton) SetShowDialogItem(setting bool) {
C.gtk_app_chooser_button_set_show_dialog_item(v.native(), gbool(setting))
}
// GetHeading() is a wrapper around gtk_app_chooser_button_get_heading().
// In case when gtk_app_chooser_button_get_heading() returns a nil string,
// GetHeading() returns a non-nil error.
func (v *AppChooserButton) GetHeading() (string, error) {
cstr := C.gtk_app_chooser_button_get_heading(v.native())
if cstr == nil {
return "", nilPtrErr
}
defer C.free(unsafe.Pointer(cstr))
return C.GoString((*C.char)(cstr)), nil
}
// SetHeading() is a wrapper around gtk_app_chooser_button_set_heading().
func (v *AppChooserButton) SetHeading(heading string) {
cstr := C.CString(heading)
defer C.free(unsafe.Pointer(cstr))
C.gtk_app_chooser_button_set_heading(v.native(), (*C.gchar)(cstr))
}
/*
* GtkAppChooserWidget
*/
// AppChooserWidget is a representation of GTK's GtkAppChooserWidget.
type AppChooserWidget struct {
Box
// Interfaces
AppChooser
}
// native returns a pointer to the underlying GtkAppChooserWidget.
func (v *AppChooserWidget) native() *C.GtkAppChooserWidget {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAppChooserWidget(p)
}
func marshalAppChooserWidget(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c))), nil
}
func wrapAppChooserWidget(obj *glib.Object) *AppChooserWidget {
box := wrapBox(obj)
ac := wrapAppChooser(obj)
return &AppChooserWidget{*box, *ac}
}
// AppChooserWidgetNew() is a wrapper around gtk_app_chooser_widget_new().
func AppChooserWidgetNew(content_type string) (*AppChooserWidget, error) {
cstr := C.CString(content_type)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_app_chooser_widget_new((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c))), nil
}
// GetShowDefault() is a wrapper around gtk_app_chooser_widget_get_show_default().
func (v *AppChooserWidget) GetShowDefault() bool {
return gobool(C.gtk_app_chooser_widget_get_show_default(v.native()))
}
// SetShowDefault() is a wrapper around gtk_app_chooser_widget_set_show_default().
func (v *AppChooserWidget) SetShowDefault(setting bool) {
C.gtk_app_chooser_widget_set_show_default(v.native(), gbool(setting))
}
// GetShowRecommended() is a wrapper around gtk_app_chooser_widget_get_show_recommended().
func (v *AppChooserWidget) GetShowRecommended() bool {
return gobool(C.gtk_app_chooser_widget_get_show_recommended(v.native()))
}
// SetShowRecommended() is a wrapper around gtk_app_chooser_widget_set_show_recommended().
func (v *AppChooserWidget) SetShowRecommended(setting bool) {
C.gtk_app_chooser_widget_set_show_recommended(v.native(), gbool(setting))
}
// GetShowFallback() is a wrapper around gtk_app_chooser_widget_get_show_fallback().
func (v *AppChooserWidget) GetShowFallback() bool {
return gobool(C.gtk_app_chooser_widget_get_show_fallback(v.native()))
}
// SetShowFallback() is a wrapper around gtk_app_chooser_widget_set_show_fallback().
func (v *AppChooserWidget) SetShowFallback(setting bool) {
C.gtk_app_chooser_widget_set_show_fallback(v.native(), gbool(setting))
}
// GetShowOther() is a wrapper around gtk_app_chooser_widget_get_show_other().
func (v *AppChooserWidget) GetShowOther() bool {
return gobool(C.gtk_app_chooser_widget_get_show_other(v.native()))
}
// SetShowOther() is a wrapper around gtk_app_chooser_widget_set_show_other().
func (v *AppChooserWidget) SetShowOther(setting bool) {
C.gtk_app_chooser_widget_set_show_other(v.native(), gbool(setting))
}
// GetShowAll() is a wrapper around gtk_app_chooser_widget_get_show_all().
func (v *AppChooserWidget) GetShowAll() bool {
return gobool(C.gtk_app_chooser_widget_get_show_all(v.native()))
}
// SetShowAll() is a wrapper around gtk_app_chooser_widget_set_show_all().
func (v *AppChooserWidget) SetShowAll(setting bool) {
C.gtk_app_chooser_widget_set_show_all(v.native(), gbool(setting))
}
// GetDefaultText() is a wrapper around gtk_app_chooser_widget_get_default_text().
// In case when gtk_app_chooser_widget_get_default_text() returns a nil string,
// GetDefaultText() returns a non-nil error.
func (v *AppChooserWidget) GetDefaultText() (string, error) {
cstr := C.gtk_app_chooser_widget_get_default_text(v.native())
if cstr == nil {
return "", nilPtrErr
}
defer C.free(unsafe.Pointer(cstr))
return C.GoString((*C.char)(cstr)), nil
}
// SetDefaultText() is a wrapper around gtk_app_chooser_widget_set_default_text().
func (v *AppChooserWidget) SetDefaultText(text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_app_chooser_widget_set_default_text(v.native(), (*C.gchar)(cstr))
}
/*
* GtkAppChooserDialog
*/
// AppChooserDialog is a representation of GTK's GtkAppChooserDialog.
type AppChooserDialog struct {
Dialog
// Interfaces
AppChooser
}
// native returns a pointer to the underlying GtkAppChooserButton.
func (v *AppChooserDialog) native() *C.GtkAppChooserDialog {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAppChooserDialog(p)
}
func marshalAppChooserDialog(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil
}
func wrapAppChooserDialog(obj *glib.Object) *AppChooserDialog {
dialog := wrapDialog(obj)
ac := wrapAppChooser(obj)
return &AppChooserDialog{*dialog, *ac}
}
// TODO: Uncomment when gio builds successfully
// AppChooserDialogNew() is a wrapper around gtk_app_chooser_dialog_new().
// func AppChooserDialogNew(parent *Window, flags DialogFlags, file *gio.File) (*AppChooserDialog, error) {
// var gfile *C.GFile
// if file != nil {
// gfile = (*C.GFile)(unsafe.Pointer(file.Native()))
// }
// c := C.gtk_app_chooser_dialog_new(parent.native(), C.GtkDialogFlags(flags), gfile)
// if c == nil {
// return nil, nilPtrErr
// }
// return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil
// }
// AppChooserDialogNewForContentType() is a wrapper around gtk_app_chooser_dialog_new_for_content_type().
func AppChooserDialogNewForContentType(parent *Window, flags DialogFlags, content_type string) (*AppChooserDialog, error) {
cstr := C.CString(content_type)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_app_chooser_dialog_new_for_content_type(parent.native(), C.GtkDialogFlags(flags), (*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil
}
// GetWidget() is a wrapper around gtk_app_chooser_dialog_get_widget().
func (v *AppChooserDialog) GetWidget() *AppChooserWidget {
c := C.gtk_app_chooser_dialog_get_widget(v.native())
return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c)))
}
// GetHeading() is a wrapper around gtk_app_chooser_dialog_get_heading().
// In case when gtk_app_chooser_dialog_get_heading() returns a nil string,
// GetHeading() returns a non-nil error.
func (v *AppChooserDialog) GetHeading() (string, error) {
cstr := C.gtk_app_chooser_dialog_get_heading(v.native())
if cstr == nil {
return "", nilPtrErr
}
defer C.free(unsafe.Pointer(cstr))
return C.GoString((*C.char)(cstr)), nil
}
// SetHeading() is a wrapper around gtk_app_chooser_dialog_set_heading().
func (v *AppChooserDialog) SetHeading(heading string) {
cstr := C.CString(heading)
defer C.free(unsafe.Pointer(cstr))
C.gtk_app_chooser_dialog_set_heading(v.native(), (*C.gchar)(cstr))
}

@ -0,0 +1,156 @@
// Same copyright and license as the rest of the files in this project
// This file contains style related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"runtime"
"unsafe"
"github.com/gotk3/gotk3/glib"
)
// ApplicationInhibitFlags is a representation of GTK's GtkApplicationInhibitFlags.
type ApplicationInhibitFlags int
const (
APPLICATION_INHIBIT_LOGOUT ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_LOGOUT
APPLICATION_INHIBIT_SWITCH ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_SWITCH
APPLICATION_INHIBIT_SUSPEND ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_SUSPEND
APPLICATION_INHIBIT_IDLE ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_IDLE
)
/*
* GtkApplication
*/
// Application is a representation of GTK's GtkApplication.
type Application struct {
glib.Application
}
// native returns a pointer to the underlying GtkApplication.
func (v *Application) native() *C.GtkApplication {
if v == nil || v.GObject == nil {
return nil
}
return C.toGtkApplication(unsafe.Pointer(v.GObject))
}
func marshalApplication(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapApplication(obj), nil
}
func wrapApplication(obj *glib.Object) *Application {
return &Application{glib.Application{obj}}
}
// ApplicationNew is a wrapper around gtk_application_new().
func ApplicationNew(appId string, flags glib.ApplicationFlags) (*Application, error) {
cstr := (*C.gchar)(C.CString(appId))
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_application_new(cstr, C.GApplicationFlags(flags))
if c == nil {
return nil, nilPtrErr
}
return wrapApplication(wrapObject(unsafe.Pointer(c))), nil
}
// AddWindow is a wrapper around gtk_application_add_window().
func (v *Application) AddWindow(w *Window) {
C.gtk_application_add_window(v.native(), w.native())
}
// RemoveWindow is a wrapper around gtk_application_remove_window().
func (v *Application) RemoveWindow(w *Window) {
C.gtk_application_remove_window(v.native(), w.native())
}
// GetWindowByID is a wrapper around gtk_application_get_window_by_id().
func (v *Application) GetWindowByID(id uint) *Window {
c := C.gtk_application_get_window_by_id(v.native(), C.guint(id))
if c == nil {
return nil
}
return wrapWindow(wrapObject(unsafe.Pointer(c)))
}
// GetActiveWindow is a wrapper around gtk_application_get_active_window().
func (v *Application) GetActiveWindow() *Window {
c := C.gtk_application_get_active_window(v.native())
if c == nil {
return nil
}
return wrapWindow(wrapObject(unsafe.Pointer(c)))
}
// Uninhibit is a wrapper around gtk_application_uninhibit().
func (v *Application) Uninhibit(cookie uint) {
C.gtk_application_uninhibit(v.native(), C.guint(cookie))
}
// GetAppMenu is a wrapper around gtk_application_get_app_menu().
func (v *Application) GetAppMenu() *glib.MenuModel {
c := C.gtk_application_get_app_menu(v.native())
if c == nil {
return nil
}
return &glib.MenuModel{wrapObject(unsafe.Pointer(c))}
}
// SetAppMenu is a wrapper around gtk_application_set_app_menu().
func (v *Application) SetAppMenu(m *glib.MenuModel) {
mptr := (*C.GMenuModel)(unsafe.Pointer(m.Native()))
C.gtk_application_set_app_menu(v.native(), mptr)
}
// GetMenubar is a wrapper around gtk_application_get_menubar().
func (v *Application) GetMenubar() *glib.MenuModel {
c := C.gtk_application_get_menubar(v.native())
if c == nil {
return nil
}
return &glib.MenuModel{wrapObject(unsafe.Pointer(c))}
}
// SetMenubar is a wrapper around gtk_application_set_menubar().
func (v *Application) SetMenubar(m *glib.MenuModel) {
mptr := (*C.GMenuModel)(unsafe.Pointer(m.Native()))
C.gtk_application_set_menubar(v.native(), mptr)
}
// IsInhibited is a wrapper around gtk_application_is_inhibited().
func (v *Application) IsInhibited(flags ApplicationInhibitFlags) bool {
return gobool(C.gtk_application_is_inhibited(v.native(), C.GtkApplicationInhibitFlags(flags)))
}
// Inhibited is a wrapper around gtk_application_inhibit().
func (v *Application) Inhibited(w *Window, flags ApplicationInhibitFlags, reason string) uint {
cstr1 := (*C.gchar)(C.CString(reason))
defer C.free(unsafe.Pointer(cstr1))
return uint(C.gtk_application_inhibit(v.native(), w.native(), C.GtkApplicationInhibitFlags(flags), cstr1))
}
// void gtk_application_add_accelerator () // deprecated and uses a gvariant paramater
// void gtk_application_remove_accelerator () // deprecated and uses a gvariant paramater
// GetWindows is a wrapper around gtk_application_get_windows().
// Returned list is wrapped to return *gtk.Window elements.
func (v *Application) GetWindows() *glib.List {
glist := C.gtk_application_get_windows(v.native())
list := glib.WrapList(uintptr(unsafe.Pointer(glist)))
list.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return wrapWindow(wrapObject(ptr))
})
runtime.SetFinalizer(list, func(l *glib.List) {
l.Free()
})
return list
}

@ -0,0 +1,62 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10
// See: https://developer.gnome.org/gtk3/3.12/api-index-3-12.html
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import "unsafe"
// GetAccelsForAction is a wrapper around gtk_application_get_accels_for_action().
func (v *Application) GetAccelsForAction(act string) []string {
cstr1 := (*C.gchar)(C.CString(act))
defer C.free(unsafe.Pointer(cstr1))
var descs []string
c := C.gtk_application_get_accels_for_action(v.native(), cstr1)
originalc := c
defer C.g_strfreev(originalc)
for *c != nil {
descs = append(descs, C.GoString((*C.char)(*c)))
c = C.next_gcharptr(c)
}
return descs
}
// SetAccelsForAction is a wrapper around gtk_application_set_accels_for_action().
func (v *Application) SetAccelsForAction(act string, accels []string) {
cstr1 := (*C.gchar)(C.CString(act))
defer C.free(unsafe.Pointer(cstr1))
caccels := C.make_strings(C.int(len(accels) + 1))
defer C.destroy_strings(caccels)
for i, accel := range accels {
cstr := C.CString(accel)
defer C.free(unsafe.Pointer(cstr))
C.set_string(caccels, C.int(i), (*C.gchar)(cstr))
}
C.set_string(caccels, C.int(len(accels)), nil)
C.gtk_application_set_accels_for_action(v.native(), cstr1, caccels)
}
// ListActionDescriptions is a wrapper around gtk_application_list_action_descriptions().
func (v *Application) ListActionDescriptions() []string {
var descs []string
c := C.gtk_application_list_action_descriptions(v.native())
originalc := c
defer C.g_strfreev(originalc)
for *c != nil {
descs = append(descs, C.GoString((*C.char)(*c)))
c = C.next_gcharptr(c)
}
return descs
}

@ -0,0 +1,49 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12
// See: https://developer.gnome.org/gtk3/3.14/api-index-3-14.html
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
// PrefersAppMenu is a wrapper around gtk_application_prefers_app_menu().
func (v *Application) PrefersAppMenu() bool {
return gobool(C.gtk_application_prefers_app_menu(v.native()))
}
// GetActionsForAccel is a wrapper around gtk_application_get_actions_for_accel().
func (v *Application) GetActionsForAccel(acc string) []string {
cstr1 := (*C.gchar)(C.CString(acc))
defer C.free(unsafe.Pointer(cstr1))
var acts []string
c := C.gtk_application_get_actions_for_accel(v.native(), cstr1)
originalc := c
defer C.g_strfreev(originalc)
for *c != nil {
acts = append(acts, C.GoString((*C.char)(*c)))
c = C.next_gcharptr(c)
}
return acts
}
// GetMenuByID is a wrapper around gtk_application_get_menu_by_id().
func (v *Application) GetMenuByID(id string) *glib.Menu {
cstr1 := (*C.gchar)(C.CString(id))
defer C.free(unsafe.Pointer(cstr1))
c := C.gtk_application_get_menu_by_id(v.native(), cstr1)
if c == nil {
return nil
}
return &glib.Menu{glib.MenuModel{wrapObject(unsafe.Pointer(c))}}
}

@ -0,0 +1,65 @@
// Same copyright and license as the rest of the files in this project
// This file contains style related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkApplicationWindow
*/
// ApplicationWindow is a representation of GTK's GtkApplicationWindow.
type ApplicationWindow struct {
Window
}
// native returns a pointer to the underlying GtkApplicationWindow.
func (v *ApplicationWindow) native() *C.GtkApplicationWindow {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkApplicationWindow(p)
}
func marshalApplicationWindow(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapApplicationWindow(obj), nil
}
func wrapApplicationWindow(obj *glib.Object) *ApplicationWindow {
return &ApplicationWindow{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}
}
// ApplicationWindowNew is a wrapper around gtk_application_window_new().
func ApplicationWindowNew(app *Application) (*ApplicationWindow, error) {
c := C.gtk_application_window_new(app.native())
if c == nil {
return nil, nilPtrErr
}
return wrapApplicationWindow(wrapObject(unsafe.Pointer(c))), nil
}
// SetShowMenubar is a wrapper around gtk_application_window_set_show_menubar().
func (v *ApplicationWindow) SetShowMenubar(b bool) {
C.gtk_application_window_set_show_menubar(v.native(), gbool(b))
}
// GetShowMenubar is a wrapper around gtk_application_window_get_show_menubar().
func (v *ApplicationWindow) GetShowMenubar() bool {
return gobool(C.gtk_application_window_get_show_menubar(v.native()))
}
// GetID is a wrapper around gtk_application_window_get_id().
func (v *ApplicationWindow) GetID() uint {
return uint(C.gtk_application_window_get_id(v.native()))
}

@ -0,0 +1,148 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_color_chooser_get_type()), marshalColorChooser},
{glib.Type(C.gtk_color_chooser_dialog_get_type()), marshalColorChooserDialog},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkColorChooser"] = wrapColorChooser
WrapMap["GtkColorChooserDialog"] = wrapColorChooserDialog
}
/*
* GtkColorChooser
*/
// ColorChooser is a representation of GTK's GtkColorChooser GInterface.
type ColorChooser struct {
*glib.Object
}
// IColorChooser is an interface type implemented by all structs
// embedding an ColorChooser. It is meant to be used as an argument type
// for wrapper functions that wrap around a C GTK function taking a
// GtkColorChooser.
type IColorChooser interface {
toColorChooser() *C.GtkColorChooser
}
// native returns a pointer to the underlying GtkAppChooser.
func (v *ColorChooser) native() *C.GtkColorChooser {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkColorChooser(p)
}
func marshalColorChooser(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapColorChooser(obj), nil
}
func wrapColorChooser(obj *glib.Object) *ColorChooser {
return &ColorChooser{obj}
}
func (v *ColorChooser) toColorChooser() *C.GtkColorChooser {
if v == nil {
return nil
}
return v.native()
}
// GetRGBA() is a wrapper around gtk_color_chooser_get_rgba().
func (v *ColorChooser) GetRGBA() *gdk.RGBA {
gdkColor := gdk.NewRGBA()
C.gtk_color_chooser_get_rgba(v.native(), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native())))
return gdkColor
}
// SetRGBA() is a wrapper around gtk_color_chooser_set_rgba().
func (v *ColorChooser) SetRGBA(gdkColor *gdk.RGBA) {
C.gtk_color_chooser_set_rgba(v.native(), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native())))
}
// GetUseAlpha() is a wrapper around gtk_color_chooser_get_use_alpha().
func (v *ColorChooser) GetUseAlpha() bool {
return gobool(C.gtk_color_chooser_get_use_alpha(v.native()))
}
// SetUseAlpha() is a wrapper around gtk_color_chooser_set_use_alpha().
func (v *ColorChooser) SetUseAlpha(use_alpha bool) {
C.gtk_color_chooser_set_use_alpha(v.native(), gbool(use_alpha))
}
// AddPalette() is a wrapper around gtk_color_chooser_add_palette().
func (v *ColorChooser) AddPalette(orientation Orientation, colors_per_line int, colors []*gdk.RGBA) {
n_colors := len(colors)
var c_colors []C.GdkRGBA
for _, c := range colors {
c_colors = append(c_colors, *(*C.GdkRGBA)(unsafe.Pointer(c.Native())))
}
C.gtk_color_chooser_add_palette(
v.native(),
C.GtkOrientation(orientation),
C.gint(colors_per_line),
C.gint(n_colors),
&c_colors[0],
)
}
/*
* GtkColorChooserDialog
*/
// ColorChooserDialog is a representation of GTK's GtkColorChooserDialog.
type ColorChooserDialog struct {
Dialog
// Interfaces
ColorChooser
}
// native returns a pointer to the underlying GtkColorChooserButton.
func (v *ColorChooserDialog) native() *C.GtkColorChooserDialog {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkColorChooserDialog(p)
}
func marshalColorChooserDialog(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapColorChooserDialog(wrapObject(unsafe.Pointer(c))), nil
}
func wrapColorChooserDialog(obj *glib.Object) *ColorChooserDialog {
dialog := wrapDialog(obj)
cc := wrapColorChooser(obj)
return &ColorChooserDialog{*dialog, *cc}
}
// ColorChooserDialogNew() is a wrapper around gtk_color_chooser_dialog_new().
func ColorChooserDialogNew(title string, parent *Window) (*ColorChooserDialog, error) {
cstr := C.CString(title)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_color_chooser_dialog_new((*C.gchar)(cstr), parent.native())
if c == nil {
return nil, nilPtrErr
}
return wrapColorChooserDialog(wrapObject(unsafe.Pointer(c))), nil
}

@ -0,0 +1,264 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"errors"
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_combo_box_get_type()), marshalComboBox},
{glib.Type(C.gtk_combo_box_text_get_type()), marshalComboBoxText},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkComboBox"] = wrapComboBox
WrapMap["GtkComboBoxText"] = wrapComboBoxText
}
/*
* GtkComboBox
*/
// ComboBox is a representation of GTK's GtkComboBox.
type ComboBox struct {
Bin
// Interfaces
CellLayout
}
// native returns a pointer to the underlying GtkComboBox.
func (v *ComboBox) native() *C.GtkComboBox {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkComboBox(p)
}
func (v *ComboBox) toCellLayout() *C.GtkCellLayout {
if v == nil {
return nil
}
return C.toGtkCellLayout(unsafe.Pointer(v.GObject))
}
func marshalComboBox(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBox(obj), nil
}
func wrapComboBox(obj *glib.Object) *ComboBox {
cl := wrapCellLayout(obj)
return &ComboBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}, *cl}
}
// ComboBoxNew() is a wrapper around gtk_combo_box_new().
func ComboBoxNew() (*ComboBox, error) {
c := C.gtk_combo_box_new()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBox(obj), nil
}
// ComboBoxNewWithEntry() is a wrapper around gtk_combo_box_new_with_entry().
func ComboBoxNewWithEntry() (*ComboBox, error) {
c := C.gtk_combo_box_new_with_entry()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBox(obj), nil
}
// ComboBoxNewWithModel() is a wrapper around gtk_combo_box_new_with_model().
func ComboBoxNewWithModel(model ITreeModel) (*ComboBox, error) {
c := C.gtk_combo_box_new_with_model(model.toTreeModel())
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBox(obj), nil
}
// GetActive() is a wrapper around gtk_combo_box_get_active().
func (v *ComboBox) GetActive() int {
c := C.gtk_combo_box_get_active(v.native())
return int(c)
}
// SetActive() is a wrapper around gtk_combo_box_set_active().
func (v *ComboBox) SetActive(index int) {
C.gtk_combo_box_set_active(v.native(), C.gint(index))
}
// GetActiveIter is a wrapper around gtk_combo_box_get_active_iter().
func (v *ComboBox) GetActiveIter() (*TreeIter, error) {
var cIter C.GtkTreeIter
c := C.gtk_combo_box_get_active_iter(v.native(), &cIter)
if !gobool(c) {
return nil, errors.New("unable to get active iter")
}
return &TreeIter{cIter}, nil
}
// SetActiveIter is a wrapper around gtk_combo_box_set_active_iter().
func (v *ComboBox) SetActiveIter(iter *TreeIter) {
var cIter *C.GtkTreeIter
if iter != nil {
cIter = &iter.GtkTreeIter
}
C.gtk_combo_box_set_active_iter(v.native(), cIter)
}
// GetActiveID is a wrapper around gtk_combo_box_get_active_id().
func (v *ComboBox) GetActiveID() string {
c := C.gtk_combo_box_get_active_id(v.native())
return C.GoString((*C.char)(c))
}
// SetActiveID is a wrapper around gtk_combo_box_set_active_id().
func (v *ComboBox) SetActiveID(id string) bool {
cid := C.CString(id)
defer C.free(unsafe.Pointer(cid))
c := C.gtk_combo_box_set_active_id(v.native(), (*C.gchar)(cid))
return gobool(c)
}
// GetModel is a wrapper around gtk_combo_box_get_model().
func (v *ComboBox) GetModel() (*TreeModel, error) {
c := C.gtk_combo_box_get_model(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapTreeModel(obj), nil
}
// SetModel is a wrapper around gtk_combo_box_set_model().
func (v *ComboBox) SetModel(model ITreeModel) {
C.gtk_combo_box_set_model(v.native(), model.toTreeModel())
}
/*
* GtkComboBoxText
*/
// ComboBoxText is a representation of GTK's GtkComboBoxText.
type ComboBoxText struct {
ComboBox
}
// native returns a pointer to the underlying GtkComboBoxText.
func (v *ComboBoxText) native() *C.GtkComboBoxText {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkComboBoxText(p)
}
func marshalComboBoxText(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBoxText(obj), nil
}
func wrapComboBoxText(obj *glib.Object) *ComboBoxText {
return &ComboBoxText{*wrapComboBox(obj)}
}
// ComboBoxTextNew is a wrapper around gtk_combo_box_text_new().
func ComboBoxTextNew() (*ComboBoxText, error) {
c := C.gtk_combo_box_text_new()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBoxText(obj), nil
}
// ComboBoxTextNewWithEntry is a wrapper around gtk_combo_box_text_new_with_entry().
func ComboBoxTextNewWithEntry() (*ComboBoxText, error) {
c := C.gtk_combo_box_text_new_with_entry()
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapComboBoxText(obj), nil
}
// Append is a wrapper around gtk_combo_box_text_append().
func (v *ComboBoxText) Append(id, text string) {
cid := C.CString(id)
ctext := C.CString(text)
defer C.free(unsafe.Pointer(cid))
defer C.free(unsafe.Pointer(ctext))
C.gtk_combo_box_text_append(v.native(), (*C.gchar)(cid), (*C.gchar)(ctext))
}
// Prepend is a wrapper around gtk_combo_box_text_prepend().
func (v *ComboBoxText) Prepend(id, text string) {
cid := C.CString(id)
ctext := C.CString(text)
defer C.free(unsafe.Pointer(cid))
defer C.free(unsafe.Pointer(ctext))
C.gtk_combo_box_text_prepend(v.native(), (*C.gchar)(cid), (*C.gchar)(ctext))
}
// Insert is a wrapper around gtk_combo_box_text_insert().
func (v *ComboBoxText) Insert(position int, id, text string) {
cid := C.CString(id)
ctext := C.CString(text)
defer C.free(unsafe.Pointer(cid))
defer C.free(unsafe.Pointer(ctext))
C.gtk_combo_box_text_insert(v.native(), C.gint(position), (*C.gchar)(cid), (*C.gchar)(ctext))
}
// AppendText is a wrapper around gtk_combo_box_text_append_text().
func (v *ComboBoxText) AppendText(text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_combo_box_text_append_text(v.native(), (*C.gchar)(cstr))
}
// PrependText is a wrapper around gtk_combo_box_text_prepend_text().
func (v *ComboBoxText) PrependText(text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_combo_box_text_prepend_text(v.native(), (*C.gchar)(cstr))
}
// InsertText is a wrapper around gtk_combo_box_text_insert_text().
func (v *ComboBoxText) InsertText(position int, text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_combo_box_text_insert_text(v.native(), C.gint(position), (*C.gchar)(cstr))
}
// Remove is a wrapper around gtk_combo_box_text_remove().
func (v *ComboBoxText) Remove(position int) {
C.gtk_combo_box_text_remove(v.native(), C.gint(position))
}
// RemoveAll is a wrapper around gtk_combo_box_text_remove_all().
func (v *ComboBoxText) RemoveAll() {
C.gtk_combo_box_text_remove_all(v.native())
}
// GetActiveText is a wrapper around gtk_combo_box_text_get_active_text().
func (v *ComboBoxText) GetActiveText() string {
c := (*C.char)(C.gtk_combo_box_text_get_active_text(v.native()))
defer C.free(unsafe.Pointer(c))
return C.GoString(c)
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,813 @@
/*
* 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.
*/
#ifndef __GTK_GO_H__
#define __GTK_GO_H__
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static GtkAboutDialog *
toGtkAboutDialog(void *p)
{
return (GTK_ABOUT_DIALOG(p));
}
static GtkAppChooser *
toGtkAppChooser(void *p)
{
return (GTK_APP_CHOOSER(p));
}
static GtkAppChooserButton *
toGtkAppChooserButton(void *p)
{
return (GTK_APP_CHOOSER_BUTTON(p));
}
static GtkAppChooserDialog *
toGtkAppChooserDialog(void *p)
{
return (GTK_APP_CHOOSER_DIALOG(p));
}
static GtkAppChooserWidget *
toGtkAppChooserWidget(void *p)
{
return (GTK_APP_CHOOSER_WIDGET(p));
}
static GtkApplication *
toGtkApplication(void *p)
{
return (GTK_APPLICATION(p));
}
static GtkApplicationWindow *
toGtkApplicationWindow(void *p)
{
return (GTK_APPLICATION_WINDOW(p));
}
static GtkAssistant *
toGtkAssistant(void *p)
{
return (GTK_ASSISTANT(p));
}
static GtkCalendar *
toGtkCalendar(void *p)
{
return (GTK_CALENDAR(p));
}
static GtkColorChooserDialog *
toGtkColorChooserDialog(void *p)
{
return (GTK_COLOR_CHOOSER_DIALOG(p));
}
static GtkDrawingArea *
toGtkDrawingArea(void *p)
{
return (GTK_DRAWING_AREA(p));
}
static GtkCellRendererSpinner *
toGtkCellRendererSpinner(void *p)
{
return (GTK_CELL_RENDERER_SPINNER(p));
}
static GtkEventBox *
toGtkEventBox(void *p)
{
return (GTK_EVENT_BOX(p));
}
static GtkGrid *
toGtkGrid(void *p)
{
return (GTK_GRID(p));
}
static GtkWidget *
toGtkWidget(void *p)
{
return (GTK_WIDGET(p));
}
static GtkContainer *
toGtkContainer(void *p)
{
return (GTK_CONTAINER(p));
}
static GtkPaned *
toGtkPaned(void *p)
{
return (GTK_PANED(p));
}
static GtkProgressBar *
toGtkProgressBar(void *p)
{
return (GTK_PROGRESS_BAR(p));
}
static GtkLevelBar *
toGtkLevelBar(void *p)
{
return (GTK_LEVEL_BAR(p));
}
static GtkBin *
toGtkBin(void *p)
{
return (GTK_BIN(p));
}
static GtkWindow *
toGtkWindow(void *p)
{
return (GTK_WINDOW(p));
}
static GtkBox *
toGtkBox(void *p)
{
return (GTK_BOX(p));
}
static GtkStatusbar *
toGtkStatusbar(void *p)
{
return (GTK_STATUSBAR(p));
}
static GtkLabel *
toGtkLabel(void *p)
{
return (GTK_LABEL(p));
}
static GtkNotebook *
toGtkNotebook(void *p)
{
return (GTK_NOTEBOOK(p));
}
static GtkEntry *
toGtkEntry(void *p)
{
return (GTK_ENTRY(p));
}
static GtkEntryBuffer *
toGtkEntryBuffer(void *p)
{
return (GTK_ENTRY_BUFFER(p));
}
static GtkEntryCompletion *
toGtkEntryCompletion(void *p)
{
return (GTK_ENTRY_COMPLETION(p));
}
static GtkAdjustment *
toGtkAdjustment(void *p)
{
return (GTK_ADJUSTMENT(p));
}
static GtkAccelGroup *
toGtkAccelGroup(void *p)
{
return (GTK_ACCEL_GROUP(p));
}
static GtkAccelMap *
toGtkAccelMap(void *p)
{
return (GTK_ACCEL_MAP(p));
}
static GtkTextTag *
toGtkTextTag(void *p)
{
return (GTK_TEXT_TAG(p));
}
static GtkIconView *
toGtkIconView(void *p)
{
return (GTK_ICON_VIEW(p));
}
static GtkImage *
toGtkImage(void *p)
{
return (GTK_IMAGE(p));
}
static GtkButton *
toGtkButton(void *p)
{
return (GTK_BUTTON(p));
}
static GtkScaleButton *
toGtkScaleButton(void *p)
{
return (GTK_SCALE_BUTTON(p));
}
static GtkColorButton *
toGtkColorButton(void *p)
{
return (GTK_COLOR_BUTTON(p));
}
static GtkViewport *
toGtkViewport(void *p)
{
return (GTK_VIEWPORT(p));
}
static GtkVolumeButton *
toGtkVolumeButton(void *p)
{
return (GTK_VOLUME_BUTTON(p));
}
static GtkScrollable *
toGtkScrollable(void *p)
{
return (GTK_SCROLLABLE(p));
}
static GtkScrolledWindow *
toGtkScrolledWindow(void *p)
{
return (GTK_SCROLLED_WINDOW(p));
}
static GtkMenuItem *
toGtkMenuItem(void *p)
{
return (GTK_MENU_ITEM(p));
}
static GtkMenu *
toGtkMenu(void *p)
{
return (GTK_MENU(p));
}
static GtkMenuShell *
toGtkMenuShell(void *p)
{
return (GTK_MENU_SHELL(p));
}
static GtkMenuBar *
toGtkMenuBar(void *p)
{
return (GTK_MENU_BAR(p));
}
static GtkSizeGroup *
toGtkSizeGroup(void *p)
{
return (GTK_SIZE_GROUP(p));
}
static GtkSpinButton *
toGtkSpinButton(void *p)
{
return (GTK_SPIN_BUTTON(p));
}
static GtkSpinner *
toGtkSpinner(void *p)
{
return (GTK_SPINNER(p));
}
static GtkComboBox *
toGtkComboBox(void *p)
{
return (GTK_COMBO_BOX(p));
}
static GtkComboBoxText *
toGtkComboBoxText(void *p)
{
return (GTK_COMBO_BOX_TEXT(p));
}
static GtkLinkButton *
toGtkLinkButton(void *p)
{
return (GTK_LINK_BUTTON(p));
}
static GtkLayout *
toGtkLayout(void *p)
{
return (GTK_LAYOUT(p));
}
static GtkListStore *
toGtkListStore(void *p)
{
return (GTK_LIST_STORE(p));
}
static GtkSwitch *
toGtkSwitch(void *p)
{
return (GTK_SWITCH(p));
}
static GtkTextView *
toGtkTextView(void *p)
{
return (GTK_TEXT_VIEW(p));
}
static GtkTextTagTable *
toGtkTextTagTable(void *p)
{
return (GTK_TEXT_TAG_TABLE(p));
}
static GtkTextBuffer *
toGtkTextBuffer(void *p)
{
return (GTK_TEXT_BUFFER(p));
}
static GtkTreeModel *
toGtkTreeModel(void *p)
{
return (GTK_TREE_MODEL(p));
}
static GtkCellRenderer *
toGtkCellRenderer(void *p)
{
return (GTK_CELL_RENDERER(p));
}
static GtkCellRendererPixbuf *
toGtkCellRendererPixbuf(void *p)
{
return (GTK_CELL_RENDERER_PIXBUF(p));
}
static GtkCellRendererText *
toGtkCellRendererText(void *p)
{
return (GTK_CELL_RENDERER_TEXT(p));
}
static GtkCellRendererToggle *
toGtkCellRendererToggle(void *p)
{
return (GTK_CELL_RENDERER_TOGGLE(p));
}
static GtkCellLayout *
toGtkCellLayout(void *p)
{
return (GTK_CELL_LAYOUT(p));
}
static GtkOrientable *
toGtkOrientable(void *p)
{
return (GTK_ORIENTABLE(p));
}
static GtkTreeStore *
toGtkTreeStore (void *p)
{
return (GTK_TREE_STORE(p));
}
static GtkTreeView *
toGtkTreeView(void *p)
{
return (GTK_TREE_VIEW(p));
}
static GtkTreeViewColumn *
toGtkTreeViewColumn(void *p)
{
return (GTK_TREE_VIEW_COLUMN(p));
}
static GtkTreeSelection *
toGtkTreeSelection(void *p)
{
return (GTK_TREE_SELECTION(p));
}
static GtkTreeSortable *
toGtkTreeSortable(void *p)
{
return (GTK_TREE_SORTABLE(p));
}
static GtkClipboard *
toGtkClipboard(void *p)
{
return (GTK_CLIPBOARD(p));
}
static GtkDialog *
toGtkDialog(void *p)
{
return (GTK_DIALOG(p));
}
static GtkMessageDialog *
toGtkMessageDialog(void *p)
{
return (GTK_MESSAGE_DIALOG(p));
}
static GtkBuilder *
toGtkBuilder(void *p)
{
return (GTK_BUILDER(p));
}
static GtkSeparatorMenuItem *
toGtkSeparatorMenuItem(void *p)
{
return (GTK_SEPARATOR_MENU_ITEM(p));
}
static GtkCheckButton *
toGtkCheckButton(void *p)
{
return (GTK_CHECK_BUTTON(p));
}
static GtkToggleButton *
toGtkToggleButton(void *p)
{
return (GTK_TOGGLE_BUTTON(p));
}
static GtkFontButton *
toGtkFontButton(void *p)
{
return (GTK_FONT_BUTTON(p));
}
static GtkFrame *
toGtkFrame(void *p)
{
return (GTK_FRAME(p));
}
static GtkSeparator *
toGtkSeparator(void *p)
{
return (GTK_SEPARATOR(p));
}
static GtkScale*
toGtkScale(void *p)
{
return (GTK_SCALE(p));
}
static GtkScrollbar *
toGtkScrollbar(void *p)
{
return (GTK_SCROLLBAR(p));
}
static GtkRange *
toGtkRange(void *p)
{
return (GTK_RANGE(p));
}
static GtkSearchEntry *
toGtkSearchEntry(void *p)
{
return (GTK_SEARCH_ENTRY(p));
}
static GtkOffscreenWindow *
toGtkOffscreenWindow(void *p)
{
return (GTK_OFFSCREEN_WINDOW(p));
}
static GtkExpander *
toGtkExpander(void *p)
{
return (GTK_EXPANDER(p));
}
static GtkFileChooser *
toGtkFileChooser(void *p)
{
return (GTK_FILE_CHOOSER(p));
}
static GtkFileChooserButton *
toGtkFileChooserButton(void *p)
{
return (GTK_FILE_CHOOSER_BUTTON(p));
}
static GtkFileChooserDialog *
toGtkFileChooserDialog(void *p)
{
return (GTK_FILE_CHOOSER_DIALOG(p));
}
static GtkFileChooserWidget *
toGtkFileChooserWidget(void *p)
{
return (GTK_FILE_CHOOSER_WIDGET(p));
}
static GtkFileFilter *
toGtkFileFilter(void *p)
{
return (GTK_FILE_FILTER(p));
}
static GtkMenuButton *
toGtkMenuButton(void *p)
{
return (GTK_MENU_BUTTON(p));
}
static GtkRadioButton *
toGtkRadioButton(void *p)
{
return (GTK_RADIO_BUTTON(p));
}
static GtkRecentChooser *
toGtkRecentChooser(void *p)
{
return (GTK_RECENT_CHOOSER(p));
}
static GtkRecentChooserMenu *
toGtkRecentChooserMenu(void *p)
{
return (GTK_RECENT_CHOOSER_MENU(p));
}
static GtkColorChooser *
toGtkColorChooser(void *p)
{
return (GTK_COLOR_CHOOSER(p));
}
static GtkRecentFilter *
toGtkRecentFilter(void *p)
{
return (GTK_RECENT_FILTER(p));
}
static GtkRecentManager *
toGtkRecentManager(void *p)
{
return (GTK_RECENT_MANAGER(p));
}
static GtkCheckMenuItem *
toGtkCheckMenuItem(void *p)
{
return (GTK_CHECK_MENU_ITEM(p));
}
static GtkRadioMenuItem *
toGtkRadioMenuItem(void *p)
{
return (GTK_RADIO_MENU_ITEM(p));
}
static GtkToolItem *
toGtkToolItem(void *p)
{
return (GTK_TOOL_ITEM(p));
}
static GtkToolbar *
toGtkToolbar(void *p)
{
return (GTK_TOOLBAR(p));
}
static GtkEditable *
toGtkEditable(void *p)
{
return (GTK_EDITABLE(p));
}
static GtkToolButton *
toGtkToolButton(void *p)
{
return (GTK_TOOL_BUTTON(p));
}
static GtkSeparatorToolItem *
toGtkSeparatorToolItem(void *p)
{
return (GTK_SEPARATOR_TOOL_ITEM(p));
}
static GtkCssProvider *
toGtkCssProvider(void *p)
{
return (GTK_CSS_PROVIDER(p));
}
static GtkStyleContext *
toGtkStyleContext(void *p)
{
return (GTK_STYLE_CONTEXT(p));
}
static GtkStyleProvider *
toGtkStyleProvider(void *p)
{
return (GTK_STYLE_PROVIDER(p));
}
static GtkInfoBar *
toGtkInfoBar(void *p)
{
return (GTK_INFO_BAR(p));
}
static GType *
alloc_types(int n) {
return ((GType *)g_new0(GType, n));
}
static void
set_type(GType *types, int n, GType t)
{
types[n] = t;
}
static GtkTreeViewColumn *
_gtk_tree_view_column_new_with_attributes_one(const gchar *title,
GtkCellRenderer *renderer, const gchar *attribute, gint column)
{
GtkTreeViewColumn *tvc;
tvc = gtk_tree_view_column_new_with_attributes(title, renderer,
attribute, column, NULL);
return (tvc);
}
static void
_gtk_list_store_set(GtkListStore *list_store, GtkTreeIter *iter, gint column,
void* value)
{
gtk_list_store_set(list_store, iter, column, value, -1);
}
static void
_gtk_tree_store_set(GtkTreeStore *store, GtkTreeIter *iter, gint column,
void* value)
{
gtk_tree_store_set(store, iter, column, value, -1);
}
static GtkWidget *
_gtk_message_dialog_new(GtkWindow *parent, GtkDialogFlags flags,
GtkMessageType type, GtkButtonsType buttons, char *msg)
{
GtkWidget *w;
w = gtk_message_dialog_new(parent, flags, type, buttons, "%s", msg);
return (w);
}
static GtkWidget *
_gtk_message_dialog_new_with_markup(GtkWindow *parent, GtkDialogFlags flags,
GtkMessageType type, GtkButtonsType buttons, char *msg)
{
GtkWidget *w;
w = gtk_message_dialog_new_with_markup(parent, flags, type, buttons,
"%s", msg);
return (w);
}
static void
_gtk_message_dialog_format_secondary_text(GtkMessageDialog *message_dialog,
const gchar *msg)
{
gtk_message_dialog_format_secondary_text(message_dialog, "%s", msg);
}
static void
_gtk_message_dialog_format_secondary_markup(GtkMessageDialog *message_dialog,
const gchar *msg)
{
gtk_message_dialog_format_secondary_markup(message_dialog, "%s", msg);
}
static const gchar *
object_get_class_name(GObject *object)
{
return G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(object));
}
static GtkWidget *
gtk_file_chooser_dialog_new_1(
const gchar *title,
GtkWindow *parent,
GtkFileChooserAction action,
const gchar *first_button_text, int first_button_id
) {
return gtk_file_chooser_dialog_new(
title, parent, action,
first_button_text, first_button_id,
NULL);
}
static GtkWidget *
gtk_file_chooser_dialog_new_2(
const gchar *title,
GtkWindow *parent,
GtkFileChooserAction action,
const gchar *first_button_text, int first_button_id,
const gchar *second_button_text, int second_button_id
) {
return gtk_file_chooser_dialog_new(
title, parent, action,
first_button_text, first_button_id,
second_button_text, second_button_id,
NULL);
}
static void _gtk_widget_hide_on_delete(GtkWidget* w) {
g_signal_connect(GTK_WIDGET(w), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
}
static inline gchar** make_strings(int count) {
return (gchar**)malloc(sizeof(gchar*) * count);
}
static inline void destroy_strings(gchar** strings) {
free(strings);
}
static inline gchar* get_string(gchar** strings, int n) {
return strings[n];
}
static inline void set_string(gchar** strings, int n, gchar* str) {
strings[n] = str;
}
static inline gchar** next_gcharptr(gchar** s) { return (s+1); }
extern void goBuilderConnect (GtkBuilder *builder,
GObject *object,
gchar *signal_name,
gchar *handler_name,
GObject *connect_object,
GConnectFlags flags,
gpointer user_data);
static inline void _gtk_builder_connect_signals_full(GtkBuilder *builder) {
gtk_builder_connect_signals_full(builder, (GtkBuilderConnectFunc)(goBuilderConnect), NULL);
}
#endif

@ -0,0 +1,210 @@
// 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 deprecated beginning with GTK 3.10,
// and should only be included in a build targeted intended to target GTK
// 3.8 or earlier. To target an earlier build build, use the build tag
// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run
// 'go build -tags gtk_3_8'.
// +build gtk_3_6 gtk_3_8
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
import "C"
import "unsafe"
// ButtonNewFromStock is a wrapper around gtk_button_new_from_stock().
func ButtonNewFromStock(stock Stock) (*Button, error) {
cstr := C.CString(string(stock))
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_button_new_from_stock((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapButton(wrapObject(unsafe.Pointer(c))), nil
}
// SetUseStock is a wrapper around gtk_button_set_use_stock().
func (v *Button) SetUseStock(useStock bool) {
C.gtk_button_set_use_stock(v.native(), gbool(useStock))
}
// GetUseStock is a wrapper around gtk_button_get_use_stock().
func (v *Button) GetUseStock() bool {
c := C.gtk_button_get_use_stock(v.native())
return gobool(c)
}
// GetIconStock is a wrapper around gtk_entry_get_icon_stock().
func (v *Entry) GetIconStock(iconPos EntryIconPosition) (string, error) {
c := C.gtk_entry_get_icon_stock(v.native(),
C.GtkEntryIconPosition(iconPos))
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// SetIconFromStock is a wrapper around gtk_entry_set_icon_from_stock().
func (v *Entry) SetIconFromStock(iconPos EntryIconPosition, stockID string) {
cstr := C.CString(stockID)
defer C.free(unsafe.Pointer(cstr))
C.gtk_entry_set_icon_from_stock(v.native(),
C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr))
}
// ImageNewFromStock is a wrapper around gtk_image_new_from_stock().
func ImageNewFromStock(stock Stock, size IconSize) (*Image, error) {
cstr := C.CString(string(stock))
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_image_new_from_stock((*C.gchar)(cstr), C.GtkIconSize(size))
if c == nil {
return nil, nilPtrErr
}
return wrapImage(wrapObject(unsafe.Pointer(c))), nil
}
// SetFromStock is a wrapper around gtk_image_set_from_stock().
func (v *Image) SetFromStock(stock Stock, size IconSize) {
cstr := C.CString(string(stock))
defer C.free(unsafe.Pointer(cstr))
C.gtk_image_set_from_stock(v.native(), (*C.gchar)(cstr),
C.GtkIconSize(size))
}
// Stock is a special type that does not have an equivalent type in
// GTK. It is the type used as a parameter anytime an identifier for
// stock icons are needed. A Stock must be type converted to string when
// function parameters may take a Stock, but when other string values are
// valid as well.
type Stock string
const (
STOCK_ABOUT Stock = C.GTK_STOCK_ABOUT
STOCK_ADD Stock = C.GTK_STOCK_ADD
STOCK_APPLY Stock = C.GTK_STOCK_APPLY
STOCK_BOLD Stock = C.GTK_STOCK_BOLD
STOCK_CANCEL Stock = C.GTK_STOCK_CANCEL
STOCK_CAPS_LOCK_WARNING Stock = C.GTK_STOCK_CAPS_LOCK_WARNING
STOCK_CDROM Stock = C.GTK_STOCK_CDROM
STOCK_CLEAR Stock = C.GTK_STOCK_CLEAR
STOCK_CLOSE Stock = C.GTK_STOCK_CLOSE
STOCK_COLOR_PICKER Stock = C.GTK_STOCK_COLOR_PICKER
STOCK_CONNECT Stock = C.GTK_STOCK_CONNECT
STOCK_CONVERT Stock = C.GTK_STOCK_CONVERT
STOCK_COPY Stock = C.GTK_STOCK_COPY
STOCK_CUT Stock = C.GTK_STOCK_CUT
STOCK_DELETE Stock = C.GTK_STOCK_DELETE
STOCK_DIALOG_AUTHENTICATION Stock = C.GTK_STOCK_DIALOG_AUTHENTICATION
STOCK_DIALOG_INFO Stock = C.GTK_STOCK_DIALOG_INFO
STOCK_DIALOG_WARNING Stock = C.GTK_STOCK_DIALOG_WARNING
STOCK_DIALOG_ERROR Stock = C.GTK_STOCK_DIALOG_ERROR
STOCK_DIALOG_QUESTION Stock = C.GTK_STOCK_DIALOG_QUESTION
STOCK_DIRECTORY Stock = C.GTK_STOCK_DIRECTORY
STOCK_DISCARD Stock = C.GTK_STOCK_DISCARD
STOCK_DISCONNECT Stock = C.GTK_STOCK_DISCONNECT
STOCK_DND Stock = C.GTK_STOCK_DND
STOCK_DND_MULTIPLE Stock = C.GTK_STOCK_DND_MULTIPLE
STOCK_EDIT Stock = C.GTK_STOCK_EDIT
STOCK_EXECUTE Stock = C.GTK_STOCK_EXECUTE
STOCK_FILE Stock = C.GTK_STOCK_FILE
STOCK_FIND Stock = C.GTK_STOCK_FIND
STOCK_FIND_AND_REPLACE Stock = C.GTK_STOCK_FIND_AND_REPLACE
STOCK_FLOPPY Stock = C.GTK_STOCK_FLOPPY
STOCK_FULLSCREEN Stock = C.GTK_STOCK_FULLSCREEN
STOCK_GOTO_BOTTOM Stock = C.GTK_STOCK_GOTO_BOTTOM
STOCK_GOTO_FIRST Stock = C.GTK_STOCK_GOTO_FIRST
STOCK_GOTO_LAST Stock = C.GTK_STOCK_GOTO_LAST
STOCK_GOTO_TOP Stock = C.GTK_STOCK_GOTO_TOP
STOCK_GO_BACK Stock = C.GTK_STOCK_GO_BACK
STOCK_GO_DOWN Stock = C.GTK_STOCK_GO_DOWN
STOCK_GO_FORWARD Stock = C.GTK_STOCK_GO_FORWARD
STOCK_GO_UP Stock = C.GTK_STOCK_GO_UP
STOCK_HARDDISK Stock = C.GTK_STOCK_HARDDISK
STOCK_HELP Stock = C.GTK_STOCK_HELP
STOCK_HOME Stock = C.GTK_STOCK_HOME
STOCK_INDEX Stock = C.GTK_STOCK_INDEX
STOCK_INDENT Stock = C.GTK_STOCK_INDENT
STOCK_INFO Stock = C.GTK_STOCK_INFO
STOCK_ITALIC Stock = C.GTK_STOCK_ITALIC
STOCK_JUMP_TO Stock = C.GTK_STOCK_JUMP_TO
STOCK_JUSTIFY_CENTER Stock = C.GTK_STOCK_JUSTIFY_CENTER
STOCK_JUSTIFY_FILL Stock = C.GTK_STOCK_JUSTIFY_FILL
STOCK_JUSTIFY_LEFT Stock = C.GTK_STOCK_JUSTIFY_LEFT
STOCK_JUSTIFY_RIGHT Stock = C.GTK_STOCK_JUSTIFY_RIGHT
STOCK_LEAVE_FULLSCREEN Stock = C.GTK_STOCK_LEAVE_FULLSCREEN
STOCK_MISSING_IMAGE Stock = C.GTK_STOCK_MISSING_IMAGE
STOCK_MEDIA_FORWARD Stock = C.GTK_STOCK_MEDIA_FORWARD
STOCK_MEDIA_NEXT Stock = C.GTK_STOCK_MEDIA_NEXT
STOCK_MEDIA_PAUSE Stock = C.GTK_STOCK_MEDIA_PAUSE
STOCK_MEDIA_PLAY Stock = C.GTK_STOCK_MEDIA_PLAY
STOCK_MEDIA_PREVIOUS Stock = C.GTK_STOCK_MEDIA_PREVIOUS
STOCK_MEDIA_RECORD Stock = C.GTK_STOCK_MEDIA_RECORD
STOCK_MEDIA_REWIND Stock = C.GTK_STOCK_MEDIA_REWIND
STOCK_MEDIA_STOP Stock = C.GTK_STOCK_MEDIA_STOP
STOCK_NETWORK Stock = C.GTK_STOCK_NETWORK
STOCK_NEW Stock = C.GTK_STOCK_NEW
STOCK_NO Stock = C.GTK_STOCK_NO
STOCK_OK Stock = C.GTK_STOCK_OK
STOCK_OPEN Stock = C.GTK_STOCK_OPEN
STOCK_ORIENTATION_PORTRAIT Stock = C.GTK_STOCK_ORIENTATION_PORTRAIT
STOCK_ORIENTATION_LANDSCAPE Stock = C.GTK_STOCK_ORIENTATION_LANDSCAPE
STOCK_ORIENTATION_REVERSE_LANDSCAPE Stock = C.GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE
STOCK_ORIENTATION_REVERSE_PORTRAIT Stock = C.GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT
STOCK_PAGE_SETUP Stock = C.GTK_STOCK_PAGE_SETUP
STOCK_PASTE Stock = C.GTK_STOCK_PASTE
STOCK_PREFERENCES Stock = C.GTK_STOCK_PREFERENCES
STOCK_PRINT Stock = C.GTK_STOCK_PRINT
STOCK_PRINT_ERROR Stock = C.GTK_STOCK_PRINT_ERROR
STOCK_PRINT_PAUSED Stock = C.GTK_STOCK_PRINT_PAUSED
STOCK_PRINT_PREVIEW Stock = C.GTK_STOCK_PRINT_PREVIEW
STOCK_PRINT_REPORT Stock = C.GTK_STOCK_PRINT_REPORT
STOCK_PRINT_WARNING Stock = C.GTK_STOCK_PRINT_WARNING
STOCK_PROPERTIES Stock = C.GTK_STOCK_PROPERTIES
STOCK_QUIT Stock = C.GTK_STOCK_QUIT
STOCK_REDO Stock = C.GTK_STOCK_REDO
STOCK_REFRESH Stock = C.GTK_STOCK_REFRESH
STOCK_REMOVE Stock = C.GTK_STOCK_REMOVE
STOCK_REVERT_TO_SAVED Stock = C.GTK_STOCK_REVERT_TO_SAVED
STOCK_SAVE Stock = C.GTK_STOCK_SAVE
STOCK_SAVE_AS Stock = C.GTK_STOCK_SAVE_AS
STOCK_SELECT_ALL Stock = C.GTK_STOCK_SELECT_ALL
STOCK_SELECT_COLOR Stock = C.GTK_STOCK_SELECT_COLOR
STOCK_SELECT_FONT Stock = C.GTK_STOCK_SELECT_FONT
STOCK_SORT_ASCENDING Stock = C.GTK_STOCK_SORT_ASCENDING
STOCK_SORT_DESCENDING Stock = C.GTK_STOCK_SORT_DESCENDING
STOCK_SPELL_CHECK Stock = C.GTK_STOCK_SPELL_CHECK
STOCK_STOP Stock = C.GTK_STOCK_STOP
STOCK_STRIKETHROUGH Stock = C.GTK_STOCK_STRIKETHROUGH
STOCK_UNDELETE Stock = C.GTK_STOCK_UNDELETE
STOCK_UNDERLINE Stock = C.GTK_STOCK_UNDERLINE
STOCK_UNDO Stock = C.GTK_STOCK_UNDO
STOCK_UNINDENT Stock = C.GTK_STOCK_UNINDENT
STOCK_YES Stock = C.GTK_STOCK_YES
STOCK_ZOOM_100 Stock = C.GTK_STOCK_ZOOM_100
STOCK_ZOOM_FIT Stock = C.GTK_STOCK_ZOOM_FIT
STOCK_ZOOM_IN Stock = C.GTK_STOCK_ZOOM_IN
STOCK_ZOOM_OUT Stock = C.GTK_STOCK_ZOOM_OUT
)
// ReshowWithInitialSize is a wrapper around
// gtk_window_reshow_with_initial_size().
func (v *Window) ReshowWithInitialSize() {
C.gtk_window_reshow_with_initial_size(v.native())
}

@ -0,0 +1,86 @@
// 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 deprecated beginning with GTK 3.12,
// and should only be included in a build targeted intended to target GTK
// 3.10 or earlier. To target an earlier build build, use the build tag
// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run
// 'go build -tags gtk_3_8'.
// +build gtk_3_6 gtk_3_8 gtk_3_10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
import "unsafe"
/*
* GtkDialog
*/
// GetActionArea() is a wrapper around gtk_dialog_get_action_area().
func (v *Dialog) GetActionArea() (*Widget, error) {
c := C.gtk_dialog_get_action_area(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
/*
* GtkMessageDialog
*/
// GetImage is a wrapper around gtk_message_dialog_get_image().
func (v *MessageDialog) GetImage() (*Widget, error) {
c := C.gtk_message_dialog_get_image(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// SetImage is a wrapper around gtk_message_dialog_set_image().
func (v *MessageDialog) SetImage(image IWidget) {
C.gtk_message_dialog_set_image(v.native(), image.toWidget())
}
/*
* GtkWidget
*/
// GetMarginLeft is a wrapper around gtk_widget_get_margin_left().
func (v *Widget) GetMarginLeft() int {
c := C.gtk_widget_get_margin_left(v.native())
return int(c)
}
// SetMarginLeft is a wrapper around gtk_widget_set_margin_left().
func (v *Widget) SetMarginLeft(margin int) {
C.gtk_widget_set_margin_left(v.native(), C.gint(margin))
}
// GetMarginRight is a wrapper around gtk_widget_get_margin_right().
func (v *Widget) GetMarginRight() int {
c := C.gtk_widget_get_margin_right(v.native())
return int(c)
}
// SetMarginRight is a wrapper around gtk_widget_set_margin_right().
func (v *Widget) SetMarginRight(margin int) {
C.gtk_widget_set_margin_right(v.native(), C.gint(margin))
}

@ -0,0 +1,423 @@
// +build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_deprecated_since_3_14.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_alignment_get_type()), marshalAlignment},
{glib.Type(C.gtk_arrow_get_type()), marshalArrow},
{glib.Type(C.gtk_misc_get_type()), marshalMisc},
{glib.Type(C.gtk_status_icon_get_type()), marshalStatusIcon},
}
glib.RegisterGValueMarshalers(tm)
//Contribute to casting
for k, v := range map[string]WrapFn{
"GtkAlignment": wrapAlignment,
"GtkArrow": wrapArrow,
"GtkMisc": wrapMisc,
"GtkStatusIcon": wrapStatusIcon,
} {
WrapMap[k] = v
}
}
/*
* deprecated since version 3.14 and should not be used in newly-written code
*/
// ResizeGripIsVisible is a wrapper around
// gtk_window_resize_grip_is_visible().
func (v *Window) ResizeGripIsVisible() bool {
c := C.gtk_window_resize_grip_is_visible(v.native())
return gobool(c)
}
// SetHasResizeGrip is a wrapper around gtk_window_set_has_resize_grip().
func (v *Window) SetHasResizeGrip(setting bool) {
C.gtk_window_set_has_resize_grip(v.native(), gbool(setting))
}
// GetHasResizeGrip is a wrapper around gtk_window_get_has_resize_grip().
func (v *Window) GetHasResizeGrip() bool {
c := C.gtk_window_get_has_resize_grip(v.native())
return gobool(c)
}
// Reparent() is a wrapper around gtk_widget_reparent().
func (v *Widget) Reparent(newParent IWidget) {
C.gtk_widget_reparent(v.native(), newParent.toWidget())
}
// GetPadding is a wrapper around gtk_alignment_get_padding().
func (v *Alignment) GetPadding() (top, bottom, left, right uint) {
var ctop, cbottom, cleft, cright C.guint
C.gtk_alignment_get_padding(v.native(), &ctop, &cbottom, &cleft,
&cright)
return uint(ctop), uint(cbottom), uint(cleft), uint(cright)
}
// SetPadding is a wrapper around gtk_alignment_set_padding().
func (v *Alignment) SetPadding(top, bottom, left, right uint) {
C.gtk_alignment_set_padding(v.native(), C.guint(top), C.guint(bottom),
C.guint(left), C.guint(right))
}
// AlignmentNew is a wrapper around gtk_alignment_new().
func AlignmentNew(xalign, yalign, xscale, yscale float32) (*Alignment, error) {
c := C.gtk_alignment_new(C.gfloat(xalign), C.gfloat(yalign), C.gfloat(xscale),
C.gfloat(yscale))
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapAlignment(obj), nil
}
// Set is a wrapper around gtk_alignment_set().
func (v *Alignment) Set(xalign, yalign, xscale, yscale float32) {
C.gtk_alignment_set(v.native(), C.gfloat(xalign), C.gfloat(yalign),
C.gfloat(xscale), C.gfloat(yscale))
}
/*
* GtkArrow
*/
// Arrow is a representation of GTK's GtkArrow.
type Arrow struct {
Misc
}
// ArrowNew is a wrapper around gtk_arrow_new().
func ArrowNew(arrowType ArrowType, shadowType ShadowType) (*Arrow, error) {
c := C.gtk_arrow_new(C.GtkArrowType(arrowType),
C.GtkShadowType(shadowType))
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapArrow(obj), nil
}
// Set is a wrapper around gtk_arrow_set().
func (v *Arrow) Set(arrowType ArrowType, shadowType ShadowType) {
C.gtk_arrow_set(v.native(), C.GtkArrowType(arrowType), C.GtkShadowType(shadowType))
}
// SetAlignment() is a wrapper around gtk_button_set_alignment().
func (v *Button) SetAlignment(xalign, yalign float32) {
C.gtk_button_set_alignment(v.native(), (C.gfloat)(xalign),
(C.gfloat)(yalign))
}
// GetAlignment() is a wrapper around gtk_button_get_alignment().
func (v *Button) GetAlignment() (xalign, yalign float32) {
var x, y C.gfloat
C.gtk_button_get_alignment(v.native(), &x, &y)
return float32(x), float32(y)
}
// SetReallocateRedraws is a wrapper around
// gtk_container_set_reallocate_redraws().
func (v *Container) SetReallocateRedraws(needsRedraws bool) {
C.gtk_container_set_reallocate_redraws(v.native(), gbool(needsRedraws))
}
// GetAlignment is a wrapper around gtk_misc_get_alignment().
func (v *Misc) GetAlignment() (xAlign, yAlign float32) {
var x, y C.gfloat
C.gtk_misc_get_alignment(v.native(), &x, &y)
return float32(x), float32(y)
}
// SetAlignment is a wrapper around gtk_misc_set_alignment().
func (v *Misc) SetAlignment(xAlign, yAlign float32) {
C.gtk_misc_set_alignment(v.native(), C.gfloat(xAlign), C.gfloat(yAlign))
}
// GetPadding is a wrapper around gtk_misc_get_padding().
func (v *Misc) GetPadding() (xpad, ypad int) {
var x, y C.gint
C.gtk_misc_get_padding(v.native(), &x, &y)
return int(x), int(y)
}
// SetPadding is a wrapper around gtk_misc_set_padding().
func (v *Misc) SetPadding(xPad, yPad int) {
C.gtk_misc_set_padding(v.native(), C.gint(xPad), C.gint(yPad))
}
// SetDoubleBuffered is a wrapper around gtk_widget_set_double_buffered().
func (v *Widget) SetDoubleBuffered(doubleBuffered bool) {
C.gtk_widget_set_double_buffered(v.native(), gbool(doubleBuffered))
}
// GetDoubleBuffered is a wrapper around gtk_widget_get_double_buffered().
func (v *Widget) GetDoubleBuffered() bool {
c := C.gtk_widget_get_double_buffered(v.native())
return gobool(c)
}
/*
* GtkArrow
* deprecated since version 3.14
*/
// native returns a pointer to the underlying GtkButton.
func (v *Arrow) native() *C.GtkArrow {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkArrow(p)
}
func marshalArrow(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapArrow(obj), nil
}
func wrapArrow(obj *glib.Object) *Arrow {
return &Arrow{Misc{Widget{glib.InitiallyUnowned{obj}}}}
}
/*
* GtkAlignment
* deprecated since version 3.14
*/
type Alignment struct {
Bin
}
// native returns a pointer to the underlying GtkAlignment.
func (v *Alignment) native() *C.GtkAlignment {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkAlignment(p)
}
func marshalAlignment(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapAlignment(obj), nil
}
func wrapAlignment(obj *glib.Object) *Alignment {
return &Alignment{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
/*
* GtkStatusIcon
* deprecated since version 3.14
*/
// StatusIcon is a representation of GTK's GtkStatusIcon
type StatusIcon struct {
*glib.Object
}
func marshalStatusIcon(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapStatusIcon(obj), nil
}
func wrapStatusIcon(obj *glib.Object) *StatusIcon {
return &StatusIcon{obj}
}
func (v *StatusIcon) native() *C.GtkStatusIcon {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkStatusIcon(p)
}
// StatusIconNew is a wrapper around gtk_status_icon_new()
func StatusIconNew() (*StatusIcon, error) {
c := C.gtk_status_icon_new()
if c == nil {
return nil, nilPtrErr
}
return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil
}
// StatusIconNewFromFile is a wrapper around gtk_status_icon_new_from_file()
func StatusIconNewFromFile(filename string) (*StatusIcon, error) {
cstr := C.CString(filename)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_status_icon_new_from_file((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil
}
// StatusIconNewFromIconName is a wrapper around gtk_status_icon_new_from_name()
func StatusIconNewFromIconName(iconName string) (*StatusIcon, error) {
cstr := C.CString(iconName)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_status_icon_new_from_icon_name((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil
}
// SetFromFile is a wrapper around gtk_status_icon_set_from_file()
func (v *StatusIcon) SetFromFile(filename string) {
cstr := C.CString(filename)
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_from_file(v.native(), (*C.gchar)(cstr))
}
// SetFromIconName is a wrapper around gtk_status_icon_set_from_icon_name()
func (v *StatusIcon) SetFromIconName(iconName string) {
cstr := C.CString(iconName)
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_from_icon_name(v.native(), (*C.gchar)(cstr))
}
// GetStorageType is a wrapper around gtk_status_icon_get_storage_type()
func (v *StatusIcon) GetStorageType() ImageType {
return (ImageType)(C.gtk_status_icon_get_storage_type(v.native()))
}
// SetTooltipText is a wrapper around gtk_status_icon_set_tooltip_text()
func (v *StatusIcon) SetTooltipText(text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_tooltip_text(v.native(), (*C.gchar)(cstr))
}
// GetTooltipText is a wrapper around gtk_status_icon_get_tooltip_text()
func (v *StatusIcon) GetTooltipText() string {
cstr := (*C.char)(C.gtk_status_icon_get_tooltip_text(v.native()))
defer C.free(unsafe.Pointer(cstr))
return C.GoString(cstr)
}
// SetTooltipMarkup is a wrapper around gtk_status_icon_set_tooltip_markup()
func (v *StatusIcon) SetTooltipMarkup(markup string) {
cstr := (*C.gchar)(C.CString(markup))
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_tooltip_markup(v.native(), cstr)
}
// GetTooltipMarkup is a wrapper around gtk_status_icon_get_tooltip_markup()
func (v *StatusIcon) GetTooltipMarkup() string {
cstr := (*C.char)(C.gtk_status_icon_get_tooltip_markup(v.native()))
defer C.free(unsafe.Pointer(cstr))
return C.GoString(cstr)
}
// SetHasTooltip is a wrapper around gtk_status_icon_set_has_tooltip()
func (v *StatusIcon) SetHasTooltip(hasTooltip bool) {
C.gtk_status_icon_set_has_tooltip(v.native(), gbool(hasTooltip))
}
// GetTitle is a wrapper around gtk_status_icon_get_title()
func (v *StatusIcon) GetTitle() string {
cstr := (*C.char)(C.gtk_status_icon_get_title(v.native()))
defer C.free(unsafe.Pointer(cstr))
return C.GoString(cstr)
}
// SetName is a wrapper around gtk_status_icon_set_name()
func (v *StatusIcon) SetName(name string) {
cstr := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_name(v.native(), cstr)
}
// SetVisible is a wrapper around gtk_status_icon_set_visible()
func (v *StatusIcon) SetVisible(visible bool) {
C.gtk_status_icon_set_visible(v.native(), gbool(visible))
}
// GetVisible is a wrapper around gtk_status_icon_get_visible()
func (v *StatusIcon) GetVisible() bool {
return gobool(C.gtk_status_icon_get_visible(v.native()))
}
// IsEmbedded is a wrapper around gtk_status_icon_is_embedded()
func (v *StatusIcon) IsEmbedded() bool {
return gobool(C.gtk_status_icon_is_embedded(v.native()))
}
// GetX11WindowID is a wrapper around gtk_status_icon_get_x11_window_id()
func (v *StatusIcon) GetX11WindowID() int {
return int(C.gtk_status_icon_get_x11_window_id(v.native()))
}
// GetHasTooltip is a wrapper around gtk_status_icon_get_has_tooltip()
func (v *StatusIcon) GetHasTooltip() bool {
return gobool(C.gtk_status_icon_get_has_tooltip(v.native()))
}
// SetTitle is a wrapper around gtk_status_icon_set_title()
func (v *StatusIcon) SetTitle(title string) {
cstr := (*C.gchar)(C.CString(title))
defer C.free(unsafe.Pointer(cstr))
C.gtk_status_icon_set_title(v.native(), cstr)
}
// GetIconName is a wrapper around gtk_status_icon_get_icon_name()
func (v *StatusIcon) GetIconName() string {
cstr := (*C.char)(C.gtk_status_icon_get_icon_name(v.native()))
defer C.free(unsafe.Pointer(cstr))
return C.GoString(cstr)
}
// GetSize is a wrapper around gtk_status_icon_get_size()
func (v *StatusIcon) GetSize() int {
return int(C.gtk_status_icon_get_size(v.native()))
}
/*
* GtkMisc
*/
// Misc is a representation of GTK's GtkMisc.
type Misc struct {
Widget
}
// native returns a pointer to the underlying GtkMisc.
func (v *Misc) native() *C.GtkMisc {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkMisc(p)
}
func marshalMisc(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapMisc(obj), nil
}
func wrapMisc(obj *glib.Object) *Misc {
return &Misc{Widget{glib.InitiallyUnowned{obj}}}
}
/*
* End deprecated since version 3.14
*/

@ -0,0 +1,30 @@
static GtkStatusIcon *
toGtkStatusIcon(void *p)
{
return (GTK_STATUS_ICON(p));
}
/*
* deprecated since version 3.14
*/
static GtkAlignment *
toGtkAlignment(void *p)
{
return (GTK_ALIGNMENT(p));
}
static GtkArrow *
toGtkArrow(void *p)
{
return (GTK_ARROW(p));
}
static GtkMisc *
toGtkMisc(void *p)
{
return (GTK_MISC(p));
}
/*
* End deprecated since version 3.14
*/

@ -0,0 +1,31 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include <stdlib.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
)
// OverrideColor is a wrapper around gtk_widget_override_color().
func (v *Widget) OverrideColor(state StateFlags, color *gdk.RGBA) {
var cColor *C.GdkRGBA
if color != nil {
cColor = (*C.GdkRGBA)(unsafe.Pointer(color.Native()))
}
C.gtk_widget_override_color(v.native(), C.GtkStateFlags(state), cColor)
}
// OverrideFont is a wrapper around gtk_widget_override_font().
func (v *Widget) OverrideFont(description string) {
cstr := C.CString(description)
defer C.free(unsafe.Pointer(cstr))
c := C.pango_font_description_from_string(cstr)
C.gtk_widget_override_font(v.native(), c)
}

@ -0,0 +1,44 @@
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
//export goBuilderConnect
func goBuilderConnect(builder *C.GtkBuilder,
object *C.GObject,
signal_name *C.gchar,
handler_name *C.gchar,
connect_object *C.GObject,
flags C.GConnectFlags,
user_data C.gpointer) {
builderSignals.Lock()
signals, ok := builderSignals.m[builder]
builderSignals.Unlock()
if !ok {
panic("no signal mapping defined for this GtkBuilder")
}
h := C.GoString((*C.char)(handler_name))
s := C.GoString((*C.char)(signal_name))
handler, ok := signals[h]
if !ok {
return
}
if object == nil {
panic("unexpected nil object from builder")
}
//TODO: figure out a better way to get a glib.Object from a *C.GObject
gobj := glib.Object{glib.ToGObject(unsafe.Pointer(object))}
gobj.Connect(s, handler)
}

@ -0,0 +1,693 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
// +build !gtk_3_6,!gtk_3_8
// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_since_3_10.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
{glib.Type(C.gtk_revealer_transition_type_get_type()), marshalRevealerTransitionType},
{glib.Type(C.gtk_stack_transition_type_get_type()), marshalStackTransitionType},
// Objects/Interfaces
{glib.Type(C.gtk_header_bar_get_type()), marshalHeaderBar},
{glib.Type(C.gtk_list_box_get_type()), marshalListBox},
{glib.Type(C.gtk_list_box_row_get_type()), marshalListBoxRow},
{glib.Type(C.gtk_revealer_get_type()), marshalRevealer},
{glib.Type(C.gtk_search_bar_get_type()), marshalSearchBar},
{glib.Type(C.gtk_stack_get_type()), marshalStack},
{glib.Type(C.gtk_stack_switcher_get_type()), marshalStackSwitcher},
}
glib.RegisterGValueMarshalers(tm)
//Contribute to casting
for k, v := range map[string]WrapFn{
"GtkHeaderBar": wrapHeaderBar,
"GtkListBox": wrapListBox,
"GtkListBoxRow": wrapListBoxRow,
"GtkRevealer": wrapRevealer,
"GtkSearchBar": wrapSearchBar,
"GtkStack": wrapStack,
} {
WrapMap[k] = v
}
}
/*
* Constants
*/
const (
ALIGN_BASELINE Align = C.GTK_ALIGN_BASELINE
)
// RevealerTransitionType is a representation of GTK's GtkRevealerTransitionType.
type RevealerTransitionType int
const (
REVEALER_TRANSITION_TYPE_NONE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_NONE
REVEALER_TRANSITION_TYPE_CROSSFADE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_CROSSFADE
REVEALER_TRANSITION_TYPE_SLIDE_RIGHT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT
REVEALER_TRANSITION_TYPE_SLIDE_LEFT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT
REVEALER_TRANSITION_TYPE_SLIDE_UP RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP
REVEALER_TRANSITION_TYPE_SLIDE_DOWN RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN
)
func marshalRevealerTransitionType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return RevealerTransitionType(c), nil
}
// StackTransitionType is a representation of GTK's GtkStackTransitionType.
type StackTransitionType int
const (
STACK_TRANSITION_TYPE_NONE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_NONE
STACK_TRANSITION_TYPE_CROSSFADE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_CROSSFADE
STACK_TRANSITION_TYPE_SLIDE_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT
STACK_TRANSITION_TYPE_SLIDE_LEFT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT
STACK_TRANSITION_TYPE_SLIDE_UP StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP
STACK_TRANSITION_TYPE_SLIDE_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN
STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT
STACK_TRANSITION_TYPE_SLIDE_UP_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN
)
func marshalStackTransitionType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return StackTransitionType(c), nil
}
/*
* GtkButton
*/
// ButtonNewFromIconName is a wrapper around gtk_button_new_from_icon_name().
func ButtonNewFromIconName(iconName string, size IconSize) (*Button, error) {
cstr := C.CString(iconName)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_button_new_from_icon_name((*C.gchar)(cstr),
C.GtkIconSize(size))
if c == nil {
return nil, nilPtrErr
}
return wrapButton(wrapObject(unsafe.Pointer(c))), nil
}
/*
* GtkHeaderBar
*/
type HeaderBar struct {
Container
}
// native returns a pointer to the underlying GtkHeaderBar.
func (v *HeaderBar) native() *C.GtkHeaderBar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkHeaderBar(p)
}
func marshalHeaderBar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapHeaderBar(obj), nil
}
func wrapHeaderBar(obj *glib.Object) *HeaderBar {
return &HeaderBar{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// HeaderBarNew is a wrapper around gtk_header_bar_new().
func HeaderBarNew() (*HeaderBar, error) {
c := C.gtk_header_bar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapHeaderBar(wrapObject(unsafe.Pointer(c))), nil
}
// SetTitle is a wrapper around gtk_header_bar_set_title().
func (v *HeaderBar) SetTitle(title string) {
cstr := C.CString(title)
defer C.free(unsafe.Pointer(cstr))
C.gtk_header_bar_set_title(v.native(), (*C.gchar)(cstr))
}
// GetTitle is a wrapper around gtk_header_bar_get_title().
func (v *HeaderBar) GetTitle() string {
cstr := C.gtk_header_bar_get_title(v.native())
return C.GoString((*C.char)(cstr))
}
// SetSubtitle is a wrapper around gtk_header_bar_set_subtitle().
func (v *HeaderBar) SetSubtitle(subtitle string) {
cstr := C.CString(subtitle)
defer C.free(unsafe.Pointer(cstr))
C.gtk_header_bar_set_subtitle(v.native(), (*C.gchar)(cstr))
}
// GetSubtitle is a wrapper around gtk_header_bar_get_subtitle().
func (v *HeaderBar) GetSubtitle() string {
cstr := C.gtk_header_bar_get_subtitle(v.native())
return C.GoString((*C.char)(cstr))
}
// SetCustomTitle is a wrapper around gtk_header_bar_set_custom_title().
func (v *HeaderBar) SetCustomTitle(titleWidget IWidget) {
C.gtk_header_bar_set_custom_title(v.native(), titleWidget.toWidget())
}
// GetCustomTitle is a wrapper around gtk_header_bar_get_custom_title().
func (v *HeaderBar) GetCustomTitle() (*Widget, error) {
c := C.gtk_header_bar_get_custom_title(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// PackStart is a wrapper around gtk_header_bar_pack_start().
func (v *HeaderBar) PackStart(child IWidget) {
C.gtk_header_bar_pack_start(v.native(), child.toWidget())
}
// PackEnd is a wrapper around gtk_header_bar_pack_end().
func (v *HeaderBar) PackEnd(child IWidget) {
C.gtk_header_bar_pack_end(v.native(), child.toWidget())
}
// SetShowCloseButton is a wrapper around gtk_header_bar_set_show_close_button().
func (v *HeaderBar) SetShowCloseButton(setting bool) {
C.gtk_header_bar_set_show_close_button(v.native(), gbool(setting))
}
// GetShowCloseButton is a wrapper around gtk_header_bar_get_show_close_button().
func (v *HeaderBar) GetShowCloseButton() bool {
c := C.gtk_header_bar_get_show_close_button(v.native())
return gobool(c)
}
/*
* GtkLabel
*/
// GetLines() is a wrapper around gtk_label_get_lines().
func (v *Label) GetLines() int {
c := C.gtk_label_get_lines(v.native())
return int(c)
}
// SetLines() is a wrapper around gtk_label_set_lines().
func (v *Label) SetLines(lines int) {
C.gtk_label_set_lines(v.native(), C.gint(lines))
}
/*
* GtkListBox
*/
// ListBox is a representation of GTK's GtkListBox.
type ListBox struct {
Container
}
// native returns a pointer to the underlying GtkListBox.
func (v *ListBox) native() *C.GtkListBox {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkListBox(p)
}
func marshalListBox(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapListBox(obj), nil
}
func wrapListBox(obj *glib.Object) *ListBox {
return &ListBox{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// ListBoxNew is a wrapper around gtk_list_box_new().
func ListBoxNew() (*ListBox, error) {
c := C.gtk_list_box_new()
if c == nil {
return nil, nilPtrErr
}
return wrapListBox(wrapObject(unsafe.Pointer(c))), nil
}
// Prepend is a wrapper around gtk_list_box_prepend().
func (v *ListBox) Prepend(child IWidget) {
C.gtk_list_box_prepend(v.native(), child.toWidget())
}
// Insert is a wrapper around gtk_list_box_insert().
func (v *ListBox) Insert(child IWidget, position int) {
C.gtk_list_box_insert(v.native(), child.toWidget(), C.gint(position))
}
// SelectRow is a wrapper around gtk_list_box_select_row().
func (v *ListBox) SelectRow(row *ListBoxRow) {
C.gtk_list_box_select_row(v.native(), row.native())
}
// GetSelectedRow is a wrapper around gtk_list_box_get_selected_row().
func (v *ListBox) GetSelectedRow() *ListBoxRow {
c := C.gtk_list_box_get_selected_row(v.native())
if c == nil {
return nil
}
return wrapListBoxRow(wrapObject(unsafe.Pointer(c)))
}
// SetSelectionMode is a wrapper around gtk_list_box_set_selection_mode().
func (v *ListBox) SetSelectionMode(mode SelectionMode) {
C.gtk_list_box_set_selection_mode(v.native(), C.GtkSelectionMode(mode))
}
// GetSelectionMode is a wrapper around gtk_list_box_get_selection_mode()
func (v *ListBox) GetSelectionMode() SelectionMode {
c := C.gtk_list_box_get_selection_mode(v.native())
return SelectionMode(c)
}
// SetActivateOnSingleClick is a wrapper around gtk_list_box_set_activate_on_single_click().
func (v *ListBox) SetActivateOnSingleClick(single bool) {
C.gtk_list_box_set_activate_on_single_click(v.native(), gbool(single))
}
// GetActivateOnSingleClick is a wrapper around gtk_list_box_get_activate_on_single_click().
func (v *ListBox) GetActivateOnSingleClick() bool {
c := C.gtk_list_box_get_activate_on_single_click(v.native())
return gobool(c)
}
// GetAdjustment is a wrapper around gtk_list_box_get_adjustment().
func (v *ListBox) GetAdjustment() *Adjustment {
c := C.gtk_list_box_get_adjustment(v.native())
obj := wrapObject(unsafe.Pointer(c))
return &Adjustment{glib.InitiallyUnowned{obj}}
}
// SetAdjustment is a wrapper around gtk_list_box_set_adjustment().
func (v *ListBox) SetAdjuctment(adjustment *Adjustment) {
C.gtk_list_box_set_adjustment(v.native(), adjustment.native())
}
// SetPlaceholder is a wrapper around gtk_list_box_set_placeholder().
func (v *ListBox) SetPlaceholder(placeholder IWidget) {
C.gtk_list_box_set_placeholder(v.native(), placeholder.toWidget())
}
// GetRowAtIndex is a wrapper around gtk_list_box_get_row_at_index().
func (v *ListBox) GetRowAtIndex(index int) *ListBoxRow {
c := C.gtk_list_box_get_row_at_index(v.native(), C.gint(index))
if c == nil {
return nil
}
return wrapListBoxRow(wrapObject(unsafe.Pointer(c)))
}
// GetRowAtY is a wrapper around gtk_list_box_get_row_at_y().
func (v *ListBox) GetRowAtY(y int) *ListBoxRow {
c := C.gtk_list_box_get_row_at_y(v.native(), C.gint(y))
if c == nil {
return nil
}
return wrapListBoxRow(wrapObject(unsafe.Pointer(c)))
}
// InvalidateFilter is a wrapper around gtk_list_box_invalidate_filter().
func (v *ListBox) InvalidateFilter() {
C.gtk_list_box_invalidate_filter(v.native())
}
// InvalidateHeaders is a wrapper around gtk_list_box_invalidate_headers().
func (v *ListBox) InvalidateHeaders() {
C.gtk_list_box_invalidate_headers(v.native())
}
// InvalidateSort is a wrapper around gtk_list_box_invalidate_sort().
func (v *ListBox) InvalidateSort() {
C.gtk_list_box_invalidate_sort(v.native())
}
// TODO: SetFilterFunc
// TODO: SetHeaderFunc
// TODO: SetSortFunc
// DragHighlightRow is a wrapper around gtk_list_box_drag_highlight_row()
func (v *ListBox) DragHighlightRow(row *ListBoxRow) {
C.gtk_list_box_drag_highlight_row(v.native(), row.native())
}
/*
* GtkListBoxRow
*/
// ListBoxRow is a representation of GTK's GtkListBoxRow.
type ListBoxRow struct {
Bin
}
// native returns a pointer to the underlying GtkListBoxRow.
func (v *ListBoxRow) native() *C.GtkListBoxRow {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkListBoxRow(p)
}
func marshalListBoxRow(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapListBoxRow(obj), nil
}
func wrapListBoxRow(obj *glib.Object) *ListBoxRow {
return &ListBoxRow{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
func ListBoxRowNew() (*ListBoxRow, error) {
c := C.gtk_list_box_row_new()
if c == nil {
return nil, nilPtrErr
}
return wrapListBoxRow(wrapObject(unsafe.Pointer(c))), nil
}
// Changed is a wrapper around gtk_list_box_row_changed().
func (v *ListBoxRow) Changed() {
C.gtk_list_box_row_changed(v.native())
}
// GetHeader is a wrapper around gtk_list_box_row_get_header().
func (v *ListBoxRow) GetHeader() *Widget {
c := C.gtk_list_box_row_get_header(v.native())
if c == nil {
return nil
}
return wrapWidget(wrapObject(unsafe.Pointer(c)))
}
// SetHeader is a wrapper around gtk_list_box_row_get_header().
func (v *ListBoxRow) SetHeader(header IWidget) {
C.gtk_list_box_row_set_header(v.native(), header.toWidget())
}
// GetIndex is a wrapper around gtk_list_box_row_get_index()
func (v *ListBoxRow) GetIndex() int {
c := C.gtk_list_box_row_get_index(v.native())
return int(c)
}
/*
* GtkRevealer
*/
// Revealer is a representation of GTK's GtkRevealer
type Revealer struct {
Bin
}
// native returns a pointer to the underlying GtkRevealer.
func (v *Revealer) native() *C.GtkRevealer {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkRevealer(p)
}
func marshalRevealer(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapRevealer(obj), nil
}
func wrapRevealer(obj *glib.Object) *Revealer {
return &Revealer{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// RevealerNew is a wrapper around gtk_revealer_new()
func RevealerNew() (*Revealer, error) {
c := C.gtk_revealer_new()
if c == nil {
return nil, nilPtrErr
}
return wrapRevealer(wrapObject(unsafe.Pointer(c))), nil
}
// GetRevealChild is a wrapper around gtk_revealer_get_reveal_child().
func (v *Revealer) GetRevealChild() bool {
c := C.gtk_revealer_get_reveal_child(v.native())
return gobool(c)
}
// SetRevealChild is a wrapper around gtk_revealer_set_reveal_child().
func (v *Revealer) SetRevealChild(revealChild bool) {
C.gtk_revealer_set_reveal_child(v.native(), gbool(revealChild))
}
// GetChildRevealed is a wrapper around gtk_revealer_get_child_revealed().
func (v *Revealer) GetChildRevealed() bool {
c := C.gtk_revealer_get_child_revealed(v.native())
return gobool(c)
}
// GetTransitionDuration is a wrapper around gtk_revealer_get_transition_duration()
func (v *Revealer) GetTransitionDuration() uint {
c := C.gtk_revealer_get_transition_duration(v.native())
return uint(c)
}
// SetTransitionDuration is a wrapper around gtk_revealer_set_transition_duration().
func (v *Revealer) SetTransitionDuration(duration uint) {
C.gtk_revealer_set_transition_duration(v.native(), C.guint(duration))
}
// GetTransitionType is a wrapper around gtk_revealer_get_transition_type()
func (v *Revealer) GetTransitionType() RevealerTransitionType {
c := C.gtk_revealer_get_transition_type(v.native())
return RevealerTransitionType(c)
}
// SetTransitionType is a wrapper around gtk_revealer_set_transition_type()
func (v *Revealer) SetTransitionType(transition RevealerTransitionType) {
t := C.GtkRevealerTransitionType(transition)
C.gtk_revealer_set_transition_type(v.native(), t)
}
/*
* GtkSearchBar
*/
// SearchBar is a representation of GTK's GtkSearchBar.
type SearchBar struct {
Bin
}
// native returns a pointer to the underlying GtkSearchBar.
func (v *SearchBar) native() *C.GtkSearchBar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkSearchBar(p)
}
func marshalSearchBar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapSearchBar(obj), nil
}
func wrapSearchBar(obj *glib.Object) *SearchBar {
return &SearchBar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// SearchBarNew is a wrapper around gtk_search_bar_new()
func SearchBarNew() (*SearchBar, error) {
c := C.gtk_search_bar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapSearchBar(wrapObject(unsafe.Pointer(c))), nil
}
// ConnectEntry is a wrapper around gtk_search_bar_connect_entry().
func (v *SearchBar) ConnectEntry(entry IEntry) {
C.gtk_search_bar_connect_entry(v.native(), entry.toEntry())
}
// GetSearchMode is a wrapper around gtk_search_bar_get_search_mode().
func (v *SearchBar) GetSearchMode() bool {
c := C.gtk_search_bar_get_search_mode(v.native())
return gobool(c)
}
// SetSearchMode is a wrapper around gtk_search_bar_set_search_mode().
func (v *SearchBar) SetSearchMode(searchMode bool) {
C.gtk_search_bar_set_search_mode(v.native(), gbool(searchMode))
}
// GetShowCloseButton is a wrapper arounb gtk_search_bar_get_show_close_button().
func (v *SearchBar) GetShowCloseButton() bool {
c := C.gtk_search_bar_get_show_close_button(v.native())
return gobool(c)
}
// SetShowCloseButton is a wrapper around gtk_search_bar_set_show_close_button()
func (v *SearchBar) SetShowCloseButton(visible bool) {
C.gtk_search_bar_set_show_close_button(v.native(), gbool(visible))
}
// HandleEvent is a wrapper around gtk_search_bar_handle_event()
func (v *SearchBar) HandleEvent(event *gdk.Event) {
e := (*C.GdkEvent)(unsafe.Pointer(event.Native()))
C.gtk_search_bar_handle_event(v.native(), e)
}
/*
* GtkStack
*/
// Stack is a representation of GTK's GtkStack.
type Stack struct {
Container
}
// native returns a pointer to the underlying GtkStack.
func (v *Stack) native() *C.GtkStack {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkStack(p)
}
func marshalStack(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapStack(obj), nil
}
func wrapStack(obj *glib.Object) *Stack {
return &Stack{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// StackNew is a wrapper around gtk_stack_new().
func StackNew() (*Stack, error) {
c := C.gtk_stack_new()
if c == nil {
return nil, nilPtrErr
}
return wrapStack(wrapObject(unsafe.Pointer(c))), nil
}
// AddNamed is a wrapper around gtk_stack_add_named().
func (v *Stack) AddNamed(child IWidget, name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_stack_add_named(v.native(), child.toWidget(), (*C.gchar)(cstr))
}
// AddTitled is a wrapper around gtk_stack_add_titled().
func (v *Stack) AddTitled(child IWidget, name, title string) {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
cTitle := C.CString(title)
defer C.free(unsafe.Pointer(cTitle))
C.gtk_stack_add_titled(v.native(), child.toWidget(), (*C.gchar)(cName),
(*C.gchar)(cTitle))
}
// SetVisibleChild is a wrapper around gtk_stack_set_visible_child().
func (v *Stack) SetVisibleChild(child IWidget) {
C.gtk_stack_set_visible_child(v.native(), child.toWidget())
}
// GetVisibleChild is a wrapper around gtk_stack_get_visible_child().
func (v *Stack) GetVisibleChild() *Widget {
c := C.gtk_stack_get_visible_child(v.native())
if c == nil {
return nil
}
return wrapWidget(wrapObject(unsafe.Pointer(c)))
}
// SetVisibleChildName is a wrapper around gtk_stack_set_visible_child_name().
func (v *Stack) SetVisibleChildName(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_stack_set_visible_child_name(v.native(), (*C.gchar)(cstr))
}
// GetVisibleChildName is a wrapper around gtk_stack_get_visible_child_name().
func (v *Stack) GetVisibleChildName() string {
c := C.gtk_stack_get_visible_child_name(v.native())
return C.GoString((*C.char)(c))
}
// SetVisibleChildFull is a wrapper around gtk_stack_set_visible_child_full().
func (v *Stack) SetVisibleChildFull(name string, transaction StackTransitionType) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_stack_set_visible_child_full(v.native(), (*C.gchar)(cstr),
C.GtkStackTransitionType(transaction))
}
// SetHomogeneous is a wrapper around gtk_stack_set_homogeneous().
func (v *Stack) SetHomogeneous(homogeneous bool) {
C.gtk_stack_set_homogeneous(v.native(), gbool(homogeneous))
}
// GetHomogeneous is a wrapper around gtk_stack_get_homogeneous().
func (v *Stack) GetHomogeneous() bool {
c := C.gtk_stack_get_homogeneous(v.native())
return gobool(c)
}
// SetTransitionDuration is a wrapper around gtk_stack_set_transition_duration().
func (v *Stack) SetTransitionDuration(duration uint) {
C.gtk_stack_set_transition_duration(v.native(), C.guint(duration))
}
// GetTransitionDuration is a wrapper around gtk_stack_get_transition_duration().
func (v *Stack) GetTransitionDuration() uint {
c := C.gtk_stack_get_transition_duration(v.native())
return uint(c)
}
// SetTransitionType is a wrapper around gtk_stack_set_transition_type().
func (v *Stack) SetTransitionType(transition StackTransitionType) {
C.gtk_stack_set_transition_type(v.native(), C.GtkStackTransitionType(transition))
}
// GetTransitionType is a wrapper around gtk_stack_get_transition_type().
func (v *Stack) GetTransitionType() StackTransitionType {
c := C.gtk_stack_get_transition_type(v.native())
return StackTransitionType(c)
}

@ -0,0 +1,61 @@
/*
* 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.
*/
static GtkHeaderBar *
toGtkHeaderBar(void *p)
{
return (GTK_HEADER_BAR(p));
}
static GtkListBox *
toGtkListBox(void *p)
{
return (GTK_LIST_BOX(p));
}
static GtkListBoxRow *
toGtkListBoxRow(void *p)
{
return (GTK_LIST_BOX_ROW(p));
}
static GtkRevealer *
toGtkRevealer(void *p)
{
return (GTK_REVEALER(p));
}
static GtkSearchBar *
toGtkSearchBar(void *p)
{
return (GTK_SEARCH_BAR(p));
}
static GtkStack *
toGtkStack(void *p)
{
return (GTK_STACK(p));
}
static GtkStackSwitcher *
toGtkStackSwitcher(void *p)
{
return (GTK_STACK_SWITCHER(p));
}

@ -0,0 +1,37 @@
// 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.8, and
// and should not be included in a build intended to target any older GTK
// versions. To target an older build, such as 3.8, use
// 'go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.18
// is assumed and this file is built.
// +build !gtk_3_6
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
/*
* Constants
*/
const (
STATE_FLAG_DIR_LTR StateFlags = C.GTK_STATE_FLAG_DIR_LTR
STATE_FLAG_DIR_RTL StateFlags = C.GTK_STATE_FLAG_DIR_RTL
)

@ -0,0 +1,106 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_info_bar_get_type()), marshalInfoBar},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkInfoBar"] = wrapInfoBar
}
type InfoBar struct {
Box
}
func (v *InfoBar) native() *C.GtkInfoBar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkInfoBar(p)
}
func marshalInfoBar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapInfoBar(wrapObject(unsafe.Pointer(c))), nil
}
func wrapInfoBar(obj *glib.Object) *InfoBar {
return &InfoBar{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
func InfoBarNew() (*InfoBar, error) {
c := C.gtk_info_bar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapInfoBar(wrapObject(unsafe.Pointer(c))), nil
}
func (v *InfoBar) AddActionWidget(w IWidget, responseId ResponseType) {
C.gtk_info_bar_add_action_widget(v.native(), w.toWidget(), C.gint(responseId))
}
func (v *InfoBar) AddButton(buttonText string, responseId ResponseType) {
cstr := C.CString(buttonText)
defer C.free(unsafe.Pointer(cstr))
C.gtk_info_bar_add_button(v.native(), (*C.gchar)(cstr), C.gint(responseId))
}
func (v *InfoBar) SetResponseSensitive(responseId ResponseType, setting bool) {
C.gtk_info_bar_set_response_sensitive(v.native(), C.gint(responseId), gbool(setting))
}
func (v *InfoBar) SetDefaultResponse(responseId ResponseType) {
C.gtk_info_bar_set_default_response(v.native(), C.gint(responseId))
}
func (v *InfoBar) SetMessageType(messageType MessageType) {
C.gtk_info_bar_set_message_type(v.native(), C.GtkMessageType(messageType))
}
func (v *InfoBar) GetMessageType() MessageType {
messageType := C.gtk_info_bar_get_message_type(v.native())
return MessageType(messageType)
}
func (v *InfoBar) GetActionArea() (*Widget, error) {
c := C.gtk_info_bar_get_action_area(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
func (v *InfoBar) GetContentArea() (*Box, error) {
c := C.gtk_info_bar_get_content_area(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapBox(wrapObject(unsafe.Pointer(c))), nil
}
func (v *InfoBar) GetShowCloseButton() bool {
b := C.gtk_info_bar_get_show_close_button(v.native())
return gobool(b)
}
func (v *InfoBar) SetShowCloseButton(setting bool) {
C.gtk_info_bar_set_show_close_button(v.native(), gbool(setting))
}

@ -0,0 +1,266 @@
// Same copyright and license as the rest of the files in this project
// This file contains style related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/pango"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkLabel
*/
// Label is a representation of GTK's GtkLabel.
type Label struct {
Widget
}
// native returns a pointer to the underlying GtkLabel.
func (v *Label) native() *C.GtkLabel {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkLabel(p)
}
func marshalLabel(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapLabel(obj), nil
}
func wrapLabel(obj *glib.Object) *Label {
return &Label{Widget{glib.InitiallyUnowned{obj}}}
}
// LabelNew is a wrapper around gtk_label_new().
func LabelNew(str string) (*Label, error) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_label_new((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapLabel(obj), nil
}
// SetText is a wrapper around gtk_label_set_text().
func (v *Label) SetText(str string) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
C.gtk_label_set_text(v.native(), (*C.gchar)(cstr))
}
// SetMarkup is a wrapper around gtk_label_set_markup().
func (v *Label) SetMarkup(str string) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
C.gtk_label_set_markup(v.native(), (*C.gchar)(cstr))
}
// SetMarkupWithMnemonic is a wrapper around
// gtk_label_set_markup_with_mnemonic().
func (v *Label) SetMarkupWithMnemonic(str string) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
C.gtk_label_set_markup_with_mnemonic(v.native(), (*C.gchar)(cstr))
}
// SetPattern is a wrapper around gtk_label_set_pattern().
func (v *Label) SetPattern(patern string) {
cstr := C.CString(patern)
defer C.free(unsafe.Pointer(cstr))
C.gtk_label_set_pattern(v.native(), (*C.gchar)(cstr))
}
// SetJustify is a wrapper around gtk_label_set_justify().
func (v *Label) SetJustify(jtype Justification) {
C.gtk_label_set_justify(v.native(), C.GtkJustification(jtype))
}
// SetEllipsize is a wrapper around gtk_label_set_ellipsize().
func (v *Label) SetEllipsize(mode pango.EllipsizeMode) {
C.gtk_label_set_ellipsize(v.native(), C.PangoEllipsizeMode(mode))
}
// GetWidthChars is a wrapper around gtk_label_get_width_chars().
func (v *Label) GetWidthChars() int {
c := C.gtk_label_get_width_chars(v.native())
return int(c)
}
// SetWidthChars is a wrapper around gtk_label_set_width_chars().
func (v *Label) SetWidthChars(nChars int) {
C.gtk_label_set_width_chars(v.native(), C.gint(nChars))
}
// GetMaxWidthChars is a wrapper around gtk_label_get_max_width_chars().
func (v *Label) GetMaxWidthChars() int {
c := C.gtk_label_get_max_width_chars(v.native())
return int(c)
}
// SetMaxWidthChars is a wrapper around gtk_label_set_max_width_chars().
func (v *Label) SetMaxWidthChars(nChars int) {
C.gtk_label_set_max_width_chars(v.native(), C.gint(nChars))
}
// GetLineWrap is a wrapper around gtk_label_get_line_wrap().
func (v *Label) GetLineWrap() bool {
c := C.gtk_label_get_line_wrap(v.native())
return gobool(c)
}
// SetLineWrap is a wrapper around gtk_label_set_line_wrap().
func (v *Label) SetLineWrap(wrap bool) {
C.gtk_label_set_line_wrap(v.native(), gbool(wrap))
}
// SetLineWrapMode is a wrapper around gtk_label_set_line_wrap_mode().
func (v *Label) SetLineWrapMode(wrapMode pango.WrapMode) {
C.gtk_label_set_line_wrap_mode(v.native(), C.PangoWrapMode(wrapMode))
}
// GetSelectable is a wrapper around gtk_label_get_selectable().
func (v *Label) GetSelectable() bool {
c := C.gtk_label_get_selectable(v.native())
return gobool(c)
}
// GetText is a wrapper around gtk_label_get_text().
func (v *Label) GetText() (string, error) {
c := C.gtk_label_get_text(v.native())
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// GetJustify is a wrapper around gtk_label_get_justify().
func (v *Label) GetJustify() Justification {
c := C.gtk_label_get_justify(v.native())
return Justification(c)
}
// GetEllipsize is a wrapper around gtk_label_get_ellipsize().
func (v *Label) GetEllipsize() pango.EllipsizeMode {
c := C.gtk_label_get_ellipsize(v.native())
return pango.EllipsizeMode(c)
}
// GetCurrentUri is a wrapper around gtk_label_get_current_uri().
func (v *Label) GetCurrentUri() string {
c := C.gtk_label_get_current_uri(v.native())
return C.GoString((*C.char)(c))
}
// GetTrackVisitedLinks is a wrapper around gtk_label_get_track_visited_links().
func (v *Label) GetTrackVisitedLinks() bool {
c := C.gtk_label_get_track_visited_links(v.native())
return gobool(c)
}
// SetTrackVisitedLinks is a wrapper around gtk_label_set_track_visited_links().
func (v *Label) SetTrackVisitedLinks(trackLinks bool) {
C.gtk_label_set_track_visited_links(v.native(), gbool(trackLinks))
}
// GetAngle is a wrapper around gtk_label_get_angle().
func (v *Label) GetAngle() float64 {
c := C.gtk_label_get_angle(v.native())
return float64(c)
}
// SetAngle is a wrapper around gtk_label_set_angle().
func (v *Label) SetAngle(angle float64) {
C.gtk_label_set_angle(v.native(), C.gdouble(angle))
}
// GetSelectionBounds is a wrapper around gtk_label_get_selection_bounds().
func (v *Label) GetSelectionBounds() (start, end int, nonEmpty bool) {
var cstart, cend C.gint
c := C.gtk_label_get_selection_bounds(v.native(), &cstart, &cend)
return int(cstart), int(cend), gobool(c)
}
// GetSingleLineMode is a wrapper around gtk_label_get_single_line_mode().
func (v *Label) GetSingleLineMode() bool {
c := C.gtk_label_get_single_line_mode(v.native())
return gobool(c)
}
// SetSingleLineMode is a wrapper around gtk_label_set_single_line_mode().
func (v *Label) SetSingleLineMode(mode bool) {
C.gtk_label_set_single_line_mode(v.native(), gbool(mode))
}
// GetUseMarkup is a wrapper around gtk_label_get_use_markup().
func (v *Label) GetUseMarkup() bool {
c := C.gtk_label_get_use_markup(v.native())
return gobool(c)
}
// SetUseMarkup is a wrapper around gtk_label_set_use_markup().
func (v *Label) SetUseMarkup(use bool) {
C.gtk_label_set_use_markup(v.native(), gbool(use))
}
// GetUseUnderline is a wrapper around gtk_label_get_use_underline().
func (v *Label) GetUseUnderline() bool {
c := C.gtk_label_get_use_underline(v.native())
return gobool(c)
}
// SetUseUnderline is a wrapper around gtk_label_set_use_underline().
func (v *Label) SetUseUnderline(use bool) {
C.gtk_label_set_use_underline(v.native(), gbool(use))
}
// LabelNewWithMnemonic is a wrapper around gtk_label_new_with_mnemonic().
func LabelNewWithMnemonic(str string) (*Label, error) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_label_new_with_mnemonic((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapLabel(obj), nil
}
// SelectRegion is a wrapper around gtk_label_select_region().
func (v *Label) SelectRegion(startOffset, endOffset int) {
C.gtk_label_select_region(v.native(), C.gint(startOffset),
C.gint(endOffset))
}
// SetSelectable is a wrapper around gtk_label_set_selectable().
func (v *Label) SetSelectable(setting bool) {
C.gtk_label_set_selectable(v.native(), gbool(setting))
}
// SetLabel is a wrapper around gtk_label_set_label().
func (v *Label) SetLabel(str string) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
C.gtk_label_set_label(v.native(), (*C.gchar)(cstr))
}
// GetLabel is a wrapper around gtk_label_get_label().
func (v *Label) GetLabel() string {
c := C.gtk_label_get_label(v.native())
if c == nil {
return ""
}
return C.GoString((*C.char)(c))
}

@ -0,0 +1,151 @@
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_level_bar_mode_get_type()), marshalLevelBarMode},
{glib.Type(C.gtk_level_bar_get_type()), marshalLevelBar},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkLevelBar"] = wrapLevelBar
}
// LevelBarMode is a representation of GTK's GtkLevelBarMode.
type LevelBarMode int
const (
LEVEL_BAR_MODE_CONTINUOUS LevelBarMode = C.GTK_LEVEL_BAR_MODE_CONTINUOUS
LEVEL_BAR_MODE_DISCRETE LevelBarMode = C.GTK_LEVEL_BAR_MODE_DISCRETE
)
func marshalLevelBarMode(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return LevelBarMode(c), nil
}
/*
* GtkLevelBar
*/
type LevelBar struct {
Widget
}
// native returns a pointer to the underlying GtkLevelBar.
func (v *LevelBar) native() *C.GtkLevelBar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkLevelBar(p)
}
func marshalLevelBar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapLevelBar(obj), nil
}
func wrapLevelBar(obj *glib.Object) *LevelBar {
return &LevelBar{Widget{glib.InitiallyUnowned{obj}}}
}
// LevelBarNew() is a wrapper around gtk_level_bar_new().
func LevelBarNew() (*LevelBar, error) {
c := C.gtk_level_bar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapLevelBar(wrapObject(unsafe.Pointer(c))), nil
}
// LevelBarNewForInterval() is a wrapper around gtk_level_bar_new_for_interval().
func LevelBarNewForInterval(min_value, max_value float64) (*LevelBar, error) {
c := C.gtk_level_bar_new_for_interval(C.gdouble(min_value), C.gdouble(max_value))
if c == nil {
return nil, nilPtrErr
}
return wrapLevelBar(wrapObject(unsafe.Pointer(c))), nil
}
// SetMode() is a wrapper around gtk_level_bar_set_mode().
func (v *LevelBar) SetMode(m LevelBarMode) {
C.gtk_level_bar_set_mode(v.native(), C.GtkLevelBarMode(m))
}
// GetMode() is a wrapper around gtk_level_bar_get_mode().
func (v *LevelBar) GetMode() LevelBarMode {
return LevelBarMode(C.gtk_level_bar_get_mode(v.native()))
}
// SetValue() is a wrapper around gtk_level_bar_set_value().
func (v *LevelBar) SetValue(value float64) {
C.gtk_level_bar_set_value(v.native(), C.gdouble(value))
}
// GetValue() is a wrapper around gtk_level_bar_get_value().
func (v *LevelBar) GetValue() float64 {
c := C.gtk_level_bar_get_value(v.native())
return float64(c)
}
// SetMinValue() is a wrapper around gtk_level_bar_set_min_value().
func (v *LevelBar) SetMinValue(value float64) {
C.gtk_level_bar_set_min_value(v.native(), C.gdouble(value))
}
// GetMinValue() is a wrapper around gtk_level_bar_get_min_value().
func (v *LevelBar) GetMinValue() float64 {
c := C.gtk_level_bar_get_min_value(v.native())
return float64(c)
}
// SetMaxValue() is a wrapper around gtk_level_bar_set_max_value().
func (v *LevelBar) SetMaxValue(value float64) {
C.gtk_level_bar_set_max_value(v.native(), C.gdouble(value))
}
// GetMaxValue() is a wrapper around gtk_level_bar_get_max_value().
func (v *LevelBar) GetMaxValue() float64 {
c := C.gtk_level_bar_get_max_value(v.native())
return float64(c)
}
const (
LEVEL_BAR_OFFSET_LOW string = C.GTK_LEVEL_BAR_OFFSET_LOW
LEVEL_BAR_OFFSET_HIGH string = C.GTK_LEVEL_BAR_OFFSET_HIGH
)
// AddOffsetValue() is a wrapper around gtk_level_bar_add_offset_value().
func (v *LevelBar) AddOffsetValue(name string, value float64) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_level_bar_add_offset_value(v.native(), (*C.gchar)(cstr), C.gdouble(value))
}
// RemoveOffsetValue() is a wrapper around gtk_level_bar_remove_offset_value().
func (v *LevelBar) RemoveOffsetValue(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_level_bar_remove_offset_value(v.native(), (*C.gchar)(cstr))
}
// GetOffsetValue() is a wrapper around gtk_level_bar_get_offset_value().
func (v *LevelBar) GetOffsetValue(name string) (float64, bool) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
var value C.gdouble
c := C.gtk_level_bar_get_offset_value(v.native(), (*C.gchar)(cstr), &value)
return float64(value), gobool(c)
}

@ -0,0 +1,18 @@
// +build !gtk_3_6
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
// SetInverted() is a wrapper around gtk_level_bar_set_inverted().
func (v *LevelBar) SetInverted(inverted bool) {
C.gtk_level_bar_set_inverted(v.native(), gbool(inverted))
}
// GetInverted() is a wrapper around gtk_level_bar_get_inverted().
func (v *LevelBar) GetInverted() bool {
c := C.gtk_level_bar_get_inverted(v.native())
return gobool(c)
}

@ -0,0 +1,96 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkMenuShell
*/
// MenuShell is a representation of GTK's GtkMenuShell.
type MenuShell struct {
Container
}
// native returns a pointer to the underlying GtkMenuShell.
func (v *MenuShell) native() *C.GtkMenuShell {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkMenuShell(p)
}
func marshalMenuShell(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapMenuShell(obj), nil
}
func wrapMenuShell(obj *glib.Object) *MenuShell {
return &MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// Append is a wrapper around gtk_menu_shell_append().
func (v *MenuShell) Append(child IMenuItem) {
C.gtk_menu_shell_append(v.native(), child.toWidget())
}
// Prepend is a wrapper around gtk_menu_shell_prepend().
func (v *MenuShell) Prepend(child IMenuItem) {
C.gtk_menu_shell_prepend(v.native(), child.toWidget())
}
// Insert is a wrapper around gtk_menu_shell_insert().
func (v *MenuShell) Insert(child IMenuItem, position int) {
C.gtk_menu_shell_insert(v.native(), child.toWidget(), C.gint(position))
}
// Deactivate is a wrapper around gtk_menu_shell_deactivate().
func (v *MenuShell) Deactivate() {
C.gtk_menu_shell_deactivate(v.native())
}
// SelectItem is a wrapper around gtk_menu_shell_select_item().
func (v *MenuShell) SelectItem(child IMenuItem) {
C.gtk_menu_shell_select_item(v.native(), child.toWidget())
}
// SelectFirst is a wrapper around gtk_menu_shell_select_first().
func (v *MenuShell) SelectFirst(searchSensitive bool) {
C.gtk_menu_shell_select_first(v.native(), gbool(searchSensitive))
}
// Deselect is a wrapper around gtk_menu_shell_deselect().
func (v *MenuShell) Deselect() {
C.gtk_menu_shell_deselect(v.native())
}
// ActivateItem is a wrapper around gtk_menu_shell_activate_item().
func (v *MenuShell) ActivateItem(child IMenuItem, forceDeactivate bool) {
C.gtk_menu_shell_activate_item(v.native(), child.toWidget(), gbool(forceDeactivate))
}
// Cancel is a wrapper around gtk_menu_shell_cancel().
func (v *MenuShell) Cancel() {
C.gtk_menu_shell_cancel(v.native())
}
// SetTakeFocus is a wrapper around gtk_menu_shell_set_take_focus().
func (v *MenuShell) SetTakeFocus(takeFocus bool) {
C.gtk_menu_shell_set_take_focus(v.native(), gbool(takeFocus))
}
// gboolean gtk_menu_shell_get_take_focus ()
// GtkWidget * gtk_menu_shell_get_selected_item ()
// GtkWidget * gtk_menu_shell_get_parent_shell ()
// void gtk_menu_shell_bind_model ()

@ -0,0 +1,83 @@
// 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 <gtk/gtk.h>
// #include "popover_since_3_12.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_popover_get_type()), marshalPopover},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkPopover"] = wrapPopover
}
//TODO(sjon): Implement GtkPopover
//GtkPopover
type Popover struct {
Bin
}
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)))
return wrapPopover(wrapObject(unsafe.Pointer(c))), nil
}
func wrapPopover(obj *glib.Object) *Popover {
return &Popover{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
//gtk_popover_new()
func PopoverNew(relative IWidget) (*Popover, error) {
//Takes relative to widget
var c *C.struct__GtkWidget
if relative == nil {
c = C.gtk_popover_new(nil)
} else {
c = C.gtk_popover_new(relative.toWidget())
}
if c == nil {
return nil, nilPtrErr
}
return wrapPopover(wrapObject(unsafe.Pointer(c))), nil
}

@ -0,0 +1,25 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12
/*
* 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.
*/
static GtkPopover *
toGtkPopover(void *p)
{
return (GTK_POPOVER(p));
}

@ -0,0 +1,30 @@
// +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.18/api-index-3-18.html
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
//void
//gtk_popover_set_default_widget (GtkPopover *popover, GtkWidget *widget);
func (p *Popover) SetDefaultWidget(widget IWidget) {
C.gtk_popover_set_default_widget(p.native(), widget.toWidget())
}
//GtkWidget *
//gtk_popover_get_default_widget (GtkPopover *popover);
func (p *Popover) GetDefaultWidget() *Widget {
w := C.gtk_popover_get_default_widget(p.native())
if w == nil {
return nil
}
return &Widget{glib.InitiallyUnowned{wrapObject(unsafe.Pointer(w))}}
}

@ -0,0 +1,53 @@
package gtk
// #include <gtk/gtk.h>
// #include "settings.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
{glib.Type(C.gtk_settings_get_type()), marshalSettings},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkSettings"] = wrapSettings
}
//GtkSettings
type Settings struct {
*glib.Object
}
func (v *Settings) native() *C.GtkSettings {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkSettings(p)
}
func marshalSettings(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return wrapSettings(wrapObject(unsafe.Pointer(c))), nil
}
func wrapSettings(obj *glib.Object) *Settings {
return &Settings{obj}
}
//Get the global non window specific settings
func SettingsGetDefault() (*Settings, error) {
c := C.gtk_settings_get_default()
if c == nil {
return nil, nilPtrErr
}
return wrapSettings(wrapObject(unsafe.Pointer(c))), nil
}

@ -0,0 +1,5 @@
static GtkSettings *
toGtkSettings(void *p)
{
return (GTK_SETTINGS(p));
}

@ -0,0 +1,27 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10
// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_since_3_10.go.h"
import "C"
import (
"unsafe"
)
// GetChildByName is a wrapper around gtk_stack_get_child_by_name().
func (v *Stack) GetChildByName(name string) *Widget {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_stack_get_child_by_name(v.native(), (*C.gchar)(cstr))
if c == nil {
return nil
}
return wrapWidget(wrapObject(unsafe.Pointer(c)))
}

@ -0,0 +1,78 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
// +build !gtk_3_6,!gtk_3_8
// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_since_3_10.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
//Contribute to casting
for k, v := range map[string]WrapFn{
"GtkStackSwitcher": wrapStackSwitcher,
} {
WrapMap[k] = v
}
}
/*
* GtkStackSwitcher
*/
// StackSwitcher is a representation of GTK's GtkStackSwitcher
type StackSwitcher struct {
Box
}
// native returns a pointer to the underlying GtkStackSwitcher.
func (v *StackSwitcher) native() *C.GtkStackSwitcher {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkStackSwitcher(p)
}
func marshalStackSwitcher(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapStackSwitcher(obj), nil
}
func wrapStackSwitcher(obj *glib.Object) *StackSwitcher {
return &StackSwitcher{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// StackSwitcherNew is a wrapper around gtk_stack_switcher_new().
func StackSwitcherNew() (*StackSwitcher, error) {
c := C.gtk_stack_switcher_new()
if c == nil {
return nil, nilPtrErr
}
return wrapStackSwitcher(wrapObject(unsafe.Pointer(c))), nil
}
// SetStack is a wrapper around gtk_stack_switcher_set_stack().
func (v *StackSwitcher) SetStack(stack *Stack) {
C.gtk_stack_switcher_set_stack(v.native(), stack.native())
}
// GetStack is a wrapper around gtk_stack_switcher_get_stack().
func (v *StackSwitcher) GetStack() *Stack {
c := C.gtk_stack_switcher_get_stack(v.native())
if c == nil {
return nil
}
return wrapStack(wrapObject(unsafe.Pointer(c)))
}

@ -0,0 +1,232 @@
// Same copyright and license as the rest of the files in this project
// This file contains style related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
type StyleProviderPriority int
const (
STYLE_PROVIDER_PRIORITY_FALLBACK StyleProviderPriority = C.GTK_STYLE_PROVIDER_PRIORITY_FALLBACK
STYLE_PROVIDER_PRIORITY_THEME = C.GTK_STYLE_PROVIDER_PRIORITY_THEME
STYLE_PROVIDER_PRIORITY_SETTINGS = C.GTK_STYLE_PROVIDER_PRIORITY_SETTINGS
STYLE_PROVIDER_PRIORITY_APPLICATION = C.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
STYLE_PROVIDER_PRIORITY_USER = C.GTK_STYLE_PROVIDER_PRIORITY_USER
)
/*
* GtkStyleContext
*/
// StyleContext is a representation of GTK's GtkStyleContext.
type StyleContext struct {
*glib.Object
}
// native returns a pointer to the underlying GtkStyleContext.
func (v *StyleContext) native() *C.GtkStyleContext {
if v == nil || v.Object == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkStyleContext(p)
}
func wrapStyleContext(obj *glib.Object) *StyleContext {
return &StyleContext{obj}
}
func (v *StyleContext) AddClass(class_name string) {
cstr := C.CString(class_name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_style_context_add_class(v.native(), (*C.gchar)(cstr))
}
func (v *StyleContext) RemoveClass(class_name string) {
cstr := C.CString(class_name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_style_context_remove_class(v.native(), (*C.gchar)(cstr))
}
func fromNativeStyleContext(c *C.GtkStyleContext) (*StyleContext, error) {
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapStyleContext(obj), nil
}
// GetStyleContext is a wrapper around gtk_widget_get_style_context().
func (v *Widget) GetStyleContext() (*StyleContext, error) {
return fromNativeStyleContext(C.gtk_widget_get_style_context(v.native()))
}
// GetParent is a wrapper around gtk_style_context_get_parent().
func (v *StyleContext) GetParent() (*StyleContext, error) {
return fromNativeStyleContext(C.gtk_style_context_get_parent(v.native()))
}
// GetProperty is a wrapper around gtk_style_context_get_property().
func (v *StyleContext) GetProperty(property string, state StateFlags) (interface{}, error) {
cstr := (*C.gchar)(C.CString(property))
defer C.free(unsafe.Pointer(cstr))
var gval C.GValue
C.gtk_style_context_get_property(v.native(), cstr, C.GtkStateFlags(state), &gval)
val := glib.ValueFromNative(unsafe.Pointer(&gval))
return val.GoValue()
}
// GetStyleProperty is a wrapper around gtk_style_context_get_style_property().
func (v *StyleContext) GetStyleProperty(property string) (interface{}, error) {
cstr := (*C.gchar)(C.CString(property))
defer C.free(unsafe.Pointer(cstr))
var gval C.GValue
C.gtk_style_context_get_style_property(v.native(), cstr, &gval)
val := glib.ValueFromNative(unsafe.Pointer(&gval))
return val.GoValue()
}
// GetScreen is a wrapper around gtk_style_context_get_screen().
func (v *StyleContext) GetScreen() (*gdk.Screen, error) {
c := C.gtk_style_context_get_screen(v.native())
if c == nil {
return nil, nilPtrErr
}
d := &gdk.Screen{wrapObject(unsafe.Pointer(c))}
return d, nil
}
// GetState is a wrapper around gtk_style_context_get_state().
func (v *StyleContext) GetState() StateFlags {
return StateFlags(C.gtk_style_context_get_state(v.native()))
}
// GetColor is a wrapper around gtk_style_context_get_color().
func (v *StyleContext) GetColor(state StateFlags) *gdk.RGBA {
gdkColor := gdk.NewRGBA()
C.gtk_style_context_get_color(v.native(), C.GtkStateFlags(state), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native())))
return gdkColor
}
// LookupColor is a wrapper around gtk_style_context_lookup_color().
func (v *StyleContext) LookupColor(colorName string) (*gdk.RGBA, bool) {
cstr := (*C.gchar)(C.CString(colorName))
defer C.free(unsafe.Pointer(cstr))
gdkColor := gdk.NewRGBA()
ret := C.gtk_style_context_lookup_color(v.native(), cstr, (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native())))
return gdkColor, gobool(ret)
}
// StyleContextResetWidgets is a wrapper around gtk_style_context_reset_widgets().
func StyleContextResetWidgets(v *gdk.Screen) {
C.gtk_style_context_reset_widgets((*C.GdkScreen)(unsafe.Pointer(v.Native())))
}
// Restore is a wrapper around gtk_style_context_restore().
func (v *StyleContext) Restore() {
C.gtk_style_context_restore(v.native())
}
// Save is a wrapper around gtk_style_context_save().
func (v *StyleContext) Save() {
C.gtk_style_context_save(v.native())
}
// SetParent is a wrapper around gtk_style_context_set_parent().
func (v *StyleContext) SetParent(p *StyleContext) {
C.gtk_style_context_set_parent(v.native(), p.native())
}
// HasClass is a wrapper around gtk_style_context_has_class().
func (v *StyleContext) HasClass(className string) bool {
cstr := C.CString(className)
defer C.free(unsafe.Pointer(cstr))
return gobool(C.gtk_style_context_has_class(v.native(), (*C.gchar)(cstr)))
}
// SetScreen is a wrapper around gtk_style_context_set_screen().
func (v *StyleContext) SetScreen(s *gdk.Screen) {
C.gtk_style_context_set_screen(v.native(), (*C.GdkScreen)(unsafe.Pointer(s.Native())))
}
// SetState is a wrapper around gtk_style_context_set_state().
func (v *StyleContext) SetState(state StateFlags) {
C.gtk_style_context_set_state(v.native(), C.GtkStateFlags(state))
}
type IStyleProvider interface {
toStyleProvider() *C.GtkStyleProvider
}
// AddProvider is a wrapper around gtk_style_context_add_provider().
func (v *StyleContext) AddProvider(provider IStyleProvider, prio uint) {
C.gtk_style_context_add_provider(v.native(), provider.toStyleProvider(), C.guint(prio))
}
// AddProviderForScreen is a wrapper around gtk_style_context_add_provider_for_screen().
func AddProviderForScreen(s *gdk.Screen, provider IStyleProvider, prio uint) {
C.gtk_style_context_add_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider(), C.guint(prio))
}
// RemoveProvider is a wrapper around gtk_style_context_remove_provider().
func (v *StyleContext) RemoveProvider(provider IStyleProvider) {
C.gtk_style_context_remove_provider(v.native(), provider.toStyleProvider())
}
// RemoveProviderForScreen is a wrapper around gtk_style_context_remove_provider_for_screen().
func RemoveProviderForScreen(s *gdk.Screen, provider IStyleProvider) {
C.gtk_style_context_remove_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider())
}
// GtkStyleContext * gtk_style_context_new ()
// void gtk_style_context_get ()
// GtkTextDirection gtk_style_context_get_direction ()
// GtkJunctionSides gtk_style_context_get_junction_sides ()
// const GtkWidgetPath * gtk_style_context_get_path ()
// GdkFrameClock * gtk_style_context_get_frame_clock ()
// void gtk_style_context_get_style ()
// void gtk_style_context_get_style_valist ()
// void gtk_style_context_get_valist ()
// GtkCssSection * gtk_style_context_get_section ()
// void gtk_style_context_get_background_color ()
// void gtk_style_context_get_border_color ()
// void gtk_style_context_get_border ()
// void gtk_style_context_get_padding ()
// void gtk_style_context_get_margin ()
// const PangoFontDescription * gtk_style_context_get_font ()
// void gtk_style_context_invalidate ()
// gboolean gtk_style_context_state_is_running ()
// GtkIconSet * gtk_style_context_lookup_icon_set ()
// void gtk_style_context_cancel_animations ()
// void gtk_style_context_scroll_animations ()
// void gtk_style_context_notify_state_change ()
// void gtk_style_context_pop_animatable_region ()
// void gtk_style_context_push_animatable_region ()
// void gtk_style_context_set_background ()
// void gtk_style_context_set_direction ()
// void gtk_style_context_set_junction_sides ()
// void gtk_style_context_set_path ()
// void gtk_style_context_add_region ()
// void gtk_style_context_remove_region ()
// gboolean gtk_style_context_has_region ()
// GList * gtk_style_context_list_regions ()
// void gtk_style_context_set_frame_clock ()
// void gtk_style_context_set_scale ()
// gint gtk_style_context_get_scale ()
// GList * gtk_style_context_list_classes ()

@ -0,0 +1,404 @@
// 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"
/*
* GtkTextIter
*/
// TextIter is a representation of GTK's GtkTextIter
type TextIter C.GtkTextIter
// native returns a pointer to the underlying GtkTextIter.
func (v *TextIter) native() *C.GtkTextIter {
if v == nil {
return nil
}
return (*C.GtkTextIter)(v)
}
func marshalTextIter(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
return (*TextIter)(unsafe.Pointer(c)), nil
}
// GetBuffer is a wrapper around gtk_text_iter_get_buffer().
func (v *TextIter) GetBuffer() *TextBuffer {
c := C.gtk_text_iter_get_buffer(v.native())
if c == nil {
return nil
}
return wrapTextBuffer(wrapObject(unsafe.Pointer(c)))
}
// GetOffset is a wrapper around gtk_text_iter_get_offset().
func (v *TextIter) GetOffset() int {
return int(C.gtk_text_iter_get_offset(v.native()))
}
// GetLine is a wrapper around gtk_text_iter_get_line().
func (v *TextIter) GetLine() int {
return int(C.gtk_text_iter_get_line(v.native()))
}
// GetLineOffset is a wrapper around gtk_text_iter_get_line_offset().
func (v *TextIter) GetLineOffset() int {
return int(C.gtk_text_iter_get_line_offset(v.native()))
}
// GetLineIndex is a wrapper around gtk_text_iter_get_line_index().
func (v *TextIter) GetLineIndex() int {
return int(C.gtk_text_iter_get_line_index(v.native()))
}
// GetVisibleLineOffset is a wrapper around gtk_text_iter_get_visible_line_offset().
func (v *TextIter) GetVisibleLineOffset() int {
return int(C.gtk_text_iter_get_visible_line_offset(v.native()))
}
// GetVisibleLineIndex is a wrapper around gtk_text_iter_get_visible_line_index().
func (v *TextIter) GetVisibleLineIndex() int {
return int(C.gtk_text_iter_get_visible_line_index(v.native()))
}
// GetChar is a wrapper around gtk_text_iter_get_char().
func (v *TextIter) GetChar() rune {
return rune(C.gtk_text_iter_get_char(v.native()))
}
// GetSlice is a wrapper around gtk_text_iter_get_slice().
func (v *TextIter) GetSlice(end *TextIter) string {
c := C.gtk_text_iter_get_slice(v.native(), end.native())
return C.GoString((*C.char)(c))
}
// GetText is a wrapper around gtk_text_iter_get_text().
func (v *TextIter) GetText(end *TextIter) string {
c := C.gtk_text_iter_get_text(v.native(), end.native())
return C.GoString((*C.char)(c))
}
// GetVisibleSlice is a wrapper around gtk_text_iter_get_visible_slice().
func (v *TextIter) GetVisibleSlice(end *TextIter) string {
c := C.gtk_text_iter_get_visible_slice(v.native(), end.native())
return C.GoString((*C.char)(c))
}
// GetVisibleText is a wrapper around gtk_text_iter_get_visible_text().
func (v *TextIter) GetVisibleText(end *TextIter) string {
c := C.gtk_text_iter_get_visible_text(v.native(), end.native())
return C.GoString((*C.char)(c))
}
// BeginsTag is a wrapper around gtk_text_iter_begins_tag().
func (v *TextIter) BeginsTag(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_begins_tag(v.native(), v1.native()))
}
// EndsTag is a wrapper around gtk_text_iter_ends_tag().
func (v *TextIter) EndsTag(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_ends_tag(v.native(), v1.native()))
}
// TogglesTag is a wrapper around gtk_text_iter_toggles_tag().
func (v *TextIter) TogglesTag(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_toggles_tag(v.native(), v1.native()))
}
// HasTag is a wrapper around gtk_text_iter_has_tag().
func (v *TextIter) HasTag(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_has_tag(v.native(), v1.native()))
}
// Editable is a wrapper around gtk_text_iter_editable().
func (v *TextIter) Editable(v1 bool) bool {
return gobool(C.gtk_text_iter_editable(v.native(), gbool(v1)))
}
// CanInsert is a wrapper around gtk_text_iter_can_insert().
func (v *TextIter) CanInsert(v1 bool) bool {
return gobool(C.gtk_text_iter_can_insert(v.native(), gbool(v1)))
}
// StartsWord is a wrapper around gtk_text_iter_starts_word().
func (v *TextIter) StartsWord() bool {
return gobool(C.gtk_text_iter_starts_word(v.native()))
}
// EndsWord is a wrapper around gtk_text_iter_ends_word().
func (v *TextIter) EndsWord() bool {
return gobool(C.gtk_text_iter_ends_word(v.native()))
}
// InsideWord is a wrapper around gtk_text_iter_inside_word().
func (v *TextIter) InsideWord() bool {
return gobool(C.gtk_text_iter_inside_word(v.native()))
}
// StartsLine is a wrapper around gtk_text_iter_starts_line().
func (v *TextIter) StartsLine() bool {
return gobool(C.gtk_text_iter_starts_line(v.native()))
}
// EndsLine is a wrapper around gtk_text_iter_ends_line().
func (v *TextIter) EndsLine() bool {
return gobool(C.gtk_text_iter_ends_line(v.native()))
}
// StartsSentence is a wrapper around gtk_text_iter_starts_sentence().
func (v *TextIter) StartsSentence() bool {
return gobool(C.gtk_text_iter_starts_sentence(v.native()))
}
// EndsSentence is a wrapper around gtk_text_iter_ends_sentence().
func (v *TextIter) EndsSentence() bool {
return gobool(C.gtk_text_iter_ends_sentence(v.native()))
}
// InsideSentence is a wrapper around gtk_text_iter_inside_sentence().
func (v *TextIter) InsideSentence() bool {
return gobool(C.gtk_text_iter_inside_sentence(v.native()))
}
// IsCursorPosition is a wrapper around gtk_text_iter_is_cursor_position().
func (v *TextIter) IsCursorPosition() bool {
return gobool(C.gtk_text_iter_is_cursor_position(v.native()))
}
// GetCharsInLine is a wrapper around gtk_text_iter_get_chars_in_line().
func (v *TextIter) GetCharsInLine() int {
return int(C.gtk_text_iter_get_chars_in_line(v.native()))
}
// GetBytesInLine is a wrapper around gtk_text_iter_get_bytes_in_line().
func (v *TextIter) GetBytesInLine() int {
return int(C.gtk_text_iter_get_bytes_in_line(v.native()))
}
// IsEnd is a wrapper around gtk_text_iter_is_end().
func (v *TextIter) IsEnd() bool {
return gobool(C.gtk_text_iter_is_end(v.native()))
}
// IsStart is a wrapper around gtk_text_iter_is_start().
func (v *TextIter) IsStart() bool {
return gobool(C.gtk_text_iter_is_start(v.native()))
}
// ForwardChar is a wrapper around gtk_text_iter_forward_char().
func (v *TextIter) ForwardChar() bool {
return gobool(C.gtk_text_iter_forward_char(v.native()))
}
// BackwardChar is a wrapper around gtk_text_iter_backward_char().
func (v *TextIter) BackwardChar() bool {
return gobool(C.gtk_text_iter_backward_char(v.native()))
}
// ForwardChars is a wrapper around gtk_text_iter_forward_chars().
func (v *TextIter) ForwardChars(v1 int) bool {
return gobool(C.gtk_text_iter_forward_chars(v.native(), C.gint(v1)))
}
// BackwardChars is a wrapper around gtk_text_iter_backward_chars().
func (v *TextIter) BackwardChars(v1 int) bool {
return gobool(C.gtk_text_iter_backward_chars(v.native(), C.gint(v1)))
}
// ForwardLine is a wrapper around gtk_text_iter_forward_line().
func (v *TextIter) ForwardLine() bool {
return gobool(C.gtk_text_iter_forward_line(v.native()))
}
// BackwardLine is a wrapper around gtk_text_iter_backward_line().
func (v *TextIter) BackwardLine() bool {
return gobool(C.gtk_text_iter_backward_line(v.native()))
}
// ForwardLines is a wrapper around gtk_text_iter_forward_lines().
func (v *TextIter) ForwardLines(v1 int) bool {
return gobool(C.gtk_text_iter_forward_lines(v.native(), C.gint(v1)))
}
// BackwardLines is a wrapper around gtk_text_iter_backward_lines().
func (v *TextIter) BackwardLines(v1 int) bool {
return gobool(C.gtk_text_iter_backward_lines(v.native(), C.gint(v1)))
}
// ForwardWordEnds is a wrapper around gtk_text_iter_forward_word_ends().
func (v *TextIter) ForwardWordEnds(v1 int) bool {
return gobool(C.gtk_text_iter_forward_word_ends(v.native(), C.gint(v1)))
}
// ForwardWordEnd is a wrapper around gtk_text_iter_forward_word_end().
func (v *TextIter) ForwardWordEnd() bool {
return gobool(C.gtk_text_iter_forward_word_end(v.native()))
}
// ForwardCursorPosition is a wrapper around gtk_text_iter_forward_cursor_position().
func (v *TextIter) ForwardCursorPosition() bool {
return gobool(C.gtk_text_iter_forward_cursor_position(v.native()))
}
// BackwardCursorPosition is a wrapper around gtk_text_iter_backward_cursor_position().
func (v *TextIter) BackwardCursorPosition() bool {
return gobool(C.gtk_text_iter_backward_cursor_position(v.native()))
}
// ForwardCursorPositions is a wrapper around gtk_text_iter_forward_cursor_positions().
func (v *TextIter) ForwardCursorPositions(v1 int) bool {
return gobool(C.gtk_text_iter_forward_cursor_positions(v.native(), C.gint(v1)))
}
// BackwardCursorPositions is a wrapper around gtk_text_iter_backward_cursor_positions().
func (v *TextIter) BackwardCursorPositions(v1 int) bool {
return gobool(C.gtk_text_iter_backward_cursor_positions(v.native(), C.gint(v1)))
}
// ForwardSentenceEnds is a wrapper around gtk_text_iter_forward_sentence_ends().
func (v *TextIter) ForwardSentenceEnds(v1 int) bool {
return gobool(C.gtk_text_iter_forward_sentence_ends(v.native(), C.gint(v1)))
}
// ForwardSentenceEnd is a wrapper around gtk_text_iter_forward_sentence_end().
func (v *TextIter) ForwardSentenceEnd() bool {
return gobool(C.gtk_text_iter_forward_sentence_end(v.native()))
}
// ForwardVisibleWordEnds is a wrapper around gtk_text_iter_forward_word_ends().
func (v *TextIter) ForwardVisibleWordEnds(v1 int) bool {
return gobool(C.gtk_text_iter_forward_word_ends(v.native(), C.gint(v1)))
}
// ForwardVisibleWordEnd is a wrapper around gtk_text_iter_forward_visible_word_end().
func (v *TextIter) ForwardVisibleWordEnd() bool {
return gobool(C.gtk_text_iter_forward_visible_word_end(v.native()))
}
// ForwardVisibleCursorPosition is a wrapper around gtk_text_iter_forward_visible_cursor_position().
func (v *TextIter) ForwardVisibleCursorPosition() bool {
return gobool(C.gtk_text_iter_forward_visible_cursor_position(v.native()))
}
// BackwardVisibleCursorPosition is a wrapper around gtk_text_iter_backward_visible_cursor_position().
func (v *TextIter) BackwardVisibleCursorPosition() bool {
return gobool(C.gtk_text_iter_backward_visible_cursor_position(v.native()))
}
// ForwardVisibleCursorPositions is a wrapper around gtk_text_iter_forward_visible_cursor_positions().
func (v *TextIter) ForwardVisibleCursorPositions(v1 int) bool {
return gobool(C.gtk_text_iter_forward_visible_cursor_positions(v.native(), C.gint(v1)))
}
// BackwardVisibleCursorPositions is a wrapper around gtk_text_iter_backward_visible_cursor_positions().
func (v *TextIter) BackwardVisibleCursorPositions(v1 int) bool {
return gobool(C.gtk_text_iter_backward_visible_cursor_positions(v.native(), C.gint(v1)))
}
// ForwardVisibleLine is a wrapper around gtk_text_iter_forward_visible_line().
func (v *TextIter) ForwardVisibleLine() bool {
return gobool(C.gtk_text_iter_forward_visible_line(v.native()))
}
// BackwardVisibleLine is a wrapper around gtk_text_iter_backward_visible_line().
func (v *TextIter) BackwardVisibleLine() bool {
return gobool(C.gtk_text_iter_backward_visible_line(v.native()))
}
// ForwardVisibleLines is a wrapper around gtk_text_iter_forward_visible_lines().
func (v *TextIter) ForwardVisibleLines(v1 int) bool {
return gobool(C.gtk_text_iter_forward_visible_lines(v.native(), C.gint(v1)))
}
// BackwardVisibleLines is a wrapper around gtk_text_iter_backward_visible_lines().
func (v *TextIter) BackwardVisibleLines(v1 int) bool {
return gobool(C.gtk_text_iter_backward_visible_lines(v.native(), C.gint(v1)))
}
// SetOffset is a wrapper around gtk_text_iter_set_offset().
func (v *TextIter) SetOffset(v1 int) {
C.gtk_text_iter_set_offset(v.native(), C.gint(v1))
}
// SetLine is a wrapper around gtk_text_iter_set_line().
func (v *TextIter) SetLine(v1 int) {
C.gtk_text_iter_set_line(v.native(), C.gint(v1))
}
// SetLineOffset is a wrapper around gtk_text_iter_set_line_offset().
func (v *TextIter) SetLineOffset(v1 int) {
C.gtk_text_iter_set_line_offset(v.native(), C.gint(v1))
}
// SetLineIndex is a wrapper around gtk_text_iter_set_line_index().
func (v *TextIter) SetLineIndex(v1 int) {
C.gtk_text_iter_set_line_index(v.native(), C.gint(v1))
}
// SetVisibleLineOffset is a wrapper around gtk_text_iter_set_visible_line_offset().
func (v *TextIter) SetVisibleLineOffset(v1 int) {
C.gtk_text_iter_set_visible_line_offset(v.native(), C.gint(v1))
}
// SetVisibleLineIndex is a wrapper around gtk_text_iter_set_visible_line_index().
func (v *TextIter) SetVisibleLineIndex(v1 int) {
C.gtk_text_iter_set_visible_line_index(v.native(), C.gint(v1))
}
// ForwardToEnd is a wrapper around gtk_text_iter_forward_to_end().
func (v *TextIter) ForwardToEnd() {
C.gtk_text_iter_forward_to_end(v.native())
}
// ForwardToLineEnd is a wrapper around gtk_text_iter_forward_to_line_end().
func (v *TextIter) ForwardToLineEnd() bool {
return gobool(C.gtk_text_iter_forward_to_line_end(v.native()))
}
// ForwardToTagToggle is a wrapper around gtk_text_iter_forward_to_tag_toggle().
func (v *TextIter) ForwardToTagToggle(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_forward_to_tag_toggle(v.native(), v1.native()))
}
// BackwardToTagToggle is a wrapper around gtk_text_iter_backward_to_tag_toggle().
func (v *TextIter) BackwardToTagToggle(v1 *TextTag) bool {
return gobool(C.gtk_text_iter_backward_to_tag_toggle(v.native(), v1.native()))
}
// Equal is a wrapper around gtk_text_iter_equal().
func (v *TextIter) Equal(v1 *TextIter) bool {
return gobool(C.gtk_text_iter_equal(v.native(), v1.native()))
}
// Compare is a wrapper around gtk_text_iter_compare().
func (v *TextIter) Compare(v1 *TextIter) int {
return int(C.gtk_text_iter_compare(v.native(), v1.native()))
}
// InRange is a wrapper around gtk_text_iter_in_range().
func (v *TextIter) InRange(v1 *TextIter, v2 *TextIter) bool {
return gobool(C.gtk_text_iter_in_range(v.native(), v1.native(), v2.native()))
}
// void gtk_text_iter_order ()
// gboolean (*GtkTextCharPredicate) ()
// gboolean gtk_text_iter_forward_find_char ()
// gboolean gtk_text_iter_backward_find_char ()
// gboolean gtk_text_iter_forward_search ()
// gboolean gtk_text_iter_backward_search ()
// gboolean gtk_text_iter_get_attributes ()
// GtkTextIter * gtk_text_iter_copy ()
// void gtk_text_iter_assign ()
// void gtk_text_iter_free ()
// GdkPixbuf * gtk_text_iter_get_pixbuf ()
// GSList * gtk_text_iter_get_marks ()
// GSList * gtk_text_iter_get_toggled_tags ()
// GtkTextChildAnchor * gtk_text_iter_get_child_anchor ()
// GSList * gtk_text_iter_get_tags ()
// PangoLanguage * gtk_text_iter_get_language ()

@ -0,0 +1,29 @@
// 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"
/*
* GtkTextMark
*/
// TextMark is a representation of GTK's GtkTextMark
type TextMark C.GtkTextMark
// native returns a pointer to the underlying GtkTextMark.
func (v *TextMark) native() *C.GtkTextMark {
if v == nil {
return nil
}
return (*C.GtkTextMark)(v)
}
func marshalTextMark(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
return (*TextMark)(unsafe.Pointer(c)), nil
}

@ -0,0 +1,420 @@
// 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/gdk"
"github.com/gotk3/gotk3/glib"
)
// TextWindowType is a representation of GTK's GtkTextWindowType.
type TextWindowType int
const (
TEXT_WINDOW_WIDGET TextWindowType = C.GTK_TEXT_WINDOW_WIDGET
TEXT_WINDOW_TEXT TextWindowType = C.GTK_TEXT_WINDOW_TEXT
TEXT_WINDOW_LEFT TextWindowType = C.GTK_TEXT_WINDOW_LEFT
TEXT_WINDOW_RIGHT TextWindowType = C.GTK_TEXT_WINDOW_RIGHT
TEXT_WINDOW_TOP TextWindowType = C.GTK_TEXT_WINDOW_TOP
TEXT_WINDOW_BOTTOM TextWindowType = C.GTK_TEXT_WINDOW_BOTTOM
)
/*
* GtkTextView
*/
// TextView is a representation of GTK's GtkTextView
type TextView struct {
Container
}
// native returns a pointer to the underlying GtkTextView.
func (v *TextView) native() *C.GtkTextView {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkTextView(p)
}
func marshalTextView(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapTextView(obj), nil
}
func wrapTextView(obj *glib.Object) *TextView {
return &TextView{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// TextViewNew is a wrapper around gtk_text_view_new().
func TextViewNew() (*TextView, error) {
c := C.gtk_text_view_new()
if c == nil {
return nil, nilPtrErr
}
return wrapTextView(wrapObject(unsafe.Pointer(c))), nil
}
// TextViewNewWithBuffer is a wrapper around gtk_text_view_new_with_buffer().
func TextViewNewWithBuffer(buf *TextBuffer) (*TextView, error) {
cbuf := buf.native()
c := C.gtk_text_view_new_with_buffer(cbuf)
return wrapTextView(wrapObject(unsafe.Pointer(c))), nil
}
// GetBuffer is a wrapper around gtk_text_view_get_buffer().
func (v *TextView) GetBuffer() (*TextBuffer, error) {
c := C.gtk_text_view_get_buffer(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapTextBuffer(wrapObject(unsafe.Pointer(c))), nil
}
// SetBuffer is a wrapper around gtk_text_view_set_buffer().
func (v *TextView) SetBuffer(buffer *TextBuffer) {
C.gtk_text_view_set_buffer(v.native(), buffer.native())
}
// SetEditable is a wrapper around gtk_text_view_set_editable().
func (v *TextView) SetEditable(editable bool) {
C.gtk_text_view_set_editable(v.native(), gbool(editable))
}
// GetEditable is a wrapper around gtk_text_view_get_editable().
func (v *TextView) GetEditable() bool {
c := C.gtk_text_view_get_editable(v.native())
return gobool(c)
}
// SetWrapMode is a wrapper around gtk_text_view_set_wrap_mode().
func (v *TextView) SetWrapMode(wrapMode WrapMode) {
C.gtk_text_view_set_wrap_mode(v.native(), C.GtkWrapMode(wrapMode))
}
// GetWrapMode is a wrapper around gtk_text_view_get_wrap_mode().
func (v *TextView) GetWrapMode() WrapMode {
return WrapMode(C.gtk_text_view_get_wrap_mode(v.native()))
}
// SetCursorVisible is a wrapper around gtk_text_view_set_cursor_visible().
func (v *TextView) SetCursorVisible(visible bool) {
C.gtk_text_view_set_cursor_visible(v.native(), gbool(visible))
}
// GetCursorVisible is a wrapper around gtk_text_view_get_cursor_visible().
func (v *TextView) GetCursorVisible() bool {
c := C.gtk_text_view_get_cursor_visible(v.native())
return gobool(c)
}
// SetOverwrite is a wrapper around gtk_text_view_set_overwrite().
func (v *TextView) SetOverwrite(overwrite bool) {
C.gtk_text_view_set_overwrite(v.native(), gbool(overwrite))
}
// GetOverwrite is a wrapper around gtk_text_view_get_overwrite().
func (v *TextView) GetOverwrite() bool {
c := C.gtk_text_view_get_overwrite(v.native())
return gobool(c)
}
// SetJustification is a wrapper around gtk_text_view_set_justification().
func (v *TextView) SetJustification(justify Justification) {
C.gtk_text_view_set_justification(v.native(), C.GtkJustification(justify))
}
// GetJustification is a wrapper around gtk_text_view_get_justification().
func (v *TextView) GetJustification() Justification {
c := C.gtk_text_view_get_justification(v.native())
return Justification(c)
}
// SetAcceptsTab is a wrapper around gtk_text_view_set_accepts_tab().
func (v *TextView) SetAcceptsTab(acceptsTab bool) {
C.gtk_text_view_set_accepts_tab(v.native(), gbool(acceptsTab))
}
// GetAcceptsTab is a wrapper around gtk_text_view_get_accepts_tab().
func (v *TextView) GetAcceptsTab() bool {
c := C.gtk_text_view_get_accepts_tab(v.native())
return gobool(c)
}
// SetPixelsAboveLines is a wrapper around gtk_text_view_set_pixels_above_lines().
func (v *TextView) SetPixelsAboveLines(px int) {
C.gtk_text_view_set_pixels_above_lines(v.native(), C.gint(px))
}
// GetPixelsAboveLines is a wrapper around gtk_text_view_get_pixels_above_lines().
func (v *TextView) GetPixelsAboveLines() int {
c := C.gtk_text_view_get_pixels_above_lines(v.native())
return int(c)
}
// SetPixelsBelowLines is a wrapper around gtk_text_view_set_pixels_below_lines().
func (v *TextView) SetPixelsBelowLines(px int) {
C.gtk_text_view_set_pixels_below_lines(v.native(), C.gint(px))
}
// GetPixelsBelowLines is a wrapper around gtk_text_view_get_pixels_below_lines().
func (v *TextView) GetPixelsBelowLines() int {
c := C.gtk_text_view_get_pixels_below_lines(v.native())
return int(c)
}
// SetPixelsInsideWrap is a wrapper around gtk_text_view_set_pixels_inside_wrap().
func (v *TextView) SetPixelsInsideWrap(px int) {
C.gtk_text_view_set_pixels_inside_wrap(v.native(), C.gint(px))
}
// GetPixelsInsideWrap is a wrapper around gtk_text_view_get_pixels_inside_wrap().
func (v *TextView) GetPixelsInsideWrap() int {
c := C.gtk_text_view_get_pixels_inside_wrap(v.native())
return int(c)
}
// SetLeftMargin is a wrapper around gtk_text_view_set_left_margin().
func (v *TextView) SetLeftMargin(margin int) {
C.gtk_text_view_set_left_margin(v.native(), C.gint(margin))
}
// GetLeftMargin is a wrapper around gtk_text_view_get_left_margin().
func (v *TextView) GetLeftMargin() int {
c := C.gtk_text_view_get_left_margin(v.native())
return int(c)
}
// SetRightMargin is a wrapper around gtk_text_view_set_right_margin().
func (v *TextView) SetRightMargin(margin int) {
C.gtk_text_view_set_right_margin(v.native(), C.gint(margin))
}
// GetRightMargin is a wrapper around gtk_text_view_get_right_margin().
func (v *TextView) GetRightMargin() int {
c := C.gtk_text_view_get_right_margin(v.native())
return int(c)
}
// SetIndent is a wrapper around gtk_text_view_set_indent().
func (v *TextView) SetIndent(indent int) {
C.gtk_text_view_set_indent(v.native(), C.gint(indent))
}
// GetIndent is a wrapper around gtk_text_view_get_indent().
func (v *TextView) GetIndent() int {
c := C.gtk_text_view_get_indent(v.native())
return int(c)
}
// SetInputHints is a wrapper around gtk_text_view_set_input_hints().
func (v *TextView) SetInputHints(hints InputHints) {
C.gtk_text_view_set_input_hints(v.native(), C.GtkInputHints(hints))
}
// GetInputHints is a wrapper around gtk_text_view_get_input_hints().
func (v *TextView) GetInputHints() InputHints {
c := C.gtk_text_view_get_input_hints(v.native())
return InputHints(c)
}
// SetInputPurpose is a wrapper around gtk_text_view_set_input_purpose().
func (v *TextView) SetInputPurpose(purpose InputPurpose) {
C.gtk_text_view_set_input_purpose(v.native(),
C.GtkInputPurpose(purpose))
}
// GetInputPurpose is a wrapper around gtk_text_view_get_input_purpose().
func (v *TextView) GetInputPurpose() InputPurpose {
c := C.gtk_text_view_get_input_purpose(v.native())
return InputPurpose(c)
}
// ScrollToMark is a wrapper around gtk_text_view_scroll_to_mark().
func (v *TextView) ScrollToMark(mark *TextMark, within_margin float64, use_align bool, xalign, yalign float64) {
C.gtk_text_view_scroll_to_mark(v.native(), mark.native(), C.gdouble(within_margin), gbool(use_align), C.gdouble(xalign), C.gdouble(yalign))
}
// ScrollToIter is a wrapper around gtk_text_view_scroll_to_iter().
func (v *TextView) ScrollToIter(iter *TextIter, within_margin float64, use_align bool, xalign, yalign float64) bool {
return gobool(C.gtk_text_view_scroll_to_iter(v.native(), iter.native(), C.gdouble(within_margin), gbool(use_align), C.gdouble(xalign), C.gdouble(yalign)))
}
// ScrollMarkOnscreen is a wrapper around gtk_text_view_scroll_mark_onscreen().
func (v *TextView) ScrollMarkOnscreen(mark *TextMark) {
C.gtk_text_view_scroll_mark_onscreen(v.native(), mark.native())
}
// MoveMarkOnscreen is a wrapper around gtk_text_view_move_mark_onscreen().
func (v *TextView) MoveMarkOnscreen(mark *TextMark) bool {
return gobool(C.gtk_text_view_move_mark_onscreen(v.native(), mark.native()))
}
// PlaceCursorOnscreen is a wrapper around gtk_text_view_place_cursor_onscreen().
func (v *TextView) PlaceCursorOnscreen() bool {
return gobool(C.gtk_text_view_place_cursor_onscreen(v.native()))
}
// GetVisibleRect is a wrapper around gtk_text_view_get_visible_rect().
func (v *TextView) GetVisibleRect() *gdk.Rectangle {
var rect C.GdkRectangle
C.gtk_text_view_get_visible_rect(v.native(), &rect)
return gdk.WrapRectangle(uintptr(unsafe.Pointer(&rect)))
}
// GetIterLocation is a wrapper around gtk_text_view_get_iter_location().
func (v *TextView) GetIterLocation(iter *TextIter) *gdk.Rectangle {
var rect C.GdkRectangle
C.gtk_text_view_get_iter_location(v.native(), iter.native(), &rect)
return gdk.WrapRectangle(uintptr(unsafe.Pointer(&rect)))
}
// GetCursorLocations is a wrapper around gtk_text_view_get_cursor_locations().
func (v *TextView) GetCursorLocations(iter *TextIter) (strong, weak *gdk.Rectangle) {
var strongRect, weakRect C.GdkRectangle
C.gtk_text_view_get_cursor_locations(v.native(), iter.native(), &strongRect, &weakRect)
return gdk.WrapRectangle(uintptr(unsafe.Pointer(&strongRect))), gdk.WrapRectangle(uintptr(unsafe.Pointer(&weakRect)))
}
// GetLineAtY is a wrapper around gtk_text_view_get_line_at_y().
func (v *TextView) GetLineAtY(y int) (*TextIter, int) {
var iter TextIter
var line_top C.gint
iiter := (C.GtkTextIter)(iter)
C.gtk_text_view_get_line_at_y(v.native(), &iiter, C.gint(y), &line_top)
return &iter, int(line_top)
}
// GetLineYrange is a wrapper around gtk_text_view_get_line_yrange().
func (v *TextView) GetLineYrange(iter *TextIter) (y, height int) {
var yx, heightx C.gint
C.gtk_text_view_get_line_yrange(v.native(), iter.native(), &yx, &heightx)
return int(yx), int(heightx)
}
// GetIterAtLocation is a wrapper around gtk_text_view_get_iter_at_location().
func (v *TextView) GetIterAtLocation(x, y int) *TextIter {
var iter TextIter
iiter := (C.GtkTextIter)(iter)
C.gtk_text_view_get_iter_at_location(v.native(), &iiter, C.gint(x), C.gint(y))
return &iter
}
// GetIterAtPosition is a wrapper around gtk_text_view_get_iter_at_position().
func (v *TextView) GetIterAtPosition(x, y int) (*TextIter, int) {
var iter TextIter
var trailing C.gint
iiter := (C.GtkTextIter)(iter)
C.gtk_text_view_get_iter_at_position(v.native(), &iiter, &trailing, C.gint(x), C.gint(y))
return &iter, int(trailing)
}
// BufferToWindowCoords is a wrapper around gtk_text_view_buffer_to_window_coords().
func (v *TextView) BufferToWindowCoords(win TextWindowType, buffer_x, buffer_y int) (window_x, window_y int) {
var wx, wy C.gint
C.gtk_text_view_buffer_to_window_coords(v.native(), C.GtkTextWindowType(win), C.gint(buffer_x), C.gint(buffer_y), &wx, &wy)
return int(wx), int(wy)
}
// WindowToBufferCoords is a wrapper around gtk_text_view_window_to_buffer_coords().
func (v *TextView) WindowToBufferCoords(win TextWindowType, window_x, window_y int) (buffer_x, buffer_y int) {
var bx, by C.gint
C.gtk_text_view_window_to_buffer_coords(v.native(), C.GtkTextWindowType(win), C.gint(window_x), C.gint(window_y), &bx, &by)
return int(bx), int(by)
}
// GetWindow is a wrapper around gtk_text_view_get_window().
func (v *TextView) GetWindow(win TextWindowType) *gdk.Window {
c := C.gtk_text_view_get_window(v.native(), C.GtkTextWindowType(win))
if c == nil {
return nil
}
return &gdk.Window{wrapObject(unsafe.Pointer(c))}
}
// GetWindowType is a wrapper around gtk_text_view_get_window_type().
func (v *TextView) GetWindowType(w *gdk.Window) TextWindowType {
return TextWindowType(C.gtk_text_view_get_window_type(v.native(), (*C.GdkWindow)(unsafe.Pointer(w.Native()))))
}
// SetBorderWindowSize is a wrapper around gtk_text_view_set_border_window_size().
func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) {
C.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size))
}
// GetBorderWindowSize is a wrapper around gtk_text_view_get_border_window_size().
func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {
return int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))
}
// ForwardDisplayLine is a wrapper around gtk_text_view_forward_display_line().
func (v *TextView) ForwardDisplayLine(iter *TextIter) bool {
return gobool(C.gtk_text_view_forward_display_line(v.native(), iter.native()))
}
// BackwardDisplayLine is a wrapper around gtk_text_view_backward_display_line().
func (v *TextView) BackwardDisplayLine(iter *TextIter) bool {
return gobool(C.gtk_text_view_backward_display_line(v.native(), iter.native()))
}
// ForwardDisplayLineEnd is a wrapper around gtk_text_view_forward_display_line_end().
func (v *TextView) ForwardDisplayLineEnd(iter *TextIter) bool {
return gobool(C.gtk_text_view_forward_display_line_end(v.native(), iter.native()))
}
// BackwardDisplayLineStart is a wrapper around gtk_text_view_backward_display_line_start().
func (v *TextView) BackwardDisplayLineStart(iter *TextIter) bool {
return gobool(C.gtk_text_view_backward_display_line_start(v.native(), iter.native()))
}
// StartsDisplayLine is a wrapper around gtk_text_view_starts_display_line().
func (v *TextView) StartsDisplayLine(iter *TextIter) bool {
return gobool(C.gtk_text_view_starts_display_line(v.native(), iter.native()))
}
// MoveVisually is a wrapper around gtk_text_view_move_visually().
func (v *TextView) MoveVisually(iter *TextIter, count int) bool {
return gobool(C.gtk_text_view_move_visually(v.native(), iter.native(), C.gint(count)))
}
// AddChildInWindow is a wrapper around gtk_text_view_add_child_in_window().
func (v *TextView) AddChildInWindow(child IWidget, tp TextWindowType, xpos, ypos int) {
C.gtk_text_view_add_child_in_window(v.native(), child.toWidget(), C.GtkTextWindowType(tp), C.gint(xpos), C.gint(ypos))
}
// MoveChild is a wrapper around gtk_text_view_move_child().
func (v *TextView) MoveChild(child IWidget, xpos, ypos int) {
C.gtk_text_view_move_child(v.native(), child.toWidget(), C.gint(xpos), C.gint(ypos))
}
// ImContextFilterKeypress is a wrapper around gtk_text_view_im_context_filter_keypress().
func (v *TextView) ImContextFilterKeypress(event *gdk.EventKey) bool {
return gobool(C.gtk_text_view_im_context_filter_keypress(v.native(), (*C.GdkEventKey)(unsafe.Pointer(event.Native()))))
}
// ResetImContext is a wrapper around gtk_text_view_reset_im_context().
func (v *TextView) ResetImContext() {
C.gtk_text_view_reset_im_context(v.native())
}
// GtkAdjustment * gtk_text_view_get_hadjustment () -- DEPRECATED
// GtkAdjustment * gtk_text_view_get_vadjustment () -- DEPRECATED
// void gtk_text_view_add_child_at_anchor ()
// GtkTextChildAnchor * gtk_text_child_anchor_new ()
// GList * gtk_text_child_anchor_get_widgets ()
// gboolean gtk_text_child_anchor_get_deleted ()
// void gtk_text_view_set_top_margin () -- SINCE 3.18
// gint gtk_text_view_get_top_margin () -- SINCE 3.18
// void gtk_text_view_set_bottom_margin () -- SINCE 3.18
// gint gtk_text_view_get_bottom_margin () -- SINCE 3.18
// void gtk_text_view_set_tabs () -- PangoTabArray
// PangoTabArray * gtk_text_view_get_tabs () -- PangoTabArray
// GtkTextAttributes * gtk_text_view_get_default_attributes () -- GtkTextAttributes
// void gtk_text_view_set_monospace () -- SINCE 3.16
// gboolean gtk_text_view_get_monospace () -- SINCE 3.16

@ -0,0 +1,445 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"runtime"
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkTreeView
*/
// TreeView is a representation of GTK's GtkTreeView.
type TreeView struct {
Container
}
// native returns a pointer to the underlying GtkTreeView.
func (v *TreeView) native() *C.GtkTreeView {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkTreeView(p)
}
func marshalTreeView(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapTreeView(obj), nil
}
func wrapTreeView(obj *glib.Object) *TreeView {
return &TreeView{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
func setupTreeView(c unsafe.Pointer) (*TreeView, error) {
if c == nil {
return nil, nilPtrErr
}
return wrapTreeView(wrapObject(c)), nil
}
// TreeViewNew() is a wrapper around gtk_tree_view_new().
func TreeViewNew() (*TreeView, error) {
return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new()))
}
// TreeViewNewWithModel() is a wrapper around gtk_tree_view_new_with_model().
func TreeViewNewWithModel(model ITreeModel) (*TreeView, error) {
return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new_with_model(model.toTreeModel())))
}
// GetModel() is a wrapper around gtk_tree_view_get_model().
func (v *TreeView) GetModel() (*TreeModel, error) {
c := C.gtk_tree_view_get_model(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapTreeModel(wrapObject(unsafe.Pointer(c))), nil
}
// SetModel() is a wrapper around gtk_tree_view_set_model().
func (v *TreeView) SetModel(model ITreeModel) {
C.gtk_tree_view_set_model(v.native(), model.toTreeModel())
}
// GetSelection() is a wrapper around gtk_tree_view_get_selection().
func (v *TreeView) GetSelection() (*TreeSelection, error) {
c := C.gtk_tree_view_get_selection(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapTreeSelection(wrapObject(unsafe.Pointer(c))), nil
}
// AppendColumn() is a wrapper around gtk_tree_view_append_column().
func (v *TreeView) AppendColumn(column *TreeViewColumn) int {
c := C.gtk_tree_view_append_column(v.native(), column.native())
return int(c)
}
// GetPathAtPos() is a wrapper around gtk_tree_view_get_path_at_pos().
func (v *TreeView) GetPathAtPos(x, y int, path *TreePath, column *TreeViewColumn, cellX, cellY *int) bool {
var ctp **C.GtkTreePath
if path != nil {
ctp = (**C.GtkTreePath)(unsafe.Pointer(&path.GtkTreePath))
} else {
ctp = nil
}
var pctvcol **C.GtkTreeViewColumn
if column != nil {
ctvcol := column.native()
pctvcol = &ctvcol
} else {
pctvcol = nil
}
return 0 != C.gtk_tree_view_get_path_at_pos(
v.native(),
(C.gint)(x),
(C.gint)(y),
ctp,
pctvcol,
(*C.gint)(unsafe.Pointer(cellX)),
(*C.gint)(unsafe.Pointer(cellY)))
}
// GetLevelIndentation is a wrapper around gtk_tree_view_get_level_indentation().
func (v *TreeView) GetLevelIndentation() int {
return int(C.gtk_tree_view_get_level_indentation(v.native()))
}
// GetShowExpanders is a wrapper around gtk_tree_view_get_show_expanders().
func (v *TreeView) GetShowExpanders() bool {
return gobool(C.gtk_tree_view_get_show_expanders(v.native()))
}
// SetLevelIndentation is a wrapper around gtk_tree_view_set_level_indentation().
func (v *TreeView) SetLevelIndentation(indent int) {
C.gtk_tree_view_set_level_indentation(v.native(), C.gint(indent))
}
// SetShowExpanders is a wrapper around gtk_tree_view_set_show_expanders().
func (v *TreeView) SetShowExpanders(show bool) {
C.gtk_tree_view_set_show_expanders(v.native(), gbool(show))
}
// GetHeadersVisible is a wrapper around gtk_tree_view_get_headers_visible().
func (v *TreeView) GetHeadersVisible() bool {
return gobool(C.gtk_tree_view_get_headers_visible(v.native()))
}
// SetHeadersVisible is a wrapper around gtk_tree_view_set_headers_visible().
func (v *TreeView) SetHeadersVisible(show bool) {
C.gtk_tree_view_set_headers_visible(v.native(), gbool(show))
}
// ColumnsAutosize is a wrapper around gtk_tree_view_columns_autosize().
func (v *TreeView) ColumnsAutosize() {
C.gtk_tree_view_columns_autosize(v.native())
}
// GetHeadersClickable is a wrapper around gtk_tree_view_get_headers_clickable().
func (v *TreeView) GetHeadersClickable() bool {
return gobool(C.gtk_tree_view_get_headers_clickable(v.native()))
}
// SetHeadersClickable is a wrapper around gtk_tree_view_set_headers_clickable().
func (v *TreeView) SetHeadersClickable(show bool) {
C.gtk_tree_view_set_headers_clickable(v.native(), gbool(show))
}
// GetActivateOnSingleClick is a wrapper around gtk_tree_view_get_activate_on_single_click().
func (v *TreeView) GetActivateOnSingleClick() bool {
return gobool(C.gtk_tree_view_get_activate_on_single_click(v.native()))
}
// SetActivateOnSingleClick is a wrapper around gtk_tree_view_set_activate_on_single_click().
func (v *TreeView) SetActivateOnSingleClick(show bool) {
C.gtk_tree_view_set_activate_on_single_click(v.native(), gbool(show))
}
// RemoveColumn() is a wrapper around gtk_tree_view_remove_column().
func (v *TreeView) RemoveColumn(column *TreeViewColumn) int {
return int(C.gtk_tree_view_remove_column(v.native(), column.native()))
}
// InsertColumn() is a wrapper around gtk_tree_view_insert_column().
func (v *TreeView) InsertColumn(column *TreeViewColumn, pos int) int {
return int(C.gtk_tree_view_insert_column(v.native(), column.native(), C.gint(pos)))
}
// GetNColumns() is a wrapper around gtk_tree_view_get_n_columns().
func (v *TreeView) GetNColumns() uint {
return uint(C.gtk_tree_view_get_n_columns(v.native()))
}
// GetColumn() is a wrapper around gtk_tree_view_get_column().
func (v *TreeView) GetColumn(n int) *TreeViewColumn {
c := C.gtk_tree_view_get_column(v.native(), C.gint(n))
if c == nil {
return nil
}
return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c)))
}
// MoveColumnAfter() is a wrapper around gtk_tree_view_move_column_after().
func (v *TreeView) MoveColumnAfter(column *TreeViewColumn, baseColumn *TreeViewColumn) {
C.gtk_tree_view_move_column_after(v.native(), column.native(), baseColumn.native())
}
// SetExpanderColumn() is a wrapper around gtk_tree_view_set_expander_column().
func (v *TreeView) SetExpanderColumn(column *TreeViewColumn) {
C.gtk_tree_view_set_expander_column(v.native(), column.native())
}
// GetExpanderColumn() is a wrapper around gtk_tree_view_get_expander_column().
func (v *TreeView) GetExpanderColumn() *TreeViewColumn {
c := C.gtk_tree_view_get_expander_column(v.native())
if c == nil {
return nil
}
return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c)))
}
// ScrollToPoint() is a wrapper around gtk_tree_view_scroll_to_point().
func (v *TreeView) ScrollToPoint(treeX, treeY int) {
C.gtk_tree_view_scroll_to_point(v.native(), C.gint(treeX), C.gint(treeY))
}
// SetCursor() is a wrapper around gtk_tree_view_set_cursor().
func (v *TreeView) SetCursor(path *TreePath, focusColumn *TreeViewColumn, startEditing bool) {
C.gtk_tree_view_set_cursor(v.native(), path.native(), focusColumn.native(), gbool(startEditing))
}
// SetCursorOnCell() is a wrapper around gtk_tree_view_set_cursor_on_cell().
func (v *TreeView) SetCursorOnCell(path *TreePath, focusColumn *TreeViewColumn, focusCell *CellRenderer, startEditing bool) {
C.gtk_tree_view_set_cursor_on_cell(v.native(), path.native(), focusColumn.native(), focusCell.native(), gbool(startEditing))
}
// GetCursor() is a wrapper around gtk_tree_view_get_cursor().
func (v *TreeView) GetCursor() (p *TreePath, c *TreeViewColumn) {
var path *C.GtkTreePath
var col *C.GtkTreeViewColumn
C.gtk_tree_view_get_cursor(v.native(), &path, &col)
if path != nil {
p = &TreePath{path}
runtime.SetFinalizer(p, (*TreePath).free)
}
if col != nil {
c = wrapTreeViewColumn(wrapObject(unsafe.Pointer(col)))
}
return
}
// RowActivated() is a wrapper around gtk_tree_view_row_activated().
func (v *TreeView) RowActivated(path *TreePath, column *TreeViewColumn) {
C.gtk_tree_view_row_activated(v.native(), path.native(), column.native())
}
// ExpandAll() is a wrapper around gtk_tree_view_expand_all().
func (v *TreeView) ExpandAll() {
C.gtk_tree_view_expand_all(v.native())
}
// CollapseAll() is a wrapper around gtk_tree_view_collapse_all().
func (v *TreeView) CollapseAll() {
C.gtk_tree_view_collapse_all(v.native())
}
// ExpandToPath() is a wrapper around gtk_tree_view_expand_to_path().
func (v *TreeView) ExpandToPath(path *TreePath) {
C.gtk_tree_view_expand_to_path(v.native(), path.native())
}
// ExpandRow() is a wrapper around gtk_tree_view_expand_row().
func (v *TreeView) ExpandRow(path *TreePath, openAll bool) bool {
return gobool(C.gtk_tree_view_expand_row(v.native(), path.native(), gbool(openAll)))
}
// CollapseRow() is a wrapper around gtk_tree_view_collapse_row().
func (v *TreeView) CollapseRow(path *TreePath) bool {
return gobool(C.gtk_tree_view_collapse_row(v.native(), path.native()))
}
// RowExpanded() is a wrapper around gtk_tree_view_row_expanded().
func (v *TreeView) RowExpanded(path *TreePath) bool {
return gobool(C.gtk_tree_view_row_expanded(v.native(), path.native()))
}
// SetReorderable is a wrapper around gtk_tree_view_set_reorderable().
func (v *TreeView) SetReorderable(b bool) {
C.gtk_tree_view_set_reorderable(v.native(), gbool(b))
}
// GetReorderable() is a wrapper around gtk_tree_view_get_reorderable().
func (v *TreeView) GetReorderable() bool {
return gobool(C.gtk_tree_view_get_reorderable(v.native()))
}
// GetBinWindow() is a wrapper around gtk_tree_view_get_bin_window().
func (v *TreeView) GetBinWindow() *gdk.Window {
c := C.gtk_tree_view_get_bin_window(v.native())
if c == nil {
return nil
}
w := &gdk.Window{wrapObject(unsafe.Pointer(c))}
return w
}
// SetEnableSearch is a wrapper around gtk_tree_view_set_enable_search().
func (v *TreeView) SetEnableSearch(b bool) {
C.gtk_tree_view_set_enable_search(v.native(), gbool(b))
}
// GetEnableSearch() is a wrapper around gtk_tree_view_get_enable_search().
func (v *TreeView) GetEnableSearch() bool {
return gobool(C.gtk_tree_view_get_enable_search(v.native()))
}
// SetSearchColumn is a wrapper around gtk_tree_view_set_search_column().
func (v *TreeView) SetSearchColumn(c int) {
C.gtk_tree_view_set_search_column(v.native(), C.gint(c))
}
// GetSearchColumn() is a wrapper around gtk_tree_view_get_search_column().
func (v *TreeView) GetSearchColumn() int {
return int(C.gtk_tree_view_get_search_column(v.native()))
}
// GetSearchEntry() is a wrapper around gtk_tree_view_get_search_entry().
func (v *TreeView) GetSearchEntry() *Entry {
c := C.gtk_tree_view_get_search_entry(v.native())
if c == nil {
return nil
}
return wrapEntry(wrapObject(unsafe.Pointer(c)))
}
// SetSearchEntry() is a wrapper around gtk_tree_view_set_search_entry().
func (v *TreeView) SetSearchEntry(e *Entry) {
C.gtk_tree_view_set_search_entry(v.native(), e.native())
}
// SetFixedHeightMode is a wrapper around gtk_tree_view_set_fixed_height_mode().
func (v *TreeView) SetFixedHeightMode(b bool) {
C.gtk_tree_view_set_fixed_height_mode(v.native(), gbool(b))
}
// GetFixedHeightMode() is a wrapper around gtk_tree_view_get_fixed_height_mode().
func (v *TreeView) GetFixedHeightMode() bool {
return gobool(C.gtk_tree_view_get_fixed_height_mode(v.native()))
}
// SetHoverSelection is a wrapper around gtk_tree_view_set_hover_selection().
func (v *TreeView) SetHoverSelection(b bool) {
C.gtk_tree_view_set_hover_selection(v.native(), gbool(b))
}
// GetHoverSelection() is a wrapper around gtk_tree_view_get_hover_selection().
func (v *TreeView) GetHoverSelection() bool {
return gobool(C.gtk_tree_view_get_hover_selection(v.native()))
}
// SetHoverExpand is a wrapper around gtk_tree_view_set_hover_expand().
func (v *TreeView) SetHoverExpand(b bool) {
C.gtk_tree_view_set_hover_expand(v.native(), gbool(b))
}
// GetHoverExpand() is a wrapper around gtk_tree_view_get_hover_expand().
func (v *TreeView) GetHoverExpand() bool {
return gobool(C.gtk_tree_view_get_hover_expand(v.native()))
}
// SetRubberBanding is a wrapper around gtk_tree_view_set_rubber_banding().
func (v *TreeView) SetRubberBanding(b bool) {
C.gtk_tree_view_set_rubber_banding(v.native(), gbool(b))
}
// GetRubberBanding() is a wrapper around gtk_tree_view_get_rubber_banding().
func (v *TreeView) GetRubberBanding() bool {
return gobool(C.gtk_tree_view_get_rubber_banding(v.native()))
}
// IsRubberBandingActive() is a wrapper around gtk_tree_view_is_rubber_banding_active().
func (v *TreeView) IsRubberBandingActive() bool {
return gobool(C.gtk_tree_view_is_rubber_banding_active(v.native()))
}
// SetEnableTreeLines is a wrapper around gtk_tree_view_set_enable_tree_lines().
func (v *TreeView) SetEnableTreeLines(b bool) {
C.gtk_tree_view_set_enable_tree_lines(v.native(), gbool(b))
}
// GetEnableTreeLines() is a wrapper around gtk_tree_view_get_enable_tree_lines().
func (v *TreeView) GetEnableTreeLines() bool {
return gobool(C.gtk_tree_view_get_enable_tree_lines(v.native()))
}
// GetTooltipColumn() is a wrapper around gtk_tree_view_get_tooltip_column().
func (v *TreeView) GetTooltipColumn() int {
return int(C.gtk_tree_view_get_tooltip_column(v.native()))
}
// SetTooltipColumn() is a wrapper around gtk_tree_view_set_tooltip_column().
func (v *TreeView) SetTooltipColumn(c int) {
C.gtk_tree_view_set_tooltip_column(v.native(), C.gint(c))
}
// void gtk_tree_view_set_tooltip_row ()
// void gtk_tree_view_set_tooltip_cell ()
// gboolean gtk_tree_view_get_tooltip_context ()
// void gtk_tree_view_set_grid_lines ()
// GtkTreeViewGridLines gtk_tree_view_get_grid_lines ()
// void (*GtkTreeDestroyCountFunc) ()
// void gtk_tree_view_set_destroy_count_func ()
// gboolean (*GtkTreeViewRowSeparatorFunc) ()
// GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func ()
// void gtk_tree_view_set_row_separator_func ()
// void (*GtkTreeViewSearchPositionFunc) ()
// GtkTreeViewSearchPositionFunc gtk_tree_view_get_search_position_func ()
// void gtk_tree_view_set_search_position_func ()
// void gtk_tree_view_set_search_equal_func ()
// GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func ()
// void gtk_tree_view_map_expanded_rows ()
// GList * gtk_tree_view_get_columns ()
// gint gtk_tree_view_insert_column_with_attributes ()
// gint gtk_tree_view_insert_column_with_data_func ()
// void gtk_tree_view_set_column_drag_function ()
// void gtk_tree_view_scroll_to_cell ()
// gboolean gtk_tree_view_is_blank_at_pos ()
// void gtk_tree_view_get_cell_area ()
// void gtk_tree_view_get_background_area ()
// void gtk_tree_view_get_visible_rect ()
// gboolean gtk_tree_view_get_visible_range ()
// void gtk_tree_view_convert_bin_window_to_tree_coords ()
// void gtk_tree_view_convert_bin_window_to_widget_coords ()
// void gtk_tree_view_convert_tree_to_bin_window_coords ()
// void gtk_tree_view_convert_tree_to_widget_coords ()
// void gtk_tree_view_convert_widget_to_bin_window_coords ()
// void gtk_tree_view_convert_widget_to_tree_coords ()
// void gtk_tree_view_enable_model_drag_dest ()
// void gtk_tree_view_enable_model_drag_source ()
// void gtk_tree_view_unset_rows_drag_source ()
// void gtk_tree_view_unset_rows_drag_dest ()
// void gtk_tree_view_set_drag_dest_row ()
// void gtk_tree_view_get_drag_dest_row ()
// gboolean gtk_tree_view_get_dest_row_at_pos ()
// cairo_surface_t * gtk_tree_view_create_row_drag_icon ()

@ -0,0 +1,265 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkTreeViewColumn
*/
// TreeViewColumns is a representation of GTK's GtkTreeViewColumn.
type TreeViewColumn struct {
glib.InitiallyUnowned
}
// native returns a pointer to the underlying GtkTreeViewColumn.
func (v *TreeViewColumn) native() *C.GtkTreeViewColumn {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkTreeViewColumn(p)
}
func marshalTreeViewColumn(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapTreeViewColumn(obj), nil
}
func wrapTreeViewColumn(obj *glib.Object) *TreeViewColumn {
return &TreeViewColumn{glib.InitiallyUnowned{obj}}
}
// TreeViewColumnNew() is a wrapper around gtk_tree_view_column_new().
func TreeViewColumnNew() (*TreeViewColumn, error) {
c := C.gtk_tree_view_column_new()
if c == nil {
return nil, nilPtrErr
}
return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil
}
// TreeViewColumnNewWithAttribute() is a wrapper around
// gtk_tree_view_column_new_with_attributes() that only sets one
// attribute for one column.
func TreeViewColumnNewWithAttribute(title string, renderer ICellRenderer, attribute string, column int) (*TreeViewColumn, error) {
t_cstr := C.CString(title)
defer C.free(unsafe.Pointer(t_cstr))
a_cstr := C.CString(attribute)
defer C.free(unsafe.Pointer(a_cstr))
c := C._gtk_tree_view_column_new_with_attributes_one((*C.gchar)(t_cstr),
renderer.toCellRenderer(), (*C.gchar)(a_cstr), C.gint(column))
if c == nil {
return nil, nilPtrErr
}
return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil
}
// AddAttribute() is a wrapper around gtk_tree_view_column_add_attribute().
func (v *TreeViewColumn) AddAttribute(renderer ICellRenderer, attribute string, column int) {
cstr := C.CString(attribute)
defer C.free(unsafe.Pointer(cstr))
C.gtk_tree_view_column_add_attribute(v.native(),
renderer.toCellRenderer(), (*C.gchar)(cstr), C.gint(column))
}
// SetExpand() is a wrapper around gtk_tree_view_column_set_expand().
func (v *TreeViewColumn) SetExpand(expand bool) {
C.gtk_tree_view_column_set_expand(v.native(), gbool(expand))
}
// GetExpand() is a wrapper around gtk_tree_view_column_get_expand().
func (v *TreeViewColumn) GetExpand() bool {
c := C.gtk_tree_view_column_get_expand(v.native())
return gobool(c)
}
// SetMinWidth() is a wrapper around gtk_tree_view_column_set_min_width().
func (v *TreeViewColumn) SetMinWidth(minWidth int) {
C.gtk_tree_view_column_set_min_width(v.native(), C.gint(minWidth))
}
// GetMinWidth() is a wrapper around gtk_tree_view_column_get_min_width().
func (v *TreeViewColumn) GetMinWidth() int {
c := C.gtk_tree_view_column_get_min_width(v.native())
return int(c)
}
// PackStart() is a wrapper around gtk_tree_view_column_pack_start().
func (v *TreeViewColumn) PackStart(cell *CellRenderer, expand bool) {
C.gtk_tree_view_column_pack_start(v.native(), cell.native(), gbool(expand))
}
// PackEnd() is a wrapper around gtk_tree_view_column_pack_end().
func (v *TreeViewColumn) PackEnd(cell *CellRenderer, expand bool) {
C.gtk_tree_view_column_pack_end(v.native(), cell.native(), gbool(expand))
}
// Clear() is a wrapper around gtk_tree_view_column_clear().
func (v *TreeViewColumn) Clear() {
C.gtk_tree_view_column_clear(v.native())
}
// ClearAttributes() is a wrapper around gtk_tree_view_column_clear_attributes().
func (v *TreeViewColumn) ClearAttributes(cell *CellRenderer) {
C.gtk_tree_view_column_clear_attributes(v.native(), cell.native())
}
// SetSpacing() is a wrapper around gtk_tree_view_column_set_spacing().
func (v *TreeViewColumn) SetSpacing(spacing int) {
C.gtk_tree_view_column_set_spacing(v.native(), C.gint(spacing))
}
// GetSpacing() is a wrapper around gtk_tree_view_column_get_spacing().
func (v *TreeViewColumn) GetSpacing() int {
return int(C.gtk_tree_view_column_get_spacing(v.native()))
}
// SetVisible() is a wrapper around gtk_tree_view_column_set_visible().
func (v *TreeViewColumn) SetVisible(visible bool) {
C.gtk_tree_view_column_set_visible(v.native(), gbool(visible))
}
// GetVisible() is a wrapper around gtk_tree_view_column_get_visible().
func (v *TreeViewColumn) GetVisible() bool {
return gobool(C.gtk_tree_view_column_get_visible(v.native()))
}
// SetResizable() is a wrapper around gtk_tree_view_column_set_resizable().
func (v *TreeViewColumn) SetResizable(resizable bool) {
C.gtk_tree_view_column_set_resizable(v.native(), gbool(resizable))
}
// GetResizable() is a wrapper around gtk_tree_view_column_get_resizable().
func (v *TreeViewColumn) GetResizable() bool {
return gobool(C.gtk_tree_view_column_get_resizable(v.native()))
}
// GetWidth() is a wrapper around gtk_tree_view_column_get_width().
func (v *TreeViewColumn) GetWidth() int {
return int(C.gtk_tree_view_column_get_width(v.native()))
}
// SetFixedWidth() is a wrapper around gtk_tree_view_column_set_fixed_width().
func (v *TreeViewColumn) SetFixedWidth(w int) {
C.gtk_tree_view_column_set_fixed_width(v.native(), C.gint(w))
}
// GetFixedWidth() is a wrapper around gtk_tree_view_column_get_fixed_width().
func (v *TreeViewColumn) GetFixedWidth() int {
return int(C.gtk_tree_view_column_get_fixed_width(v.native()))
}
// SetMaxWidth() is a wrapper around gtk_tree_view_column_set_max_width().
func (v *TreeViewColumn) SetMaxWidth(w int) {
C.gtk_tree_view_column_set_max_width(v.native(), C.gint(w))
}
// GetMaxWidth() is a wrapper around gtk_tree_view_column_get_max_width().
func (v *TreeViewColumn) GetMaxWidth() int {
return int(C.gtk_tree_view_column_get_max_width(v.native()))
}
// Clicked() is a wrapper around gtk_tree_view_column_clicked().
func (v *TreeViewColumn) Clicked() {
C.gtk_tree_view_column_clicked(v.native())
}
// SetTitle() is a wrapper around gtk_tree_view_column_set_title().
func (v *TreeViewColumn) SetTitle(t string) {
cstr := (*C.gchar)(C.CString(t))
defer C.free(unsafe.Pointer(cstr))
C.gtk_tree_view_column_set_title(v.native(), cstr)
}
// GetTitle() is a wrapper around gtk_tree_view_column_get_title().
func (v *TreeViewColumn) GetTitle() string {
return C.GoString((*C.char)(C.gtk_tree_view_column_get_title(v.native())))
}
// SetClickable() is a wrapper around gtk_tree_view_column_set_clickable().
func (v *TreeViewColumn) SetClickable(clickable bool) {
C.gtk_tree_view_column_set_clickable(v.native(), gbool(clickable))
}
// GetClickable() is a wrapper around gtk_tree_view_column_get_clickable().
func (v *TreeViewColumn) GetClickable() bool {
return gobool(C.gtk_tree_view_column_get_clickable(v.native()))
}
// SetReorderable() is a wrapper around gtk_tree_view_column_set_reorderable().
func (v *TreeViewColumn) SetReorderable(reorderable bool) {
C.gtk_tree_view_column_set_reorderable(v.native(), gbool(reorderable))
}
// GetReorderable() is a wrapper around gtk_tree_view_column_get_reorderable().
func (v *TreeViewColumn) GetReorderable() bool {
return gobool(C.gtk_tree_view_column_get_reorderable(v.native()))
}
// SetSortIndicator() is a wrapper around gtk_tree_view_column_set_sort_indicator().
func (v *TreeViewColumn) SetSortIndicator(reorderable bool) {
C.gtk_tree_view_column_set_sort_indicator(v.native(), gbool(reorderable))
}
// GetSortIndicator() is a wrapper around gtk_tree_view_column_get_sort_indicator().
func (v *TreeViewColumn) GetSortIndicator() bool {
return gobool(C.gtk_tree_view_column_get_sort_indicator(v.native()))
}
// SetSortColumnID() is a wrapper around gtk_tree_view_column_set_sort_column_id().
func (v *TreeViewColumn) SetSortColumnID(w int) {
C.gtk_tree_view_column_set_sort_column_id(v.native(), C.gint(w))
}
// GetSortColumnID() is a wrapper around gtk_tree_view_column_get_sort_column_id().
func (v *TreeViewColumn) GetSortColumnID() int {
return int(C.gtk_tree_view_column_get_sort_column_id(v.native()))
}
// CellIsVisible() is a wrapper around gtk_tree_view_column_cell_is_visible().
func (v *TreeViewColumn) CellIsVisible() bool {
return gobool(C.gtk_tree_view_column_cell_is_visible(v.native()))
}
// FocusCell() is a wrapper around gtk_tree_view_column_focus_cell().
func (v *TreeViewColumn) FocusCell(cell *CellRenderer) {
C.gtk_tree_view_column_focus_cell(v.native(), cell.native())
}
// QueueResize() is a wrapper around gtk_tree_view_column_queue_resize().
func (v *TreeViewColumn) QueueResize() {
C.gtk_tree_view_column_queue_resize(v.native())
}
// GetXOffset() is a wrapper around gtk_tree_view_column_get_x_offset().
func (v *TreeViewColumn) GetXOffset() int {
return int(C.gtk_tree_view_column_get_x_offset(v.native()))
}
// GtkTreeViewColumn * gtk_tree_view_column_new_with_area ()
// void gtk_tree_view_column_set_attributes ()
// void gtk_tree_view_column_set_cell_data_func ()
// void gtk_tree_view_column_set_sizing ()
// GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing ()
// void gtk_tree_view_column_set_widget ()
// GtkWidget * gtk_tree_view_column_get_widget ()
// GtkWidget * gtk_tree_view_column_get_button ()
// void gtk_tree_view_column_set_alignment ()
// gfloat gtk_tree_view_column_get_alignment ()
// void gtk_tree_view_column_set_sort_order ()
// GtkSortType gtk_tree_view_column_get_sort_order ()
// void gtk_tree_view_column_cell_set_cell_data ()
// void gtk_tree_view_column_cell_get_size ()
// gboolean gtk_tree_view_column_cell_get_position ()
// GtkWidget * gtk_tree_view_column_get_tree_view ()

@ -0,0 +1,30 @@
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
import "errors"
func CheckVersion(major, minor, micro uint) error {
errChar := C.gtk_check_version(C.guint(major), C.guint(minor), C.guint(micro))
if errChar == nil {
return nil
}
return errors.New(C.GoString((*C.char)(errChar)))
}
func GetMajorVersion() uint {
v := C.gtk_get_major_version()
return uint(v)
}
func GetMinorVersion() uint {
v := C.gtk_get_minor_version()
return uint(v)
}
func GetMicroVersion() uint {
v := C.gtk_get_micro_version()
return uint(v)
}

@ -0,0 +1,612 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"errors"
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkWidget
*/
// Widget is a representation of GTK's GtkWidget.
type Widget struct {
glib.InitiallyUnowned
}
// IWidget is an interface type implemented by all structs
// embedding a Widget. It is meant to be used as an argument type
// for wrapper functions that wrap around a C GTK function taking a
// GtkWidget.
type IWidget interface {
toWidget() *C.GtkWidget
Set(string, interface{}) error
}
type IWidgetable interface {
toWidget() *C.GtkWidget
}
func nullableWidget(v IWidgetable) *C.GtkWidget {
if v == nil {
return nil
}
return v.toWidget()
}
// native returns a pointer to the underlying GtkWidget.
func (v *Widget) native() *C.GtkWidget {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkWidget(p)
}
func (v *Widget) toWidget() *C.GtkWidget {
if v == nil {
return nil
}
return v.native()
}
func marshalWidget(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapWidget(obj), nil
}
func wrapWidget(obj *glib.Object) *Widget {
return &Widget{glib.InitiallyUnowned{obj}}
}
// Destroy is a wrapper around gtk_widget_destroy().
func (v *Widget) Destroy() {
C.gtk_widget_destroy(v.native())
}
func (v *Widget) HideOnDelete() {
C._gtk_widget_hide_on_delete(v.native())
}
/* TODO
func (v *Widget) DragDestSet(flags DestDefaults, targets []TargetEntry, actions gdk.DragAction) {
C.gtk_drag_dest_set(v.native(), C.GtkDestDefaults(flags), (*C.GtkTargetEntry)(&targets[0]),
C.gint(len(targets)), C.GdkDragAction(actions))
}
*/
// ResetStyle is a wrapper around gtk_widget_reset_style().
func (v *Widget) ResetStyle() {
C.gtk_widget_reset_style(v.native())
}
// InDestruction is a wrapper around gtk_widget_in_destruction().
func (v *Widget) InDestruction() bool {
return gobool(C.gtk_widget_in_destruction(v.native()))
}
// TODO(jrick) this may require some rethinking
/*
func (v *Widget) Destroyed(widgetPointer **Widget) {
}
*/
// Unparent is a wrapper around gtk_widget_unparent().
func (v *Widget) Unparent() {
C.gtk_widget_unparent(v.native())
}
// Show is a wrapper around gtk_widget_show().
func (v *Widget) Show() {
C.gtk_widget_show(v.native())
}
// Hide is a wrapper around gtk_widget_hide().
func (v *Widget) Hide() {
C.gtk_widget_hide(v.native())
}
// GetCanFocus is a wrapper around gtk_widget_get_can_focus().
func (v *Widget) GetCanFocus() bool {
c := C.gtk_widget_get_can_focus(v.native())
return gobool(c)
}
// SetCanFocus is a wrapper around gtk_widget_set_can_focus().
func (v *Widget) SetCanFocus(canFocus bool) {
C.gtk_widget_set_can_focus(v.native(), gbool(canFocus))
}
// GetCanDefault is a wrapper around gtk_widget_get_can_default().
func (v *Widget) GetCanDefault() bool {
c := C.gtk_widget_get_can_default(v.native())
return gobool(c)
}
// SetCanDefault is a wrapper around gtk_widget_set_can_default().
func (v *Widget) SetCanDefault(canDefault bool) {
C.gtk_widget_set_can_default(v.native(), gbool(canDefault))
}
// GetMapped is a wrapper around gtk_widget_get_mapped().
func (v *Widget) GetMapped() bool {
c := C.gtk_widget_get_mapped(v.native())
return gobool(c)
}
// SetMapped is a wrapper around gtk_widget_set_mapped().
func (v *Widget) SetMapped(mapped bool) {
C.gtk_widget_set_can_focus(v.native(), gbool(mapped))
}
// GetRealized is a wrapper around gtk_widget_get_realized().
func (v *Widget) GetRealized() bool {
c := C.gtk_widget_get_realized(v.native())
return gobool(c)
}
// SetRealized is a wrapper around gtk_widget_set_realized().
func (v *Widget) SetRealized(realized bool) {
C.gtk_widget_set_realized(v.native(), gbool(realized))
}
// GetHasWindow is a wrapper around gtk_widget_get_has_window().
func (v *Widget) GetHasWindow() bool {
c := C.gtk_widget_get_has_window(v.native())
return gobool(c)
}
// SetHasWindow is a wrapper around gtk_widget_set_has_window().
func (v *Widget) SetHasWindow(hasWindow bool) {
C.gtk_widget_set_has_window(v.native(), gbool(hasWindow))
}
// ShowNow is a wrapper around gtk_widget_show_now().
func (v *Widget) ShowNow() {
C.gtk_widget_show_now(v.native())
}
// ShowAll is a wrapper around gtk_widget_show_all().
func (v *Widget) ShowAll() {
C.gtk_widget_show_all(v.native())
}
// SetNoShowAll is a wrapper around gtk_widget_set_no_show_all().
func (v *Widget) SetNoShowAll(noShowAll bool) {
C.gtk_widget_set_no_show_all(v.native(), gbool(noShowAll))
}
// GetNoShowAll is a wrapper around gtk_widget_get_no_show_all().
func (v *Widget) GetNoShowAll() bool {
c := C.gtk_widget_get_no_show_all(v.native())
return gobool(c)
}
// Map is a wrapper around gtk_widget_map().
func (v *Widget) Map() {
C.gtk_widget_map(v.native())
}
// Unmap is a wrapper around gtk_widget_unmap().
func (v *Widget) Unmap() {
C.gtk_widget_unmap(v.native())
}
// QueueDrawArea is a wrapper aroung gtk_widget_queue_draw_area().
func (v *Widget) QueueDrawArea(x, y, w, h int) {
C.gtk_widget_queue_draw_area(v.native(), C.gint(x), C.gint(y), C.gint(w), C.gint(h))
}
//void gtk_widget_realize(GtkWidget *widget);
//void gtk_widget_unrealize(GtkWidget *widget);
//void gtk_widget_draw(GtkWidget *widget, cairo_t *cr);
//void gtk_widget_queue_resize(GtkWidget *widget);
//void gtk_widget_queue_resize_no_redraw(GtkWidget *widget);
//GdkFrameClock *gtk_widget_get_frame_clock(GtkWidget *widget);
//guint gtk_widget_add_tick_callback (GtkWidget *widget,
// GtkTickCallback callback,
// gpointer user_data,
// GDestroyNotify notify);
//void gtk_widget_remove_tick_callback(GtkWidget *widget, guint id);
// TODO(jrick) GtkAllocation
/*
func (v *Widget) SizeAllocate() {
}
*/
// Allocation is a representation of GTK's GtkAllocation type.
type Allocation struct {
gdk.Rectangle
}
// Native returns a pointer to the underlying GtkAllocation.
func (v *Allocation) native() *C.GtkAllocation {
return (*C.GtkAllocation)(unsafe.Pointer(&v.GdkRectangle))
}
// GetAllocatedWidth() is a wrapper around gtk_widget_get_allocated_width().
func (v *Widget) GetAllocatedWidth() int {
return int(C.gtk_widget_get_allocated_width(v.native()))
}
// GetAllocatedHeight() is a wrapper around gtk_widget_get_allocated_height().
func (v *Widget) GetAllocatedHeight() int {
return int(C.gtk_widget_get_allocated_height(v.native()))
}
// Event() is a wrapper around gtk_widget_event().
func (v *Widget) Event(event *gdk.Event) bool {
c := C.gtk_widget_event(v.native(),
(*C.GdkEvent)(unsafe.Pointer(event.Native())))
return gobool(c)
}
// Activate() is a wrapper around gtk_widget_activate().
func (v *Widget) Activate() bool {
return gobool(C.gtk_widget_activate(v.native()))
}
// TODO(jrick) GdkRectangle
/*
func (v *Widget) Intersect() {
}
*/
// IsFocus() is a wrapper around gtk_widget_is_focus().
func (v *Widget) IsFocus() bool {
return gobool(C.gtk_widget_is_focus(v.native()))
}
// GrabFocus() is a wrapper around gtk_widget_grab_focus().
func (v *Widget) GrabFocus() {
C.gtk_widget_grab_focus(v.native())
}
// GrabDefault() is a wrapper around gtk_widget_grab_default().
func (v *Widget) GrabDefault() {
C.gtk_widget_grab_default(v.native())
}
// SetName() is a wrapper around gtk_widget_set_name().
func (v *Widget) SetName(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_widget_set_name(v.native(), (*C.gchar)(cstr))
}
// GetName() is a wrapper around gtk_widget_get_name(). A non-nil
// error is returned in the case that gtk_widget_get_name returns NULL to
// differentiate between NULL and an empty string.
func (v *Widget) GetName() (string, error) {
c := C.gtk_widget_get_name(v.native())
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// GetSensitive is a wrapper around gtk_widget_get_sensitive().
func (v *Widget) GetSensitive() bool {
c := C.gtk_widget_get_sensitive(v.native())
return gobool(c)
}
// IsSensitive is a wrapper around gtk_widget_is_sensitive().
func (v *Widget) IsSensitive() bool {
c := C.gtk_widget_is_sensitive(v.native())
return gobool(c)
}
// SetSensitive is a wrapper around gtk_widget_set_sensitive().
func (v *Widget) SetSensitive(sensitive bool) {
C.gtk_widget_set_sensitive(v.native(), gbool(sensitive))
}
// GetVisible is a wrapper around gtk_widget_get_visible().
func (v *Widget) GetVisible() bool {
c := C.gtk_widget_get_visible(v.native())
return gobool(c)
}
// SetVisible is a wrapper around gtk_widget_set_visible().
func (v *Widget) SetVisible(visible bool) {
C.gtk_widget_set_visible(v.native(), gbool(visible))
}
// SetParent is a wrapper around gtk_widget_set_parent().
func (v *Widget) SetParent(parent IWidget) {
C.gtk_widget_set_parent(v.native(), parent.toWidget())
}
// GetParent is a wrapper around gtk_widget_get_parent().
func (v *Widget) GetParent() (*Widget, error) {
c := C.gtk_widget_get_parent(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// SetSizeRequest is a wrapper around gtk_widget_set_size_request().
func (v *Widget) SetSizeRequest(width, height int) {
C.gtk_widget_set_size_request(v.native(), C.gint(width), C.gint(height))
}
// GetSizeRequest is a wrapper around gtk_widget_get_size_request().
func (v *Widget) GetSizeRequest() (width, height int) {
var w, h C.gint
C.gtk_widget_get_size_request(v.native(), &w, &h)
return int(w), int(h)
}
// SetParentWindow is a wrapper around gtk_widget_set_parent_window().
func (v *Widget) SetParentWindow(parentWindow *gdk.Window) {
C.gtk_widget_set_parent_window(v.native(),
(*C.GdkWindow)(unsafe.Pointer(parentWindow.Native())))
}
// GetParentWindow is a wrapper around gtk_widget_get_parent_window().
func (v *Widget) GetParentWindow() (*gdk.Window, error) {
c := C.gtk_widget_get_parent_window(v.native())
if v == nil {
return nil, nilPtrErr
}
w := &gdk.Window{wrapObject(unsafe.Pointer(c))}
return w, nil
}
// SetEvents is a wrapper around gtk_widget_set_events().
func (v *Widget) SetEvents(events int) {
C.gtk_widget_set_events(v.native(), C.gint(events))
}
// GetEvents is a wrapper around gtk_widget_get_events().
func (v *Widget) GetEvents() int {
return int(C.gtk_widget_get_events(v.native()))
}
// AddEvents is a wrapper around gtk_widget_add_events().
func (v *Widget) AddEvents(events int) {
C.gtk_widget_add_events(v.native(), C.gint(events))
}
// HasDefault is a wrapper around gtk_widget_has_default().
func (v *Widget) HasDefault() bool {
c := C.gtk_widget_has_default(v.native())
return gobool(c)
}
// HasFocus is a wrapper around gtk_widget_has_focus().
func (v *Widget) HasFocus() bool {
c := C.gtk_widget_has_focus(v.native())
return gobool(c)
}
// HasVisibleFocus is a wrapper around gtk_widget_has_visible_focus().
func (v *Widget) HasVisibleFocus() bool {
c := C.gtk_widget_has_visible_focus(v.native())
return gobool(c)
}
// HasGrab is a wrapper around gtk_widget_has_grab().
func (v *Widget) HasGrab() bool {
c := C.gtk_widget_has_grab(v.native())
return gobool(c)
}
// IsDrawable is a wrapper around gtk_widget_is_drawable().
func (v *Widget) IsDrawable() bool {
c := C.gtk_widget_is_drawable(v.native())
return gobool(c)
}
// IsToplevel is a wrapper around gtk_widget_is_toplevel().
func (v *Widget) IsToplevel() bool {
c := C.gtk_widget_is_toplevel(v.native())
return gobool(c)
}
// TODO(jrick) GdkEventMask
/*
func (v *Widget) SetDeviceEvents() {
}
*/
// TODO(jrick) GdkEventMask
/*
func (v *Widget) GetDeviceEvents() {
}
*/
// TODO(jrick) GdkEventMask
/*
func (v *Widget) AddDeviceEvents() {
}
*/
// SetDeviceEnabled is a wrapper around gtk_widget_set_device_enabled().
func (v *Widget) SetDeviceEnabled(device *gdk.Device, enabled bool) {
C.gtk_widget_set_device_enabled(v.native(),
(*C.GdkDevice)(unsafe.Pointer(device.Native())), gbool(enabled))
}
// GetDeviceEnabled is a wrapper around gtk_widget_get_device_enabled().
func (v *Widget) GetDeviceEnabled(device *gdk.Device) bool {
c := C.gtk_widget_get_device_enabled(v.native(),
(*C.GdkDevice)(unsafe.Pointer(device.Native())))
return gobool(c)
}
// GetToplevel is a wrapper around gtk_widget_get_toplevel().
func (v *Widget) GetToplevel() (*Widget, error) {
c := C.gtk_widget_get_toplevel(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// GetTooltipText is a wrapper around gtk_widget_get_tooltip_text().
// A non-nil error is returned in the case that
// gtk_widget_get_tooltip_text returns NULL to differentiate between NULL
// and an empty string.
func (v *Widget) GetTooltipText() (string, error) {
c := C.gtk_widget_get_tooltip_text(v.native())
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// SetTooltipText is a wrapper around gtk_widget_set_tooltip_text().
func (v *Widget) SetTooltipText(text string) {
cstr := C.CString(text)
defer C.free(unsafe.Pointer(cstr))
C.gtk_widget_set_tooltip_text(v.native(), (*C.gchar)(cstr))
}
// GetHAlign is a wrapper around gtk_widget_get_halign().
func (v *Widget) GetHAlign() Align {
c := C.gtk_widget_get_halign(v.native())
return Align(c)
}
// SetHAlign is a wrapper around gtk_widget_set_halign().
func (v *Widget) SetHAlign(align Align) {
C.gtk_widget_set_halign(v.native(), C.GtkAlign(align))
}
// GetVAlign is a wrapper around gtk_widget_get_valign().
func (v *Widget) GetVAlign() Align {
c := C.gtk_widget_get_valign(v.native())
return Align(c)
}
// SetVAlign is a wrapper around gtk_widget_set_valign().
func (v *Widget) SetVAlign(align Align) {
C.gtk_widget_set_valign(v.native(), C.GtkAlign(align))
}
// GetMarginTop is a wrapper around gtk_widget_get_margin_top().
func (v *Widget) GetMarginTop() int {
c := C.gtk_widget_get_margin_top(v.native())
return int(c)
}
// SetMarginTop is a wrapper around gtk_widget_set_margin_top().
func (v *Widget) SetMarginTop(margin int) {
C.gtk_widget_set_margin_top(v.native(), C.gint(margin))
}
// GetMarginBottom is a wrapper around gtk_widget_get_margin_bottom().
func (v *Widget) GetMarginBottom() int {
c := C.gtk_widget_get_margin_bottom(v.native())
return int(c)
}
// SetMarginBottom is a wrapper around gtk_widget_set_margin_bottom().
func (v *Widget) SetMarginBottom(margin int) {
C.gtk_widget_set_margin_bottom(v.native(), C.gint(margin))
}
// GetHExpand is a wrapper around gtk_widget_get_hexpand().
func (v *Widget) GetHExpand() bool {
c := C.gtk_widget_get_hexpand(v.native())
return gobool(c)
}
// SetHExpand is a wrapper around gtk_widget_set_hexpand().
func (v *Widget) SetHExpand(expand bool) {
C.gtk_widget_set_hexpand(v.native(), gbool(expand))
}
// GetVExpand is a wrapper around gtk_widget_get_vexpand().
func (v *Widget) GetVExpand() bool {
c := C.gtk_widget_get_vexpand(v.native())
return gobool(c)
}
// SetVExpand is a wrapper around gtk_widget_set_vexpand().
func (v *Widget) SetVExpand(expand bool) {
C.gtk_widget_set_vexpand(v.native(), gbool(expand))
}
// TranslateCoordinates is a wrapper around gtk_widget_translate_coordinates().
func (v *Widget) TranslateCoordinates(dest IWidget, srcX, srcY int) (destX, destY int, e error) {
cdest := nullableWidget(dest)
var cdestX, cdestY C.gint
c := C.gtk_widget_translate_coordinates(v.native(), cdest, C.gint(srcX), C.gint(srcY), &cdestX, &cdestY)
if !gobool(c) {
return 0, 0, errors.New("translate coordinates failed")
}
return int(cdestX), int(cdestY), nil
}
// SetVisual is a wrapper around gtk_widget_set_visual().
func (v *Widget) SetVisual(visual *gdk.Visual) {
C.gtk_widget_set_visual(v.native(),
(*C.GdkVisual)(unsafe.Pointer(visual.Native())))
}
// SetAppPaintable is a wrapper around gtk_widget_set_app_paintable().
func (v *Widget) SetAppPaintable(paintable bool) {
C.gtk_widget_set_app_paintable(v.native(), gbool(paintable))
}
// GetAppPaintable is a wrapper around gtk_widget_get_app_paintable().
func (v *Widget) GetAppPaintable() bool {
c := C.gtk_widget_get_app_paintable(v.native())
return gobool(c)
}
// QueueDraw is a wrapper around gtk_widget_queue_draw().
func (v *Widget) QueueDraw() {
C.gtk_widget_queue_draw(v.native())
}
// GetAllocation is a wrapper around gtk_widget_get_allocation().
func (v *Widget) GetAllocation() *Allocation {
var a Allocation
C.gtk_widget_get_allocation(v.native(), a.native())
return &a
}
// SetAllocation is a wrapper around gtk_widget_set_allocation().
func (v *Widget) SetAllocation(allocation *Allocation) {
C.gtk_widget_set_allocation(v.native(), allocation.native())
}
// SizeAllocate is a wrapper around gtk_widget_size_allocate().
func (v *Widget) SizeAllocate(allocation *Allocation) {
C.gtk_widget_size_allocate(v.native(), allocation.native())
}
// SetStateFlags is a wrapper around gtk_widget_set_state_flags().
func (v *Widget) SetStateFlags(stateFlags StateFlags, clear bool) {
C.gtk_widget_set_state_flags(v.native(), C.GtkStateFlags(stateFlags), gbool(clear))
}
// GetWindow is a wrapper around gtk_widget_get_window().
func (v *Widget) GetWindow() (*gdk.Window, error) {
c := C.gtk_widget_get_window(v.native())
if c == nil {
return nil, nilPtrErr
}
w := &gdk.Window{wrapObject(unsafe.Pointer(c))}
return w, nil
}

@ -0,0 +1,46 @@
// 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 <gtk/gtk.h>
import "C"
func (v *Widget) SetMarginStart(margin int) {
C.gtk_widget_set_margin_start(v.native(), C.gint(margin))
}
func (v *Widget) GetMarginStart() int {
c := C.gtk_widget_get_margin_start(v.native())
return int(c)
}
func (v *Widget) SetMarginEnd(margin int) {
C.gtk_widget_set_margin_end(v.native(), C.gint(margin))
}
func (v *Widget) GetMarginEnd() int {
c := C.gtk_widget_get_margin_end(v.native())
return int(c)
}

@ -0,0 +1,38 @@
// 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.8, and
// and should not be included in a build intended to target any older GTK
// versions. To target an older build, such as 3.8, use
// 'go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.18
// is assumed and this file is built.
// +build !gtk_3_6
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
/*
* GtkWidget
*/
// IsVisible is a wrapper around gtk_widget_is_visible().
func (v *Widget) IsVisible() bool {
c := C.gtk_widget_is_visible(v.native())
return gobool(c)
}

@ -0,0 +1,609 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
package gtk
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"errors"
"unsafe"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
/*
* GtkWindow
*/
// Window is a representation of GTK's GtkWindow.
type Window struct {
Bin
}
// IWindow is an interface type implemented by all structs embedding a
// Window. It is meant to be used as an argument type for wrapper
// functions that wrap around a C GTK function taking a GtkWindow.
type IWindow interface {
toWindow() *C.GtkWindow
}
// native returns a pointer to the underlying GtkWindow.
func (v *Window) native() *C.GtkWindow {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkWindow(p)
}
func (v *Window) toWindow() *C.GtkWindow {
if v == nil {
return nil
}
return v.native()
}
func marshalWindow(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapWindow(obj), nil
}
func wrapWindow(obj *glib.Object) *Window {
return &Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// WindowNew is a wrapper around gtk_window_new().
func WindowNew(t WindowType) (*Window, error) {
c := C.gtk_window_new(C.GtkWindowType(t))
if c == nil {
return nil, nilPtrErr
}
return wrapWindow(wrapObject(unsafe.Pointer(c))), nil
}
// SetTitle is a wrapper around gtk_window_set_title().
func (v *Window) SetTitle(title string) {
cstr := C.CString(title)
defer C.free(unsafe.Pointer(cstr))
C.gtk_window_set_title(v.native(), (*C.gchar)(cstr))
}
// SetResizable is a wrapper around gtk_window_set_resizable().
func (v *Window) SetResizable(resizable bool) {
C.gtk_window_set_resizable(v.native(), gbool(resizable))
}
// GetResizable is a wrapper around gtk_window_get_resizable().
func (v *Window) GetResizable() bool {
c := C.gtk_window_get_resizable(v.native())
return gobool(c)
}
// ActivateFocus is a wrapper around gtk_window_activate_focus().
func (v *Window) ActivateFocus() bool {
c := C.gtk_window_activate_focus(v.native())
return gobool(c)
}
// ActivateDefault is a wrapper around gtk_window_activate_default().
func (v *Window) ActivateDefault() bool {
c := C.gtk_window_activate_default(v.native())
return gobool(c)
}
// SetModal is a wrapper around gtk_window_set_modal().
func (v *Window) SetModal(modal bool) {
C.gtk_window_set_modal(v.native(), gbool(modal))
}
// SetDefaultSize is a wrapper around gtk_window_set_default_size().
func (v *Window) SetDefaultSize(width, height int) {
C.gtk_window_set_default_size(v.native(), C.gint(width), C.gint(height))
}
// SetDefaultGeometry is a wrapper around gtk_window_set_default_geometry().
func (v *Window) SetDefaultGeometry(width, height int) {
C.gtk_window_set_default_geometry(v.native(), C.gint(width),
C.gint(height))
}
// GetScreen is a wrapper around gtk_window_get_screen().
func (v *Window) GetScreen() (*gdk.Screen, error) {
c := C.gtk_window_get_screen(v.native())
if c == nil {
return nil, nilPtrErr
}
s := &gdk.Screen{wrapObject(unsafe.Pointer(c))}
return s, nil
}
// SetIcon is a wrapper around gtk_window_set_icon().
func (v *Window) SetIcon(icon *gdk.Pixbuf) {
iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native()))
C.gtk_window_set_icon(v.native(), iconPtr)
}
// WindowSetDefaultIcon is a wrapper around gtk_window_set_default_icon().
func WindowSetDefaultIcon(icon *gdk.Pixbuf) {
iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native()))
C.gtk_window_set_default_icon(iconPtr)
}
// TODO(jrick) GdkGeometry GdkWindowHints.
/*
func (v *Window) SetGeometryHints() {
}
*/
// SetGravity is a wrapper around gtk_window_set_gravity().
func (v *Window) SetGravity(gravity gdk.GdkGravity) {
C.gtk_window_set_gravity(v.native(), C.GdkGravity(gravity))
}
// TODO(jrick) GdkGravity.
/*
func (v *Window) GetGravity() {
}
*/
// SetPosition is a wrapper around gtk_window_set_position().
func (v *Window) SetPosition(position WindowPosition) {
C.gtk_window_set_position(v.native(), C.GtkWindowPosition(position))
}
// SetTransientFor is a wrapper around gtk_window_set_transient_for().
func (v *Window) SetTransientFor(parent IWindow) {
var pw *C.GtkWindow = nil
if parent != nil {
pw = parent.toWindow()
}
C.gtk_window_set_transient_for(v.native(), pw)
}
// SetDestroyWithParent is a wrapper around
// gtk_window_set_destroy_with_parent().
func (v *Window) SetDestroyWithParent(setting bool) {
C.gtk_window_set_destroy_with_parent(v.native(), gbool(setting))
}
// SetHideTitlebarWhenMaximized is a wrapper around
// gtk_window_set_hide_titlebar_when_maximized().
func (v *Window) SetHideTitlebarWhenMaximized(setting bool) {
C.gtk_window_set_hide_titlebar_when_maximized(v.native(),
gbool(setting))
}
// IsActive is a wrapper around gtk_window_is_active().
func (v *Window) IsActive() bool {
c := C.gtk_window_is_active(v.native())
return gobool(c)
}
// HasToplevelFocus is a wrapper around gtk_window_has_toplevel_focus().
func (v *Window) HasToplevelFocus() bool {
c := C.gtk_window_has_toplevel_focus(v.native())
return gobool(c)
}
// GetFocus is a wrapper around gtk_window_get_focus().
func (v *Window) GetFocus() (*Widget, error) {
c := C.gtk_window_get_focus(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// SetFocus is a wrapper around gtk_window_set_focus().
func (v *Window) SetFocus(w *Widget) {
C.gtk_window_set_focus(v.native(), w.native())
}
// GetDefaultWidget is a wrapper arround gtk_window_get_default_widget().
func (v *Window) GetDefaultWidget() *Widget {
c := C.gtk_window_get_default_widget(v.native())
if c == nil {
return nil
}
obj := wrapObject(unsafe.Pointer(c))
return wrapWidget(obj)
}
// SetDefault is a wrapper arround gtk_window_set_default().
func (v *Window) SetDefault(widget IWidget) {
C.gtk_window_set_default(v.native(), widget.toWidget())
}
// Present is a wrapper around gtk_window_present().
func (v *Window) Present() {
C.gtk_window_present(v.native())
}
// PresentWithTime is a wrapper around gtk_window_present_with_time().
func (v *Window) PresentWithTime(ts uint32) {
C.gtk_window_present_with_time(v.native(), C.guint32(ts))
}
// Iconify is a wrapper around gtk_window_iconify().
func (v *Window) Iconify() {
C.gtk_window_iconify(v.native())
}
// Deiconify is a wrapper around gtk_window_deiconify().
func (v *Window) Deiconify() {
C.gtk_window_deiconify(v.native())
}
// Stick is a wrapper around gtk_window_stick().
func (v *Window) Stick() {
C.gtk_window_stick(v.native())
}
// Unstick is a wrapper around gtk_window_unstick().
func (v *Window) Unstick() {
C.gtk_window_unstick(v.native())
}
// Maximize is a wrapper around gtk_window_maximize().
func (v *Window) Maximize() {
C.gtk_window_maximize(v.native())
}
// Unmaximize is a wrapper around gtk_window_unmaximize().
func (v *Window) Unmaximize() {
C.gtk_window_unmaximize(v.native())
}
// Fullscreen is a wrapper around gtk_window_fullscreen().
func (v *Window) Fullscreen() {
C.gtk_window_fullscreen(v.native())
}
// Unfullscreen is a wrapper around gtk_window_unfullscreen().
func (v *Window) Unfullscreen() {
C.gtk_window_unfullscreen(v.native())
}
// SetKeepAbove is a wrapper around gtk_window_set_keep_above().
func (v *Window) SetKeepAbove(setting bool) {
C.gtk_window_set_keep_above(v.native(), gbool(setting))
}
// SetKeepBelow is a wrapper around gtk_window_set_keep_below().
func (v *Window) SetKeepBelow(setting bool) {
C.gtk_window_set_keep_below(v.native(), gbool(setting))
}
// SetDecorated is a wrapper around gtk_window_set_decorated().
func (v *Window) SetDecorated(setting bool) {
C.gtk_window_set_decorated(v.native(), gbool(setting))
}
// SetDeletable is a wrapper around gtk_window_set_deletable().
func (v *Window) SetDeletable(setting bool) {
C.gtk_window_set_deletable(v.native(), gbool(setting))
}
// SetSkipTaskbarHint is a wrapper around gtk_window_set_skip_taskbar_hint().
func (v *Window) SetSkipTaskbarHint(setting bool) {
C.gtk_window_set_skip_taskbar_hint(v.native(), gbool(setting))
}
// SetSkipPagerHint is a wrapper around gtk_window_set_skip_pager_hint().
func (v *Window) SetSkipPagerHint(setting bool) {
C.gtk_window_set_skip_pager_hint(v.native(), gbool(setting))
}
// SetUrgencyHint is a wrapper around gtk_window_set_urgency_hint().
func (v *Window) SetUrgencyHint(setting bool) {
C.gtk_window_set_urgency_hint(v.native(), gbool(setting))
}
// SetAcceptFocus is a wrapper around gtk_window_set_accept_focus().
func (v *Window) SetAcceptFocus(setting bool) {
C.gtk_window_set_accept_focus(v.native(), gbool(setting))
}
// SetFocusOnMap is a wrapper around gtk_window_set_focus_on_map().
func (v *Window) SetFocusOnMap(setting bool) {
C.gtk_window_set_focus_on_map(v.native(), gbool(setting))
}
// SetStartupID is a wrapper around gtk_window_set_startup_id().
func (v *Window) SetStartupID(sid string) {
cstr := (*C.gchar)(C.CString(sid))
defer C.free(unsafe.Pointer(cstr))
C.gtk_window_set_startup_id(v.native(), cstr)
}
// SetRole is a wrapper around gtk_window_set_role().
func (v *Window) SetRole(s string) {
cstr := (*C.gchar)(C.CString(s))
defer C.free(unsafe.Pointer(cstr))
C.gtk_window_set_role(v.native(), cstr)
}
// SetWMClass is a wrapper around gtk_window_set_wmclass().
func (v *Window) SetWMClass(name, class string) {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
cClass := C.CString(class)
defer C.free(unsafe.Pointer(cClass))
C.gtk_window_set_wmclass(v.native(), (*C.gchar)(cName), (*C.gchar)(cClass))
}
// GetDecorated is a wrapper around gtk_window_get_decorated().
func (v *Window) GetDecorated() bool {
c := C.gtk_window_get_decorated(v.native())
return gobool(c)
}
// GetDeletable is a wrapper around gtk_window_get_deletable().
func (v *Window) GetDeletable() bool {
c := C.gtk_window_get_deletable(v.native())
return gobool(c)
}
// WindowGetDefaultIconName is a wrapper around gtk_window_get_default_icon_name().
func WindowGetDefaultIconName() (string, error) {
return stringReturn(C.gtk_window_get_default_icon_name())
}
// GetDefaultSize is a wrapper around gtk_window_get_default_size().
func (v *Window) GetDefaultSize() (width, height int) {
var w, h C.gint
C.gtk_window_get_default_size(v.native(), &w, &h)
return int(w), int(h)
}
// GetDestroyWithParent is a wrapper around
// gtk_window_get_destroy_with_parent().
func (v *Window) GetDestroyWithParent() bool {
c := C.gtk_window_get_destroy_with_parent(v.native())
return gobool(c)
}
// GetHideTitlebarWhenMaximized is a wrapper around
// gtk_window_get_hide_titlebar_when_maximized().
func (v *Window) GetHideTitlebarWhenMaximized() bool {
c := C.gtk_window_get_hide_titlebar_when_maximized(v.native())
return gobool(c)
}
// GetIcon is a wrapper around gtk_window_get_icon().
func (v *Window) GetIcon() (*gdk.Pixbuf, error) {
c := C.gtk_window_get_icon(v.native())
if c == nil {
return nil, nilPtrErr
}
p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))}
return p, nil
}
// GetIconName is a wrapper around gtk_window_get_icon_name().
func (v *Window) GetIconName() (string, error) {
return stringReturn(C.gtk_window_get_icon_name(v.native()))
}
// GetModal is a wrapper around gtk_window_get_modal().
func (v *Window) GetModal() bool {
c := C.gtk_window_get_modal(v.native())
return gobool(c)
}
// GetPosition is a wrapper around gtk_window_get_position().
func (v *Window) GetPosition() (root_x, root_y int) {
var x, y C.gint
C.gtk_window_get_position(v.native(), &x, &y)
return int(x), int(y)
}
func stringReturn(c *C.gchar) (string, error) {
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// GetRole is a wrapper around gtk_window_get_role().
func (v *Window) GetRole() (string, error) {
return stringReturn(C.gtk_window_get_role(v.native()))
}
// GetSize is a wrapper around gtk_window_get_size().
func (v *Window) GetSize() (width, height int) {
var w, h C.gint
C.gtk_window_get_size(v.native(), &w, &h)
return int(w), int(h)
}
// GetTitle is a wrapper around gtk_window_get_title().
func (v *Window) GetTitle() (string, error) {
return stringReturn(C.gtk_window_get_title(v.native()))
}
// GetTransientFor is a wrapper around gtk_window_get_transient_for().
func (v *Window) GetTransientFor() (*Window, error) {
c := C.gtk_window_get_transient_for(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWindow(wrapObject(unsafe.Pointer(c))), nil
}
// GetAttachedTo is a wrapper around gtk_window_get_attached_to().
func (v *Window) GetAttachedTo() (*Widget, error) {
c := C.gtk_window_get_attached_to(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapWidget(wrapObject(unsafe.Pointer(c))), nil
}
// GetSkipTaskbarHint is a wrapper around gtk_window_get_skip_taskbar_hint().
func (v *Window) GetSkipTaskbarHint() bool {
c := C.gtk_window_get_skip_taskbar_hint(v.native())
return gobool(c)
}
// GetSkipPagerHint is a wrapper around gtk_window_get_skip_pager_hint().
func (v *Window) GetSkipPagerHint() bool {
c := C.gtk_window_get_skip_taskbar_hint(v.native())
return gobool(c)
}
// GetUrgencyHint is a wrapper around gtk_window_get_urgency_hint().
func (v *Window) GetUrgencyHint() bool {
c := C.gtk_window_get_urgency_hint(v.native())
return gobool(c)
}
// GetAcceptFocus is a wrapper around gtk_window_get_accept_focus().
func (v *Window) GetAcceptFocus() bool {
c := C.gtk_window_get_accept_focus(v.native())
return gobool(c)
}
// GetFocusOnMap is a wrapper around gtk_window_get_focus_on_map().
func (v *Window) GetFocusOnMap() bool {
c := C.gtk_window_get_focus_on_map(v.native())
return gobool(c)
}
// HasGroup is a wrapper around gtk_window_has_group().
func (v *Window) HasGroup() bool {
c := C.gtk_window_has_group(v.native())
return gobool(c)
}
// Move is a wrapper around gtk_window_move().
func (v *Window) Move(x, y int) {
C.gtk_window_move(v.native(), C.gint(x), C.gint(y))
}
// Resize is a wrapper around gtk_window_resize().
func (v *Window) Resize(width, height int) {
C.gtk_window_resize(v.native(), C.gint(width), C.gint(height))
}
// ResizeToGeometry is a wrapper around gtk_window_resize_to_geometry().
func (v *Window) ResizeToGeometry(width, height int) {
C.gtk_window_resize_to_geometry(v.native(), C.gint(width), C.gint(height))
}
// WindowSetDefaultIconFromFile is a wrapper around gtk_window_set_default_icon_from_file().
func WindowSetDefaultIconFromFile(file string) error {
cstr := C.CString(file)
defer C.free(unsafe.Pointer(cstr))
var err *C.GError = nil
res := C.gtk_window_set_default_icon_from_file((*C.gchar)(cstr), &err)
if res == 0 {
defer C.g_error_free(err)
return errors.New(C.GoString((*C.char)(err.message)))
}
return nil
}
// WindowSetDefaultIconName is a wrapper around gtk_window_set_default_icon_name().
func WindowSetDefaultIconName(s string) {
cstr := (*C.gchar)(C.CString(s))
defer C.free(unsafe.Pointer(cstr))
C.gtk_window_set_default_icon_name(cstr)
}
// SetIconFromFile is a wrapper around gtk_window_set_icon_from_file().
func (v *Window) SetIconFromFile(file string) error {
cstr := C.CString(file)
defer C.free(unsafe.Pointer(cstr))
var err *C.GError = nil
res := C.gtk_window_set_icon_from_file(v.native(), (*C.gchar)(cstr), &err)
if res == 0 {
defer C.g_error_free(err)
return errors.New(C.GoString((*C.char)(err.message)))
}
return nil
}
// SetIconName is a wrapper around gtk_window_set_icon_name().
func (v *Window) SetIconName(name string) {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_window_set_icon_name(v.native(), (*C.gchar)(cstr))
}
// SetAutoStartupNotification is a wrapper around
// gtk_window_set_auto_startup_notification().
// This doesn't seem write. Might need to rethink?
/*
func (v *Window) SetAutoStartupNotification(setting bool) {
C.gtk_window_set_auto_startup_notification(gbool(setting))
}
*/
// GetMnemonicsVisible is a wrapper around
// gtk_window_get_mnemonics_visible().
func (v *Window) GetMnemonicsVisible() bool {
c := C.gtk_window_get_mnemonics_visible(v.native())
return gobool(c)
}
// SetMnemonicsVisible is a wrapper around
// gtk_window_get_mnemonics_visible().
func (v *Window) SetMnemonicsVisible(setting bool) {
C.gtk_window_set_mnemonics_visible(v.native(), gbool(setting))
}
// GetFocusVisible is a wrapper around gtk_window_get_focus_visible().
func (v *Window) GetFocusVisible() bool {
c := C.gtk_window_get_focus_visible(v.native())
return gobool(c)
}
// SetFocusVisible is a wrapper around gtk_window_set_focus_visible().
func (v *Window) SetFocusVisible(setting bool) {
C.gtk_window_set_focus_visible(v.native(), gbool(setting))
}
// GetApplication is a wrapper around gtk_window_get_application().
func (v *Window) GetApplication() (*Application, error) {
c := C.gtk_window_get_application(v.native())
if c == nil {
return nil, nilPtrErr
}
return wrapApplication(wrapObject(unsafe.Pointer(c))), nil
}
// SetApplication is a wrapper around gtk_window_set_application().
func (v *Window) SetApplication(a *Application) {
C.gtk_window_set_application(v.native(), a.native())
}
// TODO gtk_window_activate_key().
// TODO gtk_window_add_mnemonic().
// TODO gtk_window_begin_move_drag().
// TODO gtk_window_begin_resize_drag().
// TODO gtk_window_get_default_icon_list().
// TODO gtk_window_get_group().
// TODO gtk_window_get_icon_list().
// TODO gtk_window_get_mnemonic_modifier().
// TODO gtk_window_get_type_hint().
// TODO gtk_window_get_window_type().
// TODO gtk_window_list_toplevels().
// TODO gtk_window_mnemonic_activate().
// TODO gtk_window_parse_geometry().
// TODO gtk_window_propogate_key_event().
// TODO gtk_window_remove_mnemonic().
// TODO gtk_window_set_attached_to().
// TODO gtk_window_set_default_icon_list().
// TODO gtk_window_set_icon_list().
// TODO gtk_window_set_mnemonic_modifier().
// TODO gtk_window_set_screen().
// TODO gtk_window_set_type_hint().
// TODO gtk_window_get_resize_grip_area().

@ -0,0 +1,27 @@
// Same copyright and license as the rest of the files in this project
// This file contains accelerator related functions and structures
// +build !gtk_3_6,!gtk_3_8
// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_since_3_10.go.h"
import "C"
/*
* GtkWindow
*/
// SetTitlebar is a wrapper around gtk_window_set_titlebar().
func (v *Window) SetTitlebar(titlebar IWidget) {
C.gtk_window_set_titlebar(v.native(), titlebar.toWidget())
}
// Close is a wrapper around gtk_window_close().
func (v *Window) Close() {
C.gtk_window_close(v.native())
}

@ -0,0 +1,357 @@
/*
* Copyright (c) 2015- terrak <terrak1975@gmail.com>
*
* This file originated from: http://www.terrak.net/
*
* 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.
*/
package pango
// #cgo pkg-config: pango
// #include <pango/pango.h>
// #include "pango.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
{glib.Type(C.pango_attr_type_get_type()), marshalAttrType},
{glib.Type(C.pango_underline_get_type()), marshalUnderline},
}
glib.RegisterGValueMarshalers(tm)
}
/* PangoColor */
// Color is a representation of PangoColor.
type Color struct {
pangoColor *C.PangoColor
}
// Native returns a pointer to the underlying PangoColor.
func (v *Color) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *Color) native() *C.PangoColor {
return (*C.PangoColor)(unsafe.Pointer(v.pangoColor))
}
func (v *Color) Set(red, green, blue uint16) {
v.native().red = C.guint16(red)
v.native().green = C.guint16(green)
v.native().blue = C.guint16(blue)
}
func (v *Color) Get() (red, green, blue uint16) {
return uint16(v.native().red), uint16(v.native().green), uint16(v.native().blue)
}
//PangoColor *pango_color_copy (const PangoColor *src);
func (v *Color) Copy(c *Color) *Color {
w := new(Color)
w.pangoColor = C.pango_color_copy(v.native())
return w
}
//void pango_color_free (PangoColor *color);
func (v *Color) Free() {
C.pango_color_free(v.native())
}
//gboolean pango_color_parse (PangoColor *color,
// const char *spec);
func (v *Color) Parse(spec string) bool {
cstr := C.CString(spec)
defer C.free(unsafe.Pointer(cstr))
c := C.pango_color_parse(v.native(), (*C.char)(cstr))
return gobool(c)
}
//gchar *pango_color_to_string(const PangoColor *color);
func (v *Color) ToString() string {
c := C.pango_color_to_string(v.native())
return C.GoString((*C.char)(c))
}
/* --- --- --- Attributes --- --- --- */
// AttrList is a representation of PangoAttrList.
type AttrList struct {
pangoAttrList *C.PangoAttrList
}
// Native returns a pointer to the underlying PangoLayout.
func (v *AttrList) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *AttrList) native() *C.PangoAttrList {
return (*C.PangoAttrList)(unsafe.Pointer(v.pangoAttrList))
}
// AttrType is a representation of Pango's PangoAttrType.
type AttrType int
const (
ATTR_INVALID AttrType = C.PANGO_ATTR_INVALID /* 0 is an invalid attribute type */
ATTR_LANGUAGE AttrType = C.PANGO_ATTR_LANGUAGE /* PangoAttrLanguage */
ATTR_FAMILY AttrType = C.PANGO_ATTR_FAMILY /* PangoAttrString */
ATTR_STYLE AttrType = C.PANGO_ATTR_STYLE /* PangoAttrInt */
ATTR_WEIGHT AttrType = C.PANGO_ATTR_WEIGHT /* PangoAttrInt */
ATTR_VARIANT AttrType = C.PANGO_ATTR_VARIANT /* PangoAttrInt */
ATTR_STRETCH AttrType = C.PANGO_ATTR_STRETCH /* PangoAttrInt */
ATTR_SIZE AttrType = C.PANGO_ATTR_SIZE /* PangoAttrSize */
ATTR_FONT_DESC AttrType = C.PANGO_ATTR_FONT_DESC /* PangoAttrFontDesc */
ATTR_FOREGROUND AttrType = C.PANGO_ATTR_FOREGROUND /* PangoAttrColor */
ATTR_BACKGROUND AttrType = C.PANGO_ATTR_BACKGROUND /* PangoAttrColor */
ATTR_UNDERLINE AttrType = C.PANGO_ATTR_UNDERLINE /* PangoAttrInt */
ATTR_STRIKETHROUGH AttrType = C.PANGO_ATTR_STRIKETHROUGH /* PangoAttrInt */
ATTR_RISE AttrType = C.PANGO_ATTR_RISE /* PangoAttrInt */
ATTR_SHAPE AttrType = C.PANGO_ATTR_SHAPE /* PangoAttrShape */
ATTR_SCALE AttrType = C.PANGO_ATTR_SCALE /* PangoAttrFloat */
ATTR_FALLBACK AttrType = C.PANGO_ATTR_FALLBACK /* PangoAttrInt */
ATTR_LETTER_SPACING AttrType = C.PANGO_ATTR_LETTER_SPACING /* PangoAttrInt */
ATTR_UNDERLINE_COLOR AttrType = C.PANGO_ATTR_UNDERLINE_COLOR /* PangoAttrColor */
ATTR_STRIKETHROUGH_COLOR AttrType = C.PANGO_ATTR_STRIKETHROUGH_COLOR /* PangoAttrColor */
ATTR_ABSOLUTE_SIZE AttrType = C.PANGO_ATTR_ABSOLUTE_SIZE /* PangoAttrSize */
ATTR_GRAVITY AttrType = C.PANGO_ATTR_GRAVITY /* PangoAttrInt */
ATTR_GRAVITY_HINT AttrType = C.PANGO_ATTR_GRAVITY_HINT /* PangoAttrInt */
)
func marshalAttrType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return AttrType(c), nil
}
// Underline is a representation of Pango's PangoUnderline.
type Underline int
const (
UNDERLINE_NONE Underline = C.PANGO_UNDERLINE_NONE
UNDERLINE_SINGLE Underline = C.PANGO_UNDERLINE_SINGLE
UNDERLINE_DOUBLE Underline = C.PANGO_UNDERLINE_DOUBLE
UNDERLINE_LOW Underline = C.PANGO_UNDERLINE_LOW
UNDERLINE_ERROR Underline = C.PANGO_UNDERLINE_ERROR
)
func marshalUnderline(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return Underline(c), nil
}
const (
ATTR_INDEX_FROM_TEXT_BEGINNING uint = 0
ATTR_INDEX_TO_TEXT_END uint = C.G_MAXUINT
)
// Attribute is a representation of Pango's PangoAttribute.
type Attribute struct {
pangoAttribute *C.PangoAttribute
//start_index, end_index uint
}
// Native returns a pointer to the underlying PangoColor.
func (v *Attribute) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *Attribute) native() *C.PangoAttribute {
return (*C.PangoAttribute)(unsafe.Pointer(v.pangoAttribute))
}
/*
//typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute,
// gpointer user_data);
func (v *Attribute) AttrFilterFunc(user_data uintptr) bool {
c := C.PangoAttrFilterFunc(Attribute.native(), C.gpointer(user_data))
return gobool(c)
}
//typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer user_data);
func AttrDataCopyFunc(user_data uintptr) uintptr {
c := C.PangoAttrDataCopyFunc(C.gpointer(user_data))
return uintptr(c)
}
*/
// AttrClass is a representation of Pango's PangoAttrClass.
type AttrClass struct {
//PangoAttrType type;
}
// AttrString is a representation of Pango's PangoAttrString.
type AttrString struct {
Attribute
//char *value;
}
// AttrLanguage is a representation of Pango's PangoAttrLanguage.
type AttrLanguage struct {
Attribute
//PangoLanguage *value;
}
// AttrInt is a representation of Pango's PangoAttrInt.
type AttrInt struct {
Attribute
//int value;
}
// AttrFloat is a representation of Pango's PangoAttrFloat.
type AttrFloat struct {
Attribute
//double value;
}
// AttrColor is a representation of Pango's AttrColor.
type AttrColor struct {
Attribute
Color
}
// AttrSize is a representation of Pango's PangoAttrSize.
type AttrSize struct {
Attribute
//int size;
//guint absolute : 1;
}
// AttrShape is a representation of Pango's PangoAttrShape.
type AttrShape struct {
Attribute
//PangoRectangle ink_rect;
//PangoRectangle logical_rect;
//gpointer data;
//PangoAttrDataCopyFunc copy_func;
//GDestroyNotify destroy_func;
}
// AttrFontDesc is a representation of Pango's PangoAttrFontDesc.
type AttrFontDesc struct {
Attribute
//PangoFontDescription *desc;
}
/*
PangoAttrType pango_attr_type_register (const gchar *name);
const char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST;
void pango_attribute_init (PangoAttribute *attr,
const PangoAttrClass *klass);
PangoAttribute * pango_attribute_copy (const PangoAttribute *attr);
void pango_attribute_destroy (PangoAttribute *attr);
gboolean pango_attribute_equal (const PangoAttribute *attr1,
const PangoAttribute *attr2) G_GNUC_PURE;
PangoAttribute *pango_attr_language_new (PangoLanguage *language);
PangoAttribute *pango_attr_family_new (const char *family);
PangoAttribute *pango_attr_foreground_new (guint16 red,
guint16 green,
guint16 blue);
PangoAttribute *pango_attr_background_new (guint16 red,
guint16 green,
guint16 blue);
PangoAttribute *pango_attr_size_new (int size);
PangoAttribute *pango_attr_size_new_absolute (int size);
PangoAttribute *pango_attr_style_new (PangoStyle style);
PangoAttribute *pango_attr_weight_new (PangoWeight weight);
PangoAttribute *pango_attr_variant_new (PangoVariant variant);
PangoAttribute *pango_attr_stretch_new (PangoStretch stretch);
PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc);
PangoAttribute *pango_attr_underline_new (PangoUnderline underline);
PangoAttribute *pango_attr_underline_color_new (guint16 red,
guint16 green,
guint16 blue);
PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough);
PangoAttribute *pango_attr_strikethrough_color_new (guint16 red,
guint16 green,
guint16 blue);
PangoAttribute *pango_attr_rise_new (int rise);
PangoAttribute *pango_attr_scale_new (double scale_factor);
PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback);
PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing);
PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect,
const PangoRectangle *logical_rect);
PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect,
const PangoRectangle *logical_rect,
gpointer data,
PangoAttrDataCopyFunc copy_func,
GDestroyNotify destroy_func);
PangoAttribute *pango_attr_gravity_new (PangoGravity gravity);
PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint);
GType pango_attr_list_get_type (void) G_GNUC_CONST;
PangoAttrList * pango_attr_list_new (void);
PangoAttrList * pango_attr_list_ref (PangoAttrList *list);
void pango_attr_list_unref (PangoAttrList *list);
PangoAttrList * pango_attr_list_copy (PangoAttrList *list);
void pango_attr_list_insert (PangoAttrList *list,
PangoAttribute *attr);
void pango_attr_list_insert_before (PangoAttrList *list,
PangoAttribute *attr);
void pango_attr_list_change (PangoAttrList *list,
PangoAttribute *attr);
void pango_attr_list_splice (PangoAttrList *list,
PangoAttrList *other,
gint pos,
gint len);
PangoAttrList *pango_attr_list_filter (PangoAttrList *list,
PangoAttrFilterFunc func,
gpointer data);
PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list);
void pango_attr_iterator_range (PangoAttrIterator *iterator,
gint *start,
gint *end);
gboolean pango_attr_iterator_next (PangoAttrIterator *iterator);
PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator);
void pango_attr_iterator_destroy (PangoAttrIterator *iterator);
PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator,
PangoAttrType type);
void pango_attr_iterator_get_font (PangoAttrIterator *iterator,
PangoFontDescription *desc,
PangoLanguage **language,
GSList **extra_attrs);
GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator);
gboolean pango_parse_markup (const char *markup_text,
int length,
gunichar accel_marker,
PangoAttrList **attr_list,
char **text,
gunichar *accel_char,
GError **error);
GMarkupParseContext * pango_markup_parser_new (gunichar accel_marker);
gboolean pango_markup_parser_finish (GMarkupParseContext *context,
PangoAttrList **attr_list,
char **text,
gunichar *accel_char,
GError **error);
*/

@ -0,0 +1,27 @@
/*
* Copyright (c) 2015- terrak <terrak1975@gmail.com>
*
* This file originated from: http://www.terrak.net/
*
* 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.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static PangoColor* toPangoColor(void *p)
{
return ( (PangoColor*) (p) );
}

@ -0,0 +1,135 @@
/*
* Copyright (c) 2015- terrak <terrak1975@gmail.com>
*
* This file originated from: http://www.terrak.net/
*
* 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.
*/
package pango
// #cgo pkg-config: pango
// #include <pango/pango.h>
// #include "pango.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
// {glib.Type(C.pango_alignment_get_type()), marshalAlignment},
// {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode},
// {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode},
// Objects/Interfaces
// {glib.Type(C.pango_context_get_type()), marshalContext},
}
glib.RegisterGValueMarshalers(tm)
}
// Context is a representation of PangoContext.
type Context struct {
pangoContext *C.PangoContext
}
// Native returns a pointer to the underlying PangoLayout.
func (v *Context) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *Context) native() *C.PangoContext {
return (*C.PangoContext)(unsafe.Pointer(v.pangoContext))
}
/*
func marshalContext(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapContext(obj), nil
}
func wrapContext(obj *glib.Object) *Context {
return &Context{obj}
}
*/
//PangoContext *pango_context_new (void);
func ContextNew() *Context {
c := C.pango_context_new()
context := new(Context)
context.pangoContext = (*C.PangoContext)(c)
return context
}
//void pango_context_changed (PangoContext *context);
//void pango_context_set_font_map (PangoContext *context,
// PangoFontMap *font_map);
//PangoFontMap *pango_context_get_font_map (PangoContext *context);
//guint pango_context_get_serial (PangoContext *context);
//void pango_context_list_families (PangoContext *context,
// PangoFontFamily ***families,
// int *n_families);
//PangoFont * pango_context_load_font (PangoContext *context,
// const PangoFontDescription *desc);
//PangoFontset *pango_context_load_fontset (PangoContext *context,
// const PangoFontDescription *desc,
// PangoLanguage *language);
//
//PangoFontMetrics *pango_context_get_metrics (PangoContext *context,
// const PangoFontDescription *desc,
// PangoLanguage *language);
//
//void pango_context_set_font_description (PangoContext *context,
// const PangoFontDescription *desc);
//PangoFontDescription * pango_context_get_font_description (PangoContext *context);
//PangoLanguage *pango_context_get_language (PangoContext *context);
//void pango_context_set_language (PangoContext *context,
// PangoLanguage *language);
//void pango_context_set_base_dir (PangoContext *context,
// PangoDirection direction);
//PangoDirection pango_context_get_base_dir (PangoContext *context);
//void pango_context_set_base_gravity (PangoContext *context,
// PangoGravity gravity);
//PangoGravity pango_context_get_base_gravity (PangoContext *context);
//PangoGravity pango_context_get_gravity (PangoContext *context);
//void pango_context_set_gravity_hint (PangoContext *context,
// PangoGravityHint hint);
//PangoGravityHint pango_context_get_gravity_hint (PangoContext *context);
//
//void pango_context_set_matrix (PangoContext *context,
// const PangoMatrix *matrix);
//const PangoMatrix * pango_context_get_matrix (PangoContext *context);
/* Break a string of Unicode characters into segments with
* consistent shaping/language engine and bidrectional level.
* Returns a #GList of #PangoItem's
*/
//GList *pango_itemize (PangoContext *context,
// const char *text,
// int start_index,
// int length,
// PangoAttrList *attrs,
// PangoAttrIterator *cached_iter);
//GList *pango_itemize_with_base_dir (PangoContext *context,
// PangoDirection base_dir,
// const char *text,
// int start_index,
// int length,
// PangoAttrList *attrs,
// PangoAttrIterator *cached_iter);

@ -0,0 +1,706 @@
/*
* Copyright (c) 2015- terrak <terrak1975@gmail.com>
*
* This file originated from: http://www.terrak.net/
*
* 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.
*/
package pango
// #cgo pkg-config: pango
// #include <pango/pango.h>
// #include "pango.go.h"
import "C"
import (
// "github.com/andre-hub/gotk3/glib"
// "github.com/andre-hub/gotk3/cairo"
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Enums
// Objects/Interfaces
{glib.Type(C.pango_font_description_get_type()), marshalFontDescription},
}
glib.RegisterGValueMarshalers(tm)
}
// FontDescription is a representation of PangoFontDescription.
type FontDescription struct {
pangoFontDescription *C.PangoFontDescription
}
// Native returns a pointer to the underlying PangoLayout.
func (v *FontDescription) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *FontDescription) native() *C.PangoFontDescription {
return (*C.PangoFontDescription)(unsafe.Pointer(v.pangoFontDescription))
}
// FontMetrics is a representation of PangoFontMetrics.
type FontMetrics struct {
pangoFontMetrics *C.PangoFontMetrics
}
// Native returns a pointer to the underlying PangoLayout.
func (v *FontMetrics) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (v *FontMetrics) native() *C.PangoFontMetrics {
return (*C.PangoFontMetrics)(unsafe.Pointer(v.pangoFontMetrics))
}
const (
PANGO_SCALE = C.PANGO_SCALE
)
type Style int
const (
STYLE_NORMAL Style = C.PANGO_STYLE_NORMAL
STYLE_OBLIQUE Style = C.PANGO_STYLE_OBLIQUE
STYLE_ITALIC Style = C.PANGO_STYLE_ITALIC
)
type Variant int
const (
VARIANT_NORMAL Variant = C.PANGO_VARIANT_NORMAL
VARIANT_SMALL_CAPS Variant = C.PANGO_VARIANT_SMALL_CAPS
)
type Weight int
const (
WEIGHT_THIN Weight = C.PANGO_WEIGHT_THIN /* 100 */
WEIGHT_ULTRALIGHT Weight = C.PANGO_WEIGHT_ULTRALIGHT /* 200 */
WEIGHT_LIGHT Weight = C.PANGO_WEIGHT_LIGHT /* 300 */
WEIGHT_SEMILIGHT Weight = 350 /* 350 */
WEIGHT_BOOK Weight = C.PANGO_WEIGHT_BOOK /* 380 */
WEIGHT_NORMAL Weight = C.PANGO_WEIGHT_NORMAL /* 400 */
WEIGHT_MEDIUM Weight = C.PANGO_WEIGHT_MEDIUM /* 500 */
WEIGHT_SEMIBOLD Weight = C.PANGO_WEIGHT_SEMIBOLD /* 600 */
WEIGHT_BOLD Weight = C.PANGO_WEIGHT_BOLD /* 700 */
WEIGHT_ULTRABOLD Weight = C.PANGO_WEIGHT_ULTRABOLD /* 800 */
WEIGHT_HEAVY Weight = C.PANGO_WEIGHT_HEAVY /* 900 */
WEIGHT_ULTRAHEAVY Weight = C.PANGO_WEIGHT_ULTRAHEAVY /* 1000 */
)
type Stretch int
const (
STRETCH_ULTRA_CONDENSED Stretch = C.PANGO_STRETCH_ULTRA_CONDENSED
STRETCH_EXTRA_CONDENSEDStretch Stretch = C.PANGO_STRETCH_EXTRA_CONDENSED
STRETCH_CONDENSEDStretch Stretch = C.PANGO_STRETCH_CONDENSED
STRETCH_SEMI_CONDENSEDStretch Stretch = C.PANGO_STRETCH_SEMI_CONDENSED
STRETCH_NORMALStretch Stretch = C.PANGO_STRETCH_NORMAL
STRETCH_SEMI_EXPANDEDStretch Stretch = C.PANGO_STRETCH_SEMI_EXPANDED
STRETCH_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXPANDED
STRETCH_EXTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXTRA_EXPANDED
STRETCH_ULTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_ULTRA_EXPANDED
)
type FontMask int
const (
FONT_MASK_FAMILY FontMask = C.PANGO_FONT_MASK_FAMILY /* 1 << 0 */
FONT_MASK_STYLEFontMask FontMask = C.PANGO_FONT_MASK_STYLE /* 1 << 1 */
FONT_MASK_VARIANTFontMask FontMask = C.PANGO_FONT_MASK_VARIANT /* 1 << 2 */
FONT_MASK_WEIGHTFontMask FontMask = C.PANGO_FONT_MASK_WEIGHT /* 1 << 3 */
FONT_MASK_STRETCHFontMask FontMask = C.PANGO_FONT_MASK_STRETCH /* 1 << 4 */
FONT_MASK_SIZEFontMask FontMask = C.PANGO_FONT_MASK_SIZE /* 1 << 5 */
FONT_MASK_GRAVITYFontMask FontMask = C.PANGO_FONT_MASK_GRAVITY /* 1 << 6 */
)
type Scale float64
const (
SCALE_XX_SMALL Scale = /* C.PANGO_SCALE_XX_SMALL */ 0.5787037037037
SCALE_X_SMALL Scale = /*C.PANGO_SCALE_X_SMALL */ 0.6444444444444
SCALE_SMALL Scale = /*C.PANGO_SCALE_SMALL */ 0.8333333333333
SCALE_MEDIUM Scale = /*C.PANGO_SCALE_MEDIUM */ 1.0
SCALE_LARGE Scale = /*C.PANGO_SCALE_LARGE */ 1.2
SCALE_X_LARGE Scale = /*C.PANGO_SCALE_X_LARGE */ 1.4399999999999
SCALE_XX_LARGE Scale = /*C.PANGO_SCALE_XX_LARGE */ 1.728
)
/*
* PangoFontDescription
*/
func marshalFontDescription(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
c2 := (*C.PangoFontDescription)(unsafe.Pointer(c))
return wrapFontDescription(c2), nil
}
func wrapFontDescription(obj *C.PangoFontDescription) *FontDescription {
return &FontDescription{obj}
}
//PangoFontDescription *pango_font_description_new (void);
func FontDescriptionNew() *FontDescription {
c := C.pango_font_description_new()
v := new(FontDescription)
v.pangoFontDescription = c
return v
}
//PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc);
func (v *FontDescription) Copy() *FontDescription {
c := C.pango_font_description_copy(v.native())
v2 := new(FontDescription)
v2.pangoFontDescription = c
return v2
}
//PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription *desc);
func (v *FontDescription) CopyStatic() *FontDescription {
c := C.pango_font_description_copy_static(v.native())
v2 := new(FontDescription)
v2.pangoFontDescription = c
return v2
}
//guint pango_font_description_hash (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) Hash() uint {
c := C.pango_font_description_hash(v.native())
return uint(c)
}
//gboolean pango_font_description_equal (const PangoFontDescription *desc1,
// const PangoFontDescription *desc2) G_GNUC_PURE;
func (v *FontDescription) Equal(v2 *FontDescription) bool {
c := C.pango_font_description_equal(v.native(), v2.native())
return gobool(c)
}
//void pango_font_description_free (PangoFontDescription *desc);
func (v *FontDescription) Free() {
C.pango_font_description_free(v.native())
}
//void pango_font_descriptions_free (PangoFontDescription **descs,
// int n_descs);
//func (v *FontDescription) FontDescriptionsFree(n_descs int) {
// C.pango_font_descriptions_free(v.native(), C.int(n_descs))
//}
//void pango_font_description_set_family (PangoFontDescription *desc,
// const char *family);
func (v *FontDescription) SetFamily(family string) {
cstr := C.CString(family)
defer C.free(unsafe.Pointer(cstr))
C.pango_font_description_set_family(v.native(), (*C.char)(cstr))
}
//void pango_font_description_set_family_static (PangoFontDescription *desc,
// const char *family);
func (v *FontDescription) SetFamilyStatic(family string) {
cstr := C.CString(family)
defer C.free(unsafe.Pointer(cstr))
C.pango_font_description_set_family_static(v.native(), (*C.char)(cstr))
}
//const char *pango_font_description_get_family (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetFamily() string {
c := C.pango_font_description_get_family(v.native())
return C.GoString((*C.char)(c))
}
//void pango_font_description_set_style (PangoFontDescription *desc,
// PangoStyle style);
func (v *FontDescription) SetStyle(style Style) {
C.pango_font_description_set_style(v.native(), (C.PangoStyle)(style))
}
//PangoStyle pango_font_description_get_style (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetStyle() Style {
c := C.pango_font_description_get_style(v.native())
return Style(c)
}
//void pango_font_description_set_variant (PangoFontDescription *desc,
// PangoVariant variant);
//PangoVariant pango_font_description_get_variant (const PangoFontDescription *desc) G_GNUC_PURE;
//void pango_font_description_set_weight (PangoFontDescription *desc,
// PangoWeight weight);
func (v *FontDescription) SetWeight(weight Weight) {
C.pango_font_description_set_weight(v.native(), (C.PangoWeight)(weight))
}
//PangoWeight pango_font_description_get_weight (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetWeight() Weight {
c := C.pango_font_description_get_weight(v.native())
return Weight(c)
}
//void pango_font_description_set_stretch (PangoFontDescription *desc,
// PangoStretch stretch);
func (v *FontDescription) SetStretch(stretch Stretch) {
C.pango_font_description_set_stretch(v.native(), (C.PangoStretch)(stretch))
}
//PangoStretch pango_font_description_get_stretch (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetStretch() Stretch {
c := C.pango_font_description_get_stretch(v.native())
return Stretch(c)
}
//void pango_font_description_set_size (PangoFontDescription *desc,
// gint size);
func (v *FontDescription) SetSize(size int) {
C.pango_font_description_set_size(v.native(), (C.gint)(size))
}
//gint pango_font_description_get_size (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetSize() int {
c := C.pango_font_description_get_size(v.native())
return int(c)
}
//void pango_font_description_set_absolute_size (PangoFontDescription *desc,
// double size);
func (v *FontDescription) SetAbsoluteSize(size float64) {
C.pango_font_description_set_absolute_size(v.native(), (C.double)(size))
}
//gboolean pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetSizeIsAbsolute() bool {
c := C.pango_font_description_get_size_is_absolute(v.native())
return gobool(c)
}
//void pango_font_description_set_gravity (PangoFontDescription *desc,
// PangoGravity gravity);
func (v *FontDescription) SetGravity(gravity Gravity) {
C.pango_font_description_set_gravity(v.native(), (C.PangoGravity)(gravity))
}
//PangoGravity pango_font_description_get_gravity (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetGravity() Gravity {
c := C.pango_font_description_get_gravity(v.native())
return Gravity(c)
}
//PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE;
func (v *FontDescription) GetSetFields() FontMask {
c := C.pango_font_description_get_set_fields(v.native())
return FontMask(c)
}
//void pango_font_description_unset_fields (PangoFontDescription *desc,
// PangoFontMask to_unset);
func (v *FontDescription) GetUnsetFields(to_unset FontMask) {
C.pango_font_description_unset_fields(v.native(), (C.PangoFontMask)(to_unset))
}
//void pango_font_description_merge (PangoFontDescription *desc,
// const PangoFontDescription *desc_to_merge,
// gboolean replace_existing);
func (v *FontDescription) Merge(desc_to_merge *FontDescription, replace_existing bool) {
C.pango_font_description_merge(v.native(), desc_to_merge.native(), gbool(replace_existing))
}
//void pango_font_description_merge_static (PangoFontDescription *desc,
// const PangoFontDescription *desc_to_merge,
// gboolean replace_existing);
func (v *FontDescription) MergeStatic(desc_to_merge *FontDescription, replace_existing bool) {
C.pango_font_description_merge_static(v.native(), desc_to_merge.native(), gbool(replace_existing))
}
//gboolean pango_font_description_better_match (const PangoFontDescription *desc,
// const PangoFontDescription *old_match,
// const PangoFontDescription *new_match) G_GNUC_PURE;
func (v *FontDescription) BetterMatch(old_match, new_match *FontDescription) bool {
c := C.pango_font_description_better_match(v.native(), old_match.native(), new_match.native())
return gobool(c)
}
//PangoFontDescription *pango_font_description_from_string (const char *str);
func FontDescriptionFromString(str string) *FontDescription {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
c := C.pango_font_description_from_string((*C.char)(cstr))
v := new(FontDescription)
v.pangoFontDescription = c
return v
}
//char * pango_font_description_to_string (const PangoFontDescription *desc);
func (v *FontDescription) ToString() string {
c := C.pango_font_description_to_string(v.native())
return C.GoString((*C.char)(c))
}
//char * pango_font_description_to_filename (const PangoFontDescription *desc);
func (v *FontDescription) ToFilename() string {
c := C.pango_font_description_to_filename(v.native())
return C.GoString((*C.char)(c))
}
///*
// * PangoFontMetrics
// */
//
///**
// * PANGO_TYPE_FONT_METRICS:
// *
// * The #GObject type for #PangoFontMetrics.
// */
//#define PANGO_TYPE_FONT_METRICS (pango_font_metrics_get_type ())
//GType pango_font_metrics_get_type (void) G_GNUC_CONST;
//PangoFontMetrics *pango_font_metrics_ref (PangoFontMetrics *metrics);
//void pango_font_metrics_unref (PangoFontMetrics *metrics);
//int pango_font_metrics_get_ascent (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_descent (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_approximate_char_width (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_underline_position (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_underline_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_strikethrough_position (PangoFontMetrics *metrics) G_GNUC_PURE;
//int pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
//
//#ifdef PANGO_ENABLE_BACKEND
//
//PangoFontMetrics *pango_font_metrics_new (void);
//
//struct _PangoFontMetrics
//{
// guint ref_count;
//
// int ascent;
// int descent;
// int approximate_char_width;
// int approximate_digit_width;
// int underline_position;
// int underline_thickness;
// int strikethrough_position;
// int strikethrough_thickness;
//};
//
//#endif /* PANGO_ENABLE_BACKEND */
//
///*
// * PangoFontFamily
// */
//
///**
// * PANGO_TYPE_FONT_FAMILY:
// *
// * The #GObject type for #PangoFontFamily.
// */
///**
// * PANGO_FONT_FAMILY:
// * @object: a #GObject.
// *
// * Casts a #GObject to a #PangoFontFamily.
// */
///**
// * PANGO_IS_FONT_FAMILY:
// * @object: a #GObject.
// *
// * Returns: %TRUE if @object is a #PangoFontFamily.
// */
//#define PANGO_TYPE_FONT_FAMILY (pango_font_family_get_type ())
//#define PANGO_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily))
//#define PANGO_IS_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY))
//
//typedef struct _PangoFontFamily PangoFontFamily;
//typedef struct _PangoFontFace PangoFontFace;
//
//GType pango_font_family_get_type (void) G_GNUC_CONST;
//
//void pango_font_family_list_faces (PangoFontFamily *family,
// PangoFontFace ***faces,
// int *n_faces);
//const char *pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE;
//gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE;
//
//#ifdef PANGO_ENABLE_BACKEND
//
//#define PANGO_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
//#define PANGO_IS_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY))
//#define PANGO_FONT_FAMILY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
//
//typedef struct _PangoFontFamilyClass PangoFontFamilyClass;
//
//
///**
// * PangoFontFamily:
// *
// * The #PangoFontFamily structure is used to represent a family of related
// * font faces. The faces in a family share a common design, but differ in
// * slant, weight, width and other aspects.
// */
//struct _PangoFontFamily
//{
// GObject parent_instance;
//};
//
//struct _PangoFontFamilyClass
//{
// GObjectClass parent_class;
//
// /*< public >*/
//
// void (*list_faces) (PangoFontFamily *family,
// PangoFontFace ***faces,
// int *n_faces);
// const char * (*get_name) (PangoFontFamily *family);
// gboolean (*is_monospace) (PangoFontFamily *family);
//
// /*< private >*/
//
// /* Padding for future expansion */
// void (*_pango_reserved2) (void);
// void (*_pango_reserved3) (void);
// void (*_pango_reserved4) (void);
//};
//
//#endif /* PANGO_ENABLE_BACKEND */
//
///*
// * PangoFontFace
// */
//
///**
// * PANGO_TYPE_FONT_FACE:
// *
// * The #GObject type for #PangoFontFace.
// */
///**
// * PANGO_FONT_FACE:
// * @object: a #GObject.
// *
// * Casts a #GObject to a #PangoFontFace.
// */
///**
// * PANGO_IS_FONT_FACE:
// * @object: a #GObject.
// *
// * Returns: %TRUE if @object is a #PangoFontFace.
// */
//#define PANGO_TYPE_FONT_FACE (pango_font_face_get_type ())
//#define PANGO_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace))
//#define PANGO_IS_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE))
//
//GType pango_font_face_get_type (void) G_GNUC_CONST;
//
//PangoFontDescription *pango_font_face_describe (PangoFontFace *face);
//const char *pango_font_face_get_face_name (PangoFontFace *face) G_GNUC_PURE;
//void pango_font_face_list_sizes (PangoFontFace *face,
// int **sizes,
// int *n_sizes);
//gboolean pango_font_face_is_synthesized (PangoFontFace *face) G_GNUC_PURE;
//
//#ifdef PANGO_ENABLE_BACKEND
//
//#define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
//#define PANGO_IS_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE))
//#define PANGO_FONT_FACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
//
//typedef struct _PangoFontFaceClass PangoFontFaceClass;
//
///**
// * PangoFontFace:
// *
// * The #PangoFontFace structure is used to represent a group of fonts with
// * the same family, slant, weight, width, but varying sizes.
// */
//struct _PangoFontFace
//{
// GObject parent_instance;
//};
//
//struct _PangoFontFaceClass
//{
// GObjectClass parent_class;
//
// /*< public >*/
//
// const char * (*get_face_name) (PangoFontFace *face);
// PangoFontDescription * (*describe) (PangoFontFace *face);
// void (*list_sizes) (PangoFontFace *face,
// int **sizes,
// int *n_sizes);
// gboolean (*is_synthesized) (PangoFontFace *face);
//
// /*< private >*/
//
// /* Padding for future expansion */
// void (*_pango_reserved3) (void);
// void (*_pango_reserved4) (void);
//};
//
//#endif /* PANGO_ENABLE_BACKEND */
//
///*
// * PangoFont
// */
//
///**
// * PANGO_TYPE_FONT:
// *
// * The #GObject type for #PangoFont.
// */
///**
// * PANGO_FONT:
// * @object: a #GObject.
// *
// * Casts a #GObject to a #PangoFont.
// */
///**
// * PANGO_IS_FONT:
// * @object: a #GObject.
// *
// * Returns: %TRUE if @object is a #PangoFont.
// */
//#define PANGO_TYPE_FONT (pango_font_get_type ())
//#define PANGO_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont))
//#define PANGO_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT))
//
//GType pango_font_get_type (void) G_GNUC_CONST;
//
//PangoFontDescription *pango_font_describe (PangoFont *font);
//PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont *font);
//PangoCoverage * pango_font_get_coverage (PangoFont *font,
// PangoLanguage *language);
//PangoEngineShape * pango_font_find_shaper (PangoFont *font,
// PangoLanguage *language,
// guint32 ch);
//PangoFontMetrics * pango_font_get_metrics (PangoFont *font,
// PangoLanguage *language);
//void pango_font_get_glyph_extents (PangoFont *font,
// PangoGlyph glyph,
// PangoRectangle *ink_rect,
// PangoRectangle *logical_rect);
//PangoFontMap *pango_font_get_font_map (PangoFont *font);
//
//#ifdef PANGO_ENABLE_BACKEND
//
//#define PANGO_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
//#define PANGO_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT))
//#define PANGO_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass))
//
//typedef struct _PangoFontClass PangoFontClass;
//
///**
// * PangoFont:
// *
// * The #PangoFont structure is used to represent
// * a font in a rendering-system-independent matter.
// * To create an implementation of a #PangoFont,
// * the rendering-system specific code should allocate
// * a larger structure that contains a nested
// * #PangoFont, fill in the <structfield>klass</structfield> member of
// * the nested #PangoFont with a pointer to
// * a appropriate #PangoFontClass, then call
// * pango_font_init() on the structure.
// *
// * The #PangoFont structure contains one member
// * which the implementation fills in.
// */
//struct _PangoFont
//{
// GObject parent_instance;
//};
//
//struct _PangoFontClass
//{
// GObjectClass parent_class;
//
// /*< public >*/
//
// PangoFontDescription *(*describe) (PangoFont *font);
// PangoCoverage * (*get_coverage) (PangoFont *font,
// PangoLanguage *lang);
// PangoEngineShape * (*find_shaper) (PangoFont *font,
// PangoLanguage *lang,
// guint32 ch);
// void (*get_glyph_extents) (PangoFont *font,
// PangoGlyph glyph,
// PangoRectangle *ink_rect,
// PangoRectangle *logical_rect);
// PangoFontMetrics * (*get_metrics) (PangoFont *font,
// PangoLanguage *language);
// PangoFontMap * (*get_font_map) (PangoFont *font);
// PangoFontDescription *(*describe_absolute) (PangoFont *font);
// /*< private >*/
//
// /* Padding for future expansion */
// void (*_pango_reserved1) (void);
// void (*_pango_reserved2) (void);
//};
//
///* used for very rare and miserable situtations that we cannot even
// * draw a hexbox
// */
//#define PANGO_UNKNOWN_GLYPH_WIDTH 10
//#define PANGO_UNKNOWN_GLYPH_HEIGHT 14
//
//#endif /* PANGO_ENABLE_BACKEND */
//
///**
// * PANGO_GLYPH_EMPTY:
// *
// * The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a
// * special meaning, which is a zero-width empty glyph. This is useful for
// * example in shaper modules, to use as the glyph for various zero-width
// * Unicode characters (those passing pango_is_zero_width()).
// */
///**
// * PANGO_GLYPH_INVALID_INPUT:
// *
// * The %PANGO_GLYPH_INVALID_INPUT macro represents a #PangoGlyph value that has a
// * special meaning of invalid input. #PangoLayout produces one such glyph
// * per invalid input UTF-8 byte and such a glyph is rendered as a crossed
// * box.
// *
// * Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG
// * on.
// *
// * Since: 1.20
// */
///**
// * PANGO_GLYPH_UNKNOWN_FLAG:
// *
// * The %PANGO_GLYPH_UNKNOWN_FLAG macro is a flag value that can be added to
// * a #gunichar value of a valid Unicode character, to produce a #PangoGlyph
// * value, representing an unknown-character glyph for the respective #gunichar.
// */
///**
// * PANGO_GET_UNKNOWN_GLYPH:
// * @wc: a Unicode character
// *
// * The way this unknown glyphs are rendered is backend specific. For example,
// * a box with the hexadecimal Unicode code-point of the character written in it
// * is what is done in the most common backends.
// *
// * Returns: a #PangoGlyph value that means no glyph was found for @wc.
// */
//#define PANGO_GLYPH_EMPTY ((PangoGlyph)0x0FFFFFFF)
//#define PANGO_GLYPH_INVALID_INPUT ((PangoGlyph)0xFFFFFFFF)
//#define PANGO_GLYPH_UNKNOWN_FLAG ((PangoGlyph)0x10000000)
//#define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG)
//
//

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save