shw-merge v0.0.8
dma 7 years ago
parent a8321095be
commit ab7d9464e0

@ -0,0 +1,130 @@
============================================================================
User visible changes for gotk3
Go bindings for GTK3
============================================================================
Changes for next Version
- Add new binding support
- gdk: fix memory leak in Pixbuf finalizers
- gdk: new functions for Pixbuf: ApplyEmbeddedOrientation, SaveJPEG, SavePNG
- gdk: PixbufLoader wrapper
- gtk: new functions for Adjustment: GetPageSize, SetPageSize, Configure
- gtk: new functions for Range: SetIncrements, SetRange
- gtk: new wrappers: IRecentChooser, RecentChooser, RecentChooserMenu,
- gtk: RecentFilter, RecentManager, IScrollable, Scrollable, IViewport, Viewport, Allocation
- gtk: new function for ScrolledWindow: SetHAdjustment
- gtk: new function for SpinButton: SetIncrements
- gtk: new functions for Widget: GetAllocation, SetAllocation, SizeAllocate
- gtk: new function RecentChooser
- gtk: added Widget.GetStyleContext, new wrappers for GtkCssProvider
- API Break Warning: no longer support for gtk 3.16 deprecated mark functions/elements
Changes in 0.3.0 (Wed Jun 10 2015)
- API Break Warning: function signatures changed
- Add new binding support
- GtkBuilder
- GtkButton
- GtkCellRenderer
- GtkStatusIcon
- GtkStatusbar
- GtkTreeView
- better and more support for cairo
- better and more support for pango
Changes in 0.2.0 (Mon Feb 10 2014)
- API BREAK: Modify function signatures for ListStore bindings so unset
iterators need not be created and passed as pointers to be set
- Add cairo package (currently targeting cairo 1.10) and add initial binding
support for cairo Surface and Context
- Add new binding support for the following GTK classes:
- GdkPixbuf (https://github.com/geoffholden/gotk3/issues/40)
- GtkAboutDialog
- GtkAlignment
- GtkArrow
- GtkCalendar
- GtkDrawingArea
- GtkEventBox
- GtkOffscreenWindow (https://github.com/geoffholden/gotk3/issues/33)
- GtkSpinner
- GtkSwitch
- Add additional bindings for gtk.Label
- Add glib.TimeoutAdd (https://github.com/geoffholden/gotk3/issues/41)
- Call correct C function to create a new TextTagTable
(https://github.com/geoffholden/gotk3/issues/40)
- Create correct go values from glib values
(https://github.com/geoffholden/gotk3/issues/39 and
https://github.com/geoffholden/gotk3/issues/41)
Changes in 0.1.1 (Tue Jan 14 2014)
- Fix a (*glib.Object).Connect crash where an allocated GValue was
prematurely unset
- Fix memory leaks when adding callbacks with (*glib.Object).Connect and
glib.IdleAdd
- Make all constants typed for increased compile-time type safety
- Remove a duplicate example file (resulting in two main functions)
which broke recursive go get
- Add ALIGN_BASELINE const (since GTK 3.10)
Changes in 0.1.0 (Thu Jan 09 2014)
- Modify signal callback API to remove glib.CallbackContext
- New support for the following types:
- gtk.CellRendererToggle
- gtk.HeaderBar
- gtk.TextView
- Additional function support for the following types:
- gtk.MessageDialog
- gtk.Window
- Add examples for gtk.TextView bindings
- Fix build when building with gccgo
(https://github.com/geoffholden/gotk3/issues/19 and
https://github.com/geoffholden/gotk3/issues/20)
Changes in 0.0.2 (Wed Nov 13 2013)
- Begin GTK 3.10 support
- Add support for targeting GTK 3.6
- Add build tags to target previous GTK releases
- Additional function support for the following types:
- gtk.Label
- gtk.Misc
- gtk.Scrollbar
- gtk.SpinButton
- gtk.Window
- New support for the following types:
- gtk.Builder
- gtk.CheckButton
- gtk.Frame
- gtk.Range
- gtk.Scrollbar
- gtk.Separator
- gtk.SeparatorMenuItem
- gtk.ShadowType
- gtk.ToggleButton
- Add glib.GetUserSpecialDir
- Use C constants directly instead of using iota
- Fix several nil pointer dereferences
- General code cleanup
Initial Release 0.0.1 (Tue Jul 16 2013)
- Initial release

@ -0,0 +1,11 @@
## CONTRIBUTIONS
- [conformal](https://github.com/conformal/gotk3)
- [jrick](https://github.com/jrick/gotk3)
- [sqp](https://github.com/sqp/gotk3)
- [dradtke](https://github.com/dradtke/gotk3)
- [MovingtoMars](https://github.com/MovingtoMars/gotk3)
- [shish](https://github.com/shish/gotk3)
- [andre](https://github.com/andre-hub/gotk3)
- [raichu](https://github.com/raichu/gotk3)
- [juniorz](https://github.com/juniorz)
- you?

@ -0,0 +1,13 @@
Copyright (c) 2013-2014 Conformal Systems LLC.
Permission to use, copy, modify, and/or 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,206 @@
gotk3 [![GoDoc](https://godoc.org/github.com/gotk3/gotk3?status.svg)](https://godoc.org/github.com/gotk3/gotk3)
=====
[![Build Status](https://travis-ci.org/gotk3/gotk3.png?branch=master)](https://travis-ci.org/gotk3/gotk3)
The gotk3 project provides Go bindings for GTK+3 and dependent
projects. Each component is given its own subdirectory, which is used
as the import path for the package. Partial binding support for the
following libraries is currently implemented:
- GTK+3 (3.12 and later)
- GDK 3 (3.12 and later)
- GLib 2 (2.36 and later)
- Cairo (1.10 and later)
Care has been taken for memory management to work seamlessly with Go's
garbage collector without the need to use or understand GObject's
floating references.
## Sample Use
The following example can be found in [Examples](https://github.com/gotk3/gotk3-examples/).
```Go
package main
import (
"github.com/gotk3/gotk3/gtk"
"log"
)
func main() {
// Initialize GTK without parsing any command line arguments.
gtk.Init(nil)
// Create a new toplevel window, set its title, and connect it to the
// "destroy" signal to exit the GTK main loop when it is destroyed.
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Simple Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new label widget to show in the window.
l, err := gtk.LabelNew("Hello, gotk3!")
if err != nil {
log.Fatal("Unable to create label:", err)
}
// Add the label to the window.
win.Add(l)
// Set the default window size.
win.SetDefaultSize(800, 600)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
```
To build the example:
```
$ go build example.go
```
To build this example with older gtk version you should use gtk_3_10 tag:
```
$ go build -tags gtk_3_10 example.go
```
### examples for gtk3
```Go
package main
import (
"log"
"os"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
// Simple Gtk3 Application written in go.
// This application creates a window on the application callback activate.
// More GtkApplication info can be found here -> https://wiki.gnome.org/HowDoI/GtkApplication
func main() {
// Create Gtk Application, change appID to your application domain name reversed.
const appID = "org.gtk.example"
application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE)
// Check to make sure no errors when creating Gtk Application
if err != nil {
log.Fatal("Could not create application.", err)
}
// Application signals available
// startup -> sets up the application when it first starts
// activate -> shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment.
// open -> opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar.
// shutdown -> performs shutdown tasks
// Setup Gtk Application callback signals
application.Connect("activate", func() { onActivate(application) })
// Run Gtk application
os.Exit(application.Run(os.Args))
}
// Callback signal from Gtk Application
func onActivate(application *gtk.Application) {
// Create ApplicationWindow
appWindow, err := gtk.ApplicationWindowNew(application)
if err != nil {
log.Fatal("Could not create application window.", err)
}
// Set ApplicationWindow Properties
appWindow.SetTitle("Basic Application.")
appWindow.SetDefaultSize(400, 400)
appWindow.Show()
}
```
```Go
package main
import (
"log"
"os"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
// Simple Gtk3 Application written in go.
// This application creates a window on the application callback activate.
// More GtkApplication info can be found here -> https://wiki.gnome.org/HowDoI/GtkApplication
func main() {
// Create Gtk Application, change appID to your application domain name reversed.
const appID = "org.gtk.example"
application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE)
// Check to make sure no errors when creating Gtk Application
if err != nil {
log.Fatal("Could not create application.", err)
}
// Application signals available
// startup -> sets up the application when it first starts
// activate -> shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment.
// open -> opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar.
// shutdown -> performs shutdown tasks
// Setup activate signal with a closure function.
application.Connect("activate", func() {
// Create ApplicationWindow
appWindow, err := gtk.ApplicationWindowNew(application)
if err != nil {
log.Fatal("Could not create application window.", err)
}
// Set ApplicationWindow Properties
appWindow.SetTitle("Basic Application.")
appWindow.SetDefaultSize(400, 400)
appWindow.Show()
})
// Run Gtk application
application.Run(os.Args)
}
```
## Documentation
Each package's internal `go doc` style documentation can be viewed
online without installing this package by using the GoDoc site (links
to [cairo](http://godoc.org/github.com/gotk3/gotk3/cairo),
[glib](http://godoc.org/github.com/gotk3/gotk3/glib),
[gdk](http://godoc.org/github.com/gotk3/gotk3/gdk), and
[gtk](http://godoc.org/github.com/gotk3/gotk3/gtk) documentation).
You can also view the documentation locally once the package is
installed with the `godoc` tool by running `godoc -http=":6060"` and
pointing your browser to
http://localhost:6060/pkg/github.com/gotk3/gotk3
## Installation
gotk3 currently requires GTK 3.6-3.16, GLib 2.36-2.40, and
Cairo 1.10 or 1.12. A recent Go (1.3 or newer) is also required.
For detailed instructions see the wiki pages: [installation](https://github.com/gotk3/gotk3/wiki#installation)
## TODO
- Add bindings for all of GTK+
- Add tests for each implemented binding
## License
Package gotk3 is licensed under the liberal ISC License.

@ -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,406 @@
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}
}
func WrapContext(p uintptr) *Context {
context := (*C.cairo_t)(unsafe.Pointer(p))
return wrapContext(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,140 @@
package cairo
// #cgo pkg-config: cairo cairo-gobject
// #include <stdlib.h>
// #include <cairo.h>
// #include <cairo-gobject.h>
import "C"
import (
"runtime"
"unsafe"
)
/*
* cairo_pattern_t
*/
// Pattern is a representation of Cairo's cairo_pattern_t.
type Pattern struct {
pattern *C.cairo_pattern_t
}
func NewPatternFromRGB(red, green, blue float64) (*Pattern, error) {
patternNative := C.cairo_pattern_create_rgb(C.double(red), C.double(green), C.double(blue))
status := Status(C.cairo_pattern_status(patternNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
pattern := wrapPattern(patternNative)
runtime.SetFinalizer(pattern, (*Pattern).destroy)
return pattern, nil
}
func NewPatternFromRGBA(red, green, blue, alpha float64) (*Pattern, error) {
patternNative := C.cairo_pattern_create_rgba(C.double(red), C.double(green), C.double(blue), C.double(alpha))
status := Status(C.cairo_pattern_status(patternNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
pattern := wrapPattern(patternNative)
runtime.SetFinalizer(pattern, (*Pattern).destroy)
return pattern, nil
}
func NewPatternForSurface(s *Surface) (*Pattern, error) {
patternNative := C.cairo_pattern_create_for_surface(s.native())
status := Status(C.cairo_pattern_status(patternNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
pattern := wrapPattern(patternNative)
runtime.SetFinalizer(pattern, (*Pattern).destroy)
return pattern, nil
}
func NewPatternLinear(x0, y0, x1, y1 float64) (*Pattern, error) {
patternNative := C.cairo_pattern_create_linear(C.double(x0), C.double(y0), C.double(x1), C.double(y1))
status := Status(C.cairo_pattern_status(patternNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
pattern := wrapPattern(patternNative)
runtime.SetFinalizer(pattern, (*Pattern).destroy)
return pattern, nil
}
func NewPatternRadial(x0, y0, r0, x1, y1, r1 float64) (*Pattern, error) {
patternNative := C.cairo_pattern_create_radial(C.double(x0), C.double(y0), C.double(r0),
C.double(x1), C.double(y1), C.double(r1))
status := Status(C.cairo_pattern_status(patternNative))
if status != STATUS_SUCCESS {
return nil, ErrorStatus(status)
}
pattern := wrapPattern(patternNative)
runtime.SetFinalizer(pattern, (*Pattern).destroy)
return pattern, nil
}
func (p *Pattern) AddColorStopRGB(offset, red, green, blue float64) error {
C.cairo_pattern_add_color_stop_rgb(p.native(), C.double(offset),
C.double(red), C.double(green), C.double(blue))
status := Status(C.cairo_pattern_status(p.native()))
if status != STATUS_SUCCESS {
return ErrorStatus(status)
}
return nil
}
func (p *Pattern) AddColorStopRGBA(offset, red, green, blue, alpha float64) error {
C.cairo_pattern_add_color_stop_rgba(p.native(), C.double(offset),
C.double(red), C.double(green), C.double(blue), C.double(alpha))
status := Status(C.cairo_pattern_status(p.native()))
if status != STATUS_SUCCESS {
return ErrorStatus(status)
}
return nil
}
func (v *Context) SetSource(p *Pattern) {
C.cairo_set_source(v.native(), p.native())
}
// native returns a pointer to the underlying cairo_pattern_t.
func (v *Pattern) native() *C.cairo_pattern_t {
if v == nil {
return nil
}
return v.pattern
}
// Native returns a pointer to the underlying cairo_pattern_t.
func (v *Pattern) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func marshalPattern(p uintptr) (interface{}, error) {
c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p)))
pattern := (*C.cairo_pattern_t)(unsafe.Pointer(c))
return wrapPattern(pattern), nil
}
func wrapPattern(pattern *C.cairo_pattern_t) *Pattern {
return &Pattern{pattern}
}
// reference is a wrapper around cairo_pattern_reference().
func (v *Pattern) reference() {
v.pattern = C.cairo_pattern_reference(v.native())
}
// destroy is a wrapper around cairo_pattern_destroy().
func (v *Pattern) destroy() {
C.cairo_pattern_destroy(v.native())
}
// Status is a wrapper around cairo_pattern_status().
func (v *Pattern) Status() Status {
c := C.cairo_pattern_status(v.native())
return Status(c)
}

@ -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)
}

@ -0,0 +1,86 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
import "C"
import (
"runtime"
"unsafe"
"github.com/gotk3/gotk3/glib"
)
// Grab() is a wrapper around gdk_device_grab().
func (v *Device) Grab(w *Window, ownership GrabOwnership, owner_events bool, event_mask EventMask, cursor *Cursor, time uint32) GrabStatus {
ret := C.gdk_device_grab(
v.native(),
w.native(),
C.GdkGrabOwnership(ownership),
gbool(owner_events),
C.GdkEventMask(event_mask),
cursor.native(),
C.guint32(time),
)
return GrabStatus(ret)
}
// GetClientPointer() is a wrapper around gdk_device_manager_get_client_pointer().
func (v *DeviceManager) GetClientPointer() (*Device, error) {
c := C.gdk_device_manager_get_client_pointer(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return &Device{obj}, nil
}
// ListDevices() is a wrapper around gdk_device_manager_list_devices().
func (v *DeviceManager) ListDevices(tp DeviceType) *glib.List {
clist := C.gdk_device_manager_list_devices(v.native(), C.GdkDeviceType(tp))
if clist == nil {
return nil
}
glist := glib.WrapList(uintptr(unsafe.Pointer(clist)))
glist.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return &Device{&glib.Object{glib.ToGObject(ptr)}}
})
runtime.SetFinalizer(glist, func(glist *glib.List) {
glist.Free()
})
return glist
}
// Ungrab() is a wrapper around gdk_device_ungrab().
func (v *Device) Ungrab(time uint32) {
C.gdk_device_ungrab(v.native(), C.guint32(time))
}
// GetDeviceManager() is a wrapper around gdk_display_get_device_manager().
func (v *Display) GetDeviceManager() (*DeviceManager, error) {
c := C.gdk_display_get_device_manager(v.native())
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
d := &DeviceManager{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return d, nil
}
// GetScreen() is a wrapper around gdk_display_get_screen().
func (v *Display) GetScreen(screenNum int) (*Screen, error) {
c := C.gdk_display_get_screen(v.native(), C.gint(screenNum))
if c == nil {
return nil, nilPtrErr
}
obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
s := &Screen{obj}
obj.Ref()
runtime.SetFinalizer(obj, (*glib.Object).Unref)
return s, nil
}

@ -0,0 +1,84 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_3_20
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
import "C"
// 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()))
}
// 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)
}
// 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()))
}
// 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)))
}
// 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)))
}
// 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)))
}
// 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()))
}
// GetNumber is a wrapper around gdk_screen_get_number().
func (v *Screen) GetNumber() int {
return int(C.gdk_screen_get_number(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()))
}
// 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)
}
// 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()))
}
// 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()))
}

@ -0,0 +1,61 @@
package gdk
// #cgo pkg-config: gdk-3.0
// #include <gdk/gdk.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
type PixbufFormat struct {
format *C.GdkPixbufFormat
}
// native returns a pointer to the underlying GdkPixbuf.
func (v *PixbufFormat) native() *C.GdkPixbufFormat {
if v == nil {
return nil
}
return v.format
}
// Native returns a pointer to the underlying GdkPixbuf.
func (v *PixbufFormat) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
func (f *PixbufFormat) GetName() (string, error) {
c := C.gdk_pixbuf_format_get_name(f.native())
return C.GoString((*C.char)(c)), nil
}
func (f *PixbufFormat) GetDescription() (string, error) {
c := C.gdk_pixbuf_format_get_description(f.native())
return C.GoString((*C.char)(c)), nil
}
func (f *PixbufFormat) GetLicense() (string, error) {
c := C.gdk_pixbuf_format_get_license(f.native())
return C.GoString((*C.char)(c)), nil
}
func PixbufGetFormats() []*PixbufFormat {
l := (*C.struct__GSList)(C.gdk_pixbuf_get_formats())
formats := glib.WrapSList(uintptr(unsafe.Pointer(l)))
if formats == nil {
return nil // no error. A nil list is considered to be empty.
}
// "The structures themselves are owned by GdkPixbuf". Free the list only.
defer formats.Free()
ret := make([]*PixbufFormat, 0, formats.Length())
formats.Foreach(func(ptr unsafe.Pointer) {
ret = append(ret, &PixbufFormat{(*C.GdkPixbufFormat)(ptr)})
})
return ret
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,121 @@
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
}
// 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()))
}
func toString(c *C.gchar) (string, error) {
if c == nil {
return "", nilPtrErr
}
return C.GoString((*C.char)(c)), nil
}
// 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))
}
// 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,214 @@
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))
}
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()
}

@ -0,0 +1,99 @@
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"
type BindingFlags int
const (
BINDING_DEFAULT BindingFlags = C.G_BINDING_DEFAULT
BINDING_BIDIRECTIONAL BindingFlags = C.G_BINDING_BIDIRECTIONAL
BINDING_SYNC_CREATE = C.G_BINDING_SYNC_CREATE
BINDING_INVERT_BOOLEAN = C.G_BINDING_INVERT_BOOLEAN
)
type Binding struct {
*Object
}
func (v *Binding) native() *C.GBinding {
if v == nil || v.GObject == nil {
return nil
}
return C.toGBinding(unsafe.Pointer(v.GObject))
}
func marshalBinding(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
return &Binding{wrapObject(unsafe.Pointer(c))}, nil
}
// Creates a binding between source property on source and target property on
// target . Whenever the source property is changed the target_property is
// updated using the same value.
func BindProperty(source *Object, sourceProperty string,
target *Object, targetProperty string,
flags BindingFlags) *Binding {
srcStr := (*C.gchar)(C.CString(sourceProperty))
defer C.free(unsafe.Pointer(srcStr))
tgtStr := (*C.gchar)(C.CString(targetProperty))
defer C.free(unsafe.Pointer(tgtStr))
obj := C.g_object_bind_property(
C.gpointer(source.GObject), srcStr,
C.gpointer(target.GObject), tgtStr,
C.GBindingFlags(flags),
)
if obj == nil {
return nil
}
return &Binding{wrapObject(unsafe.Pointer(obj))}
}
// Explicitly releases the binding between the source and the target property
// expressed by Binding
func (v *Binding) Unbind() {
C.g_binding_unbind(v.native())
}
// Retrieves the GObject instance used as the source of the binding
func (v *Binding) GetSource() *Object {
obj := C.g_binding_get_source(v.native())
if obj == nil {
return nil
}
return wrapObject(unsafe.Pointer(obj))
}
// Retrieves the name of the property of “source” used as the source of
// the binding.
func (v *Binding) GetSourceProperty() string {
s := C.g_binding_get_source_property(v.native())
return C.GoString((*C.char)(s))
}
// Retrieves the GObject instance used as the target of the binding.
func (v *Binding) GetTarget() *Object {
obj := C.g_binding_get_target(v.native())
if obj == nil {
return nil
}
return wrapObject(unsafe.Pointer(obj))
}
// Retrieves the name of the property of “target” used as the target of
// the binding.
func (v *Binding) GetTargetProperty() string {
s := C.g_binding_get_target_property(v.native())
return C.GoString((*C.char)(s))
}
// Retrieves the flags passed when constructing the GBinding.
func (v *Binding) GetFlags() BindingFlags {
flags := C.g_binding_get_flags(v.native())
return BindingFlags(flags)
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,224 @@
/*
* 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 GBinding*
toGBinding(void *p)
{
return (G_BINDING(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,58 @@
package glib_test
import (
"runtime"
"testing"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
func init() {
gtk.Init(nil)
}
// TestConnectNotifySignal ensures that property notification signals (those
// whose name begins with "notify::") are queried by the name "notify" (with the
// "::" and the property name omitted). This is because the signal is "notify"
// and the characters after the "::" are not recognized by the signal system.
//
// See
// https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#GObject-notify
// for background, and
// https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-new
// for the specification of valid signal names.
func TestConnectNotifySignal(t *testing.T) {
runtime.LockOSThread()
// Create any GObject that has defined properties.
spacing := 0
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, spacing)
// Connect to a "notify::" signal to listen on property changes.
box.Connect("notify::spacing", func() {
gtk.MainQuit()
})
glib.IdleAdd(func(s string) bool {
t.Log(s)
spacing++
box.SetSpacing(spacing)
return true
}, "IdleAdd executed")
gtk.Main()
}
/*At this moment Visionect specific*/
func TestTimeoutAdd(t *testing.T) {
runtime.LockOSThread()
glib.TimeoutAdd(2500, func(s string) bool {
t.Log(s)
gtk.MainQuit()
return false
}, "TimeoutAdd executed")
gtk.Main()
}

@ -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,285 @@
//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 "gvariant.go.h"
// #include "glib.go.h"
import "C"
import (
"fmt"
"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.
type IVariant interface {
ToGVariant() *C.GVariant
ToVariant() *Variant
}
// A Variant is a representation of GLib's GVariant.
type Variant struct {
GVariant *C.GVariant
}
// ToGVariant exposes the underlying *C.GVariant type for this Variant,
// necessary to implement IVariant.
func (v *Variant) ToGVariant() *C.GVariant {
if v == nil {
return nil
}
return v.native()
}
// ToVariant returns this Variant, necessary to implement IVariant.
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}
}
// VariantFromUnsafePointer returns a Variant from an unsafe pointer.
// XXX: unnecessary footgun?
//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
}
return v.GVariant
}
// Native returns a pointer to the underlying GVariant.
func (v *Variant) Native() uintptr {
return uintptr(unsafe.Pointer(v.native()))
}
// TypeString returns the g variant type string for this variant.
func (v *Variant) TypeString() string {
// the string returned from this belongs to GVariant and must not be freed.
return C.GoString((*C.char)(C.g_variant_get_type_string(v.native())))
}
// IsContainer returns true if the variant is a container and false otherwise.
func (v *Variant) IsContainer() bool {
return gobool(C.g_variant_is_container(v.native()))
}
// IsFloating returns true if the variant has a floating reference count.
// XXX: this isn't useful without ref_sink/take_ref, which are themselves
// perhaps not useful for most Go code that may use variants.
//func (v *Variant) IsFloating() bool {
// return gobool(C.g_variant_is_floating(v.native()))
//}
// GetBoolean returns the bool value of this variant.
func (v *Variant) GetBoolean() bool {
return gobool(C.g_variant_get_boolean(v.native()))
}
// GetString returns the string value of the variant.
func (v *Variant) GetString() string {
var len C.gsize
gc := C.g_variant_get_string(v.native(), &len)
defer C.g_free(C.gpointer(gc))
return C.GoStringN((*C.char)(gc), (C.int)(len))
}
// GetStrv returns a slice of strings from this variant. It wraps
// g_variant_get_strv, but returns copies of the strings instead.
func (v *Variant) GetStrv() []string {
gstrv := C.g_variant_get_strv(v.native(), nil)
// we do not own the memory for these strings, so we must not use strfreev
// but we must free the actual pointer we receive.
c := gstrv
defer C.g_free(C.gpointer(gstrv))
var strs []string
for *c != nil {
strs = append(strs, C.GoString((*C.char)(*c)))
c = C.next_gcharptr(c)
}
return strs
}
// GetInt returns the int64 value of the variant if it is an integer type, and
// an error otherwise. It wraps variouns `g_variant_get_*` functions dealing
// with integers of different sizes.
func (v *Variant) GetInt() (int64, error) {
t := v.Type().String()
var i int64
switch t {
case "y":
i = int64(C.g_variant_get_byte(v.native()))
case "n":
i = int64(C.g_variant_get_int16(v.native()))
case "q":
i = int64(C.g_variant_get_uint16(v.native()))
case "i":
i = int64(C.g_variant_get_int32(v.native()))
case "u":
i = int64(C.g_variant_get_uint32(v.native()))
case "x":
i = int64(C.g_variant_get_int64(v.native()))
case "t":
i = int64(C.g_variant_get_uint64(v.native()))
default:
return 0, fmt.Errorf("variant type %s not an integer type", t)
}
return i, nil
}
// Type returns the VariantType for this variant.
func (v *Variant) Type() *VariantType {
return newVariantType(C.g_variant_get_type(v.native()))
}
// IsType returns true if the variant's type matches t.
func (v *Variant) IsType(t *VariantType) bool {
return gobool(C.g_variant_is_of_type(v.native(), t.native()))
}
// String wraps g_variant_print(). It returns a string understood
// by g_variant_parse().
func (v *Variant) String() string {
gc := C.g_variant_print(v.native(), gbool(false))
defer C.g_free(C.gpointer(gc))
return C.GoString((*C.char)(gc))
}
// AnnotatedString wraps g_variant_print(), but returns a type-annotated
// string.
func (v *Variant) AnnotatedString() string {
gc := C.g_variant_print(v.native(), gbool(true))
defer C.g_free(C.gpointer(gc))
return C.GoString((*C.char)(gc))
}
//void g_variant_unref ()
//GVariant * g_variant_ref ()
//GVariant * g_variant_ref_sink ()
//GVariant * g_variant_take_ref ()
//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 ()
//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,40 @@
// 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
#ifndef __GVARIANT_GO_H__
#define __GVARIANT_GO_H__
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.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,14 @@
// Same copyright and license as the rest of the files in this project
package glib_test
import (
"testing"
)
func Test_AcceleratorParse(t *testing.T) {
/*
testVariant := &Variant{}
t.Log("native: " + testVariant.Native())
*/
}

@ -0,0 +1,53 @@
// 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
*/
// 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,40 @@
// 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"
/*
* 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,53 @@
// 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
*/
// 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,53 @@
// 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
*/
// 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,58 @@
// 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 "gvarianttype.go.h"
import "C"
// A VariantType is a wrapper for the GVariantType, which encodes type
// information for GVariants.
type VariantType struct {
GVariantType *C.GVariantType
}
func (v *VariantType) native() *C.GVariantType {
return v.GVariantType
}
// String returns a copy of this VariantType's type string.
func (v *VariantType) String() string {
ch := C.g_variant_type_dup_string(v.native())
defer C.g_free(C.gpointer(ch))
return C.GoString((*C.char)(ch))
}
func newVariantType(v *C.GVariantType) *VariantType {
return &VariantType{v}
}
// Variant types for comparing between them. Cannot be const because
// they are pointers.
var (
VARIANT_TYPE_BOOLEAN = newVariantType(C._G_VARIANT_TYPE_BOOLEAN)
VARIANT_TYPE_BYTE = newVariantType(C._G_VARIANT_TYPE_BYTE)
VARIANT_TYPE_INT16 = newVariantType(C._G_VARIANT_TYPE_INT16)
VARIANT_TYPE_UINT16 = newVariantType(C._G_VARIANT_TYPE_UINT16)
VARIANT_TYPE_INT32 = newVariantType(C._G_VARIANT_TYPE_INT32)
VARIANT_TYPE_UINT32 = newVariantType(C._G_VARIANT_TYPE_UINT32)
VARIANT_TYPE_INT64 = newVariantType(C._G_VARIANT_TYPE_INT64)
VARIANT_TYPE_UINT64 = newVariantType(C._G_VARIANT_TYPE_UINT64)
VARIANT_TYPE_HANDLE = newVariantType(C._G_VARIANT_TYPE_HANDLE)
VARIANT_TYPE_DOUBLE = newVariantType(C._G_VARIANT_TYPE_DOUBLE)
VARIANT_TYPE_STRING = newVariantType(C._G_VARIANT_TYPE_STRING)
VARIANT_TYPE_ANY = newVariantType(C._G_VARIANT_TYPE_ANY)
VARIANT_TYPE_BASIC = newVariantType(C._G_VARIANT_TYPE_BASIC)
VARIANT_TYPE_TUPLE = newVariantType(C._G_VARIANT_TYPE_TUPLE)
VARIANT_TYPE_UNIT = newVariantType(C._G_VARIANT_TYPE_UNIT)
VARIANT_TYPE_DICTIONARY = newVariantType(C._G_VARIANT_TYPE_DICTIONARY)
VARIANT_TYPE_STRING_ARRAY = newVariantType(C._G_VARIANT_TYPE_STRING_ARRAY)
VARIANT_TYPE_OBJECT_PATH_ARRAY = newVariantType(C._G_VARIANT_TYPE_OBJECT_PATH_ARRAY)
VARIANT_TYPE_BYTESTRING = newVariantType(C._G_VARIANT_TYPE_BYTESTRING)
VARIANT_TYPE_BYTESTRING_ARRAY = newVariantType(C._G_VARIANT_TYPE_BYTESTRING_ARRAY)
VARIANT_TYPE_VARDICT = newVariantType(C._G_VARIANT_TYPE_VARDICT)
)

@ -0,0 +1,37 @@
// 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
#ifndef __GVARIANTTYPE_GO_H__
#define __GVARIANTTYPE_GO_H__
const GVariantType* _G_VARIANT_TYPE_BOOLEAN = G_VARIANT_TYPE_BOOLEAN;
const GVariantType* _G_VARIANT_TYPE_BYTE = G_VARIANT_TYPE_BYTE;
const GVariantType* _G_VARIANT_TYPE_INT16 = G_VARIANT_TYPE_INT16;
const GVariantType* _G_VARIANT_TYPE_UINT16 = G_VARIANT_TYPE_UINT16;
const GVariantType* _G_VARIANT_TYPE_INT32 = G_VARIANT_TYPE_INT32;
const GVariantType* _G_VARIANT_TYPE_UINT32 = G_VARIANT_TYPE_UINT32;
const GVariantType* _G_VARIANT_TYPE_INT64 = G_VARIANT_TYPE_INT64;
const GVariantType* _G_VARIANT_TYPE_UINT64 = G_VARIANT_TYPE_UINT64;
const GVariantType* _G_VARIANT_TYPE_HANDLE = G_VARIANT_TYPE_HANDLE;
const GVariantType* _G_VARIANT_TYPE_DOUBLE = G_VARIANT_TYPE_DOUBLE;
const GVariantType* _G_VARIANT_TYPE_STRING = G_VARIANT_TYPE_STRING;
const GVariantType* _G_VARIANT_TYPE_OBJECT_PATH = G_VARIANT_TYPE_OBJECT_PATH;
const GVariantType* _G_VARIANT_TYPE_SIGNATURE = G_VARIANT_TYPE_SIGNATURE;
const GVariantType* _G_VARIANT_TYPE_VARIANT = G_VARIANT_TYPE_VARIANT;
const GVariantType* _G_VARIANT_TYPE_ANY = G_VARIANT_TYPE_ANY;
const GVariantType* _G_VARIANT_TYPE_BASIC = G_VARIANT_TYPE_BASIC;
const GVariantType* _G_VARIANT_TYPE_MAYBE = G_VARIANT_TYPE_MAYBE;
const GVariantType* _G_VARIANT_TYPE_ARRAY = G_VARIANT_TYPE_ARRAY;
const GVariantType* _G_VARIANT_TYPE_TUPLE = G_VARIANT_TYPE_TUPLE;
const GVariantType* _G_VARIANT_TYPE_UNIT = G_VARIANT_TYPE_UNIT;
const GVariantType* _G_VARIANT_TYPE_DICT_ENTRY = G_VARIANT_TYPE_DICT_ENTRY;
const GVariantType* _G_VARIANT_TYPE_DICTIONARY = G_VARIANT_TYPE_DICTIONARY;
const GVariantType* _G_VARIANT_TYPE_STRING_ARRAY = G_VARIANT_TYPE_STRING_ARRAY;
const GVariantType* _G_VARIANT_TYPE_OBJECT_PATH_ARRAY = G_VARIANT_TYPE_OBJECT_PATH_ARRAY;
const GVariantType* _G_VARIANT_TYPE_BYTESTRING = G_VARIANT_TYPE_BYTESTRING;
const GVariantType* _G_VARIANT_TYPE_BYTESTRING_ARRAY = G_VARIANT_TYPE_BYTESTRING_ARRAY;
const GVariantType* _G_VARIANT_TYPE_VARDICT = G_VARIANT_TYPE_VARDICT;
#endif

@ -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,76 @@
package glib
import (
"fmt"
"testing"
"unsafe"
)
func TestList_Basics(t *testing.T) {
list := (&List{}).Append(0).Append(1).Append(2)
if list.Length() != 3 {
t.Errorf("Length of list with 3 appended elements must be 3. (Got %v).", list.Length())
}
list = (&List{}).Prepend(0).Prepend(1).Prepend(2)
if list.Length() != 3 {
t.Errorf("Length of list with 3 prepended elements must be 3. (Got %v).", list.Length())
}
list = (&List{}).Insert(0, 0).Insert(1, 0).Insert(2, 0)
if list.Length() != 3 {
t.Errorf("Length of list with 3 inserted elements must be 3. (Got %v).", list.Length())
}
}
func TestList_DataWrapper(t *testing.T) {
list := (&List{}).Append(0).Append(1).Append(2)
list.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return fmt.Sprintf("Value %v", uintptr(ptr))
})
i := 0
for l := list; l != nil; l = l.Next() {
expect := fmt.Sprintf("Value %v", i)
i++
actual, ok := l.Data().(string)
if !ok {
t.Error("DataWrapper must have returned a string!")
}
if actual != expect {
t.Errorf("DataWrapper returned unexpected result. Expected '%v', got '%v'.", expect, actual)
}
}
}
func TestList_Foreach(t *testing.T) {
list := (&List{}).Append(0).Append(1).Append(2)
list.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return int(uintptr(ptr) + 1)
})
sum := 0
list.Foreach(func(item interface{}) {
sum += item.(int)
})
if sum != 6 {
t.Errorf("Foreach resulted into wrong sum. Got %v, expected %v.", sum, 6)
}
}
func TestList_Nth(t *testing.T) {
list := (&List{}).Append(0).Append(1).Append(2)
list.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return int(uintptr(ptr) + 1)
})
for i := uint(0); i < 3; i++ {
nth := list.Nth(i).Data().(int)
nthData := list.NthData(i).(int)
if nth != nthData {
t.Errorf("%v's element didn't match. Nth->Data returned %v; NthData returned %v.", i, nth, nthData)
}
}
}

@ -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,283 @@
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)))
}
func (v *Settings) GetValue(name string) *Variant {
cstr := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(cstr))
return newVariant(C.g_settings_get_value(v.native(), cstr))
}
// 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,110 @@
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. A SList must be manually freed
// by either calling Free() or FreeFull()
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 {
if obj == nil {
return nil
}
//NOTE a list should be freed by calling either
//g_slist_free() or g_slist_free_full(). However, it's not possible to use a
//finalizer for this.
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
}
return wrapSList(ret)
}
// Length is a wrapper around g_slist_length().
func (v *SList) Length() uint {
return uint(C.g_slist_length(v.native()))
}
// Next is a wrapper around the next struct field
func (v *SList) Next() *SList {
n := v.native()
if n == nil {
return nil
}
return wrapSList(n.next)
}
// Foreach acts the same as g_slist_foreach().
// No user_data arguement is implemented because of Go clojure capabilities.
func (v *SList) Foreach(fn func(ptr unsafe.Pointer)) {
for l := v; l != nil; l = l.Next() {
fn(unsafe.Pointer(l.native().data))
}
}
// Free is a wrapper around g_slist_free().
func (v *SList) Free() {
C.g_slist_free(v.native())
v.list = nil
}
// FreeFull is a wrapper around g_slist_free_full().
func (v *SList) FreeFull() {
//TODO implement GDestroyNotify callback
C.g_slist_free_full(v.native(), nil)
v.list = nil
}
// 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_1 ()
// 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 ()
// GSList * g_slist_last ()
// 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,324 @@
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))
}
// GetLogo is a wrapper around gtk_about_dialog_get_logo().
func (v *AboutDialog) GetLogo() (*gdk.Pixbuf, error) {
c := C.gtk_about_dialog_get_logo(v.native())
if c == nil {
return nil, nilPtrErr
}
p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))}
return p, nil
}
// 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,34 @@
// Same copyright and license as the rest of the files in this project
package gtk
import "testing"
func Test_AccelGroup_Locking(t *testing.T) {
ag, _ := AccelGroupNew()
if ag.IsLocked() {
t.Error("A newly created AccelGroup should not be locked")
}
ag.Lock()
if !ag.IsLocked() {
t.Error("A locked AccelGroup should report being locked")
}
ag.Unlock()
if ag.IsLocked() {
t.Error("An unlocked AccelGroup should report being unlocked")
}
}
func Test_AcceleratorParse(t *testing.T) {
l, r := AcceleratorParse("<Shift><Alt>F1")
if l != 65470 {
t.Errorf("Expected parsed key to equal %d but was %d", 65470, l)
}
if r != 9 {
t.Errorf("Expected parsed mods to equal %d but was %d", 9, r)
}
}

@ -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,869 @@
/*
* 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.
*/
#pragma once
#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 GtkOverlay *
toGtkOverlay(void *p)
{
return (GTK_OVERLAY(p));
}
static GtkPageSetup *
toGtkPageSetup(void *p)
{
return (GTK_PAGE_SETUP(p));
}
static GtkPaned *
toGtkPaned(void *p)
{
return (GTK_PANED(p));
}
static GtkPrintContext *
toGtkPrintContext(void *p)
{
return (GTK_PRINT_CONTEXT(p));
}
static GtkPrintOperation *
toGtkPrintOperation(void *p)
{
return (GTK_PRINT_OPERATION(p));
}
static GtkPrintOperationPreview *
toGtkPrintOperationPreview(void *p)
{
return (GTK_PRINT_OPERATION_PREVIEW(p));
}
static GtkPrintSettings *
toGtkPrintSettings(void *p)
{
return (GTK_PRINT_SETTINGS(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 GtkTreeModelFilter *
toGtkTreeModelFilter(void *p)
{
return (GTK_TREE_MODEL_FILTER(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);
}
extern void goPrintSettings (gchar *key,
gchar *value,
gpointer user_data);
static inline void _gtk_print_settings_foreach(GtkPrintSettings *ps, gpointer user_data) {
gtk_print_settings_foreach(ps, (GtkPrintSettingsFunc)(goPrintSettings), user_data);
}
extern void goPageSetupDone (GtkPageSetup *setup,
gpointer data);
static inline void _gtk_print_run_page_setup_dialog_async(GtkWindow *parent, GtkPageSetup *setup,
GtkPrintSettings *settings, gpointer data) {
gtk_print_run_page_setup_dialog_async(parent, setup, settings,
(GtkPageSetupDoneFunc)(goPageSetupDone), data);
}

@ -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,35 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include <stdlib.h>
import "C"
// GetFocusOnClick() is a wrapper around gtk_button_get_focus_on_click().
func (v *Button) GetFocusOnClick() bool {
c := C.gtk_button_get_focus_on_click(v.native())
return gobool(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()))
}
// 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))
}
// 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))
}
// SetFocusOnClick() is a wrapper around gtk_button_set_focus_on_click().
func (v *Button) SetFocusOnClick(focusOnClick bool) {
C.gtk_button_set_focus_on_click(v.native(), gbool(focusOnClick))
}

@ -0,0 +1,44 @@
//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_3_20
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include <stdlib.h>
import "C"
import (
"unsafe"
)
// PopupAtMouse() is a wrapper for gtk_menu_popup(), without the option for a custom positioning function.
func (v *Menu) PopupAtMouseCursor(parentMenuShell IMenu, parentMenuItem IMenuItem, button int, activateTime uint32) {
wshell := nullableWidget(parentMenuShell)
witem := nullableWidget(parentMenuItem)
C.gtk_menu_popup(v.native(),
wshell,
witem,
nil,
nil,
C.guint(button),
C.guint32(activateTime))
}
func (v *SizeGroup) GetIgnoreHidden() bool {
c := C.gtk_size_group_get_ignore_hidden(v.native())
return gobool(c)
}
// 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))
}
func (v *SizeGroup) SetIgnoreHidden(ignoreHidden bool) {
C.gtk_size_group_set_ignore_hidden(v.native(), gbool(ignoreHidden))
}

@ -0,0 +1,77 @@
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)
}
//export goPageSetupDone
func goPageSetupDone(setup *C.GtkPageSetup,
data C.gpointer) {
id := int(uintptr(data))
pageSetupDoneCallbackRegistry.Lock()
r := pageSetupDoneCallbackRegistry.m[id]
delete(pageSetupDoneCallbackRegistry.m, id)
pageSetupDoneCallbackRegistry.Unlock()
obj := wrapObject(unsafe.Pointer(setup))
r.fn(wrapPageSetup(obj), r.data)
}
//export goPrintSettings
func goPrintSettings(key *C.gchar,
value *C.gchar,
userData C.gpointer) {
id := int(uintptr(userData))
printSettingsCallbackRegistry.Lock()
r := printSettingsCallbackRegistry.m[id]
// TODO: figure out a way to determine when we can clean up
//delete(printSettingsCallbackRegistry.m, id)
printSettingsCallbackRegistry.Unlock()
r.fn(C.GoString((*C.char)(key)), C.GoString((*C.char)(value)), r.userData)
}

@ -0,0 +1,707 @@
// 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
}
/*
* GtkGrid
*/
// RemoveRow() is a wrapper around gtk_grid_remove_row().
func (v *Grid) RemoveRow(position int) {
C.gtk_grid_remove_row(v.native(), C.gint(position))
}
// RemoveColumn() is a wrapper around gtk_grid_remove_column().
func (v *Grid) RemoveColumn(position int) {
C.gtk_grid_remove_column(v.native(), C.gint(position))
}
/*
* 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) SetAdjustment(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,274 @@
// +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 <gtk/gtk.h>
// #include "gtk_since_3_12.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Objects/Interfaces
{glib.Type(C.gtk_flow_box_get_type()), marshalFlowBox},
{glib.Type(C.gtk_flow_box_child_get_type()), marshalFlowBoxChild},
}
glib.RegisterGValueMarshalers(tm)
WrapMap["GtkFlowBox"] = wrapFlowBox
WrapMap["GtkFlowBoxChild"] = wrapFlowBoxChild
}
// SetPopover is a wrapper around gtk_menu_button_set_popover().
func (v *MenuButton) SetPopover(popover *Popover) {
C.gtk_menu_button_set_popover(v.native(), popover.toWidget())
}
// GetPopover is a wrapper around gtk_menu_button_get_popover().
func (v *MenuButton) GetPopover() *Popover {
c := C.gtk_menu_button_get_popover(v.native())
if c == nil {
return nil
}
return wrapPopover(wrapObject(unsafe.Pointer(c)))
}
/*
* FlowBox
*/
type FlowBox struct {
Container
}
func (fb *FlowBox) native() *C.GtkFlowBox {
if fb == nil || fb.GObject == nil {
return nil
}
p := unsafe.Pointer(fb.GObject)
return C.toGtkFlowBox(p)
}
func marshalFlowBox(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapFlowBox(obj), nil
}
func wrapFlowBox(obj *glib.Object) *FlowBox {
return &FlowBox{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
// FlowBoxNew is a wrapper around gtk_flow_box_new()
func FlowBoxNew() (*FlowBox, error) {
c := C.gtk_flow_box_new()
if c == nil {
return nil, nilPtrErr
}
return wrapFlowBox(wrapObject(unsafe.Pointer(c))), nil
}
// Insert is a wrapper around gtk_flow_box_insert()
func (fb *FlowBox) Insert(widget IWidget, position int) {
C.gtk_flow_box_insert(fb.native(), widget.toWidget(), C.gint(position))
}
// GetChildAtIndex is a wrapper around gtk_flow_box_get_child_at_index()
func (fb *FlowBox) GetChildAtIndex(idx int) *FlowBoxChild {
c := C.gtk_flow_box_get_child_at_index(fb.native(), C.gint(idx))
if c == nil {
return nil
}
return wrapFlowBoxChild(wrapObject(unsafe.Pointer(c)))
}
// TODO 3.22.6 gtk_flow_box_get_child_at_pos()
// SetHAdjustment is a wrapper around gtk_flow_box_set_hadjustment()
func (fb *FlowBox) SetHAdjustment(adjustment *Adjustment) {
C.gtk_flow_box_set_hadjustment(fb.native(), adjustment.native())
}
// SetVAdjustment is a wrapper around gtk_flow_box_set_vadjustment()
func (fb *FlowBox) SetVAdjustment(adjustment *Adjustment) {
C.gtk_flow_box_set_vadjustment(fb.native(), adjustment.native())
}
// SetHomogeneous is a wrapper around gtk_flow_box_set_homogeneous()
func (fb *FlowBox) SetHomogeneous(homogeneous bool) {
C.gtk_flow_box_set_homogeneous(fb.native(), gbool(homogeneous))
}
// GetHomogeneous is a wrapper around gtk_flow_box_get_homogeneous()
func (fb *FlowBox) GetHomogeneous() bool {
c := C.gtk_flow_box_get_homogeneous(fb.native())
return gobool(c)
}
// SetRowSpacing is a wrapper around gtk_flow_box_set_row_spacing()
func (fb *FlowBox) SetRowSpacing(spacing uint) {
C.gtk_flow_box_set_row_spacing(fb.native(), C.guint(spacing))
}
// GetRowSpacing is a wrapper around gtk_flow_box_get_row_spacing()
func (fb *FlowBox) GetRowSpacing() uint {
c := C.gtk_flow_box_get_row_spacing(fb.native())
return uint(c)
}
// SetColumnSpacing is a wrapper around gtk_flow_box_set_column_spacing()
func (fb *FlowBox) SetColumnSpacing(spacing uint) {
C.gtk_flow_box_set_column_spacing(fb.native(), C.guint(spacing))
}
// GetColumnSpacing is a wrapper around gtk_flow_box_get_column_spacing()
func (fb *FlowBox) GetColumnSpacing() uint {
c := C.gtk_flow_box_get_column_spacing(fb.native())
return uint(c)
}
// SetMinChildrenPerLine is a wrapper around gtk_flow_box_set_min_children_per_line()
func (fb *FlowBox) SetMinChildrenPerLine(n_children uint) {
C.gtk_flow_box_set_min_children_per_line(fb.native(), C.guint(n_children))
}
// GetMinChildrenPerLine is a wrapper around gtk_flow_box_get_min_children_per_line()
func (fb *FlowBox) GetMinChildrenPerLine() uint {
c := C.gtk_flow_box_get_min_children_per_line(fb.native())
return uint(c)
}
// SetMaxChildrenPerLine is a wrapper around gtk_flow_box_set_max_children_per_line()
func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) {
C.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children))
}
// GetMaxChildrenPerLine is a wrapper around gtk_flow_box_get_max_children_per_line()
func (fb *FlowBox) GetMaxChildrenPerLine() uint {
c := C.gtk_flow_box_get_max_children_per_line(fb.native())
return uint(c)
}
// SetActivateOnSingleClick is a wrapper around gtk_flow_box_set_activate_on_single_click()
func (fb *FlowBox) SetActivateOnSingleClick(single bool) {
C.gtk_flow_box_set_activate_on_single_click(fb.native(), gbool(single))
}
// GetActivateOnSingleClick gtk_flow_box_get_activate_on_single_click()
func (fb *FlowBox) GetActivateOnSingleClick() bool {
c := C.gtk_flow_box_get_activate_on_single_click(fb.native())
return gobool(c)
}
// TODO: gtk_flow_box_selected_foreach()
// GetSelectedChildren is a wrapper around gtk_flow_box_get_selected_children()
func (fb *FlowBox) GetSelectedChildren() (rv []*FlowBoxChild) {
c := C.gtk_flow_box_get_selected_children(fb.native())
if c == nil {
return
}
list := glib.WrapList(uintptr(unsafe.Pointer(c)))
for l := list; l != nil; l = l.Next() {
o := wrapFlowBoxChild(wrapObject(l.Data().(unsafe.Pointer)))
rv = append(rv, o)
}
// We got a transfer container, so we must free the list.
list.Free()
return
}
// SelectChild is a wrapper around gtk_flow_box_select_child()
func (fb *FlowBox) SelectChild(child *FlowBoxChild) {
C.gtk_flow_box_select_child(fb.native(), child.native())
}
// UnselectChild is a wrapper around gtk_flow_box_unselect_child()
func (fb *FlowBox) UnselectChild(child *FlowBoxChild) {
C.gtk_flow_box_unselect_child(fb.native(), child.native())
}
// SelectAll is a wrapper around gtk_flow_box_select_all()
func (fb *FlowBox) SelectAll() {
C.gtk_flow_box_select_all(fb.native())
}
// UnselectAll is a wrapper around gtk_flow_box_unselect_all()
func (fb *FlowBox) UnselectAll() {
C.gtk_flow_box_unselect_all(fb.native())
}
// SetSelectionMode is a wrapper around gtk_flow_box_set_selection_mode()
func (fb *FlowBox) SetSelectionMode(mode SelectionMode) {
C.gtk_flow_box_set_selection_mode(fb.native(), C.GtkSelectionMode(mode))
}
// GetSelectionMode is a wrapper around gtk_flow_box_get_selection_mode()
func (fb *FlowBox) GetSelectionMode() SelectionMode {
c := C.gtk_flow_box_get_selection_mode(fb.native())
return SelectionMode(c)
}
// TODO gtk_flow_box_set_filter_func()
// TODO gtk_flow_box_invalidate_filter()
// TODO gtk_flow_box_set_sort_func()
// TODO gtk_flow_box_invalidate_sort()
// TODO 3.18 gtk_flow_box_bind_model()
/*
* FlowBoxChild
*/
type FlowBoxChild struct {
Bin
}
func (fbc *FlowBoxChild) native() *C.GtkFlowBoxChild {
if fbc == nil || fbc.GObject == nil {
return nil
}
p := unsafe.Pointer(fbc.GObject)
return C.toGtkFlowBoxChild(p)
}
func marshalFlowBoxChild(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapFlowBoxChild(obj), nil
}
func wrapFlowBoxChild(obj *glib.Object) *FlowBoxChild {
return &FlowBoxChild{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// FlowBoxChildNew is a wrapper around gtk_flow_box_child_new()
func FlowBoxChildNew() (*FlowBoxChild, error) {
c := C.gtk_flow_box_child_new()
if c == nil {
return nil, nilPtrErr
}
return wrapFlowBoxChild(wrapObject(unsafe.Pointer(c))), nil
}
// GetIndex is a wrapper around gtk_flow_box_child_get_index()
func (fbc *FlowBoxChild) GetIndex() int {
c := C.gtk_flow_box_child_get_index(fbc.native())
return int(c)
}
// IsSelected is a wrapper around gtk_flow_box_child_is_selected()
func (fbc *FlowBoxChild) IsSelected() bool {
c := C.gtk_flow_box_child_is_selected(fbc.native())
return gobool(c)
}
// Changed is a wrapper around gtk_flow_box_child_changed()
func (fbc *FlowBoxChild) Changed() {
C.gtk_flow_box_child_changed(fbc.native())
}

@ -0,0 +1,29 @@
/*
* 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 GtkFlowBox *
toGtkFlowBox(void *p)
{
return (GTK_FLOW_BOX(p));
}
static GtkFlowBoxChild *
toGtkFlowBoxChild(void *p)
{
return (GTK_FLOW_BOX_CHILD(p));
}

@ -0,0 +1,121 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14
// See: https://developer.gnome.org/gtk3/3.16/api-index-3-16.html
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include "gtk_since_3_16.go.h"
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/glib"
)
func init() {
tm := []glib.TypeMarshaler{
// Objects/Interfaces
{glib.Type(C.gtk_stack_sidebar_get_type()), marshalStackSidebar},
}
glib.RegisterGValueMarshalers(tm)
//Contribute to casting
for k, v := range map[string]WrapFn{
"GtkStackSidebar": wrapStackSidebar,
} {
WrapMap[k] = v
}
}
// SetOverlayScrolling is a wrapper around gtk_scrolled_window_set_overlay_scrolling().
func (v *ScrolledWindow) SetOverlayScrolling(scrolling bool) {
C.gtk_scrolled_window_set_overlay_scrolling(v.native(), gbool(scrolling))
}
// GetOverlayScrolling is a wrapper around gtk_scrolled_window_get_overlay_scrolling().
func (v *ScrolledWindow) GetOverlayScrolling() bool {
return gobool(C.gtk_scrolled_window_get_overlay_scrolling(v.native()))
}
// SetWideHandle is a wrapper around gtk_paned_set_wide_handle().
func (v *Paned) SetWideHandle(wide bool) {
C.gtk_paned_set_wide_handle(v.native(), gbool(wide))
}
// GetWideHandle is a wrapper around gtk_paned_get_wide_handle().
func (v *Paned) GetWideHandle() bool {
return gobool(C.gtk_paned_get_wide_handle(v.native()))
}
// GetXAlign is a wrapper around gtk_label_get_xalign().
func (v *Label) GetXAlign() float64 {
c := C.gtk_label_get_xalign(v.native())
return float64(c)
}
// GetYAlign is a wrapper around gtk_label_get_yalign().
func (v *Label) GetYAlign() float64 {
c := C.gtk_label_get_yalign(v.native())
return float64(c)
}
// SetXAlign is a wrapper around gtk_label_set_xalign().
func (v *Label) SetXAlign(n float64) {
C.gtk_label_set_xalign(v.native(), C.gfloat(n))
}
// SetYAlign is a wrapper around gtk_label_set_yalign().
func (v *Label) SetYAlign(n float64) {
C.gtk_label_set_yalign(v.native(), C.gfloat(n))
}
/*
* GtkStackSidebar
*/
// StackSidebar is a representation of GTK's GtkStackSidebar.
type StackSidebar struct {
Bin
}
// native returns a pointer to the underlying GtkStack.
func (v *StackSidebar) native() *C.GtkStackSidebar {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkStackSidebar(p)
}
func marshalStackSidebar(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := wrapObject(unsafe.Pointer(c))
return wrapStackSidebar(obj), nil
}
func wrapStackSidebar(obj *glib.Object) *StackSidebar {
return &StackSidebar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
}
// StackSidebarNew is a wrapper around gtk_stack_sidebar_new().
func StackSidebarNew() (*StackSidebar, error) {
c := C.gtk_stack_sidebar_new()
if c == nil {
return nil, nilPtrErr
}
return wrapStackSidebar(wrapObject(unsafe.Pointer(c))), nil
}
func (v *StackSidebar) SetStack(stack *Stack) {
C.gtk_stack_sidebar_set_stack(v.native(), stack.native())
}
func (v *StackSidebar) GetStack() *Stack {
c := C.gtk_stack_sidebar_get_stack(v.native())
if c == nil {
return nil
}
return wrapStack(wrapObject(unsafe.Pointer(c)))
}

@ -0,0 +1,23 @@
/*
* 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 GtkStackSidebar *
toGtkStackSidebar(void *p)
{
return (GTK_STACK_SIDEBAR(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
// For gtk_overlay_reorder_overlay():
// See: https://git.gnome.org/browse/gtk+/tree/gtk/gtkoverlay.h?h=gtk-3-18
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
import "C"
// ReorderOverlay() is a wrapper around gtk_overlay_reorder_overlay().
func (v *Overlay) ReorderOverlay(child IWidget, position int) {
C.gtk_overlay_reorder_overlay(v.native(), child.toWidget(), C.gint(position))
}
// GetOverlayPassThrough() is a wrapper around
// gtk_overlay_get_overlay_pass_through().
func (v *Overlay) GetOverlayPassThrough(widget IWidget) bool {
c := C.gtk_overlay_get_overlay_pass_through(v.native(), widget.toWidget())
return gobool(c)
}
// SetOverlayPassThrough() is a wrapper around
// gtk_overlay_set_overlay_pass_through().
func (v *Overlay) SetOverlayPassThrough(widget IWidget, passThrough bool) {
C.gtk_overlay_set_overlay_pass_through(v.native(), widget.toWidget(), gbool(passThrough))
}

@ -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,739 @@
/*
* 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 gtk
import (
"fmt"
"log"
"testing"
"time"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
)
func init() {
Init(nil)
}
// TestBoolConvs tests the conversion between Go bools and gboolean
// types.
func TestBoolConvs(t *testing.T) {
if err := testBoolConvs(); err != nil {
t.Error(err)
}
}
// TestBox tests creating and adding widgets to a Box
func TestBox(t *testing.T) {
vbox, err := BoxNew(ORIENTATION_VERTICAL, 0)
if err != nil {
t.Error("Unable to create box")
}
vbox.Set("homogeneous", true)
if vbox.GetHomogeneous() != true {
t.Error("Could not set or get Box homogeneous property")
}
vbox.SetHomogeneous(false)
if vbox.GetHomogeneous() != false {
t.Error("Could not set or get Box homogeneous property")
}
vbox.Set("spacing", 1)
if vbox.GetSpacing() != 1 {
t.Error("Could not set or get Box spacing")
}
vbox.SetSpacing(2)
if vbox.GetSpacing() != 2 {
t.Error("Could not set or get Box spacing")
}
// add a child to start and end
start, err := LabelNew("Start")
if err != nil {
t.Error("Unable to create label")
}
end, err := LabelNew("End")
if err != nil {
t.Error("Unable to create label")
}
vbox.PackStart(start, true, true, 3)
vbox.PackEnd(end, true, true, 3)
}
func TestTextBuffer_WhenSetText_ExpectGetTextReturnsSame(t *testing.T) {
buffer, err := TextBufferNew(nil)
if err != nil {
t.Error("Unable to create text buffer")
}
expected := "Hello, World!"
buffer.SetText(expected)
start, end := buffer.GetBounds()
actual, err := buffer.GetText(start, end, true)
if err != nil {
t.Error("Unable to get text from buffer")
}
if actual != expected {
t.Errorf("Expected '%s'; Got '%s'", expected, actual)
}
}
func testTextViewEditable(set bool) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := set
tv.SetEditable(exp)
act := tv.GetEditable()
if exp != act {
return fmt.Errorf("Expected GetEditable(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetEditableFalse_ExpectGetEditableReturnsFalse(t *testing.T) {
if err := testTextViewEditable(false); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetEditableTrue_ExpectGetEditableReturnsTrue(t *testing.T) {
if err := testTextViewEditable(true); err != nil {
t.Error(err)
}
}
func testTextViewWrapMode(set WrapMode) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := set
tv.SetWrapMode(set)
act := tv.GetWrapMode()
if act != exp {
return fmt.Errorf("Expected GetWrapMode(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetWrapModeNone_ExpectGetWrapModeReturnsNone(t *testing.T) {
if err := testTextViewWrapMode(WRAP_NONE); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetWrapModeWord_ExpectGetWrapModeReturnsWord(t *testing.T) {
if err := testTextViewWrapMode(WRAP_WORD); err != nil {
t.Error(err)
}
}
func testTextViewCursorVisible(set bool) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := set
tv.SetCursorVisible(set)
act := tv.GetCursorVisible()
if act != exp {
return fmt.Errorf("Expected GetCursorVisible(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetCursorVisibleFalse_ExpectGetCursorVisibleReturnsFalse(t *testing.T) {
if err := testTextViewCursorVisible(false); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetCursorVisibleTrue_ExpectGetCursorVisibleReturnsTrue(t *testing.T) {
if err := testTextViewCursorVisible(true); err != nil {
t.Error(err)
}
}
func testTextViewOverwrite(set bool) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := set
tv.SetOverwrite(set)
act := tv.GetOverwrite()
if act != exp {
return fmt.Errorf("Expected GetOverwrite(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetOverwriteFalse_ExpectGetOverwriteReturnsFalse(t *testing.T) {
if err := testTextViewOverwrite(false); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetOverwriteTrue_ExpectGetOverwriteReturnsTrue(t *testing.T) {
if err := testTextViewOverwrite(true); err != nil {
t.Error(err)
}
}
func testTextViewJustification(justify Justification) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := justify
tv.SetJustification(justify)
act := tv.GetJustification()
if act != exp {
return fmt.Errorf("Expected GetJustification(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetJustificationLeft_ExpectGetJustificationReturnsLeft(t *testing.T) {
if err := testTextViewJustification(JUSTIFY_LEFT); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetJustificationRight_ExpectGetJustificationReturnsRight(t *testing.T) {
if err := testTextViewJustification(JUSTIFY_RIGHT); err != nil {
t.Error(err)
}
}
func testTextViewAcceptsTab(set bool) error {
tv, err := TextViewNew()
if err != nil {
return err
}
exp := set
tv.SetAcceptsTab(set)
if act := tv.GetAcceptsTab(); act != exp {
return fmt.Errorf("Expected GetAcceptsTab(): %v; Got: %v", exp, act)
}
return nil
}
func TestTextView_WhenSetAcceptsTabFalse_ExpectGetAcceptsTabReturnsFalse(t *testing.T) {
if err := testTextViewAcceptsTab(false); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetAcceptsTabTrue_ExpectGetAcceptsTabReturnsTrue(t *testing.T) {
if err := testTextViewAcceptsTab(true); err != nil {
t.Error(err)
}
}
func testIntProperty(val int, set func(int), get func() int) error {
set(val)
if exp, act := val, get(); act != exp {
return fmt.Errorf("Expected: %d; got: %d", exp, act)
}
return nil
}
func testTextViewPixelsAboveLines(px int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(px, (*tv).SetPixelsAboveLines, (*tv).GetPixelsAboveLines)
}
func TestTextView_WhenSetPixelsAboveLines10_ExpectGetPixelsAboveLinesReturns10(t *testing.T) {
if err := testTextViewPixelsAboveLines(10); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetPixelsAboveLines11_ExpectGetPixelsAboveLinesReturns11(t *testing.T) {
if err := testTextViewPixelsAboveLines(11); err != nil {
t.Error(err)
}
}
func testTextViewPixelsBelowLines(px int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(px, (*tv).SetPixelsBelowLines, (*tv).GetPixelsBelowLines)
}
func TestTextView_WhenSetPixelsBelowLines10_ExpectGetPixelsAboveLinesReturns10(t *testing.T) {
if err := testTextViewPixelsBelowLines(10); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetPixelsBelowLines11_ExpectGetPixelsBelowLinesReturns11(t *testing.T) {
if err := testTextViewPixelsBelowLines(11); err != nil {
t.Error(err)
}
}
func testTextViewPixelsInsideWrap(px int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(px, (*tv).SetPixelsInsideWrap, (*tv).GetPixelsInsideWrap)
}
func TestTextView_WhenSetPixelsInsideWrap10_ExpectGetPixelsInsideWrapReturns11(t *testing.T) {
if err := testTextViewPixelsInsideWrap(10); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetPixelsInsideWrap11_ExpectGetPixelsInsideWrapReturns11(t *testing.T) {
if err := testTextViewPixelsInsideWrap(11); err != nil {
t.Error(err)
}
}
func testTextViewLeftMargin(margin int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(margin, (*tv).SetLeftMargin, (*tv).GetLeftMargin)
}
func TestTextView_WhenSetLeftMargin11_ExpectGetLeftMarginReturns11(t *testing.T) {
if err := testTextViewLeftMargin(11); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetLeftMargin10_ExpectGetLeftMarginReturns10(t *testing.T) {
if err := testTextViewLeftMargin(10); err != nil {
t.Error(err)
}
}
func testTextViewRightMargin(margin int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(margin, (*tv).SetRightMargin, (*tv).GetRightMargin)
}
func TestTextView_WhenSetRightMargin10_ExpectGetRightMarginReturns10(t *testing.T) {
if err := testTextViewRightMargin(10); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetRightMargin11_ExpectGetRightMarginReturns11(t *testing.T) {
if err := testTextViewRightMargin(11); err != nil {
t.Error(err)
}
}
func testTextViewIndent(indent int) error {
tv, err := TextViewNew()
if err != nil {
return err
}
return testIntProperty(indent, (*tv).SetIndent, (*tv).GetIndent)
}
func TestTextView_WhenSetIndent10_ExpectGetIndentReturns10(t *testing.T) {
if err := testTextViewIndent(10); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetIndent11_ExpectGetIndentReturns11(t *testing.T) {
if err := testTextViewIndent(11); err != nil {
t.Error(err)
}
}
func testTextViewInputHints(hint InputHints) error {
tv, err := TextViewNew()
if err != nil {
return err
}
tv.SetInputHints(hint)
if exp, act := hint, tv.GetInputHints(); act != exp {
return fmt.Errorf("Expected %v; Got %v", exp, act)
}
return nil
}
func TestTextView_WhenSetInputHintsNone_ExpectGetInputHintsReturnsNone(t *testing.T) {
if err := testTextViewInputHints(INPUT_HINT_NONE); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetInputHintsSpellCheck_ExpectGetInputHintsReturnsSpellCheck(t *testing.T) {
if err := testTextViewInputHints(INPUT_HINT_SPELLCHECK); err != nil {
t.Error(err)
}
}
func testTextViewInputPurpose(purpose InputPurpose) error {
tv, err := TextViewNew()
if err != nil {
return err
}
tv.SetInputPurpose(purpose)
if exp, act := purpose, tv.GetInputPurpose(); act != exp {
return fmt.Errorf("Expected %v; Got %v", exp, act)
}
return nil
}
func TestTextView_WhenSetInputPurposeURL_ExpectGetInputPurposeReturnsURL(t *testing.T) {
if err := testTextViewInputPurpose(INPUT_PURPOSE_URL); err != nil {
t.Error(err)
}
}
func TestTextView_WhenSetInputPurposeALPHA_ExpectGetInputPurposeReturnsALPHA(t *testing.T) {
if err := testTextViewInputPurpose(INPUT_PURPOSE_ALPHA); err != nil {
t.Error(err)
}
}
func testCellRendererToggleSetRadio(set bool) error {
renderer, err := CellRendererToggleNew()
if err != nil {
return err
}
renderer.SetRadio(set)
if exp, act := set, renderer.GetRadio(); act != exp {
return fmt.Errorf("Expected GetRadio(): %v; Got: %v", exp, act)
}
return nil
}
func TestCellRendererToggle_WhenSetRadioFalse_ExpectGetRadioReturnsFalse(t *testing.T) {
if err := testCellRendererToggleSetRadio(false); err != nil {
t.Error(err)
}
}
func TestCellRendererToggle_WhenSetRadioTrue_ExpectGetRadioReturnsTrue(t *testing.T) {
if err := testCellRendererToggleSetRadio(true); err != nil {
t.Error(err)
}
}
func testCellRendererToggleSetActive(set bool) error {
renderer, err := CellRendererToggleNew()
if err != nil {
return err
}
renderer.SetActive(set)
if exp, act := set, renderer.GetActive(); act != exp {
return fmt.Errorf("Expected GetActive(): %v; Got: %v", exp, act)
}
return nil
}
func TestCellRendererToggle_WhenSetActiveFalse_ExpectGetActiveReturnsFalse(t *testing.T) {
if err := testCellRendererToggleSetActive(false); err != nil {
t.Error(err)
}
}
func TestCellRendererToggle_WhenSetActiveTrue_ExpectGetActiveReturnsTrue(t *testing.T) {
if err := testCellRendererToggleSetActive(true); err != nil {
t.Error(err)
}
}
func testCellRendererToggleSetActivatable(set bool) error {
renderer, err := CellRendererToggleNew()
if err != nil {
return err
}
renderer.SetActivatable(set)
if exp, act := set, renderer.GetActivatable(); act != exp {
return fmt.Errorf("Expected GetActivatable(): %v; Got: %v", exp, act)
}
return nil
}
func TestCellRendererToggle_WhenSetActivatableFalse_ExpectGetActivatableReturnsFalse(t *testing.T) {
if err := testCellRendererToggleSetActivatable(false); err != nil {
t.Error(err)
}
}
func TestCellRendererToggle_WhenSetActivatableTrue_ExpectGetActivatableReturnsTrue(t *testing.T) {
if err := testCellRendererToggleSetActivatable(true); err != nil {
t.Error(err)
}
}
func setupListStore() *ListStore {
ls, err := ListStoreNew(glib.TYPE_STRING)
if err != nil {
log.Fatal("Unexpected err:", err)
}
return ls
}
func getLastIter(ls *ListStore) (*TreeIter, bool) {
iter, listIsntEmpty := ls.GetIterFirst()
if !listIsntEmpty {
return iter, listIsntEmpty
}
for {
temp := *iter
last := &temp
if !ls.IterNext(iter) {
return last, true
}
}
panic("Shouldn't get here")
}
// TestListStoreRemoveLastInvalidIterator tests that when a ListStore stores
// one item and it is removed, the iterator becomes invalid.
func TestListStoreRemoveLastInvalidIterator(t *testing.T) {
ls := setupListStore()
iter := ls.Append()
if iterValid := ls.Remove(iter); iterValid {
t.Fatal("Remove() returned true (iter valid); expected false (iter invalid)")
}
}
func TestListStoreInsertBefore(t *testing.T) {
ls := setupListStore()
// Given 1 iter is already in the liststore
initialIter := ls.Append()
// When another iter is inserted before it
newIter := ls.InsertBefore(initialIter)
// Expect the newly-inserted iter is first iter in list
firstIter, listIsntEmpty := ls.GetIterFirst()
if !listIsntEmpty {
t.Fatal("Unexpected: liststore is empty")
}
if *firstIter != *newIter {
t.Fatal("Expected the new iter added to front of list")
}
}
// When 'sibling' parameter is nil, the new iter should be appended to the liststore
func TestListStoreInsertBefore_WhenNilSibling(t *testing.T) {
ls := setupListStore()
// Given 2 iters in liststore
ls.Append()
ls.Append()
// When 'sibling' parameter of InsertBefore() is nil...
newIter := ls.InsertBefore(nil)
// Then expect newly-inserted iter is the first iter in list
lastIter, listIsntEmpty := getLastIter(ls)
if !listIsntEmpty {
t.Fatal("Unexpected: liststore is empty")
}
if *lastIter != *newIter {
t.Fatal("Expected the new iter added to end of list")
}
}
func TestListStoreInsertAfter(t *testing.T) {
ls := setupListStore()
// Given 1 iter in liststore
sibling := ls.Append()
// When InsertAfter(sibling)
newIter := ls.InsertAfter(sibling)
// Then expect newly-inserted iter is the last iter in list
lastIter, listIsntEmpty := getLastIter(ls)
if !listIsntEmpty {
t.Fatal("Unexpected: liststore is empty")
}
if *lastIter != *newIter {
t.Fatal("Expected the new iter added to end of list")
}
}
// When 'sibling' parameter is nil, the new iter should be prepended to the liststore
func TestListStoreInsertAfter_WhenNilSibling(t *testing.T) {
ls := setupListStore()
// Given 2 iters in liststore
ls.Append()
ls.Append()
// When InsertAfter(nil)
newIter := ls.InsertAfter(nil)
// Then expect newly-inserted iter is the first iter in the list
first, listIsntEmpty := ls.GetIterFirst()
if !listIsntEmpty {
t.Fatal("Unexpected: liststore is empty")
}
if *first != *newIter {
t.Fatal("Expected the new iter was prepended to liststore")
}
}
func TestBuilder(t *testing.T) {
builder, err := BuilderNew()
if err != nil {
t.Error("Unable to create builder")
}
str := `
<interface>
<object class="GtkDialog" id="dialog1">
<child internal-child="vbox">
<object class="GtkBox" id="vbox1">
<property name="border-width">10</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="hbuttonbox1">
<property name="border-width">20</property>
<child>
<object class="GtkButton" id="ok_button">
<property name="label">gtk-ok</property>
<property name="use-stock">TRUE</property>
<signal name="clicked" handler="ok_button_clicked"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
`
err = builder.AddFromString(str)
if err != nil {
t.Error("Unable to add from string")
}
widget, err := builder.GetObject("ok_button")
if err != nil {
t.Error("Unable to get widget from string")
}
button, ok := widget.(*Button)
if !ok {
t.Error("Unable to cast to gtk.Button")
}
l, err := button.GetLabel()
if err != nil {
t.Error("Unable to get button label")
}
if l != "gtk-ok" {
t.Errorf("Label has the wrong value: %q", l)
}
done := make(chan bool)
builder.ConnectSignals(map[string]interface{}{
"ok_button_clicked": func() {
done <- true
},
})
go button.Emit("clicked")
select {
case <-done:
case <-time.After(1 * time.Second):
t.Error("Failed to call callback")
}
}
func TestTextTagEvent(t *testing.T) {
textTag, err := TextTagNew("mytexttag")
if err != nil {
t.Error("could not create text tag")
}
evk := gdk.EventKeyNew()
var iter TextIter
ok := textTag.Event(textTag.Object, evk.Event, &iter)
if ok {
t.Error("event should not have been handled")
}
textTag.Connect("event", func() bool {
return true
})
ok = textTag.Event(textTag.Object, evk.Event, &iter)
if !ok {
t.Error("event should have been handled")
}
}

@ -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,271 @@
// 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))
}
// GetMnemonicKeyval is a wrapper around gtk_label_get_mnemonic_keyval().
func (v *Label) GetMnemonicKeyval() uint {
return uint(C.gtk_label_get_mnemonic_keyval(v.native()))
}

@ -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,20 @@
// +build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_3_20
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
import "C"
import "github.com/gotk3/gotk3/gdk"
// PopupAtPointer() is a wrapper for gtk_menu_popup_at_pointer(), on older versions it uses PopupAtMouseCursor
func (v *Menu) PopupAtPointer(_ *gdk.Event) {
C.gtk_menu_popup(v.native(),
nil,
nil,
nil,
nil,
C.guint(0),
C.gtk_get_current_event_time())
}

@ -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,19 @@
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,!gtk_3_16,!gtk_3_18,!gtk_3_20
package gtk
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
import "C"
import (
"unsafe"
"github.com/gotk3/gotk3/gdk"
)
// PopupAtPointer() is a wrapper for gtk_menu_popup_at_pointer(), on older versions it uses PopupAtMouseCursor
func (v *Menu) PopupAtPointer(triggerEvent *gdk.Event) {
e := (*C.GdkEvent)(unsafe.Pointer(triggerEvent.Native()))
C.gtk_menu_popup_at_pointer(v.native(), e)
}

@ -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
}

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

Loading…
Cancel
Save