Giter VIP home page Giter VIP logo

gotk3's Introduction

gotk3

[Build Status] (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.

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

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, glib, gdk, and 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.

The gtk package requires the cairo, glib, and gdk packages as dependencies, so only one go get is necessary for complete installation.

The build process uses the tagging scheme gtk_MAJOR_MINOR to specify a build targeting any particular GTK version (for example, gtk_3_10). Building with no tags defaults to targeting the latest supported GTK release (3.16).

To install gotk3 targeting the latest GTK version:

$ go get github.com/gotk3/gotk3/gtk

On MacOS (using homebrew) you would likely specify PKG_CONFIG_PATH as such:

$ PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:`brew --prefix gtk+3`/lib/pkgconfig go get -u -v github.com/gotk3/gotk3/gdk

To install gotk3 targeting the older GTK 3.10 release:

$ go get -tags gtk_3_10 github.com/gotk3/gotk3/gtk

Ubuntu 14.04 uses the GTK 3.10 release. Also, some required packages may be missing. You may need to install the first or all of these packages in Ubuntu before gotk3:

$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libcairo2-dev
$ sudo apt-get install libglib2.0-dev

TODO

  • Add bindings for all of GTK+
  • Add tests for each implemented binding
  • Add examples for intent

License

Package gotk3 is licensed under the liberal ISC License.

gotk3's People

Contributors

jrick avatar andre-hub avatar movingtomars avatar juniorz avatar sqp avatar olabini avatar shish avatar geoffholden avatar raichu avatar terrak avatar weberc2 avatar tdruiva avatar mdimec4 avatar dajohi avatar dradtke avatar seppide avatar daphee avatar vvanpo avatar tmc avatar rkoesters avatar sqs avatar penberg avatar littlebuster avatar dahenson avatar tapir avatar lazyshot avatar carryforward avatar acsellers avatar amrhassan avatar akirill0v avatar

Watchers

Duzy Chan avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.