From c3a0e4de6c00fe4c3fd28a85b1237cf508960881 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Wed, 24 Feb 2016 01:48:14 +0000 Subject: [PATCH] godep gotk3 --- Godeps/Godeps.json | 28 + .../src/github.com/gotk3/gotk3/LICENSE | 13 + .../github.com/gotk3/gotk3/cairo/antialias.go | 28 + .../src/github.com/gotk3/gotk3/cairo/cairo.go | 65 + .../github.com/gotk3/gotk3/cairo/canvas.go | 401 + .../github.com/gotk3/gotk3/cairo/errors.go | 7 + .../github.com/gotk3/gotk3/cairo/fillrule.go | 23 + .../github.com/gotk3/gotk3/cairo/linecap.go | 24 + .../github.com/gotk3/gotk3/cairo/linejoin.go | 24 + .../github.com/gotk3/gotk3/cairo/mimetype.go | 13 + .../github.com/gotk3/gotk3/cairo/operator.go | 50 + .../github.com/gotk3/gotk3/cairo/status.go | 109 + .../github.com/gotk3/gotk3/cairo/surface.go | 206 + .../gotk3/gotk3/cairo/surfacetype.go | 46 + .../src/github.com/gotk3/gotk3/cairo/text.go | 127 + .../gotk3/gotk3/cairo/translations.go | 32 + .../src/github.com/gotk3/gotk3/cairo/util.go | 21 + .../src/github.com/gotk3/gotk3/gdk/gdk.go | 1607 +++ .../src/github.com/gotk3/gotk3/gdk/gdk.go.h | 100 + .../github.com/gotk3/gotk3/gdk/gdk_3_6-8.go | 34 + .../gotk3/gdk/gdk_deprecated_since_3_16.go | 13 + .../src/github.com/gotk3/gotk3/gdk/screen.go | 198 + .../gotk3/gotk3/gdk/screen_no_x11.go | 25 + .../github.com/gotk3/gotk3/gdk/screen_x11.go | 31 + .../gotk3/gotk3/gdk/window_no_x11.go | 17 + .../github.com/gotk3/gotk3/gdk/window_x11.go | 27 + .../gotk3/gotk3/glib/application.go | 216 + .../github.com/gotk3/gotk3/glib/connect.go | 117 + .../src/github.com/gotk3/gotk3/glib/glib.go | 1335 +++ .../src/github.com/gotk3/gotk3/glib/glib.go.h | 199 + .../gotk3/gotk3/glib/glib_extension.go | 18 + .../github.com/gotk3/gotk3/glib/gvariant.go | 186 + .../github.com/gotk3/gotk3/glib/gvariant.go.h | 41 + .../gotk3/gotk3/glib/gvariantbuilder.go | 54 + .../gotk3/gotk3/glib/gvariantclass.go | 39 + .../gotk3/gotk3/glib/gvariantdict.go | 54 + .../gotk3/gotk3/glib/gvariantiter.go | 54 + .../src/github.com/gotk3/gotk3/glib/list.go | 156 + .../src/github.com/gotk3/gotk3/glib/menu.go | 333 + .../gotk3/gotk3/glib/notifications.go | 106 + .../src/github.com/gotk3/gotk3/glib/slist.go | 71 + .../github.com/gotk3/gotk3/gtk/aboutdialog.go | 313 + .../src/github.com/gotk3/gotk3/gtk/accel.go | 435 + .../gotk3/gotk3/gtk/actionbar_since_3_12.go | 106 + .../gotk3/gotk3/gtk/actionbar_since_3_12.go.h | 25 + .../github.com/gotk3/gotk3/gtk/app_chooser.go | 378 + .../github.com/gotk3/gotk3/gtk/application.go | 156 + .../gotk3/gotk3/gtk/application_since_3_12.go | 62 + .../gotk3/gotk3/gtk/application_since_3_14.go | 49 + .../gotk3/gotk3/gtk/application_window.go | 65 + .../gotk3/gotk3/gtk/color_chooser.go | 148 + .../github.com/gotk3/gotk3/gtk/combo_box.go | 264 + .../src/github.com/gotk3/gotk3/gtk/gtk.go | 8876 +++++++++++++++++ .../src/github.com/gotk3/gotk3/gtk/gtk.go.h | 813 ++ .../gotk3/gtk/gtk_deprecated_since_3_10.go | 210 + .../gotk3/gtk/gtk_deprecated_since_3_12.go | 86 + .../gotk3/gtk/gtk_deprecated_since_3_14.go | 423 + .../gotk3/gtk/gtk_deprecated_since_3_14.go.h | 30 + .../gotk3/gtk/gtk_deprecated_since_3_16.go | 31 + .../github.com/gotk3/gotk3/gtk/gtk_export.go | 44 + .../gotk3/gotk3/gtk/gtk_since_3_10.go | 693 ++ .../gotk3/gotk3/gtk/gtk_since_3_10.go.h | 61 + .../gotk3/gotk3/gtk/gtk_since_3_8.go | 37 + .../github.com/gotk3/gotk3/gtk/info_bar.go | 106 + .../src/github.com/gotk3/gotk3/gtk/label.go | 257 + .../github.com/gotk3/gotk3/gtk/level_bar.go | 151 + .../gotk3/gotk3/gtk/level_bar_since_3_8.go | 18 + .../github.com/gotk3/gotk3/gtk/menu_shell.go | 96 + .../gotk3/gotk3/gtk/popover_since_3_12.go | 83 + .../gotk3/gotk3/gtk/popover_since_3_12.go.h | 25 + .../gotk3/gotk3/gtk/popover_since_3_18.go | 30 + .../github.com/gotk3/gotk3/gtk/settings.go | 53 + .../github.com/gotk3/gotk3/gtk/settings.go.h | 5 + .../gotk3/gotk3/gtk/stack_since_3_12.go | 27 + .../gotk3/gtk/stackswitcher_since_3_10.go | 78 + .../src/github.com/gotk3/gotk3/gtk/style.go | 232 + .../github.com/gotk3/gotk3/gtk/tree_view.go | 445 + .../gotk3/gotk3/gtk/tree_view_column.go | 265 + .../src/github.com/gotk3/gotk3/gtk/version.go | 30 + .../src/github.com/gotk3/gotk3/gtk/widget.go | 612 ++ .../gotk3/gotk3/gtk/widget_since_3_12.go | 46 + .../gotk3/gotk3/gtk/widget_since_3_8.go | 38 + .../src/github.com/gotk3/gotk3/gtk/window.go | 610 ++ .../gotk3/gotk3/gtk/window_since_3_10.go | 27 + .../gotk3/gotk3/pango/pango-attributes.go | 357 + .../gotk3/gotk3/pango/pango-attributes.go.h | 27 + .../gotk3/gotk3/pango/pango-context.go | 135 + .../gotk3/gotk3/pango/pango-font.go | 706 ++ .../gotk3/gotk3/pango/pango-glyph-item.go | 44 + .../gotk3/gotk3/pango/pango-glyph.go | 86 + .../gotk3/gotk3/pango/pango-gravity.go | 64 + .../gotk3/gotk3/pango/pango-layout.go | 463 + .../gotk3/gotk3/pango/pango-layout.go.h | 27 + .../gotk3/gotk3/pango/pango-types.go | 127 + .../src/github.com/gotk3/gotk3/pango/pango.go | 56 + .../github.com/gotk3/gotk3/pango/pango.go.h | 39 + .../gotk3/gotk3/pango/pangocairo.go | 139 + .../gotk3/gotk3/pango/pangocairo.go.h | 0 fw-settings/builder.go | 4 +- fw-settings/config.go | 4 +- fw-settings/dbus.go | 2 +- fw-settings/main.go | 4 +- fw-settings/rule_edit.go | 2 +- fw-settings/rules.go | 2 +- 104 files changed, 25066 insertions(+), 9 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/LICENSE create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/antialias.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/cairo.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/canvas.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/errors.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/fillrule.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linecap.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linejoin.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/mimetype.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/operator.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/status.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surface.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surfacetype.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/text.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/translations.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/util.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_3_6-8.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_16.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_no_x11.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_x11.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_no_x11.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_x11.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/application.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/connect.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib_extension.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantbuilder.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantclass.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantdict.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantiter.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/list.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/menu.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/notifications.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/glib/slist.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/aboutdialog.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/accel.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/app_chooser.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_14.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_window.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/color_chooser.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/combo_box.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_10.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_16.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_export.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_8.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/info_bar.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/label.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar_since_3_8.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/menu_shell.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_18.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stack_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stackswitcher_since_3_10.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/style.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view_column.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/version.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_12.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_8.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window_since_3_10.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-context.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-font.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph-item.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-gravity.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-types.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go.h create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go create mode 100644 Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go.h diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 86eee87..bd70008 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,12 +1,40 @@ { "ImportPath": "github.com/subgraph/fw-daemon", "GoVersion": "go1.5", + "Packages": [ + "./..." + ], "Deps": [ { "ImportPath": "github.com/godbus/dbus", "Comment": "v3-15-g230e4b2", "Rev": "230e4b23db2fd81c53eaa0073f76659d4849ce51" }, + { + "ImportPath": "github.com/gotk3/gotk3/cairo", + "Comment": "GOTK3_0_2_0-430-ge68c426", + "Rev": "e68c42636533041787e09741c5027ea670ad6f84" + }, + { + "ImportPath": "github.com/gotk3/gotk3/gdk", + "Comment": "GOTK3_0_2_0-430-ge68c426", + "Rev": "e68c42636533041787e09741c5027ea670ad6f84" + }, + { + "ImportPath": "github.com/gotk3/gotk3/glib", + "Comment": "GOTK3_0_2_0-430-ge68c426", + "Rev": "e68c42636533041787e09741c5027ea670ad6f84" + }, + { + "ImportPath": "github.com/gotk3/gotk3/gtk", + "Comment": "GOTK3_0_2_0-430-ge68c426", + "Rev": "e68c42636533041787e09741c5027ea670ad6f84" + }, + { + "ImportPath": "github.com/gotk3/gotk3/pango", + "Comment": "GOTK3_0_2_0-430-ge68c426", + "Rev": "e68c42636533041787e09741c5027ea670ad6f84" + }, { "ImportPath": "github.com/op/go-logging", "Rev": "dfaf3dff9b631bc4236201d90d41ee0de9202889" diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/LICENSE b/Godeps/_workspace/src/github.com/gotk3/gotk3/LICENSE new file mode 100644 index 0000000..53015ff --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2013-2014 Conformal Systems LLC. + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/antialias.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/antialias.go new file mode 100644 index 0000000..4d5f6cf --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/antialias.go @@ -0,0 +1,28 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/cairo.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/cairo.go new file mode 100644 index 0000000..dd6b0ba --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/cairo.go @@ -0,0 +1,65 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +// #include +// #include +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/canvas.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/canvas.go new file mode 100644 index 0000000..121b59f --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/canvas.go @@ -0,0 +1,401 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +import "C" + +import ( + "reflect" + "runtime" + "unsafe" +) + +// Context is a representation of Cairo's cairo_t. +type Context struct { + context *C.cairo_t +} + +// native returns a pointer to the underlying cairo_t. +func (v *Context) native() *C.cairo_t { + if v == nil { + return nil + } + return v.context +} + +func (v *Context) GetCContext() *C.cairo_t { + return v.native() +} + +// Native returns a pointer to the underlying cairo_t. +func (v *Context) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalContext(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + context := (*C.cairo_t)(unsafe.Pointer(c)) + return wrapContext(context), nil +} + +func wrapContext(context *C.cairo_t) *Context { + return &Context{context} +} + +// Create is a wrapper around cairo_create(). +func Create(target *Surface) *Context { + c := C.cairo_create(target.native()) + ctx := wrapContext(c) + runtime.SetFinalizer(ctx, (*Context).destroy) + return ctx +} + +// reference is a wrapper around cairo_reference(). +func (v *Context) reference() { + v.context = C.cairo_reference(v.native()) +} + +// destroy is a wrapper around cairo_destroy(). +func (v *Context) destroy() { + C.cairo_destroy(v.native()) +} + +// Status is a wrapper around cairo_status(). +func (v *Context) Status() Status { + c := C.cairo_status(v.native()) + return Status(c) +} + +// Save is a wrapper around cairo_save(). +func (v *Context) Save() { + C.cairo_save(v.native()) +} + +// Restore is a wrapper around cairo_restore(). +func (v *Context) Restore() { + C.cairo_restore(v.native()) +} + +// GetTarget is a wrapper around cairo_get_target(). +func (v *Context) GetTarget() *Surface { + c := C.cairo_get_target(v.native()) + s := wrapSurface(c) + s.reference() + runtime.SetFinalizer(s, (*Surface).destroy) + return s +} + +// PushGroup is a wrapper around cairo_push_group(). +func (v *Context) PushGroup() { + C.cairo_push_group(v.native()) +} + +// PushGroupWithContent is a wrapper around cairo_push_group_with_content(). +func (v *Context) PushGroupWithContent(content Content) { + C.cairo_push_group_with_content(v.native(), C.cairo_content_t(content)) +} + +// TODO(jrick) PopGroup (depends on Pattern) + +// PopGroupToSource is a wrapper around cairo_pop_group_to_source(). +func (v *Context) PopGroupToSource() { + C.cairo_pop_group_to_source(v.native()) +} + +// GetGroupTarget is a wrapper around cairo_get_group_target(). +func (v *Context) GetGroupTarget() *Surface { + c := C.cairo_get_group_target(v.native()) + s := wrapSurface(c) + s.reference() + runtime.SetFinalizer(s, (*Surface).destroy) + return s +} + +// SetSourceRGB is a wrapper around cairo_set_source_rgb(). +func (v *Context) SetSourceRGB(red, green, blue float64) { + C.cairo_set_source_rgb(v.native(), C.double(red), C.double(green), + C.double(blue)) +} + +// SetSourceRGBA is a wrapper around cairo_set_source_rgba(). +func (v *Context) SetSourceRGBA(red, green, blue, alpha float64) { + C.cairo_set_source_rgba(v.native(), C.double(red), C.double(green), + C.double(blue), C.double(alpha)) +} + +// TODO(jrick) SetSource (depends on Pattern) + +// SetSourceSurface is a wrapper around cairo_set_source_surface(). +func (v *Context) SetSourceSurface(surface *Surface, x, y float64) { + C.cairo_set_source_surface(v.native(), surface.native(), C.double(x), + C.double(y)) +} + +// TODO(jrick) GetSource (depends on Pattern) + +// SetAntialias is a wrapper around cairo_set_antialias(). +func (v *Context) SetAntialias(antialias Antialias) { + C.cairo_set_antialias(v.native(), C.cairo_antialias_t(antialias)) +} + +// GetAntialias is a wrapper around cairo_get_antialias(). +func (v *Context) GetAntialias() Antialias { + c := C.cairo_get_antialias(v.native()) + return Antialias(c) +} + +// SetDash is a wrapper around cairo_set_dash(). +func (v *Context) SetDash(dashes []float64, offset float64) { + header := (*reflect.SliceHeader)(unsafe.Pointer(&dashes)) + cdashes := (*C.double)(unsafe.Pointer(header.Data)) + C.cairo_set_dash(v.native(), cdashes, C.int(header.Len), + C.double(offset)) +} + +// GetDashCount is a wrapper around cairo_get_dash_count(). +func (v *Context) GetDashCount() int { + c := C.cairo_get_dash_count(v.native()) + return int(c) +} + +// GetDash is a wrapper around cairo_get_dash(). +func (v *Context) GetDash() (dashes []float64, offset float64) { + dashCount := v.GetDashCount() + cdashes := (*C.double)(C.calloc(8, C.size_t(dashCount))) + var coffset C.double + C.cairo_get_dash(v.native(), cdashes, &coffset) + header := (*reflect.SliceHeader)((unsafe.Pointer(&dashes))) + header.Data = uintptr(unsafe.Pointer(cdashes)) + header.Len = dashCount + header.Cap = dashCount + return dashes, float64(coffset) +} + +// SetFillRule is a wrapper around cairo_set_fill_rule(). +func (v *Context) SetFillRule(fillRule FillRule) { + C.cairo_set_fill_rule(v.native(), C.cairo_fill_rule_t(fillRule)) +} + +// GetFillRule is a wrapper around cairo_get_fill_rule(). +func (v *Context) GetFillRule() FillRule { + c := C.cairo_get_fill_rule(v.native()) + return FillRule(c) +} + +// SetLineCap is a wrapper around cairo_set_line_cap(). +func (v *Context) SetLineCap(lineCap LineCap) { + C.cairo_set_line_cap(v.native(), C.cairo_line_cap_t(lineCap)) +} + +// GetLineCap is a wrapper around cairo_get_line_cap(). +func (v *Context) GetLineCap() LineCap { + c := C.cairo_get_line_cap(v.native()) + return LineCap(c) +} + +// SetLineJoin is a wrapper around cairo_set_line_join(). +func (v *Context) SetLineJoin(lineJoin LineJoin) { + C.cairo_set_line_join(v.native(), C.cairo_line_join_t(lineJoin)) +} + +// GetLineJoin is a wrapper around cairo_get_line_join(). +func (v *Context) GetLineJoin() LineJoin { + c := C.cairo_get_line_join(v.native()) + return LineJoin(c) +} + +// SetLineWidth is a wrapper around cairo_set_line_width(). +func (v *Context) SetLineWidth(width float64) { + C.cairo_set_line_width(v.native(), C.double(width)) +} + +// GetLineWidth is a wrapper cairo_get_line_width(). +func (v *Context) GetLineWidth() float64 { + c := C.cairo_get_line_width(v.native()) + return float64(c) +} + +// SetMiterLimit is a wrapper around cairo_set_miter_limit(). +func (v *Context) SetMiterLimit(limit float64) { + C.cairo_set_miter_limit(v.native(), C.double(limit)) +} + +// GetMiterLimit is a wrapper around cairo_get_miter_limit(). +func (v *Context) GetMiterLimit() float64 { + c := C.cairo_get_miter_limit(v.native()) + return float64(c) +} + +// SetOperator is a wrapper around cairo_set_operator(). +func (v *Context) SetOperator(op Operator) { + C.cairo_set_operator(v.native(), C.cairo_operator_t(op)) +} + +// GetOperator is a wrapper around cairo_get_operator(). +func (v *Context) GetOperator() Operator { + c := C.cairo_get_operator(v.native()) + return Operator(c) +} + +// SetTolerance is a wrapper around cairo_set_tolerance(). +func (v *Context) SetTolerance(tolerance float64) { + C.cairo_set_tolerance(v.native(), C.double(tolerance)) +} + +// GetTolerance is a wrapper around cairo_get_tolerance(). +func (v *Context) GetTolerance() float64 { + c := C.cairo_get_tolerance(v.native()) + return float64(c) +} + +// Clip is a wrapper around cairo_clip(). +func (v *Context) Clip() { + C.cairo_clip(v.native()) +} + +// ClipPreserve is a wrapper around cairo_clip_preserve(). +func (v *Context) ClipPreserve() { + C.cairo_clip_preserve(v.native()) +} + +// ClipExtents is a wrapper around cairo_clip_extents(). +func (v *Context) ClipExtents() (x1, y1, x2, y2 float64) { + var cx1, cy1, cx2, cy2 C.double + C.cairo_clip_extents(v.native(), &cx1, &cy1, &cx2, &cy2) + return float64(cx1), float64(cy1), float64(cx2), float64(cy2) +} + +// InClip is a wrapper around cairo_in_clip(). +func (v *Context) InClip(x, y float64) bool { + c := C.cairo_in_clip(v.native(), C.double(x), C.double(y)) + return gobool(c) +} + +// ResetClip is a wrapper around cairo_reset_clip(). +func (v *Context) ResetClip() { + C.cairo_reset_clip(v.native()) +} + +// Rectangle is a wrapper around cairo_rectangle(). +func (v *Context) Rectangle(x, y, w, h float64) { + C.cairo_rectangle(v.native(), C.double(x), C.double(y), C.double(w), C.double(h)) +} + +// Arc is a wrapper around cairo_arc(). +func (v *Context) Arc(xc, yc, radius, angle1, angle2 float64) { + C.cairo_arc(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2)) +} + +// ArcNegative is a wrapper around cairo_arc_negative(). +func (v *Context) ArcNegative(xc, yc, radius, angle1, angle2 float64) { + C.cairo_arc_negative(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2)) +} + +// LineTo is a wrapper around cairo_line_to(). +func (v *Context) LineTo(x, y float64) { + C.cairo_line_to(v.native(), C.double(x), C.double(y)) +} + +// CurveTo is a wrapper around cairo_curve_to(). +func (v *Context) CurveTo(x1, y1, x2, y2, x3, y3 float64) { + C.cairo_curve_to(v.native(), C.double(x1), C.double(y1), C.double(x2), C.double(y2), C.double(x3), C.double(y3)) +} + +// MoveTo is a wrapper around cairo_move_to(). +func (v *Context) MoveTo(x, y float64) { + C.cairo_move_to(v.native(), C.double(x), C.double(y)) +} + +// TODO(jrick) CopyRectangleList (depends on RectangleList) + +// Fill is a wrapper around cairo_fill(). +func (v *Context) Fill() { + C.cairo_fill(v.native()) +} + +// ClosePath is a wrapper around cairo_close_path(). +func (v *Context) ClosePath() { + C.cairo_close_path(v.native()) +} + +// NewPath is a wrapper around cairo_new_path(). +func (v *Context) NewPath() { + C.cairo_new_path(v.native()) +} + +// GetCurrentPoint is a wrapper around cairo_get_current_point(). +func (v *Context) GetCurrentPoint() (x, y float64) { + C.cairo_get_current_point(v.native(), (*C.double)(&x), (*C.double)(&y)) + return +} + +// FillPreserve is a wrapper around cairo_fill_preserve(). +func (v *Context) FillPreserve() { + C.cairo_fill_preserve(v.native()) +} + +// FillExtents is a wrapper around cairo_fill_extents(). +func (v *Context) FillExtents() (x1, y1, x2, y2 float64) { + var cx1, cy1, cx2, cy2 C.double + C.cairo_fill_extents(v.native(), &cx1, &cy1, &cx2, &cy2) + return float64(cx1), float64(cy1), float64(cx2), float64(cy2) +} + +// InFill is a wrapper around cairo_in_fill(). +func (v *Context) InFill(x, y float64) bool { + c := C.cairo_in_fill(v.native(), C.double(x), C.double(y)) + return gobool(c) +} + +// TODO(jrick) Mask (depends on Pattern) + +// MaskSurface is a wrapper around cairo_mask_surface(). +func (v *Context) MaskSurface(surface *Surface, surfaceX, surfaceY float64) { + C.cairo_mask_surface(v.native(), surface.native(), C.double(surfaceX), + C.double(surfaceY)) +} + +// Paint is a wrapper around cairo_paint(). +func (v *Context) Paint() { + C.cairo_paint(v.native()) +} + +// PaintWithAlpha is a wrapper around cairo_paint_with_alpha(). +func (v *Context) PaintWithAlpha(alpha float64) { + C.cairo_paint_with_alpha(v.native(), C.double(alpha)) +} + +// Stroke is a wrapper around cairo_stroke(). +func (v *Context) Stroke() { + C.cairo_stroke(v.native()) +} + +// StrokePreserve is a wrapper around cairo_stroke_preserve(). +func (v *Context) StrokePreserve() { + C.cairo_stroke_preserve(v.native()) +} + +// StrokeExtents is a wrapper around cairo_stroke_extents(). +func (v *Context) StrokeExtents() (x1, y1, x2, y2 float64) { + var cx1, cy1, cx2, cy2 C.double + C.cairo_stroke_extents(v.native(), &cx1, &cy1, &cx2, &cy2) + return float64(cx1), float64(cy1), float64(cx2), float64(cy2) +} + +// InStroke is a wrapper around cairo_in_stroke(). +func (v *Context) InStroke(x, y float64) bool { + c := C.cairo_in_stroke(v.native(), C.double(x), C.double(y)) + return gobool(c) +} + +// CopyPage is a wrapper around cairo_copy_page(). +func (v *Context) CopyPage() { + C.cairo_copy_page(v.native()) +} + +// ShowPage is a wrapper around cairo_show_page(). +func (v *Context) ShowPage() { + C.cairo_show_page(v.native()) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/errors.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/errors.go new file mode 100644 index 0000000..1e48a8a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/errors.go @@ -0,0 +1,7 @@ +package cairo + +type ErrorStatus Status + +func (e ErrorStatus) Error() string { + return StatusToString(Status(e)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/fillrule.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/fillrule.go new file mode 100644 index 0000000..91a6b1f --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/fillrule.go @@ -0,0 +1,23 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linecap.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linecap.go new file mode 100644 index 0000000..3ff7ca0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linecap.go @@ -0,0 +1,24 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linejoin.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linejoin.go new file mode 100644 index 0000000..71c715f --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/linejoin.go @@ -0,0 +1,24 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/mimetype.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/mimetype.go new file mode 100644 index 0000000..406273e --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/mimetype.go @@ -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" +) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/operator.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/operator.go new file mode 100644 index 0000000..b263c8d --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/operator.go @@ -0,0 +1,50 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/status.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/status.go new file mode 100644 index 0000000..5bd8aa4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/status.go @@ -0,0 +1,109 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surface.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surface.go new file mode 100644 index 0000000..c3acaa1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surface.go @@ -0,0 +1,206 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} + +// 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) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surfacetype.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surfacetype.go new file mode 100644 index 0000000..30b9782 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/surfacetype.go @@ -0,0 +1,46 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/text.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/text.go new file mode 100644 index 0000000..a14f6ef --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/text.go @@ -0,0 +1,127 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 + diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/translations.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/translations.go new file mode 100644 index 0000000..d205a0e --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/translations.go @@ -0,0 +1,32 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/util.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/util.go new file mode 100644 index 0000000..6659109 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo/util.go @@ -0,0 +1,21 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go new file mode 100644 index 0000000..d38ef78 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go @@ -0,0 +1,1607 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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. + +// Go bindings for GDK 3. Supports version 3.6 and later. +package gdk + +// #cgo pkg-config: gdk-3.0 +// #include +// #include "gdk.go.h" +import "C" +import ( + "errors" + "reflect" + "runtime" + "strconv" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.gdk_drag_action_get_type()), marshalDragAction}, + {glib.Type(C.gdk_colorspace_get_type()), marshalColorspace}, + {glib.Type(C.gdk_event_type_get_type()), marshalEventType}, + {glib.Type(C.gdk_interp_type_get_type()), marshalInterpType}, + {glib.Type(C.gdk_modifier_type_get_type()), marshalModifierType}, + {glib.Type(C.gdk_pixbuf_alpha_mode_get_type()), marshalPixbufAlphaMode}, + {glib.Type(C.gdk_event_mask_get_type()), marshalEventMask}, + + // Objects/Interfaces + {glib.Type(C.gdk_device_get_type()), marshalDevice}, + {glib.Type(C.gdk_cursor_get_type()), marshalCursor}, + {glib.Type(C.gdk_device_manager_get_type()), marshalDeviceManager}, + {glib.Type(C.gdk_display_get_type()), marshalDisplay}, + {glib.Type(C.gdk_drag_context_get_type()), marshalDragContext}, + {glib.Type(C.gdk_pixbuf_get_type()), marshalPixbuf}, + {glib.Type(C.gdk_rgba_get_type()), marshalRGBA}, + {glib.Type(C.gdk_screen_get_type()), marshalScreen}, + {glib.Type(C.gdk_visual_get_type()), marshalVisual}, + {glib.Type(C.gdk_window_get_type()), marshalWindow}, + + // Boxed + {glib.Type(C.gdk_event_get_type()), marshalEvent}, + } + glib.RegisterGValueMarshalers(tm) +} + +/* + * Type conversions + */ + +func gbool(b bool) C.gboolean { + if b { + return C.gboolean(1) + } + return C.gboolean(0) +} +func gobool(b C.gboolean) bool { + if b != 0 { + return true + } + return false +} + +/* + * Unexported vars + */ + +var nilPtrErr = errors.New("cgo returned unexpected nil pointer") + +/* + * Constants + */ + +// DragAction is a representation of GDK's GdkDragAction. +type DragAction int + +const ( + ACTION_DEFAULT DragAction = C.GDK_ACTION_DEFAULT + ACTION_COPY DragAction = C.GDK_ACTION_COPY + ACTION_MOVE DragAction = C.GDK_ACTION_MOVE + ACTION_LINK DragAction = C.GDK_ACTION_LINK + ACTION_PRIVATE DragAction = C.GDK_ACTION_PRIVATE + ACTION_ASK DragAction = C.GDK_ACTION_ASK +) + +func marshalDragAction(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return DragAction(c), nil +} + +// Colorspace is a representation of GDK's GdkColorspace. +type Colorspace int + +const ( + COLORSPACE_RGB Colorspace = C.GDK_COLORSPACE_RGB +) + +func marshalColorspace(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Colorspace(c), nil +} + +// InterpType is a representation of GDK's GdkInterpType. +type InterpType int + +const ( + INTERP_NEAREST InterpType = C.GDK_INTERP_NEAREST + INTERP_TILES InterpType = C.GDK_INTERP_TILES + INTERP_BILINEAR InterpType = C.GDK_INTERP_BILINEAR + INTERP_HYPER InterpType = C.GDK_INTERP_HYPER +) + +// PixbufRotation is a representation of GDK's GdkPixbufRotation. +type PixbufRotation int + +const ( + PIXBUF_ROTATE_NONE PixbufRotation = C.GDK_PIXBUF_ROTATE_NONE + PIXBUF_ROTATE_COUNTERCLOCKWISE PixbufRotation = C.GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE + PIXBUF_ROTATE_UPSIDEDOWN PixbufRotation = C.GDK_PIXBUF_ROTATE_UPSIDEDOWN + PIXBUF_ROTATE_CLOCKWISE PixbufRotation = C.GDK_PIXBUF_ROTATE_CLOCKWISE +) + +func marshalInterpType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return InterpType(c), nil +} + +// ModifierType is a representation of GDK's GdkModifierType. +type ModifierType uint + +const ( + GDK_SHIFT_MASK ModifierType = C.GDK_SHIFT_MASK + GDK_LOCK_MASK = C.GDK_LOCK_MASK + GDK_CONTROL_MASK = C.GDK_CONTROL_MASK + GDK_MOD1_MASK = C.GDK_MOD1_MASK + GDK_MOD2_MASK = C.GDK_MOD2_MASK + GDK_MOD3_MASK = C.GDK_MOD3_MASK + GDK_MOD4_MASK = C.GDK_MOD4_MASK + GDK_MOD5_MASK = C.GDK_MOD5_MASK + GDK_BUTTON1_MASK = C.GDK_BUTTON1_MASK + GDK_BUTTON2_MASK = C.GDK_BUTTON2_MASK + GDK_BUTTON3_MASK = C.GDK_BUTTON3_MASK + GDK_BUTTON4_MASK = C.GDK_BUTTON4_MASK + GDK_BUTTON5_MASK = C.GDK_BUTTON5_MASK + GDK_SUPER_MASK = C.GDK_SUPER_MASK + GDK_HYPER_MASK = C.GDK_HYPER_MASK + GDK_META_MASK = C.GDK_META_MASK + GDK_RELEASE_MASK = C.GDK_RELEASE_MASK + GDK_MODIFIER_MASK = C.GDK_MODIFIER_MASK +) + +func marshalModifierType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ModifierType(c), nil +} + +// PixbufAlphaMode is a representation of GDK's GdkPixbufAlphaMode. +type PixbufAlphaMode int + +const ( + GDK_PIXBUF_ALPHA_BILEVEL PixbufAlphaMode = C.GDK_PIXBUF_ALPHA_BILEVEL + GDK_PIXBUF_ALPHA_FULL PixbufAlphaMode = C.GDK_PIXBUF_ALPHA_FULL +) + +func marshalPixbufAlphaMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PixbufAlphaMode(c), nil +} + +// Selections +const ( + SELECTION_PRIMARY Atom = 1 + SELECTION_SECONDARY Atom = 2 + SELECTION_CLIPBOARD Atom = 69 + TARGET_BITMAP Atom = 5 + TARGET_COLORMAP Atom = 7 + TARGET_DRAWABLE Atom = 17 + TARGET_PIXMAP Atom = 20 + TARGET_STRING Atom = 31 + SELECTION_TYPE_ATOM Atom = 4 + SELECTION_TYPE_BITMAP Atom = 5 + SELECTION_TYPE_COLORMAP Atom = 7 + SELECTION_TYPE_DRAWABLE Atom = 17 + SELECTION_TYPE_INTEGER Atom = 19 + SELECTION_TYPE_PIXMAP Atom = 20 + SELECTION_TYPE_WINDOW Atom = 33 + SELECTION_TYPE_STRING Atom = 31 +) + +// added by terrak +// EventMask is a representation of GDK's GdkEventMask. +type EventMask int + +const ( + EXPOSURE_MASK EventMask = C.GDK_EXPOSURE_MASK + POINTER_MOTION_MASK EventMask = C.GDK_POINTER_MOTION_MASK + POINTER_MOTION_HINT_MASK EventMask = C.GDK_POINTER_MOTION_HINT_MASK + BUTTON_MOTION_MASK EventMask = C.GDK_BUTTON_MOTION_MASK + BUTTON1_MOTION_MASK EventMask = C.GDK_BUTTON1_MOTION_MASK + BUTTON2_MOTION_MASK EventMask = C.GDK_BUTTON2_MOTION_MASK + BUTTON3_MOTION_MASK EventMask = C.GDK_BUTTON3_MOTION_MASK + BUTTON_PRESS_MASK EventMask = C.GDK_BUTTON_PRESS_MASK + BUTTON_RELEASE_MASK EventMask = C.GDK_BUTTON_RELEASE_MASK + KEY_PRESS_MASK EventMask = C.GDK_KEY_PRESS_MASK + KEY_RELEASE_MASK EventMask = C.GDK_KEY_RELEASE_MASK + ENTER_NOTIFY_MASK EventMask = C.GDK_ENTER_NOTIFY_MASK + LEAVE_NOTIFY_MASK EventMask = C.GDK_LEAVE_NOTIFY_MASK + FOCUS_CHANGE_MASK EventMask = C.GDK_FOCUS_CHANGE_MASK + STRUCTURE_MASK EventMask = C.GDK_STRUCTURE_MASK + PROPERTY_CHANGE_MASK EventMask = C.GDK_PROPERTY_CHANGE_MASK + VISIBILITY_NOTIFY_MASK EventMask = C.GDK_VISIBILITY_NOTIFY_MASK + PROXIMITY_IN_MASK EventMask = C.GDK_PROXIMITY_IN_MASK + PROXIMITY_OUT_MASK EventMask = C.GDK_PROXIMITY_OUT_MASK + SUBSTRUCTURE_MASK EventMask = C.GDK_SUBSTRUCTURE_MASK + SCROLL_MASK EventMask = C.GDK_SCROLL_MASK + TOUCH_MASK EventMask = C.GDK_TOUCH_MASK + SMOOTH_SCROLL_MASK EventMask = C.GDK_SMOOTH_SCROLL_MASK + ALL_EVENTS_MASK EventMask = C.GDK_ALL_EVENTS_MASK +) + +func marshalEventMask(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return EventMask(c), nil +} + +// added by lazyshot +// ScrollDirection is a representation of GDK's GdkScrollDirection + +type ScrollDirection int + +const ( + SCROLL_UP ScrollDirection = C.GDK_SCROLL_UP + SCROLL_DOWN ScrollDirection = C.GDK_SCROLL_DOWN + SCROLL_LEFT ScrollDirection = C.GDK_SCROLL_LEFT + SCROLL_RIGHT ScrollDirection = C.GDK_SCROLL_RIGHT + SCROLL_SMOOTH ScrollDirection = C.GDK_SCROLL_SMOOTH +) + +// CURRENT_TIME is a representation of GDK_CURRENT_TIME + +const CURRENT_TIME = C.GDK_CURRENT_TIME + +// GrabStatus is a representation of GdkGrabStatus + +type GrabStatus int + +const ( + GRAB_SUCCESS GrabStatus = C.GDK_GRAB_SUCCESS + GRAB_ALREADY_GRABBED GrabStatus = C.GDK_GRAB_ALREADY_GRABBED + GRAB_INVALID_TIME GrabStatus = C.GDK_GRAB_INVALID_TIME + GRAB_FROZEN GrabStatus = C.GDK_GRAB_FROZEN + // Only exists since 3.16 + // GRAB_FAILED GrabStatus = C.GDK_GRAB_FAILED + GRAB_FAILED GrabStatus = 5 +) + +// GrabOwnership is a representation of GdkGrabOwnership + +type GrabOwnership int + +const ( + OWNERSHIP_NONE GrabOwnership = C.GDK_OWNERSHIP_NONE + OWNERSHIP_WINDOW GrabOwnership = C.GDK_OWNERSHIP_WINDOW + OWNERSHIP_APPLICATION GrabOwnership = C.GDK_OWNERSHIP_APPLICATION +) + +// DeviceType is a representation of GdkDeviceType + +type DeviceType int + +const ( + DEVICE_TYPE_MASTER DeviceType = C.GDK_DEVICE_TYPE_MASTER + DEVICE_TYPE_SLAVE DeviceType = C.GDK_DEVICE_TYPE_SLAVE + DEVICE_TYPE_FLOATING DeviceType = C.GDK_DEVICE_TYPE_FLOATING +) + +/* + * GdkAtom + */ + +// Atom is a representation of GDK's GdkAtom. +type Atom uintptr + +// native returns the underlying GdkAtom. +func (v Atom) native() C.GdkAtom { + return C.toGdkAtom(unsafe.Pointer(uintptr(v))) +} + +func (v Atom) Name() string { + c := C.gdk_atom_name(v.native()) + defer C.g_free(C.gpointer(c)) + return C.GoString((*C.char)(c)) +} + +// GdkAtomIntern is a wrapper around gdk_atom_intern +func GdkAtomIntern(atomName string, onlyIfExists bool) Atom { + cstr := C.CString(atomName) + defer C.free(unsafe.Pointer(cstr)) + c := C.gdk_atom_intern((*C.gchar)(cstr), gbool(onlyIfExists)) + return Atom(uintptr(unsafe.Pointer(c))) +} + +/* + * GdkDevice + */ + +// Device is a representation of GDK's GdkDevice. +type Device struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkDevice. +func (v *Device) native() *C.GdkDevice { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkDevice(p) +} + +// Native returns a pointer to the underlying GdkDevice. +func (v *Device) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalDevice(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Device{obj}, nil +} + +// 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) +} + +// Ungrab() is a wrapper around gdk_device_ungrab(). +func (v *Device) Ungrab(time uint32) { + C.gdk_device_ungrab(v.native(), C.guint32(time)) +} + +/* + * GdkCursor + */ + +// Cursor is a representation of GdkCursor. +type Cursor struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkCursor. +func (v *Cursor) native() *C.GdkCursor { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkCursor(p) +} + +// Native returns a pointer to the underlying GdkCursor. +func (v *Cursor) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalCursor(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Cursor{obj}, nil +} + +/* + * GdkDeviceManager + */ + +// DeviceManager is a representation of GDK's GdkDeviceManager. +type DeviceManager struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkDeviceManager. +func (v *DeviceManager) native() *C.GdkDeviceManager { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkDeviceManager(p) +} + +// Native returns a pointer to the underlying GdkDeviceManager. +func (v *DeviceManager) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalDeviceManager(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &DeviceManager{obj}, nil +} + +// 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 +} + +// GetDisplay() is a wrapper around gdk_device_manager_get_display(). +func (v *DeviceManager) GetDisplay() (*Display, error) { + c := C.gdk_device_manager_get_display(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 &Display{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 +} + +/* + * GdkDisplay + */ + +// Display is a representation of GDK's GdkDisplay. +type Display struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkDisplay. +func (v *Display) native() *C.GdkDisplay { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkDisplay(p) +} + +// Native returns a pointer to the underlying GdkDisplay. +func (v *Display) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalDisplay(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Display{obj}, nil +} + +func toDisplay(s *C.GdkDisplay) (*Display, error) { + if s == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} + return &Display{obj}, nil +} + +// DisplayOpen() is a wrapper around gdk_display_open(). +func DisplayOpen(displayName string) (*Display, error) { + cstr := C.CString(displayName) + defer C.free(unsafe.Pointer(cstr)) + c := C.gdk_display_open((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + d := &Display{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return d, nil +} + +// DisplayGetDefault() is a wrapper around gdk_display_get_default(). +func DisplayGetDefault() (*Display, error) { + c := C.gdk_display_get_default() + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + d := &Display{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return d, nil +} + +// GetName() is a wrapper around gdk_display_get_name(). +func (v *Display) GetName() (string, error) { + c := C.gdk_display_get_name(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), 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 +} + +// GetDefaultScreen() is a wrapper around gdk_display_get_default_screen(). +func (v *Display) GetDefaultScreen() (*Screen, error) { + c := C.gdk_display_get_default_screen(v.native()) + 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 +} + +// 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 +} + +// DeviceIsGrabbed() is a wrapper around gdk_display_device_is_grabbed(). +func (v *Display) DeviceIsGrabbed(device *Device) bool { + c := C.gdk_display_device_is_grabbed(v.native(), device.native()) + return gobool(c) +} + +// Beep() is a wrapper around gdk_display_beep(). +func (v *Display) Beep() { + C.gdk_display_beep(v.native()) +} + +// Sync() is a wrapper around gdk_display_sync(). +func (v *Display) Sync() { + C.gdk_display_sync(v.native()) +} + +// Flush() is a wrapper around gdk_display_flush(). +func (v *Display) Flush() { + C.gdk_display_flush(v.native()) +} + +// Close() is a wrapper around gdk_display_close(). +func (v *Display) Close() { + C.gdk_display_close(v.native()) +} + +// IsClosed() is a wrapper around gdk_display_is_closed(). +func (v *Display) IsClosed() bool { + c := C.gdk_display_is_closed(v.native()) + return gobool(c) +} + +// GetEvent() is a wrapper around gdk_display_get_event(). +func (v *Display) GetEvent() (*Event, error) { + c := C.gdk_display_get_event(v.native()) + if c == nil { + return nil, nilPtrErr + } + e := &Event{c} + runtime.SetFinalizer(e, (*Event).free) + return e, nil +} + +// PeekEvent() is a wrapper around gdk_display_peek_event(). +func (v *Display) PeekEvent() (*Event, error) { + c := C.gdk_display_peek_event(v.native()) + if c == nil { + return nil, nilPtrErr + } + e := &Event{c} + runtime.SetFinalizer(e, (*Event).free) + return e, nil +} + +// PutEvent() is a wrapper around gdk_display_put_event(). +func (v *Display) PutEvent(event *Event) { + C.gdk_display_put_event(v.native(), event.native()) +} + +// HasPending() is a wrapper around gdk_display_has_pending(). +func (v *Display) HasPending() bool { + c := C.gdk_display_has_pending(v.native()) + return gobool(c) +} + +// SetDoubleClickTime() is a wrapper around gdk_display_set_double_click_time(). +func (v *Display) SetDoubleClickTime(msec uint) { + C.gdk_display_set_double_click_time(v.native(), C.guint(msec)) +} + +// SetDoubleClickDistance() is a wrapper around gdk_display_set_double_click_distance(). +func (v *Display) SetDoubleClickDistance(distance uint) { + C.gdk_display_set_double_click_distance(v.native(), C.guint(distance)) +} + +// SupportsColorCursor() is a wrapper around gdk_display_supports_cursor_color(). +func (v *Display) SupportsColorCursor() bool { + c := C.gdk_display_supports_cursor_color(v.native()) + return gobool(c) +} + +// SupportsCursorAlpha() is a wrapper around gdk_display_supports_cursor_alpha(). +func (v *Display) SupportsCursorAlpha() bool { + c := C.gdk_display_supports_cursor_alpha(v.native()) + return gobool(c) +} + +// GetDefaultCursorSize() is a wrapper around gdk_display_get_default_cursor_size(). +func (v *Display) GetDefaultCursorSize() uint { + c := C.gdk_display_get_default_cursor_size(v.native()) + return uint(c) +} + +// GetMaximalCursorSize() is a wrapper around gdk_display_get_maximal_cursor_size(). +func (v *Display) GetMaximalCursorSize() (width, height uint) { + var w, h C.guint + C.gdk_display_get_maximal_cursor_size(v.native(), &w, &h) + return uint(w), uint(h) +} + +// GetDefaultGroup() is a wrapper around gdk_display_get_default_group(). +func (v *Display) GetDefaultGroup() (*Window, error) { + c := C.gdk_display_get_default_group(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + w := &Window{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return w, nil +} + +// SupportsSelectionNotification() is a wrapper around +// gdk_display_supports_selection_notification(). +func (v *Display) SupportsSelectionNotification() bool { + c := C.gdk_display_supports_selection_notification(v.native()) + return gobool(c) +} + +// RequestSelectionNotification() is a wrapper around +// gdk_display_request_selection_notification(). +func (v *Display) RequestSelectionNotification(selection Atom) bool { + c := C.gdk_display_request_selection_notification(v.native(), + selection.native()) + return gobool(c) +} + +// SupportsClipboardPersistence() is a wrapper around +// gdk_display_supports_clipboard_persistence(). +func (v *Display) SupportsClipboardPersistence() bool { + c := C.gdk_display_supports_clipboard_persistence(v.native()) + return gobool(c) +} + +// TODO(jrick) +func (v *Display) StoreClipboard(clipboardWindow *Window, time uint32, targets ...Atom) { +} + +// SupportsShapes() is a wrapper around gdk_display_supports_shapes(). +func (v *Display) SupportsShapes() bool { + c := C.gdk_display_supports_shapes(v.native()) + return gobool(c) +} + +// SupportsInputShapes() is a wrapper around gdk_display_supports_input_shapes(). +func (v *Display) SupportsInputShapes() bool { + c := C.gdk_display_supports_input_shapes(v.native()) + return gobool(c) +} + +// TODO(jrick) glib.AppLaunchContext GdkAppLaunchContext +func (v *Display) GetAppLaunchContext() { +} + +// NotifyStartupComplete() is a wrapper around gdk_display_notify_startup_complete(). +func (v *Display) NotifyStartupComplete(startupID string) { + cstr := C.CString(startupID) + defer C.free(unsafe.Pointer(cstr)) + C.gdk_display_notify_startup_complete(v.native(), (*C.gchar)(cstr)) +} + +// EventType is a representation of GDK's GdkEventType. +// Do not confuse these event types with the signals that GTK+ widgets emit +type EventType int + +func marshalEventType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return EventType(c), nil +} + +const ( + EVENT_NOTHING EventType = C.GDK_NOTHING + EVENT_DELETE EventType = C.GDK_DELETE + EVENT_DESTROY EventType = C.GDK_DESTROY + EVENT_EXPOSE EventType = C.GDK_EXPOSE + EVENT_MOTION_NOTIFY EventType = C.GDK_MOTION_NOTIFY + EVENT_BUTTON_PRESS EventType = C.GDK_BUTTON_PRESS + EVENT_2BUTTON_PRESS EventType = C.GDK_2BUTTON_PRESS + EVENT_DOUBLE_BUTTON_PRESS EventType = C.GDK_DOUBLE_BUTTON_PRESS + EVENT_3BUTTON_PRESS EventType = C.GDK_3BUTTON_PRESS + EVENT_TRIPLE_BUTTON_PRESS EventType = C.GDK_TRIPLE_BUTTON_PRESS + EVENT_BUTTON_RELEASE EventType = C.GDK_BUTTON_RELEASE + EVENT_KEY_PRESS EventType = C.GDK_KEY_PRESS + EVENT_KEY_RELEASE EventType = C.GDK_KEY_RELEASE + EVENT_LEAVE_NOTIFY EventType = C.GDK_ENTER_NOTIFY + EVENT_FOCUS_CHANGE EventType = C.GDK_FOCUS_CHANGE + EVENT_CONFIGURE EventType = C.GDK_CONFIGURE + EVENT_MAP EventType = C.GDK_MAP + EVENT_UNMAP EventType = C.GDK_UNMAP + EVENT_PROPERTY_NOTIFY EventType = C.GDK_PROPERTY_NOTIFY + EVENT_SELECTION_CLEAR EventType = C.GDK_SELECTION_CLEAR + EVENT_SELECTION_REQUEST EventType = C.GDK_SELECTION_REQUEST + EVENT_SELECTION_NOTIFY EventType = C.GDK_SELECTION_NOTIFY + EVENT_PROXIMITY_IN EventType = C.GDK_PROXIMITY_IN + EVENT_PROXIMITY_OUT EventType = C.GDK_PROXIMITY_OUT + EVENT_DRAG_ENTER EventType = C.GDK_DRAG_ENTER + EVENT_DRAG_LEAVE EventType = C.GDK_DRAG_LEAVE + EVENT_DRAG_MOTION EventType = C.GDK_DRAG_MOTION + EVENT_DRAG_STATUS EventType = C.GDK_DRAG_STATUS + EVENT_DROP_START EventType = C.GDK_DROP_START + EVENT_DROP_FINISHED EventType = C.GDK_DROP_FINISHED + EVENT_CLIENT_EVENT EventType = C.GDK_CLIENT_EVENT + EVENT_VISIBILITY_NOTIFY EventType = C.GDK_VISIBILITY_NOTIFY + EVENT_SCROLL EventType = C.GDK_SCROLL + EVENT_WINDOW_STATE EventType = C.GDK_WINDOW_STATE + EVENT_SETTING EventType = C.GDK_SETTING + EVENT_OWNER_CHANGE EventType = C.GDK_OWNER_CHANGE + EVENT_GRAB_BROKEN EventType = C.GDK_GRAB_BROKEN + EVENT_DAMAGE EventType = C.GDK_DAMAGE + EVENT_TOUCH_BEGIN EventType = C.GDK_TOUCH_BEGIN + EVENT_TOUCH_UPDATE EventType = C.GDK_TOUCH_UPDATE + EVENT_TOUCH_END EventType = C.GDK_TOUCH_END + EVENT_TOUCH_CANCEL EventType = C.GDK_TOUCH_CANCEL + EVENT_LAST EventType = C.GDK_EVENT_LAST +) + +/* + * GDK Keyval + */ + +// KeyvalFromName() is a wrapper around gdk_keyval_from_name(). +func KeyvalFromName(keyvalName string) uint { + str := (*C.gchar)(C.CString(keyvalName)) + defer C.free(unsafe.Pointer(str)) + return uint(C.gdk_keyval_from_name(str)) +} + +func KeyvalConvertCase(v uint) (lower, upper uint) { + var l, u C.guint + l = 0 + u = 0 + C.gdk_keyval_convert_case(C.guint(v), &l, &u) + return uint(l), uint(u) +} + +func KeyvalIsLower(v uint) bool { + return gobool(C.gdk_keyval_is_lower(C.guint(v))) +} + +func KeyvalIsUpper(v uint) bool { + return gobool(C.gdk_keyval_is_upper(C.guint(v))) +} + +func KeyvalToLower(v uint) uint { + return uint(C.gdk_keyval_to_lower(C.guint(v))) +} + +func KeyvalToUpper(v uint) uint { + return uint(C.gdk_keyval_to_upper(C.guint(v))) +} + +/* + * GdkDragContext + */ + +// DragContext is a representation of GDK's GdkDragContext. +type DragContext struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkDragContext. +func (v *DragContext) native() *C.GdkDragContext { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkDragContext(p) +} + +// Native returns a pointer to the underlying GdkDragContext. +func (v *DragContext) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalDragContext(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &DragContext{obj}, nil +} + +func (v *DragContext) ListTargets() *glib.List { + c := C.gdk_drag_context_list_targets(v.native()) + return glib.WrapList(uintptr(unsafe.Pointer(c))) +} + +/* + * GdkEvent + */ + +// Event is a representation of GDK's GdkEvent. +type Event struct { + GdkEvent *C.GdkEvent +} + +// native returns a pointer to the underlying GdkEvent. +func (v *Event) native() *C.GdkEvent { + if v == nil { + return nil + } + return v.GdkEvent +} + +// Native returns a pointer to the underlying GdkEvent. +func (v *Event) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalEvent(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return &Event{(*C.GdkEvent)(unsafe.Pointer(c))}, nil +} + +func (v *Event) free() { + C.gdk_event_free(v.native()) +} + +/* + * GdkEventButton + */ + +// EventButton is a representation of GDK's GdkEventButton. +type EventButton struct { + *Event +} + +// Native returns a pointer to the underlying GdkEventButton. +func (v *EventButton) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EventButton) native() *C.GdkEventButton { + return (*C.GdkEventButton)(unsafe.Pointer(v.Event.native())) +} + +func (v *EventButton) X() float64 { + c := v.native().x + return float64(c) +} + +func (v *EventButton) Y() float64 { + c := v.native().y + return float64(c) +} + +// XRoot returns the x coordinate of the pointer relative to the root of the screen. +func (v *EventButton) XRoot() float64 { + c := v.native().x_root + return float64(c) +} + +// YRoot returns the y coordinate of the pointer relative to the root of the screen. +func (v *EventButton) YRoot() float64 { + c := v.native().y_root + return float64(c) +} + +func (v *EventButton) Button() uint { + c := v.native().button + return uint(c) +} + +func (v *EventButton) State() uint { + c := v.native().state + return uint(c) +} + +// Time returns the time of the event in milliseconds. +func (v *EventButton) Time() uint32 { + c := v.native().time + return uint32(c) +} + +func (v *EventButton) Type() EventType { + c := v.native()._type + return EventType(c) +} + +func (v *EventButton) MotionVal() (float64, float64) { + x := v.native().x + y := v.native().y + return float64(x), float64(y) +} + +func (v *EventButton) MotionValRoot() (float64, float64) { + x := v.native().x_root + y := v.native().y_root + return float64(x), float64(y) +} + +func (v *EventButton) ButtonVal() uint { + c := v.native().button + return uint(c) +} + +/* + * GdkEventKey + */ + +// EventKey is a representation of GDK's GdkEventKey. +type EventKey struct { + *Event +} + +func EventKeyNew() *EventKey { + ee := (*C.GdkEvent)(unsafe.Pointer(&C.GdkEventKey{})) + ev := Event{ee} + return &EventKey{&ev} +} + +// Native returns a pointer to the underlying GdkEventKey. +func (v *EventKey) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EventKey) native() *C.GdkEventKey { + return (*C.GdkEventKey)(unsafe.Pointer(v.Event.native())) +} + +func (v *EventKey) KeyVal() uint { + c := v.native().keyval + return uint(c) +} + +func (v *EventKey) Type() EventType { + c := v.native()._type + return EventType(c) +} + +func (v *EventKey) State() uint { + c := v.native().state + return uint(c) +} + +/* + * GdkEventMotion + */ + +type EventMotion struct { + *Event +} + +// Native returns a pointer to the underlying GdkEventMotion. +func (v *EventMotion) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EventMotion) native() *C.GdkEventMotion { + return (*C.GdkEventMotion)(unsafe.Pointer(v.Event.native())) +} + +func (v *EventMotion) MotionVal() (float64, float64) { + x := v.native().x + y := v.native().y + return float64(x), float64(y) +} + +func (v *EventMotion) MotionValRoot() (float64, float64) { + x := v.native().x_root + y := v.native().y_root + return float64(x), float64(y) +} + +/* + * GdkEventScroll + */ + +// EventScroll is a representation of GDK's GdkEventScroll. +type EventScroll struct { + *Event +} + +// Native returns a pointer to the underlying GdkEventScroll. +func (v *EventScroll) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EventScroll) native() *C.GdkEventScroll { + return (*C.GdkEventScroll)(unsafe.Pointer(v.Event.native())) +} + +func (v *EventScroll) DeltaX() float64 { + return float64(v.native().delta_x) +} + +func (v *EventScroll) DeltaY() float64 { + return float64(v.native().delta_y) +} + +func (v *EventScroll) X() float64 { + return float64(v.native().x) +} + +func (v *EventScroll) Y() float64 { + return float64(v.native().y) +} + +func (v *EventScroll) Type() EventType { + c := v.native()._type + return EventType(c) +} + +/* + * GdkPixbuf + */ + +// Pixbuf is a representation of GDK's GdkPixbuf. +type Pixbuf struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkPixbuf. +func (v *Pixbuf) native() *C.GdkPixbuf { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkPixbuf(p) +} + +// Native returns a pointer to the underlying GdkPixbuf. +func (v *Pixbuf) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalPixbuf(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Pixbuf{obj}, nil +} + +// GetColorspace is a wrapper around gdk_pixbuf_get_colorspace(). +func (v *Pixbuf) GetColorspace() Colorspace { + c := C.gdk_pixbuf_get_colorspace(v.native()) + return Colorspace(c) +} + +// GetNChannels is a wrapper around gdk_pixbuf_get_n_channels(). +func (v *Pixbuf) GetNChannels() int { + c := C.gdk_pixbuf_get_n_channels(v.native()) + return int(c) +} + +// GetHasAlpha is a wrapper around gdk_pixbuf_get_has_alpha(). +func (v *Pixbuf) GetHasAlpha() bool { + c := C.gdk_pixbuf_get_has_alpha(v.native()) + return gobool(c) +} + +// GetBitsPerSample is a wrapper around gdk_pixbuf_get_bits_per_sample(). +func (v *Pixbuf) GetBitsPerSample() int { + c := C.gdk_pixbuf_get_bits_per_sample(v.native()) + return int(c) +} + +// GetPixels is a wrapper around gdk_pixbuf_get_pixels_with_length(). +// A Go slice is used to represent the underlying Pixbuf data array, one +// byte per channel. +func (v *Pixbuf) GetPixels() (channels []byte) { + var length C.guint + c := C.gdk_pixbuf_get_pixels_with_length(v.native(), &length) + sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&channels)) + sliceHeader.Data = uintptr(unsafe.Pointer(c)) + sliceHeader.Len = int(length) + sliceHeader.Cap = int(length) + // To make sure the slice doesn't outlive the Pixbuf, add a reference + v.Ref() + runtime.SetFinalizer(&channels, func(_ *[]byte) { + v.Unref() + }) + return +} + +// GetWidth is a wrapper around gdk_pixbuf_get_width(). +func (v *Pixbuf) GetWidth() int { + c := C.gdk_pixbuf_get_width(v.native()) + return int(c) +} + +// GetHeight is a wrapper around gdk_pixbuf_get_height(). +func (v *Pixbuf) GetHeight() int { + c := C.gdk_pixbuf_get_height(v.native()) + return int(c) +} + +// GetRowstride is a wrapper around gdk_pixbuf_get_rowstride(). +func (v *Pixbuf) GetRowstride() int { + c := C.gdk_pixbuf_get_rowstride(v.native()) + return int(c) +} + +// GetByteLength is a wrapper around gdk_pixbuf_get_byte_length(). +func (v *Pixbuf) GetByteLength() int { + c := C.gdk_pixbuf_get_byte_length(v.native()) + return int(c) +} + +// GetOption is a wrapper around gdk_pixbuf_get_option(). ok is true if +// the key has an associated value. +func (v *Pixbuf) GetOption(key string) (value string, ok bool) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gdk_pixbuf_get_option(v.native(), (*C.gchar)(cstr)) + if c == nil { + return "", false + } + return C.GoString((*C.char)(c)), true +} + +// PixbufNew is a wrapper around gdk_pixbuf_new(). +func PixbufNew(colorspace Colorspace, hasAlpha bool, bitsPerSample, width, height int) (*Pixbuf, error) { + c := C.gdk_pixbuf_new(C.GdkColorspace(colorspace), gbool(hasAlpha), + C.int(bitsPerSample), C.int(width), C.int(height)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// PixbufCopy is a wrapper around gdk_pixbuf_copy(). +func PixbufCopy(v *Pixbuf) (*Pixbuf, error) { + c := C.gdk_pixbuf_copy(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// PixbufNewFromFile is a wrapper around gdk_pixbuf_new_from_file(). +func PixbufNewFromFile(filename string) (*Pixbuf, error) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError + res := C.gdk_pixbuf_new_from_file((*C.char)(cstr), &err) + if res == nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// PixbufNewFromFileAtSize is a wrapper around gdk_pixbuf_new_from_file_at_size(). +func PixbufNewFromFileAtSize(filename string, width, height int) (*Pixbuf, error) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gdk_pixbuf_new_from_file_at_size(cstr, C.int(width), C.int(height), &err) + if err != nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + if res == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// PixbufNewFromFileAtScale is a wrapper around gdk_pixbuf_new_from_file_at_scale(). +func PixbufNewFromFileAtScale(filename string, width, height int, preserveAspectRatio bool) (*Pixbuf, error) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gdk_pixbuf_new_from_file_at_scale(cstr, C.int(width), C.int(height), + gbool(preserveAspectRatio), &err) + if err != nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + if res == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// ScaleSimple is a wrapper around gdk_pixbuf_scale_simple(). +func (v *Pixbuf) ScaleSimple(destWidth, destHeight int, interpType InterpType) (*Pixbuf, error) { + c := C.gdk_pixbuf_scale_simple(v.native(), C.int(destWidth), + C.int(destHeight), C.GdkInterpType(interpType)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// RotateSimple is a wrapper around gdk_pixbuf_rotate_simple(). +func (v *Pixbuf) RotateSimple(angle PixbufRotation) (*Pixbuf, error) { + c := C.gdk_pixbuf_rotate_simple(v.native(), C.GdkPixbufRotation(angle)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// ApplyEmbeddedOrientation is a wrapper around gdk_pixbuf_apply_embedded_orientation(). +func (v *Pixbuf) ApplyEmbeddedOrientation() (*Pixbuf, error) { + c := C.gdk_pixbuf_apply_embedded_orientation(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// Flip is a wrapper around gdk_pixbuf_flip(). +func (v *Pixbuf) Flip(horizontal bool) (*Pixbuf, error) { + c := C.gdk_pixbuf_flip(v.native(), gbool(horizontal)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// SaveJPEG is a wrapper around gdk_pixbuf_save(). +// Quality is a number between 0...100 +func (v *Pixbuf) SaveJPEG(path string, quality int) error { + cpath := C.CString(path) + cquality := C.CString(strconv.Itoa(quality)) + defer C.free(unsafe.Pointer(cpath)) + defer C.free(unsafe.Pointer(cquality)) + + var err *C.GError + c := C._gdk_pixbuf_save_jpeg(v.native(), cpath, &err, cquality) + if !gobool(c) { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// SavePNG is a wrapper around gdk_pixbuf_save(). +// Compression is a number between 0...9 +func (v *Pixbuf) SavePNG(path string, compression int) error { + cpath := C.CString(path) + ccompression := C.CString(strconv.Itoa(compression)) + defer C.free(unsafe.Pointer(cpath)) + defer C.free(unsafe.Pointer(ccompression)) + + var err *C.GError + c := C._gdk_pixbuf_save_png(v.native(), cpath, &err, ccompression) + if !gobool(c) { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// PixbufGetFileInfo is a wrapper around gdk_pixbuf_get_file_info(). +// TODO: need to wrap the returned format to GdkPixbufFormat. +func PixbufGetFileInfo(filename string) (format interface{}, width, height int) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + var cw, ch C.gint + format = C.gdk_pixbuf_get_file_info((*C.gchar)(cstr), &cw, &ch) + // TODO: need to wrap the returned format to GdkPixbufFormat. + return format, int(cw), int(ch) +} + +/* + * GdkPixbufLoader + */ + +// PixbufLoader is a representation of GDK's GdkPixbufLoader. +// Users of PixbufLoader are expected to call Close() when they are finished. +type PixbufLoader struct { + *glib.Object +} + +// native() returns a pointer to the underlying GdkPixbufLoader. +func (v *PixbufLoader) native() *C.GdkPixbufLoader { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkPixbufLoader(p) +} + +// PixbufLoaderNew() is a wrapper around gdk_pixbuf_loader_new(). +func PixbufLoaderNew() (*PixbufLoader, error) { + c := C.gdk_pixbuf_loader_new() + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &PixbufLoader{obj} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +// Write() is a wrapper around gdk_pixbuf_loader_write(). The +// function signature differs from the C equivalent to satisify the +// io.Writer interface. +func (v *PixbufLoader) Write(data []byte) (int, error) { + // n is set to 0 on error, and set to len(data) otherwise. + // This is a tiny hacky to satisfy io.Writer and io.WriteCloser, + // which would allow access to all io and ioutil goodies, + // and play along nice with go environment. + + if len(data) == 0 { + return 0, nil + } + + var err *C.GError + c := C.gdk_pixbuf_loader_write(v.native(), + (*C.guchar)(unsafe.Pointer(&data[0])), C.gsize(len(data)), + &err) + if !gobool(c) { + defer C.g_error_free(err) + return 0, errors.New(C.GoString((*C.char)(err.message))) + } + + return len(data), nil +} + +// Close is a wrapper around gdk_pixbuf_loader_close(). An error is +// returned instead of a bool like the native C function to support the +// io.Closer interface. +func (v *PixbufLoader) Close() error { + var err *C.GError + + if ok := gobool(C.gdk_pixbuf_loader_close(v.native(), &err)); !ok { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// SetSize is a wrapper around gdk_pixbuf_loader_set_size(). +func (v *PixbufLoader) SetSize(width, height int) { + C.gdk_pixbuf_loader_set_size(v.native(), C.int(width), C.int(height)) +} + +// GetPixbuf is a wrapper around gdk_pixbuf_loader_get_pixbuf(). +func (v *PixbufLoader) GetPixbuf() (*Pixbuf, error) { + c := C.gdk_pixbuf_loader_get_pixbuf(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + p := &Pixbuf{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return p, nil +} + +type RGBA struct { + rgba *C.GdkRGBA +} + +func marshalRGBA(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + c2 := (*C.GdkRGBA)(unsafe.Pointer(c)) + return wrapRGBA(c2), nil +} + +func wrapRGBA(obj *C.GdkRGBA) *RGBA { + return &RGBA{obj} +} + +func NewRGBA(values ...float64) *RGBA { + cval := C.GdkRGBA{} + c := &RGBA{&cval} + if len(values) > 0 { + c.rgba.red = C.gdouble(values[0]) + } + if len(values) > 1 { + c.rgba.green = C.gdouble(values[1]) + } + if len(values) > 2 { + c.rgba.blue = C.gdouble(values[2]) + } + if len(values) > 3 { + c.rgba.alpha = C.gdouble(values[3]) + } + return c +} + +func (c *RGBA) Floats() []float64 { + return []float64{float64(c.rgba.red), float64(c.rgba.green), float64(c.rgba.blue), float64(c.rgba.alpha)} +} + +func (v *RGBA) Native() uintptr { + return uintptr(unsafe.Pointer(v.rgba)) +} + +// Parse is a representation of gdk_rgba_parse(). +func (v *RGBA) Parse(spec string) bool { + cstr := (*C.gchar)(C.CString(spec)) + defer C.free(unsafe.Pointer(cstr)) + + return gobool(C.gdk_rgba_parse(v.rgba, cstr)) +} + +// String is a representation of gdk_rgba_to_string(). +func (v *RGBA) String() string { + return C.GoString((*C.char)(C.gdk_rgba_to_string(v.rgba))) +} + +// GdkRGBA * gdk_rgba_copy () +// void gdk_rgba_free () +// gboolean gdk_rgba_equal () +// guint gdk_rgba_hash () + +// PixbufGetType is a wrapper around gdk_pixbuf_get_type(). +func PixbufGetType() glib.Type { + return glib.Type(C.gdk_pixbuf_get_type()) +} + +/* + * GdkRectangle + */ + +// Rectangle is a representation of GDK's GdkRectangle type. +type Rectangle struct { + GdkRectangle C.GdkRectangle +} + +// Native() returns a pointer to the underlying GdkRectangle. +func (r *Rectangle) native() *C.GdkRectangle { + return &r.GdkRectangle +} + +// GetX returns x field of the underlying GdkRectangle. +func (r *Rectangle) GetX() int { + return int(r.native().x) +} + +// GetY returns y field of the underlying GdkRectangle. +func (r *Rectangle) GetY() int { + return int(r.native().y) +} + +// GetWidth returns width field of the underlying GdkRectangle. +func (r *Rectangle) GetWidth() int { + return int(r.native().width) +} + +// GetHeight returns height field of the underlying GdkRectangle. +func (r *Rectangle) GetHeight() int { + return int(r.native().height) +} + +/* + * GdkVisual + */ + +// Visual is a representation of GDK's GdkVisual. +type Visual struct { + *glib.Object +} + +func (v *Visual) native() *C.GdkVisual { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkVisual(p) +} + +func (v *Visual) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalVisual(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Visual{obj}, nil +} + +/* + * GdkWindow + */ + +// Window is a representation of GDK's GdkWindow. +type Window struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkWindow. +func (v *Window) native() *C.GdkWindow { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkWindow(p) +} + +// Native returns a pointer to the underlying GdkWindow. +func (v *Window) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalWindow(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Window{obj}, nil +} + +func toWindow(s *C.GdkWindow) (*Window, error) { + if s == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} + return &Window{obj}, nil +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go.h new file mode 100644 index 0000000..d0d7dca --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk.go.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * 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 + +// 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)); +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_3_6-8.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_3_6-8.go new file mode 100644 index 0000000..7e06b93 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_3_6-8.go @@ -0,0 +1,34 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_16.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_16.go new file mode 100644 index 0000000..b7d1ffe --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_16.go @@ -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 +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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen.go new file mode 100644 index 0000000..b639631 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen.go @@ -0,0 +1,198 @@ +package gdk + +// #cgo pkg-config: gdk-3.0 +// #include +// #include "gdk.go.h" +import "C" +import ( + "runtime" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +/* + * GdkScreen + */ + +// Screen is a representation of GDK's GdkScreen. +type Screen struct { + *glib.Object +} + +// native returns a pointer to the underlying GdkScreen. +func (v *Screen) native() *C.GdkScreen { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGdkScreen(p) +} + +// Native returns a pointer to the underlying GdkScreen. +func (v *Screen) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalScreen(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + return &Screen{obj}, nil +} + +func toScreen(s *C.GdkScreen) (*Screen, error) { + if s == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} + return &Screen{obj}, nil +} + +// GetRGBAVisual is a wrapper around gdk_screen_get_rgba_visual(). +func (v *Screen) GetRGBAVisual() (*Visual, error) { + c := C.gdk_screen_get_rgba_visual(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + visual := &Visual{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return visual, nil +} + +// GetSystemVisual is a wrapper around gdk_screen_get_system_visual(). +func (v *Screen) GetSystemVisual() (*Visual, error) { + c := C.gdk_screen_get_system_visual(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + visual := &Visual{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return visual, nil +} + +// GetWidth is a wrapper around gdk_screen_get_width(). +func (v *Screen) GetWidth() int { + c := C.gdk_screen_get_width(v.native()) + return int(c) +} + +// GetHeight is a wrapper around gdk_screen_get_height(). +func (v *Screen) GetHeight() int { + c := C.gdk_screen_get_height(v.native()) + return int(c) +} + +// ScreenGetDefault is a wrapper aroud gdk_screen_get_default(). +func ScreenGetDefault() (*Screen, error) { + return toScreen(C.gdk_screen_get_default()) +} + +// IsComposited is a wrapper around gdk_screen_is_composited(). +func (v *Screen) IsComposited() bool { + return gobool(C.gdk_screen_is_composited(v.native())) +} + +// GetRootWindow is a wrapper around gdk_screen_get_root_window(). +func (v *Screen) GetRootWindow() (*Window, error) { + return toWindow(C.gdk_screen_get_root_window(v.native())) +} + +// GetDisplay is a wrapper around gdk_screen_get_display(). +func (v *Screen) GetDisplay() (*Display, error) { + return toDisplay(C.gdk_screen_get_display(v.native())) +} + +// GetNumber is a wrapper around gdk_screen_get_number(). +func (v *Screen) GetNumber() int { + return int(C.gdk_screen_get_number(v.native())) +} + +// GetWidthMM is a wrapper around gdk_screen_get_width_mm(). +func (v *Screen) GetWidthMM() int { + return int(C.gdk_screen_get_width_mm(v.native())) +} + +// GetHeightMM is a wrapper around gdk_screen_get_height_mm(). +func (v *Screen) GetHeightMM() int { + return int(C.gdk_screen_get_height_mm(v.native())) +} + +func toString(c *C.gchar) (string, error) { + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// MakeDisplayName is a wrapper around gdk_screen_make_display_name(). +func (v *Screen) MakeDisplayName() (string, error) { + return toString(C.gdk_screen_make_display_name(v.native())) +} + +// GetNMonitors is a wrapper around gdk_screen_get_n_monitors(). +func (v *Screen) GetNMonitors() int { + return int(C.gdk_screen_get_n_monitors(v.native())) +} + +// GetPrimaryMonitor is a wrapper around gdk_screen_get_primary_monitor(). +func (v *Screen) GetPrimaryMonitor() int { + return int(C.gdk_screen_get_primary_monitor(v.native())) +} + +// GetMonitorAtPoint is a wrapper around gdk_screen_get_monitor_at_point(). +func (v *Screen) GetMonitorAtPoint(x, y int) int { + return int(C.gdk_screen_get_monitor_at_point(v.native(), C.gint(x), C.gint(y))) +} + +// GetMonitorAtWindow is a wrapper around gdk_screen_get_monitor_at_window(). +func (v *Screen) GetMonitorAtWindow(w *Window) int { + return int(C.gdk_screen_get_monitor_at_window(v.native(), w.native())) +} + +// GetMonitorHeightMM is a wrapper around gdk_screen_get_monitor_height_mm(). +func (v *Screen) GetMonitorHeightMM(m int) int { + return int(C.gdk_screen_get_monitor_height_mm(v.native(), C.gint(m))) +} + +// GetMonitorWidthMM is a wrapper around gdk_screen_get_monitor_width_mm(). +func (v *Screen) GetMonitorWidthMM(m int) int { + return int(C.gdk_screen_get_monitor_width_mm(v.native(), C.gint(m))) +} + +// GetMonitorPlugName is a wrapper around gdk_screen_get_monitor_plug_name(). +func (v *Screen) GetMonitorPlugName(m int) (string, error) { + return toString(C.gdk_screen_get_monitor_plug_name(v.native(), C.gint(m))) +} + +// GetMonitorScaleFactor is a wrapper around gdk_screen_get_monitor_scale_factor(). +func (v *Screen) GetMonitorScaleFactor(m int) int { + return int(C.gdk_screen_get_monitor_scale_factor(v.native(), C.gint(m))) +} + +// GetResolution is a wrapper around gdk_screen_get_resolution(). +func (v *Screen) GetResolution() float64 { + return float64(C.gdk_screen_get_resolution(v.native())) +} + +// SetResolution is a wrapper around gdk_screen_set_resolution(). +func (v *Screen) SetResolution(r float64) { + C.gdk_screen_set_resolution(v.native(), C.gdouble(r)) +} + +// GetActiveWindow is a wrapper around gdk_screen_get_active_window(). +func (v *Screen) GetActiveWindow() (*Window, error) { + return toWindow(C.gdk_screen_get_active_window(v.native())) +} + +// void gdk_screen_set_font_options () +// gboolean gdk_screen_get_setting () +// const cairo_font_options_t * gdk_screen_get_font_options () +// GList * gdk_screen_get_window_stack () +// GList * gdk_screen_list_visuals () +// GList * gdk_screen_get_toplevel_windows () +// void gdk_screen_get_monitor_geometry () +// void gdk_screen_get_monitor_workarea () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_no_x11.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_no_x11.go new file mode 100644 index 0000000..9551598 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_no_x11.go @@ -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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_x11.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_x11.go new file mode 100644 index 0000000..084a52e --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/screen_x11.go @@ -0,0 +1,31 @@ +// +build linux +// +build !no_x11 + +package gdk + +// #cgo pkg-config: gdk-x11-3.0 +// #include +// #include +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())) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_no_x11.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_no_x11.go new file mode 100644 index 0000000..72c5665 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_no_x11.go @@ -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) { +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_x11.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_x11.go new file mode 100644 index 0000000..5f46200 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk/window_x11.go @@ -0,0 +1,27 @@ +// +build linux +// +build !no_x11 + +package gdk + +// #cgo pkg-config: gdk-x11-3.0 +// #include +// #include +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)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/application.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/application.go new file mode 100644 index 0000000..eef0eb0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/application.go @@ -0,0 +1,216 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include +// #include "glib.go.h" +import "C" +import "unsafe" + +// Application is a representation of GApplication. +type Application struct { + *Object +} + +// native() returns a pointer to the underlying GApplication. +func (v *Application) native() *C.GApplication { + if v == nil || v.GObject == nil { + return nil + } + return C.toGApplication(unsafe.Pointer(v.GObject)) +} + +func (v *Application) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalApplication(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + return wrapApplication(wrapObject(unsafe.Pointer(c))), nil +} + +func wrapApplication(obj *Object) *Application { + return &Application{obj} +} + +// ApplicationIDIsValid is a wrapper around g_application_id_is_valid(). +func ApplicationIDIsValid(id string) bool { + cstr1 := (*C.gchar)(C.CString(id)) + defer C.free(unsafe.Pointer(cstr1)) + + return gobool(C.g_application_id_is_valid(cstr1)) +} + +// ApplicationNew is a wrapper around g_application_new(). +func ApplicationNew(appID string, flags ApplicationFlags) *Application { + cstr1 := (*C.gchar)(C.CString(appID)) + defer C.free(unsafe.Pointer(cstr1)) + + c := C.g_application_new(cstr1, C.GApplicationFlags(flags)) + if c == nil { + return nil + } + return wrapApplication(wrapObject(unsafe.Pointer(c))) +} + +// GetApplicationID is a wrapper around g_application_get_application_id(). +func (v *Application) GetApplicationID() string { + c := C.g_application_get_application_id(v.native()) + + return C.GoString((*C.char)(c)) +} + +// SetApplicationID is a wrapper around g_application_set_application_id(). +func (v *Application) SetApplicationID(id string) { + cstr1 := (*C.gchar)(C.CString(id)) + defer C.free(unsafe.Pointer(cstr1)) + + C.g_application_set_application_id(v.native(), cstr1) +} + +// GetInactivityTimeout is a wrapper around g_application_get_inactivity_timeout(). +func (v *Application) GetInactivityTimeout() uint { + return uint(C.g_application_get_inactivity_timeout(v.native())) +} + +// SetInactivityTimeout is a wrapper around g_application_set_inactivity_timeout(). +func (v *Application) SetInactivityTimeout(timeout uint) { + C.g_application_set_inactivity_timeout(v.native(), C.guint(timeout)) +} + +// GetFlags is a wrapper around g_application_get_flags(). +func (v *Application) GetFlags() ApplicationFlags { + return ApplicationFlags(C.g_application_get_flags(v.native())) +} + +// SetFlags is a wrapper around g_application_set_flags(). +func (v *Application) SetFlags(flags ApplicationFlags) { + C.g_application_set_flags(v.native(), C.GApplicationFlags(flags)) +} + +// Only available in GLib 2.42+ +// // GetResourceBasePath is a wrapper around g_application_get_resource_base_path(). +// func (v *Application) GetResourceBasePath() string { +// c := C.g_application_get_resource_base_path(v.native()) + +// return C.GoString((*C.char)(c)) +// } + +// Only available in GLib 2.42+ +// // SetResourceBasePath is a wrapper around g_application_set_resource_base_path(). +// func (v *Application) SetResourceBasePath(bp string) { +// cstr1 := (*C.gchar)(C.CString(bp)) +// defer C.free(unsafe.Pointer(cstr1)) + +// C.g_application_set_resource_base_path(v.native(), cstr1) +// } + +// GetDbusObjectPath is a wrapper around g_application_get_dbus_object_path(). +func (v *Application) GetDbusObjectPath() string { + c := C.g_application_get_dbus_object_path(v.native()) + + return C.GoString((*C.char)(c)) +} + +// GetIsRegistered is a wrapper around g_application_get_is_registered(). +func (v *Application) GetIsRegistered() bool { + return gobool(C.g_application_get_is_registered(v.native())) +} + +// GetIsRemote is a wrapper around g_application_get_is_remote(). +func (v *Application) GetIsRemote() bool { + return gobool(C.g_application_get_is_remote(v.native())) +} + +// Hold is a wrapper around g_application_hold(). +func (v *Application) Hold() { + C.g_application_hold(v.native()) +} + +// Release is a wrapper around g_application_release(). +func (v *Application) Release() { + C.g_application_release(v.native()) +} + +// Quit is a wrapper around g_application_quit(). +func (v *Application) Quit() { + C.g_application_quit(v.native()) +} + +// Activate is a wrapper around g_application_activate(). +func (v *Application) Activate() { + C.g_application_activate(v.native()) +} + +// SendNotification is a wrapper around g_application_send_notification(). +func (v *Application) SendNotification(id string, notification *Notification) { + cstr1 := (*C.gchar)(C.CString(id)) + defer C.free(unsafe.Pointer(cstr1)) + + C.g_application_send_notification(v.native(), cstr1, notification.native()) +} + +// WithdrawNotification is a wrapper around g_application_withdraw_notification(). +func (v *Application) WithdrawNotification(id string) { + cstr1 := (*C.gchar)(C.CString(id)) + defer C.free(unsafe.Pointer(cstr1)) + + C.g_application_withdraw_notification(v.native(), cstr1) +} + +// SetDefault is a wrapper around g_application_set_default(). +func (v *Application) SetDefault() { + C.g_application_set_default(v.native()) +} + +// ApplicationGetDefault is a wrapper around g_application_get_default(). +func ApplicationGetDefault() *Application { + c := C.g_application_get_default() + if c == nil { + return nil + } + return wrapApplication(wrapObject(unsafe.Pointer(c))) +} + +// MarkBusy is a wrapper around g_application_mark_busy(). +func (v *Application) MarkBusy() { + C.g_application_mark_busy(v.native()) +} + +// UnmarkBusy is a wrapper around g_application_unmark_busy(). +func (v *Application) UnmarkBusy() { + C.g_application_unmark_busy(v.native()) +} + +// Run is a wrapper around g_application_run(). +func (v *Application) Run(args []string) int { + cargs := C.make_strings(C.int(len(args))) + defer C.destroy_strings(cargs) + + for i, arg := range args { + cstr := C.CString(arg) + defer C.free(unsafe.Pointer(cstr)) + C.set_string(cargs, C.int(i), (*C.char)(cstr)) + } + + C.set_string(cargs, C.int(len(args)), nil) + + return int(C.g_application_run(v.native(), C.int(len(args)), cargs)) +} + +// Only available in GLib 2.44+ +// // GetIsBusy is a wrapper around g_application_get_is_busy(). +// func (v *Application) GetIsBusy() bool { +// return gobool(C.g_application_get_is_busy(v.native())) +// } + +// void g_application_bind_busy_property () +// void g_application_unbind_busy_property () +// gboolean g_application_register () // requires GCancellable +// void g_application_set_action_group () // Deprecated since 2.32 +// GDBusConnection * g_application_get_dbus_connection () // No support for GDBusConnection +// void g_application_open () // Needs GFile +// void g_application_add_main_option_entries () //Needs GOptionEntry +// void g_application_add_main_option () //Needs GOptionFlags and GOptionArg +// void g_application_add_option_group () // Needs GOptionGroup diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/connect.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/connect.go new file mode 100644 index 0000000..ffa1e44 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/connect.go @@ -0,0 +1,117 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #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() +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go new file mode 100644 index 0000000..26e98f8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go @@ -0,0 +1,1335 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 glib provides Go bindings for GLib 2. Supports version 2.36 +// and later. +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0 +// #include +// #include +// #include +// #include "glib.go.h" +import "C" +import ( + "errors" + "fmt" + "os" + "reflect" + "runtime" + "sync" + "unsafe" +) + +/* + * Type conversions + */ + +func gbool(b bool) C.gboolean { + if b { + return C.gboolean(1) + } + return C.gboolean(0) +} +func gobool(b C.gboolean) bool { + if b != 0 { + return true + } + return false +} + +/* + * Unexported vars + */ + +type closureContext struct { + rf reflect.Value + userData reflect.Value +} + +var ( + errNilPtr = errors.New("cgo returned unexpected nil pointer") + + closures = struct { + sync.RWMutex + m map[*C.GClosure]closureContext + }{ + m: make(map[*C.GClosure]closureContext), + } + + signals = make(map[SignalHandle]*C.GClosure) +) + +/* + * Constants + */ + +// Type is a representation of GLib's GType. +type Type uint + +const ( + TYPE_INVALID Type = C.G_TYPE_INVALID + TYPE_NONE Type = C.G_TYPE_NONE + TYPE_INTERFACE Type = C.G_TYPE_INTERFACE + TYPE_CHAR Type = C.G_TYPE_CHAR + TYPE_UCHAR Type = C.G_TYPE_UCHAR + TYPE_BOOLEAN Type = C.G_TYPE_BOOLEAN + TYPE_INT Type = C.G_TYPE_INT + TYPE_UINT Type = C.G_TYPE_UINT + TYPE_LONG Type = C.G_TYPE_LONG + TYPE_ULONG Type = C.G_TYPE_ULONG + TYPE_INT64 Type = C.G_TYPE_INT64 + TYPE_UINT64 Type = C.G_TYPE_UINT64 + TYPE_ENUM Type = C.G_TYPE_ENUM + TYPE_FLAGS Type = C.G_TYPE_FLAGS + TYPE_FLOAT Type = C.G_TYPE_FLOAT + TYPE_DOUBLE Type = C.G_TYPE_DOUBLE + TYPE_STRING Type = C.G_TYPE_STRING + TYPE_POINTER Type = C.G_TYPE_POINTER + TYPE_BOXED Type = C.G_TYPE_BOXED + TYPE_PARAM Type = C.G_TYPE_PARAM + TYPE_OBJECT Type = C.G_TYPE_OBJECT + TYPE_VARIANT Type = C.G_TYPE_VARIANT +) + +// Name is a wrapper around g_type_name(). +func (t Type) Name() string { + return C.GoString((*C.char)(C.g_type_name(C.GType(t)))) +} + +// Depth is a wrapper around g_type_depth(). +func (t Type) Depth() uint { + return uint(C.g_type_depth(C.GType(t))) +} + +// Parent is a wrapper around g_type_parent(). +func (t Type) Parent() Type { + return Type(C.g_type_parent(C.GType(t))) +} + +// UserDirectory is a representation of GLib's GUserDirectory. +type UserDirectory int + +const ( + USER_DIRECTORY_DESKTOP UserDirectory = C.G_USER_DIRECTORY_DESKTOP + USER_DIRECTORY_DOCUMENTS UserDirectory = C.G_USER_DIRECTORY_DOCUMENTS + USER_DIRECTORY_DOWNLOAD UserDirectory = C.G_USER_DIRECTORY_DOWNLOAD + USER_DIRECTORY_MUSIC UserDirectory = C.G_USER_DIRECTORY_MUSIC + USER_DIRECTORY_PICTURES UserDirectory = C.G_USER_DIRECTORY_PICTURES + USER_DIRECTORY_PUBLIC_SHARE UserDirectory = C.G_USER_DIRECTORY_PUBLIC_SHARE + USER_DIRECTORY_TEMPLATES UserDirectory = C.G_USER_DIRECTORY_TEMPLATES + USER_DIRECTORY_VIDEOS UserDirectory = C.G_USER_DIRECTORY_VIDEOS +) + +const USER_N_DIRECTORIES int = C.G_USER_N_DIRECTORIES + +/* + * GApplicationFlags + */ + +type ApplicationFlags int + +const ( + APPLICATION_FLAGS_NONE ApplicationFlags = C.G_APPLICATION_FLAGS_NONE + APPLICATION_IS_SERVICE ApplicationFlags = C.G_APPLICATION_IS_SERVICE + APPLICATION_HANDLES_OPEN ApplicationFlags = C.G_APPLICATION_HANDLES_OPEN + APPLICATION_HANDLES_COMMAND_LINE ApplicationFlags = C.G_APPLICATION_HANDLES_COMMAND_LINE + APPLICATION_SEND_ENVIRONMENT ApplicationFlags = C.G_APPLICATION_SEND_ENVIRONMENT + APPLICATION_NON_UNIQUE ApplicationFlags = C.G_APPLICATION_NON_UNIQUE +) + +// goMarshal is called by the GLib runtime when a closure needs to be invoked. +// The closure will be invoked with as many arguments as it can take, from 0 to +// the full amount provided by the call. If the closure asks for more parameters +// than there are to give, a warning is printed to stderr and the closure is +// not run. +// +//export goMarshal +func goMarshal(closure *C.GClosure, retValue *C.GValue, + nParams C.guint, params *C.GValue, + invocationHint C.gpointer, marshalData *C.GValue) { + + // Get the context associated with this callback closure. + closures.RLock() + cc := closures.m[closure] + closures.RUnlock() + + // Get number of parameters passed in. If user data was saved with the + // closure context, increment the total number of parameters. + nGLibParams := int(nParams) + nTotalParams := nGLibParams + if cc.userData.IsValid() { + nTotalParams++ + } + + // Get number of parameters from the callback closure. If this exceeds + // the total number of marshaled parameters, a warning will be printed + // to stderr, and the callback will not be run. + nCbParams := cc.rf.Type().NumIn() + if nCbParams > nTotalParams { + fmt.Fprintf(os.Stderr, + "too many closure args: have %d, max allowed %d\n", + nCbParams, nTotalParams) + return + } + + // Create a slice of reflect.Values as arguments to call the function. + gValues := gValueSlice(params, nCbParams) + args := make([]reflect.Value, 0, nCbParams) + + // Fill beginning of args, up to the minimum of the total number of callback + // parameters and parameters from the glib runtime. + for i := 0; i < nCbParams && i < nGLibParams; i++ { + v := &Value{&gValues[i]} + val, err := v.GoValue() + if err != nil { + fmt.Fprintf(os.Stderr, + "no suitable Go value for arg %d: %v\n", i, err) + return + } + rv := reflect.ValueOf(val) + args = append(args, rv.Convert(cc.rf.Type().In(i))) + } + + // If non-nil user data was passed in and not all args have been set, + // get and set the reflect.Value directly from the GValue. + if cc.userData.IsValid() && len(args) < cap(args) { + args = append(args, cc.userData.Convert(cc.rf.Type().In(nCbParams-1))) + } + + // Call closure with args. If the callback returns one or more + // values, save the GValue equivalent of the first. + rv := cc.rf.Call(args) + if retValue != nil && len(rv) > 0 { + if g, err := GValue(rv[0].Interface()); err != nil { + fmt.Fprintf(os.Stderr, + "cannot save callback return value: %v", err) + } else { + *retValue = *g.native() + } + } +} + +// gValueSlice converts a C array of GValues to a Go slice. +func gValueSlice(values *C.GValue, nValues int) (slice []C.GValue) { + header := (*reflect.SliceHeader)((unsafe.Pointer(&slice))) + header.Cap = nValues + header.Len = nValues + header.Data = uintptr(unsafe.Pointer(values)) + return +} + +/* + * Main event loop + */ + +type SourceHandle uint + +// IdleAdd adds an idle source to the default main event loop +// context. After running once, the source func will be removed +// from the main event loop, unless f returns a single bool true. +// +// This function will cause a panic when f eventually runs if the +// types of args do not match those of f. +func IdleAdd(f interface{}, args ...interface{}) (SourceHandle, error) { + // f must be a func with no parameters. + rf := reflect.ValueOf(f) + if rf.Type().Kind() != reflect.Func { + return 0, errors.New("f is not a function") + } + + // Create an idle source func to be added to the main loop context. + idleSrc := C.g_idle_source_new() + if idleSrc == nil { + return 0, errNilPtr + } + return sourceAttach(idleSrc, rf, args...) +} + +// TimeoutAdd adds an timeout source to the default main event loop +// context. After running once, the source func will be removed +// from the main event loop, unless f returns a single bool true. +// +// This function will cause a panic when f eventually runs if the +// types of args do not match those of f. +// timeout is in milliseconds +func TimeoutAdd(timeout uint, f interface{}, args ...interface{}) (SourceHandle, error) { + // f must be a func with no parameters. + rf := reflect.ValueOf(f) + if rf.Type().Kind() != reflect.Func { + return 0, errors.New("f is not a function") + } + + // Create a timeout source func to be added to the main loop context. + timeoutSrc := C.g_timeout_source_new(C.guint(timeout)) + if timeoutSrc == nil { + return 0, errNilPtr + } + + return sourceAttach(timeoutSrc, rf, args...) +} + +// sourceAttach attaches a source to the default main loop context. +func sourceAttach(src *C.struct__GSource, rf reflect.Value, args ...interface{}) (SourceHandle, error) { + if src == nil { + return 0, errNilPtr + } + + // rf must be a func with no parameters. + if rf.Type().Kind() != reflect.Func { + C.g_source_destroy(src) + return 0, errors.New("rf is not a function") + } + + // Create a new GClosure from f that invalidates itself when + // f returns false. The error is ignored here, as this will + // always be a function. + var closure *C.GClosure + closure, _ = ClosureNew(func() { + // Create a slice of reflect.Values arguments to call the func. + rargs := make([]reflect.Value, len(args)) + for i := range args { + rargs[i] = reflect.ValueOf(args[i]) + } + + // Call func with args. The callback will be removed, unless + // it returns exactly one return value of true. + rv := rf.Call(rargs) + if len(rv) == 1 { + if rv[0].Kind() == reflect.Bool { + if rv[0].Bool() { + return + } + } + } + C.g_closure_invalidate(closure) + C.g_source_destroy(src) + }) + + // Remove closure context when closure is finalized. + C._g_closure_add_finalize_notifier(closure) + + // Set closure to run as a callback when the idle source runs. + C.g_source_set_closure(src, closure) + + // Attach the idle source func to the default main event loop + // context. + cid := C.g_source_attach(src, nil) + return SourceHandle(cid), nil +} + +/* + * Miscellaneous Utility Functions + */ + +// GetUserSpecialDir is a wrapper around g_get_user_special_dir(). A +// non-nil error is returned in the case that g_get_user_special_dir() +// returns NULL to differentiate between NULL and an empty string. +func GetUserSpecialDir(directory UserDirectory) (string, error) { + c := C.g_get_user_special_dir(C.GUserDirectory(directory)) + if c == nil { + return "", errNilPtr + } + return C.GoString((*C.char)(c)), nil +} + +/* + * GObject + */ + +// IObject is an interface type implemented by Object and all types which embed +// an Object. It is meant to be used as a type for function arguments which +// require GObjects or any subclasses thereof. +type IObject interface { + toGObject() *C.GObject + toObject() *Object +} + +// Object is a representation of GLib's GObject. +type Object struct { + GObject *C.GObject +} + +func (v *Object) toGObject() *C.GObject { + if v == nil { + return nil + } + return v.native() +} + +func (v *Object) toObject() *Object { + return v +} + +// newObject creates a new Object from a GObject pointer. +func newObject(p *C.GObject) *Object { + return &Object{GObject: p} +} + +// native returns a pointer to the underlying GObject. +func (v *Object) native() *C.GObject { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGObject(p) +} + +// Native returns a pointer to the underlying GObject. +func (v *Object) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +// IsA is a wrapper around g_type_is_a(). +func (v *Object) IsA(typ Type) bool { + return gobool(C.g_type_is_a(C.GType(v.TypeFromInstance()), C.GType(typ))) +} + +// TypeFromInstance is a wrapper around g_type_from_instance(). +func (v *Object) TypeFromInstance() Type { + c := C._g_type_from_instance(C.gpointer(unsafe.Pointer(v.native()))) + return Type(c) +} + +// ToGObject type converts an unsafe.Pointer as a native C GObject. +// This function is exported for visibility in other gotk3 packages and +// is not meant to be used by applications. +func ToGObject(p unsafe.Pointer) *C.GObject { + return C.toGObject(p) +} + +// Ref is a wrapper around g_object_ref(). +func (v *Object) Ref() { + C.g_object_ref(C.gpointer(v.GObject)) +} + +// Unref is a wrapper around g_object_unref(). +func (v *Object) Unref() { + C.g_object_unref(C.gpointer(v.GObject)) +} + +// RefSink is a wrapper around g_object_ref_sink(). +func (v *Object) RefSink() { + C.g_object_ref_sink(C.gpointer(v.GObject)) +} + +// IsFloating is a wrapper around g_object_is_floating(). +func (v *Object) IsFloating() bool { + c := C.g_object_is_floating(C.gpointer(v.GObject)) + return gobool(c) +} + +// ForceFloating is a wrapper around g_object_force_floating(). +func (v *Object) ForceFloating() { + C.g_object_force_floating(v.GObject) +} + +// StopEmission is a wrapper around g_signal_stop_emission_by_name(). +func (v *Object) StopEmission(s string) { + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + C.g_signal_stop_emission_by_name((C.gpointer)(v.GObject), + (*C.gchar)(cstr)) +} + +// Set is a wrapper around g_object_set(). However, unlike +// g_object_set(), this function only sets one name value pair. Make +// multiple calls to this function to set multiple properties. +func (v *Object) Set(name string, value interface{}) error { + return v.SetProperty(name, value) + /* + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + if _, ok := value.(Object); ok { + value = value.(Object).GObject + } + + // Can't call g_object_set() as it uses a variable arg list, use a + // wrapper instead + var p unsafe.Pointer + switch v := value.(type) { + case bool: + c := gbool(v) + p = unsafe.Pointer(&c) + + case int8: + c := C.gint8(v) + p = unsafe.Pointer(&c) + + case int16: + c := C.gint16(v) + p = unsafe.Pointer(&c) + + case int32: + c := C.gint32(v) + p = unsafe.Pointer(&c) + + case int64: + c := C.gint64(v) + p = unsafe.Pointer(&c) + + case int: + c := C.gint(v) + p = unsafe.Pointer(&c) + + case uint8: + c := C.guchar(v) + p = unsafe.Pointer(&c) + + case uint16: + c := C.guint16(v) + p = unsafe.Pointer(&c) + + case uint32: + c := C.guint32(v) + p = unsafe.Pointer(&c) + + case uint64: + c := C.guint64(v) + p = unsafe.Pointer(&c) + + case uint: + c := C.guint(v) + p = unsafe.Pointer(&c) + + case uintptr: + p = unsafe.Pointer(C.gpointer(v)) + + case float32: + c := C.gfloat(v) + p = unsafe.Pointer(&c) + + case float64: + c := C.gdouble(v) + p = unsafe.Pointer(&c) + + case string: + cstr := C.CString(v) + defer C.g_free(C.gpointer(unsafe.Pointer(cstr))) + p = unsafe.Pointer(&cstr) + + default: + if pv, ok := value.(unsafe.Pointer); ok { + p = pv + } else { + val := reflect.ValueOf(value) + switch val.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + c := C.int(val.Int()) + p = unsafe.Pointer(&c) + + case reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer: + p = unsafe.Pointer(C.gpointer(val.Pointer())) + } + } + } + if p == nil { + return errors.New("Unable to perform type conversion") + } + C._g_object_set_one(C.gpointer(v.GObject), (*C.gchar)(cstr), p) + return nil*/ +} + +// GetPropertyType returns the Type of a property of the underlying GObject. +// If the property is missing it will return TYPE_INVALID and an error. +func (v *Object) GetPropertyType(name string) (Type, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + paramSpec := C.g_object_class_find_property(C._g_object_get_class(v.native()), (*C.gchar)(cstr)) + if paramSpec == nil { + return TYPE_INVALID, errors.New("couldn't find Property") + } + return Type(paramSpec.value_type), nil +} + +// GetProperty is a wrapper around g_object_get_property(). +func (v *Object) GetProperty(name string) (interface{}, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + t, err := v.GetPropertyType(name) + if err != nil { + return nil, err + } + + p, err := ValueInit(t) + if err != nil { + return nil, errors.New("unable to allocate value") + } + C.g_object_get_property(v.GObject, (*C.gchar)(cstr), p.native()) + return p.GoValue() +} + +// SetProperty is a wrapper around g_object_set_property(). +func (v *Object) SetProperty(name string, value interface{}) error { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + if _, ok := value.(Object); ok { + value = value.(Object).GObject + } + + p, err := GValue(value) + if err != nil { + return errors.New("Unable to perform type conversion") + } + C.g_object_set_property(v.GObject, (*C.gchar)(cstr), p.native()) + return nil +} + +// pointerVal attempts to return an unsafe.Pointer for value. +// Not all types are understood, in which case a nil Pointer +// is returned. +/*func pointerVal(value interface{}) unsafe.Pointer { + var p unsafe.Pointer + switch v := value.(type) { + case bool: + c := gbool(v) + p = unsafe.Pointer(&c) + + case int8: + c := C.gint8(v) + p = unsafe.Pointer(&c) + + case int16: + c := C.gint16(v) + p = unsafe.Pointer(&c) + + case int32: + c := C.gint32(v) + p = unsafe.Pointer(&c) + + case int64: + c := C.gint64(v) + p = unsafe.Pointer(&c) + + case int: + c := C.gint(v) + p = unsafe.Pointer(&c) + + case uint8: + c := C.guchar(v) + p = unsafe.Pointer(&c) + + case uint16: + c := C.guint16(v) + p = unsafe.Pointer(&c) + + case uint32: + c := C.guint32(v) + p = unsafe.Pointer(&c) + + case uint64: + c := C.guint64(v) + p = unsafe.Pointer(&c) + + case uint: + c := C.guint(v) + p = unsafe.Pointer(&c) + + case uintptr: + p = unsafe.Pointer(C.gpointer(v)) + + case float32: + c := C.gfloat(v) + p = unsafe.Pointer(&c) + + case float64: + c := C.gdouble(v) + p = unsafe.Pointer(&c) + + case string: + cstr := C.CString(v) + defer C.free(unsafe.Pointer(cstr)) + p = unsafe.Pointer(cstr) + + default: + if pv, ok := value.(unsafe.Pointer); ok { + p = pv + } else { + val := reflect.ValueOf(value) + switch val.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + c := C.int(val.Int()) + p = unsafe.Pointer(&c) + + case reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer: + p = unsafe.Pointer(C.gpointer(val.Pointer())) + } + } + } + + return p +}*/ + +/* + * GObject Signals + */ + +// Emit is a wrapper around g_signal_emitv() and emits the signal +// specified by the string s to an Object. Arguments to callback +// functions connected to this signal must be specified in args. Emit() +// returns an interface{} which must be type asserted as the Go +// equivalent type to the return value for native C callback. +// +// Note that this code is unsafe in that the types of values in args are +// not checked against whether they are suitable for the callback. +func (v *Object) Emit(s string, args ...interface{}) (interface{}, error) { + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + + // Create array of this instance and arguments + valv := C.alloc_gvalue_list(C.int(len(args)) + 1) + defer C.free(unsafe.Pointer(valv)) + + // Add args and valv + val, err := GValue(v) + if err != nil { + return nil, errors.New("Error converting Object to GValue: " + err.Error()) + } + C.val_list_insert(valv, C.int(0), val.native()) + for i := range args { + val, err := GValue(args[i]) + if err != nil { + return nil, fmt.Errorf("Error converting arg %d to GValue: %s", i, err.Error()) + } + C.val_list_insert(valv, C.int(i+1), val.native()) + } + + t := v.TypeFromInstance() + // TODO: use just the signal name + id := C.g_signal_lookup((*C.gchar)(cstr), C.GType(t)) + + ret, err := ValueAlloc() + if err != nil { + return nil, errors.New("Error creating Value for return value") + } + C.g_signal_emitv(valv, id, C.GQuark(0), ret.native()) + + return ret.GoValue() +} + +// HandlerBlock is a wrapper around g_signal_handler_block(). +func (v *Object) HandlerBlock(handle SignalHandle) { + C.g_signal_handler_block(C.gpointer(v.GObject), C.gulong(handle)) +} + +// HandlerUnblock is a wrapper around g_signal_handler_unblock(). +func (v *Object) HandlerUnblock(handle SignalHandle) { + C.g_signal_handler_unblock(C.gpointer(v.GObject), C.gulong(handle)) +} + +// HandlerDisconnect is a wrapper around g_signal_handler_disconnect(). +func (v *Object) HandlerDisconnect(handle SignalHandle) { + C.g_signal_handler_disconnect(C.gpointer(v.GObject), C.gulong(handle)) + C.g_closure_invalidate(signals[handle]) + delete(closures.m, signals[handle]) + delete(signals, handle) +} + +// Wrapper function for new objects with reference management. +func wrapObject(ptr unsafe.Pointer) *Object { + obj := &Object{ToGObject(ptr)} + + if obj.IsFloating() { + obj.RefSink() + } else { + obj.Ref() + } + + runtime.SetFinalizer(obj, (*Object).Unref) + return obj +} + +/* + * GInitiallyUnowned + */ + +// InitiallyUnowned is a representation of GLib's GInitiallyUnowned. +type InitiallyUnowned struct { + // This must be a pointer so copies of the ref-sinked object + // do not outlive the original object, causing an unref + // finalizer to prematurely run. + *Object +} + +// Native returns a pointer to the underlying GObject. This is implemented +// here rather than calling Native on the embedded Object to prevent a nil +// pointer dereference. +func (v *InitiallyUnowned) Native() uintptr { + if v == nil || v.Object == nil { + return uintptr(unsafe.Pointer(nil)) + } + return v.Object.Native() +} + +/* + * GValue + */ + +// Value is a representation of GLib's GValue. +// +// Don't allocate Values on the stack or heap manually as they may not +// be properly unset when going out of scope. Instead, use ValueAlloc(), +// which will set the runtime finalizer to unset the Value after it has +// left scope. +type Value struct { + GValue *C.GValue +} + +// native returns a pointer to the underlying GValue. +func (v *Value) native() *C.GValue { + return v.GValue +} + +// Native returns a pointer to the underlying GValue. +func (v *Value) Native() unsafe.Pointer { + return unsafe.Pointer(v.native()) +} + +// ValueAlloc allocates a Value and sets a runtime finalizer to call +// g_value_unset() on the underlying GValue after leaving scope. +// ValueAlloc() returns a non-nil error if the allocation failed. +func ValueAlloc() (*Value, error) { + c := C._g_value_alloc() + if c == nil { + return nil, errNilPtr + } + + v := &Value{c} + + //An allocated GValue is not guaranteed to hold a value that can be unset + //We need to double check before unsetting, to prevent: + //`g_value_unset: assertion 'G_IS_VALUE (value)' failed` + runtime.SetFinalizer(v, func(f *Value) { + if t, _, err := f.Type(); err != nil || t == TYPE_INVALID || t == TYPE_NONE { + C.g_free(C.gpointer(f.native())) + return + } + + f.unset() + }) + + return v, nil +} + +// ValueInit is a wrapper around g_value_init() and allocates and +// initializes a new Value with the Type t. A runtime finalizer is set +// to call g_value_unset() on the underlying GValue after leaving scope. +// ValueInit() returns a non-nil error if the allocation failed. +func ValueInit(t Type) (*Value, error) { + c := C._g_value_init(C.GType(t)) + if c == nil { + return nil, errNilPtr + } + + v := &Value{c} + + runtime.SetFinalizer(v, (*Value).unset) + return v, nil +} + +// ValueFromNative returns a type-asserted pointer to the Value. +func ValueFromNative(l unsafe.Pointer) *Value { + //TODO why it does not add finalizer to the value? + return &Value{(*C.GValue)(l)} +} + +func (v *Value) unset() { + C.g_value_unset(v.native()) +} + +// Type is a wrapper around the G_VALUE_HOLDS_GTYPE() macro and +// the g_value_get_gtype() function. GetType() returns TYPE_INVALID if v +// does not hold a Type, or otherwise returns the Type of v. +func (v *Value) Type() (actual Type, fundamental Type, err error) { + if !gobool(C._g_is_value(v.native())) { + return actual, fundamental, errors.New("invalid GValue") + } + cActual := C._g_value_type(v.native()) + cFundamental := C._g_value_fundamental(cActual) + return Type(cActual), Type(cFundamental), nil +} + +// GValue converts a Go type to a comparable GValue. GValue() +// returns a non-nil error if the conversion was unsuccessful. +func GValue(v interface{}) (gvalue *Value, err error) { + if v == nil { + val, err := ValueInit(TYPE_POINTER) + if err != nil { + return nil, err + } + val.SetPointer(uintptr(unsafe.Pointer(nil))) + return val, nil + } + + switch e := v.(type) { + case bool: + val, err := ValueInit(TYPE_BOOLEAN) + if err != nil { + return nil, err + } + val.SetBool(e) + return val, nil + + case int8: + val, err := ValueInit(TYPE_CHAR) + if err != nil { + return nil, err + } + val.SetSChar(e) + return val, nil + + case int64: + val, err := ValueInit(TYPE_INT64) + if err != nil { + return nil, err + } + val.SetInt64(e) + return val, nil + + case int: + val, err := ValueInit(TYPE_INT) + if err != nil { + return nil, err + } + val.SetInt(e) + return val, nil + + case uint8: + val, err := ValueInit(TYPE_UCHAR) + if err != nil { + return nil, err + } + val.SetUChar(e) + return val, nil + + case uint64: + val, err := ValueInit(TYPE_UINT64) + if err != nil { + return nil, err + } + val.SetUInt64(e) + return val, nil + + case uint: + val, err := ValueInit(TYPE_UINT) + if err != nil { + return nil, err + } + val.SetUInt(e) + return val, nil + + case float32: + val, err := ValueInit(TYPE_FLOAT) + if err != nil { + return nil, err + } + val.SetFloat(e) + return val, nil + + case float64: + val, err := ValueInit(TYPE_DOUBLE) + if err != nil { + return nil, err + } + val.SetDouble(e) + return val, nil + + case string: + val, err := ValueInit(TYPE_STRING) + if err != nil { + return nil, err + } + val.SetString(e) + return val, nil + + case *Object: + val, err := ValueInit(TYPE_OBJECT) + if err != nil { + return nil, err + } + val.SetInstance(uintptr(unsafe.Pointer(e.GObject))) + return val, nil + + default: + /* Try this since above doesn't catch constants under other types */ + rval := reflect.ValueOf(v) + switch rval.Kind() { + case reflect.Int8: + val, err := ValueInit(TYPE_CHAR) + if err != nil { + return nil, err + } + val.SetSChar(int8(rval.Int())) + return val, nil + + case reflect.Int16: + return nil, errors.New("Type not implemented") + + case reflect.Int32: + return nil, errors.New("Type not implemented") + + case reflect.Int64: + val, err := ValueInit(TYPE_INT64) + if err != nil { + return nil, err + } + val.SetInt64(rval.Int()) + return val, nil + + case reflect.Int: + val, err := ValueInit(TYPE_INT) + if err != nil { + return nil, err + } + val.SetInt(int(rval.Int())) + return val, nil + + case reflect.Uintptr, reflect.Ptr: + val, err := ValueInit(TYPE_POINTER) + if err != nil { + return nil, err + } + val.SetPointer(rval.Pointer()) + return val, nil + } + } + + return nil, errors.New("Type not implemented") +} + +// GValueMarshaler is a marshal function to convert a GValue into an +// appropiate Go type. The uintptr parameter is a *C.GValue. +type GValueMarshaler func(uintptr) (interface{}, error) + +// TypeMarshaler represents an actual type and it's associated marshaler. +type TypeMarshaler struct { + T Type + F GValueMarshaler +} + +// RegisterGValueMarshalers adds marshalers for several types to the +// internal marshalers map. Once registered, calling GoValue on any +// Value witha registered type will return the data returned by the +// marshaler. +func RegisterGValueMarshalers(tm []TypeMarshaler) { + gValueMarshalers.register(tm) +} + +type marshalMap map[Type]GValueMarshaler + +// gValueMarshalers is a map of Glib types to functions to marshal a +// GValue to a native Go type. +var gValueMarshalers = marshalMap{ + TYPE_INVALID: marshalInvalid, + TYPE_NONE: marshalNone, + TYPE_INTERFACE: marshalInterface, + TYPE_CHAR: marshalChar, + TYPE_UCHAR: marshalUchar, + TYPE_BOOLEAN: marshalBoolean, + TYPE_INT: marshalInt, + TYPE_LONG: marshalLong, + TYPE_ENUM: marshalEnum, + TYPE_INT64: marshalInt64, + TYPE_UINT: marshalUint, + TYPE_ULONG: marshalUlong, + TYPE_FLAGS: marshalFlags, + TYPE_UINT64: marshalUint64, + TYPE_FLOAT: marshalFloat, + TYPE_DOUBLE: marshalDouble, + TYPE_STRING: marshalString, + TYPE_POINTER: marshalPointer, + TYPE_BOXED: marshalBoxed, + TYPE_OBJECT: marshalObject, + TYPE_VARIANT: marshalVariant, +} + +func (m marshalMap) register(tm []TypeMarshaler) { + for i := range tm { + m[tm[i].T] = tm[i].F + } +} + +func (m marshalMap) lookup(v *Value) (GValueMarshaler, error) { + actual, fundamental, err := v.Type() + if err != nil { + return nil, err + } + + if f, ok := m[actual]; ok { + return f, nil + } + if f, ok := m[fundamental]; ok { + return f, nil + } + return nil, errors.New("missing marshaler for type") +} + +func marshalInvalid(uintptr) (interface{}, error) { + return nil, errors.New("invalid type") +} + +func marshalNone(uintptr) (interface{}, error) { + return nil, nil +} + +func marshalInterface(uintptr) (interface{}, error) { + return nil, errors.New("interface conversion not yet implemented") +} + +func marshalChar(p uintptr) (interface{}, error) { + c := C.g_value_get_schar((*C.GValue)(unsafe.Pointer(p))) + return int8(c), nil +} + +func marshalUchar(p uintptr) (interface{}, error) { + c := C.g_value_get_uchar((*C.GValue)(unsafe.Pointer(p))) + return uint8(c), nil +} + +func marshalBoolean(p uintptr) (interface{}, error) { + c := C.g_value_get_boolean((*C.GValue)(unsafe.Pointer(p))) + return gobool(c), nil +} + +func marshalInt(p uintptr) (interface{}, error) { + c := C.g_value_get_int((*C.GValue)(unsafe.Pointer(p))) + return int(c), nil +} + +func marshalLong(p uintptr) (interface{}, error) { + c := C.g_value_get_long((*C.GValue)(unsafe.Pointer(p))) + return int(c), nil +} + +func marshalEnum(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return int(c), nil +} + +func marshalInt64(p uintptr) (interface{}, error) { + c := C.g_value_get_int64((*C.GValue)(unsafe.Pointer(p))) + return int64(c), nil +} + +func marshalUint(p uintptr) (interface{}, error) { + c := C.g_value_get_uint((*C.GValue)(unsafe.Pointer(p))) + return uint(c), nil +} + +func marshalUlong(p uintptr) (interface{}, error) { + c := C.g_value_get_ulong((*C.GValue)(unsafe.Pointer(p))) + return uint(c), nil +} + +func marshalFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_flags((*C.GValue)(unsafe.Pointer(p))) + return uint(c), nil +} + +func marshalUint64(p uintptr) (interface{}, error) { + c := C.g_value_get_uint64((*C.GValue)(unsafe.Pointer(p))) + return uint64(c), nil +} + +func marshalFloat(p uintptr) (interface{}, error) { + c := C.g_value_get_float((*C.GValue)(unsafe.Pointer(p))) + return float32(c), nil +} + +func marshalDouble(p uintptr) (interface{}, error) { + c := C.g_value_get_double((*C.GValue)(unsafe.Pointer(p))) + return float64(c), nil +} + +func marshalString(p uintptr) (interface{}, error) { + c := C.g_value_get_string((*C.GValue)(unsafe.Pointer(p))) + return C.GoString((*C.char)(c)), nil +} + +func marshalBoxed(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return uintptr(unsafe.Pointer(c)), nil +} + +func marshalPointer(p uintptr) (interface{}, error) { + c := C.g_value_get_pointer((*C.GValue)(unsafe.Pointer(p))) + return unsafe.Pointer(c), nil +} + +func marshalObject(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + return newObject((*C.GObject)(c)), nil +} + +func marshalVariant(p uintptr) (interface{}, error) { + return nil, errors.New("variant conversion not yet implemented") +} + +// GoValue converts a Value to comparable Go type. GoValue() +// returns a non-nil error if the conversion was unsuccessful. The +// returned interface{} must be type asserted as the actual Go +// representation of the Value. +// +// This function is a wrapper around the many g_value_get_*() +// functions, depending on the type of the Value. +func (v *Value) GoValue() (interface{}, error) { + f, err := gValueMarshalers.lookup(v) + if err != nil { + return nil, err + } + + //No need to add finalizer because it is already done by ValueAlloc and ValueInit + rv, err := f(uintptr(unsafe.Pointer(v.native()))) + return rv, err +} + +// SetBool is a wrapper around g_value_set_boolean(). +func (v *Value) SetBool(val bool) { + C.g_value_set_boolean(v.native(), gbool(val)) +} + +// SetSChar is a wrapper around g_value_set_schar(). +func (v *Value) SetSChar(val int8) { + C.g_value_set_schar(v.native(), C.gint8(val)) +} + +// SetInt64 is a wrapper around g_value_set_int64(). +func (v *Value) SetInt64(val int64) { + C.g_value_set_int64(v.native(), C.gint64(val)) +} + +// SetInt is a wrapper around g_value_set_int(). +func (v *Value) SetInt(val int) { + C.g_value_set_int(v.native(), C.gint(val)) +} + +// SetUChar is a wrapper around g_value_set_uchar(). +func (v *Value) SetUChar(val uint8) { + C.g_value_set_uchar(v.native(), C.guchar(val)) +} + +// SetUInt64 is a wrapper around g_value_set_uint64(). +func (v *Value) SetUInt64(val uint64) { + C.g_value_set_uint64(v.native(), C.guint64(val)) +} + +// SetUInt is a wrapper around g_value_set_uint(). +func (v *Value) SetUInt(val uint) { + C.g_value_set_uint(v.native(), C.guint(val)) +} + +// SetFloat is a wrapper around g_value_set_float(). +func (v *Value) SetFloat(val float32) { + C.g_value_set_float(v.native(), C.gfloat(val)) +} + +// SetDouble is a wrapper around g_value_set_double(). +func (v *Value) SetDouble(val float64) { + C.g_value_set_double(v.native(), C.gdouble(val)) +} + +// SetString is a wrapper around g_value_set_string(). +func (v *Value) SetString(val string) { + cstr := C.CString(val) + defer C.free(unsafe.Pointer(cstr)) + C.g_value_set_string(v.native(), (*C.gchar)(cstr)) +} + +// SetInstance is a wrapper around g_value_set_instance(). +func (v *Value) SetInstance(instance uintptr) { + C.g_value_set_instance(v.native(), C.gpointer(instance)) +} + +// SetPointer is a wrapper around g_value_set_pointer(). +func (v *Value) SetPointer(p uintptr) { + C.g_value_set_pointer(v.native(), C.gpointer(p)) +} + +// GetPointer is a wrapper around g_value_get_pointer(). +func (v *Value) GetPointer() unsafe.Pointer { + return unsafe.Pointer(C.g_value_get_pointer(v.native())) +} + +// GetString is a wrapper around g_value_get_string(). GetString() +// returns a non-nil error if g_value_get_string() returned a NULL +// pointer to distinguish between returning a NULL pointer and returning +// an empty string. +func (v *Value) GetString() (string, error) { + c := C.g_value_get_string(v.native()) + if c == nil { + return "", errNilPtr + } + return C.GoString((*C.char)(c)), nil +} + +type Signal struct { + name string + signalId C.guint +} + +func SignalNew(s string) (*Signal, error) { + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + + signalId := C._g_signal_new((*C.gchar)(cstr)) + + if signalId == 0 { + return nil, fmt.Errorf("invalid signal name: %s", s) + } + + return &Signal{ + name: s, + signalId: signalId, + }, nil +} + +func (s *Signal) String() string { + return s.name +} + +type Quark uint32 + +// GetApplicationName is a wrapper around g_get_application_name(). +func GetApplicationName() string { + c := C.g_get_application_name() + + return C.GoString((*C.char)(c)) +} + +// SetApplicationName is a wrapper around g_set_application_name(). +func SetApplicationName(name string) { + cstr := (*C.gchar)(C.CString(name)) + defer C.free(unsafe.Pointer(cstr)) + + C.g_set_application_name(cstr) +} + +// InitI18n initializes the i18n subsystem. +func InitI18n(domain string, dir string) { + domainStr := C.CString(domain) + defer C.free(unsafe.Pointer(domainStr)) + + dirStr := C.CString(dir) + defer C.free(unsafe.Pointer(dirStr)) + + C.init_i18n(domainStr, dirStr) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go.h new file mode 100644 index 0000000..40dea65 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib.go.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * 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 +#include +#include + +#include +#include +#include +#include +#include + +/* 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 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 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; +} + +#endif diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib_extension.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib_extension.go new file mode 100644 index 0000000..2d5b1ea --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/glib_extension.go @@ -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 +) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go new file mode 100644 index 0000000..34909ae --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go @@ -0,0 +1,186 @@ +//GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +// #include "gvariant.go.h" +//import "C" +//import "unsafe" + +/* + * GVariant + */ + +// IVariant is an interface type implemented by Variant and all types which embed +// an Variant. It is meant to be used as a type for function arguments which +// require GVariants or any subclasses thereof. +/* todo fix bugs +type IVariant interface { + ToGVariant() *C.GVariant + ToVariant() *Variant +} + +// Variant is a representation of GLib's GVariant. +type Variant struct { + GVariant *C.GVariant +} + +func (v *Variant) ToGVariant() *C.GVariant { + if v == nil { + return nil + } + return v.native() +} + +func (v *Variant) ToVariant() *Variant { + return v +} + +// newVariant creates a new Variant from a GVariant pointer. +func newVariant(p *C.GVariant) *Variant { + return &Variant{GVariant: p} +} + +func VariantFromUnsafePointer(p unsafe.Pointer) *Variant { + return &Variant{C.toGVariant(p)} +} + +// native returns a pointer to the underlying GVariant. +func (v *Variant) native() *C.GVariant { + if v == nil || v.GVariant == nil { + return nil + } + p := unsafe.Pointer(v.GVariant) + return C.toGVariant(p) +} + +// Native returns a pointer to the underlying GVariant. +func (v *Variant) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} +*/ + +//void g_variant_unref () +//GVariant * g_variant_ref () +//GVariant * g_variant_ref_sink () +//gboolean g_variant_is_floating () +//GVariant * g_variant_take_ref () +//const GVariantType * g_variant_get_type () +//const gchar * g_variant_get_type_string () +//gboolean g_variant_is_of_type () +//gboolean g_variant_is_container () +//gint g_variant_compare () +//GVariantClass g_variant_classify () +//gboolean g_variant_check_format_string () +//void g_variant_get () +//void g_variant_get_va () +//GVariant * g_variant_new () +//GVariant * g_variant_new_va () +//GVariant * g_variant_new_boolean () +//GVariant * g_variant_new_byte () +//GVariant * g_variant_new_int16 () +//GVariant * g_variant_new_uint16 () +//GVariant * g_variant_new_int32 () +//GVariant * g_variant_new_uint32 () +//GVariant * g_variant_new_int64 () +//GVariant * g_variant_new_uint64 () +//GVariant * g_variant_new_handle () +//GVariant * g_variant_new_double () +//GVariant * g_variant_new_string () +//GVariant * g_variant_new_take_string () +//GVariant * g_variant_new_printf () +//GVariant * g_variant_new_object_path () +//gboolean g_variant_is_object_path () +//GVariant * g_variant_new_signature () +//gboolean g_variant_is_signature () +//GVariant * g_variant_new_variant () +//GVariant * g_variant_new_strv () +//GVariant * g_variant_new_objv () +//GVariant * g_variant_new_bytestring () +//GVariant * g_variant_new_bytestring_array () +//gboolean g_variant_get_boolean () +//guchar g_variant_get_byte () +//gint16 g_variant_get_int16 () +//guint16 g_variant_get_uint16 () +//gint32 g_variant_get_int32 () +//guint32 g_variant_get_uint32 () +//gint64 g_variant_get_int64 () +//guint64 g_variant_get_uint64 () +//gint32 g_variant_get_handle () +//gdouble g_variant_get_double () +//const gchar * g_variant_get_string () +//gchar * g_variant_dup_string () +//GVariant * g_variant_get_variant () +//const gchar ** g_variant_get_strv () +//gchar ** g_variant_dup_strv () +//const gchar ** g_variant_get_objv () +//gchar ** g_variant_dup_objv () +//const gchar * g_variant_get_bytestring () +//gchar * g_variant_dup_bytestring () +//const gchar ** g_variant_get_bytestring_array () +//gchar ** g_variant_dup_bytestring_array () +//GVariant * g_variant_new_maybe () +//GVariant * g_variant_new_array () +//GVariant * g_variant_new_tuple () +//GVariant * g_variant_new_dict_entry () +//GVariant * g_variant_new_fixed_array () +//GVariant * g_variant_get_maybe () +//gsize g_variant_n_children () +//GVariant * g_variant_get_child_value () +//void g_variant_get_child () +//GVariant * g_variant_lookup_value () +//gboolean g_variant_lookup () +//gconstpointer g_variant_get_fixed_array () +//gsize g_variant_get_size () +//gconstpointer g_variant_get_data () +//GBytes * g_variant_get_data_as_bytes () +//void g_variant_store () +//GVariant * g_variant_new_from_data () +//GVariant * g_variant_new_from_bytes () +//GVariant * g_variant_byteswap () +//GVariant * g_variant_get_normal_form () +//gboolean g_variant_is_normal_form () +//guint g_variant_hash () +//gboolean g_variant_equal () +//gchar * g_variant_print () +//GString * g_variant_print_string () +//GVariantIter * g_variant_iter_copy () +//void g_variant_iter_free () +//gsize g_variant_iter_init () +//gsize g_variant_iter_n_children () +//GVariantIter * g_variant_iter_new () +//GVariant * g_variant_iter_next_value () +//gboolean g_variant_iter_next () +//gboolean g_variant_iter_loop () +//void g_variant_builder_unref () +//GVariantBuilder * g_variant_builder_ref () +//GVariantBuilder * g_variant_builder_new () +//void g_variant_builder_init () +//void g_variant_builder_clear () +//void g_variant_builder_add_value () +//void g_variant_builder_add () +//void g_variant_builder_add_parsed () +//GVariant * g_variant_builder_end () +//void g_variant_builder_open () +//void g_variant_builder_close () +//void g_variant_dict_unref () +//GVariantDict * g_variant_dict_ref () +//GVariantDict * g_variant_dict_new () +//void g_variant_dict_init () +//void g_variant_dict_clear () +//gboolean g_variant_dict_contains () +//gboolean g_variant_dict_lookup () +//GVariant * g_variant_dict_lookup_value () +//void g_variant_dict_insert () +//void g_variant_dict_insert_value () +//gboolean g_variant_dict_remove () +//GVariant * g_variant_dict_end () +//#define G_VARIANT_PARSE_ERROR +//GVariant * g_variant_parse () +//GVariant * g_variant_new_parsed_va () +//GVariant * g_variant_new_parsed () +//gchar * g_variant_parse_error_print_context () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go.h new file mode 100644 index 0000000..8f535c5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariant.go.h @@ -0,0 +1,41 @@ +// Same copyright and license as the rest of the files in this project + +//GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +/* todo fix bugs +#ifndef __GVARIANT_GO_H__ +#define __GVARIANT_GO_H__ + +#include +#include +#include +#include + +// 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 +*/ \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantbuilder.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantbuilder.go new file mode 100644 index 0000000..c7ef854 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantbuilder.go @@ -0,0 +1,54 @@ +// Same copyright and license as the rest of the files in this project + +// GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +// #include "gvariant.go.h" +//import "C" +//import "unsafe" + +/* + * GVariantBuilder + */ +/* todo fix bugs +// VariantBuilder is a representation of GLib's VariantBuilder. +type VariantBuilder struct { + GVariantBuilder *C.GVariantBuilder +} + +func (v *VariantBuilder) toGVariantBuilder() *C.GVariantBuilder { + if v == nil { + return nil + } + return v.native() +} + +func (v *VariantBuilder) toVariantBuilder() *VariantBuilder { + return v +} + +// newVariantBuilder creates a new VariantBuilder from a GVariantBuilder pointer. +func newVariantBuilder(p *C.GVariantBuilder) *VariantBuilder { + return &VariantBuilder{GVariantBuilder: p} +} + +// native returns a pointer to the underlying GVariantBuilder. +func (v *VariantBuilder) native() *C.GVariantBuilder { + if v == nil || v.GVariantBuilder == nil { + return nil + } + p := unsafe.Pointer(v.GVariantBuilder) + return C.toGVariantBuilder(p) +} + +// Native returns a pointer to the underlying GVariantBuilder. +func (v *VariantBuilder) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} +*/ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantclass.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantclass.go new file mode 100644 index 0000000..be6a237 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantclass.go @@ -0,0 +1,39 @@ +// Same copyright and license as the rest of the files in this project + +//GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +import "C" + +/* + * GVariantClass + */ + +type VariantClass int + +const ( + VARIANT_CLASS_BOOLEAN VariantClass = C.G_VARIANT_CLASS_BOOLEAN //The GVariant is a boolean. + VARIANT_CLASS_BYTE VariantClass = C.G_VARIANT_CLASS_BYTE //The GVariant is a byte. + VARIANT_CLASS_INT16 VariantClass = C.G_VARIANT_CLASS_INT16 //The GVariant is a signed 16 bit integer. + VARIANT_CLASS_UINT16 VariantClass = C.G_VARIANT_CLASS_UINT16 //The GVariant is an unsigned 16 bit integer. + VARIANT_CLASS_INT32 VariantClass = C.G_VARIANT_CLASS_INT32 //The GVariant is a signed 32 bit integer. + VARIANT_CLASS_UINT32 VariantClass = C.G_VARIANT_CLASS_UINT32 //The GVariant is an unsigned 32 bit integer. + VARIANT_CLASS_INT64 VariantClass = C.G_VARIANT_CLASS_INT64 //The GVariant is a signed 64 bit integer. + VARIANT_CLASS_UINT64 VariantClass = C.G_VARIANT_CLASS_UINT64 //The GVariant is an unsigned 64 bit integer. + VARIANT_CLASS_HANDLE VariantClass = C.G_VARIANT_CLASS_HANDLE //The GVariant is a file handle index. + VARIANT_CLASS_DOUBLE VariantClass = C.G_VARIANT_CLASS_DOUBLE //The GVariant is a double precision floating point value. + VARIANT_CLASS_STRING VariantClass = C.G_VARIANT_CLASS_STRING //The GVariant is a normal string. + VARIANT_CLASS_OBJECT_PATH VariantClass = C.G_VARIANT_CLASS_OBJECT_PATH //The GVariant is a D-Bus object path string. + VARIANT_CLASS_SIGNATURE VariantClass = C.G_VARIANT_CLASS_SIGNATURE //The GVariant is a D-Bus signature string. + VARIANT_CLASS_VARIANT VariantClass = C.G_VARIANT_CLASS_VARIANT //The GVariant is a variant. + VARIANT_CLASS_MAYBE VariantClass = C.G_VARIANT_CLASS_MAYBE //The GVariant is a maybe-typed value. + VARIANT_CLASS_ARRAY VariantClass = C.G_VARIANT_CLASS_ARRAY //The GVariant is an array. + VARIANT_CLASS_TUPLE VariantClass = C.G_VARIANT_CLASS_TUPLE //The GVariant is a tuple. + VARIANT_CLASS_DICT_ENTRY VariantClass = C.G_VARIANT_CLASS_DICT_ENTRY //The GVariant is a dictionary entry. +) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantdict.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantdict.go new file mode 100644 index 0000000..fcebb7a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantdict.go @@ -0,0 +1,54 @@ +// Same copyright and license as the rest of the files in this project + +//GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +// #include "gvariant.go.h" +//import "C" +//import "unsafe" + +/* + * GVariantDict + */ +/* todo fix bugs +// VariantDict is a representation of GLib's VariantDict. +type VariantDict struct { + GVariantDict *C.GVariantDict +} + +func (v *VariantDict) toGVariantDict() *C.GVariantDict { + if v == nil { + return nil + } + return v.native() +} + +func (v *VariantDict) toVariantDict() *VariantDict { + return v +} + +// newVariantDict creates a new VariantDict from a GVariantDict pointer. +func newVariantDict(p *C.GVariantDict) *VariantDict { + return &VariantDict{GVariantDict: p} +} + +// native returns a pointer to the underlying GVariantDict. +func (v *VariantDict) native() *C.GVariantDict { + if v == nil || v.GVariantDict == nil { + return nil + } + p := unsafe.Pointer(v.GVariantDict) + return C.toGVariantDict(p) +} + +// Native returns a pointer to the underlying GVariantDict. +func (v *VariantDict) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} +*/ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantiter.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantiter.go new file mode 100644 index 0000000..6bad360 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/gvariantiter.go @@ -0,0 +1,54 @@ +// Same copyright and license as the rest of the files in this project + +//GVariant : GVariant — strongly typed value datatype +// https://developer.gnome.org/glib/2.26/glib-GVariant.html + +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +// #include "gvariant.go.h" +//import "C" +//import "unsafe" + +/* + * GVariantIter + */ +/* todo fix bugs +// VariantIter is a representation of GLib's GVariantIter. +type VariantIter struct { + GVariantIter *C.GVariantIter +} + +func (v *VariantIter) toGVariantIter() *C.GVariantIter { + if v == nil { + return nil + } + return v.native() +} + +func (v *VariantIter) toVariantIter() *VariantIter { + return v +} + +// newVariantIter creates a new VariantIter from a GVariantIter pointer. +func newVariantIter(p *C.GVariantIter) *VariantIter { + return &VariantIter{GVariantIter: p} +} + +// native returns a pointer to the underlying GVariantIter. +func (v *VariantIter) native() *C.GVariantIter { + if v == nil || v.GVariantIter == nil { + return nil + } + p := unsafe.Pointer(v.GVariantIter) + return C.toGVariantIter(p) +} + +// Native returns a pointer to the underlying GVariantIter. +func (v *VariantIter) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} +*/ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/list.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/list.go new file mode 100644 index 0000000..2b7a0de --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/list.go @@ -0,0 +1,156 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #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() +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/menu.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/menu.go new file mode 100644 index 0000000..b3b4cc8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/menu.go @@ -0,0 +1,333 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include +// #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 () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/notifications.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/notifications.go new file mode 100644 index 0000000..35ac322 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/notifications.go @@ -0,0 +1,106 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include +// #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. diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/slist.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/slist.go new file mode 100644 index 0000000..66ab8f2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/glib/slist.go @@ -0,0 +1,71 @@ +package glib + +// #cgo pkg-config: glib-2.0 gobject-2.0 +// #include +// #include +// #include "glib.go.h" +import "C" +import "unsafe" + +// SList is a representation of Glib's GSList. +type SList struct { + list *C.struct__GSList +} + +func WrapSList(obj uintptr) *SList { + return wrapSList((*C.struct__GSList)(unsafe.Pointer(obj))) +} + +func wrapSList(obj *C.struct__GSList) *SList { + return &SList{obj} +} + +func (v *SList) Native() uintptr { + return uintptr(unsafe.Pointer(v.list)) +} + +func (v *SList) native() *C.struct__GSList { + if v == nil || v.list == nil { + return nil + } + return v.list +} + +func (v *SList) Append(data uintptr) *SList { + ret := C.g_slist_append(v.native(), C.gpointer(data)) + if ret == v.native() { + return v + } else { + return wrapSList(ret) + } +} + +// GSList * g_slist_alloc () +// GSList * g_slist_prepend () +// GSList * g_slist_insert () +// GSList * g_slist_insert_before () +// GSList * g_slist_insert_sorted () +// GSList * g_slist_remove () +// GSList * g_slist_remove_link () +// GSList * g_slist_delete_link () +// GSList * g_slist_remove_all () +// void g_slist_free () +// void g_slist_free_full () +// void g_slist_free_1 () +// guint g_slist_length () +// GSList * g_slist_copy () +// GSList * g_slist_copy_deep () +// GSList * g_slist_reverse () +// GSList * g_slist_insert_sorted_with_data () +// GSList * g_slist_sort () +// GSList * g_slist_sort_with_data () +// GSList * g_slist_concat () +// void g_slist_foreach () +// GSList * g_slist_last () +// #define g_slist_next() +// GSList * g_slist_nth () +// gpointer g_slist_nth_data () +// GSList * g_slist_find () +// GSList * g_slist_find_custom () +// gint g_slist_position () +// gint g_slist_index () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/aboutdialog.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/aboutdialog.go new file mode 100644 index 0000000..7c491e6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/aboutdialog.go @@ -0,0 +1,313 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + {glib.Type(C.gtk_about_dialog_get_type()), marshalAboutDialog}, + } + + glib.RegisterGValueMarshalers(tm) + + WrapMap["GtkAboutDialog"] = wrapAboutDialog +} + +/* + * GtkAboutDialog + */ + +// AboutDialog is a representation of GTK's GtkAboutDialog. +type AboutDialog struct { + Dialog +} + +// native returns a pointer to the underlying GtkAboutDialog. +func (v *AboutDialog) native() *C.GtkAboutDialog { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkAboutDialog(p) +} + +func marshalAboutDialog(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapAboutDialog(obj), nil +} + +func wrapAboutDialog(obj *glib.Object) *AboutDialog { + return &AboutDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} +} + +// AboutDialogNew is a wrapper around gtk_about_dialog_new(). +func AboutDialogNew() (*AboutDialog, error) { + c := C.gtk_about_dialog_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapAboutDialog(obj), nil +} + +// GetComments is a wrapper around gtk_about_dialog_get_comments(). +func (v *AboutDialog) GetComments() string { + c := C.gtk_about_dialog_get_comments(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetComments is a wrapper around gtk_about_dialog_set_comments(). +func (v *AboutDialog) SetComments(comments string) { + cstr := C.CString(comments) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_comments(v.native(), (*C.gchar)(cstr)) +} + +// GetCopyright is a wrapper around gtk_about_dialog_get_copyright(). +func (v *AboutDialog) GetCopyright() string { + c := C.gtk_about_dialog_get_copyright(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetCopyright is a wrapper around gtk_about_dialog_set_copyright(). +func (v *AboutDialog) SetCopyright(copyright string) { + cstr := C.CString(copyright) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_copyright(v.native(), (*C.gchar)(cstr)) +} + +// GetLicense is a wrapper around gtk_about_dialog_get_license(). +func (v *AboutDialog) GetLicense() string { + c := C.gtk_about_dialog_get_license(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetLicense is a wrapper around gtk_about_dialog_set_license(). +func (v *AboutDialog) SetLicense(license string) { + cstr := C.CString(license) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_license(v.native(), (*C.gchar)(cstr)) +} + +// GetLicenseType is a wrapper around gtk_about_dialog_get_license_type(). +func (v *AboutDialog) GetLicenseType() License { + c := C.gtk_about_dialog_get_license_type(v.native()) + return License(c) +} + +// SetLicenseType is a wrapper around gtk_about_dialog_set_license_type(). +func (v *AboutDialog) SetLicenseType(license License) { + C.gtk_about_dialog_set_license_type(v.native(), C.GtkLicense(license)) +} + +// SetLogo is a wrapper around gtk_about_dialog_set_logo(). +func (v *AboutDialog) SetLogo(logo *gdk.Pixbuf) { + logoPtr := (*C.GdkPixbuf)(unsafe.Pointer(logo.Native())) + C.gtk_about_dialog_set_logo(v.native(), logoPtr) +} + +// GetLogoIconName is a wrapper around gtk_about_dialog_get_logo_icon_name(). +func (v *AboutDialog) GetLogoIconName() string { + c := C.gtk_about_dialog_get_logo_icon_name(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetLogoIconName is a wrapper around gtk_about_dialog_set_logo_icon_name(). +func (v *AboutDialog) SetLogoIconName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_logo_icon_name(v.native(), (*C.gchar)(cstr)) +} + +// GetProgramName is a wrapper around gtk_about_dialog_get_program_name(). +func (v *AboutDialog) GetProgramName() string { + c := C.gtk_about_dialog_get_program_name(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetProgramName is a wrapper around gtk_about_dialog_set_program_name(). +func (v *AboutDialog) SetProgramName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_program_name(v.native(), (*C.gchar)(cstr)) +} + +// GetAuthors is a wrapper around gtk_about_dialog_get_authors(). +func (v *AboutDialog) GetAuthors() []string { + var authors []string + cauthors := C.gtk_about_dialog_get_authors(v.native()) + if cauthors == nil { + return nil + } + for { + if *cauthors == nil { + break + } + authors = append(authors, C.GoString((*C.char)(*cauthors))) + cauthors = C.next_gcharptr(cauthors) + } + return authors +} + +// SetAuthors is a wrapper around gtk_about_dialog_set_authors(). +func (v *AboutDialog) SetAuthors(authors []string) { + cauthors := C.make_strings(C.int(len(authors) + 1)) + for i, author := range authors { + cstr := C.CString(author) + defer C.free(unsafe.Pointer(cstr)) + C.set_string(cauthors, C.int(i), (*C.gchar)(cstr)) + } + + C.set_string(cauthors, C.int(len(authors)), nil) + C.gtk_about_dialog_set_authors(v.native(), cauthors) + C.destroy_strings(cauthors) +} + +// GetArtists is a wrapper around gtk_about_dialog_get_artists(). +func (v *AboutDialog) GetArtists() []string { + var artists []string + cartists := C.gtk_about_dialog_get_artists(v.native()) + if cartists == nil { + return nil + } + for { + if *cartists == nil { + break + } + artists = append(artists, C.GoString((*C.char)(*cartists))) + cartists = C.next_gcharptr(cartists) + } + return artists +} + +// SetArtists is a wrapper around gtk_about_dialog_set_artists(). +func (v *AboutDialog) SetArtists(artists []string) { + cartists := C.make_strings(C.int(len(artists) + 1)) + for i, artist := range artists { + cstr := C.CString(artist) + defer C.free(unsafe.Pointer(cstr)) + C.set_string(cartists, C.int(i), (*C.gchar)(cstr)) + } + + C.set_string(cartists, C.int(len(artists)), nil) + C.gtk_about_dialog_set_artists(v.native(), cartists) + C.destroy_strings(cartists) +} + +// GetDocumenters is a wrapper around gtk_about_dialog_get_documenters(). +func (v *AboutDialog) GetDocumenters() []string { + var documenters []string + cdocumenters := C.gtk_about_dialog_get_documenters(v.native()) + if cdocumenters == nil { + return nil + } + for { + if *cdocumenters == nil { + break + } + documenters = append(documenters, C.GoString((*C.char)(*cdocumenters))) + cdocumenters = C.next_gcharptr(cdocumenters) + } + return documenters +} + +// SetDocumenters is a wrapper around gtk_about_dialog_set_documenters(). +func (v *AboutDialog) SetDocumenters(documenters []string) { + cdocumenters := C.make_strings(C.int(len(documenters) + 1)) + for i, doc := range documenters { + cstr := C.CString(doc) + defer C.free(unsafe.Pointer(cstr)) + C.set_string(cdocumenters, C.int(i), (*C.gchar)(cstr)) + } + + C.set_string(cdocumenters, C.int(len(documenters)), nil) + C.gtk_about_dialog_set_documenters(v.native(), cdocumenters) + C.destroy_strings(cdocumenters) +} + +// GetTranslatorCredits is a wrapper around gtk_about_dialog_get_translator_credits(). +func (v *AboutDialog) GetTranslatorCredits() string { + c := C.gtk_about_dialog_get_translator_credits(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetTranslatorCredits is a wrapper around gtk_about_dialog_set_translator_credits(). +func (v *AboutDialog) SetTranslatorCredits(translatorCredits string) { + cstr := C.CString(translatorCredits) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_translator_credits(v.native(), (*C.gchar)(cstr)) +} + +// GetVersion is a wrapper around gtk_about_dialog_get_version(). +func (v *AboutDialog) GetVersion() string { + c := C.gtk_about_dialog_get_version(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetVersion is a wrapper around gtk_about_dialog_set_version(). +func (v *AboutDialog) SetVersion(version string) { + cstr := C.CString(version) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_version(v.native(), (*C.gchar)(cstr)) +} + +// GetWebsite is a wrapper around gtk_about_dialog_get_website(). +func (v *AboutDialog) GetWebsite() string { + c := C.gtk_about_dialog_get_website(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetWebsite is a wrapper around gtk_about_dialog_set_website(). +func (v *AboutDialog) SetWebsite(website string) { + cstr := C.CString(website) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_website(v.native(), (*C.gchar)(cstr)) +} + +// GetWebsiteLabel is a wrapper around gtk_about_dialog_get_website_label(). +func (v *AboutDialog) GetWebsiteLabel() string { + c := C.gtk_about_dialog_get_website_label(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetWebsiteLabel is a wrapper around gtk_about_dialog_set_website_label(). +func (v *AboutDialog) SetWebsiteLabel(websiteLabel string) { + cstr := C.CString(websiteLabel) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_about_dialog_set_website_label(v.native(), (*C.gchar)(cstr)) +} + +// GetWrapLicense is a wrapper around gtk_about_dialog_get_wrap_license(). +func (v *AboutDialog) GetWrapLicense() bool { + return gobool(C.gtk_about_dialog_get_wrap_license(v.native())) +} + +// SetWrapLicense is a wrapper around gtk_about_dialog_set_wrap_license(). +func (v *AboutDialog) SetWrapLicense(wrapLicense bool) { + C.gtk_about_dialog_set_wrap_license(v.native(), gbool(wrapLicense)) +} + +// AddCreditSection is a wrapper around gtk_about_dialog_add_credit_section(). +func (v *AboutDialog) AddCreditSection(sectionName string, people []string) { + cname := (*C.gchar)(C.CString(sectionName)) + defer C.free(unsafe.Pointer(cname)) + + cpeople := C.make_strings(C.int(len(people)) + 1) + defer C.destroy_strings(cpeople) + for i, p := range people { + cp := (*C.gchar)(C.CString(p)) + defer C.free(unsafe.Pointer(cp)) + C.set_string(cpeople, C.int(i), cp) + } + C.set_string(cpeople, C.int(len(people)), nil) + + C.gtk_about_dialog_add_credit_section(v.native(), cname, cpeople) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/accel.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/accel.go new file mode 100644 index 0000000..a600ca1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/accel.go @@ -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 +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go new file mode 100644 index 0000000..929ecc9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go @@ -0,0 +1,106 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 + +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +// #include "actionbar_since_3_12.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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))}} +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go.h new file mode 100644 index 0000000..d58e36a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/actionbar_since_3_12.go.h @@ -0,0 +1,25 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12 + +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * 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)); +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/app_chooser.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/app_chooser.go new file mode 100644 index 0000000..63b0b0a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/app_chooser.go @@ -0,0 +1,378 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application.go new file mode 100644 index 0000000..c144f34 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application.go @@ -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 +// #include "gtk.go.h" +import "C" +import ( + "runtime" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_12.go new file mode 100644 index 0000000..1fd55fb --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_12.go @@ -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 +// #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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_14.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_14.go new file mode 100644 index 0000000..7fee467 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_since_3_14.go @@ -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 +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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))}} +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_window.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_window.go new file mode 100644 index 0000000..32b1d1e --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/application_window.go @@ -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 +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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())) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/color_chooser.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/color_chooser.go new file mode 100644 index 0000000..6419903 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/color_chooser.go @@ -0,0 +1,148 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/combo_box.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/combo_box.go new file mode 100644 index 0000000..0dc7097 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/combo_box.go @@ -0,0 +1,264 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "errors" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go new file mode 100644 index 0000000..5b57160 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go @@ -0,0 +1,8876 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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. + +// Go bindings for GTK+ 3. Supports version 3.6 and later. +// +// Functions use the same names as the native C function calls, but use +// CamelCase. In cases where native GTK uses pointers to values to +// simulate multiple return values, Go's native multiple return values +// are used instead. Whenever a native GTK call could return an +// unexpected NULL pointer, an additonal error is returned in the Go +// binding. +// +// GTK's C API documentation can be very useful for understanding how the +// functions in this package work and what each type is for. This +// documentation can be found at https://developer.gnome.org/gtk3/. +// +// In addition to Go versions of the C GTK functions, every struct type +// includes a method named Native (either by direct implementation, or +// by means of struct embedding). These methods return a uintptr of the +// native C object the binding type represents. These pointers may be +// type switched to a native C pointer using unsafe and used with cgo +// function calls outside this package. +// +// Memory management is handled in proper Go fashion, using runtime +// finalizers to properly free memory when it is no longer needed. Each +// time a Go type is created with a pointer to a GObject, a reference is +// added for Go, sinking the floating reference when necessary. After +// going out of scope and the next time Go's garbage collector is run, a +// finalizer is run to remove Go's reference to the GObject. When this +// reference count hits zero (when neither Go nor GTK holds ownership) +// the object will be freed internally by GTK. +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include "gtk.go.h" +import "C" +import ( + "errors" + "fmt" + "reflect" + "runtime" + "sync" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.gtk_align_get_type()), marshalAlign}, + {glib.Type(C.gtk_accel_flags_get_type()), marshalAccelFlags}, + {glib.Type(C.gtk_accel_group_get_type()), marshalAccelGroup}, + {glib.Type(C.gtk_accel_map_get_type()), marshalAccelMap}, + {glib.Type(C.gtk_arrow_placement_get_type()), marshalArrowPlacement}, + {glib.Type(C.gtk_arrow_type_get_type()), marshalArrowType}, + {glib.Type(C.gtk_assistant_page_type_get_type()), marshalAssistantPageType}, + {glib.Type(C.gtk_buttons_type_get_type()), marshalButtonsType}, + {glib.Type(C.gtk_calendar_display_options_get_type()), marshalCalendarDisplayOptions}, + {glib.Type(C.gtk_dest_defaults_get_type()), marshalDestDefaults}, + {glib.Type(C.gtk_dialog_flags_get_type()), marshalDialogFlags}, + {glib.Type(C.gtk_entry_icon_position_get_type()), marshalEntryIconPosition}, + {glib.Type(C.gtk_file_chooser_action_get_type()), marshalFileChooserAction}, + {glib.Type(C.gtk_icon_lookup_flags_get_type()), marshalSortType}, + {glib.Type(C.gtk_icon_size_get_type()), marshalIconSize}, + {glib.Type(C.gtk_image_type_get_type()), marshalImageType}, + {glib.Type(C.gtk_input_hints_get_type()), marshalInputHints}, + {glib.Type(C.gtk_input_purpose_get_type()), marshalInputPurpose}, + {glib.Type(C.gtk_justification_get_type()), marshalJustification}, + {glib.Type(C.gtk_license_get_type()), marshalLicense}, + {glib.Type(C.gtk_message_type_get_type()), marshalMessageType}, + {glib.Type(C.gtk_orientation_get_type()), marshalOrientation}, + {glib.Type(C.gtk_pack_type_get_type()), marshalPackType}, + {glib.Type(C.gtk_path_type_get_type()), marshalPathType}, + {glib.Type(C.gtk_policy_type_get_type()), marshalPolicyType}, + {glib.Type(C.gtk_position_type_get_type()), marshalPositionType}, + {glib.Type(C.gtk_relief_style_get_type()), marshalReliefStyle}, + {glib.Type(C.gtk_response_type_get_type()), marshalResponseType}, + {glib.Type(C.gtk_selection_mode_get_type()), marshalSelectionMode}, + {glib.Type(C.gtk_shadow_type_get_type()), marshalShadowType}, + {glib.Type(C.gtk_sort_type_get_type()), marshalSortType}, + {glib.Type(C.gtk_state_flags_get_type()), marshalStateFlags}, + {glib.Type(C.gtk_target_flags_get_type()), marshalTargetFlags}, + {glib.Type(C.gtk_toolbar_style_get_type()), marshalToolbarStyle}, + {glib.Type(C.gtk_tree_model_flags_get_type()), marshalTreeModelFlags}, + {glib.Type(C.gtk_window_position_get_type()), marshalWindowPosition}, + {glib.Type(C.gtk_window_type_get_type()), marshalWindowType}, + {glib.Type(C.gtk_wrap_mode_get_type()), marshalWrapMode}, + + // Objects/Interfaces + {glib.Type(C.gtk_accel_group_get_type()), marshalAccelGroup}, + {glib.Type(C.gtk_accel_map_get_type()), marshalAccelMap}, + {glib.Type(C.gtk_adjustment_get_type()), marshalAdjustment}, + {glib.Type(C.gtk_application_get_type()), marshalApplication}, + {glib.Type(C.gtk_application_window_get_type()), marshalApplicationWindow}, + {glib.Type(C.gtk_assistant_get_type()), marshalAssistant}, + {glib.Type(C.gtk_bin_get_type()), marshalBin}, + {glib.Type(C.gtk_builder_get_type()), marshalBuilder}, + {glib.Type(C.gtk_button_get_type()), marshalButton}, + {glib.Type(C.gtk_box_get_type()), marshalBox}, + {glib.Type(C.gtk_calendar_get_type()), marshalCalendar}, + {glib.Type(C.gtk_cell_layout_get_type()), marshalCellLayout}, + {glib.Type(C.gtk_cell_renderer_get_type()), marshalCellRenderer}, + {glib.Type(C.gtk_cell_renderer_spinner_get_type()), marshalCellRendererSpinner}, + {glib.Type(C.gtk_cell_renderer_pixbuf_get_type()), marshalCellRendererPixbuf}, + {glib.Type(C.gtk_cell_renderer_text_get_type()), marshalCellRendererText}, + {glib.Type(C.gtk_cell_renderer_toggle_get_type()), marshalCellRendererToggle}, + {glib.Type(C.gtk_check_button_get_type()), marshalCheckButton}, + {glib.Type(C.gtk_check_menu_item_get_type()), marshalCheckMenuItem}, + {glib.Type(C.gtk_clipboard_get_type()), marshalClipboard}, + {glib.Type(C.gtk_container_get_type()), marshalContainer}, + {glib.Type(C.gtk_dialog_get_type()), marshalDialog}, + {glib.Type(C.gtk_drawing_area_get_type()), marshalDrawingArea}, + {glib.Type(C.gtk_editable_get_type()), marshalEditable}, + {glib.Type(C.gtk_entry_get_type()), marshalEntry}, + {glib.Type(C.gtk_entry_buffer_get_type()), marshalEntryBuffer}, + {glib.Type(C.gtk_entry_completion_get_type()), marshalEntryCompletion}, + {glib.Type(C.gtk_event_box_get_type()), marshalEventBox}, + {glib.Type(C.gtk_expander_get_type()), marshalExpander}, + {glib.Type(C.gtk_file_chooser_get_type()), marshalFileChooser}, + {glib.Type(C.gtk_file_chooser_button_get_type()), marshalFileChooserButton}, + {glib.Type(C.gtk_file_chooser_dialog_get_type()), marshalFileChooserDialog}, + {glib.Type(C.gtk_file_chooser_widget_get_type()), marshalFileChooserWidget}, + {glib.Type(C.gtk_font_button_get_type()), marshalFontButton}, + {glib.Type(C.gtk_frame_get_type()), marshalFrame}, + {glib.Type(C.gtk_grid_get_type()), marshalGrid}, + {glib.Type(C.gtk_icon_view_get_type()), marshalIconView}, + {glib.Type(C.gtk_image_get_type()), marshalImage}, + {glib.Type(C.gtk_label_get_type()), marshalLabel}, + {glib.Type(C.gtk_link_button_get_type()), marshalLinkButton}, + {glib.Type(C.gtk_layout_get_type()), marshalLayout}, + {glib.Type(C.gtk_list_store_get_type()), marshalListStore}, + {glib.Type(C.gtk_menu_get_type()), marshalMenu}, + {glib.Type(C.gtk_menu_bar_get_type()), marshalMenuBar}, + {glib.Type(C.gtk_menu_button_get_type()), marshalMenuButton}, + {glib.Type(C.gtk_menu_item_get_type()), marshalMenuItem}, + {glib.Type(C.gtk_menu_shell_get_type()), marshalMenuShell}, + {glib.Type(C.gtk_message_dialog_get_type()), marshalMessageDialog}, + {glib.Type(C.gtk_notebook_get_type()), marshalNotebook}, + {glib.Type(C.gtk_offscreen_window_get_type()), marshalOffscreenWindow}, + {glib.Type(C.gtk_orientable_get_type()), marshalOrientable}, + {glib.Type(C.gtk_paned_get_type()), marshalPaned}, + {glib.Type(C.gtk_progress_bar_get_type()), marshalProgressBar}, + {glib.Type(C.gtk_radio_button_get_type()), marshalRadioButton}, + {glib.Type(C.gtk_radio_menu_item_get_type()), marshalRadioMenuItem}, + {glib.Type(C.gtk_range_get_type()), marshalRange}, + {glib.Type(C.gtk_scale_button_get_type()), marshalScaleButton}, + {glib.Type(C.gtk_scale_get_type()), marshalScale}, + {glib.Type(C.gtk_scrollbar_get_type()), marshalScrollbar}, + {glib.Type(C.gtk_scrolled_window_get_type()), marshalScrolledWindow}, + {glib.Type(C.gtk_search_entry_get_type()), marshalSearchEntry}, + {glib.Type(C.gtk_selection_data_get_type()), marshalSelectionData}, + {glib.Type(C.gtk_separator_get_type()), marshalSeparator}, + {glib.Type(C.gtk_separator_menu_item_get_type()), marshalSeparatorMenuItem}, + {glib.Type(C.gtk_separator_tool_item_get_type()), marshalSeparatorToolItem}, + {glib.Type(C.gtk_spin_button_get_type()), marshalSpinButton}, + {glib.Type(C.gtk_spinner_get_type()), marshalSpinner}, + {glib.Type(C.gtk_statusbar_get_type()), marshalStatusbar}, + {glib.Type(C.gtk_switch_get_type()), marshalSwitch}, + {glib.Type(C.gtk_text_view_get_type()), marshalTextView}, + {glib.Type(C.gtk_text_tag_get_type()), marshalTextTag}, + {glib.Type(C.gtk_text_tag_table_get_type()), marshalTextTagTable}, + {glib.Type(C.gtk_text_buffer_get_type()), marshalTextBuffer}, + {glib.Type(C.gtk_toggle_button_get_type()), marshalToggleButton}, + {glib.Type(C.gtk_toolbar_get_type()), marshalToolbar}, + {glib.Type(C.gtk_tool_button_get_type()), marshalToolButton}, + {glib.Type(C.gtk_tool_item_get_type()), marshalToolItem}, + {glib.Type(C.gtk_tree_model_get_type()), marshalTreeModel}, + {glib.Type(C.gtk_tree_selection_get_type()), marshalTreeSelection}, + {glib.Type(C.gtk_tree_store_get_type()), marshalTreeStore}, + {glib.Type(C.gtk_tree_view_get_type()), marshalTreeView}, + {glib.Type(C.gtk_tree_view_column_get_type()), marshalTreeViewColumn}, + {glib.Type(C.gtk_volume_button_get_type()), marshalVolumeButton}, + {glib.Type(C.gtk_widget_get_type()), marshalWidget}, + {glib.Type(C.gtk_window_get_type()), marshalWindow}, + + // Boxed + {glib.Type(C.gtk_target_entry_get_type()), marshalTargetEntry}, + {glib.Type(C.gtk_text_iter_get_type()), marshalTextIter}, + {glib.Type(C.gtk_tree_iter_get_type()), marshalTreeIter}, + {glib.Type(C.gtk_tree_path_get_type()), marshalTreePath}, + } + glib.RegisterGValueMarshalers(tm) +} + +/* + * Type conversions + */ + +func gbool(b bool) C.gboolean { + if b { + return C.gboolean(1) + } + return C.gboolean(0) +} + +func gobool(b C.gboolean) bool { + return b != C.FALSE +} + +// Wrapper function for new objects with reference management. +func wrapObject(ptr unsafe.Pointer) *glib.Object { + obj := &glib.Object{glib.ToGObject(ptr)} + + if obj.IsFloating() { + obj.RefSink() + } else { + obj.Ref() + } + + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return obj +} + +// Wrapper function for TestBoolConvs since cgo can't be used with +// testing package +func testBoolConvs() error { + b := gobool(gbool(true)) + if b != true { + return errors.New("Unexpected bool conversion result") + } + + cb := gbool(gobool(C.gboolean(0))) + if cb != C.gboolean(0) { + return errors.New("Unexpected bool conversion result") + } + + return nil +} + +/* + * Unexported vars + */ + +var nilPtrErr = errors.New("cgo returned unexpected nil pointer") + +/* + * Constants + */ + +// Align is a representation of GTK's GtkAlign. +type Align int + +const ( + ALIGN_FILL Align = C.GTK_ALIGN_FILL + ALIGN_START Align = C.GTK_ALIGN_START + ALIGN_END Align = C.GTK_ALIGN_END + ALIGN_CENTER Align = C.GTK_ALIGN_CENTER +) + +func marshalAlign(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Align(c), nil +} + +// ArrowPlacement is a representation of GTK's GtkArrowPlacement. +type ArrowPlacement int + +const ( + ARROWS_BOTH ArrowPlacement = C.GTK_ARROWS_BOTH + ARROWS_START ArrowPlacement = C.GTK_ARROWS_START + ARROWS_END ArrowPlacement = C.GTK_ARROWS_END +) + +func marshalArrowPlacement(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ArrowPlacement(c), nil +} + +// ArrowType is a representation of GTK's GtkArrowType. +type ArrowType int + +const ( + ARROW_UP ArrowType = C.GTK_ARROW_UP + ARROW_DOWN ArrowType = C.GTK_ARROW_DOWN + ARROW_LEFT ArrowType = C.GTK_ARROW_LEFT + ARROW_RIGHT ArrowType = C.GTK_ARROW_RIGHT + ARROW_NONE ArrowType = C.GTK_ARROW_NONE +) + +func marshalArrowType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ArrowType(c), nil +} + +// AssistantPageType is a representation of GTK's GtkAssistantPageType. +type AssistantPageType int + +const ( + ASSISTANT_PAGE_CONTENT AssistantPageType = C.GTK_ASSISTANT_PAGE_CONTENT + ASSISTANT_PAGE_INTRO AssistantPageType = C.GTK_ASSISTANT_PAGE_INTRO + ASSISTANT_PAGE_CONFIRM AssistantPageType = C.GTK_ASSISTANT_PAGE_CONFIRM + ASSISTANT_PAGE_SUMMARY AssistantPageType = C.GTK_ASSISTANT_PAGE_SUMMARY + ASSISTANT_PAGE_PROGRESS AssistantPageType = C.GTK_ASSISTANT_PAGE_PROGRESS + ASSISTANT_PAGE_CUSTOM AssistantPageType = C.GTK_ASSISTANT_PAGE_CUSTOM +) + +func marshalAssistantPageType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return AssistantPageType(c), nil +} + +// ButtonsType is a representation of GTK's GtkButtonsType. +type ButtonsType int + +const ( + BUTTONS_NONE ButtonsType = C.GTK_BUTTONS_NONE + BUTTONS_OK ButtonsType = C.GTK_BUTTONS_OK + BUTTONS_CLOSE ButtonsType = C.GTK_BUTTONS_CLOSE + BUTTONS_CANCEL ButtonsType = C.GTK_BUTTONS_CANCEL + BUTTONS_YES_NO ButtonsType = C.GTK_BUTTONS_YES_NO + BUTTONS_OK_CANCEL ButtonsType = C.GTK_BUTTONS_OK_CANCEL +) + +func marshalButtonsType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ButtonsType(c), nil +} + +// CalendarDisplayOptions is a representation of GTK's GtkCalendarDisplayOptions +type CalendarDisplayOptions int + +const ( + CALENDAR_SHOW_HEADING CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_HEADING + CALENDAR_SHOW_DAY_NAMES CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_DAY_NAMES + CALENDAR_NO_MONTH_CHANGE CalendarDisplayOptions = C.GTK_CALENDAR_NO_MONTH_CHANGE + CALENDAR_SHOW_WEEK_NUMBERS CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_WEEK_NUMBERS + CALENDAR_SHOW_DETAILS CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_DETAILS +) + +func marshalCalendarDisplayOptions(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return CalendarDisplayOptions(c), nil +} + +// DestDefaults is a representation of GTK's GtkDestDefaults. +type DestDefaults int + +const ( + DEST_DEFAULT_MOTION DestDefaults = C.GTK_DEST_DEFAULT_MOTION + DEST_DEFAULT_HIGHLIGHT DestDefaults = C.GTK_DEST_DEFAULT_HIGHLIGHT + DEST_DEFAULT_DROP DestDefaults = C.GTK_DEST_DEFAULT_DROP + DEST_DEFAULT_ALL DestDefaults = C.GTK_DEST_DEFAULT_ALL +) + +func marshalDestDefaults(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return DestDefaults(c), nil +} + +// DialogFlags is a representation of GTK's GtkDialogFlags. +type DialogFlags int + +const ( + DIALOG_MODAL DialogFlags = C.GTK_DIALOG_MODAL + DIALOG_DESTROY_WITH_PARENT DialogFlags = C.GTK_DIALOG_DESTROY_WITH_PARENT +) + +func marshalDialogFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return DialogFlags(c), nil +} + +// EntryIconPosition is a representation of GTK's GtkEntryIconPosition. +type EntryIconPosition int + +const ( + ENTRY_ICON_PRIMARY EntryIconPosition = C.GTK_ENTRY_ICON_PRIMARY + ENTRY_ICON_SECONDARY EntryIconPosition = C.GTK_ENTRY_ICON_SECONDARY +) + +func marshalEntryIconPosition(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return EntryIconPosition(c), nil +} + +// FileChooserAction is a representation of GTK's GtkFileChooserAction. +type FileChooserAction int + +const ( + FILE_CHOOSER_ACTION_OPEN FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_OPEN + FILE_CHOOSER_ACTION_SAVE FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_SAVE + FILE_CHOOSER_ACTION_SELECT_FOLDER FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER + FILE_CHOOSER_ACTION_CREATE_FOLDER FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER +) + +func marshalFileChooserAction(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return FileChooserAction(c), nil +} + +// IconLookupFlags is a representation of GTK's GtkIconLookupFlags. +type IconLookupFlags int + +const ( + ICON_LOOKUP_NO_SVG IconLookupFlags = C.GTK_ICON_LOOKUP_NO_SVG + ICON_LOOKUP_FORCE_SVG = C.GTK_ICON_LOOKUP_FORCE_SVG + ICON_LOOKUP_USE_BUILTIN = C.GTK_ICON_LOOKUP_USE_BUILTIN + ICON_LOOKUP_GENERIC_FALLBACK = C.GTK_ICON_LOOKUP_GENERIC_FALLBACK + ICON_LOOKUP_FORCE_SIZE = C.GTK_ICON_LOOKUP_FORCE_SIZE +) + +func marshalIconLookupFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return IconLookupFlags(c), nil +} + +// IconSize is a representation of GTK's GtkIconSize. +type IconSize int + +const ( + ICON_SIZE_INVALID IconSize = C.GTK_ICON_SIZE_INVALID + ICON_SIZE_MENU IconSize = C.GTK_ICON_SIZE_MENU + ICON_SIZE_SMALL_TOOLBAR IconSize = C.GTK_ICON_SIZE_SMALL_TOOLBAR + ICON_SIZE_LARGE_TOOLBAR IconSize = C.GTK_ICON_SIZE_LARGE_TOOLBAR + ICON_SIZE_BUTTON IconSize = C.GTK_ICON_SIZE_BUTTON + ICON_SIZE_DND IconSize = C.GTK_ICON_SIZE_DND + ICON_SIZE_DIALOG IconSize = C.GTK_ICON_SIZE_DIALOG +) + +func marshalIconSize(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return IconSize(c), nil +} + +// ImageType is a representation of GTK's GtkImageType. +type ImageType int + +const ( + IMAGE_EMPTY ImageType = C.GTK_IMAGE_EMPTY + IMAGE_PIXBUF ImageType = C.GTK_IMAGE_PIXBUF + IMAGE_STOCK ImageType = C.GTK_IMAGE_STOCK + IMAGE_ICON_SET ImageType = C.GTK_IMAGE_ICON_SET + IMAGE_ANIMATION ImageType = C.GTK_IMAGE_ANIMATION + IMAGE_ICON_NAME ImageType = C.GTK_IMAGE_ICON_NAME + IMAGE_GICON ImageType = C.GTK_IMAGE_GICON +) + +func marshalImageType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ImageType(c), nil +} + +// InputHints is a representation of GTK's GtkInputHints. +type InputHints int + +const ( + INPUT_HINT_NONE InputHints = C.GTK_INPUT_HINT_NONE + INPUT_HINT_SPELLCHECK InputHints = C.GTK_INPUT_HINT_SPELLCHECK + INPUT_HINT_NO_SPELLCHECK InputHints = C.GTK_INPUT_HINT_NO_SPELLCHECK + INPUT_HINT_WORD_COMPLETION InputHints = C.GTK_INPUT_HINT_WORD_COMPLETION + INPUT_HINT_LOWERCASE InputHints = C.GTK_INPUT_HINT_LOWERCASE + INPUT_HINT_UPPERCASE_CHARS InputHints = C.GTK_INPUT_HINT_UPPERCASE_CHARS + INPUT_HINT_UPPERCASE_WORDS InputHints = C.GTK_INPUT_HINT_UPPERCASE_WORDS + INPUT_HINT_UPPERCASE_SENTENCES InputHints = C.GTK_INPUT_HINT_UPPERCASE_SENTENCES + INPUT_HINT_INHIBIT_OSK InputHints = C.GTK_INPUT_HINT_INHIBIT_OSK +) + +func marshalInputHints(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return InputHints(c), nil +} + +// InputPurpose is a representation of GTK's GtkInputPurpose. +type InputPurpose int + +const ( + INPUT_PURPOSE_FREE_FORM InputPurpose = C.GTK_INPUT_PURPOSE_FREE_FORM + INPUT_PURPOSE_ALPHA InputPurpose = C.GTK_INPUT_PURPOSE_ALPHA + INPUT_PURPOSE_DIGITS InputPurpose = C.GTK_INPUT_PURPOSE_DIGITS + INPUT_PURPOSE_NUMBER InputPurpose = C.GTK_INPUT_PURPOSE_NUMBER + INPUT_PURPOSE_PHONE InputPurpose = C.GTK_INPUT_PURPOSE_PHONE + INPUT_PURPOSE_URL InputPurpose = C.GTK_INPUT_PURPOSE_URL + INPUT_PURPOSE_EMAIL InputPurpose = C.GTK_INPUT_PURPOSE_EMAIL + INPUT_PURPOSE_NAME InputPurpose = C.GTK_INPUT_PURPOSE_NAME + INPUT_PURPOSE_PASSWORD InputPurpose = C.GTK_INPUT_PURPOSE_PASSWORD + INPUT_PURPOSE_PIN InputPurpose = C.GTK_INPUT_PURPOSE_PIN +) + +func marshalInputPurpose(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return InputPurpose(c), nil +} + +// Justify is a representation of GTK's GtkJustification. +type Justification int + +const ( + JUSTIFY_LEFT Justification = C.GTK_JUSTIFY_LEFT + JUSTIFY_RIGHT Justification = C.GTK_JUSTIFY_RIGHT + JUSTIFY_CENTER Justification = C.GTK_JUSTIFY_CENTER + JUSTIFY_FILL Justification = C.GTK_JUSTIFY_FILL +) + +func marshalJustification(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Justification(c), nil +} + +// License is a representation of GTK's GtkLicense. +type License int + +const ( + LICENSE_UNKNOWN License = C.GTK_LICENSE_UNKNOWN + LICENSE_CUSTOM License = C.GTK_LICENSE_CUSTOM + LICENSE_GPL_2_0 License = C.GTK_LICENSE_GPL_2_0 + LICENSE_GPL_3_0 License = C.GTK_LICENSE_GPL_3_0 + LICENSE_LGPL_2_1 License = C.GTK_LICENSE_LGPL_2_1 + LICENSE_LGPL_3_0 License = C.GTK_LICENSE_LGPL_3_0 + LICENSE_BSD License = C.GTK_LICENSE_BSD + LICENSE_MIT_X11 License = C.GTK_LICENSE_MIT_X11 + LICENSE_GTK_ARTISTIC License = C.GTK_LICENSE_ARTISTIC +) + +func marshalLicense(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return License(c), nil +} + +// MessageType is a representation of GTK's GtkMessageType. +type MessageType int + +const ( + MESSAGE_INFO MessageType = C.GTK_MESSAGE_INFO + MESSAGE_WARNING MessageType = C.GTK_MESSAGE_WARNING + MESSAGE_QUESTION MessageType = C.GTK_MESSAGE_QUESTION + MESSAGE_ERROR MessageType = C.GTK_MESSAGE_ERROR + MESSAGE_OTHER MessageType = C.GTK_MESSAGE_OTHER +) + +func marshalMessageType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return MessageType(c), nil +} + +// Orientation is a representation of GTK's GtkOrientation. +type Orientation int + +const ( + ORIENTATION_HORIZONTAL Orientation = C.GTK_ORIENTATION_HORIZONTAL + ORIENTATION_VERTICAL Orientation = C.GTK_ORIENTATION_VERTICAL +) + +func marshalOrientation(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Orientation(c), nil +} + +// PackType is a representation of GTK's GtkPackType. +type PackType int + +const ( + PACK_START PackType = C.GTK_PACK_START + PACK_END PackType = C.GTK_PACK_END +) + +func marshalPackType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PackType(c), nil +} + +// PathType is a representation of GTK's GtkPathType. +type PathType int + +const ( + PATH_WIDGET PathType = C.GTK_PATH_WIDGET + PATH_WIDGET_CLASS PathType = C.GTK_PATH_WIDGET_CLASS + PATH_CLASS PathType = C.GTK_PATH_CLASS +) + +func marshalPathType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PathType(c), nil +} + +// PolicyType is a representation of GTK's GtkPolicyType. +type PolicyType int + +const ( + POLICY_ALWAYS PolicyType = C.GTK_POLICY_ALWAYS + POLICY_AUTOMATIC PolicyType = C.GTK_POLICY_AUTOMATIC + POLICY_NEVER PolicyType = C.GTK_POLICY_NEVER +) + +func marshalPolicyType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PolicyType(c), nil +} + +// PositionType is a representation of GTK's GtkPositionType. +type PositionType int + +const ( + POS_LEFT PositionType = C.GTK_POS_LEFT + POS_RIGHT PositionType = C.GTK_POS_RIGHT + POS_TOP PositionType = C.GTK_POS_TOP + POS_BOTTOM PositionType = C.GTK_POS_BOTTOM +) + +func marshalPositionType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PositionType(c), nil +} + +// ReliefStyle is a representation of GTK's GtkReliefStyle. +type ReliefStyle int + +const ( + RELIEF_NORMAL ReliefStyle = C.GTK_RELIEF_NORMAL + RELIEF_HALF ReliefStyle = C.GTK_RELIEF_HALF + RELIEF_NONE ReliefStyle = C.GTK_RELIEF_NONE +) + +func marshalReliefStyle(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ReliefStyle(c), nil +} + +// ResponseType is a representation of GTK's GtkResponseType. +type ResponseType int + +const ( + RESPONSE_NONE ResponseType = C.GTK_RESPONSE_NONE + RESPONSE_REJECT ResponseType = C.GTK_RESPONSE_REJECT + RESPONSE_ACCEPT ResponseType = C.GTK_RESPONSE_ACCEPT + RESPONSE_DELETE_EVENT ResponseType = C.GTK_RESPONSE_DELETE_EVENT + RESPONSE_OK ResponseType = C.GTK_RESPONSE_OK + RESPONSE_CANCEL ResponseType = C.GTK_RESPONSE_CANCEL + RESPONSE_CLOSE ResponseType = C.GTK_RESPONSE_CLOSE + RESPONSE_YES ResponseType = C.GTK_RESPONSE_YES + RESPONSE_NO ResponseType = C.GTK_RESPONSE_NO + RESPONSE_APPLY ResponseType = C.GTK_RESPONSE_APPLY + RESPONSE_HELP ResponseType = C.GTK_RESPONSE_HELP +) + +func marshalResponseType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ResponseType(c), nil +} + +// SelectionMode is a representation of GTK's GtkSelectionMode. +type SelectionMode int + +const ( + SELECTION_NONE SelectionMode = C.GTK_SELECTION_NONE + SELECTION_SINGLE SelectionMode = C.GTK_SELECTION_SINGLE + SELECTION_BROWSE SelectionMode = C.GTK_SELECTION_BROWSE + SELECTION_MULTIPLE SelectionMode = C.GTK_SELECTION_MULTIPLE +) + +func marshalSelectionMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return SelectionMode(c), nil +} + +// ShadowType is a representation of GTK's GtkShadowType. +type ShadowType int + +const ( + SHADOW_NONE ShadowType = C.GTK_SHADOW_NONE + SHADOW_IN ShadowType = C.GTK_SHADOW_IN + SHADOW_OUT ShadowType = C.GTK_SHADOW_OUT + SHADOW_ETCHED_IN ShadowType = C.GTK_SHADOW_ETCHED_IN + SHADOW_ETCHED_OUT ShadowType = C.GTK_SHADOW_ETCHED_OUT +) + +func marshalShadowType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ShadowType(c), nil +} + +// SizeGroupMode is a representation of GTK's GtkSizeGroupMode +type SizeGroupMode int + +const ( + SIZE_GROUP_NONE SizeGroupMode = C.GTK_SIZE_GROUP_NONE + SIZE_GROUP_HORIZONTAL SizeGroupMode = C.GTK_SIZE_GROUP_HORIZONTAL + SIZE_GROUP_VERTICAL SizeGroupMode = C.GTK_SIZE_GROUP_VERTICAL + SIZE_GROUP_BOTH SizeGroupMode = C.GTK_SIZE_GROUP_BOTH +) + +func marshalSizeGroupMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return SizeGroupMode(c), nil +} + +// SortType is a representation of GTK's GtkSortType. +type SortType int + +const ( + SORT_ASCENDING SortType = C.GTK_SORT_ASCENDING + SORT_DESCENDING = C.GTK_SORT_DESCENDING +) + +func marshalSortType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return SortType(c), nil +} + +// StateFlags is a representation of GTK's GtkStateFlags. +type StateFlags int + +const ( + STATE_FLAG_NORMAL StateFlags = C.GTK_STATE_FLAG_NORMAL + STATE_FLAG_ACTIVE StateFlags = C.GTK_STATE_FLAG_ACTIVE + STATE_FLAG_PRELIGHT StateFlags = C.GTK_STATE_FLAG_PRELIGHT + STATE_FLAG_SELECTED StateFlags = C.GTK_STATE_FLAG_SELECTED + STATE_FLAG_INSENSITIVE StateFlags = C.GTK_STATE_FLAG_INSENSITIVE + STATE_FLAG_INCONSISTENT StateFlags = C.GTK_STATE_FLAG_INCONSISTENT + STATE_FLAG_FOCUSED StateFlags = C.GTK_STATE_FLAG_FOCUSED + STATE_FLAG_BACKDROP StateFlags = C.GTK_STATE_FLAG_BACKDROP +) + +func marshalStateFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return StateFlags(c), nil +} + +// TargetFlags is a representation of GTK's GtkTargetFlags. +type TargetFlags int + +const ( + TARGET_SAME_APP TargetFlags = C.GTK_TARGET_SAME_APP + TARGET_SAME_WIDGET TargetFlags = C.GTK_TARGET_SAME_WIDGET + TARGET_OTHER_APP TargetFlags = C.GTK_TARGET_OTHER_APP + TARGET_OTHER_WIDGET TargetFlags = C.GTK_TARGET_OTHER_WIDGET +) + +func marshalTargetFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return TargetFlags(c), nil +} + +// ToolbarStyle is a representation of GTK's GtkToolbarStyle. +type ToolbarStyle int + +const ( + TOOLBAR_ICONS ToolbarStyle = C.GTK_TOOLBAR_ICONS + TOOLBAR_TEXT ToolbarStyle = C.GTK_TOOLBAR_TEXT + TOOLBAR_BOTH ToolbarStyle = C.GTK_TOOLBAR_BOTH + TOOLBAR_BOTH_HORIZ ToolbarStyle = C.GTK_TOOLBAR_BOTH_HORIZ +) + +func marshalToolbarStyle(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return ToolbarStyle(c), nil +} + +// TreeModelFlags is a representation of GTK's GtkTreeModelFlags. +type TreeModelFlags int + +const ( + TREE_MODEL_ITERS_PERSIST TreeModelFlags = C.GTK_TREE_MODEL_ITERS_PERSIST + TREE_MODEL_LIST_ONLY TreeModelFlags = C.GTK_TREE_MODEL_LIST_ONLY +) + +func marshalTreeModelFlags(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return TreeModelFlags(c), nil +} + +// WindowPosition is a representation of GTK's GtkWindowPosition. +type WindowPosition int + +const ( + WIN_POS_NONE WindowPosition = C.GTK_WIN_POS_NONE + WIN_POS_CENTER WindowPosition = C.GTK_WIN_POS_CENTER + WIN_POS_MOUSE WindowPosition = C.GTK_WIN_POS_MOUSE + WIN_POS_CENTER_ALWAYS WindowPosition = C.GTK_WIN_POS_CENTER_ALWAYS + WIN_POS_CENTER_ON_PARENT WindowPosition = C.GTK_WIN_POS_CENTER_ON_PARENT +) + +func marshalWindowPosition(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return WindowPosition(c), nil +} + +// WindowType is a representation of GTK's GtkWindowType. +type WindowType int + +const ( + WINDOW_TOPLEVEL WindowType = C.GTK_WINDOW_TOPLEVEL + WINDOW_POPUP WindowType = C.GTK_WINDOW_POPUP +) + +func marshalWindowType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return WindowType(c), nil +} + +// WrapMode is a representation of GTK's GtkWrapMode. +type WrapMode int + +const ( + WRAP_NONE WrapMode = C.GTK_WRAP_NONE + WRAP_CHAR WrapMode = C.GTK_WRAP_CHAR + WRAP_WORD WrapMode = C.GTK_WRAP_WORD + WRAP_WORD_CHAR WrapMode = C.GTK_WRAP_WORD_CHAR +) + +func marshalWrapMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return WrapMode(c), nil +} + +/* + * Init and main event loop + */ + +/* +Init() is a wrapper around gtk_init() and must be called before any +other GTK calls and is used to initialize everything necessary. + +In addition to setting up GTK for usage, a pointer to a slice of +strings may be passed in to parse standard GTK command line arguments. +args will be modified to remove any flags that were handled. +Alternatively, nil may be passed in to not perform any command line +parsing. +*/ +func Init(args *[]string) { + if args != nil { + argc := C.int(len(*args)) + argv := C.make_strings(argc) + defer C.destroy_strings(argv) + + for i, arg := range *args { + cstr := C.CString(arg) + C.set_string(argv, C.int(i), (*C.gchar)(cstr)) + } + + C.gtk_init((*C.int)(unsafe.Pointer(&argc)), + (***C.char)(unsafe.Pointer(&argv))) + + unhandled := make([]string, argc) + for i := 0; i < int(argc); i++ { + cstr := C.get_string(argv, C.int(i)) + unhandled[i] = C.GoString((*C.char)(cstr)) + C.free(unsafe.Pointer(cstr)) + } + *args = unhandled + } else { + C.gtk_init(nil, nil) + } +} + +// Main() is a wrapper around gtk_main() and runs the GTK main loop, +// blocking until MainQuit() is called. +func Main() { + C.gtk_main() +} + +// MainIteration is a wrapper around gtk_main_iteration. +func MainIteration() bool { + return gobool(C.gtk_main_iteration()) +} + +// MainIterationDo is a wrapper around gtk_main_iteration_do. +func MainIterationDo(blocking bool) bool { + return gobool(C.gtk_main_iteration_do(gbool(blocking))) +} + +// EventsPending is a wrapper around gtk_events_pending. +func EventsPending() bool { + return gobool(C.gtk_events_pending()) +} + +// MainQuit() is a wrapper around gtk_main_quit() is used to terminate +// the GTK main loop (started by Main()). +func MainQuit() { + C.gtk_main_quit() +} + +/* + * GtkAdjustment + */ + +// Adjustment is a representation of GTK's GtkAdjustment. +type Adjustment struct { + glib.InitiallyUnowned +} + +// native returns a pointer to the underlying GtkAdjustment. +func (v *Adjustment) native() *C.GtkAdjustment { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkAdjustment(p) +} + +func marshalAdjustment(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapAdjustment(obj), nil +} + +func wrapAdjustment(obj *glib.Object) *Adjustment { + return &Adjustment{glib.InitiallyUnowned{obj}} +} + +// AdjustmentNew is a wrapper around gtk_adjustment_new(). +func AdjustmentNew(value, lower, upper, stepIncrement, pageIncrement, pageSize float64) (*Adjustment, error) { + c := C.gtk_adjustment_new(C.gdouble(value), + C.gdouble(lower), + C.gdouble(upper), + C.gdouble(stepIncrement), + C.gdouble(pageIncrement), + C.gdouble(pageSize)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapAdjustment(obj), nil +} + +// GetValue is a wrapper around gtk_adjustment_get_value(). +func (v *Adjustment) GetValue() float64 { + c := C.gtk_adjustment_get_value(v.native()) + return float64(c) +} + +// SetValue is a wrapper around gtk_adjustment_set_value(). +func (v *Adjustment) SetValue(value float64) { + C.gtk_adjustment_set_value(v.native(), C.gdouble(value)) +} + +// GetLower is a wrapper around gtk_adjustment_get_lower(). +func (v *Adjustment) GetLower() float64 { + c := C.gtk_adjustment_get_lower(v.native()) + return float64(c) +} + +// GetPageSize is a wrapper around gtk_adjustment_get_page_size(). +func (v *Adjustment) GetPageSize() float64 { + return float64(C.gtk_adjustment_get_page_size(v.native())) +} + +// SetPageSize is a wrapper around gtk_adjustment_set_page_size(). +func (v *Adjustment) SetPageSize(value float64) { + C.gtk_adjustment_set_page_size(v.native(), C.gdouble(value)) +} + +// Configure is a wrapper around gtk_adjustment_configure(). +func (v *Adjustment) Configure(value, lower, upper, stepIncrement, pageIncrement, pageSize float64) { + C.gtk_adjustment_configure(v.native(), C.gdouble(value), + C.gdouble(lower), C.gdouble(upper), C.gdouble(stepIncrement), + C.gdouble(pageIncrement), C.gdouble(pageSize)) +} + +// SetLower is a wrapper around gtk_adjustment_set_lower(). +func (v *Adjustment) SetLower(value float64) { + C.gtk_adjustment_set_lower(v.native(), C.gdouble(value)) +} + +// GetUpper is a wrapper around gtk_adjustment_get_upper(). +func (v *Adjustment) GetUpper() float64 { + c := C.gtk_adjustment_get_upper(v.native()) + return float64(c) +} + +// SetUpper is a wrapper around gtk_adjustment_set_upper(). +func (v *Adjustment) SetUpper(value float64) { + C.gtk_adjustment_set_upper(v.native(), C.gdouble(value)) +} + +// GetPageIncrement is a wrapper around gtk_adjustment_get_page_increment(). +func (v *Adjustment) GetPageIncrement() float64 { + c := C.gtk_adjustment_get_page_increment(v.native()) + return float64(c) +} + +// SetPageIncrement is a wrapper around gtk_adjustment_set_page_increment(). +func (v *Adjustment) SetPageIncrement(value float64) { + C.gtk_adjustment_set_page_increment(v.native(), C.gdouble(value)) +} + +// GetStepIncrement is a wrapper around gtk_adjustment_get_step_increment(). +func (v *Adjustment) GetStepIncrement() float64 { + c := C.gtk_adjustment_get_step_increment(v.native()) + return float64(c) +} + +// SetStepIncrement is a wrapper around gtk_adjustment_set_step_increment(). +func (v *Adjustment) SetStepIncrement(value float64) { + C.gtk_adjustment_set_step_increment(v.native(), C.gdouble(value)) +} + +// GetMinimumIncrement is a wrapper around gtk_adjustment_get_minimum_increment(). +func (v *Adjustment) GetMinimumIncrement() float64 { + c := C.gtk_adjustment_get_minimum_increment(v.native()) + return float64(c) +} + +/* +void gtk_adjustment_clamp_page () +void gtk_adjustment_changed () +void gtk_adjustment_value_changed () +void gtk_adjustment_configure () +*/ + +/* + * GtkAssistant + */ + +// Assistant is a representation of GTK's GtkAssistant. +type Assistant struct { + Window +} + +// native returns a pointer to the underlying GtkAssistant. +func (v *Assistant) native() *C.GtkAssistant { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkAssistant(p) +} + +func marshalAssistant(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapAssistant(obj), nil +} + +func wrapAssistant(obj *glib.Object) *Assistant { + return &Assistant{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} +} + +// AssistantNew is a wrapper around gtk_assistant_new(). +func AssistantNew() (*Assistant, error) { + c := C.gtk_assistant_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapAssistant(obj), nil +} + +// GetCurrentPage is a wrapper around gtk_assistant_get_current_page(). +func (v *Assistant) GetCurrentPage() int { + c := C.gtk_assistant_get_current_page(v.native()) + return int(c) +} + +// SetCurrentPage is a wrapper around gtk_assistant_set_current_page(). +func (v *Assistant) SetCurrentPage(pageNum int) { + C.gtk_assistant_set_current_page(v.native(), C.gint(pageNum)) +} + +// GetNPages is a wrapper around gtk_assistant_get_n_pages(). +func (v *Assistant) GetNPages() int { + c := C.gtk_assistant_get_n_pages(v.native()) + return int(c) +} + +// GetNthPage is a wrapper around gtk_assistant_get_nth_page(). +func (v *Assistant) GetNthPage(pageNum int) (*Widget, error) { + c := C.gtk_assistant_get_nth_page(v.native(), C.gint(pageNum)) + if c == nil { + return nil, fmt.Errorf("page %d is out of bounds", pageNum) + } + + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +// PrependPage is a wrapper around gtk_assistant_prepend_page(). +func (v *Assistant) PrependPage(page IWidget) int { + c := C.gtk_assistant_prepend_page(v.native(), page.toWidget()) + return int(c) +} + +// AppendPage is a wrapper around gtk_assistant_append_page(). +func (v *Assistant) AppendPage(page IWidget) int { + c := C.gtk_assistant_append_page(v.native(), page.toWidget()) + return int(c) +} + +// InsertPage is a wrapper around gtk_assistant_insert_page(). +func (v *Assistant) InsertPage(page IWidget, position int) int { + c := C.gtk_assistant_insert_page(v.native(), page.toWidget(), + C.gint(position)) + return int(c) +} + +// RemovePage is a wrapper around gtk_assistant_remove_page(). +func (v *Assistant) RemovePage(pageNum int) { + C.gtk_assistant_remove_page(v.native(), C.gint(pageNum)) +} + +// TODO: gtk_assistant_set_forward_page_func + +// SetPageType is a wrapper around gtk_assistant_set_page_type(). +func (v *Assistant) SetPageType(page IWidget, ptype AssistantPageType) { + C.gtk_assistant_set_page_type(v.native(), page.toWidget(), + C.GtkAssistantPageType(ptype)) +} + +// GetPageType is a wrapper around gtk_assistant_get_page_type(). +func (v *Assistant) GetPageType(page IWidget) AssistantPageType { + c := C.gtk_assistant_get_page_type(v.native(), page.toWidget()) + return AssistantPageType(c) +} + +// SetPageTitle is a wrapper around gtk_assistant_set_page_title(). +func (v *Assistant) SetPageTitle(page IWidget, title string) { + cstr := C.CString(title) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_assistant_set_page_title(v.native(), page.toWidget(), + (*C.gchar)(cstr)) +} + +// GetPageTitle is a wrapper around gtk_assistant_get_page_title(). +func (v *Assistant) GetPageTitle(page IWidget) string { + c := C.gtk_assistant_get_page_title(v.native(), page.toWidget()) + return C.GoString((*C.char)(c)) +} + +// SetPageComplete is a wrapper around gtk_assistant_set_page_complete(). +func (v *Assistant) SetPageComplete(page IWidget, complete bool) { + C.gtk_assistant_set_page_complete(v.native(), page.toWidget(), + gbool(complete)) +} + +// GetPageComplete is a wrapper around gtk_assistant_get_page_complete(). +func (v *Assistant) GetPageComplete(page IWidget) bool { + c := C.gtk_assistant_get_page_complete(v.native(), page.toWidget()) + return gobool(c) +} + +// AddActionWidget is a wrapper around gtk_assistant_add_action_widget(). +func (v *Assistant) AddActionWidget(child IWidget) { + C.gtk_assistant_add_action_widget(v.native(), child.toWidget()) +} + +// RemoveActionWidget is a wrapper around gtk_assistant_remove_action_widget(). +func (v *Assistant) RemoveActionWidget(child IWidget) { + C.gtk_assistant_remove_action_widget(v.native(), child.toWidget()) +} + +// UpdateButtonsState is a wrapper around gtk_assistant_update_buttons_state(). +func (v *Assistant) UpdateButtonsState() { + C.gtk_assistant_update_buttons_state(v.native()) +} + +// Commit is a wrapper around gtk_assistant_commit(). +func (v *Assistant) Commit() { + C.gtk_assistant_commit(v.native()) +} + +// NextPage is a wrapper around gtk_assistant_next_page(). +func (v *Assistant) NextPage() { + C.gtk_assistant_next_page(v.native()) +} + +// PreviousPage is a wrapper around gtk_assistant_previous_page(). +func (v *Assistant) PreviousPage() { + C.gtk_assistant_previous_page(v.native()) +} + +/* + * GtkBin + */ + +// Bin is a representation of GTK's GtkBin. +type Bin struct { + Container +} + +// native returns a pointer to the underlying GtkBin. +func (v *Bin) native() *C.GtkBin { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkBin(p) +} + +func marshalBin(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapBin(obj), nil +} + +func wrapBin(obj *glib.Object) *Bin { + return &Bin{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// GetChild is a wrapper around gtk_bin_get_child(). +func (v *Bin) GetChild() (*Widget, error) { + c := C.gtk_bin_get_child(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +/* + * GtkBuilder + */ + +// Builder is a representation of GTK's GtkBuilder. +type Builder struct { + *glib.Object +} + +// native() returns a pointer to the underlying GtkBuilder. +func (b *Builder) native() *C.GtkBuilder { + if b == nil || b.GObject == nil { + return nil + } + p := unsafe.Pointer(b.GObject) + return C.toGtkBuilder(p) +} + +func marshalBuilder(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return &Builder{obj}, nil +} + +// BuilderNew is a wrapper around gtk_builder_new(). +func BuilderNew() (*Builder, error) { + c := C.gtk_builder_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return &Builder{obj}, nil +} + +// AddFromFile is a wrapper around gtk_builder_add_from_file(). +func (b *Builder) AddFromFile(filename string) error { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_builder_add_from_file(b.native(), (*C.gchar)(cstr), &err) + if res == 0 { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// AddFromResource is a wrapper around gtk_builder_add_from_resource(). +func (b *Builder) AddFromResource(path string) error { + cstr := C.CString(path) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_builder_add_from_resource(b.native(), (*C.gchar)(cstr), &err) + if res == 0 { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// AddFromString is a wrapper around gtk_builder_add_from_string(). +func (b *Builder) AddFromString(str string) error { + cstr := C.CString(str) + defer C.free(unsafe.Pointer(cstr)) + length := (C.gsize)(len(str)) + var err *C.GError = nil + res := C.gtk_builder_add_from_string(b.native(), (*C.gchar)(cstr), length, &err) + if res == 0 { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// GetObject is a wrapper around gtk_builder_get_object(). The returned result +// is an IObject, so it will need to be type-asserted to the appropriate type before +// being used. For example, to get an object and type assert it as a window: +// +// obj, err := builder.GetObject("window") +// if err != nil { +// // object not found +// return +// } +// if w, ok := obj.(*gtk.Window); ok { +// // do stuff with w here +// } else { +// // not a *gtk.Window +// } +// +func (b *Builder) GetObject(name string) (glib.IObject, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_builder_get_object(b.native(), (*C.gchar)(cstr)) + if c == nil { + return nil, errors.New("object '" + name + "' not found") + } + obj, err := cast(c) + if err != nil { + return nil, err + } + return obj, nil +} + +var ( + builderSignals = struct { + sync.RWMutex + m map[*C.GtkBuilder]map[string]interface{} + }{ + m: make(map[*C.GtkBuilder]map[string]interface{}), + } +) + +// ConnectSignals is a wrapper around gtk_builder_connect_signals_full(). +func (b *Builder) ConnectSignals(signals map[string]interface{}) { + builderSignals.Lock() + builderSignals.m[b.native()] = signals + builderSignals.Unlock() + + C._gtk_builder_connect_signals_full(b.native()) +} + +/* + * GtkButton + */ + +// Button is a representation of GTK's GtkButton. +type Button struct { + Bin +} + +// native() returns a pointer to the underlying GtkButton. +func (v *Button) native() *C.GtkButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkButton(p) +} + +func marshalButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapButton(obj), nil +} + +func wrapButton(obj *glib.Object) *Button { + return &Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// ButtonNew() is a wrapper around gtk_button_new(). +func ButtonNew() (*Button, error) { + c := C.gtk_button_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapButton(obj), nil +} + +// ButtonNewWithLabel() is a wrapper around gtk_button_new_with_label(). +func ButtonNewWithLabel(label string) (*Button, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_button_new_with_label((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapButton(obj), nil +} + +// ButtonNewWithMnemonic() is a wrapper around gtk_button_new_with_mnemonic(). +func ButtonNewWithMnemonic(label string) (*Button, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_button_new_with_mnemonic((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapButton(obj), nil +} + +// Clicked() is a wrapper around gtk_button_clicked(). +func (v *Button) Clicked() { + C.gtk_button_clicked(v.native()) +} + +// SetRelief() is a wrapper around gtk_button_set_relief(). +func (v *Button) SetRelief(newStyle ReliefStyle) { + C.gtk_button_set_relief(v.native(), C.GtkReliefStyle(newStyle)) +} + +// GetRelief() is a wrapper around gtk_button_get_relief(). +func (v *Button) GetRelief() ReliefStyle { + c := C.gtk_button_get_relief(v.native()) + return ReliefStyle(c) +} + +// SetLabel() is a wrapper around gtk_button_set_label(). +func (v *Button) SetLabel(label string) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_button_set_label(v.native(), (*C.gchar)(cstr)) +} + +// GetLabel() is a wrapper around gtk_button_get_label(). +func (v *Button) GetLabel() (string, error) { + c := C.gtk_button_get_label(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// SetUseUnderline() is a wrapper around gtk_button_set_use_underline(). +func (v *Button) SetUseUnderline(useUnderline bool) { + C.gtk_button_set_use_underline(v.native(), gbool(useUnderline)) +} + +// GetUseUnderline() is a wrapper around gtk_button_get_use_underline(). +func (v *Button) GetUseUnderline() bool { + c := C.gtk_button_get_use_underline(v.native()) + return gobool(c) +} + +// 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)) +} + +// 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) +} + +// SetImage() is a wrapper around gtk_button_set_image(). +func (v *Button) SetImage(image IWidget) { + C.gtk_button_set_image(v.native(), image.toWidget()) +} + +// GetImage() is a wrapper around gtk_button_get_image(). +func (v *Button) GetImage() (*Widget, error) { + c := C.gtk_button_get_image(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +// SetImagePosition() is a wrapper around gtk_button_set_image_position(). +func (v *Button) SetImagePosition(position PositionType) { + C.gtk_button_set_image_position(v.native(), C.GtkPositionType(position)) +} + +// GetImagePosition() is a wrapper around gtk_button_get_image_position(). +func (v *Button) GetImagePosition() PositionType { + c := C.gtk_button_get_image_position(v.native()) + return PositionType(c) +} + +// SetAlwaysShowImage() is a wrapper around gtk_button_set_always_show_image(). +func (v *Button) SetAlwaysShowImage(alwaysShow bool) { + C.gtk_button_set_always_show_image(v.native(), gbool(alwaysShow)) +} + +// GetAlwaysShowImage() is a wrapper around gtk_button_get_always_show_image(). +func (v *Button) GetAlwaysShowImage() bool { + c := C.gtk_button_get_always_show_image(v.native()) + return gobool(c) +} + +// GetEventWindow() is a wrapper around gtk_button_get_event_window(). +func (v *Button) GetEventWindow() (*gdk.Window, error) { + c := C.gtk_button_get_event_window(v.native()) + if c == nil { + return nil, nilPtrErr + } + + w := &gdk.Window{wrapObject(unsafe.Pointer(c))} + return w, nil +} + +/* + * GtkColorButton + */ + +// ColorButton is a representation of GTK's GtkColorButton. +type ColorButton struct { + Button + + // Interfaces + ColorChooser +} + +// Native returns a pointer to the underlying GtkColorButton. +func (v *ColorButton) native() *C.GtkColorButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkColorButton(p) +} + +func wrapColorButton(obj *glib.Object) *ColorButton { + cc := wrapColorChooser(obj) + return &ColorButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}, *cc} +} + +// ColorButtonNew is a wrapper around gtk_color_button_new(). +func ColorButtonNew() (*ColorButton, error) { + c := C.gtk_color_button_new() + if c == nil { + return nil, nilPtrErr + } + return wrapColorButton(wrapObject(unsafe.Pointer(c))), nil +} + +// ColorButtonNewWithRGBA is a wrapper around gtk_color_button_new_with_rgba(). +func ColorButtonNewWithRGBA(gdkColor *gdk.RGBA) (*ColorButton, error) { + c := C.gtk_color_button_new_with_rgba((*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) + if c == nil { + return nil, nilPtrErr + } + return wrapColorButton(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkBox + */ + +// Box is a representation of GTK's GtkBox. +type Box struct { + Container +} + +// native() returns a pointer to the underlying GtkBox. +func (v *Box) native() *C.GtkBox { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkBox(p) +} + +func marshalBox(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapBox(obj), nil +} + +func wrapBox(obj *glib.Object) *Box { + return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// BoxNew() is a wrapper around gtk_box_new(). +func BoxNew(orientation Orientation, spacing int) (*Box, error) { + c := C.gtk_box_new(C.GtkOrientation(orientation), C.gint(spacing)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapBox(obj), nil +} + +// PackStart() is a wrapper around gtk_box_pack_start(). +func (v *Box) PackStart(child IWidget, expand, fill bool, padding uint) { + C.gtk_box_pack_start(v.native(), child.toWidget(), gbool(expand), + gbool(fill), C.guint(padding)) +} + +// PackEnd() is a wrapper around gtk_box_pack_end(). +func (v *Box) PackEnd(child IWidget, expand, fill bool, padding uint) { + C.gtk_box_pack_end(v.native(), child.toWidget(), gbool(expand), + gbool(fill), C.guint(padding)) +} + +// GetHomogeneous() is a wrapper around gtk_box_get_homogeneous(). +func (v *Box) GetHomogeneous() bool { + c := C.gtk_box_get_homogeneous(v.native()) + return gobool(c) +} + +// SetHomogeneous() is a wrapper around gtk_box_set_homogeneous(). +func (v *Box) SetHomogeneous(homogeneous bool) { + C.gtk_box_set_homogeneous(v.native(), gbool(homogeneous)) +} + +// GetSpacing() is a wrapper around gtk_box_get_spacing(). +func (v *Box) GetSpacing() int { + c := C.gtk_box_get_spacing(v.native()) + return int(c) +} + +// SetSpacing() is a wrapper around gtk_box_set_spacing() +func (v *Box) SetSpacing(spacing int) { + C.gtk_box_set_spacing(v.native(), C.gint(spacing)) +} + +// ReorderChild() is a wrapper around gtk_box_reorder_child(). +func (v *Box) ReorderChild(child IWidget, position int) { + C.gtk_box_reorder_child(v.native(), child.toWidget(), C.gint(position)) +} + +// QueryChildPacking() is a wrapper around gtk_box_query_child_packing(). +func (v *Box) QueryChildPacking(child IWidget) (expand, fill bool, padding uint, packType PackType) { + var cexpand, cfill C.gboolean + var cpadding C.guint + var cpackType C.GtkPackType + + C.gtk_box_query_child_packing(v.native(), child.toWidget(), &cexpand, + &cfill, &cpadding, &cpackType) + return gobool(cexpand), gobool(cfill), uint(cpadding), PackType(cpackType) +} + +// SetChildPacking() is a wrapper around gtk_box_set_child_packing(). +func (v *Box) SetChildPacking(child IWidget, expand, fill bool, padding uint, packType PackType) { + C.gtk_box_set_child_packing(v.native(), child.toWidget(), gbool(expand), + gbool(fill), C.guint(padding), C.GtkPackType(packType)) +} + +/* + * GtkCalendar + */ + +// Calendar is a representation of GTK's GtkCalendar. +type Calendar struct { + Widget +} + +// native() returns a pointer to the underlying GtkCalendar. +func (v *Calendar) native() *C.GtkCalendar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCalendar(p) +} + +func marshalCalendar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCalendar(obj), nil +} + +func wrapCalendar(obj *glib.Object) *Calendar { + return &Calendar{Widget{glib.InitiallyUnowned{obj}}} +} + +// CalendarNew is a wrapper around gtk_calendar_new(). +func CalendarNew() (*Calendar, error) { + c := C.gtk_calendar_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCalendar(obj), nil +} + +// SelectMonth is a wrapper around gtk_calendar_select_month(). +func (v *Calendar) SelectMonth(month, year uint) { + C.gtk_calendar_select_month(v.native(), C.guint(month), C.guint(year)) +} + +// SelectDay is a wrapper around gtk_calendar_select_day(). +func (v *Calendar) SelectDay(day uint) { + C.gtk_calendar_select_day(v.native(), C.guint(day)) +} + +// MarkDay is a wrapper around gtk_calendar_mark_day(). +func (v *Calendar) MarkDay(day uint) { + C.gtk_calendar_mark_day(v.native(), C.guint(day)) +} + +// UnmarkDay is a wrapper around gtk_calendar_unmark_day(). +func (v *Calendar) UnmarkDay(day uint) { + C.gtk_calendar_unmark_day(v.native(), C.guint(day)) +} + +// GetDayIsMarked is a wrapper around gtk_calendar_get_day_is_marked(). +func (v *Calendar) GetDayIsMarked(day uint) bool { + c := C.gtk_calendar_get_day_is_marked(v.native(), C.guint(day)) + return gobool(c) +} + +// ClearMarks is a wrapper around gtk_calendar_clear_marks(). +func (v *Calendar) ClearMarks() { + C.gtk_calendar_clear_marks(v.native()) +} + +// GetDisplayOptions is a wrapper around gtk_calendar_get_display_options(). +func (v *Calendar) GetDisplayOptions() CalendarDisplayOptions { + c := C.gtk_calendar_get_display_options(v.native()) + return CalendarDisplayOptions(c) +} + +// SetDisplayOptions is a wrapper around gtk_calendar_set_display_options(). +func (v *Calendar) SetDisplayOptions(flags CalendarDisplayOptions) { + C.gtk_calendar_set_display_options(v.native(), + C.GtkCalendarDisplayOptions(flags)) +} + +// GetDate is a wrapper around gtk_calendar_get_date(). +func (v *Calendar) GetDate() (year, month, day uint) { + var cyear, cmonth, cday C.guint + C.gtk_calendar_get_date(v.native(), &cyear, &cmonth, &cday) + return uint(cyear), uint(cmonth), uint(cday) +} + +// TODO gtk_calendar_set_detail_func + +// GetDetailWidthChars is a wrapper around gtk_calendar_get_detail_width_chars(). +func (v *Calendar) GetDetailWidthChars() int { + c := C.gtk_calendar_get_detail_width_chars(v.native()) + return int(c) +} + +// SetDetailWidthChars is a wrapper around gtk_calendar_set_detail_width_chars(). +func (v *Calendar) SetDetailWidthChars(chars int) { + C.gtk_calendar_set_detail_width_chars(v.native(), C.gint(chars)) +} + +// GetDetailHeightRows is a wrapper around gtk_calendar_get_detail_height_rows(). +func (v *Calendar) GetDetailHeightRows() int { + c := C.gtk_calendar_get_detail_height_rows(v.native()) + return int(c) +} + +// SetDetailHeightRows is a wrapper around gtk_calendar_set_detail_height_rows(). +func (v *Calendar) SetDetailHeightRows(rows int) { + C.gtk_calendar_set_detail_height_rows(v.native(), C.gint(rows)) +} + +/* + * GtkCellLayout + */ + +// CellLayout is a representation of GTK's GtkCellLayout GInterface. +type CellLayout struct { + *glib.Object +} + +// ICellLayout is an interface type implemented by all structs +// embedding a CellLayout. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkCellLayout. +type ICellLayout interface { + toCellLayout() *C.GtkCellLayout +} + +// native() returns a pointer to the underlying GObject as a GtkCellLayout. +func (v *CellLayout) native() *C.GtkCellLayout { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellLayout(p) +} + +func marshalCellLayout(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellLayout(obj), nil +} + +func wrapCellLayout(obj *glib.Object) *CellLayout { + return &CellLayout{obj} +} + +func (v *CellLayout) toCellLayout() *C.GtkCellLayout { + if v == nil { + return nil + } + return v.native() +} + +// PackStart() is a wrapper around gtk_cell_layout_pack_start(). +func (v *CellLayout) PackStart(cell ICellRenderer, expand bool) { + C.gtk_cell_layout_pack_start(v.native(), cell.toCellRenderer(), + gbool(expand)) +} + +// AddAttribute() is a wrapper around gtk_cell_layout_add_attribute(). +func (v *CellLayout) AddAttribute(cell ICellRenderer, attribute string, column int) { + cstr := C.CString(attribute) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_cell_layout_add_attribute(v.native(), cell.toCellRenderer(), + (*C.gchar)(cstr), C.gint(column)) +} + +/* + * GtkCellRenderer + */ + +// CellRenderer is a representation of GTK's GtkCellRenderer. +type CellRenderer struct { + glib.InitiallyUnowned +} + +// ICellRenderer is an interface type implemented by all structs +// embedding a CellRenderer. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkCellRenderer. +type ICellRenderer interface { + toCellRenderer() *C.GtkCellRenderer +} + +// native returns a pointer to the underlying GtkCellRenderer. +func (v *CellRenderer) native() *C.GtkCellRenderer { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellRenderer(p) +} + +func (v *CellRenderer) toCellRenderer() *C.GtkCellRenderer { + if v == nil { + return nil + } + return v.native() +} + +func marshalCellRenderer(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRenderer(obj), nil +} + +func wrapCellRenderer(obj *glib.Object) *CellRenderer { + return &CellRenderer{glib.InitiallyUnowned{obj}} +} + +/* + * GtkCellRendererSpinner + */ + +// CellRendererSpinner is a representation of GTK's GtkCellRendererSpinner. +type CellRendererSpinner struct { + CellRenderer +} + +// native returns a pointer to the underlying GtkCellRendererSpinner. +func (v *CellRendererSpinner) native() *C.GtkCellRendererSpinner { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellRendererSpinner(p) +} + +func marshalCellRendererSpinner(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererSpinner(obj), nil +} + +func wrapCellRendererSpinner(obj *glib.Object) *CellRendererSpinner { + return &CellRendererSpinner{CellRenderer{glib.InitiallyUnowned{obj}}} +} + +// CellRendererSpinnerNew is a wrapper around gtk_cell_renderer_text_new(). +func CellRendererSpinnerNew() (*CellRendererSpinner, error) { + c := C.gtk_cell_renderer_spinner_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererSpinner(obj), nil +} + +/* + * GtkCellRendererPixbuf + */ + +// CellRendererPixbuf is a representation of GTK's GtkCellRendererPixbuf. +type CellRendererPixbuf struct { + CellRenderer +} + +// native returns a pointer to the underlying GtkCellRendererPixbuf. +func (v *CellRendererPixbuf) native() *C.GtkCellRendererPixbuf { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellRendererPixbuf(p) +} + +func marshalCellRendererPixbuf(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererPixbuf(obj), nil +} + +func wrapCellRendererPixbuf(obj *glib.Object) *CellRendererPixbuf { + return &CellRendererPixbuf{CellRenderer{glib.InitiallyUnowned{obj}}} +} + +// CellRendererPixbufNew is a wrapper around gtk_cell_renderer_pixbuf_new(). +func CellRendererPixbufNew() (*CellRendererPixbuf, error) { + c := C.gtk_cell_renderer_pixbuf_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererPixbuf(obj), nil +} + +/* + * GtkCellRendererText + */ + +// CellRendererText is a representation of GTK's GtkCellRendererText. +type CellRendererText struct { + CellRenderer +} + +// native returns a pointer to the underlying GtkCellRendererText. +func (v *CellRendererText) native() *C.GtkCellRendererText { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellRendererText(p) +} + +func marshalCellRendererText(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererText(obj), nil +} + +func wrapCellRendererText(obj *glib.Object) *CellRendererText { + return &CellRendererText{CellRenderer{glib.InitiallyUnowned{obj}}} +} + +// CellRendererTextNew is a wrapper around gtk_cell_renderer_text_new(). +func CellRendererTextNew() (*CellRendererText, error) { + c := C.gtk_cell_renderer_text_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererText(obj), nil +} + +/* + * GtkCellRendererToggle + */ + +// CellRendererToggle is a representation of GTK's GtkCellRendererToggle. +type CellRendererToggle struct { + CellRenderer +} + +// native returns a pointer to the underlying GtkCellRendererToggle. +func (v *CellRendererToggle) native() *C.GtkCellRendererToggle { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCellRendererToggle(p) +} + +func (v *CellRendererToggle) toCellRenderer() *C.GtkCellRenderer { + if v == nil { + return nil + } + return v.CellRenderer.native() +} + +func marshalCellRendererToggle(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererToggle(obj), nil +} + +func wrapCellRendererToggle(obj *glib.Object) *CellRendererToggle { + return &CellRendererToggle{CellRenderer{glib.InitiallyUnowned{obj}}} +} + +// CellRendererToggleNew is a wrapper around gtk_cell_renderer_toggle_new(). +func CellRendererToggleNew() (*CellRendererToggle, error) { + c := C.gtk_cell_renderer_toggle_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCellRendererToggle(obj), nil +} + +// SetRadio is a wrapper around gtk_cell_renderer_toggle_set_radio(). +func (v *CellRendererToggle) SetRadio(set bool) { + C.gtk_cell_renderer_toggle_set_radio(v.native(), gbool(set)) +} + +// GetRadio is a wrapper around gtk_cell_renderer_toggle_get_radio(). +func (v *CellRendererToggle) GetRadio() bool { + c := C.gtk_cell_renderer_toggle_get_radio(v.native()) + return gobool(c) +} + +// SetActive is a wrapper arround gtk_cell_renderer_toggle_set_active(). +func (v *CellRendererToggle) SetActive(active bool) { + C.gtk_cell_renderer_toggle_set_active(v.native(), gbool(active)) +} + +// GetActive is a wrapper around gtk_cell_renderer_toggle_get_active(). +func (v *CellRendererToggle) GetActive() bool { + c := C.gtk_cell_renderer_toggle_get_active(v.native()) + return gobool(c) +} + +// SetActivatable is a wrapper around gtk_cell_renderer_toggle_set_activatable(). +func (v *CellRendererToggle) SetActivatable(activatable bool) { + C.gtk_cell_renderer_toggle_set_activatable(v.native(), + gbool(activatable)) +} + +// GetActivatable is a wrapper around gtk_cell_renderer_toggle_get_activatable(). +func (v *CellRendererToggle) GetActivatable() bool { + c := C.gtk_cell_renderer_toggle_get_activatable(v.native()) + return gobool(c) +} + +/* + * GtkCheckButton + */ + +// CheckButton is a wrapper around GTK's GtkCheckButton. +type CheckButton struct { + ToggleButton +} + +// native returns a pointer to the underlying GtkCheckButton. +func (v *CheckButton) native() *C.GtkCheckButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCheckButton(p) +} + +func marshalCheckButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckButton(obj), nil +} + +func wrapCheckButton(obj *glib.Object) *CheckButton { + return &CheckButton{ToggleButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}}} +} + +// CheckButtonNew is a wrapper around gtk_check_button_new(). +func CheckButtonNew() (*CheckButton, error) { + c := C.gtk_check_button_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckButton(obj), nil +} + +// CheckButtonNewWithLabel is a wrapper around +// gtk_check_button_new_with_label(). +func CheckButtonNewWithLabel(label string) (*CheckButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_check_button_new_with_label((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapCheckButton(wrapObject(unsafe.Pointer(c))), nil +} + +// CheckButtonNewWithMnemonic is a wrapper around +// gtk_check_button_new_with_mnemonic(). +func CheckButtonNewWithMnemonic(label string) (*CheckButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_check_button_new_with_mnemonic((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckButton(obj), nil +} + +/* + * GtkCheckMenuItem + */ + +type CheckMenuItem struct { + MenuItem +} + +// native returns a pointer to the underlying GtkCheckMenuItem. +func (v *CheckMenuItem) native() *C.GtkCheckMenuItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCheckMenuItem(p) +} + +func marshalCheckMenuItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckMenuItem(obj), nil +} + +func wrapCheckMenuItem(obj *glib.Object) *CheckMenuItem { + return &CheckMenuItem{MenuItem{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// CheckMenuItemNew is a wrapper around gtk_check_menu_item_new(). +func CheckMenuItemNew() (*CheckMenuItem, error) { + c := C.gtk_check_menu_item_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckMenuItem(obj), nil +} + +// CheckMenuItemNewWithLabel is a wrapper around +// gtk_check_menu_item_new_with_label(). +func CheckMenuItemNewWithLabel(label string) (*CheckMenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_check_menu_item_new_with_label((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckMenuItem(obj), nil +} + +// CheckMenuItemNewWithMnemonic is a wrapper around +// gtk_check_menu_item_new_with_mnemonic(). +func CheckMenuItemNewWithMnemonic(label string) (*CheckMenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_check_menu_item_new_with_mnemonic((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapCheckMenuItem(obj), nil +} + +// GetActive is a wrapper around gtk_check_menu_item_get_active(). +func (v *CheckMenuItem) GetActive() bool { + c := C.gtk_check_menu_item_get_active(v.native()) + return gobool(c) +} + +// SetActive is a wrapper around gtk_check_menu_item_set_active(). +func (v *CheckMenuItem) SetActive(isActive bool) { + C.gtk_check_menu_item_set_active(v.native(), gbool(isActive)) +} + +// Toggled is a wrapper around gtk_check_menu_item_toggled(). +func (v *CheckMenuItem) Toggled() { + C.gtk_check_menu_item_toggled(v.native()) +} + +// GetInconsistent is a wrapper around gtk_check_menu_item_get_inconsistent(). +func (v *CheckMenuItem) GetInconsistent() bool { + c := C.gtk_check_menu_item_get_inconsistent(v.native()) + return gobool(c) +} + +// SetInconsistent is a wrapper around gtk_check_menu_item_set_inconsistent(). +func (v *CheckMenuItem) SetInconsistent(setting bool) { + C.gtk_check_menu_item_set_inconsistent(v.native(), gbool(setting)) +} + +// SetDrawAsRadio is a wrapper around gtk_check_menu_item_set_draw_as_radio(). +func (v *CheckMenuItem) SetDrawAsRadio(drawAsRadio bool) { + C.gtk_check_menu_item_set_draw_as_radio(v.native(), gbool(drawAsRadio)) +} + +// GetDrawAsRadio is a wrapper around gtk_check_menu_item_get_draw_as_radio(). +func (v *CheckMenuItem) GetDrawAsRadio() bool { + c := C.gtk_check_menu_item_get_draw_as_radio(v.native()) + return gobool(c) +} + +/* + * GtkClipboard + */ + +// Clipboard is a wrapper around GTK's GtkClipboard. +type Clipboard struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkClipboard. +func (v *Clipboard) native() *C.GtkClipboard { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkClipboard(p) +} + +func marshalClipboard(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapClipboard(obj), nil +} + +func wrapClipboard(obj *glib.Object) *Clipboard { + return &Clipboard{obj} +} + +// Store is a wrapper around gtk_clipboard_store +func (v *Clipboard) Store() { + C.gtk_clipboard_store(v.native()) +} + +// ClipboardGet() is a wrapper around gtk_clipboard_get(). +func ClipboardGet(atom gdk.Atom) (*Clipboard, error) { + c := C.gtk_clipboard_get(C.GdkAtom(unsafe.Pointer(atom))) + if c == nil { + return nil, nilPtrErr + } + + cb := &Clipboard{wrapObject(unsafe.Pointer(c))} + return cb, nil +} + +// ClipboardGetForDisplay() is a wrapper around gtk_clipboard_get_for_display(). +func ClipboardGetForDisplay(display *gdk.Display, atom gdk.Atom) (*Clipboard, error) { + displayPtr := (*C.GdkDisplay)(unsafe.Pointer(display.Native())) + c := C.gtk_clipboard_get_for_display(displayPtr, + C.GdkAtom(unsafe.Pointer(atom))) + if c == nil { + return nil, nilPtrErr + } + + cb := &Clipboard{wrapObject(unsafe.Pointer(c))} + return cb, nil +} + +// WaitIsTextAvailable is a wrapper around gtk_clipboard_wait_is_text_available +func (v *Clipboard) WaitIsTextAvailable() bool { + c := C.gtk_clipboard_wait_is_text_available(v.native()) + return gobool(c) +} + +// WaitForText is a wrapper around gtk_clipboard_wait_for_text +func (v *Clipboard) WaitForText() (string, error) { + c := C.gtk_clipboard_wait_for_text(v.native()) + if c == nil { + return "", nilPtrErr + } + defer C.g_free(C.gpointer(c)) + return C.GoString((*C.char)(c)), nil +} + +// SetText() is a wrapper around gtk_clipboard_set_text(). +func (v *Clipboard) SetText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_clipboard_set_text(v.native(), (*C.gchar)(cstr), + C.gint(len(text))) +} + +// WaitIsRichTextAvailable is a wrapper around gtk_clipboard_wait_is_rich_text_available +func (v *Clipboard) WaitIsRichTextAvailable(buf *TextBuffer) bool { + c := C.gtk_clipboard_wait_is_rich_text_available(v.native(), buf.native()) + return gobool(c) +} + +// WaitIsUrisAvailable is a wrapper around gtk_clipboard_wait_is_uris_available +func (v *Clipboard) WaitIsUrisAvailable() bool { + c := C.gtk_clipboard_wait_is_uris_available(v.native()) + return gobool(c) +} + +// WaitIsImageAvailable is a wrapper around gtk_clipboard_wait_is_image_available +func (v *Clipboard) WaitIsImageAvailable() bool { + c := C.gtk_clipboard_wait_is_image_available(v.native()) + return gobool(c) +} + +// SetImage is a wrapper around gtk_clipboard_set_image +func (v *Clipboard) SetImage(pixbuf *gdk.Pixbuf) { + C.gtk_clipboard_set_image(v.native(), (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native()))) +} + +// WaitForImage is a wrapper around gtk_clipboard_wait_for_image +func (v *Clipboard) WaitForImage() (*gdk.Pixbuf, error) { + c := C.gtk_clipboard_wait_for_image(v.native()) + if c == nil { + return nil, nilPtrErr + } + + p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} + return p, nil +} + +// WaitIsTargetAvailable is a wrapper around gtk_clipboard_wait_is_target_available +func (v *Clipboard) WaitIsTargetAvailable(target gdk.Atom) bool { + c := C.gtk_clipboard_wait_is_target_available(v.native(), C.GdkAtom(unsafe.Pointer(target))) + return gobool(c) +} + +// WaitForContents is a wrapper around gtk_clipboard_wait_for_contents +func (v *Clipboard) WaitForContents(target gdk.Atom) (*SelectionData, error) { + c := C.gtk_clipboard_wait_for_contents(v.native(), C.GdkAtom(unsafe.Pointer(target))) + if c == nil { + return nil, nilPtrErr + } + p := &SelectionData{c} + runtime.SetFinalizer(p, (*SelectionData).free) + return p, nil +} + +/* + * GtkContainer + */ + +// Container is a representation of GTK's GtkContainer. +type Container struct { + Widget +} + +// native returns a pointer to the underlying GtkContainer. +func (v *Container) native() *C.GtkContainer { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkContainer(p) +} + +func marshalContainer(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapContainer(obj), nil +} + +func wrapContainer(obj *glib.Object) *Container { + return &Container{Widget{glib.InitiallyUnowned{obj}}} +} + +// Add is a wrapper around gtk_container_add(). +func (v *Container) Add(w IWidget) { + C.gtk_container_add(v.native(), w.toWidget()) +} + +// Remove is a wrapper around gtk_container_remove(). +func (v *Container) Remove(w IWidget) { + C.gtk_container_remove(v.native(), w.toWidget()) +} + +// TODO: gtk_container_add_with_properties + +// CheckResize is a wrapper around gtk_container_check_resize(). +func (v *Container) CheckResize() { + C.gtk_container_check_resize(v.native()) +} + +// TODO: gtk_container_foreach +// TODO: gtk_container_get_children +// TODO: gtk_container_get_path_for_child + +// GetFocusChild is a wrapper around gtk_container_get_focus_child(). +func (v *Container) GetFocusChild() *Widget { + c := C.gtk_container_get_focus_child(v.native()) + if c == nil { + return nil + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj) +} + +// SetFocusChild is a wrapper around gtk_container_set_focus_child(). +func (v *Container) SetFocusChild(child IWidget) { + C.gtk_container_set_focus_child(v.native(), child.toWidget()) +} + +// GetFocusVAdjustment is a wrapper around +// gtk_container_get_focus_vadjustment(). +func (v *Container) GetFocusVAdjustment() *Adjustment { + c := C.gtk_container_get_focus_vadjustment(v.native()) + if c == nil { + return nil + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapAdjustment(obj) +} + +// SetFocusVAdjustment is a wrapper around +// gtk_container_set_focus_vadjustment(). +func (v *Container) SetFocusVAdjustment(adjustment *Adjustment) { + C.gtk_container_set_focus_vadjustment(v.native(), adjustment.native()) +} + +// GetFocusHAdjustment is a wrapper around +// gtk_container_get_focus_hadjustment(). +func (v *Container) GetFocusHAdjustment() *Adjustment { + c := C.gtk_container_get_focus_hadjustment(v.native()) + if c == nil { + return nil + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapAdjustment(obj) +} + +// SetFocusHAdjustment is a wrapper around +// gtk_container_set_focus_hadjustment(). +func (v *Container) SetFocusHAdjustment(adjustment *Adjustment) { + C.gtk_container_set_focus_hadjustment(v.native(), adjustment.native()) +} + +// ChildType is a wrapper around gtk_container_child_type(). +func (v *Container) ChildType() glib.Type { + c := C.gtk_container_child_type(v.native()) + return glib.Type(c) +} + +// TODO: gtk_container_child_get_valist +// TODO: gtk_container_child_set_valist + +// ChildNotify is a wrapper around gtk_container_child_notify(). +func (v *Container) ChildNotify(child IWidget, childProperty string) { + cstr := C.CString(childProperty) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_container_child_notify(v.native(), child.toWidget(), + (*C.gchar)(cstr)) +} + +// ChildSetProperty is a wrapper around gtk_container_child_set_property(). +func (v *Container) ChildSetProperty(child IWidget, name string, value interface{}) error { + gv, e := glib.GValue(value) + if e != nil { + return e + } + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + C.gtk_container_child_set_property(v.native(), child.toWidget(), (*C.gchar)(cstr), (*C.GValue)(unsafe.Pointer(gv))) + return nil +} + +// TODO: gtk_container_forall + +// GetBorderWidth is a wrapper around gtk_container_get_border_width(). +func (v *Container) GetBorderWidth() uint { + c := C.gtk_container_get_border_width(v.native()) + return uint(c) +} + +// SetBorderWidth is a wrapper around gtk_container_set_border_width(). +func (v *Container) SetBorderWidth(borderWidth uint) { + C.gtk_container_set_border_width(v.native(), C.guint(borderWidth)) +} + +// PropagateDraw is a wrapper around gtk_container_propagate_draw(). +func (v *Container) PropagateDraw(child IWidget, cr *cairo.Context) { + context := (*C.cairo_t)(unsafe.Pointer(cr.Native())) + C.gtk_container_propagate_draw(v.native(), child.toWidget(), context) +} + +// GdkCairoSetSourcePixBuf() is a wrapper around gdk_cairo_set_source_pixbuf(). +func GdkCairoSetSourcePixBuf(cr *cairo.Context, pixbuf *gdk.Pixbuf, pixbufX, pixbufY float64) { + context := (*C.cairo_t)(unsafe.Pointer(cr.Native())) + ptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) + C.gdk_cairo_set_source_pixbuf(context, ptr, C.gdouble(pixbufX), C.gdouble(pixbufY)) +} + +// GetFocusChain is a wrapper around gtk_container_get_focus_chain(). +func (v *Container) GetFocusChain() ([]*Widget, bool) { + var cwlist *C.GList + c := C.gtk_container_get_focus_chain(v.native(), &cwlist) + + var widgets []*Widget + wlist := glib.WrapList(uintptr(unsafe.Pointer(cwlist))) + for ; wlist.Data() != nil; wlist = wlist.Next() { + widgets = append(widgets, wrapWidget(wrapObject(wlist.Data().(unsafe.Pointer)))) + } + return widgets, gobool(c) +} + +// SetFocusChain is a wrapper around gtk_container_set_focus_chain(). +func (v *Container) SetFocusChain(focusableWidgets []IWidget) { + var list *glib.List + for _, w := range focusableWidgets { + data := uintptr(unsafe.Pointer(w.toWidget())) + list = list.Append(data) + } + glist := (*C.GList)(unsafe.Pointer(list)) + C.gtk_container_set_focus_chain(v.native(), glist) +} + +/* + * GtkCssProvider + */ + +// CssProvider is a representation of GTK's GtkCssProvider. +type CssProvider struct { + *glib.Object +} + +func (v *CssProvider) toStyleProvider() *C.GtkStyleProvider { + if v == nil { + return nil + } + return C.toGtkStyleProvider(unsafe.Pointer(v.native())) +} + +// native returns a pointer to the underlying GtkCssProvider. +func (v *CssProvider) native() *C.GtkCssProvider { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkCssProvider(p) +} + +func wrapCssProvider(obj *glib.Object) *CssProvider { + return &CssProvider{obj} +} + +// CssProviderNew is a wrapper around gtk_css_provider_new(). +func CssProviderNew() (*CssProvider, error) { + c := C.gtk_css_provider_new() + if c == nil { + return nil, nilPtrErr + } + + return wrapCssProvider(wrapObject(unsafe.Pointer(c))), nil +} + +// LoadFromPath is a wrapper around gtk_css_provider_load_from_path(). +func (v *CssProvider) LoadFromPath(path string) error { + cpath := C.CString(path) + defer C.free(unsafe.Pointer(cpath)) + var gerr *C.GError + if C.gtk_css_provider_load_from_path(v.native(), (*C.gchar)(cpath), &gerr) == 0 { + defer C.g_error_free(gerr) + return errors.New(C.GoString((*C.char)(gerr.message))) + } + return nil +} + +// LoadFromData is a wrapper around gtk_css_provider_load_from_data(). +func (v *CssProvider) LoadFromData(data string) error { + cdata := C.CString(data) + defer C.free(unsafe.Pointer(cdata)) + var gerr *C.GError + if C.gtk_css_provider_load_from_data(v.native(), (*C.gchar)(unsafe.Pointer(cdata)), C.gssize(len(data)), &gerr) == 0 { + defer C.g_error_free(gerr) + return errors.New(C.GoString((*C.char)(gerr.message))) + } + return nil +} + +// ToString is a wrapper around gtk_css_provider_to_string(). +func (v *CssProvider) ToString() (string, error) { + c := C.gtk_css_provider_to_string(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString(c), nil +} + +// CssProviderGetDefault is a wrapper around gtk_css_provider_get_default(). +func CssProviderGetDefault() (*CssProvider, error) { + c := C.gtk_css_provider_get_default() + if c == nil { + return nil, nilPtrErr + } + + obj := wrapObject(unsafe.Pointer(c)) + return wrapCssProvider(obj), nil +} + +// GetNamed is a wrapper around gtk_css_provider_get_named(). +func CssProviderGetNamed(name string, variant string) (*CssProvider, error) { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + cvariant := C.CString(variant) + defer C.free(unsafe.Pointer(cvariant)) + + c := C.gtk_css_provider_get_named((*C.gchar)(cname), (*C.gchar)(cvariant)) + if c == nil { + return nil, nilPtrErr + } + + obj := wrapObject(unsafe.Pointer(c)) + return wrapCssProvider(obj), nil +} + +/* + * GtkDialog + */ + +// Dialog is a representation of GTK's GtkDialog. +type Dialog struct { + Window +} + +// native returns a pointer to the underlying GtkDialog. +func (v *Dialog) native() *C.GtkDialog { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkDialog(p) +} + +func marshalDialog(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapDialog(obj), nil +} + +func wrapDialog(obj *glib.Object) *Dialog { + return &Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} +} + +// DialogNew() is a wrapper around gtk_dialog_new(). +func DialogNew() (*Dialog, error) { + c := C.gtk_dialog_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapDialog(obj), nil +} + +// Run() is a wrapper around gtk_dialog_run(). +func (v *Dialog) Run() int { + c := C.gtk_dialog_run(v.native()) + return int(c) +} + +// Response() is a wrapper around gtk_dialog_response(). +func (v *Dialog) Response(response ResponseType) { + C.gtk_dialog_response(v.native(), C.gint(response)) +} + +// AddButton() is a wrapper around gtk_dialog_add_button(). text may +// be either the literal button text, or if using GTK 3.8 or earlier, a +// Stock type converted to a string. +func (v *Dialog) AddButton(text string, id ResponseType) (*Button, error) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_dialog_add_button(v.native(), (*C.gchar)(cstr), C.gint(id)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return &Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}, nil +} + +// AddActionWidget() is a wrapper around gtk_dialog_add_action_widget(). +func (v *Dialog) AddActionWidget(child IWidget, id ResponseType) { + C.gtk_dialog_add_action_widget(v.native(), child.toWidget(), C.gint(id)) +} + +// SetDefaultResponse() is a wrapper around gtk_dialog_set_default_response(). +func (v *Dialog) SetDefaultResponse(id ResponseType) { + C.gtk_dialog_set_default_response(v.native(), C.gint(id)) +} + +// SetResponseSensitive() is a wrapper around +// gtk_dialog_set_response_sensitive(). +func (v *Dialog) SetResponseSensitive(id ResponseType, setting bool) { + C.gtk_dialog_set_response_sensitive(v.native(), C.gint(id), + gbool(setting)) +} + +// GetResponseForWidget() is a wrapper around +// gtk_dialog_get_response_for_widget(). +func (v *Dialog) GetResponseForWidget(widget IWidget) ResponseType { + c := C.gtk_dialog_get_response_for_widget(v.native(), widget.toWidget()) + return ResponseType(c) +} + +// GetWidgetForResponse() is a wrapper around +// gtk_dialog_get_widget_for_response(). +func (v *Dialog) GetWidgetForResponse(id ResponseType) (*Widget, error) { + c := C.gtk_dialog_get_widget_for_response(v.native(), C.gint(id)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +// GetContentArea() is a wrapper around gtk_dialog_get_content_area(). +func (v *Dialog) GetContentArea() (*Box, error) { + c := C.gtk_dialog_get_content_area(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + b := &Box{Container{Widget{glib.InitiallyUnowned{obj}}}} + return b, nil +} + +// TODO(jrick) +/* +func (v *gdk.Screen) AlternativeDialogButtonOrder() bool { + c := C.gtk_alternative_dialog_button_order(v.native()) + return gobool(c) +} +*/ + +// TODO(jrick) +/* +func SetAlternativeButtonOrder(ids ...ResponseType) { +} +*/ + +/* + * GtkDrawingArea + */ + +// DrawingArea is a representation of GTK's GtkDrawingArea. +type DrawingArea struct { + Widget +} + +// native returns a pointer to the underlying GtkDrawingArea. +func (v *DrawingArea) native() *C.GtkDrawingArea { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkDrawingArea(p) +} + +func marshalDrawingArea(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapDrawingArea(obj), nil +} + +func wrapDrawingArea(obj *glib.Object) *DrawingArea { + return &DrawingArea{Widget{glib.InitiallyUnowned{obj}}} +} + +// DrawingAreaNew is a wrapper around gtk_drawing_area_new(). +func DrawingAreaNew() (*DrawingArea, error) { + c := C.gtk_drawing_area_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapDrawingArea(obj), nil +} + +/* + * GtkEditable + */ + +// Editable is a representation of GTK's GtkEditable GInterface. +type Editable struct { + *glib.Object +} + +// IEditable is an interface type implemented by all structs +// embedding an Editable. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkEditable. +type IEditable interface { + toEditable() *C.GtkEditable +} + +// native() returns a pointer to the underlying GObject as a GtkEditable. +func (v *Editable) native() *C.GtkEditable { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkEditable(p) +} + +func marshalEditable(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapEditable(obj), nil +} + +func wrapEditable(obj *glib.Object) *Editable { + return &Editable{obj} +} + +func (v *Editable) toEditable() *C.GtkEditable { + if v == nil { + return nil + } + return v.native() +} + +// SelectRegion is a wrapper around gtk_editable_select_region(). +func (v *Editable) SelectRegion(startPos, endPos int) { + C.gtk_editable_select_region(v.native(), C.gint(startPos), + C.gint(endPos)) +} + +// GetSelectionBounds is a wrapper around gtk_editable_get_selection_bounds(). +func (v *Editable) GetSelectionBounds() (start, end int, nonEmpty bool) { + var cstart, cend C.gint + c := C.gtk_editable_get_selection_bounds(v.native(), &cstart, &cend) + return int(cstart), int(cend), gobool(c) +} + +// InsertText is a wrapper around gtk_editable_insert_text(). The returned +// int is the position after the inserted text. +func (v *Editable) InsertText(newText string, position int) int { + cstr := C.CString(newText) + defer C.free(unsafe.Pointer(cstr)) + pos := new(C.gint) + *pos = C.gint(position) + C.gtk_editable_insert_text(v.native(), (*C.gchar)(cstr), + C.gint(len(newText)), pos) + return int(*pos) +} + +// DeleteText is a wrapper around gtk_editable_delete_text(). +func (v *Editable) DeleteText(startPos, endPos int) { + C.gtk_editable_delete_text(v.native(), C.gint(startPos), C.gint(endPos)) +} + +// GetChars is a wrapper around gtk_editable_get_chars(). +func (v *Editable) GetChars(startPos, endPos int) string { + c := C.gtk_editable_get_chars(v.native(), C.gint(startPos), + C.gint(endPos)) + defer C.free(unsafe.Pointer(c)) + return C.GoString((*C.char)(c)) +} + +// CutClipboard is a wrapper around gtk_editable_cut_clipboard(). +func (v *Editable) CutClipboard() { + C.gtk_editable_cut_clipboard(v.native()) +} + +// CopyClipboard is a wrapper around gtk_editable_copy_clipboard(). +func (v *Editable) CopyClipboard() { + C.gtk_editable_copy_clipboard(v.native()) +} + +// PasteClipboard is a wrapper around gtk_editable_paste_clipboard(). +func (v *Editable) PasteClipboard() { + C.gtk_editable_paste_clipboard(v.native()) +} + +// DeleteSelection is a wrapper around gtk_editable_delete_selection(). +func (v *Editable) DeleteSelection() { + C.gtk_editable_delete_selection(v.native()) +} + +// SetPosition is a wrapper around gtk_editable_set_position(). +func (v *Editable) SetPosition(position int) { + C.gtk_editable_set_position(v.native(), C.gint(position)) +} + +// GetPosition is a wrapper around gtk_editable_get_position(). +func (v *Editable) GetPosition() int { + c := C.gtk_editable_get_position(v.native()) + return int(c) +} + +// SetEditable is a wrapper around gtk_editable_set_editable(). +func (v *Editable) SetEditable(isEditable bool) { + C.gtk_editable_set_editable(v.native(), gbool(isEditable)) +} + +// GetEditable is a wrapper around gtk_editable_get_editable(). +func (v *Editable) GetEditable() bool { + c := C.gtk_editable_get_editable(v.native()) + return gobool(c) +} + +/* + * GtkEntry + */ + +// Entry is a representation of GTK's GtkEntry. +type Entry struct { + Widget + + // Interfaces + Editable +} + +type IEntry interface { + toEntry() *C.GtkEntry +} + +func (v *Entry) toEntry() *C.GtkEntry { + return v.native() +} + +// native returns a pointer to the underlying GtkEntry. +func (v *Entry) native() *C.GtkEntry { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkEntry(p) +} + +func marshalEntry(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapEntry(obj), nil +} + +func wrapEntry(obj *glib.Object) *Entry { + e := wrapEditable(obj) + return &Entry{Widget{glib.InitiallyUnowned{obj}}, *e} +} + +// EntryNew() is a wrapper around gtk_entry_new(). +func EntryNew() (*Entry, error) { + c := C.gtk_entry_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapEntry(obj), nil +} + +// EntryNewWithBuffer() is a wrapper around gtk_entry_new_with_buffer(). +func EntryNewWithBuffer(buffer *EntryBuffer) (*Entry, error) { + c := C.gtk_entry_new_with_buffer(buffer.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapEntry(obj), nil +} + +// GetBuffer() is a wrapper around gtk_entry_get_buffer(). +func (v *Entry) GetBuffer() (*EntryBuffer, error) { + c := C.gtk_entry_get_buffer(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return &EntryBuffer{obj}, nil +} + +// SetBuffer() is a wrapper around gtk_entry_set_buffer(). +func (v *Entry) SetBuffer(buffer *EntryBuffer) { + C.gtk_entry_set_buffer(v.native(), buffer.native()) +} + +// SetText() is a wrapper around gtk_entry_set_text(). +func (v *Entry) SetText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_set_text(v.native(), (*C.gchar)(cstr)) +} + +// GetText() is a wrapper around gtk_entry_get_text(). +func (v *Entry) GetText() (string, error) { + c := C.gtk_entry_get_text(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// GetTextLength() is a wrapper around gtk_entry_get_text_length(). +func (v *Entry) GetTextLength() uint16 { + c := C.gtk_entry_get_text_length(v.native()) + return uint16(c) +} + +// TODO(jrick) GdkRectangle +/* +func (v *Entry) GetTextArea() { +} +*/ + +// SetVisibility() is a wrapper around gtk_entry_set_visibility(). +func (v *Entry) SetVisibility(visible bool) { + C.gtk_entry_set_visibility(v.native(), gbool(visible)) +} + +// SetInvisibleChar() is a wrapper around gtk_entry_set_invisible_char(). +func (v *Entry) SetInvisibleChar(ch rune) { + C.gtk_entry_set_invisible_char(v.native(), C.gunichar(ch)) +} + +// UnsetInvisibleChar() is a wrapper around gtk_entry_unset_invisible_char(). +func (v *Entry) UnsetInvisibleChar() { + C.gtk_entry_unset_invisible_char(v.native()) +} + +// SetMaxLength() is a wrapper around gtk_entry_set_max_length(). +func (v *Entry) SetMaxLength(len int) { + C.gtk_entry_set_max_length(v.native(), C.gint(len)) +} + +// GetActivatesDefault() is a wrapper around gtk_entry_get_activates_default(). +func (v *Entry) GetActivatesDefault() bool { + c := C.gtk_entry_get_activates_default(v.native()) + return gobool(c) +} + +// GetHasFrame() is a wrapper around gtk_entry_get_has_frame(). +func (v *Entry) GetHasFrame() bool { + c := C.gtk_entry_get_has_frame(v.native()) + return gobool(c) +} + +// GetWidthChars() is a wrapper around gtk_entry_get_width_chars(). +func (v *Entry) GetWidthChars() int { + c := C.gtk_entry_get_width_chars(v.native()) + return int(c) +} + +// SetActivatesDefault() is a wrapper around gtk_entry_set_activates_default(). +func (v *Entry) SetActivatesDefault(setting bool) { + C.gtk_entry_set_activates_default(v.native(), gbool(setting)) +} + +// SetHasFrame() is a wrapper around gtk_entry_set_has_frame(). +func (v *Entry) SetHasFrame(setting bool) { + C.gtk_entry_set_has_frame(v.native(), gbool(setting)) +} + +// SetWidthChars() is a wrapper around gtk_entry_set_width_chars(). +func (v *Entry) SetWidthChars(nChars int) { + C.gtk_entry_set_width_chars(v.native(), C.gint(nChars)) +} + +// GetInvisibleChar() is a wrapper around gtk_entry_get_invisible_char(). +func (v *Entry) GetInvisibleChar() rune { + c := C.gtk_entry_get_invisible_char(v.native()) + return rune(c) +} + +// SetAlignment() is a wrapper around gtk_entry_set_alignment(). +func (v *Entry) SetAlignment(xalign float32) { + C.gtk_entry_set_alignment(v.native(), C.gfloat(xalign)) +} + +// GetAlignment() is a wrapper around gtk_entry_get_alignment(). +func (v *Entry) GetAlignment() float32 { + c := C.gtk_entry_get_alignment(v.native()) + return float32(c) +} + +// SetPlaceholderText() is a wrapper around gtk_entry_set_placeholder_text(). +func (v *Entry) SetPlaceholderText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_set_placeholder_text(v.native(), (*C.gchar)(cstr)) +} + +// GetPlaceholderText() is a wrapper around gtk_entry_get_placeholder_text(). +func (v *Entry) GetPlaceholderText() (string, error) { + c := C.gtk_entry_get_placeholder_text(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// SetOverwriteMode() is a wrapper around gtk_entry_set_overwrite_mode(). +func (v *Entry) SetOverwriteMode(overwrite bool) { + C.gtk_entry_set_overwrite_mode(v.native(), gbool(overwrite)) +} + +// GetOverwriteMode() is a wrapper around gtk_entry_get_overwrite_mode(). +func (v *Entry) GetOverwriteMode() bool { + c := C.gtk_entry_get_overwrite_mode(v.native()) + return gobool(c) +} + +// TODO(jrick) Pangolayout +/* +func (v *Entry) GetLayout() { +} +*/ + +// GetLayoutOffsets() is a wrapper around gtk_entry_get_layout_offsets(). +func (v *Entry) GetLayoutOffsets() (x, y int) { + var gx, gy C.gint + C.gtk_entry_get_layout_offsets(v.native(), &gx, &gy) + return int(gx), int(gy) +} + +// LayoutIndexToTextIndex() is a wrapper around +// gtk_entry_layout_index_to_text_index(). +func (v *Entry) LayoutIndexToTextIndex(layoutIndex int) int { + c := C.gtk_entry_layout_index_to_text_index(v.native(), + C.gint(layoutIndex)) + return int(c) +} + +// TextIndexToLayoutIndex() is a wrapper around +// gtk_entry_text_index_to_layout_index(). +func (v *Entry) TextIndexToLayoutIndex(textIndex int) int { + c := C.gtk_entry_text_index_to_layout_index(v.native(), + C.gint(textIndex)) + return int(c) +} + +// TODO(jrick) PandoAttrList +/* +func (v *Entry) SetAttributes() { +} +*/ + +// TODO(jrick) PandoAttrList +/* +func (v *Entry) GetAttributes() { +} +*/ + +// GetMaxLength() is a wrapper around gtk_entry_get_max_length(). +func (v *Entry) GetMaxLength() int { + c := C.gtk_entry_get_max_length(v.native()) + return int(c) +} + +// GetVisibility() is a wrapper around gtk_entry_get_visibility(). +func (v *Entry) GetVisibility() bool { + c := C.gtk_entry_get_visibility(v.native()) + return gobool(c) +} + +// SetCompletion() is a wrapper around gtk_entry_set_completion(). +func (v *Entry) SetCompletion(completion *EntryCompletion) { + C.gtk_entry_set_completion(v.native(), completion.native()) +} + +// GetCompletion() is a wrapper around gtk_entry_get_completion(). +func (v *Entry) GetCompletion() (*EntryCompletion, error) { + c := C.gtk_entry_get_completion(v.native()) + if c == nil { + return nil, nilPtrErr + } + + e := &EntryCompletion{wrapObject(unsafe.Pointer(c))} + return e, nil +} + +// SetCursorHAdjustment() is a wrapper around +// gtk_entry_set_cursor_hadjustment(). +func (v *Entry) SetCursorHAdjustment(adjustment *Adjustment) { + C.gtk_entry_set_cursor_hadjustment(v.native(), adjustment.native()) +} + +// GetCursorHAdjustment() is a wrapper around +// gtk_entry_get_cursor_hadjustment(). +func (v *Entry) GetCursorHAdjustment() (*Adjustment, error) { + c := C.gtk_entry_get_cursor_hadjustment(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return &Adjustment{glib.InitiallyUnowned{obj}}, nil +} + +// SetProgressFraction() is a wrapper around gtk_entry_set_progress_fraction(). +func (v *Entry) SetProgressFraction(fraction float64) { + C.gtk_entry_set_progress_fraction(v.native(), C.gdouble(fraction)) +} + +// GetProgressFraction() is a wrapper around gtk_entry_get_progress_fraction(). +func (v *Entry) GetProgressFraction() float64 { + c := C.gtk_entry_get_progress_fraction(v.native()) + return float64(c) +} + +// SetProgressPulseStep() is a wrapper around +// gtk_entry_set_progress_pulse_step(). +func (v *Entry) SetProgressPulseStep(fraction float64) { + C.gtk_entry_set_progress_pulse_step(v.native(), C.gdouble(fraction)) +} + +// GetProgressPulseStep() is a wrapper around +// gtk_entry_get_progress_pulse_step(). +func (v *Entry) GetProgressPulseStep() float64 { + c := C.gtk_entry_get_progress_pulse_step(v.native()) + return float64(c) +} + +// ProgressPulse() is a wrapper around gtk_entry_progress_pulse(). +func (v *Entry) ProgressPulse() { + C.gtk_entry_progress_pulse(v.native()) +} + +// TODO(jrick) GdkEventKey +/* +func (v *Entry) IMContextFilterKeypress() { +} +*/ + +// ResetIMContext() is a wrapper around gtk_entry_reset_im_context(). +func (v *Entry) ResetIMContext() { + C.gtk_entry_reset_im_context(v.native()) +} + +// TODO(jrick) GdkPixbuf +/* +func (v *Entry) SetIconFromPixbuf() { +} +*/ + +// SetIconFromIconName() is a wrapper around +// gtk_entry_set_icon_from_icon_name(). +func (v *Entry) SetIconFromIconName(iconPos EntryIconPosition, name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_set_icon_from_icon_name(v.native(), + C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) +} + +// TODO(jrick) GIcon +/* +func (v *Entry) SetIconFromGIcon() { +} +*/ + +// GetIconStorageType() is a wrapper around gtk_entry_get_icon_storage_type(). +func (v *Entry) GetIconStorageType(iconPos EntryIconPosition) ImageType { + c := C.gtk_entry_get_icon_storage_type(v.native(), + C.GtkEntryIconPosition(iconPos)) + return ImageType(c) +} + +// TODO(jrick) GdkPixbuf +/* +func (v *Entry) GetIconPixbuf() { +} +*/ + +// GetIconName() is a wrapper around gtk_entry_get_icon_name(). +func (v *Entry) GetIconName(iconPos EntryIconPosition) (string, error) { + c := C.gtk_entry_get_icon_name(v.native(), + C.GtkEntryIconPosition(iconPos)) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// TODO(jrick) GIcon +/* +func (v *Entry) GetIconGIcon() { +} +*/ + +// SetIconActivatable() is a wrapper around gtk_entry_set_icon_activatable(). +func (v *Entry) SetIconActivatable(iconPos EntryIconPosition, activatable bool) { + C.gtk_entry_set_icon_activatable(v.native(), + C.GtkEntryIconPosition(iconPos), gbool(activatable)) +} + +// GetIconActivatable() is a wrapper around gtk_entry_get_icon_activatable(). +func (v *Entry) GetIconActivatable(iconPos EntryIconPosition) bool { + c := C.gtk_entry_get_icon_activatable(v.native(), + C.GtkEntryIconPosition(iconPos)) + return gobool(c) +} + +// SetIconSensitive() is a wrapper around gtk_entry_set_icon_sensitive(). +func (v *Entry) SetIconSensitive(iconPos EntryIconPosition, sensitive bool) { + C.gtk_entry_set_icon_sensitive(v.native(), + C.GtkEntryIconPosition(iconPos), gbool(sensitive)) +} + +// GetIconSensitive() is a wrapper around gtk_entry_get_icon_sensitive(). +func (v *Entry) GetIconSensitive(iconPos EntryIconPosition) bool { + c := C.gtk_entry_get_icon_sensitive(v.native(), + C.GtkEntryIconPosition(iconPos)) + return gobool(c) +} + +// GetIconAtPos() is a wrapper around gtk_entry_get_icon_at_pos(). +func (v *Entry) GetIconAtPos(x, y int) int { + c := C.gtk_entry_get_icon_at_pos(v.native(), C.gint(x), C.gint(y)) + return int(c) +} + +// SetIconTooltipText() is a wrapper around gtk_entry_set_icon_tooltip_text(). +func (v *Entry) SetIconTooltipText(iconPos EntryIconPosition, tooltip string) { + cstr := C.CString(tooltip) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_set_icon_tooltip_text(v.native(), + C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) +} + +// GetIconTooltipText() is a wrapper around gtk_entry_get_icon_tooltip_text(). +func (v *Entry) GetIconTooltipText(iconPos EntryIconPosition) (string, error) { + c := C.gtk_entry_get_icon_tooltip_text(v.native(), + C.GtkEntryIconPosition(iconPos)) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// SetIconTooltipMarkup() is a wrapper around +// gtk_entry_set_icon_tooltip_markup(). +func (v *Entry) SetIconTooltipMarkup(iconPos EntryIconPosition, tooltip string) { + cstr := C.CString(tooltip) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_set_icon_tooltip_markup(v.native(), + C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) +} + +// GetIconTooltipMarkup() is a wrapper around +// gtk_entry_get_icon_tooltip_markup(). +func (v *Entry) GetIconTooltipMarkup(iconPos EntryIconPosition) (string, error) { + c := C.gtk_entry_get_icon_tooltip_markup(v.native(), + C.GtkEntryIconPosition(iconPos)) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// TODO(jrick) GdkDragAction +/* +func (v *Entry) SetIconDragSource() { +} +*/ + +// GetCurrentIconDragSource() is a wrapper around +// gtk_entry_get_current_icon_drag_source(). +func (v *Entry) GetCurrentIconDragSource() int { + c := C.gtk_entry_get_current_icon_drag_source(v.native()) + return int(c) +} + +// TODO(jrick) GdkRectangle +/* +func (v *Entry) GetIconArea() { +} +*/ + +// SetInputPurpose() is a wrapper around gtk_entry_set_input_purpose(). +func (v *Entry) SetInputPurpose(purpose InputPurpose) { + C.gtk_entry_set_input_purpose(v.native(), C.GtkInputPurpose(purpose)) +} + +// GetInputPurpose() is a wrapper around gtk_entry_get_input_purpose(). +func (v *Entry) GetInputPurpose() InputPurpose { + c := C.gtk_entry_get_input_purpose(v.native()) + return InputPurpose(c) +} + +// SetInputHints() is a wrapper around gtk_entry_set_input_hints(). +func (v *Entry) SetInputHints(hints InputHints) { + C.gtk_entry_set_input_hints(v.native(), C.GtkInputHints(hints)) +} + +// GetInputHints() is a wrapper around gtk_entry_get_input_hints(). +func (v *Entry) GetInputHints() InputHints { + c := C.gtk_entry_get_input_hints(v.native()) + return InputHints(c) +} + +/* + * GtkEntryBuffer + */ + +// EntryBuffer is a representation of GTK's GtkEntryBuffer. +type EntryBuffer struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkEntryBuffer. +func (v *EntryBuffer) native() *C.GtkEntryBuffer { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkEntryBuffer(p) +} + +func marshalEntryBuffer(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapEntryBuffer(obj), nil +} + +func wrapEntryBuffer(obj *glib.Object) *EntryBuffer { + return &EntryBuffer{obj} +} + +// EntryBufferNew() is a wrapper around gtk_entry_buffer_new(). +func EntryBufferNew(initialChars string, nInitialChars int) (*EntryBuffer, error) { + cstr := C.CString(initialChars) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_entry_buffer_new((*C.gchar)(cstr), C.gint(nInitialChars)) + if c == nil { + return nil, nilPtrErr + } + + e := wrapEntryBuffer(wrapObject(unsafe.Pointer(c))) + return e, nil +} + +// GetText() is a wrapper around gtk_entry_buffer_get_text(). A +// non-nil error is returned in the case that gtk_entry_buffer_get_text +// returns NULL to differentiate between NULL and an empty string. +func (v *EntryBuffer) GetText() (string, error) { + c := C.gtk_entry_buffer_get_text(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// SetText() is a wrapper around gtk_entry_buffer_set_text(). +func (v *EntryBuffer) SetText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_buffer_set_text(v.native(), (*C.gchar)(cstr), + C.gint(len(text))) +} + +// GetBytes() is a wrapper around gtk_entry_buffer_get_bytes(). +func (v *EntryBuffer) GetBytes() uint { + c := C.gtk_entry_buffer_get_bytes(v.native()) + return uint(c) +} + +// GetLength() is a wrapper around gtk_entry_buffer_get_length(). +func (v *EntryBuffer) GetLength() uint { + c := C.gtk_entry_buffer_get_length(v.native()) + return uint(c) +} + +// GetMaxLength() is a wrapper around gtk_entry_buffer_get_max_length(). +func (v *EntryBuffer) GetMaxLength() int { + c := C.gtk_entry_buffer_get_max_length(v.native()) + return int(c) +} + +// SetMaxLength() is a wrapper around gtk_entry_buffer_set_max_length(). +func (v *EntryBuffer) SetMaxLength(maxLength int) { + C.gtk_entry_buffer_set_max_length(v.native(), C.gint(maxLength)) +} + +// InsertText() is a wrapper around gtk_entry_buffer_insert_text(). +func (v *EntryBuffer) InsertText(position uint, text string) uint { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_entry_buffer_insert_text(v.native(), C.guint(position), + (*C.gchar)(cstr), C.gint(len(text))) + return uint(c) +} + +// DeleteText() is a wrapper around gtk_entry_buffer_delete_text(). +func (v *EntryBuffer) DeleteText(position uint, nChars int) uint { + c := C.gtk_entry_buffer_delete_text(v.native(), C.guint(position), + C.gint(nChars)) + return uint(c) +} + +// EmitDeletedText() is a wrapper around gtk_entry_buffer_emit_deleted_text(). +func (v *EntryBuffer) EmitDeletedText(pos, nChars uint) { + C.gtk_entry_buffer_emit_deleted_text(v.native(), C.guint(pos), + C.guint(nChars)) +} + +// EmitInsertedText() is a wrapper around gtk_entry_buffer_emit_inserted_text(). +func (v *EntryBuffer) EmitInsertedText(pos uint, text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_entry_buffer_emit_inserted_text(v.native(), C.guint(pos), + (*C.gchar)(cstr), C.guint(len(text))) +} + +/* + * GtkEntryCompletion + */ + +// EntryCompletion is a representation of GTK's GtkEntryCompletion. +type EntryCompletion struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkEntryCompletion. +func (v *EntryCompletion) native() *C.GtkEntryCompletion { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkEntryCompletion(p) +} + +func marshalEntryCompletion(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapEntryCompletion(obj), nil +} + +func wrapEntryCompletion(obj *glib.Object) *EntryCompletion { + return &EntryCompletion{obj} +} + +/* + * GtkEventBox + */ + +// EventBox is a representation of GTK's GtkEventBox. +type EventBox struct { + Bin +} + +// native returns a pointer to the underlying GtkEventBox. +func (v *EventBox) native() *C.GtkEventBox { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkEventBox(p) +} + +func marshalEventBox(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapEventBox(obj), nil +} + +func wrapEventBox(obj *glib.Object) *EventBox { + return &EventBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// EventBoxNew is a wrapper around gtk_event_box_new(). +func EventBoxNew() (*EventBox, error) { + c := C.gtk_event_box_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapEventBox(obj), nil +} + +// SetAboveChild is a wrapper around gtk_event_box_set_above_child(). +func (v *EventBox) SetAboveChild(aboveChild bool) { + C.gtk_event_box_set_above_child(v.native(), gbool(aboveChild)) +} + +// GetAboveChild is a wrapper around gtk_event_box_get_above_child(). +func (v *EventBox) GetAboveChild() bool { + c := C.gtk_event_box_get_above_child(v.native()) + return gobool(c) +} + +// SetVisibleWindow is a wrapper around gtk_event_box_set_visible_window(). +func (v *EventBox) SetVisibleWindow(visibleWindow bool) { + C.gtk_event_box_set_visible_window(v.native(), gbool(visibleWindow)) +} + +// GetVisibleWindow is a wrapper around gtk_event_box_get_visible_window(). +func (v *EventBox) GetVisibleWindow() bool { + c := C.gtk_event_box_get_visible_window(v.native()) + return gobool(c) +} + +/* + * GtkExpander + */ + +// Expander is a representation of GTK's GtkExpander. +type Expander struct { + Bin +} + +// native returns a pointer to the underlying GtkExpander. +func (v *Expander) native() *C.GtkExpander { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkExpander(p) +} + +func marshalExpander(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapExpander(obj), nil +} + +func wrapExpander(obj *glib.Object) *Expander { + return &Expander{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// ExpanderNew is a wrapper around gtk_expander_new(). +func ExpanderNew(label string) (*Expander, error) { + var cstr *C.gchar + if label != "" { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + } + c := C.gtk_expander_new((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapExpander(obj), nil +} + +// SetExpanded is a wrapper around gtk_expander_set_expanded(). +func (v *Expander) SetExpanded(expanded bool) { + C.gtk_expander_set_expanded(v.native(), gbool(expanded)) +} + +// GetExpanded is a wrapper around gtk_expander_get_expanded(). +func (v *Expander) GetExpanded() bool { + c := C.gtk_expander_get_expanded(v.native()) + return gobool(c) +} + +// SetLabel is a wrapper around gtk_expander_set_label(). +func (v *Expander) SetLabel(label string) { + var cstr *C.char + if label != "" { + cstr = C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + } + C.gtk_expander_set_label(v.native(), (*C.gchar)(cstr)) +} + +// GetLabel is a wrapper around gtk_expander_get_label(). +func (v *Expander) GetLabel() string { + c := C.gtk_expander_get_label(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetLabelWidget is a wrapper around gtk_expander_set_label_widget(). +func (v *Expander) SetLabelWidget(widget IWidget) { + C.gtk_expander_set_label_widget(v.native(), widget.toWidget()) +} + +/* + * GtkFileChooser + */ + +// FileChoser is a representation of GTK's GtkFileChooser GInterface. +type FileChooser struct { + *glib.Object +} + +// native returns a pointer to the underlying GObject as a GtkFileChooser. +func (v *FileChooser) native() *C.GtkFileChooser { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFileChooser(p) +} + +func marshalFileChooser(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooser(obj), nil +} + +func wrapFileChooser(obj *glib.Object) *FileChooser { + return &FileChooser{obj} +} + +// GetFilename is a wrapper around gtk_file_chooser_get_filename(). +func (v *FileChooser) GetFilename() string { + c := C.gtk_file_chooser_get_filename(v.native()) + s := C.GoString((*C.char)(c)) + defer C.g_free((C.gpointer)(c)) + return s +} + +// SetCurrentName is a wrapper around gtk_file_chooser_set_current_name(). +func (v *FileChooser) SetCurrentName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_file_chooser_set_current_name(v.native(), (*C.gchar)(cstr)) + return +} + +// SetCurrentFolder is a wrapper around gtk_file_chooser_set_current_folder(). +func (v *FileChooser) SetCurrentFolder(folder string) bool { + cstr := C.CString(folder) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_file_chooser_set_current_folder(v.native(), (*C.gchar)(cstr)) + return gobool(c) +} + +// GetCurrentFolder is a wrapper around gtk_file_chooser_get_current_folder(). +func (v *FileChooser) GetCurrentFolder() (string, error) { + c := C.gtk_file_chooser_get_current_folder(v.native()) + if c == nil { + return "", nilPtrErr + } + defer C.free(unsafe.Pointer(c)) + return C.GoString((*C.char)(c)), nil +} + +// SetPreviewWidget is a wrapper around gtk_file_chooser_set_preview_widget(). +func (v *FileChooser) SetPreviewWidget(widget IWidget) { + C.gtk_file_chooser_set_preview_widget(v.native(), widget.toWidget()) +} + +// SetPreviewWidgetActive is a wrapper around gtk_file_chooser_set_preview_widget_active(). +func (v *FileChooser) SetPreviewWidgetActive(active bool) { + C.gtk_file_chooser_set_preview_widget_active(v.native(), gbool(active)) +} + +// GetPreviewFilename is a wrapper around gtk_file_chooser_get_preview_filename(). +func (v *FileChooser) GetPreviewFilename() string { + c := C.gtk_file_chooser_get_preview_filename(v.native()) + defer C.free(unsafe.Pointer(c)) + return C.GoString(c) +} + +// AddFilter is a wrapper around gtk_file_chooser_add_filter(). +func (v *FileChooser) AddFilter(filter *FileFilter) { + C.gtk_file_chooser_add_filter(v.native(), filter.native()) +} + +// GetURI is a wrapper around gtk_file_chooser_get_uri(). +func (v *FileChooser) GetURI() string { + c := C.gtk_file_chooser_get_uri(v.native()) + s := C.GoString((*C.char)(c)) + defer C.g_free((C.gpointer)(c)) + return s +} + +// AddShortcutFolder is a wrapper around gtk_file_chooser_add_shortcut_folder(). +func (v *FileChooser) AddShortcutFolder(folder string) bool { + cstr := C.CString(folder) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_file_chooser_add_shortcut_folder(v.native(), cstr, nil) + return gobool(c) +} + +/* + * GtkFileChooserButton + */ + +// FileChooserButton is a representation of GTK's GtkFileChooserButton. +type FileChooserButton struct { + Box + + // Interfaces + FileChooser +} + +// native returns a pointer to the underlying GtkFileChooserButton. +func (v *FileChooserButton) native() *C.GtkFileChooserButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFileChooserButton(p) +} + +func marshalFileChooserButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserButton(obj), nil +} + +func wrapFileChooserButton(obj *glib.Object) *FileChooserButton { + fc := wrapFileChooser(obj) + return &FileChooserButton{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, *fc} +} + +// FileChooserButtonNew is a wrapper around gtk_file_chooser_button_new(). +func FileChooserButtonNew(title string, action FileChooserAction) (*FileChooserButton, error) { + cstr := C.CString(title) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_file_chooser_button_new((*C.gchar)(cstr), + (C.GtkFileChooserAction)(action)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserButton(obj), nil +} + +/* + * GtkFileChooserDialog + */ + +// FileChooserDialog is a representation of GTK's GtkFileChooserDialog. +type FileChooserDialog struct { + Dialog + + // Interfaces + FileChooser +} + +// native returns a pointer to the underlying GtkFileChooserDialog. +func (v *FileChooserDialog) native() *C.GtkFileChooserDialog { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFileChooserDialog(p) +} + +func marshalFileChooserDialog(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserDialog(obj), nil +} + +func wrapFileChooserDialog(obj *glib.Object) *FileChooserDialog { + fc := wrapFileChooser(obj) + return &FileChooserDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}, *fc} +} + +// FileChooserDialogNewWith1Button is a wrapper around gtk_file_chooser_dialog_new() with one button. +func FileChooserDialogNewWith1Button( + title string, + parent *Window, + action FileChooserAction, + first_button_text string, + first_button_id ResponseType) (*FileChooserDialog, error) { + c_title := C.CString(title) + defer C.free(unsafe.Pointer(c_title)) + c_first_button_text := C.CString(first_button_text) + defer C.free(unsafe.Pointer(c_first_button_text)) + c := C.gtk_file_chooser_dialog_new_1( + (*C.gchar)(c_title), parent.native(), C.GtkFileChooserAction(action), + (*C.gchar)(c_first_button_text), C.int(first_button_id)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserDialog(obj), nil +} + +// FileChooserDialogNewWith2Buttons is a wrapper around gtk_file_chooser_dialog_new() with two buttons. +func FileChooserDialogNewWith2Buttons( + title string, + parent *Window, + action FileChooserAction, + first_button_text string, + first_button_id ResponseType, + second_button_text string, + second_button_id ResponseType) (*FileChooserDialog, error) { + c_title := C.CString(title) + defer C.free(unsafe.Pointer(c_title)) + c_first_button_text := C.CString(first_button_text) + defer C.free(unsafe.Pointer(c_first_button_text)) + c_second_button_text := C.CString(second_button_text) + defer C.free(unsafe.Pointer(c_second_button_text)) + c := C.gtk_file_chooser_dialog_new_2( + (*C.gchar)(c_title), parent.native(), C.GtkFileChooserAction(action), + (*C.gchar)(c_first_button_text), C.int(first_button_id), + (*C.gchar)(c_second_button_text), C.int(second_button_id)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserDialog(obj), nil +} + +/* + * GtkFileChooserWidget + */ + +// FileChooserWidget is a representation of GTK's GtkFileChooserWidget. +type FileChooserWidget struct { + Box + + // Interfaces + FileChooser +} + +// native returns a pointer to the underlying GtkFileChooserWidget. +func (v *FileChooserWidget) native() *C.GtkFileChooserWidget { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFileChooserWidget(p) +} + +func marshalFileChooserWidget(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserWidget(obj), nil +} + +func wrapFileChooserWidget(obj *glib.Object) *FileChooserWidget { + fc := wrapFileChooser(obj) + return &FileChooserWidget{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, *fc} +} + +// FileChooserWidgetNew is a wrapper around gtk_file_chooser_widget_new(). +func FileChooserWidgetNew(action FileChooserAction) (*FileChooserWidget, error) { + c := C.gtk_file_chooser_widget_new((C.GtkFileChooserAction)(action)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileChooserWidget(obj), nil +} + +/* + * GtkFileFilter + */ + +// FileChoser is a representation of GTK's GtkFileFilter GInterface. +type FileFilter struct { + *glib.Object +} + +// native returns a pointer to the underlying GObject as a GtkFileFilter. +func (v *FileFilter) native() *C.GtkFileFilter { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFileFilter(p) +} + +func marshalFileFilter(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileFilter(obj), nil +} + +func wrapFileFilter(obj *glib.Object) *FileFilter { + return &FileFilter{obj} +} + +// FileFilterNew is a wrapper around gtk_file_filter_new(). +func FileFilterNew() (*FileFilter, error) { + c := C.gtk_file_filter_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFileFilter(obj), nil +} + +// SetName is a wrapper around gtk_file_filter_set_name(). +func (v *FileFilter) SetName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_file_filter_set_name(v.native(), (*C.gchar)(cstr)) +} + +// AddPattern is a wrapper around gtk_file_filter_add_pattern(). +func (v *FileFilter) AddPattern(pattern string) { + cstr := C.CString(pattern) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_file_filter_add_pattern(v.native(), (*C.gchar)(cstr)) +} + +// AddPixbufFormats is a wrapper around gtk_file_filter_add_pixbuf_formats(). +func (v *FileFilter) AddPixbufFormats() { + C.gtk_file_filter_add_pixbuf_formats(v.native()) +} + +/* + * GtkFontButton + */ + +// FontButton is a representation of GTK's GtkFontButton. +type FontButton struct { + Button +} + +// native returns a pointer to the underlying GtkFontButton. +func (v *FontButton) native() *C.GtkFontButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFontButton(p) +} + +func marshalFontButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFontButton(obj), nil +} + +func wrapFontButton(obj *glib.Object) *FontButton { + return &FontButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// FontButtonNew is a wrapper around gtk_font_button_new(). +func FontButtonNew() (*FontButton, error) { + c := C.gtk_font_button_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFontButton(obj), nil +} + +// FontButtonNewWithFont is a wrapper around gtk_font_button_new_with_font(). +func FontButtonNewWithFont(fontname string) (*FontButton, error) { + cstr := C.CString(fontname) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_font_button_new_with_font((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFontButton(obj), nil +} + +// GetFontName is a wrapper around gtk_font_button_get_font_name(). +func (v *FontButton) GetFontName() string { + c := C.gtk_font_button_get_font_name(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetFontName is a wrapper around gtk_font_button_set_font_name(). +func (v *FontButton) SetFontName(fontname string) bool { + cstr := C.CString(fontname) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_font_button_set_font_name(v.native(), (*C.gchar)(cstr)) + return gobool(c) +} + +/* + * GtkFrame + */ + +// Frame is a representation of GTK's GtkFrame. +type Frame struct { + Bin +} + +// native returns a pointer to the underlying GtkFrame. +func (v *Frame) native() *C.GtkFrame { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkFrame(p) +} + +func marshalFrame(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFrame(obj), nil +} + +func wrapFrame(obj *glib.Object) *Frame { + return &Frame{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// FrameNew is a wrapper around gtk_frame_new(). +func FrameNew(label string) (*Frame, error) { + var cstr *C.char + if label != "" { + cstr = C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + } + c := C.gtk_frame_new((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapFrame(obj), nil +} + +// SetLabel is a wrapper around gtk_frame_set_label(). +func (v *Frame) SetLabel(label string) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_frame_set_label(v.native(), (*C.gchar)(cstr)) +} + +// SetLabelWidget is a wrapper around gtk_frame_set_label_widget(). +func (v *Frame) SetLabelWidget(labelWidget IWidget) { + C.gtk_frame_set_label_widget(v.native(), labelWidget.toWidget()) +} + +// SetLabelAlign is a wrapper around gtk_frame_set_label_align(). +func (v *Frame) SetLabelAlign(xAlign, yAlign float32) { + C.gtk_frame_set_label_align(v.native(), C.gfloat(xAlign), + C.gfloat(yAlign)) +} + +// SetShadowType is a wrapper around gtk_frame_set_shadow_type(). +func (v *Frame) SetShadowType(t ShadowType) { + C.gtk_frame_set_shadow_type(v.native(), C.GtkShadowType(t)) +} + +// GetLabel is a wrapper around gtk_frame_get_label(). +func (v *Frame) GetLabel() string { + c := C.gtk_frame_get_label(v.native()) + return C.GoString((*C.char)(c)) +} + +// GetLabelAlign is a wrapper around gtk_frame_get_label_align(). +func (v *Frame) GetLabelAlign() (xAlign, yAlign float32) { + var x, y C.gfloat + C.gtk_frame_get_label_align(v.native(), &x, &y) + return float32(x), float32(y) +} + +// GetLabelWidget is a wrapper around gtk_frame_get_label_widget(). +func (v *Frame) GetLabelWidget() (*Widget, error) { + c := C.gtk_frame_get_label_widget(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +// GetShadowType is a wrapper around gtk_frame_get_shadow_type(). +func (v *Frame) GetShadowType() ShadowType { + c := C.gtk_frame_get_shadow_type(v.native()) + return ShadowType(c) +} + +/* + * GtkGrid + */ + +// Grid is a representation of GTK's GtkGrid. +type Grid struct { + Container + + // Interfaces + Orientable +} + +// native returns a pointer to the underlying GtkGrid. +func (v *Grid) native() *C.GtkGrid { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkGrid(p) +} + +func (v *Grid) toOrientable() *C.GtkOrientable { + if v == nil { + return nil + } + return C.toGtkOrientable(unsafe.Pointer(v.GObject)) +} + +func marshalGrid(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapGrid(obj), nil +} + +func wrapGrid(obj *glib.Object) *Grid { + o := wrapOrientable(obj) + return &Grid{Container{Widget{glib.InitiallyUnowned{obj}}}, *o} +} + +// GridNew() is a wrapper around gtk_grid_new(). +func GridNew() (*Grid, error) { + c := C.gtk_grid_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapGrid(obj), nil +} + +// Attach() is a wrapper around gtk_grid_attach(). +func (v *Grid) Attach(child IWidget, left, top, width, height int) { + C.gtk_grid_attach(v.native(), child.toWidget(), C.gint(left), + C.gint(top), C.gint(width), C.gint(height)) +} + +// AttachNextTo() is a wrapper around gtk_grid_attach_next_to(). +func (v *Grid) AttachNextTo(child, sibling IWidget, side PositionType, width, height int) { + C.gtk_grid_attach_next_to(v.native(), child.toWidget(), + sibling.toWidget(), C.GtkPositionType(side), C.gint(width), + C.gint(height)) +} + +// GetChildAt() is a wrapper around gtk_grid_get_child_at(). +func (v *Grid) GetChildAt(left, top int) (*Widget, error) { + c := C.gtk_grid_get_child_at(v.native(), C.gint(left), C.gint(top)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +// InsertRow() is a wrapper around gtk_grid_insert_row(). +func (v *Grid) InsertRow(position int) { + C.gtk_grid_insert_row(v.native(), C.gint(position)) +} + +// InsertColumn() is a wrapper around gtk_grid_insert_column(). +func (v *Grid) InsertColumn(position int) { + C.gtk_grid_insert_column(v.native(), C.gint(position)) +} + +// InsertNextTo() is a wrapper around gtk_grid_insert_next_to() +func (v *Grid) InsertNextTo(sibling IWidget, side PositionType) { + C.gtk_grid_insert_next_to(v.native(), sibling.toWidget(), + C.GtkPositionType(side)) +} + +// SetRowHomogeneous() is a wrapper around gtk_grid_set_row_homogeneous(). +func (v *Grid) SetRowHomogeneous(homogeneous bool) { + C.gtk_grid_set_row_homogeneous(v.native(), gbool(homogeneous)) +} + +// GetRowHomogeneous() is a wrapper around gtk_grid_get_row_homogeneous(). +func (v *Grid) GetRowHomogeneous() bool { + c := C.gtk_grid_get_row_homogeneous(v.native()) + return gobool(c) +} + +// SetRowSpacing() is a wrapper around gtk_grid_set_row_spacing(). +func (v *Grid) SetRowSpacing(spacing uint) { + C.gtk_grid_set_row_spacing(v.native(), C.guint(spacing)) +} + +// GetRowSpacing() is a wrapper around gtk_grid_get_row_spacing(). +func (v *Grid) GetRowSpacing() uint { + c := C.gtk_grid_get_row_spacing(v.native()) + return uint(c) +} + +// SetColumnHomogeneous() is a wrapper around gtk_grid_set_column_homogeneous(). +func (v *Grid) SetColumnHomogeneous(homogeneous bool) { + C.gtk_grid_set_column_homogeneous(v.native(), gbool(homogeneous)) +} + +// GetColumnHomogeneous() is a wrapper around gtk_grid_get_column_homogeneous(). +func (v *Grid) GetColumnHomogeneous() bool { + c := C.gtk_grid_get_column_homogeneous(v.native()) + return gobool(c) +} + +// SetColumnSpacing() is a wrapper around gtk_grid_set_column_spacing(). +func (v *Grid) SetColumnSpacing(spacing uint) { + C.gtk_grid_set_column_spacing(v.native(), C.guint(spacing)) +} + +// GetColumnSpacing() is a wrapper around gtk_grid_get_column_spacing(). +func (v *Grid) GetColumnSpacing() uint { + c := C.gtk_grid_get_column_spacing(v.native()) + return uint(c) +} + +/* + * GtkIconTheme + */ + +// IconTheme is a representation of GTK's GtkIconTheme +type IconTheme struct { + Theme *C.GtkIconTheme +} + +// IconThemeGetDefault is a wrapper around gtk_icon_theme_get_default(). +func IconThemeGetDefault() (*IconTheme, error) { + c := C.gtk_icon_theme_get_default() + if c == nil { + return nil, nilPtrErr + } + return &IconTheme{c}, nil +} + +// IconThemeGetForScreen is a wrapper around gtk_icon_theme_get_for_screen(). +func IconThemeGetForScreen(screen gdk.Screen) (*IconTheme, error) { + cScreen := (*C.GdkScreen)(unsafe.Pointer(screen.Native())) + c := C.gtk_icon_theme_get_for_screen(cScreen) + if c == nil { + return nil, nilPtrErr + } + return &IconTheme{c}, nil +} + +// LoadIcon is a wrapper around gtk_icon_theme_load_icon(). +func (v *IconTheme) LoadIcon(iconName string, size int, flags IconLookupFlags) (*gdk.Pixbuf, error) { + cstr := C.CString(iconName) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + c := C.gtk_icon_theme_load_icon(v.Theme, (*C.gchar)(cstr), C.gint(size), C.GtkIconLookupFlags(flags), &err) + if c == nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + return &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))}, nil +} + +/* + * GtkIconView + */ + +// IconView is a representation of GTK's GtkIconView. +type IconView struct { + Container +} + +// native returns a pointer to the underlying GtkIconView. +func (v *IconView) native() *C.GtkIconView { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkIconView(p) +} + +func marshalIconView(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapIconView(obj), nil +} + +func wrapIconView(obj *glib.Object) *IconView { + return &IconView{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// IconViewNew is a wrapper around gtk_icon_view_new(). +func IconViewNew() (*IconView, error) { + c := C.gtk_icon_view_new() + if c == nil { + return nil, nilPtrErr + } + + return wrapIconView(wrapObject(unsafe.Pointer(c))), nil +} + +// IconViewNewWithModel is a wrapper around gtk_icon_view_new_with_model(). +func IconViewNewWithModel(model ITreeModel) (*IconView, error) { + c := C.gtk_icon_view_new_with_model(model.toTreeModel()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapIconView(obj), nil +} + +// GetModel is a wrapper around gtk_icon_view_get_model(). +func (v *IconView) GetModel() (*TreeModel, error) { + c := C.gtk_icon_view_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_icon_view_set_model(). +func (v *IconView) SetModel(model ITreeModel) { + C.gtk_icon_view_set_model(v.native(), model.toTreeModel()) +} + +// SelectPath is a wrapper around gtk_icon_view_select_path(). +func (v *IconView) SelectPath(path *TreePath) { + C.gtk_icon_view_select_path(v.native(), path.native()) +} + +// ScrollToPath is a wrapper around gtk_icon_view_scroll_to_path(). +func (v *IconView) ScrollToPath(path *TreePath, useAlign bool, rowAlign, colAlign float64) { + C.gtk_icon_view_scroll_to_path(v.native(), path.native(), gbool(useAlign), + C.gfloat(rowAlign), C.gfloat(colAlign)) +} + +/* + * GtkImage + */ + +// Image is a representation of GTK's GtkImage. +type Image struct { + Widget +} + +// native returns a pointer to the underlying GtkImage. +func (v *Image) native() *C.GtkImage { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkImage(p) +} + +func marshalImage(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +func wrapImage(obj *glib.Object) *Image { + return &Image{Widget{glib.InitiallyUnowned{obj}}} +} + +// ImageNew() is a wrapper around gtk_image_new(). +func ImageNew() (*Image, error) { + c := C.gtk_image_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +// ImageNewFromFile() is a wrapper around gtk_image_new_from_file(). +func ImageNewFromFile(filename string) (*Image, error) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_image_new_from_file((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +// ImageNewFromResource() is a wrapper around gtk_image_new_from_resource(). +func ImageNewFromResource(resourcePath string) (*Image, error) { + cstr := C.CString(resourcePath) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_image_new_from_resource((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +// ImageNewFromPixbuf is a wrapper around gtk_image_new_from_pixbuf(). +func ImageNewFromPixbuf(pixbuf *gdk.Pixbuf) (*Image, error) { + ptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) + c := C.gtk_image_new_from_pixbuf(ptr) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +// TODO(jrick) GtkIconSet +/* +func ImageNewFromIconSet() { +} +*/ + +// TODO(jrick) GdkPixbufAnimation +/* +func ImageNewFromAnimation() { +} +*/ + +// ImageNewFromIconName() is a wrapper around gtk_image_new_from_icon_name(). +func ImageNewFromIconName(iconName string, size IconSize) (*Image, error) { + cstr := C.CString(iconName) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_image_new_from_icon_name((*C.gchar)(cstr), + C.GtkIconSize(size)) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapImage(obj), nil +} + +// TODO(jrick) GIcon +/* +func ImageNewFromGIcon() { +} +*/ + +// Clear() is a wrapper around gtk_image_clear(). +func (v *Image) Clear() { + C.gtk_image_clear(v.native()) +} + +// SetFromFile() is a wrapper around gtk_image_set_from_file(). +func (v *Image) SetFromFile(filename string) { + cstr := C.CString(filename) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_image_set_from_file(v.native(), (*C.gchar)(cstr)) +} + +// SetFromResource() is a wrapper around gtk_image_set_from_resource(). +func (v *Image) SetFromResource(resourcePath string) { + cstr := C.CString(resourcePath) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_image_set_from_resource(v.native(), (*C.gchar)(cstr)) +} + +// SetFromFixbuf is a wrapper around gtk_image_set_from_pixbuf(). +func (v *Image) SetFromPixbuf(pixbuf *gdk.Pixbuf) { + pbptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) + C.gtk_image_set_from_pixbuf(v.native(), pbptr) +} + +// TODO(jrick) GtkIconSet +/* +func (v *Image) SetFromIconSet() { +} +*/ + +// TODO(jrick) GdkPixbufAnimation +/* +func (v *Image) SetFromAnimation() { +} +*/ + +// SetFromIconName() is a wrapper around gtk_image_set_from_icon_name(). +func (v *Image) SetFromIconName(iconName string, size IconSize) { + cstr := C.CString(iconName) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_image_set_from_icon_name(v.native(), (*C.gchar)(cstr), + C.GtkIconSize(size)) +} + +// TODO(jrick) GIcon +/* +func (v *Image) SetFromGIcon() { +} +*/ + +// SetPixelSize() is a wrapper around gtk_image_set_pixel_size(). +func (v *Image) SetPixelSize(pixelSize int) { + C.gtk_image_set_pixel_size(v.native(), C.gint(pixelSize)) +} + +// GetStorageType() is a wrapper around gtk_image_get_storage_type(). +func (v *Image) GetStorageType() ImageType { + c := C.gtk_image_get_storage_type(v.native()) + return ImageType(c) +} + +// GetPixbuf() is a wrapper around gtk_image_get_pixbuf(). +func (v *Image) GetPixbuf() *gdk.Pixbuf { + c := C.gtk_image_get_pixbuf(v.native()) + if c == nil { + return nil + } + + pb := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} + return pb +} + +// TODO(jrick) GtkIconSet +/* +func (v *Image) GetIconSet() { +} +*/ + +// TODO(jrick) GdkPixbufAnimation +/* +func (v *Image) GetAnimation() { +} +*/ + +// GetIconName() is a wrapper around gtk_image_get_icon_name(). +func (v *Image) GetIconName() (string, IconSize) { + var iconName *C.gchar + var size C.GtkIconSize + C.gtk_image_get_icon_name(v.native(), &iconName, &size) + return C.GoString((*C.char)(iconName)), IconSize(size) +} + +// TODO(jrick) GIcon +/* +func (v *Image) GetGIcon() { +} +*/ + +// GetPixelSize() is a wrapper around gtk_image_get_pixel_size(). +func (v *Image) GetPixelSize() int { + c := C.gtk_image_get_pixel_size(v.native()) + return int(c) +} + +// added by terrak +/* + * GtkLayout + */ + +// Layout is a representation of GTK's GtkLayout. +type Layout struct { + Container +} + +// native returns a pointer to the underlying GtkDrawingArea. +func (v *Layout) native() *C.GtkLayout { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkLayout(p) +} + +func marshalLayout(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapLayout(obj), nil +} + +func wrapLayout(obj *glib.Object) *Layout { + return &Layout{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// LayoutNew is a wrapper around gtk_layout_new(). +func LayoutNew(hadjustment, vadjustment *Adjustment) (*Layout, error) { + c := C.gtk_layout_new(hadjustment.native(), vadjustment.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapLayout(obj), nil +} + +// Layout.Put is a wrapper around gtk_layout_put(). +func (v *Layout) Put(w IWidget, x, y int) { + C.gtk_layout_put(v.native(), w.toWidget(), C.gint(x), C.gint(y)) +} + +// Layout.Move is a wrapper around gtk_layout_move(). +func (v *Layout) Move(w IWidget, x, y int) { + C.gtk_layout_move(v.native(), w.toWidget(), C.gint(x), C.gint(y)) +} + +// Layout.SetSize is a wrapper around gtk_layout_set_size +func (v *Layout) SetSize(width, height uint) { + C.gtk_layout_set_size(v.native(), C.guint(width), C.guint(height)) +} + +// Layout.GetSize is a wrapper around gtk_layout_get_size +func (v *Layout) GetSize() (width, height uint) { + var w, h C.guint + C.gtk_layout_get_size(v.native(), &w, &h) + return uint(w), uint(h) +} + +/* + * GtkLinkButton + */ + +// LinkButton is a representation of GTK's GtkLinkButton. +type LinkButton struct { + Button +} + +// native returns a pointer to the underlying GtkLinkButton. +func (v *LinkButton) native() *C.GtkLinkButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkLinkButton(p) +} + +func marshalLinkButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapLinkButton(obj), nil +} + +func wrapLinkButton(obj *glib.Object) *LinkButton { + return &LinkButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// LinkButtonNew is a wrapper around gtk_link_button_new(). +func LinkButtonNew(label string) (*LinkButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_link_button_new((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapLinkButton(wrapObject(unsafe.Pointer(c))), nil +} + +// LinkButtonNewWithLabel is a wrapper around gtk_link_button_new_with_label(). +func LinkButtonNewWithLabel(uri, label string) (*LinkButton, error) { + curi := C.CString(uri) + defer C.free(unsafe.Pointer(curi)) + clabel := C.CString(label) + defer C.free(unsafe.Pointer(clabel)) + c := C.gtk_link_button_new_with_label((*C.gchar)(curi), (*C.gchar)(clabel)) + if c == nil { + return nil, nilPtrErr + } + return wrapLinkButton(wrapObject(unsafe.Pointer(c))), nil +} + +// GetUri is a wrapper around gtk_link_button_get_uri(). +func (v *LinkButton) GetUri() string { + c := C.gtk_link_button_get_uri(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetUri is a wrapper around gtk_link_button_set_uri(). +func (v *LinkButton) SetUri(uri string) { + cstr := C.CString(uri) + C.gtk_link_button_set_uri(v.native(), (*C.gchar)(cstr)) +} + +/* + * GtkListStore + */ + +// ListStore is a representation of GTK's GtkListStore. +type ListStore struct { + *glib.Object + + // Interfaces + TreeModel +} + +// native returns a pointer to the underlying GtkListStore. +func (v *ListStore) native() *C.GtkListStore { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkListStore(p) +} + +func marshalListStore(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapListStore(obj), nil +} + +func wrapListStore(obj *glib.Object) *ListStore { + tm := wrapTreeModel(obj) + return &ListStore{obj, *tm} +} + +func (v *ListStore) toTreeModel() *C.GtkTreeModel { + if v == nil { + return nil + } + return C.toGtkTreeModel(unsafe.Pointer(v.GObject)) +} + +// ListStoreNew is a wrapper around gtk_list_store_newv(). +func ListStoreNew(types ...glib.Type) (*ListStore, error) { + gtypes := C.alloc_types(C.int(len(types))) + for n, val := range types { + C.set_type(gtypes, C.int(n), C.GType(val)) + } + defer C.g_free(C.gpointer(gtypes)) + c := C.gtk_list_store_newv(C.gint(len(types)), gtypes) + if c == nil { + return nil, nilPtrErr + } + + ls := wrapListStore(wrapObject(unsafe.Pointer(c))) + return ls, nil +} + +// Remove is a wrapper around gtk_list_store_remove(). +func (v *ListStore) Remove(iter *TreeIter) bool { + c := C.gtk_list_store_remove(v.native(), iter.native()) + return gobool(c) +} + +// TODO(jrick) +/* +func (v *ListStore) SetColumnTypes(types ...glib.Type) { +} +*/ + +// Set() is a wrapper around gtk_list_store_set_value() but provides +// a function similar to gtk_list_store_set() in that multiple columns +// may be set by one call. The length of columns and values slices must +// match, or Set() will return a non-nil error. +// +// As an example, a call to: +// store.Set(iter, []int{0, 1}, []interface{}{"Foo", "Bar"}) +// is functionally equivalent to calling the native C GTK function: +// gtk_list_store_set(store, iter, 0, "Foo", 1, "Bar", -1); +func (v *ListStore) Set(iter *TreeIter, columns []int, values []interface{}) error { + if len(columns) != len(values) { + return errors.New("columns and values lengths do not match") + } + for i, val := range values { + v.SetValue(iter, columns[i], val) + } + return nil +} + +// SetValue is a wrapper around gtk_list_store_set_value(). +func (v *ListStore) SetValue(iter *TreeIter, column int, value interface{}) error { + switch value.(type) { + case *gdk.Pixbuf: + pix := value.(*gdk.Pixbuf) + C._gtk_list_store_set(v.native(), iter.native(), C.gint(column), unsafe.Pointer(pix.Native())) + + default: + gv, err := glib.GValue(value) + if err != nil { + return err + } + + C.gtk_list_store_set_value(v.native(), iter.native(), + C.gint(column), + (*C.GValue)(unsafe.Pointer(gv.Native()))) + } + + return nil +} + +// func (v *ListStore) Model(model ITreeModel) { +// obj := &glib.Object{glib.ToGObject(unsafe.Pointer(model.toTreeModel()))} +// v.TreeModel = *wrapTreeModel(obj) +//} + +// SetSortColumnId() is a wrapper around gtk_tree_sortable_set_sort_column_id(). +func (v *ListStore) SetSortColumnId(column int, order SortType) { + sort := C.toGtkTreeSortable(unsafe.Pointer(v.Native())) + C.gtk_tree_sortable_set_sort_column_id(sort, C.gint(column), C.GtkSortType(order)) +} + +func (v *ListStore) SetCols(iter *TreeIter, cols Cols) error { + for key, value := range cols { + err := v.SetValue(iter, key, value) + if err != nil { + return err + } + } + return nil +} + +// Convenient map for Columns and values (See ListStore, TreeStore) +type Cols map[int]interface{} + +// TODO(jrick) +/* +func (v *ListStore) InsertWithValues(iter *TreeIter, position int, columns []int, values []glib.Value) { + var ccolumns *C.gint + var cvalues *C.GValue + + C.gtk_list_store_insert_with_values(v.native(), iter.native(), + C.gint(position), columns, values, C.gint(len(values))) +} +*/ + +// InsertBefore() is a wrapper around gtk_list_store_insert_before(). +func (v *ListStore) InsertBefore(sibling *TreeIter) *TreeIter { + var ti C.GtkTreeIter + C.gtk_list_store_insert_before(v.native(), &ti, sibling.native()) + iter := &TreeIter{ti} + return iter +} + +// InsertAfter() is a wrapper around gtk_list_store_insert_after(). +func (v *ListStore) InsertAfter(sibling *TreeIter) *TreeIter { + var ti C.GtkTreeIter + C.gtk_list_store_insert_after(v.native(), &ti, sibling.native()) + iter := &TreeIter{ti} + return iter +} + +// Prepend() is a wrapper around gtk_list_store_prepend(). +func (v *ListStore) Prepend() *TreeIter { + var ti C.GtkTreeIter + C.gtk_list_store_prepend(v.native(), &ti) + iter := &TreeIter{ti} + return iter +} + +// Append() is a wrapper around gtk_list_store_append(). +func (v *ListStore) Append() *TreeIter { + var ti C.GtkTreeIter + C.gtk_list_store_append(v.native(), &ti) + iter := &TreeIter{ti} + return iter +} + +// Clear() is a wrapper around gtk_list_store_clear(). +func (v *ListStore) Clear() { + C.gtk_list_store_clear(v.native()) +} + +// IterIsValid() is a wrapper around gtk_list_store_iter_is_valid(). +func (v *ListStore) IterIsValid(iter *TreeIter) bool { + c := C.gtk_list_store_iter_is_valid(v.native(), iter.native()) + return gobool(c) +} + +// TODO(jrick) +/* +func (v *ListStore) Reorder(newOrder []int) { +} +*/ + +// Swap() is a wrapper around gtk_list_store_swap(). +func (v *ListStore) Swap(a, b *TreeIter) { + C.gtk_list_store_swap(v.native(), a.native(), b.native()) +} + +// MoveBefore() is a wrapper around gtk_list_store_move_before(). +func (v *ListStore) MoveBefore(iter, position *TreeIter) { + C.gtk_list_store_move_before(v.native(), iter.native(), + position.native()) +} + +// MoveAfter() is a wrapper around gtk_list_store_move_after(). +func (v *ListStore) MoveAfter(iter, position *TreeIter) { + C.gtk_list_store_move_after(v.native(), iter.native(), + position.native()) +} + +/* + * GtkMenu + */ + +// Menu is a representation of GTK's GtkMenu. +type Menu struct { + MenuShell +} + +// IMenu is an interface type implemented by all structs embedding +// a Menu. It is meant to be used as an argument type for wrapper +// functions that wrap around a C GTK function taking a +// GtkMenu. +type IMenu interface { + toMenu() *C.GtkMenu + toWidget() *C.GtkWidget +} + +// native() returns a pointer to the underlying GtkMenu. +func (v *Menu) native() *C.GtkMenu { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkMenu(p) +} + +func (v *Menu) toMenu() *C.GtkMenu { + if v == nil { + return nil + } + return v.native() +} + +func marshalMenu(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapMenu(obj), nil +} + +func wrapMenu(obj *glib.Object) *Menu { + return &Menu{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// MenuNew() is a wrapper around gtk_menu_new(). +func MenuNew() (*Menu, error) { + c := C.gtk_menu_new() + if c == nil { + return nil, nilPtrErr + } + return wrapMenu(wrapObject(unsafe.Pointer(c))), nil +} + +// 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)) +} + +// Popdown() is a wrapper around gtk_menu_popdown(). +func (v *Menu) Popdown() { + C.gtk_menu_popdown(v.native()) +} + +// ReorderChild() is a wrapper around gtk_menu_reorder_child(). +func (v *Menu) ReorderChild(child IWidget, position int) { + C.gtk_menu_reorder_child(v.native(), child.toWidget(), C.gint(position)) +} + +/* + * GtkMenuBar + */ + +// MenuBar is a representation of GTK's GtkMenuBar. +type MenuBar struct { + MenuShell +} + +// native() returns a pointer to the underlying GtkMenuBar. +func (v *MenuBar) native() *C.GtkMenuBar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkMenuBar(p) +} + +func marshalMenuBar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapMenuBar(obj), nil +} + +func wrapMenuBar(obj *glib.Object) *MenuBar { + return &MenuBar{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// MenuBarNew() is a wrapper around gtk_menu_bar_new(). +func MenuBarNew() (*MenuBar, error) { + c := C.gtk_menu_bar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapMenuBar(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkMenuButton + */ + +// MenuButton is a representation of GTK's GtkMenuButton. +type MenuButton struct { + ToggleButton +} + +// native returns a pointer to the underlying GtkMenuButton. +func (v *MenuButton) native() *C.GtkMenuButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkMenuButton(p) +} + +func marshalMenuButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapMenuButton(obj), nil +} + +func wrapMenuButton(obj *glib.Object) *MenuButton { + return &MenuButton{ToggleButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}}} +} + +// MenuButtonNew is a wrapper around gtk_menu_button_new(). +func MenuButtonNew() (*MenuButton, error) { + c := C.gtk_menu_button_new() + if c == nil { + return nil, nilPtrErr + } + return wrapMenuButton(wrapObject(unsafe.Pointer(c))), nil +} + +// SetPopup is a wrapper around gtk_menu_button_set_popup(). +func (v *MenuButton) SetPopup(menu IMenu) { + C.gtk_menu_button_set_popup(v.native(), menu.toWidget()) +} + +// GetPopup is a wrapper around gtk_menu_button_get_popup(). +func (v *MenuButton) GetPopup() *Menu { + c := C.gtk_menu_button_get_popup(v.native()) + if c == nil { + return nil + } + return wrapMenu(wrapObject(unsafe.Pointer(c))) +} + +// TODO: gtk_menu_button_set_menu_model +// TODO: gtk_menu_button_get_menu_model + +// SetDirection is a wrapper around gtk_menu_button_set_direction(). +func (v *MenuButton) SetDirection(direction ArrowType) { + C.gtk_menu_button_set_direction(v.native(), C.GtkArrowType(direction)) +} + +// GetDirection is a wrapper around gtk_menu_button_get_direction(). +func (v *MenuButton) GetDirection() ArrowType { + c := C.gtk_menu_button_get_direction(v.native()) + return ArrowType(c) +} + +// SetAlignWidget is a wrapper around gtk_menu_button_set_align_widget(). +func (v *MenuButton) SetAlignWidget(alignWidget IWidget) { + C.gtk_menu_button_set_align_widget(v.native(), alignWidget.toWidget()) +} + +// GetAlignWidget is a wrapper around gtk_menu_button_get_align_widget(). +func (v *MenuButton) GetAlignWidget() *Widget { + c := C.gtk_menu_button_get_align_widget(v.native()) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} + +/* + * GtkMenuItem + */ + +// MenuItem is a representation of GTK's GtkMenuItem. +type MenuItem struct { + Bin +} + +// IMenuItem is an interface type implemented by all structs +// embedding a MenuItem. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkMenuItem. +type IMenuItem interface { + toMenuItem() *C.GtkMenuItem + toWidget() *C.GtkWidget +} + +// native returns a pointer to the underlying GtkMenuItem. +func (v *MenuItem) native() *C.GtkMenuItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkMenuItem(p) +} + +func (v *MenuItem) toMenuItem() *C.GtkMenuItem { + if v == nil { + return nil + } + return v.native() +} + +func marshalMenuItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapMenuItem(obj), nil +} + +func wrapMenuItem(obj *glib.Object) *MenuItem { + return &MenuItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// MenuItemNew() is a wrapper around gtk_menu_item_new(). +func MenuItemNew() (*MenuItem, error) { + c := C.gtk_menu_item_new() + if c == nil { + return nil, nilPtrErr + } + return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// MenuItemNewWithLabel() is a wrapper around gtk_menu_item_new_with_label(). +func MenuItemNewWithLabel(label string) (*MenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_menu_item_new_with_label((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// MenuItemNewWithMnemonic() is a wrapper around +// gtk_menu_item_new_with_mnemonic(). +func MenuItemNewWithMnemonic(label string) (*MenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_menu_item_new_with_mnemonic((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// SetSubmenu() is a wrapper around gtk_menu_item_set_submenu(). +func (v *MenuItem) SetSubmenu(submenu IWidget) { + C.gtk_menu_item_set_submenu(v.native(), submenu.toWidget()) +} + +// Sets text on the menu_item label +func (v *MenuItem) SetLabel(label string) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_menu_item_set_label(v.native(), (*C.gchar)(cstr)) +} + +/* + * GtkMessageDialog + */ + +// MessageDialog is a representation of GTK's GtkMessageDialog. +type MessageDialog struct { + Dialog +} + +// native returns a pointer to the underlying GtkMessageDialog. +func (v *MessageDialog) native() *C.GtkMessageDialog { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkMessageDialog(p) +} + +func marshalMessageDialog(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapMessageDialog(obj), nil +} + +func wrapMessageDialog(obj *glib.Object) *MessageDialog { + return &MessageDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} +} + +// MessageDialogNew() is a wrapper around gtk_message_dialog_new(). +// The text is created and formatted by the format specifier and any +// additional arguments. +func MessageDialogNew(parent IWindow, flags DialogFlags, mType MessageType, buttons ButtonsType, format string, a ...interface{}) *MessageDialog { + s := fmt.Sprintf(format, a...) + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + var w *C.GtkWindow = nil + if parent != nil { + w = parent.toWindow() + } + c := C._gtk_message_dialog_new(w, + C.GtkDialogFlags(flags), C.GtkMessageType(mType), + C.GtkButtonsType(buttons), cstr) + return wrapMessageDialog(wrapObject(unsafe.Pointer(c))) +} + +// MessageDialogNewWithMarkup is a wrapper around +// gtk_message_dialog_new_with_markup(). +func MessageDialogNewWithMarkup(parent IWindow, flags DialogFlags, mType MessageType, buttons ButtonsType, format string, a ...interface{}) *MessageDialog { + s := fmt.Sprintf(format, a...) + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + var w *C.GtkWindow = nil + if parent != nil { + w = parent.toWindow() + } + c := C._gtk_message_dialog_new_with_markup(w, + C.GtkDialogFlags(flags), C.GtkMessageType(mType), + C.GtkButtonsType(buttons), cstr) + return wrapMessageDialog(wrapObject(unsafe.Pointer(c))) +} + +// SetMarkup is a wrapper around gtk_message_dialog_set_markup(). +func (v *MessageDialog) SetMarkup(str string) { + cstr := C.CString(str) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_message_dialog_set_markup(v.native(), (*C.gchar)(cstr)) +} + +// FormatSecondaryText is a wrapper around +// gtk_message_dialog_format_secondary_text(). +func (v *MessageDialog) FormatSecondaryText(format string, a ...interface{}) { + s := fmt.Sprintf(format, a...) + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + C._gtk_message_dialog_format_secondary_text(v.native(), + (*C.gchar)(cstr)) +} + +// FormatSecondaryMarkup is a wrapper around +// gtk_message_dialog_format_secondary_text(). +func (v *MessageDialog) FormatSecondaryMarkup(format string, a ...interface{}) { + s := fmt.Sprintf(format, a...) + cstr := C.CString(s) + defer C.free(unsafe.Pointer(cstr)) + C._gtk_message_dialog_format_secondary_markup(v.native(), + (*C.gchar)(cstr)) +} + +/* + * GtkNotebook + */ + +// Notebook is a representation of GTK's GtkNotebook. +type Notebook struct { + Container +} + +// native returns a pointer to the underlying GtkNotebook. +func (v *Notebook) native() *C.GtkNotebook { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkNotebook(p) +} + +func marshalNotebook(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapNotebook(obj), nil +} + +func wrapNotebook(obj *glib.Object) *Notebook { + return &Notebook{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// NotebookNew() is a wrapper around gtk_notebook_new(). +func NotebookNew() (*Notebook, error) { + c := C.gtk_notebook_new() + if c == nil { + return nil, nilPtrErr + } + return wrapNotebook(wrapObject(unsafe.Pointer(c))), nil +} + +// AppendPage() is a wrapper around gtk_notebook_append_page(). +func (v *Notebook) AppendPage(child IWidget, tabLabel IWidget) int { + cTabLabel := nullableWidget(tabLabel) + c := C.gtk_notebook_append_page(v.native(), child.toWidget(), cTabLabel) + return int(c) +} + +// AppendPageMenu() is a wrapper around gtk_notebook_append_page_menu(). +func (v *Notebook) AppendPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget) int { + c := C.gtk_notebook_append_page_menu(v.native(), child.toWidget(), + tabLabel.toWidget(), menuLabel.toWidget()) + return int(c) +} + +// PrependPage() is a wrapper around gtk_notebook_prepend_page(). +func (v *Notebook) PrependPage(child IWidget, tabLabel IWidget) int { + cTabLabel := nullableWidget(tabLabel) + c := C.gtk_notebook_prepend_page(v.native(), child.toWidget(), cTabLabel) + return int(c) +} + +// PrependPageMenu() is a wrapper around gtk_notebook_prepend_page_menu(). +func (v *Notebook) PrependPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget) int { + c := C.gtk_notebook_prepend_page_menu(v.native(), child.toWidget(), + tabLabel.toWidget(), menuLabel.toWidget()) + return int(c) +} + +// InsertPage() is a wrapper around gtk_notebook_insert_page(). +func (v *Notebook) InsertPage(child IWidget, tabLabel IWidget, position int) int { + label := nullableWidget(tabLabel) + c := C.gtk_notebook_insert_page(v.native(), child.toWidget(), label, C.gint(position)) + + return int(c) +} + +// InsertPageMenu() is a wrapper around gtk_notebook_insert_page_menu(). +func (v *Notebook) InsertPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget, position int) int { + c := C.gtk_notebook_insert_page_menu(v.native(), child.toWidget(), + tabLabel.toWidget(), menuLabel.toWidget(), C.gint(position)) + return int(c) +} + +// RemovePage() is a wrapper around gtk_notebook_remove_page(). +func (v *Notebook) RemovePage(pageNum int) { + C.gtk_notebook_remove_page(v.native(), C.gint(pageNum)) +} + +// PageNum() is a wrapper around gtk_notebook_page_num(). +func (v *Notebook) PageNum(child IWidget) int { + c := C.gtk_notebook_page_num(v.native(), child.toWidget()) + return int(c) +} + +// NextPage() is a wrapper around gtk_notebook_next_page(). +func (v *Notebook) NextPage() { + C.gtk_notebook_next_page(v.native()) +} + +// PrevPage() is a wrapper around gtk_notebook_prev_page(). +func (v *Notebook) PrevPage() { + C.gtk_notebook_prev_page(v.native()) +} + +// ReorderChild() is a wrapper around gtk_notebook_reorder_child(). +func (v *Notebook) ReorderChild(child IWidget, position int) { + C.gtk_notebook_reorder_child(v.native(), child.toWidget(), + C.gint(position)) +} + +// SetTabPos() is a wrapper around gtk_notebook_set_tab_pos(). +func (v *Notebook) SetTabPos(pos PositionType) { + C.gtk_notebook_set_tab_pos(v.native(), C.GtkPositionType(pos)) +} + +// SetShowTabs() is a wrapper around gtk_notebook_set_show_tabs(). +func (v *Notebook) SetShowTabs(showTabs bool) { + C.gtk_notebook_set_show_tabs(v.native(), gbool(showTabs)) +} + +// SetShowBorder() is a wrapper around gtk_notebook_set_show_border(). +func (v *Notebook) SetShowBorder(showBorder bool) { + C.gtk_notebook_set_show_border(v.native(), gbool(showBorder)) +} + +// SetScrollable() is a wrapper around gtk_notebook_set_scrollable(). +func (v *Notebook) SetScrollable(scrollable bool) { + C.gtk_notebook_set_scrollable(v.native(), gbool(scrollable)) +} + +// PopupEnable() is a wrapper around gtk_notebook_popup_enable(). +func (v *Notebook) PopupEnable() { + C.gtk_notebook_popup_enable(v.native()) +} + +// PopupDisable() is a wrapper around gtk_notebook_popup_disable(). +func (v *Notebook) PopupDisable() { + C.gtk_notebook_popup_disable(v.native()) +} + +// GetCurrentPage() is a wrapper around gtk_notebook_get_current_page(). +func (v *Notebook) GetCurrentPage() int { + c := C.gtk_notebook_get_current_page(v.native()) + return int(c) +} + +// GetMenuLabel() is a wrapper around gtk_notebook_get_menu_label(). +func (v *Notebook) GetMenuLabel(child IWidget) (*Widget, error) { + c := C.gtk_notebook_get_menu_label(v.native(), child.toWidget()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetNthPage() is a wrapper around gtk_notebook_get_nth_page(). +func (v *Notebook) GetNthPage(pageNum int) (*Widget, error) { + c := C.gtk_notebook_get_nth_page(v.native(), C.gint(pageNum)) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetNPages() is a wrapper around gtk_notebook_get_n_pages(). +func (v *Notebook) GetNPages() int { + c := C.gtk_notebook_get_n_pages(v.native()) + return int(c) +} + +// GetTabLabel() is a wrapper around gtk_notebook_get_tab_label(). +func (v *Notebook) GetTabLabel(child IWidget) (*Widget, error) { + c := C.gtk_notebook_get_tab_label(v.native(), child.toWidget()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// SetMenuLabel() is a wrapper around gtk_notebook_set_menu_label(). +func (v *Notebook) SetMenuLabel(child, menuLabel IWidget) { + C.gtk_notebook_set_menu_label(v.native(), child.toWidget(), + menuLabel.toWidget()) +} + +// SetMenuLabelText() is a wrapper around gtk_notebook_set_menu_label_text(). +func (v *Notebook) SetMenuLabelText(child IWidget, menuText string) { + cstr := C.CString(menuText) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_notebook_set_menu_label_text(v.native(), child.toWidget(), + (*C.gchar)(cstr)) +} + +// SetTabLabel() is a wrapper around gtk_notebook_set_tab_label(). +func (v *Notebook) SetTabLabel(child, tabLabel IWidget) { + C.gtk_notebook_set_tab_label(v.native(), child.toWidget(), + tabLabel.toWidget()) +} + +// SetTabLabelText() is a wrapper around gtk_notebook_set_tab_label_text(). +func (v *Notebook) SetTabLabelText(child IWidget, tabText string) { + cstr := C.CString(tabText) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_notebook_set_tab_label_text(v.native(), child.toWidget(), + (*C.gchar)(cstr)) +} + +// SetTabReorderable() is a wrapper around gtk_notebook_set_tab_reorderable(). +func (v *Notebook) SetTabReorderable(child IWidget, reorderable bool) { + C.gtk_notebook_set_tab_reorderable(v.native(), child.toWidget(), + gbool(reorderable)) +} + +// SetTabDetachable() is a wrapper around gtk_notebook_set_tab_detachable(). +func (v *Notebook) SetTabDetachable(child IWidget, detachable bool) { + C.gtk_notebook_set_tab_detachable(v.native(), child.toWidget(), + gbool(detachable)) +} + +// GetMenuLabelText() is a wrapper around gtk_notebook_get_menu_label_text(). +func (v *Notebook) GetMenuLabelText(child IWidget) (string, error) { + c := C.gtk_notebook_get_menu_label_text(v.native(), child.toWidget()) + if c == nil { + return "", errors.New("No menu label for widget") + } + return C.GoString((*C.char)(c)), nil +} + +// GetScrollable() is a wrapper around gtk_notebook_get_scrollable(). +func (v *Notebook) GetScrollable() bool { + c := C.gtk_notebook_get_scrollable(v.native()) + return gobool(c) +} + +// GetShowBorder() is a wrapper around gtk_notebook_get_show_border(). +func (v *Notebook) GetShowBorder() bool { + c := C.gtk_notebook_get_show_border(v.native()) + return gobool(c) +} + +// GetShowTabs() is a wrapper around gtk_notebook_get_show_tabs(). +func (v *Notebook) GetShowTabs() bool { + c := C.gtk_notebook_get_show_tabs(v.native()) + return gobool(c) +} + +// GetTabLabelText() is a wrapper around gtk_notebook_get_tab_label_text(). +func (v *Notebook) GetTabLabelText(child IWidget) (string, error) { + c := C.gtk_notebook_get_tab_label_text(v.native(), child.toWidget()) + if c == nil { + return "", errors.New("No tab label for widget") + } + return C.GoString((*C.char)(c)), nil +} + +// GetTabPos() is a wrapper around gtk_notebook_get_tab_pos(). +func (v *Notebook) GetTabPos() PositionType { + c := C.gtk_notebook_get_tab_pos(v.native()) + return PositionType(c) +} + +// GetTabReorderable() is a wrapper around gtk_notebook_get_tab_reorderable(). +func (v *Notebook) GetTabReorderable(child IWidget) bool { + c := C.gtk_notebook_get_tab_reorderable(v.native(), child.toWidget()) + return gobool(c) +} + +// GetTabDetachable() is a wrapper around gtk_notebook_get_tab_detachable(). +func (v *Notebook) GetTabDetachable(child IWidget) bool { + c := C.gtk_notebook_get_tab_detachable(v.native(), child.toWidget()) + return gobool(c) +} + +// SetCurrentPage() is a wrapper around gtk_notebook_set_current_page(). +func (v *Notebook) SetCurrentPage(pageNum int) { + C.gtk_notebook_set_current_page(v.native(), C.gint(pageNum)) +} + +// SetGroupName() is a wrapper around gtk_notebook_set_group_name(). +func (v *Notebook) SetGroupName(groupName string) { + cstr := C.CString(groupName) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_notebook_set_group_name(v.native(), (*C.gchar)(cstr)) +} + +// GetGroupName() is a wrapper around gtk_notebook_get_group_name(). +func (v *Notebook) GetGroupName() (string, error) { + c := C.gtk_notebook_get_group_name(v.native()) + if c == nil { + return "", errors.New("No group name") + } + return C.GoString((*C.char)(c)), nil +} + +// SetActionWidget() is a wrapper around gtk_notebook_set_action_widget(). +func (v *Notebook) SetActionWidget(widget IWidget, packType PackType) { + C.gtk_notebook_set_action_widget(v.native(), widget.toWidget(), + C.GtkPackType(packType)) +} + +// GetActionWidget() is a wrapper around gtk_notebook_get_action_widget(). +func (v *Notebook) GetActionWidget(packType PackType) (*Widget, error) { + c := C.gtk_notebook_get_action_widget(v.native(), + C.GtkPackType(packType)) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkOffscreenWindow + */ + +// OffscreenWindow is a representation of GTK's GtkOffscreenWindow. +type OffscreenWindow struct { + Window +} + +// native returns a pointer to the underlying GtkOffscreenWindow. +func (v *OffscreenWindow) native() *C.GtkOffscreenWindow { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkOffscreenWindow(p) +} + +func marshalOffscreenWindow(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapOffscreenWindow(obj), nil +} + +func wrapOffscreenWindow(obj *glib.Object) *OffscreenWindow { + return &OffscreenWindow{Window{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// OffscreenWindowNew is a wrapper around gtk_offscreen_window_new(). +func OffscreenWindowNew() (*OffscreenWindow, error) { + c := C.gtk_offscreen_window_new() + if c == nil { + return nil, nilPtrErr + } + return wrapOffscreenWindow(wrapObject(unsafe.Pointer(c))), nil +} + +// GetSurface is a wrapper around gtk_offscreen_window_get_surface(). +// The returned surface is safe to use over window resizes. +func (v *OffscreenWindow) GetSurface() (*cairo.Surface, error) { + c := C.gtk_offscreen_window_get_surface(v.native()) + if c == nil { + return nil, nilPtrErr + } + cairoPtr := (uintptr)(unsafe.Pointer(c)) + s := cairo.NewSurface(cairoPtr, true) + return s, nil +} + +// GetPixbuf is a wrapper around gtk_offscreen_window_get_pixbuf(). +func (v *OffscreenWindow) GetPixbuf() (*gdk.Pixbuf, error) { + c := C.gtk_offscreen_window_get_pixbuf(v.native()) + if c == nil { + return nil, nilPtrErr + } + + // Pixbuf is returned with ref count of 1, so don't increment. + // Is it a floating reference? + pb := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} + return pb, nil +} + +/* + * GtkOrientable + */ + +// Orientable is a representation of GTK's GtkOrientable GInterface. +type Orientable struct { + *glib.Object +} + +// IOrientable is an interface type implemented by all structs +// embedding an Orientable. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkOrientable. +type IOrientable interface { + toOrientable() *C.GtkOrientable +} + +// native returns a pointer to the underlying GObject as a GtkOrientable. +func (v *Orientable) native() *C.GtkOrientable { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkOrientable(p) +} + +func marshalOrientable(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapOrientable(obj), nil +} + +func wrapOrientable(obj *glib.Object) *Orientable { + return &Orientable{obj} +} + +// GetOrientation() is a wrapper around gtk_orientable_get_orientation(). +func (v *Orientable) GetOrientation() Orientation { + c := C.gtk_orientable_get_orientation(v.native()) + return Orientation(c) +} + +// SetOrientation() is a wrapper around gtk_orientable_set_orientation(). +func (v *Orientable) SetOrientation(orientation Orientation) { + C.gtk_orientable_set_orientation(v.native(), + C.GtkOrientation(orientation)) +} + +/* + * GtkPaned + */ + +// Paned is a representation of GTK's GtkPaned. +type Paned struct { + Bin +} + +// native returns a pointer to the underlying GtkPaned. +func (v *Paned) native() *C.GtkPaned { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkPaned(p) +} + +func marshalPaned(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPaned(obj), nil +} + +func wrapPaned(obj *glib.Object) *Paned { + return &Paned{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// PanedNew() is a wrapper around gtk_scrolled_window_new(). +func PanedNew(orientation Orientation) (*Paned, error) { + c := C.gtk_paned_new(C.GtkOrientation(orientation)) + if c == nil { + return nil, nilPtrErr + } + return wrapPaned(wrapObject(unsafe.Pointer(c))), nil +} + +// Add1() is a wrapper around gtk_paned_add1(). +func (v *Paned) Add1(child IWidget) { + C.gtk_paned_add1(v.native(), child.toWidget()) +} + +// Add2() is a wrapper around gtk_paned_add2(). +func (v *Paned) Add2(child IWidget) { + C.gtk_paned_add2(v.native(), child.toWidget()) +} + +// Pack1() is a wrapper around gtk_paned_pack1(). +func (v *Paned) Pack1(child IWidget, resize, shrink bool) { + C.gtk_paned_pack1(v.native(), child.toWidget(), gbool(resize), gbool(shrink)) +} + +// Pack2() is a wrapper around gtk_paned_pack2(). +func (v *Paned) Pack2(child IWidget, resize, shrink bool) { + C.gtk_paned_pack2(v.native(), child.toWidget(), gbool(resize), gbool(shrink)) +} + +// SetPosition() is a wrapper around gtk_paned_set_position(). +func (v *Paned) SetPosition(position int) { + C.gtk_paned_set_position(v.native(), C.gint(position)) +} + +// GetChild1() is a wrapper around gtk_paned_get_child1(). +func (v *Paned) GetChild1() (*Widget, error) { + c := C.gtk_paned_get_child1(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetChild2() is a wrapper around gtk_paned_get_child2(). +func (v *Paned) GetChild2() (*Widget, error) { + c := C.gtk_paned_get_child2(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetHandleWindow() is a wrapper around gtk_paned_get_handle_window(). +func (v *Paned) GetHandleWindow() (*Window, error) { + c := C.gtk_paned_get_handle_window(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWindow(wrapObject(unsafe.Pointer(c))), nil +} + +// GetPosition() is a wrapper around gtk_paned_get_position(). +func (v *Paned) GetPosition() int { + return int(C.gtk_paned_get_position(v.native())) +} + +/* + * GtkProgressBar + */ + +// ProgressBar is a representation of GTK's GtkProgressBar. +type ProgressBar struct { + Widget +} + +// native returns a pointer to the underlying GtkProgressBar. +func (v *ProgressBar) native() *C.GtkProgressBar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkProgressBar(p) +} + +func marshalProgressBar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapProgressBar(obj), nil +} + +func wrapProgressBar(obj *glib.Object) *ProgressBar { + return &ProgressBar{Widget{glib.InitiallyUnowned{obj}}} +} + +// ProgressBarNew() is a wrapper around gtk_progress_bar_new(). +func ProgressBarNew() (*ProgressBar, error) { + c := C.gtk_progress_bar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapProgressBar(wrapObject(unsafe.Pointer(c))), nil +} + +// SetFraction() is a wrapper around gtk_progress_bar_set_fraction(). +func (v *ProgressBar) SetFraction(fraction float64) { + C.gtk_progress_bar_set_fraction(v.native(), C.gdouble(fraction)) +} + +// GetFraction() is a wrapper around gtk_progress_bar_get_fraction(). +func (v *ProgressBar) GetFraction() float64 { + c := C.gtk_progress_bar_get_fraction(v.native()) + return float64(c) +} + +// SetShowText is a wrapper around gtk_progress_bar_set_show_text(). +func (v *ProgressBar) SetShowText(showText bool) { + C.gtk_progress_bar_set_show_text(v.native(), gbool(showText)) +} + +// GetShowText is a wrapper around gtk_progress_bar_get_show_text(). +func (v *ProgressBar) GetShowText() bool { + c := C.gtk_progress_bar_get_show_text(v.native()) + return gobool(c) +} + +// SetText() is a wrapper around gtk_progress_bar_set_text(). +func (v *ProgressBar) SetText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_progress_bar_set_text(v.native(), (*C.gchar)(cstr)) +} + +/* + * GtkRadioButton + */ + +// RadioButton is a representation of GTK's GtkRadioButton. +type RadioButton struct { + CheckButton +} + +// native returns a pointer to the underlying GtkRadioButton. +func (v *RadioButton) native() *C.GtkRadioButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRadioButton(p) +} + +func marshalRadioButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapRadioButton(obj), nil +} + +func wrapRadioButton(obj *glib.Object) *RadioButton { + return &RadioButton{CheckButton{ToggleButton{Button{Bin{Container{ + Widget{glib.InitiallyUnowned{obj}}}}}}}} +} + +// RadioButtonNew is a wrapper around gtk_radio_button_new(). +func RadioButtonNew(group *glib.SList) (*RadioButton, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + c := C.gtk_radio_button_new(gslist) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioButtonNewFromWidget is a wrapper around +// gtk_radio_button_new_from_widget(). +func RadioButtonNewFromWidget(radioGroupMember *RadioButton) (*RadioButton, error) { + c := C.gtk_radio_button_new_from_widget(radioGroupMember.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioButtonNewWithLabel is a wrapper around +// gtk_radio_button_new_with_label(). +func RadioButtonNewWithLabel(group *glib.SList, label string) (*RadioButton, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_button_new_with_label(gslist, (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioButtonNewWithLabelFromWidget is a wrapper around +// gtk_radio_button_new_with_label_from_widget(). +func RadioButtonNewWithLabelFromWidget(radioGroupMember *RadioButton, label string) (*RadioButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_button_new_with_label_from_widget(radioGroupMember.native(), + (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioButtonNewWithMnemonic is a wrapper around +// gtk_radio_button_new_with_mnemonic() +func RadioButtonNewWithMnemonic(group *glib.SList, label string) (*RadioButton, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_button_new_with_mnemonic(gslist, (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioButtonNewWithMnemonicFromWidget is a wrapper around +// gtk_radio_button_new_with_mnemonic_from_widget(). +func RadioButtonNewWithMnemonicFromWidget(radioGroupMember *RadioButton, label string) (*RadioButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_button_new_with_mnemonic_from_widget(radioGroupMember.native(), + (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil +} + +// SetGroup is a wrapper around gtk_radio_button_set_group(). +func (v *RadioButton) SetGroup(group *glib.SList) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + C.gtk_radio_button_set_group(v.native(), gslist) +} + +// GetGroup is a wrapper around gtk_radio_button_get_group(). +func (v *RadioButton) GetGroup() (*glib.SList, error) { + c := C.gtk_radio_button_get_group(v.native()) + if c == nil { + return nil, nilPtrErr + } + return glib.WrapSList(uintptr(unsafe.Pointer(c))), nil +} + +// JoinGroup is a wrapper around gtk_radio_button_join_group(). +func (v *RadioButton) JoinGroup(groupSource *RadioButton) { + C.gtk_radio_button_join_group(v.native(), groupSource.native()) +} + +/* + * GtkRadioMenuItem + */ + +// RadioMenuItem is a representation of GTK's GtkRadioMenuItem. +type RadioMenuItem struct { + CheckMenuItem +} + +// native returns a pointer to the underlying GtkRadioMenuItem. +func (v *RadioMenuItem) native() *C.GtkRadioMenuItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRadioMenuItem(p) +} + +func marshalRadioMenuItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapRadioMenuItem(obj), nil +} + +func wrapRadioMenuItem(obj *glib.Object) *RadioMenuItem { + return &RadioMenuItem{CheckMenuItem{MenuItem{Bin{Container{ + Widget{glib.InitiallyUnowned{obj}}}}}}} +} + +// RadioMenuItemNew is a wrapper around gtk_radio_menu_item_new(). +func RadioMenuItemNew(group *glib.SList) (*RadioMenuItem, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + c := C.gtk_radio_menu_item_new(gslist) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioMenuItemNewWithLabel is a wrapper around +// gtk_radio_menu_item_new_with_label(). +func RadioMenuItemNewWithLabel(group *glib.SList, label string) (*RadioMenuItem, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_menu_item_new_with_label(gslist, (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioMenuItemNewWithMnemonic is a wrapper around +// gtk_radio_menu_item_new_with_mnemonic(). +func RadioMenuItemNewWithMnemonic(group *glib.SList, label string) (*RadioMenuItem, error) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_menu_item_new_with_mnemonic(gslist, (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioMenuItemNewFromWidget is a wrapper around +// gtk_radio_menu_item_new_from_widget(). +func RadioMenuItemNewFromWidget(group *RadioMenuItem) (*RadioMenuItem, error) { + c := C.gtk_radio_menu_item_new_from_widget(group.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioMenuItemNewWithLabelFromWidget is a wrapper around +// gtk_radio_menu_item_new_with_label_from_widget(). +func RadioMenuItemNewWithLabelFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_menu_item_new_with_label_from_widget(group.native(), + (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// RadioMenuItemNewWithMnemonicFromWidget is a wrapper around +// gtk_radio_menu_item_new_with_mnemonic_from_widget(). +func RadioMenuItemNewWithMnemonicFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_radio_menu_item_new_with_mnemonic_from_widget(group.native(), + (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +// SetGroup is a wrapper around gtk_radio_menu_item_set_group(). +func (v *RadioMenuItem) SetGroup(group *glib.SList) { + gslist := (*C.GSList)(unsafe.Pointer(group.Native())) + C.gtk_radio_menu_item_set_group(v.native(), gslist) +} + +// GetGroup is a wrapper around gtk_radio_menu_item_get_group(). +func (v *RadioMenuItem) GetGroup() (*glib.SList, error) { + c := C.gtk_radio_menu_item_get_group(v.native()) + if c == nil { + return nil, nilPtrErr + } + return glib.WrapSList(uintptr(unsafe.Pointer(c))), nil +} + +/* + * GtkRange + */ + +// Range is a representation of GTK's GtkRange. +type Range struct { + Widget +} + +// native returns a pointer to the underlying GtkRange. +func (v *Range) native() *C.GtkRange { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRange(p) +} + +func marshalRange(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapRange(obj), nil +} + +func wrapRange(obj *glib.Object) *Range { + return &Range{Widget{glib.InitiallyUnowned{obj}}} +} + +// GetValue is a wrapper around gtk_range_get_value(). +func (v *Range) GetValue() float64 { + c := C.gtk_range_get_value(v.native()) + return float64(c) +} + +// SetValue is a wrapper around gtk_range_set_value(). +func (v *Range) SetValue(value float64) { + C.gtk_range_set_value(v.native(), C.gdouble(value)) +} + +// SetIncrements() is a wrapper around gtk_range_set_increments(). +func (v *Range) SetIncrements(step, page float64) { + C.gtk_range_set_increments(v.native(), C.gdouble(step), C.gdouble(page)) +} + +// SetRange() is a wrapper around gtk_range_set_range(). +func (v *Range) SetRange(min, max float64) { + C.gtk_range_set_range(v.native(), C.gdouble(min), C.gdouble(max)) +} + +// IRecentChooser is an interface type implemented by all structs +// embedding a RecentChooser. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkWidget. +type IRecentChooser interface { + toRecentChooser() *C.GtkRecentChooser +} + +/* + * GtkRecentChooser + */ + +// RecentChooser is a representation of GTK's GtkRecentChooser. +type RecentChooser struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkRecentChooser. +func (v *RecentChooser) native() *C.GtkRecentChooser { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRecentChooser(p) +} + +func wrapRecentChooser(obj *glib.Object) *RecentChooser { + return &RecentChooser{obj} +} + +func (v *RecentChooser) toRecentChooser() *C.GtkRecentChooser { + return v.native() +} + +func (v *RecentChooser) GetCurrentUri() string { + curi := C.gtk_recent_chooser_get_current_uri(v.native()) + uri := C.GoString((*C.char)(curi)) + return uri +} + +func (v *RecentChooser) AddFilter(filter *RecentFilter) { + C.gtk_recent_chooser_add_filter(v.native(), filter.native()) +} + +func (v *RecentChooser) RemoveFilter(filter *RecentFilter) { + C.gtk_recent_chooser_remove_filter(v.native(), filter.native()) +} + +/* + * GtkRecentChooserMenu + */ + +// RecentChooserMenu is a representation of GTK's GtkRecentChooserMenu. +type RecentChooserMenu struct { + Menu + RecentChooser +} + +// native returns a pointer to the underlying GtkRecentManager. +func (v *RecentChooserMenu) native() *C.GtkRecentChooserMenu { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRecentChooserMenu(p) +} + +func wrapRecentChooserMenu(obj *glib.Object) *RecentChooserMenu { + return &RecentChooserMenu{ + Menu{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}}, + RecentChooser{obj}, + } +} + +/* + * GtkRecentFilter + */ + +// RecentFilter is a representation of GTK's GtkRecentFilter. +type RecentFilter struct { + glib.InitiallyUnowned +} + +// native returns a pointer to the underlying GtkRecentFilter. +func (v *RecentFilter) native() *C.GtkRecentFilter { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRecentFilter(p) +} + +func wrapRecentFilter(obj *glib.Object) *RecentFilter { + return &RecentFilter{glib.InitiallyUnowned{obj}} +} + +// RecentFilterNew is a wrapper around gtk_recent_filter_new(). +func RecentFilterNew() (*RecentFilter, error) { + c := C.gtk_recent_filter_new() + if c == nil { + return nil, nilPtrErr + } + return wrapRecentFilter(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkRecentManager + */ + +// RecentManager is a representation of GTK's GtkRecentManager. +type RecentManager struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkRecentManager. +func (v *RecentManager) native() *C.GtkRecentManager { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRecentManager(p) +} + +func marshalRecentManager(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapRecentManager(obj), nil +} + +func wrapRecentManager(obj *glib.Object) *RecentManager { + return &RecentManager{obj} +} + +// RecentManagerGetDefault is a wrapper around gtk_recent_manager_get_default(). +func RecentManagerGetDefault() (*RecentManager, error) { + c := C.gtk_recent_manager_get_default() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + v := wrapRecentManager(obj) + return v, nil +} + +// AddItem is a wrapper around gtk_recent_manager_add_item(). +func (v *RecentManager) AddItem(fileURI string) bool { + cstr := C.CString(fileURI) + defer C.free(unsafe.Pointer(cstr)) + cok := C.gtk_recent_manager_add_item(v.native(), (*C.gchar)(cstr)) + return gobool(cok) +} + +/* + * GtkScale + */ + +// Scale is a representation of GTK's GtkScale. +type Scale struct { + Range +} + +// native returns a pointer to the underlying GtkScale. +func (v *Scale) native() *C.GtkScale { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkScale(p) +} + +func marshalScale(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapScale(obj), nil +} + +func wrapScale(obj *glib.Object) *Scale { + return &Scale{Range{Widget{glib.InitiallyUnowned{obj}}}} +} + +// ScaleNew is a wrapper around gtk_scale_new(). +func ScaleNew(orientation Orientation, adjustment *Adjustment) (*Scale, error) { + c := C.gtk_scale_new(C.GtkOrientation(orientation), adjustment.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapScale(wrapObject(unsafe.Pointer(c))), nil +} + +// ScaleNewWithRange is a wrapper around gtk_scale_new_with_range(). +func ScaleNewWithRange(orientation Orientation, min, max, step float64) (*Scale, error) { + c := C.gtk_scale_new_with_range(C.GtkOrientation(orientation), + C.gdouble(min), C.gdouble(max), C.gdouble(step)) + + if c == nil { + return nil, nilPtrErr + } + return wrapScale(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkScaleButton + */ + +// ScaleButton is a representation of GTK's GtkScaleButton. +type ScaleButton struct { + Button +} + +// native() returns a pointer to the underlying GtkScaleButton. +func (v *ScaleButton) native() *C.GtkScaleButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkScaleButton(p) +} + +func marshalScaleButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapScaleButton(obj), nil +} + +func wrapScaleButton(obj *glib.Object) *ScaleButton { + return &ScaleButton{Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} +} + +// ScaleButtonNew() is a wrapper around gtk_scale_button_new(). +func ScaleButtonNew(size IconSize, min, max, step float64, icons []string) (*ScaleButton, error) { + cicons := make([]*C.gchar, len(icons)) + for i, icon := range icons { + cicons[i] = (*C.gchar)(C.CString(icon)) + defer C.free(unsafe.Pointer(cicons[i])) + } + cicons = append(cicons, nil) + + c := C.gtk_scale_button_new(C.GtkIconSize(size), + C.gdouble(min), + C.gdouble(max), + C.gdouble(step), + &cicons[0]) + if c == nil { + return nil, nilPtrErr + } + return wrapScaleButton(wrapObject(unsafe.Pointer(c))), nil +} + +// GetAdjustment() is a wrapper around gtk_scale_button_get_adjustment(). +func (v *ScaleButton) GetAdjustment() *Adjustment { + c := C.gtk_scale_button_get_adjustment(v.native()) + obj := wrapObject(unsafe.Pointer(c)) + return &Adjustment{glib.InitiallyUnowned{obj}} +} + +// GetPopup() is a wrapper around gtk_scale_button_get_popup(). +func (v *ScaleButton) GetPopup() (*Widget, error) { + c := C.gtk_scale_button_get_popup(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetValue() is a wrapper around gtk_scale_button_get_value(). +func (v *ScaleButton) GetValue() float64 { + return float64(C.gtk_scale_button_get_value(v.native())) +} + +// SetAdjustment() is a wrapper around gtk_scale_button_set_adjustment(). +func (v *ScaleButton) SetAdjustment(adjustment *Adjustment) { + C.gtk_scale_button_set_adjustment(v.native(), adjustment.native()) +} + +// SetValue() is a wrapper around gtk_scale_button_set_value(). +func (v *ScaleButton) SetValue(value float64) { + C.gtk_scale_button_set_value(v.native(), C.gdouble(value)) +} + +/* + * GtkScrollable + */ + +// IScrollable is an interface type implemented by all structs +// embedding a Scrollable. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkScrollable. +type IScrollable interface { + toScrollable() *C.GtkScrollable +} + +// Scrollable is a representation of GTK's GtkScrollable GInterface. +type Scrollable struct { + *glib.Object +} + +// native() returns a pointer to the underlying GObject as a GtkScrollable. +func (v *Scrollable) native() *C.GtkScrollable { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkScrollable(p) +} + +func wrapScrollable(obj *glib.Object) *Scrollable { + return &Scrollable{obj} +} + +func (v *Scrollable) toScrollable() *C.GtkScrollable { + if v == nil { + return nil + } + return v.native() +} + +// SetHAdjustment is a wrapper around gtk_scrollable_set_hadjustment(). +func (v *Scrollable) SetHAdjustment(adjustment *Adjustment) { + C.gtk_scrollable_set_hadjustment(v.native(), adjustment.native()) +} + +// GetHAdjustment is a wrapper around gtk_scrollable_get_hadjustment(). +func (v *Scrollable) GetHAdjustment() (*Adjustment, error) { + c := C.gtk_scrollable_get_hadjustment(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapAdjustment(wrapObject(unsafe.Pointer(c))), nil +} + +// SetVAdjustment is a wrapper around gtk_scrollable_set_vadjustment(). +func (v *Scrollable) SetVAdjustment(adjustment *Adjustment) { + C.gtk_scrollable_set_vadjustment(v.native(), adjustment.native()) +} + +// GetVAdjustment is a wrapper around gtk_scrollable_get_vadjustment(). +func (v *Scrollable) GetVAdjustment() (*Adjustment, error) { + c := C.gtk_scrollable_get_vadjustment(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapAdjustment(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkScrollbar + */ + +// Scrollbar is a representation of GTK's GtkScrollbar. +type Scrollbar struct { + Range +} + +// native returns a pointer to the underlying GtkScrollbar. +func (v *Scrollbar) native() *C.GtkScrollbar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkScrollbar(p) +} + +func marshalScrollbar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapScrollbar(obj), nil +} + +func wrapScrollbar(obj *glib.Object) *Scrollbar { + return &Scrollbar{Range{Widget{glib.InitiallyUnowned{obj}}}} +} + +// ScrollbarNew is a wrapper around gtk_scrollbar_new(). +func ScrollbarNew(orientation Orientation, adjustment *Adjustment) (*Scrollbar, error) { + c := C.gtk_scrollbar_new(C.GtkOrientation(orientation), adjustment.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapScrollbar(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkScrolledWindow + */ + +// ScrolledWindow is a representation of GTK's GtkScrolledWindow. +type ScrolledWindow struct { + Bin +} + +// native returns a pointer to the underlying GtkScrolledWindow. +func (v *ScrolledWindow) native() *C.GtkScrolledWindow { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkScrolledWindow(p) +} + +func marshalScrolledWindow(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapScrolledWindow(obj), nil +} + +func wrapScrolledWindow(obj *glib.Object) *ScrolledWindow { + return &ScrolledWindow{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// ScrolledWindowNew() is a wrapper around gtk_scrolled_window_new(). +func ScrolledWindowNew(hadjustment, vadjustment *Adjustment) (*ScrolledWindow, error) { + c := C.gtk_scrolled_window_new(hadjustment.native(), + vadjustment.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapScrolledWindow(wrapObject(unsafe.Pointer(c))), nil +} + +// SetPolicy() is a wrapper around gtk_scrolled_window_set_policy(). +func (v *ScrolledWindow) SetPolicy(hScrollbarPolicy, vScrollbarPolicy PolicyType) { + C.gtk_scrolled_window_set_policy(v.native(), + C.GtkPolicyType(hScrollbarPolicy), + C.GtkPolicyType(vScrollbarPolicy)) +} + +// GetHAdjustment() is a wrapper around gtk_scrolled_window_get_hadjustment(). +func (v *ScrolledWindow) GetHAdjustment() *Adjustment { + c := C.gtk_scrolled_window_get_hadjustment(v.native()) + if c == nil { + return nil + } + return wrapAdjustment(wrapObject(unsafe.Pointer(c))) +} + +// SetHAdjustment is a wrapper around gtk_scrolled_window_set_hadjustment(). +func (v *ScrolledWindow) SetHAdjustment(adjustment *Adjustment) { + C.gtk_scrolled_window_set_hadjustment(v.native(), adjustment.native()) +} + +// GetVAdjustment() is a wrapper around gtk_scrolled_window_get_vadjustment(). +func (v *ScrolledWindow) GetVAdjustment() *Adjustment { + c := C.gtk_scrolled_window_get_vadjustment(v.native()) + if c == nil { + return nil + } + return wrapAdjustment(wrapObject(unsafe.Pointer(c))) +} + +// SetVAdjustment is a wrapper around gtk_scrolled_window_set_vadjustment(). +func (v *ScrolledWindow) SetVAdjustment(adjustment *Adjustment) { + C.gtk_scrolled_window_set_vadjustment(v.native(), adjustment.native()) +} + +/* + * GtkSearchEntry + */ + +// SearchEntry is a reprensentation of GTK's GtkSearchEntry. +type SearchEntry struct { + Entry +} + +// native returns a pointer to the underlying GtkSearchEntry. +func (v *SearchEntry) native() *C.GtkSearchEntry { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSearchEntry(p) +} + +func marshalSearchEntry(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSearchEntry(obj), nil +} + +func wrapSearchEntry(obj *glib.Object) *SearchEntry { + e := wrapEditable(obj) + return &SearchEntry{Entry{Widget{glib.InitiallyUnowned{obj}}, *e}} +} + +// SearchEntryNew is a wrapper around gtk_search_entry_new(). +func SearchEntryNew() (*SearchEntry, error) { + c := C.gtk_search_entry_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSearchEntry(wrapObject(unsafe.Pointer(c))), nil +} + +/* +* GtkSelectionData + */ +type SelectionData struct { + GtkSelectionData *C.GtkSelectionData +} + +func marshalSelectionData(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return (*SelectionData)(unsafe.Pointer(c)), nil +} + +// native returns a pointer to the underlying GtkSelectionData. +func (v *SelectionData) native() *C.GtkSelectionData { + if v == nil { + return nil + } + return v.GtkSelectionData +} + +// GetLength is a wrapper around gtk_selection_data_get_length +func (v *SelectionData) GetLength() int { + return int(C.gtk_selection_data_get_length(v.native())) +} + +// GetData is a wrapper around gtk_selection_data_get_data_with_length. +// It returns a slice of the correct size with the selection's data. +func (v *SelectionData) GetData() (data []byte) { + var length C.gint + c := C.gtk_selection_data_get_data_with_length(v.native(), &length) + sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&data)) + sliceHeader.Data = uintptr(unsafe.Pointer(c)) + sliceHeader.Len = int(length) + sliceHeader.Cap = int(length) + return +} + +func (v *SelectionData) free() { + C.gtk_selection_data_free(v.native()) +} + +/* + * GtkSeparator + */ + +// Separator is a representation of GTK's GtkSeparator. +type Separator struct { + Widget +} + +// native returns a pointer to the underlying GtkSeperator. +func (v *Separator) native() *C.GtkSeparator { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSeparator(p) +} + +func marshalSeparator(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSeparator(obj), nil +} + +func wrapSeparator(obj *glib.Object) *Separator { + return &Separator{Widget{glib.InitiallyUnowned{obj}}} +} + +// SeparatorNew is a wrapper around gtk_separator_new(). +func SeparatorNew(orientation Orientation) (*Separator, error) { + c := C.gtk_separator_new(C.GtkOrientation(orientation)) + if c == nil { + return nil, nilPtrErr + } + return wrapSeparator(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkSeparatorMenuItem + */ + +// SeparatorMenuItem is a representation of GTK's GtkSeparatorMenuItem. +type SeparatorMenuItem struct { + MenuItem +} + +// native returns a pointer to the underlying GtkSeparatorMenuItem. +func (v *SeparatorMenuItem) native() *C.GtkSeparatorMenuItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSeparatorMenuItem(p) +} + +func marshalSeparatorMenuItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSeparatorMenuItem(obj), nil +} + +func wrapSeparatorMenuItem(obj *glib.Object) *SeparatorMenuItem { + return &SeparatorMenuItem{MenuItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} +} + +// SeparatorMenuItemNew is a wrapper around gtk_separator_menu_item_new(). +func SeparatorMenuItemNew() (*SeparatorMenuItem, error) { + c := C.gtk_separator_menu_item_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSeparatorMenuItem(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkSeparatorToolItem + */ + +// SeparatorToolItem is a representation of GTK's GtkSeparatorToolItem. +type SeparatorToolItem struct { + ToolItem +} + +// native returns a pointer to the underlying GtkSeparatorToolItem. +func (v *SeparatorToolItem) native() *C.GtkSeparatorToolItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSeparatorToolItem(p) +} + +func marshalSeparatorToolItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSeparatorToolItem(obj), nil +} + +func wrapSeparatorToolItem(obj *glib.Object) *SeparatorToolItem { + return &SeparatorToolItem{ToolItem{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// SeparatorToolItemNew is a wrapper around gtk_separator_tool_item_new(). +func SeparatorToolItemNew() (*SeparatorToolItem, error) { + c := C.gtk_separator_tool_item_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSeparatorToolItem(wrapObject(unsafe.Pointer(c))), nil +} + +// SetDraw is a wrapper around gtk_separator_tool_item_set_draw(). +func (v *SeparatorToolItem) SetDraw(draw bool) { + C.gtk_separator_tool_item_set_draw(v.native(), gbool(draw)) +} + +// GetDraw is a wrapper around gtk_separator_tool_item_get_draw(). +func (v *SeparatorToolItem) GetDraw() bool { + c := C.gtk_separator_tool_item_get_draw(v.native()) + return gobool(c) +} + +/* + * GtkSizeGroup + */ + +// SizeGroup is a representation of GTK's GtkSizeGroup +type SizeGroup struct { + *glib.Object +} + +// native() returns a pointer to the underlying GtkSizeGroup +func (v *SizeGroup) native() *C.GtkSizeGroup { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSizeGroup(p) +} + +func marshalSizeGroup(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return &SizeGroup{obj}, nil +} + +func wrapSizeGroup(obj *glib.Object) *SizeGroup { + return &SizeGroup{obj} +} + +// SizeGroupNew is a wrapper around gtk_size_group_new(). +func SizeGroupNew(mode SizeGroupMode) (*SizeGroup, error) { + c := C.gtk_size_group_new(C.GtkSizeGroupMode(mode)) + if c == nil { + return nil, nilPtrErr + } + return wrapSizeGroup(wrapObject(unsafe.Pointer(c))), nil +} + +func (v *SizeGroup) SetMode(mode SizeGroupMode) { + C.gtk_size_group_set_mode(v.native(), C.GtkSizeGroupMode(mode)) +} + +func (v *SizeGroup) GetMode() SizeGroupMode { + return SizeGroupMode(C.gtk_size_group_get_mode(v.native())) +} + +func (v *SizeGroup) SetIgnoreHidden(ignoreHidden bool) { + C.gtk_size_group_set_ignore_hidden(v.native(), gbool(ignoreHidden)) +} + +func (v *SizeGroup) GetIgnoreHidden() bool { + c := C.gtk_size_group_get_ignore_hidden(v.native()) + return gobool(c) +} + +func (v *SizeGroup) AddWidget(widget IWidget) { + C.gtk_size_group_add_widget(v.native(), widget.toWidget()) +} + +func (v *SizeGroup) RemoveWidget(widget IWidget) { + C.gtk_size_group_remove_widget(v.native(), widget.toWidget()) +} + +func (v *SizeGroup) GetWidgets() *glib.SList { + c := C.gtk_size_group_get_widgets(v.native()) + if c == nil { + return nil + } + return glib.WrapSList(uintptr(unsafe.Pointer(c))) +} + +/* + * GtkSpinButton + */ + +// SpinButton is a representation of GTK's GtkSpinButton. +type SpinButton struct { + Entry +} + +// native returns a pointer to the underlying GtkSpinButton. +func (v *SpinButton) native() *C.GtkSpinButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSpinButton(p) +} + +func marshalSpinButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSpinButton(obj), nil +} + +func wrapSpinButton(obj *glib.Object) *SpinButton { + e := wrapEditable(obj) + return &SpinButton{Entry{Widget{glib.InitiallyUnowned{obj}}, *e}} +} + +// Configure() is a wrapper around gtk_spin_button_configure(). +func (v *SpinButton) Configure(adjustment *Adjustment, climbRate float64, digits uint) { + C.gtk_spin_button_configure(v.native(), adjustment.native(), + C.gdouble(climbRate), C.guint(digits)) +} + +// SpinButtonNew() is a wrapper around gtk_spin_button_new(). +func SpinButtonNew(adjustment *Adjustment, climbRate float64, digits uint) (*SpinButton, error) { + c := C.gtk_spin_button_new(adjustment.native(), + C.gdouble(climbRate), C.guint(digits)) + if c == nil { + return nil, nilPtrErr + } + return wrapSpinButton(wrapObject(unsafe.Pointer(c))), nil +} + +// SpinButtonNewWithRange() is a wrapper around +// gtk_spin_button_new_with_range(). +func SpinButtonNewWithRange(min, max, step float64) (*SpinButton, error) { + c := C.gtk_spin_button_new_with_range(C.gdouble(min), C.gdouble(max), + C.gdouble(step)) + if c == nil { + return nil, nilPtrErr + } + return wrapSpinButton(wrapObject(unsafe.Pointer(c))), nil +} + +// GetValueAsInt() is a wrapper around gtk_spin_button_get_value_as_int(). +func (v *SpinButton) GetValueAsInt() int { + c := C.gtk_spin_button_get_value_as_int(v.native()) + return int(c) +} + +// SetValue() is a wrapper around gtk_spin_button_set_value(). +func (v *SpinButton) SetValue(value float64) { + C.gtk_spin_button_set_value(v.native(), C.gdouble(value)) +} + +// GetValue() is a wrapper around gtk_spin_button_get_value(). +func (v *SpinButton) GetValue() float64 { + c := C.gtk_spin_button_get_value(v.native()) + return float64(c) +} + +// GetAdjustment() is a wrapper around gtk_spin_button_get_adjustment +func (v *SpinButton) GetAdjustment() *Adjustment { + c := C.gtk_spin_button_get_adjustment(v.native()) + if c == nil { + return nil + } + return wrapAdjustment(wrapObject(unsafe.Pointer(c))) +} + +// SetRange is a wrapper around gtk_spin_button_set_range(). +func (v *SpinButton) SetRange(min, max float64) { + C.gtk_spin_button_set_range(v.native(), C.gdouble(min), C.gdouble(max)) +} + +// SetIncrements() is a wrapper around gtk_spin_button_set_increments(). +func (v *SpinButton) SetIncrements(step, page float64) { + C.gtk_spin_button_set_increments(v.native(), C.gdouble(step), C.gdouble(page)) +} + +/* + * GtkSpinner + */ + +// Spinner is a representation of GTK's GtkSpinner. +type Spinner struct { + Widget +} + +// native returns a pointer to the underlying GtkSpinner. +func (v *Spinner) native() *C.GtkSpinner { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSpinner(p) +} + +func marshalSpinner(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSpinner(obj), nil +} + +func wrapSpinner(obj *glib.Object) *Spinner { + return &Spinner{Widget{glib.InitiallyUnowned{obj}}} +} + +// SpinnerNew is a wrapper around gtk_spinner_new(). +func SpinnerNew() (*Spinner, error) { + c := C.gtk_spinner_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSpinner(wrapObject(unsafe.Pointer(c))), nil +} + +// Start is a wrapper around gtk_spinner_start(). +func (v *Spinner) Start() { + C.gtk_spinner_start(v.native()) +} + +// Stop is a wrapper around gtk_spinner_stop(). +func (v *Spinner) Stop() { + C.gtk_spinner_stop(v.native()) +} + +/* + * GtkStatusbar + */ + +// Statusbar is a representation of GTK's GtkStatusbar +type Statusbar struct { + Box +} + +// native returns a pointer to the underlying GtkStatusbar +func (v *Statusbar) native() *C.GtkStatusbar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkStatusbar(p) +} + +func marshalStatusbar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapStatusbar(obj), nil +} + +func wrapStatusbar(obj *glib.Object) *Statusbar { + return &Statusbar{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// StatusbarNew() is a wrapper around gtk_statusbar_new(). +func StatusbarNew() (*Statusbar, error) { + c := C.gtk_statusbar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapStatusbar(wrapObject(unsafe.Pointer(c))), nil +} + +// GetContextId() is a wrapper around gtk_statusbar_get_context_id(). +func (v *Statusbar) GetContextId(contextDescription string) uint { + cstr := C.CString(contextDescription) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_statusbar_get_context_id(v.native(), (*C.gchar)(cstr)) + return uint(c) +} + +// Push() is a wrapper around gtk_statusbar_push(). +func (v *Statusbar) Push(contextID uint, text string) uint { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_statusbar_push(v.native(), C.guint(contextID), + (*C.gchar)(cstr)) + return uint(c) +} + +// Pop() is a wrapper around gtk_statusbar_pop(). +func (v *Statusbar) Pop(contextID uint) { + C.gtk_statusbar_pop(v.native(), C.guint(contextID)) +} + +// GetMessageArea() is a wrapper around gtk_statusbar_get_message_area(). +func (v *Statusbar) GetMessageArea() (*Box, error) { + c := C.gtk_statusbar_get_message_area(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, nil +} + +/* + * GtkSwitch + */ + +// Switch is a representation of GTK's GtkSwitch. +type Switch struct { + Widget +} + +// native returns a pointer to the underlying GtkSwitch. +func (v *Switch) native() *C.GtkSwitch { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSwitch(p) +} + +func marshalSwitch(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSwitch(obj), nil +} + +func wrapSwitch(obj *glib.Object) *Switch { + return &Switch{Widget{glib.InitiallyUnowned{obj}}} +} + +// SwitchNew is a wrapper around gtk_switch_new(). +func SwitchNew() (*Switch, error) { + c := C.gtk_switch_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSwitch(wrapObject(unsafe.Pointer(c))), nil +} + +// GetActive is a wrapper around gtk_switch_get_active(). +func (v *Switch) GetActive() bool { + c := C.gtk_switch_get_active(v.native()) + return gobool(c) +} + +// SetActive is a wrapper around gtk_switch_set_active(). +func (v *Switch) SetActive(isActive bool) { + C.gtk_switch_set_active(v.native(), gbool(isActive)) +} + +/* + * GtkTargetEntry + */ + +// TargetEntry is a representation of GTK's GtkTargetEntry +type TargetEntry C.GtkTargetEntry + +func marshalTargetEntry(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return (*TargetEntry)(unsafe.Pointer(c)), nil +} + +func (v *TargetEntry) native() *C.GtkTargetEntry { + return (*C.GtkTargetEntry)(unsafe.Pointer(v)) +} + +// TargetEntryNew is a wrapper aroud gtk_target_entry_new(). +func TargetEntryNew(target string, flags TargetFlags, info uint) (*TargetEntry, error) { + cstr := C.CString(target) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_target_entry_new((*C.gchar)(cstr), C.guint(flags), C.guint(info)) + if c == nil { + return nil, nilPtrErr + } + t := (*TargetEntry)(unsafe.Pointer(c)) + runtime.SetFinalizer(t, (*TargetEntry).free) + return t, nil +} + +func (v *TargetEntry) free() { + C.gtk_target_entry_free(v.native()) +} + +/* + * GtkTextView + */ + +// TextView is a representation of GTK's GtkTextView +type TextView struct { + Container +} + +// native returns a pointer to the underlying GtkTextView. +func (v *TextView) native() *C.GtkTextView { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTextView(p) +} + +func marshalTextView(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTextView(obj), nil +} + +func wrapTextView(obj *glib.Object) *TextView { + return &TextView{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// TextViewNew is a wrapper around gtk_text_view_new(). +func TextViewNew() (*TextView, error) { + c := C.gtk_text_view_new() + if c == nil { + return nil, nilPtrErr + } + return wrapTextView(wrapObject(unsafe.Pointer(c))), nil +} + +// TextViewNewWithBuffer is a wrapper around gtk_text_view_new_with_buffer(). +func TextViewNewWithBuffer(buf *TextBuffer) (*TextView, error) { + cbuf := buf.native() + c := C.gtk_text_view_new_with_buffer(cbuf) + return wrapTextView(wrapObject(unsafe.Pointer(c))), nil +} + +// GetBuffer is a wrapper around gtk_text_view_get_buffer(). +func (v *TextView) GetBuffer() (*TextBuffer, error) { + c := C.gtk_text_view_get_buffer(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapTextBuffer(wrapObject(unsafe.Pointer(c))), nil +} + +// SetBuffer is a wrapper around gtk_text_view_set_buffer(). +func (v *TextView) SetBuffer(buffer *TextBuffer) { + C.gtk_text_view_set_buffer(v.native(), buffer.native()) +} + +// SetEditable is a wrapper around gtk_text_view_set_editable(). +func (v *TextView) SetEditable(editable bool) { + C.gtk_text_view_set_editable(v.native(), gbool(editable)) +} + +// GetEditable is a wrapper around gtk_text_view_get_editable(). +func (v *TextView) GetEditable() bool { + c := C.gtk_text_view_get_editable(v.native()) + return gobool(c) +} + +// SetWrapMode is a wrapper around gtk_text_view_set_wrap_mode(). +func (v *TextView) SetWrapMode(wrapMode WrapMode) { + C.gtk_text_view_set_wrap_mode(v.native(), C.GtkWrapMode(wrapMode)) +} + +// GetWrapMode is a wrapper around gtk_text_view_get_wrap_mode(). +func (v *TextView) GetWrapMode() WrapMode { + return WrapMode(C.gtk_text_view_get_wrap_mode(v.native())) +} + +// SetCursorVisible is a wrapper around gtk_text_view_set_cursor_visible(). +func (v *TextView) SetCursorVisible(visible bool) { + C.gtk_text_view_set_cursor_visible(v.native(), gbool(visible)) +} + +// GetCursorVisible is a wrapper around gtk_text_view_get_cursor_visible(). +func (v *TextView) GetCursorVisible() bool { + c := C.gtk_text_view_get_cursor_visible(v.native()) + return gobool(c) +} + +// SetOverwrite is a wrapper around gtk_text_view_set_overwrite(). +func (v *TextView) SetOverwrite(overwrite bool) { + C.gtk_text_view_set_overwrite(v.native(), gbool(overwrite)) +} + +// GetOverwrite is a wrapper around gtk_text_view_get_overwrite(). +func (v *TextView) GetOverwrite() bool { + c := C.gtk_text_view_get_overwrite(v.native()) + return gobool(c) +} + +// SetJustification is a wrapper around gtk_text_view_set_justification(). +func (v *TextView) SetJustification(justify Justification) { + C.gtk_text_view_set_justification(v.native(), C.GtkJustification(justify)) +} + +// GetJustification is a wrapper around gtk_text_view_get_justification(). +func (v *TextView) GetJustification() Justification { + c := C.gtk_text_view_get_justification(v.native()) + return Justification(c) +} + +// SetAcceptsTab is a wrapper around gtk_text_view_set_accepts_tab(). +func (v *TextView) SetAcceptsTab(acceptsTab bool) { + C.gtk_text_view_set_accepts_tab(v.native(), gbool(acceptsTab)) +} + +// GetAcceptsTab is a wrapper around gtk_text_view_get_accepts_tab(). +func (v *TextView) GetAcceptsTab() bool { + c := C.gtk_text_view_get_accepts_tab(v.native()) + return gobool(c) +} + +// SetPixelsAboveLines is a wrapper around gtk_text_view_set_pixels_above_lines(). +func (v *TextView) SetPixelsAboveLines(px int) { + C.gtk_text_view_set_pixels_above_lines(v.native(), C.gint(px)) +} + +// GetPixelsAboveLines is a wrapper around gtk_text_view_get_pixels_above_lines(). +func (v *TextView) GetPixelsAboveLines() int { + c := C.gtk_text_view_get_pixels_above_lines(v.native()) + return int(c) +} + +// SetPixelsBelowLines is a wrapper around gtk_text_view_set_pixels_below_lines(). +func (v *TextView) SetPixelsBelowLines(px int) { + C.gtk_text_view_set_pixels_below_lines(v.native(), C.gint(px)) +} + +// GetPixelsBelowLines is a wrapper around gtk_text_view_get_pixels_below_lines(). +func (v *TextView) GetPixelsBelowLines() int { + c := C.gtk_text_view_get_pixels_below_lines(v.native()) + return int(c) +} + +// SetPixelsInsideWrap is a wrapper around gtk_text_view_set_pixels_inside_wrap(). +func (v *TextView) SetPixelsInsideWrap(px int) { + C.gtk_text_view_set_pixels_inside_wrap(v.native(), C.gint(px)) +} + +// GetPixelsInsideWrap is a wrapper around gtk_text_view_get_pixels_inside_wrap(). +func (v *TextView) GetPixelsInsideWrap() int { + c := C.gtk_text_view_get_pixels_inside_wrap(v.native()) + return int(c) +} + +// SetLeftMargin is a wrapper around gtk_text_view_set_left_margin(). +func (v *TextView) SetLeftMargin(margin int) { + C.gtk_text_view_set_left_margin(v.native(), C.gint(margin)) +} + +// GetLeftMargin is a wrapper around gtk_text_view_get_left_margin(). +func (v *TextView) GetLeftMargin() int { + c := C.gtk_text_view_get_left_margin(v.native()) + return int(c) +} + +// SetRightMargin is a wrapper around gtk_text_view_set_right_margin(). +func (v *TextView) SetRightMargin(margin int) { + C.gtk_text_view_set_right_margin(v.native(), C.gint(margin)) +} + +// GetRightMargin is a wrapper around gtk_text_view_get_right_margin(). +func (v *TextView) GetRightMargin() int { + c := C.gtk_text_view_get_right_margin(v.native()) + return int(c) +} + +// SetIndent is a wrapper around gtk_text_view_set_indent(). +func (v *TextView) SetIndent(indent int) { + C.gtk_text_view_set_indent(v.native(), C.gint(indent)) +} + +// GetIndent is a wrapper around gtk_text_view_get_indent(). +func (v *TextView) GetIndent() int { + c := C.gtk_text_view_get_indent(v.native()) + return int(c) +} + +// SetInputHints is a wrapper around gtk_text_view_set_input_hints(). +func (v *TextView) SetInputHints(hints InputHints) { + C.gtk_text_view_set_input_hints(v.native(), C.GtkInputHints(hints)) +} + +// GetInputHints is a wrapper around gtk_text_view_get_input_hints(). +func (v *TextView) GetInputHints() InputHints { + c := C.gtk_text_view_get_input_hints(v.native()) + return InputHints(c) +} + +// SetInputPurpose is a wrapper around gtk_text_view_set_input_purpose(). +func (v *TextView) SetInputPurpose(purpose InputPurpose) { + C.gtk_text_view_set_input_purpose(v.native(), + C.GtkInputPurpose(purpose)) +} + +// GetInputPurpose is a wrapper around gtk_text_view_get_input_purpose(). +func (v *TextView) GetInputPurpose() InputPurpose { + c := C.gtk_text_view_get_input_purpose(v.native()) + return InputPurpose(c) +} + +/* + * GtkTextTag + */ + +type TextTag struct { + *glib.Object +} + +// native returns a pointer to the underlying GObject as a GtkTextTag. +func (v *TextTag) native() *C.GtkTextTag { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTextTag(p) +} + +func marshalTextTag(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTextTag(obj), nil +} + +func wrapTextTag(obj *glib.Object) *TextTag { + return &TextTag{obj} +} + +func TextTagNew(name string) (*TextTag, error) { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + c := C.gtk_text_tag_new((*C.gchar)(cname)) + if c == nil { + return nil, nilPtrErr + } + return wrapTextTag(wrapObject(unsafe.Pointer(c))), nil +} + +// GetPriority() is a wrapper around gtk_text_tag_get_priority(). +func (v *TextTag) GetPriority() int { + return int(C.gtk_text_tag_get_priority(v.native())) +} + +// SetPriority() is a wrapper around gtk_text_tag_set_priority(). +func (v *TextTag) SetPriority(priority int) { + C.gtk_text_tag_set_priority(v.native(), C.gint(priority)) +} + +// Event() is a wrapper around gtk_text_tag_event(). +func (v *TextTag) Event(eventObject *glib.Object, event *gdk.Event, iter *TextIter) bool { + ok := C.gtk_text_tag_event(v.native(), + (*C.GObject)(unsafe.Pointer(eventObject.Native())), + (*C.GdkEvent)(unsafe.Pointer(event.Native())), + (*C.GtkTextIter)(iter), + ) + return gobool(ok) +} + +/* + * GtkTextTagTable + */ + +type TextTagTable struct { + *glib.Object +} + +// native returns a pointer to the underlying GObject as a GtkTextTagTable. +func (v *TextTagTable) native() *C.GtkTextTagTable { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTextTagTable(p) +} + +func marshalTextTagTable(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTextTagTable(obj), nil +} + +func wrapTextTagTable(obj *glib.Object) *TextTagTable { + return &TextTagTable{obj} +} + +func TextTagTableNew() (*TextTagTable, error) { + c := C.gtk_text_tag_table_new() + if c == nil { + return nil, nilPtrErr + } + return wrapTextTagTable(wrapObject(unsafe.Pointer(c))), nil +} + +// Add() is a wrapper around gtk_text_tag_table_add(). +func (v *TextTagTable) Add(tag *TextTag) { + C.gtk_text_tag_table_add(v.native(), tag.native()) + //return gobool(c) // TODO version-separate +} + +// Lookup() is a wrapper around gtk_text_tag_table_lookup(). +func (v *TextTagTable) Lookup(name string) (*TextTag, error) { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + c := C.gtk_text_tag_table_lookup(v.native(), (*C.gchar)(cname)) + if c == nil { + return nil, nilPtrErr + } + return wrapTextTag(wrapObject(unsafe.Pointer(c))), nil +} + +// Remove() is a wrapper around gtk_text_tag_table_remove(). +func (v *TextTagTable) Remove(tag *TextTag) { + C.gtk_text_tag_table_remove(v.native(), tag.native()) +} + +/* + * GtkTextBuffer + */ + +// TextBuffer is a representation of GTK's GtkTextBuffer. +type TextBuffer struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkTextBuffer. +func (v *TextBuffer) native() *C.GtkTextBuffer { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTextBuffer(p) +} + +func marshalTextBuffer(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTextBuffer(obj), nil +} + +func wrapTextBuffer(obj *glib.Object) *TextBuffer { + return &TextBuffer{obj} +} + +// TextBufferNew() is a wrapper around gtk_text_buffer_new(). +func TextBufferNew(table *TextTagTable) (*TextBuffer, error) { + c := C.gtk_text_buffer_new(table.native()) + if c == nil { + return nil, nilPtrErr + } + + e := wrapTextBuffer(wrapObject(unsafe.Pointer(c))) + return e, nil +} + +// ApplyTag() is a wrapper around gtk_text_buffer_apply_tag(). +func (v *TextBuffer) ApplyTag(tag *TextTag, start, end *TextIter) { + C.gtk_text_buffer_apply_tag(v.native(), tag.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) +} + +// ApplyTagByName() is a wrapper around gtk_text_buffer_apply_tag_by_name(). +func (v *TextBuffer) ApplyTagByName(name string, start, end *TextIter) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_text_buffer_apply_tag_by_name(v.native(), (*C.gchar)(cstr), + (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) +} + +// Delete() is a wrapper around gtk_text_buffer_delete(). +func (v *TextBuffer) Delete(start, end *TextIter) { + C.gtk_text_buffer_delete(v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) +} + +func (v *TextBuffer) GetBounds() (start, end *TextIter) { + start, end = new(TextIter), new(TextIter) + C.gtk_text_buffer_get_bounds(v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) + return +} + +// GetCharCount() is a wrapper around gtk_text_buffer_get_char_count(). +func (v *TextBuffer) GetCharCount() int { + return int(C.gtk_text_buffer_get_char_count(v.native())) +} + +// GetIterAtOffset() is a wrapper around gtk_text_buffer_get_iter_at_offset(). +func (v *TextBuffer) GetIterAtOffset(charOffset int) *TextIter { + var iter C.GtkTextIter + C.gtk_text_buffer_get_iter_at_offset(v.native(), &iter, C.gint(charOffset)) + return (*TextIter)(&iter) +} + +// GetStartIter() is a wrapper around gtk_text_buffer_get_start_iter(). +func (v *TextBuffer) GetStartIter() *TextIter { + var iter C.GtkTextIter + C.gtk_text_buffer_get_start_iter(v.native(), &iter) + return (*TextIter)(&iter) +} + +// GetEndIter() is a wrapper around gtk_text_buffer_get_end_iter(). +func (v *TextBuffer) GetEndIter() *TextIter { + var iter C.GtkTextIter + C.gtk_text_buffer_get_end_iter(v.native(), &iter) + return (*TextIter)(&iter) +} + +// GetLineCount() is a wrapper around gtk_text_buffer_get_line_count(). +func (v *TextBuffer) GetLineCount() int { + return int(C.gtk_text_buffer_get_line_count(v.native())) +} + +// GetModified() is a wrapper around gtk_text_buffer_get_modified(). +func (v *TextBuffer) GetModified() bool { + return gobool(C.gtk_text_buffer_get_modified(v.native())) +} + +// GetTagTable() is a wrapper around gtk_text_buffer_get_tag_table(). +func (v *TextBuffer) GetTagTable() (*TextTagTable, error) { + c := C.gtk_text_buffer_get_tag_table(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapTextTagTable(obj), nil +} + +func (v *TextBuffer) GetText(start, end *TextIter, includeHiddenChars bool) (string, error) { + c := C.gtk_text_buffer_get_text( + v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end), gbool(includeHiddenChars), + ) + if c == nil { + return "", nilPtrErr + } + gostr := C.GoString((*C.char)(c)) + C.g_free(C.gpointer(c)) + return gostr, nil +} + +// Insert() is a wrapper around gtk_text_buffer_insert(). +func (v *TextBuffer) Insert(iter *TextIter, text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_text_buffer_insert(v.native(), (*C.GtkTextIter)(iter), (*C.gchar)(cstr), C.gint(len(text))) +} + +// InsertAtCursor() is a wrapper around gtk_text_buffer_insert_at_cursor(). +func (v *TextBuffer) InsertAtCursor(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_text_buffer_insert_at_cursor(v.native(), (*C.gchar)(cstr), C.gint(len(text))) +} + +// RemoveTag() is a wrapper around gtk_text_buffer_remove_tag(). +func (v *TextBuffer) RemoveTag(tag *TextTag, start, end *TextIter) { + C.gtk_text_buffer_remove_tag(v.native(), tag.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) +} + +// SetModified() is a wrapper around gtk_text_buffer_set_modified(). +func (v *TextBuffer) SetModified(setting bool) { + C.gtk_text_buffer_set_modified(v.native(), gbool(setting)) +} + +func (v *TextBuffer) SetText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_text_buffer_set_text(v.native(), (*C.gchar)(cstr), + C.gint(len(text))) +} + +/* + * GtkTextIter + */ + +// TextIter is a representation of GTK's GtkTextIter +type TextIter C.GtkTextIter + +func marshalTextIter(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return (*TextIter)(unsafe.Pointer(c)), nil +} + +/* + * GtkToggleButton + */ + +// ToggleButton is a representation of GTK's GtkToggleButton. +type ToggleButton struct { + Button +} + +// native returns a pointer to the underlying GtkToggleButton. +func (v *ToggleButton) native() *C.GtkToggleButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkToggleButton(p) +} + +func marshalToggleButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapToggleButton(obj), nil +} + +func wrapToggleButton(obj *glib.Object) *ToggleButton { + return &ToggleButton{Button{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// ToggleButtonNew is a wrapper around gtk_toggle_button_new(). +func ToggleButtonNew() (*ToggleButton, error) { + c := C.gtk_toggle_button_new() + if c == nil { + return nil, nilPtrErr + } + return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil +} + +// ToggleButtonNewWithLabel is a wrapper around +// gtk_toggle_button_new_with_label(). +func ToggleButtonNewWithLabel(label string) (*ToggleButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_toggle_button_new_with_label((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil +} + +// ToggleButtonNewWithMnemonic is a wrapper around +// gtk_toggle_button_new_with_mnemonic(). +func ToggleButtonNewWithMnemonic(label string) (*ToggleButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_toggle_button_new_with_mnemonic((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil +} + +// GetActive is a wrapper around gtk_toggle_button_get_active(). +func (v *ToggleButton) GetActive() bool { + c := C.gtk_toggle_button_get_active(v.native()) + return gobool(c) +} + +// SetActive is a wrapper around gtk_toggle_button_set_active(). +func (v *ToggleButton) SetActive(isActive bool) { + C.gtk_toggle_button_set_active(v.native(), gbool(isActive)) +} + +/* + * GtkToolbar + */ + +// Toolbar is a representation of GTK's GtkToolbar. +type Toolbar struct { + Container +} + +// native returns a pointer to the underlying GtkToolbar. +func (v *Toolbar) native() *C.GtkToolbar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkToolbar(p) +} + +func marshalToolbar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapToolbar(obj), nil +} + +func wrapToolbar(obj *glib.Object) *Toolbar { + return &Toolbar{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// ToolbarNew is a wrapper around gtk_toolbar_new(). +func ToolbarNew() (*Toolbar, error) { + c := C.gtk_toolbar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapToolbar(wrapObject(unsafe.Pointer(c))), nil +} + +// Insert is a wrapper around gtk_toolbar_insert(). +func (v *Toolbar) Insert(item IToolItem, pos int) { + C.gtk_toolbar_insert(v.native(), item.toToolItem(), C.gint(pos)) +} + +// GetItemIndex is a wrapper around gtk_toolbar_get_item_index(). +func (v *Toolbar) GetItemIndex(item IToolItem) int { + c := C.gtk_toolbar_get_item_index(v.native(), item.toToolItem()) + return int(c) +} + +// GetNItems is a wrapper around gtk_toolbar_get_n_items(). +func (v *Toolbar) GetNItems() int { + c := C.gtk_toolbar_get_n_items(v.native()) + return int(c) +} + +// GetNthItem is a wrapper around gtk_toolbar_get_nth_item(). +func (v *Toolbar) GetNthItem(n int) *ToolItem { + c := C.gtk_toolbar_get_nth_item(v.native(), C.gint(n)) + if c == nil { + return nil + } + return wrapToolItem(wrapObject(unsafe.Pointer(c))) +} + +// GetDropIndex is a wrapper around gtk_toolbar_get_drop_index(). +func (v *Toolbar) GetDropIndex(x, y int) int { + c := C.gtk_toolbar_get_drop_index(v.native(), C.gint(x), C.gint(y)) + return int(c) +} + +// SetDropHighlightItem is a wrapper around +// gtk_toolbar_set_drop_highlight_item(). +func (v *Toolbar) SetDropHighlightItem(toolItem IToolItem, index int) { + C.gtk_toolbar_set_drop_highlight_item(v.native(), + toolItem.toToolItem(), C.gint(index)) +} + +// SetShowArrow is a wrapper around gtk_toolbar_set_show_arrow(). +func (v *Toolbar) SetShowArrow(showArrow bool) { + C.gtk_toolbar_set_show_arrow(v.native(), gbool(showArrow)) +} + +// UnsetIconSize is a wrapper around gtk_toolbar_unset_icon_size(). +func (v *Toolbar) UnsetIconSize() { + C.gtk_toolbar_unset_icon_size(v.native()) +} + +// GetShowArrow is a wrapper around gtk_toolbar_get_show_arrow(). +func (v *Toolbar) GetShowArrow() bool { + c := C.gtk_toolbar_get_show_arrow(v.native()) + return gobool(c) +} + +// GetStyle is a wrapper around gtk_toolbar_get_style(). +func (v *Toolbar) GetStyle() ToolbarStyle { + c := C.gtk_toolbar_get_style(v.native()) + return ToolbarStyle(c) +} + +// GetIconSize is a wrapper around gtk_toolbar_get_icon_size(). +func (v *Toolbar) GetIconSize() IconSize { + c := C.gtk_toolbar_get_icon_size(v.native()) + return IconSize(c) +} + +// GetReliefStyle is a wrapper around gtk_toolbar_get_relief_style(). +func (v *Toolbar) GetReliefStyle() ReliefStyle { + c := C.gtk_toolbar_get_relief_style(v.native()) + return ReliefStyle(c) +} + +// SetStyle is a wrapper around gtk_toolbar_set_style(). +func (v *Toolbar) SetStyle(style ToolbarStyle) { + C.gtk_toolbar_set_style(v.native(), C.GtkToolbarStyle(style)) +} + +// SetIconSize is a wrapper around gtk_toolbar_set_icon_size(). +func (v *Toolbar) SetIconSize(iconSize IconSize) { + C.gtk_toolbar_set_icon_size(v.native(), C.GtkIconSize(iconSize)) +} + +// UnsetStyle is a wrapper around gtk_toolbar_unset_style(). +func (v *Toolbar) UnsetStyle() { + C.gtk_toolbar_unset_style(v.native()) +} + +/* + * GtkToolButton + */ + +// ToolButton is a representation of GTK's GtkToolButton. +type ToolButton struct { + ToolItem +} + +// native returns a pointer to the underlying GtkToolButton. +func (v *ToolButton) native() *C.GtkToolButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkToolButton(p) +} + +func marshalToolButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapToolButton(obj), nil +} + +func wrapToolButton(obj *glib.Object) *ToolButton { + return &ToolButton{ToolItem{Bin{Container{Widget{ + glib.InitiallyUnowned{obj}}}}}} +} + +// ToolButtonNew is a wrapper around gtk_tool_button_new(). +func ToolButtonNew(iconWidget IWidget, label string) (*ToolButton, error) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + w := nullableWidget(iconWidget) + c := C.gtk_tool_button_new(w, (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + return wrapToolButton(wrapObject(unsafe.Pointer(c))), nil +} + +// SetLabel is a wrapper around gtk_tool_button_set_label(). +func (v *ToolButton) SetLabel(label string) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tool_button_set_label(v.native(), (*C.gchar)(cstr)) +} + +// GetLabel is a wrapper aroud gtk_tool_button_get_label(). +func (v *ToolButton) GetLabel() string { + c := C.gtk_tool_button_get_label(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetUseUnderline is a wrapper around gtk_tool_button_set_use_underline(). +func (v *ToolButton) SetGetUnderline(useUnderline bool) { + C.gtk_tool_button_set_use_underline(v.native(), gbool(useUnderline)) +} + +// GetUseUnderline is a wrapper around gtk_tool_button_get_use_underline(). +func (v *ToolButton) GetuseUnderline() bool { + c := C.gtk_tool_button_get_use_underline(v.native()) + return gobool(c) +} + +// SetIconName is a wrapper around gtk_tool_button_set_icon_name(). +func (v *ToolButton) SetIconName(iconName string) { + cstr := C.CString(iconName) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tool_button_set_icon_name(v.native(), (*C.gchar)(cstr)) +} + +// GetIconName is a wrapper around gtk_tool_button_get_icon_name(). +func (v *ToolButton) GetIconName() string { + c := C.gtk_tool_button_get_icon_name(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetIconWidget is a wrapper around gtk_tool_button_set_icon_widget(). +func (v *ToolButton) SetIconWidget(iconWidget IWidget) { + C.gtk_tool_button_set_icon_widget(v.native(), iconWidget.toWidget()) +} + +// GetIconWidget is a wrapper around gtk_tool_button_get_icon_widget(). +func (v *ToolButton) GetIconWidget() *Widget { + c := C.gtk_tool_button_get_icon_widget(v.native()) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} + +// SetLabelWidget is a wrapper around gtk_tool_button_set_label_widget(). +func (v *ToolButton) SetLabelWidget(labelWidget IWidget) { + C.gtk_tool_button_set_label_widget(v.native(), labelWidget.toWidget()) +} + +// GetLabelWidget is a wrapper around gtk_tool_button_get_label_widget(). +func (v *ToolButton) GetLabelWidget() *Widget { + c := C.gtk_tool_button_get_label_widget(v.native()) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} + +/* + * GtkToolItem + */ + +// ToolItem is a representation of GTK's GtkToolItem. +type ToolItem struct { + Bin +} + +// IToolItem is an interface type implemented by all structs embedding +// a ToolItem. It is meant to be used as an argument type for wrapper +// functions that wrap around a C GTK function taking a GtkToolItem. +type IToolItem interface { + toToolItem() *C.GtkToolItem +} + +// native returns a pointer to the underlying GtkToolItem. +func (v *ToolItem) native() *C.GtkToolItem { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkToolItem(p) +} + +func (v *ToolItem) toToolItem() *C.GtkToolItem { + return v.native() +} + +func marshalToolItem(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapToolItem(obj), nil +} + +func wrapToolItem(obj *glib.Object) *ToolItem { + return &ToolItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// ToolItemNew is a wrapper around gtk_tool_item_new(). +func ToolItemNew() (*ToolItem, error) { + c := C.gtk_tool_item_new() + if c == nil { + return nil, nilPtrErr + } + return wrapToolItem(wrapObject(unsafe.Pointer(c))), nil +} + +// SetHomogeneous is a wrapper around gtk_tool_item_set_homogeneous(). +func (v *ToolItem) SetHomogeneous(homogeneous bool) { + C.gtk_tool_item_set_homogeneous(v.native(), gbool(homogeneous)) +} + +// GetHomogeneous is a wrapper around gtk_tool_item_get_homogeneous(). +func (v *ToolItem) GetHomogeneous() bool { + c := C.gtk_tool_item_get_homogeneous(v.native()) + return gobool(c) +} + +// SetExpand is a wrapper around gtk_tool_item_set_expand(). +func (v *ToolItem) SetExpand(expand bool) { + C.gtk_tool_item_set_expand(v.native(), gbool(expand)) +} + +// GetExpand is a wrapper around gtk_tool_item_get_expand(). +func (v *ToolItem) GetExpand() bool { + c := C.gtk_tool_item_get_expand(v.native()) + return gobool(c) +} + +// SetTooltipText is a wrapper around gtk_tool_item_set_tooltip_text(). +func (v *ToolItem) SetTooltipText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tool_item_set_tooltip_text(v.native(), (*C.gchar)(cstr)) +} + +// SetTooltipMarkup is a wrapper around gtk_tool_item_set_tooltip_markup(). +func (v *ToolItem) SetTooltipMarkup(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tool_item_set_tooltip_markup(v.native(), (*C.gchar)(cstr)) +} + +// SetUseDragWindow is a wrapper around gtk_tool_item_set_use_drag_window(). +func (v *ToolItem) SetUseDragWindow(useDragWindow bool) { + C.gtk_tool_item_set_use_drag_window(v.native(), gbool(useDragWindow)) +} + +// GetUseDragWindow is a wrapper around gtk_tool_item_get_use_drag_window(). +func (v *ToolItem) GetUseDragWindow() bool { + c := C.gtk_tool_item_get_use_drag_window(v.native()) + return gobool(c) +} + +// SetVisibleHorizontal is a wrapper around +// gtk_tool_item_set_visible_horizontal(). +func (v *ToolItem) SetVisibleHorizontal(visibleHorizontal bool) { + C.gtk_tool_item_set_visible_horizontal(v.native(), + gbool(visibleHorizontal)) +} + +// GetVisibleHorizontal is a wrapper around +// gtk_tool_item_get_visible_horizontal(). +func (v *ToolItem) GetVisibleHorizontal() bool { + c := C.gtk_tool_item_get_visible_horizontal(v.native()) + return gobool(c) +} + +// SetVisibleVertical is a wrapper around gtk_tool_item_set_visible_vertical(). +func (v *ToolItem) SetVisibleVertical(visibleVertical bool) { + C.gtk_tool_item_set_visible_vertical(v.native(), gbool(visibleVertical)) +} + +// GetVisibleVertical is a wrapper around gtk_tool_item_get_visible_vertical(). +func (v *ToolItem) GetVisibleVertical() bool { + c := C.gtk_tool_item_get_visible_vertical(v.native()) + return gobool(c) +} + +// SetIsImportant is a wrapper around gtk_tool_item_set_is_important(). +func (v *ToolItem) SetIsImportant(isImportant bool) { + C.gtk_tool_item_set_is_important(v.native(), gbool(isImportant)) +} + +// GetIsImportant is a wrapper around gtk_tool_item_get_is_important(). +func (v *ToolItem) GetIsImportant() bool { + c := C.gtk_tool_item_get_is_important(v.native()) + return gobool(c) +} + +// TODO: gtk_tool_item_get_ellipsize_mode + +// GetIconSize is a wrapper around gtk_tool_item_get_icon_size(). +func (v *ToolItem) GetIconSize() IconSize { + c := C.gtk_tool_item_get_icon_size(v.native()) + return IconSize(c) +} + +// GetOrientation is a wrapper around gtk_tool_item_get_orientation(). +func (v *ToolItem) GetOrientation() Orientation { + c := C.gtk_tool_item_get_orientation(v.native()) + return Orientation(c) +} + +// GetToolbarStyle is a wrapper around gtk_tool_item_get_toolbar_style(). +func (v *ToolItem) gtk_tool_item_get_toolbar_style() ToolbarStyle { + c := C.gtk_tool_item_get_toolbar_style(v.native()) + return ToolbarStyle(c) +} + +// GetReliefStyle is a wrapper around gtk_tool_item_get_relief_style(). +func (v *ToolItem) GetReliefStyle() ReliefStyle { + c := C.gtk_tool_item_get_relief_style(v.native()) + return ReliefStyle(c) +} + +// GetTextAlignment is a wrapper around gtk_tool_item_get_text_alignment(). +func (v *ToolItem) GetTextAlignment() float32 { + c := C.gtk_tool_item_get_text_alignment(v.native()) + return float32(c) +} + +// GetTextOrientation is a wrapper around gtk_tool_item_get_text_orientation(). +func (v *ToolItem) GetTextOrientation() Orientation { + c := C.gtk_tool_item_get_text_orientation(v.native()) + return Orientation(c) +} + +// RetrieveProxyMenuItem is a wrapper around +// gtk_tool_item_retrieve_proxy_menu_item() +func (v *ToolItem) RetrieveProxyMenuItem() *MenuItem { + c := C.gtk_tool_item_retrieve_proxy_menu_item(v.native()) + if c == nil { + return nil + } + return wrapMenuItem(wrapObject(unsafe.Pointer(c))) +} + +// SetProxyMenuItem is a wrapper around gtk_tool_item_set_proxy_menu_item(). +func (v *ToolItem) SetProxyMenuItem(menuItemId string, menuItem IMenuItem) { + cstr := C.CString(menuItemId) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tool_item_set_proxy_menu_item(v.native(), (*C.gchar)(cstr), + C.toGtkWidget(unsafe.Pointer(menuItem.toMenuItem()))) +} + +// RebuildMenu is a wrapper around gtk_tool_item_rebuild_menu(). +func (v *ToolItem) RebuildMenu() { + C.gtk_tool_item_rebuild_menu(v.native()) +} + +// ToolbarReconfigured is a wrapper around gtk_tool_item_toolbar_reconfigured(). +func (v *ToolItem) ToolbarReconfigured() { + C.gtk_tool_item_toolbar_reconfigured(v.native()) +} + +// TODO: gtk_tool_item_get_text_size_group + +/* + * GtkTreeIter + */ + +// TreeIter is a representation of GTK's GtkTreeIter. +type TreeIter struct { + GtkTreeIter C.GtkTreeIter +} + +// native returns a pointer to the underlying GtkTreeIter. +func (v *TreeIter) native() *C.GtkTreeIter { + if v == nil { + return nil + } + return &v.GtkTreeIter +} + +func marshalTreeIter(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return (*TreeIter)(unsafe.Pointer(c)), nil +} + +func (v *TreeIter) free() { + C.gtk_tree_iter_free(v.native()) +} + +// Copy() is a wrapper around gtk_tree_iter_copy(). +func (v *TreeIter) Copy() (*TreeIter, error) { + c := C.gtk_tree_iter_copy(v.native()) + if c == nil { + return nil, nilPtrErr + } + t := &TreeIter{*c} + runtime.SetFinalizer(t, (*TreeIter).free) + return t, nil +} + +/* + * GtkTreeModel + */ + +// TreeModel is a representation of GTK's GtkTreeModel GInterface. +type TreeModel struct { + *glib.Object +} + +// ITreeModel is an interface type implemented by all structs +// embedding a TreeModel. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkTreeModel. +type ITreeModel interface { + toTreeModel() *C.GtkTreeModel +} + +// native returns a pointer to the underlying GObject as a GtkTreeModel. +func (v *TreeModel) native() *C.GtkTreeModel { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTreeModel(p) +} + +func (v *TreeModel) toTreeModel() *C.GtkTreeModel { + if v == nil { + return nil + } + return v.native() +} + +func marshalTreeModel(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTreeModel(obj), nil +} + +func wrapTreeModel(obj *glib.Object) *TreeModel { + return &TreeModel{obj} +} + +// GetFlags() is a wrapper around gtk_tree_model_get_flags(). +func (v *TreeModel) GetFlags() TreeModelFlags { + c := C.gtk_tree_model_get_flags(v.native()) + return TreeModelFlags(c) +} + +// GetNColumns() is a wrapper around gtk_tree_model_get_n_columns(). +func (v *TreeModel) GetNColumns() int { + c := C.gtk_tree_model_get_n_columns(v.native()) + return int(c) +} + +// GetColumnType() is a wrapper around gtk_tree_model_get_column_type(). +func (v *TreeModel) GetColumnType(index int) glib.Type { + c := C.gtk_tree_model_get_column_type(v.native(), C.gint(index)) + return glib.Type(c) +} + +// GetIter() is a wrapper around gtk_tree_model_get_iter(). +func (v *TreeModel) GetIter(path *TreePath) (*TreeIter, error) { + var iter C.GtkTreeIter + c := C.gtk_tree_model_get_iter(v.native(), &iter, path.native()) + if !gobool(c) { + return nil, errors.New("Unable to set iterator") + } + t := &TreeIter{iter} + return t, nil +} + +// GetIterFromString() is a wrapper around +// gtk_tree_model_get_iter_from_string(). +func (v *TreeModel) GetIterFromString(path string) (*TreeIter, error) { + var iter C.GtkTreeIter + cstr := C.CString(path) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_tree_model_get_iter_from_string(v.native(), &iter, + (*C.gchar)(cstr)) + if !gobool(c) { + return nil, errors.New("Unable to set iterator") + } + t := &TreeIter{iter} + return t, nil +} + +// GetIterFirst() is a wrapper around gtk_tree_model_get_iter_first(). +func (v *TreeModel) GetIterFirst() (*TreeIter, bool) { + var iter C.GtkTreeIter + c := C.gtk_tree_model_get_iter_first(v.native(), &iter) + if !gobool(c) { + return nil, false + } + t := &TreeIter{iter} + return t, true +} + +// GetPath() is a wrapper around gtk_tree_model_get_path(). +func (v *TreeModel) GetPath(iter *TreeIter) (*TreePath, error) { + c := C.gtk_tree_model_get_path(v.native(), iter.native()) + if c == nil { + return nil, nilPtrErr + } + p := &TreePath{c} + runtime.SetFinalizer(p, (*TreePath).free) + return p, nil +} + +// GetValue() is a wrapper around gtk_tree_model_get_value(). +func (v *TreeModel) GetValue(iter *TreeIter, column int) (*glib.Value, error) { + val, err := glib.ValueAlloc() + if err != nil { + return nil, err + } + C.gtk_tree_model_get_value( + (*C.GtkTreeModel)(unsafe.Pointer(v.native())), + iter.native(), + C.gint(column), + (*C.GValue)(unsafe.Pointer(val.Native()))) + return val, nil +} + +// IterNext() is a wrapper around gtk_tree_model_iter_next(). +func (v *TreeModel) IterNext(iter *TreeIter) bool { + c := C.gtk_tree_model_iter_next(v.native(), iter.native()) + return gobool(c) +} + +// IterPrevious is a wrapper around gtk_tree_model_iter_previous(). +func (v *TreeModel) IterPrevious(iter *TreeIter) bool { + c := C.gtk_tree_model_iter_previous(v.native(), iter.native()) + return gobool(c) +} + +// IterChildren is a wrapper around gtk_tree_model_iter_children(). +func (v *TreeModel) IterChildren(iter, child *TreeIter) bool { + var cIter, cChild *C.GtkTreeIter + if iter != nil { + cIter = iter.native() + } + cChild = child.native() + c := C.gtk_tree_model_iter_children(v.native(), cChild, cIter) + return gobool(c) +} + +// IterNChildren is a wrapper around gtk_tree_model_iter_n_children(). +func (v *TreeModel) IterNChildren(iter *TreeIter) int { + var cIter *C.GtkTreeIter + if iter != nil { + cIter = iter.native() + } + c := C.gtk_tree_model_iter_n_children(v.native(), cIter) + return int(c) +} + +/* + * GtkTreePath + */ + +// TreePath is a representation of GTK's GtkTreePath. +type TreePath struct { + GtkTreePath *C.GtkTreePath +} + +// Return a TreePath from the GList +func TreePathFromList(list *glib.List) *TreePath { + if list == nil { + return nil + } + return &TreePath{(*C.GtkTreePath)(list.Data().(unsafe.Pointer))} +} + +// native returns a pointer to the underlying GtkTreePath. +func (v *TreePath) native() *C.GtkTreePath { + if v == nil { + return nil + } + return v.GtkTreePath +} + +func marshalTreePath(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return &TreePath{(*C.GtkTreePath)(unsafe.Pointer(c))}, nil +} + +func (v *TreePath) free() { + C.gtk_tree_path_free(v.native()) +} + +// String is a wrapper around gtk_tree_path_to_string(). +func (v *TreePath) String() string { + c := C.gtk_tree_path_to_string(v.native()) + return C.GoString((*C.char)(c)) +} + +// TreePathNewFromString is a wrapper around gtk_tree_path_new_from_string(). +func TreePathNewFromString(path string) (*TreePath, error) { + cstr := C.CString(path) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_tree_path_new_from_string((*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + t := &TreePath{c} + runtime.SetFinalizer(t, (*TreePath).free) + return t, nil +} + +/* + * GtkTreeSelection + */ + +// TreeSelection is a representation of GTK's GtkTreeSelection. +type TreeSelection struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkTreeSelection. +func (v *TreeSelection) native() *C.GtkTreeSelection { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTreeSelection(p) +} + +func marshalTreeSelection(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTreeSelection(obj), nil +} + +func wrapTreeSelection(obj *glib.Object) *TreeSelection { + return &TreeSelection{obj} +} + +// GetSelected() is a wrapper around gtk_tree_selection_get_selected(). +func (v *TreeSelection) GetSelected() (model ITreeModel, iter *TreeIter, ok bool) { + var cmodel *C.GtkTreeModel + var citer C.GtkTreeIter + c := C.gtk_tree_selection_get_selected(v.native(), + &cmodel, &citer) + model = wrapTreeModel(wrapObject(unsafe.Pointer(cmodel))) + iter = &TreeIter{citer} + ok = gobool(c) + return +} + +// SelectPath is a wrapper around gtk_tree_selection_select_path(). +func (v *TreeSelection) SelectPath(path *TreePath) { + C.gtk_tree_selection_select_path(v.native(), path.native()) +} + +// UnselectPath is a wrapper around gtk_tree_selection_unselect_path(). +func (v *TreeSelection) UnselectPath(path *TreePath) { + C.gtk_tree_selection_unselect_path(v.native(), path.native()) +} + +// GetSelectedRows is a wrapper around gtk_tree_selection_get_selected_rows(). +// All the elements of returned list are wrapped into (*gtk.TreePath) values. +// +// Please note that a runtime finalizer is only set on the head of the linked +// list, and must be kept live while accessing any item in the list, or the +// Go garbage collector will free the whole list. +func (v *TreeSelection) GetSelectedRows(model ITreeModel) *glib.List { + var pcmodel **C.GtkTreeModel + if model != nil { + cmodel := model.toTreeModel() + pcmodel = &cmodel + } + + clist := C.gtk_tree_selection_get_selected_rows(v.native(), pcmodel) + if clist == nil { + return nil + } + + glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) + glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { + return &TreePath{(*C.GtkTreePath)(ptr)} + }) + runtime.SetFinalizer(glist, func(glist *glib.List) { + glist.FreeFull(func(item interface{}) { + path := item.(TreePath) + C.gtk_tree_path_free(path.GtkTreePath) + }) + }) + + return glist +} + +// CountSelectedRows() is a wrapper around gtk_tree_selection_count_selected_rows(). +func (v *TreeSelection) CountSelectedRows() int { + return int(C.gtk_tree_selection_count_selected_rows(v.native())) +} + +// SelectIter is a wrapper around gtk_tree_selection_select_iter(). +func (v *TreeSelection) SelectIter(iter *TreeIter) { + C.gtk_tree_selection_select_iter(v.native(), iter.native()) +} + +// SetMode() is a wrapper around gtk_tree_selection_set_mode(). +func (v *TreeSelection) SetMode(m SelectionMode) { + C.gtk_tree_selection_set_mode(v.native(), C.GtkSelectionMode(m)) +} + +// GetMode() is a wrapper around gtk_tree_selection_get_mode(). +func (v *TreeSelection) GetMode() SelectionMode { + return SelectionMode(C.gtk_tree_selection_get_mode(v.native())) +} + +/* + * GtkTreeStore + */ + +// TreeStore is a representation of GTK's GtkTreeStore. +type TreeStore struct { + *glib.Object + + // Interfaces + TreeModel +} + +// native returns a pointer to the underlying GtkTreeStore. +func (v *TreeStore) native() *C.GtkTreeStore { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTreeStore(p) +} + +func marshalTreeStore(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTreeStore(obj), nil +} + +func wrapTreeStore(obj *glib.Object) *TreeStore { + tm := wrapTreeModel(obj) + return &TreeStore{obj, *tm} +} + +func (v *TreeStore) toTreeModel() *C.GtkTreeModel { + if v == nil { + return nil + } + return C.toGtkTreeModel(unsafe.Pointer(v.GObject)) +} + +// TreeStoreNew is a wrapper around gtk_tree_store_newv(). +func TreeStoreNew(types ...glib.Type) (*TreeStore, error) { + gtypes := C.alloc_types(C.int(len(types))) + for n, val := range types { + C.set_type(gtypes, C.int(n), C.GType(val)) + } + defer C.g_free(C.gpointer(gtypes)) + c := C.gtk_tree_store_newv(C.gint(len(types)), gtypes) + if c == nil { + return nil, nilPtrErr + } + + ts := wrapTreeStore(wrapObject(unsafe.Pointer(c))) + return ts, nil +} + +// Append is a wrapper around gtk_tree_store_append(). +func (v *TreeStore) Append(parent *TreeIter) *TreeIter { + var ti C.GtkTreeIter + var cParent *C.GtkTreeIter + if parent != nil { + cParent = parent.native() + } + C.gtk_tree_store_append(v.native(), &ti, cParent) + iter := &TreeIter{ti} + return iter +} + +// Insert is a wrapper around gtk_tree_store_insert +func (v *TreeStore) Insert(parent *TreeIter, position int) *TreeIter { + var ti C.GtkTreeIter + var cParent *C.GtkTreeIter + if parent != nil { + cParent = parent.native() + } + C.gtk_tree_store_insert(v.native(), &ti, cParent, C.gint(position)) + iter := &TreeIter{ti} + return iter +} + +// SetValue is a wrapper around gtk_tree_store_set_value() +func (v *TreeStore) SetValue(iter *TreeIter, column int, value interface{}) error { + switch value.(type) { + case *gdk.Pixbuf: + pix := value.(*gdk.Pixbuf) + C._gtk_tree_store_set(v.native(), iter.native(), C.gint(column), unsafe.Pointer(pix.Native())) + + default: + gv, err := glib.GValue(value) + if err != nil { + return err + } + C.gtk_tree_store_set_value(v.native(), iter.native(), + C.gint(column), + (*C.GValue)(C.gpointer(gv.Native()))) + } + return nil +} + +// Remove is a wrapper around gtk_tree_store_remove(). +func (v *TreeStore) Remove(iter *TreeIter) bool { + var ti *C.GtkTreeIter + if iter != nil { + ti = iter.native() + } + return 0 != C.gtk_tree_store_remove(v.native(), ti) +} + +// Clear is a wrapper around gtk_tree_store_clear(). +func (v *TreeStore) Clear() { + C.gtk_tree_store_clear(v.native()) +} + +/* + * GtkViewport + */ + +// Viewport is a representation of GTK's GtkViewport GInterface. +type Viewport struct { + Bin + + // Interfaces + Scrollable +} + +// IViewport is an interface type implemented by all structs +// embedding a Viewport. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkViewport. +type IViewport interface { + toViewport() *C.GtkViewport +} + +// native() returns a pointer to the underlying GObject as a GtkViewport. +func (v *Viewport) native() *C.GtkViewport { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkViewport(p) +} + +func wrapViewport(obj *glib.Object) *Viewport { + b := wrapBin(obj) + s := wrapScrollable(obj) + return &Viewport{ + Bin: *b, + Scrollable: *s, + } +} + +func (v *Viewport) toViewport() *C.GtkViewport { + if v == nil { + return nil + } + return v.native() +} + +// ViewportNew() is a wrapper around gtk_viewport_new(). +func ViewportNew(hadjustment, vadjustment *Adjustment) (*Viewport, error) { + c := C.gtk_viewport_new(hadjustment.native(), vadjustment.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapViewport(wrapObject(unsafe.Pointer(c))), nil +} + +func (v *Viewport) SetHAdjustment(adjustment *Adjustment) { + wrapScrollable(v.Object).SetHAdjustment(adjustment) +} + +func (v *Viewport) GetHAdjustment() (*Adjustment, error) { + return wrapScrollable(v.Object).GetHAdjustment() +} + +func (v *Viewport) SetVAdjustment(adjustment *Adjustment) { + wrapScrollable(v.Object).SetVAdjustment(adjustment) +} + +func (v *Viewport) GetVAdjustment() (*Adjustment, error) { + return wrapScrollable(v.Object).GetVAdjustment() +} + +/* + * GtkVolumeButton + */ + +// VolumeButton is a representation of GTK's GtkVolumeButton. +type VolumeButton struct { + ScaleButton +} + +// native() returns a pointer to the underlying GtkVolumeButton. +func (v *VolumeButton) native() *C.GtkVolumeButton { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkVolumeButton(p) +} + +func marshalVolumeButton(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapVolumeButton(obj), nil +} + +func wrapVolumeButton(obj *glib.Object) *VolumeButton { + return &VolumeButton{ScaleButton{Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} +} + +// VolumeButtonNew() is a wrapper around gtk_button_new(). +func VolumeButtonNew() (*VolumeButton, error) { + c := C.gtk_volume_button_new() + if c == nil { + return nil, nilPtrErr + } + return wrapVolumeButton(wrapObject(unsafe.Pointer(c))), nil +} + +type WrapFn interface{} + +var WrapMap = map[string]WrapFn{ + "GtkAccelGroup": wrapAccelGroup, + "GtkAccelMao": wrapAccelMap, + "GtkAdjustment": wrapAdjustment, + "GtkApplicationWindow": wrapApplicationWindow, + "GtkAssistant": wrapAssistant, + "GtkBin": wrapBin, + "GtkBox": wrapBox, + "GtkButton": wrapButton, + "GtkCalendar": wrapCalendar, + "GtkCellLayout": wrapCellLayout, + "GtkCellRenderer": wrapCellRenderer, + "GtkCellRendererSpinner": wrapCellRendererSpinner, + "GtkCellRendererPixbuf": wrapCellRendererPixbuf, + "GtkCellRendererText": wrapCellRendererText, + "GtkCellRendererToggle": wrapCellRendererToggle, + "GtkCheckButton": wrapCheckButton, + "GtkCheckMenuItem": wrapCheckMenuItem, + "GtkClipboard": wrapClipboard, + "GtkContainer": wrapContainer, + "GtkDialog": wrapDialog, + "GtkDrawingArea": wrapDrawingArea, + "GtkEditable": wrapEditable, + "GtkEntry": wrapEntry, + "GtkEntryBuffer": wrapEntryBuffer, + "GtkEntryCompletion": wrapEntryCompletion, + "GtkEventBox": wrapEventBox, + "GtkExpander": wrapExpander, + "GtkFrame": wrapFrame, + "GtkFileChooser": wrapFileChooser, + "GtkFileChooserButton": wrapFileChooserButton, + "GtkFileChooserDialog": wrapFileChooserDialog, + "GtkFileChooserWidget": wrapFileChooserWidget, + "GtkFontButton": wrapFontButton, + "GtkGrid": wrapGrid, + "GtkIconView": wrapIconView, + "GtkImage": wrapImage, + "GtkLabel": wrapLabel, + "GtkLayout": wrapLayout, + "GtkLinkButton": wrapLinkButton, + "GtkListStore": wrapListStore, + "GtkMenu": wrapMenu, + "GtkMenuBar": wrapMenuBar, + "GtkMenuButton": wrapMenuButton, + "GtkMenuItem": wrapMenuItem, + "GtkMenuShell": wrapMenuShell, + "GtkMessageDialog": wrapMessageDialog, + "GtkNotebook": wrapNotebook, + "GtkOffscreenWindow": wrapOffscreenWindow, + "GtkOrientable": wrapOrientable, + "GtkPaned": wrapPaned, + "GtkProgressBar": wrapProgressBar, + "GtkRadioButton": wrapRadioButton, + "GtkRadioMenuItem": wrapRadioMenuItem, + "GtkRange": wrapRange, + "GtkRecentChooser": wrapRecentChooser, + "GtkRecentChooserMenu": wrapRecentChooserMenu, + "GtkRecentFilter": wrapRecentFilter, + "GtkRecentManager": wrapRecentManager, + "GtkScaleButton": wrapScaleButton, + "GtkScale": wrapScale, + "GtkScrollable": wrapScrollable, + "GtkScrollbar": wrapScrollbar, + "GtkScrolledWindow": wrapScrolledWindow, + "GtkSearchEntry": wrapSearchEntry, + "GtkSeparator": wrapSeparator, + "GtkSeparatorMenuItem": wrapSeparatorMenuItem, + "GtkSeparatorToolItem": wrapSeparatorToolItem, + "GtkSpinButton": wrapSpinButton, + "GtkSpinner": wrapSpinner, + "GtkStatusbar": wrapStatusbar, + "GtkSwitch": wrapSwitch, + "GtkTextView": wrapTextView, + "GtkTextBuffer": wrapTextBuffer, + "GtkTextTag": wrapTextTag, + "GtkTextTagTable": wrapTextTagTable, + "GtkToggleButton": wrapToggleButton, + "GtkToolbar": wrapToolbar, + "GtkToolButton": wrapToolButton, + "GtkToolItem": wrapToolItem, + "GtkTreeModel": wrapTreeModel, + "GtkTreeSelection": wrapTreeSelection, + "GtkTreeStore": wrapTreeStore, + "GtkTreeView": wrapTreeView, + "GtkTreeViewColumn": wrapTreeViewColumn, + "GtkViewport": wrapViewport, + "GtkVolumeButton": wrapVolumeButton, + "GtkWidget": wrapWidget, + "GtkWindow": wrapWindow, +} + +// cast takes a native GObject and casts it to the appropriate Go struct. +//TODO change all wrapFns to return an IObject +func cast(c *C.GObject) (glib.IObject, error) { + var ( + className = C.GoString((*C.char)(C.object_get_class_name(c))) + obj = wrapObject(unsafe.Pointer(c)) + ) + + fn, ok := WrapMap[className] + if !ok { + return nil, errors.New("unrecognized class name '" + className + "'") + } + + rf := reflect.ValueOf(fn) + if rf.Type().Kind() != reflect.Func { + return nil, errors.New("wraper is not a function") + } + + v := reflect.ValueOf(obj) + rv := rf.Call([]reflect.Value{v}) + + if len(rv) != 1 { + return nil, errors.New("wrapper did not return") + } + + if k := rv[0].Kind(); k != reflect.Ptr { + return nil, fmt.Errorf("wrong return type %s", k) + } + + ret, ok := rv[0].Interface().(glib.IObject) + if !ok { + return nil, errors.New("did not return an IObject") + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go.h new file mode 100644 index 0000000..25876f0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk.go.h @@ -0,0 +1,813 @@ +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * This file originated from: http://opensource.conformal.com/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef __GTK_GO_H__ +#define __GTK_GO_H__ + +#include +#include +#include + +static GtkAboutDialog * +toGtkAboutDialog(void *p) +{ + return (GTK_ABOUT_DIALOG(p)); +} + +static GtkAppChooser * +toGtkAppChooser(void *p) +{ + return (GTK_APP_CHOOSER(p)); +} + +static GtkAppChooserButton * +toGtkAppChooserButton(void *p) +{ + return (GTK_APP_CHOOSER_BUTTON(p)); +} + +static GtkAppChooserDialog * +toGtkAppChooserDialog(void *p) +{ + return (GTK_APP_CHOOSER_DIALOG(p)); +} + +static GtkAppChooserWidget * +toGtkAppChooserWidget(void *p) +{ + return (GTK_APP_CHOOSER_WIDGET(p)); +} + +static GtkApplication * +toGtkApplication(void *p) +{ + return (GTK_APPLICATION(p)); +} + +static GtkApplicationWindow * +toGtkApplicationWindow(void *p) +{ + return (GTK_APPLICATION_WINDOW(p)); +} + +static GtkAssistant * +toGtkAssistant(void *p) +{ + return (GTK_ASSISTANT(p)); +} + +static GtkCalendar * +toGtkCalendar(void *p) +{ + return (GTK_CALENDAR(p)); +} + +static GtkColorChooserDialog * +toGtkColorChooserDialog(void *p) +{ + return (GTK_COLOR_CHOOSER_DIALOG(p)); +} + +static GtkDrawingArea * +toGtkDrawingArea(void *p) +{ + return (GTK_DRAWING_AREA(p)); +} + +static GtkCellRendererSpinner * +toGtkCellRendererSpinner(void *p) +{ + return (GTK_CELL_RENDERER_SPINNER(p)); +} + +static GtkEventBox * +toGtkEventBox(void *p) +{ + return (GTK_EVENT_BOX(p)); +} + +static GtkGrid * +toGtkGrid(void *p) +{ + return (GTK_GRID(p)); +} + +static GtkWidget * +toGtkWidget(void *p) +{ + return (GTK_WIDGET(p)); +} + +static GtkContainer * +toGtkContainer(void *p) +{ + return (GTK_CONTAINER(p)); +} + +static GtkPaned * +toGtkPaned(void *p) +{ + return (GTK_PANED(p)); +} + +static GtkProgressBar * +toGtkProgressBar(void *p) +{ + return (GTK_PROGRESS_BAR(p)); +} + +static GtkLevelBar * +toGtkLevelBar(void *p) +{ + return (GTK_LEVEL_BAR(p)); +} + +static GtkBin * +toGtkBin(void *p) +{ + return (GTK_BIN(p)); +} + +static GtkWindow * +toGtkWindow(void *p) +{ + return (GTK_WINDOW(p)); +} + +static GtkBox * +toGtkBox(void *p) +{ + return (GTK_BOX(p)); +} + +static GtkStatusbar * +toGtkStatusbar(void *p) +{ + return (GTK_STATUSBAR(p)); +} + +static GtkLabel * +toGtkLabel(void *p) +{ + return (GTK_LABEL(p)); +} + +static GtkNotebook * +toGtkNotebook(void *p) +{ + return (GTK_NOTEBOOK(p)); +} + +static GtkEntry * +toGtkEntry(void *p) +{ + return (GTK_ENTRY(p)); +} + +static GtkEntryBuffer * +toGtkEntryBuffer(void *p) +{ + return (GTK_ENTRY_BUFFER(p)); +} + +static GtkEntryCompletion * +toGtkEntryCompletion(void *p) +{ + return (GTK_ENTRY_COMPLETION(p)); +} + +static GtkAdjustment * +toGtkAdjustment(void *p) +{ + return (GTK_ADJUSTMENT(p)); +} + +static GtkAccelGroup * +toGtkAccelGroup(void *p) +{ + return (GTK_ACCEL_GROUP(p)); +} + +static GtkAccelMap * +toGtkAccelMap(void *p) +{ + return (GTK_ACCEL_MAP(p)); +} + +static GtkTextTag * +toGtkTextTag(void *p) +{ + return (GTK_TEXT_TAG(p)); +} + +static GtkIconView * +toGtkIconView(void *p) +{ + return (GTK_ICON_VIEW(p)); +} + +static GtkImage * +toGtkImage(void *p) +{ + return (GTK_IMAGE(p)); +} + +static GtkButton * +toGtkButton(void *p) +{ + return (GTK_BUTTON(p)); +} + +static GtkScaleButton * +toGtkScaleButton(void *p) +{ + return (GTK_SCALE_BUTTON(p)); +} + +static GtkColorButton * +toGtkColorButton(void *p) +{ + return (GTK_COLOR_BUTTON(p)); +} + +static GtkViewport * +toGtkViewport(void *p) +{ + return (GTK_VIEWPORT(p)); +} + +static GtkVolumeButton * +toGtkVolumeButton(void *p) +{ + return (GTK_VOLUME_BUTTON(p)); +} + +static GtkScrollable * +toGtkScrollable(void *p) +{ + return (GTK_SCROLLABLE(p)); +} + +static GtkScrolledWindow * +toGtkScrolledWindow(void *p) +{ + return (GTK_SCROLLED_WINDOW(p)); +} + +static GtkMenuItem * +toGtkMenuItem(void *p) +{ + return (GTK_MENU_ITEM(p)); +} + +static GtkMenu * +toGtkMenu(void *p) +{ + return (GTK_MENU(p)); +} + +static GtkMenuShell * +toGtkMenuShell(void *p) +{ + return (GTK_MENU_SHELL(p)); +} + +static GtkMenuBar * +toGtkMenuBar(void *p) +{ + return (GTK_MENU_BAR(p)); +} + +static GtkSizeGroup * +toGtkSizeGroup(void *p) +{ + return (GTK_SIZE_GROUP(p)); +} + +static GtkSpinButton * +toGtkSpinButton(void *p) +{ + return (GTK_SPIN_BUTTON(p)); +} + +static GtkSpinner * +toGtkSpinner(void *p) +{ + return (GTK_SPINNER(p)); +} + +static GtkComboBox * +toGtkComboBox(void *p) +{ + return (GTK_COMBO_BOX(p)); +} + +static GtkComboBoxText * +toGtkComboBoxText(void *p) +{ + return (GTK_COMBO_BOX_TEXT(p)); +} + +static GtkLinkButton * +toGtkLinkButton(void *p) +{ + return (GTK_LINK_BUTTON(p)); +} + +static GtkLayout * +toGtkLayout(void *p) +{ + return (GTK_LAYOUT(p)); +} + +static GtkListStore * +toGtkListStore(void *p) +{ + return (GTK_LIST_STORE(p)); +} + +static GtkSwitch * +toGtkSwitch(void *p) +{ + return (GTK_SWITCH(p)); +} + +static GtkTextView * +toGtkTextView(void *p) +{ + return (GTK_TEXT_VIEW(p)); +} + +static GtkTextTagTable * +toGtkTextTagTable(void *p) +{ + return (GTK_TEXT_TAG_TABLE(p)); +} + +static GtkTextBuffer * +toGtkTextBuffer(void *p) +{ + return (GTK_TEXT_BUFFER(p)); +} + +static GtkTreeModel * +toGtkTreeModel(void *p) +{ + return (GTK_TREE_MODEL(p)); +} + +static GtkCellRenderer * +toGtkCellRenderer(void *p) +{ + return (GTK_CELL_RENDERER(p)); +} + +static GtkCellRendererPixbuf * +toGtkCellRendererPixbuf(void *p) +{ + return (GTK_CELL_RENDERER_PIXBUF(p)); +} + +static GtkCellRendererText * +toGtkCellRendererText(void *p) +{ + return (GTK_CELL_RENDERER_TEXT(p)); +} + +static GtkCellRendererToggle * +toGtkCellRendererToggle(void *p) +{ + return (GTK_CELL_RENDERER_TOGGLE(p)); +} + +static GtkCellLayout * +toGtkCellLayout(void *p) +{ + return (GTK_CELL_LAYOUT(p)); +} + +static GtkOrientable * +toGtkOrientable(void *p) +{ + return (GTK_ORIENTABLE(p)); +} + +static GtkTreeStore * +toGtkTreeStore (void *p) +{ + return (GTK_TREE_STORE(p)); +} + +static GtkTreeView * +toGtkTreeView(void *p) +{ + return (GTK_TREE_VIEW(p)); +} + +static GtkTreeViewColumn * +toGtkTreeViewColumn(void *p) +{ + return (GTK_TREE_VIEW_COLUMN(p)); +} + +static GtkTreeSelection * +toGtkTreeSelection(void *p) +{ + return (GTK_TREE_SELECTION(p)); +} + +static GtkTreeSortable * +toGtkTreeSortable(void *p) +{ + return (GTK_TREE_SORTABLE(p)); +} + +static GtkClipboard * +toGtkClipboard(void *p) +{ + return (GTK_CLIPBOARD(p)); +} + +static GtkDialog * +toGtkDialog(void *p) +{ + return (GTK_DIALOG(p)); +} + +static GtkMessageDialog * +toGtkMessageDialog(void *p) +{ + return (GTK_MESSAGE_DIALOG(p)); +} + +static GtkBuilder * +toGtkBuilder(void *p) +{ + return (GTK_BUILDER(p)); +} + +static GtkSeparatorMenuItem * +toGtkSeparatorMenuItem(void *p) +{ + return (GTK_SEPARATOR_MENU_ITEM(p)); +} + +static GtkCheckButton * +toGtkCheckButton(void *p) +{ + return (GTK_CHECK_BUTTON(p)); +} + +static GtkToggleButton * +toGtkToggleButton(void *p) +{ + return (GTK_TOGGLE_BUTTON(p)); +} + +static GtkFontButton * +toGtkFontButton(void *p) +{ + return (GTK_FONT_BUTTON(p)); +} + +static GtkFrame * +toGtkFrame(void *p) +{ + return (GTK_FRAME(p)); +} + +static GtkSeparator * +toGtkSeparator(void *p) +{ + return (GTK_SEPARATOR(p)); +} + +static GtkScale* +toGtkScale(void *p) +{ + return (GTK_SCALE(p)); +} + +static GtkScrollbar * +toGtkScrollbar(void *p) +{ + return (GTK_SCROLLBAR(p)); +} + +static GtkRange * +toGtkRange(void *p) +{ + return (GTK_RANGE(p)); +} + +static GtkSearchEntry * +toGtkSearchEntry(void *p) +{ + return (GTK_SEARCH_ENTRY(p)); +} + +static GtkOffscreenWindow * +toGtkOffscreenWindow(void *p) +{ + return (GTK_OFFSCREEN_WINDOW(p)); +} + +static GtkExpander * +toGtkExpander(void *p) +{ + return (GTK_EXPANDER(p)); +} + +static GtkFileChooser * +toGtkFileChooser(void *p) +{ + return (GTK_FILE_CHOOSER(p)); +} + +static GtkFileChooserButton * +toGtkFileChooserButton(void *p) +{ + return (GTK_FILE_CHOOSER_BUTTON(p)); +} + +static GtkFileChooserDialog * +toGtkFileChooserDialog(void *p) +{ + return (GTK_FILE_CHOOSER_DIALOG(p)); +} + +static GtkFileChooserWidget * +toGtkFileChooserWidget(void *p) +{ + return (GTK_FILE_CHOOSER_WIDGET(p)); +} + +static GtkFileFilter * +toGtkFileFilter(void *p) +{ + return (GTK_FILE_FILTER(p)); +} + +static GtkMenuButton * +toGtkMenuButton(void *p) +{ + return (GTK_MENU_BUTTON(p)); +} + +static GtkRadioButton * +toGtkRadioButton(void *p) +{ + return (GTK_RADIO_BUTTON(p)); +} + +static GtkRecentChooser * +toGtkRecentChooser(void *p) +{ + return (GTK_RECENT_CHOOSER(p)); +} + +static GtkRecentChooserMenu * +toGtkRecentChooserMenu(void *p) +{ + return (GTK_RECENT_CHOOSER_MENU(p)); +} + +static GtkColorChooser * +toGtkColorChooser(void *p) +{ + return (GTK_COLOR_CHOOSER(p)); +} + +static GtkRecentFilter * +toGtkRecentFilter(void *p) +{ + return (GTK_RECENT_FILTER(p)); +} + +static GtkRecentManager * +toGtkRecentManager(void *p) +{ + return (GTK_RECENT_MANAGER(p)); +} + +static GtkCheckMenuItem * +toGtkCheckMenuItem(void *p) +{ + return (GTK_CHECK_MENU_ITEM(p)); +} + +static GtkRadioMenuItem * +toGtkRadioMenuItem(void *p) +{ + return (GTK_RADIO_MENU_ITEM(p)); +} + +static GtkToolItem * +toGtkToolItem(void *p) +{ + return (GTK_TOOL_ITEM(p)); +} + +static GtkToolbar * +toGtkToolbar(void *p) +{ + return (GTK_TOOLBAR(p)); +} + +static GtkEditable * +toGtkEditable(void *p) +{ + return (GTK_EDITABLE(p)); +} + +static GtkToolButton * +toGtkToolButton(void *p) +{ + return (GTK_TOOL_BUTTON(p)); +} + +static GtkSeparatorToolItem * +toGtkSeparatorToolItem(void *p) +{ + return (GTK_SEPARATOR_TOOL_ITEM(p)); +} + +static GtkCssProvider * +toGtkCssProvider(void *p) +{ + return (GTK_CSS_PROVIDER(p)); +} + +static GtkStyleContext * +toGtkStyleContext(void *p) +{ + return (GTK_STYLE_CONTEXT(p)); +} + +static GtkStyleProvider * +toGtkStyleProvider(void *p) +{ + return (GTK_STYLE_PROVIDER(p)); +} + +static GtkInfoBar * +toGtkInfoBar(void *p) +{ + return (GTK_INFO_BAR(p)); +} + +static GType * +alloc_types(int n) { + return ((GType *)g_new0(GType, n)); +} + +static void +set_type(GType *types, int n, GType t) +{ + types[n] = t; +} + +static GtkTreeViewColumn * +_gtk_tree_view_column_new_with_attributes_one(const gchar *title, + GtkCellRenderer *renderer, const gchar *attribute, gint column) +{ + GtkTreeViewColumn *tvc; + + tvc = gtk_tree_view_column_new_with_attributes(title, renderer, + attribute, column, NULL); + return (tvc); +} + +static void +_gtk_list_store_set(GtkListStore *list_store, GtkTreeIter *iter, gint column, + void* value) +{ + gtk_list_store_set(list_store, iter, column, value, -1); +} + +static void +_gtk_tree_store_set(GtkTreeStore *store, GtkTreeIter *iter, gint column, + void* value) +{ + gtk_tree_store_set(store, iter, column, value, -1); +} + +static GtkWidget * +_gtk_message_dialog_new(GtkWindow *parent, GtkDialogFlags flags, + GtkMessageType type, GtkButtonsType buttons, char *msg) +{ + GtkWidget *w; + + w = gtk_message_dialog_new(parent, flags, type, buttons, "%s", msg); + return (w); +} + +static GtkWidget * +_gtk_message_dialog_new_with_markup(GtkWindow *parent, GtkDialogFlags flags, + GtkMessageType type, GtkButtonsType buttons, char *msg) +{ + GtkWidget *w; + + w = gtk_message_dialog_new_with_markup(parent, flags, type, buttons, + "%s", msg); + return (w); +} + +static void +_gtk_message_dialog_format_secondary_text(GtkMessageDialog *message_dialog, + const gchar *msg) +{ + gtk_message_dialog_format_secondary_text(message_dialog, "%s", msg); +} + +static void +_gtk_message_dialog_format_secondary_markup(GtkMessageDialog *message_dialog, + const gchar *msg) +{ + gtk_message_dialog_format_secondary_markup(message_dialog, "%s", msg); +} + +static const gchar * +object_get_class_name(GObject *object) +{ + return G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(object)); +} + +static GtkWidget * +gtk_file_chooser_dialog_new_1( + const gchar *title, + GtkWindow *parent, + GtkFileChooserAction action, + const gchar *first_button_text, int first_button_id +) { + return gtk_file_chooser_dialog_new( + title, parent, action, + first_button_text, first_button_id, + NULL); +} + +static GtkWidget * +gtk_file_chooser_dialog_new_2( + const gchar *title, + GtkWindow *parent, + GtkFileChooserAction action, + const gchar *first_button_text, int first_button_id, + const gchar *second_button_text, int second_button_id +) { + return gtk_file_chooser_dialog_new( + title, parent, action, + first_button_text, first_button_id, + second_button_text, second_button_id, + NULL); +} + +static void _gtk_widget_hide_on_delete(GtkWidget* w) { + g_signal_connect(GTK_WIDGET(w), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); +} + +static inline gchar** make_strings(int count) { + return (gchar**)malloc(sizeof(gchar*) * count); +} + +static inline void destroy_strings(gchar** strings) { + free(strings); +} + +static inline gchar* get_string(gchar** strings, int n) { + return strings[n]; +} + +static inline void set_string(gchar** strings, int n, gchar* str) { + strings[n] = str; +} + +static inline gchar** next_gcharptr(gchar** s) { return (s+1); } + +extern void goBuilderConnect (GtkBuilder *builder, + GObject *object, + gchar *signal_name, + gchar *handler_name, + GObject *connect_object, + GConnectFlags flags, + gpointer user_data); + +static inline void _gtk_builder_connect_signals_full(GtkBuilder *builder) { + gtk_builder_connect_signals_full(builder, (GtkBuilderConnectFunc)(goBuilderConnect), NULL); +} + +#endif diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_10.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_10.go new file mode 100644 index 0000000..d3477b2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_10.go @@ -0,0 +1,210 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +// #include +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()) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_12.go new file mode 100644 index 0000000..bebf416 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_12.go @@ -0,0 +1,86 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +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)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go new file mode 100644 index 0000000..dd9f7ee --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go @@ -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 +// #include +// #include "gtk_deprecated_since_3_14.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 + */ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go.h new file mode 100644 index 0000000..fa30e9a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_14.go.h @@ -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 + */ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_16.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_16.go new file mode 100644 index 0000000..e0dd8de --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_16.go @@ -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 +// #include +import "C" + +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_export.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_export.go new file mode 100644 index 0000000..59e595f --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_export.go @@ -0,0 +1,44 @@ +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go new file mode 100644 index 0000000..7dbb6e8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go @@ -0,0 +1,693 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +// +build !gtk_3_6,!gtk_3_8 +// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +// #include "gtk_since_3_10.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.gtk_revealer_transition_type_get_type()), marshalRevealerTransitionType}, + {glib.Type(C.gtk_stack_transition_type_get_type()), marshalStackTransitionType}, + + // Objects/Interfaces + {glib.Type(C.gtk_header_bar_get_type()), marshalHeaderBar}, + {glib.Type(C.gtk_list_box_get_type()), marshalListBox}, + {glib.Type(C.gtk_list_box_row_get_type()), marshalListBoxRow}, + {glib.Type(C.gtk_revealer_get_type()), marshalRevealer}, + {glib.Type(C.gtk_search_bar_get_type()), marshalSearchBar}, + {glib.Type(C.gtk_stack_get_type()), marshalStack}, + {glib.Type(C.gtk_stack_switcher_get_type()), marshalStackSwitcher}, + } + glib.RegisterGValueMarshalers(tm) + + //Contribute to casting + for k, v := range map[string]WrapFn{ + "GtkHeaderBar": wrapHeaderBar, + "GtkListBox": wrapListBox, + "GtkListBoxRow": wrapListBoxRow, + "GtkRevealer": wrapRevealer, + "GtkSearchBar": wrapSearchBar, + "GtkStack": wrapStack, + } { + WrapMap[k] = v + } +} + +/* + * Constants + */ + +const ( + ALIGN_BASELINE Align = C.GTK_ALIGN_BASELINE +) + +// RevealerTransitionType is a representation of GTK's GtkRevealerTransitionType. +type RevealerTransitionType int + +const ( + REVEALER_TRANSITION_TYPE_NONE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_NONE + REVEALER_TRANSITION_TYPE_CROSSFADE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_CROSSFADE + REVEALER_TRANSITION_TYPE_SLIDE_RIGHT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT + REVEALER_TRANSITION_TYPE_SLIDE_LEFT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT + REVEALER_TRANSITION_TYPE_SLIDE_UP RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP + REVEALER_TRANSITION_TYPE_SLIDE_DOWN RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN +) + +func marshalRevealerTransitionType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return RevealerTransitionType(c), nil +} + +// StackTransitionType is a representation of GTK's GtkStackTransitionType. +type StackTransitionType int + +const ( + STACK_TRANSITION_TYPE_NONE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_NONE + STACK_TRANSITION_TYPE_CROSSFADE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_CROSSFADE + STACK_TRANSITION_TYPE_SLIDE_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT + STACK_TRANSITION_TYPE_SLIDE_LEFT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT + STACK_TRANSITION_TYPE_SLIDE_UP StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP + STACK_TRANSITION_TYPE_SLIDE_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN + STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT + STACK_TRANSITION_TYPE_SLIDE_UP_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN +) + +func marshalStackTransitionType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return StackTransitionType(c), nil +} + +/* + * GtkButton + */ + +// ButtonNewFromIconName is a wrapper around gtk_button_new_from_icon_name(). +func ButtonNewFromIconName(iconName string, size IconSize) (*Button, error) { + cstr := C.CString(iconName) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_button_new_from_icon_name((*C.gchar)(cstr), + C.GtkIconSize(size)) + if c == nil { + return nil, nilPtrErr + } + return wrapButton(wrapObject(unsafe.Pointer(c))), nil +} + +/* + * GtkHeaderBar + */ + +type HeaderBar struct { + Container +} + +// native returns a pointer to the underlying GtkHeaderBar. +func (v *HeaderBar) native() *C.GtkHeaderBar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkHeaderBar(p) +} + +func marshalHeaderBar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapHeaderBar(obj), nil +} + +func wrapHeaderBar(obj *glib.Object) *HeaderBar { + return &HeaderBar{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// HeaderBarNew is a wrapper around gtk_header_bar_new(). +func HeaderBarNew() (*HeaderBar, error) { + c := C.gtk_header_bar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapHeaderBar(wrapObject(unsafe.Pointer(c))), nil +} + +// SetTitle is a wrapper around gtk_header_bar_set_title(). +func (v *HeaderBar) SetTitle(title string) { + cstr := C.CString(title) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_header_bar_set_title(v.native(), (*C.gchar)(cstr)) +} + +// GetTitle is a wrapper around gtk_header_bar_get_title(). +func (v *HeaderBar) GetTitle() string { + cstr := C.gtk_header_bar_get_title(v.native()) + return C.GoString((*C.char)(cstr)) +} + +// SetSubtitle is a wrapper around gtk_header_bar_set_subtitle(). +func (v *HeaderBar) SetSubtitle(subtitle string) { + cstr := C.CString(subtitle) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_header_bar_set_subtitle(v.native(), (*C.gchar)(cstr)) +} + +// GetSubtitle is a wrapper around gtk_header_bar_get_subtitle(). +func (v *HeaderBar) GetSubtitle() string { + cstr := C.gtk_header_bar_get_subtitle(v.native()) + return C.GoString((*C.char)(cstr)) +} + +// SetCustomTitle is a wrapper around gtk_header_bar_set_custom_title(). +func (v *HeaderBar) SetCustomTitle(titleWidget IWidget) { + C.gtk_header_bar_set_custom_title(v.native(), titleWidget.toWidget()) +} + +// GetCustomTitle is a wrapper around gtk_header_bar_get_custom_title(). +func (v *HeaderBar) GetCustomTitle() (*Widget, error) { + c := C.gtk_header_bar_get_custom_title(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// PackStart is a wrapper around gtk_header_bar_pack_start(). +func (v *HeaderBar) PackStart(child IWidget) { + C.gtk_header_bar_pack_start(v.native(), child.toWidget()) +} + +// PackEnd is a wrapper around gtk_header_bar_pack_end(). +func (v *HeaderBar) PackEnd(child IWidget) { + C.gtk_header_bar_pack_end(v.native(), child.toWidget()) +} + +// SetShowCloseButton is a wrapper around gtk_header_bar_set_show_close_button(). +func (v *HeaderBar) SetShowCloseButton(setting bool) { + C.gtk_header_bar_set_show_close_button(v.native(), gbool(setting)) +} + +// GetShowCloseButton is a wrapper around gtk_header_bar_get_show_close_button(). +func (v *HeaderBar) GetShowCloseButton() bool { + c := C.gtk_header_bar_get_show_close_button(v.native()) + return gobool(c) +} + +/* + * GtkLabel + */ + +// GetLines() is a wrapper around gtk_label_get_lines(). +func (v *Label) GetLines() int { + c := C.gtk_label_get_lines(v.native()) + return int(c) +} + +// SetLines() is a wrapper around gtk_label_set_lines(). +func (v *Label) SetLines(lines int) { + C.gtk_label_set_lines(v.native(), C.gint(lines)) +} + +/* + * GtkListBox + */ + +// ListBox is a representation of GTK's GtkListBox. +type ListBox struct { + Container +} + +// native returns a pointer to the underlying GtkListBox. +func (v *ListBox) native() *C.GtkListBox { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkListBox(p) +} + +func marshalListBox(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapListBox(obj), nil +} + +func wrapListBox(obj *glib.Object) *ListBox { + return &ListBox{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// ListBoxNew is a wrapper around gtk_list_box_new(). +func ListBoxNew() (*ListBox, error) { + c := C.gtk_list_box_new() + if c == nil { + return nil, nilPtrErr + } + return wrapListBox(wrapObject(unsafe.Pointer(c))), nil +} + +// Prepend is a wrapper around gtk_list_box_prepend(). +func (v *ListBox) Prepend(child IWidget) { + C.gtk_list_box_prepend(v.native(), child.toWidget()) +} + +// Insert is a wrapper around gtk_list_box_insert(). +func (v *ListBox) Insert(child IWidget, position int) { + C.gtk_list_box_insert(v.native(), child.toWidget(), C.gint(position)) +} + +// SelectRow is a wrapper around gtk_list_box_select_row(). +func (v *ListBox) SelectRow(row *ListBoxRow) { + C.gtk_list_box_select_row(v.native(), row.native()) +} + +// GetSelectedRow is a wrapper around gtk_list_box_get_selected_row(). +func (v *ListBox) GetSelectedRow() *ListBoxRow { + c := C.gtk_list_box_get_selected_row(v.native()) + if c == nil { + return nil + } + return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) +} + +// SetSelectionMode is a wrapper around gtk_list_box_set_selection_mode(). +func (v *ListBox) SetSelectionMode(mode SelectionMode) { + C.gtk_list_box_set_selection_mode(v.native(), C.GtkSelectionMode(mode)) +} + +// GetSelectionMode is a wrapper around gtk_list_box_get_selection_mode() +func (v *ListBox) GetSelectionMode() SelectionMode { + c := C.gtk_list_box_get_selection_mode(v.native()) + return SelectionMode(c) +} + +// SetActivateOnSingleClick is a wrapper around gtk_list_box_set_activate_on_single_click(). +func (v *ListBox) SetActivateOnSingleClick(single bool) { + C.gtk_list_box_set_activate_on_single_click(v.native(), gbool(single)) +} + +// GetActivateOnSingleClick is a wrapper around gtk_list_box_get_activate_on_single_click(). +func (v *ListBox) GetActivateOnSingleClick() bool { + c := C.gtk_list_box_get_activate_on_single_click(v.native()) + return gobool(c) +} + +// GetAdjustment is a wrapper around gtk_list_box_get_adjustment(). +func (v *ListBox) GetAdjustment() *Adjustment { + c := C.gtk_list_box_get_adjustment(v.native()) + obj := wrapObject(unsafe.Pointer(c)) + return &Adjustment{glib.InitiallyUnowned{obj}} +} + +// SetAdjustment is a wrapper around gtk_list_box_set_adjustment(). +func (v *ListBox) SetAdjuctment(adjustment *Adjustment) { + C.gtk_list_box_set_adjustment(v.native(), adjustment.native()) +} + +// SetPlaceholder is a wrapper around gtk_list_box_set_placeholder(). +func (v *ListBox) SetPlaceholder(placeholder IWidget) { + C.gtk_list_box_set_placeholder(v.native(), placeholder.toWidget()) +} + +// GetRowAtIndex is a wrapper around gtk_list_box_get_row_at_index(). +func (v *ListBox) GetRowAtIndex(index int) *ListBoxRow { + c := C.gtk_list_box_get_row_at_index(v.native(), C.gint(index)) + if c == nil { + return nil + } + return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) +} + +// GetRowAtY is a wrapper around gtk_list_box_get_row_at_y(). +func (v *ListBox) GetRowAtY(y int) *ListBoxRow { + c := C.gtk_list_box_get_row_at_y(v.native(), C.gint(y)) + if c == nil { + return nil + } + return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) +} + +// InvalidateFilter is a wrapper around gtk_list_box_invalidate_filter(). +func (v *ListBox) InvalidateFilter() { + C.gtk_list_box_invalidate_filter(v.native()) +} + +// InvalidateHeaders is a wrapper around gtk_list_box_invalidate_headers(). +func (v *ListBox) InvalidateHeaders() { + C.gtk_list_box_invalidate_headers(v.native()) +} + +// InvalidateSort is a wrapper around gtk_list_box_invalidate_sort(). +func (v *ListBox) InvalidateSort() { + C.gtk_list_box_invalidate_sort(v.native()) +} + +// TODO: SetFilterFunc +// TODO: SetHeaderFunc +// TODO: SetSortFunc + +// DragHighlightRow is a wrapper around gtk_list_box_drag_highlight_row() +func (v *ListBox) DragHighlightRow(row *ListBoxRow) { + C.gtk_list_box_drag_highlight_row(v.native(), row.native()) +} + +/* + * GtkListBoxRow + */ + +// ListBoxRow is a representation of GTK's GtkListBoxRow. +type ListBoxRow struct { + Bin +} + +// native returns a pointer to the underlying GtkListBoxRow. +func (v *ListBoxRow) native() *C.GtkListBoxRow { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkListBoxRow(p) +} + +func marshalListBoxRow(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapListBoxRow(obj), nil +} + +func wrapListBoxRow(obj *glib.Object) *ListBoxRow { + return &ListBoxRow{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +func ListBoxRowNew() (*ListBoxRow, error) { + c := C.gtk_list_box_row_new() + if c == nil { + return nil, nilPtrErr + } + return wrapListBoxRow(wrapObject(unsafe.Pointer(c))), nil +} + +// Changed is a wrapper around gtk_list_box_row_changed(). +func (v *ListBoxRow) Changed() { + C.gtk_list_box_row_changed(v.native()) +} + +// GetHeader is a wrapper around gtk_list_box_row_get_header(). +func (v *ListBoxRow) GetHeader() *Widget { + c := C.gtk_list_box_row_get_header(v.native()) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} + +// SetHeader is a wrapper around gtk_list_box_row_get_header(). +func (v *ListBoxRow) SetHeader(header IWidget) { + C.gtk_list_box_row_set_header(v.native(), header.toWidget()) +} + +// GetIndex is a wrapper around gtk_list_box_row_get_index() +func (v *ListBoxRow) GetIndex() int { + c := C.gtk_list_box_row_get_index(v.native()) + return int(c) +} + +/* + * GtkRevealer + */ + +// Revealer is a representation of GTK's GtkRevealer +type Revealer struct { + Bin +} + +// native returns a pointer to the underlying GtkRevealer. +func (v *Revealer) native() *C.GtkRevealer { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkRevealer(p) +} + +func marshalRevealer(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapRevealer(obj), nil +} + +func wrapRevealer(obj *glib.Object) *Revealer { + return &Revealer{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// RevealerNew is a wrapper around gtk_revealer_new() +func RevealerNew() (*Revealer, error) { + c := C.gtk_revealer_new() + if c == nil { + return nil, nilPtrErr + } + return wrapRevealer(wrapObject(unsafe.Pointer(c))), nil +} + +// GetRevealChild is a wrapper around gtk_revealer_get_reveal_child(). +func (v *Revealer) GetRevealChild() bool { + c := C.gtk_revealer_get_reveal_child(v.native()) + return gobool(c) +} + +// SetRevealChild is a wrapper around gtk_revealer_set_reveal_child(). +func (v *Revealer) SetRevealChild(revealChild bool) { + C.gtk_revealer_set_reveal_child(v.native(), gbool(revealChild)) +} + +// GetChildRevealed is a wrapper around gtk_revealer_get_child_revealed(). +func (v *Revealer) GetChildRevealed() bool { + c := C.gtk_revealer_get_child_revealed(v.native()) + return gobool(c) +} + +// GetTransitionDuration is a wrapper around gtk_revealer_get_transition_duration() +func (v *Revealer) GetTransitionDuration() uint { + c := C.gtk_revealer_get_transition_duration(v.native()) + return uint(c) +} + +// SetTransitionDuration is a wrapper around gtk_revealer_set_transition_duration(). +func (v *Revealer) SetTransitionDuration(duration uint) { + C.gtk_revealer_set_transition_duration(v.native(), C.guint(duration)) +} + +// GetTransitionType is a wrapper around gtk_revealer_get_transition_type() +func (v *Revealer) GetTransitionType() RevealerTransitionType { + c := C.gtk_revealer_get_transition_type(v.native()) + return RevealerTransitionType(c) +} + +// SetTransitionType is a wrapper around gtk_revealer_set_transition_type() +func (v *Revealer) SetTransitionType(transition RevealerTransitionType) { + t := C.GtkRevealerTransitionType(transition) + C.gtk_revealer_set_transition_type(v.native(), t) +} + +/* + * GtkSearchBar + */ + +// SearchBar is a representation of GTK's GtkSearchBar. +type SearchBar struct { + Bin +} + +// native returns a pointer to the underlying GtkSearchBar. +func (v *SearchBar) native() *C.GtkSearchBar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkSearchBar(p) +} + +func marshalSearchBar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapSearchBar(obj), nil +} + +func wrapSearchBar(obj *glib.Object) *SearchBar { + return &SearchBar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// SearchBarNew is a wrapper around gtk_search_bar_new() +func SearchBarNew() (*SearchBar, error) { + c := C.gtk_search_bar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapSearchBar(wrapObject(unsafe.Pointer(c))), nil +} + +// ConnectEntry is a wrapper around gtk_search_bar_connect_entry(). +func (v *SearchBar) ConnectEntry(entry IEntry) { + C.gtk_search_bar_connect_entry(v.native(), entry.toEntry()) +} + +// GetSearchMode is a wrapper around gtk_search_bar_get_search_mode(). +func (v *SearchBar) GetSearchMode() bool { + c := C.gtk_search_bar_get_search_mode(v.native()) + return gobool(c) +} + +// SetSearchMode is a wrapper around gtk_search_bar_set_search_mode(). +func (v *SearchBar) SetSearchMode(searchMode bool) { + C.gtk_search_bar_set_search_mode(v.native(), gbool(searchMode)) +} + +// GetShowCloseButton is a wrapper arounb gtk_search_bar_get_show_close_button(). +func (v *SearchBar) GetShowCloseButton() bool { + c := C.gtk_search_bar_get_show_close_button(v.native()) + return gobool(c) +} + +// SetShowCloseButton is a wrapper around gtk_search_bar_set_show_close_button() +func (v *SearchBar) SetShowCloseButton(visible bool) { + C.gtk_search_bar_set_show_close_button(v.native(), gbool(visible)) +} + +// HandleEvent is a wrapper around gtk_search_bar_handle_event() +func (v *SearchBar) HandleEvent(event *gdk.Event) { + e := (*C.GdkEvent)(unsafe.Pointer(event.Native())) + C.gtk_search_bar_handle_event(v.native(), e) +} + +/* + * GtkStack + */ + +// Stack is a representation of GTK's GtkStack. +type Stack struct { + Container +} + +// native returns a pointer to the underlying GtkStack. +func (v *Stack) native() *C.GtkStack { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkStack(p) +} + +func marshalStack(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapStack(obj), nil +} + +func wrapStack(obj *glib.Object) *Stack { + return &Stack{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// StackNew is a wrapper around gtk_stack_new(). +func StackNew() (*Stack, error) { + c := C.gtk_stack_new() + if c == nil { + return nil, nilPtrErr + } + return wrapStack(wrapObject(unsafe.Pointer(c))), nil +} + +// AddNamed is a wrapper around gtk_stack_add_named(). +func (v *Stack) AddNamed(child IWidget, name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_stack_add_named(v.native(), child.toWidget(), (*C.gchar)(cstr)) +} + +// AddTitled is a wrapper around gtk_stack_add_titled(). +func (v *Stack) AddTitled(child IWidget, name, title string) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + cTitle := C.CString(title) + defer C.free(unsafe.Pointer(cTitle)) + C.gtk_stack_add_titled(v.native(), child.toWidget(), (*C.gchar)(cName), + (*C.gchar)(cTitle)) +} + +// SetVisibleChild is a wrapper around gtk_stack_set_visible_child(). +func (v *Stack) SetVisibleChild(child IWidget) { + C.gtk_stack_set_visible_child(v.native(), child.toWidget()) +} + +// GetVisibleChild is a wrapper around gtk_stack_get_visible_child(). +func (v *Stack) GetVisibleChild() *Widget { + c := C.gtk_stack_get_visible_child(v.native()) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} + +// SetVisibleChildName is a wrapper around gtk_stack_set_visible_child_name(). +func (v *Stack) SetVisibleChildName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_stack_set_visible_child_name(v.native(), (*C.gchar)(cstr)) +} + +// GetVisibleChildName is a wrapper around gtk_stack_get_visible_child_name(). +func (v *Stack) GetVisibleChildName() string { + c := C.gtk_stack_get_visible_child_name(v.native()) + return C.GoString((*C.char)(c)) +} + +// SetVisibleChildFull is a wrapper around gtk_stack_set_visible_child_full(). +func (v *Stack) SetVisibleChildFull(name string, transaction StackTransitionType) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_stack_set_visible_child_full(v.native(), (*C.gchar)(cstr), + C.GtkStackTransitionType(transaction)) +} + +// SetHomogeneous is a wrapper around gtk_stack_set_homogeneous(). +func (v *Stack) SetHomogeneous(homogeneous bool) { + C.gtk_stack_set_homogeneous(v.native(), gbool(homogeneous)) +} + +// GetHomogeneous is a wrapper around gtk_stack_get_homogeneous(). +func (v *Stack) GetHomogeneous() bool { + c := C.gtk_stack_get_homogeneous(v.native()) + return gobool(c) +} + +// SetTransitionDuration is a wrapper around gtk_stack_set_transition_duration(). +func (v *Stack) SetTransitionDuration(duration uint) { + C.gtk_stack_set_transition_duration(v.native(), C.guint(duration)) +} + +// GetTransitionDuration is a wrapper around gtk_stack_get_transition_duration(). +func (v *Stack) GetTransitionDuration() uint { + c := C.gtk_stack_get_transition_duration(v.native()) + return uint(c) +} + +// SetTransitionType is a wrapper around gtk_stack_set_transition_type(). +func (v *Stack) SetTransitionType(transition StackTransitionType) { + C.gtk_stack_set_transition_type(v.native(), C.GtkStackTransitionType(transition)) +} + +// GetTransitionType is a wrapper around gtk_stack_get_transition_type(). +func (v *Stack) GetTransitionType() StackTransitionType { + c := C.gtk_stack_get_transition_type(v.native()) + return StackTransitionType(c) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go.h new file mode 100644 index 0000000..724b223 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_10.go.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * 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)); +} + + \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_8.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_8.go new file mode 100644 index 0000000..1c3d97f --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/gtk_since_3_8.go @@ -0,0 +1,37 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +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 +) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/info_bar.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/info_bar.go new file mode 100644 index 0000000..b33c1e8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/info_bar.go @@ -0,0 +1,106 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/label.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/label.go new file mode 100644 index 0000000..0a649c6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/label.go @@ -0,0 +1,257 @@ +// Same copyright and license as the rest of the files in this project +// This file contains style related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/pango" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar.go new file mode 100644 index 0000000..b0d4af4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar.go @@ -0,0 +1,151 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar_since_3_8.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar_since_3_8.go new file mode 100644 index 0000000..8df8f29 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/level_bar_since_3_8.go @@ -0,0 +1,18 @@ +// +build !gtk_3_6 + +package gtk + +// #include +// #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) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/menu_shell.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/menu_shell.go new file mode 100644 index 0000000..d9759fe --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/menu_shell.go @@ -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 +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go new file mode 100644 index 0000000..cd307e5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go @@ -0,0 +1,83 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +// #include "popover_since_3_12.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/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 +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go.h new file mode 100644 index 0000000..3cc5564 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_12.go.h @@ -0,0 +1,25 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12 + +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * This file originated from: http://opensource.conformal.com/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +static GtkPopover * +toGtkPopover(void *p) +{ + return (GTK_POPOVER(p)); +} \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_18.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_18.go new file mode 100644 index 0000000..ca1b5dd --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/popover_since_3_18.go @@ -0,0 +1,30 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,!gtk_3_16,gtk_3_18 + +// See: https://developer.gnome.org/gtk3/3.18/api-index-3-18.html + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +//void +//gtk_popover_set_default_widget (GtkPopover *popover, GtkWidget *widget); +func (p *Popover) SetDefaultWidget(widget IWidget) { + C.gtk_popover_set_default_widget(p.native(), widget.toWidget()) +} + +//GtkWidget * +//gtk_popover_get_default_widget (GtkPopover *popover); +func (p *Popover) GetDefaultWidget() *Widget { + w := C.gtk_popover_get_default_widget(p.native()) + if w == nil { + return nil + } + return &Widget{glib.InitiallyUnowned{wrapObject(unsafe.Pointer(w))}} +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go new file mode 100644 index 0000000..1deea98 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go @@ -0,0 +1,53 @@ +package gtk + +// #include +// #include "settings.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + {glib.Type(C.gtk_settings_get_type()), marshalSettings}, + } + + glib.RegisterGValueMarshalers(tm) + + WrapMap["GtkSettings"] = wrapSettings +} + +//GtkSettings +type Settings struct { + *glib.Object +} + +func (v *Settings) native() *C.GtkSettings { + if v == nil || v.GObject == nil { + return nil + } + + p := unsafe.Pointer(v.GObject) + return C.toGtkSettings(p) +} + +func marshalSettings(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + return wrapSettings(wrapObject(unsafe.Pointer(c))), nil +} + +func wrapSettings(obj *glib.Object) *Settings { + return &Settings{obj} +} + +//Get the global non window specific settings +func SettingsGetDefault() (*Settings, error) { + c := C.gtk_settings_get_default() + if c == nil { + return nil, nilPtrErr + } + + return wrapSettings(wrapObject(unsafe.Pointer(c))), nil +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go.h new file mode 100644 index 0000000..571b91a --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/settings.go.h @@ -0,0 +1,5 @@ +static GtkSettings * +toGtkSettings(void *p) +{ + return (GTK_SETTINGS(p)); +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stack_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stack_since_3_12.go new file mode 100644 index 0000000..42addd5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stack_since_3_12.go @@ -0,0 +1,27 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 +// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +// #include "gtk_since_3_10.go.h" +import "C" +import ( + "unsafe" +) + +// GetChildByName is a wrapper around gtk_stack_get_child_by_name(). +func (v *Stack) GetChildByName(name string) *Widget { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_stack_get_child_by_name(v.native(), (*C.gchar)(cstr)) + if c == nil { + return nil + } + return wrapWidget(wrapObject(unsafe.Pointer(c))) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stackswitcher_since_3_10.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stackswitcher_since_3_10.go new file mode 100644 index 0000000..d8845c4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/stackswitcher_since_3_10.go @@ -0,0 +1,78 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +// +build !gtk_3_6,!gtk_3_8 +// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +// #include "gtk_since_3_10.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + //Contribute to casting + for k, v := range map[string]WrapFn{ + "GtkStackSwitcher": wrapStackSwitcher, + } { + WrapMap[k] = v + } +} + +/* + * GtkStackSwitcher + */ + +// StackSwitcher is a representation of GTK's GtkStackSwitcher +type StackSwitcher struct { + Box +} + +// native returns a pointer to the underlying GtkStackSwitcher. +func (v *StackSwitcher) native() *C.GtkStackSwitcher { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkStackSwitcher(p) +} + +func marshalStackSwitcher(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapStackSwitcher(obj), nil +} + +func wrapStackSwitcher(obj *glib.Object) *StackSwitcher { + return &StackSwitcher{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// StackSwitcherNew is a wrapper around gtk_stack_switcher_new(). +func StackSwitcherNew() (*StackSwitcher, error) { + c := C.gtk_stack_switcher_new() + if c == nil { + return nil, nilPtrErr + } + return wrapStackSwitcher(wrapObject(unsafe.Pointer(c))), nil +} + +// SetStack is a wrapper around gtk_stack_switcher_set_stack(). +func (v *StackSwitcher) SetStack(stack *Stack) { + C.gtk_stack_switcher_set_stack(v.native(), stack.native()) +} + +// GetStack is a wrapper around gtk_stack_switcher_get_stack(). +func (v *StackSwitcher) GetStack() *Stack { + c := C.gtk_stack_switcher_get_stack(v.native()) + if c == nil { + return nil + } + return wrapStack(wrapObject(unsafe.Pointer(c))) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/style.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/style.go new file mode 100644 index 0000000..538fe90 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/style.go @@ -0,0 +1,232 @@ +// Same copyright and license as the rest of the files in this project +// This file contains style related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +type StyleProviderPriority int + +const ( + STYLE_PROVIDER_PRIORITY_FALLBACK StyleProviderPriority = C.GTK_STYLE_PROVIDER_PRIORITY_FALLBACK + STYLE_PROVIDER_PRIORITY_THEME = C.GTK_STYLE_PROVIDER_PRIORITY_THEME + STYLE_PROVIDER_PRIORITY_SETTINGS = C.GTK_STYLE_PROVIDER_PRIORITY_SETTINGS + STYLE_PROVIDER_PRIORITY_APPLICATION = C.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + STYLE_PROVIDER_PRIORITY_USER = C.GTK_STYLE_PROVIDER_PRIORITY_USER +) + +/* + * GtkStyleContext + */ + +// StyleContext is a representation of GTK's GtkStyleContext. +type StyleContext struct { + *glib.Object +} + +// native returns a pointer to the underlying GtkStyleContext. +func (v *StyleContext) native() *C.GtkStyleContext { + if v == nil || v.Object == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkStyleContext(p) +} + +func wrapStyleContext(obj *glib.Object) *StyleContext { + return &StyleContext{obj} +} + +func (v *StyleContext) AddClass(class_name string) { + cstr := C.CString(class_name) + defer C.free(unsafe.Pointer(cstr)) + + C.gtk_style_context_add_class(v.native(), (*C.gchar)(cstr)) +} + +func (v *StyleContext) RemoveClass(class_name string) { + cstr := C.CString(class_name) + defer C.free(unsafe.Pointer(cstr)) + + C.gtk_style_context_remove_class(v.native(), (*C.gchar)(cstr)) +} + +func fromNativeStyleContext(c *C.GtkStyleContext) (*StyleContext, error) { + if c == nil { + return nil, nilPtrErr + } + + obj := wrapObject(unsafe.Pointer(c)) + return wrapStyleContext(obj), nil +} + +// GetStyleContext is a wrapper around gtk_widget_get_style_context(). +func (v *Widget) GetStyleContext() (*StyleContext, error) { + return fromNativeStyleContext(C.gtk_widget_get_style_context(v.native())) +} + +// GetParent is a wrapper around gtk_style_context_get_parent(). +func (v *StyleContext) GetParent() (*StyleContext, error) { + return fromNativeStyleContext(C.gtk_style_context_get_parent(v.native())) +} + +// GetProperty is a wrapper around gtk_style_context_get_property(). +func (v *StyleContext) GetProperty(property string, state StateFlags) (interface{}, error) { + cstr := (*C.gchar)(C.CString(property)) + defer C.free(unsafe.Pointer(cstr)) + + var gval C.GValue + C.gtk_style_context_get_property(v.native(), cstr, C.GtkStateFlags(state), &gval) + val := glib.ValueFromNative(unsafe.Pointer(&gval)) + return val.GoValue() +} + +// GetStyleProperty is a wrapper around gtk_style_context_get_style_property(). +func (v *StyleContext) GetStyleProperty(property string) (interface{}, error) { + cstr := (*C.gchar)(C.CString(property)) + defer C.free(unsafe.Pointer(cstr)) + + var gval C.GValue + C.gtk_style_context_get_style_property(v.native(), cstr, &gval) + val := glib.ValueFromNative(unsafe.Pointer(&gval)) + return val.GoValue() +} + +// GetScreen is a wrapper around gtk_style_context_get_screen(). +func (v *StyleContext) GetScreen() (*gdk.Screen, error) { + c := C.gtk_style_context_get_screen(v.native()) + if c == nil { + return nil, nilPtrErr + } + + d := &gdk.Screen{wrapObject(unsafe.Pointer(c))} + return d, nil +} + +// GetState is a wrapper around gtk_style_context_get_state(). +func (v *StyleContext) GetState() StateFlags { + return StateFlags(C.gtk_style_context_get_state(v.native())) +} + +// GetColor is a wrapper around gtk_style_context_get_color(). +func (v *StyleContext) GetColor(state StateFlags) *gdk.RGBA { + gdkColor := gdk.NewRGBA() + C.gtk_style_context_get_color(v.native(), C.GtkStateFlags(state), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) + return gdkColor +} + +// LookupColor is a wrapper around gtk_style_context_lookup_color(). +func (v *StyleContext) LookupColor(colorName string) (*gdk.RGBA, bool) { + cstr := (*C.gchar)(C.CString(colorName)) + defer C.free(unsafe.Pointer(cstr)) + gdkColor := gdk.NewRGBA() + ret := C.gtk_style_context_lookup_color(v.native(), cstr, (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) + return gdkColor, gobool(ret) +} + +// StyleContextResetWidgets is a wrapper around gtk_style_context_reset_widgets(). +func StyleContextResetWidgets(v *gdk.Screen) { + C.gtk_style_context_reset_widgets((*C.GdkScreen)(unsafe.Pointer(v.Native()))) +} + +// Restore is a wrapper around gtk_style_context_restore(). +func (v *StyleContext) Restore() { + C.gtk_style_context_restore(v.native()) +} + +// Save is a wrapper around gtk_style_context_save(). +func (v *StyleContext) Save() { + C.gtk_style_context_save(v.native()) +} + +// SetParent is a wrapper around gtk_style_context_set_parent(). +func (v *StyleContext) SetParent(p *StyleContext) { + C.gtk_style_context_set_parent(v.native(), p.native()) +} + +// HasClass is a wrapper around gtk_style_context_has_class(). +func (v *StyleContext) HasClass(className string) bool { + cstr := C.CString(className) + defer C.free(unsafe.Pointer(cstr)) + + return gobool(C.gtk_style_context_has_class(v.native(), (*C.gchar)(cstr))) +} + +// SetScreen is a wrapper around gtk_style_context_set_screen(). +func (v *StyleContext) SetScreen(s *gdk.Screen) { + C.gtk_style_context_set_screen(v.native(), (*C.GdkScreen)(unsafe.Pointer(s.Native()))) +} + +// SetState is a wrapper around gtk_style_context_set_state(). +func (v *StyleContext) SetState(state StateFlags) { + C.gtk_style_context_set_state(v.native(), C.GtkStateFlags(state)) +} + +type IStyleProvider interface { + toStyleProvider() *C.GtkStyleProvider +} + +// AddProvider is a wrapper around gtk_style_context_add_provider(). +func (v *StyleContext) AddProvider(provider IStyleProvider, prio uint) { + C.gtk_style_context_add_provider(v.native(), provider.toStyleProvider(), C.guint(prio)) +} + +// AddProviderForScreen is a wrapper around gtk_style_context_add_provider_for_screen(). +func AddProviderForScreen(s *gdk.Screen, provider IStyleProvider, prio uint) { + C.gtk_style_context_add_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider(), C.guint(prio)) +} + +// RemoveProvider is a wrapper around gtk_style_context_remove_provider(). +func (v *StyleContext) RemoveProvider(provider IStyleProvider) { + C.gtk_style_context_remove_provider(v.native(), provider.toStyleProvider()) +} + +// RemoveProviderForScreen is a wrapper around gtk_style_context_remove_provider_for_screen(). +func RemoveProviderForScreen(s *gdk.Screen, provider IStyleProvider) { + C.gtk_style_context_remove_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider()) +} + +// GtkStyleContext * gtk_style_context_new () +// void gtk_style_context_get () +// GtkTextDirection gtk_style_context_get_direction () +// GtkJunctionSides gtk_style_context_get_junction_sides () +// const GtkWidgetPath * gtk_style_context_get_path () +// GdkFrameClock * gtk_style_context_get_frame_clock () +// void gtk_style_context_get_style () +// void gtk_style_context_get_style_valist () +// void gtk_style_context_get_valist () +// GtkCssSection * gtk_style_context_get_section () +// void gtk_style_context_get_background_color () +// void gtk_style_context_get_border_color () +// void gtk_style_context_get_border () +// void gtk_style_context_get_padding () +// void gtk_style_context_get_margin () +// const PangoFontDescription * gtk_style_context_get_font () +// void gtk_style_context_invalidate () +// gboolean gtk_style_context_state_is_running () +// GtkIconSet * gtk_style_context_lookup_icon_set () +// void gtk_style_context_cancel_animations () +// void gtk_style_context_scroll_animations () +// void gtk_style_context_notify_state_change () +// void gtk_style_context_pop_animatable_region () +// void gtk_style_context_push_animatable_region () +// void gtk_style_context_set_background () +// void gtk_style_context_set_direction () +// void gtk_style_context_set_junction_sides () +// void gtk_style_context_set_path () +// void gtk_style_context_add_region () +// void gtk_style_context_remove_region () +// gboolean gtk_style_context_has_region () +// GList * gtk_style_context_list_regions () +// void gtk_style_context_set_frame_clock () +// void gtk_style_context_set_scale () +// gint gtk_style_context_get_scale () +// GList * gtk_style_context_list_classes () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view.go new file mode 100644 index 0000000..cdfa985 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view.go @@ -0,0 +1,445 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "runtime" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +/* + * GtkTreeView + */ + +// TreeView is a representation of GTK's GtkTreeView. +type TreeView struct { + Container +} + +// native returns a pointer to the underlying GtkTreeView. +func (v *TreeView) native() *C.GtkTreeView { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTreeView(p) +} + +func marshalTreeView(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTreeView(obj), nil +} + +func wrapTreeView(obj *glib.Object) *TreeView { + return &TreeView{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +func setupTreeView(c unsafe.Pointer) (*TreeView, error) { + if c == nil { + return nil, nilPtrErr + } + + return wrapTreeView(wrapObject(c)), nil +} + +// TreeViewNew() is a wrapper around gtk_tree_view_new(). +func TreeViewNew() (*TreeView, error) { + return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new())) +} + +// TreeViewNewWithModel() is a wrapper around gtk_tree_view_new_with_model(). +func TreeViewNewWithModel(model ITreeModel) (*TreeView, error) { + return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new_with_model(model.toTreeModel()))) +} + +// GetModel() is a wrapper around gtk_tree_view_get_model(). +func (v *TreeView) GetModel() (*TreeModel, error) { + c := C.gtk_tree_view_get_model(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapTreeModel(wrapObject(unsafe.Pointer(c))), nil +} + +// SetModel() is a wrapper around gtk_tree_view_set_model(). +func (v *TreeView) SetModel(model ITreeModel) { + C.gtk_tree_view_set_model(v.native(), model.toTreeModel()) +} + +// GetSelection() is a wrapper around gtk_tree_view_get_selection(). +func (v *TreeView) GetSelection() (*TreeSelection, error) { + c := C.gtk_tree_view_get_selection(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapTreeSelection(wrapObject(unsafe.Pointer(c))), nil +} + +// AppendColumn() is a wrapper around gtk_tree_view_append_column(). +func (v *TreeView) AppendColumn(column *TreeViewColumn) int { + c := C.gtk_tree_view_append_column(v.native(), column.native()) + return int(c) +} + +// GetPathAtPos() is a wrapper around gtk_tree_view_get_path_at_pos(). +func (v *TreeView) GetPathAtPos(x, y int, path *TreePath, column *TreeViewColumn, cellX, cellY *int) bool { + var ctp **C.GtkTreePath + if path != nil { + ctp = (**C.GtkTreePath)(unsafe.Pointer(&path.GtkTreePath)) + } else { + ctp = nil + } + + var pctvcol **C.GtkTreeViewColumn + if column != nil { + ctvcol := column.native() + pctvcol = &ctvcol + } else { + pctvcol = nil + } + + return 0 != C.gtk_tree_view_get_path_at_pos( + v.native(), + (C.gint)(x), + (C.gint)(y), + ctp, + pctvcol, + (*C.gint)(unsafe.Pointer(cellX)), + (*C.gint)(unsafe.Pointer(cellY))) +} + +// GetLevelIndentation is a wrapper around gtk_tree_view_get_level_indentation(). +func (v *TreeView) GetLevelIndentation() int { + return int(C.gtk_tree_view_get_level_indentation(v.native())) +} + +// GetShowExpanders is a wrapper around gtk_tree_view_get_show_expanders(). +func (v *TreeView) GetShowExpanders() bool { + return gobool(C.gtk_tree_view_get_show_expanders(v.native())) +} + +// SetLevelIndentation is a wrapper around gtk_tree_view_set_level_indentation(). +func (v *TreeView) SetLevelIndentation(indent int) { + C.gtk_tree_view_set_level_indentation(v.native(), C.gint(indent)) +} + +// SetShowExpanders is a wrapper around gtk_tree_view_set_show_expanders(). +func (v *TreeView) SetShowExpanders(show bool) { + C.gtk_tree_view_set_show_expanders(v.native(), gbool(show)) +} + +// GetHeadersVisible is a wrapper around gtk_tree_view_get_headers_visible(). +func (v *TreeView) GetHeadersVisible() bool { + return gobool(C.gtk_tree_view_get_headers_visible(v.native())) +} + +// SetHeadersVisible is a wrapper around gtk_tree_view_set_headers_visible(). +func (v *TreeView) SetHeadersVisible(show bool) { + C.gtk_tree_view_set_headers_visible(v.native(), gbool(show)) +} + +// ColumnsAutosize is a wrapper around gtk_tree_view_columns_autosize(). +func (v *TreeView) ColumnsAutosize() { + C.gtk_tree_view_columns_autosize(v.native()) +} + +// GetHeadersClickable is a wrapper around gtk_tree_view_get_headers_clickable(). +func (v *TreeView) GetHeadersClickable() bool { + return gobool(C.gtk_tree_view_get_headers_clickable(v.native())) +} + +// SetHeadersClickable is a wrapper around gtk_tree_view_set_headers_clickable(). +func (v *TreeView) SetHeadersClickable(show bool) { + C.gtk_tree_view_set_headers_clickable(v.native(), gbool(show)) +} + +// GetActivateOnSingleClick is a wrapper around gtk_tree_view_get_activate_on_single_click(). +func (v *TreeView) GetActivateOnSingleClick() bool { + return gobool(C.gtk_tree_view_get_activate_on_single_click(v.native())) +} + +// SetActivateOnSingleClick is a wrapper around gtk_tree_view_set_activate_on_single_click(). +func (v *TreeView) SetActivateOnSingleClick(show bool) { + C.gtk_tree_view_set_activate_on_single_click(v.native(), gbool(show)) +} + +// RemoveColumn() is a wrapper around gtk_tree_view_remove_column(). +func (v *TreeView) RemoveColumn(column *TreeViewColumn) int { + return int(C.gtk_tree_view_remove_column(v.native(), column.native())) +} + +// InsertColumn() is a wrapper around gtk_tree_view_insert_column(). +func (v *TreeView) InsertColumn(column *TreeViewColumn, pos int) int { + return int(C.gtk_tree_view_insert_column(v.native(), column.native(), C.gint(pos))) +} + +// GetNColumns() is a wrapper around gtk_tree_view_get_n_columns(). +func (v *TreeView) GetNColumns() uint { + return uint(C.gtk_tree_view_get_n_columns(v.native())) +} + +// GetColumn() is a wrapper around gtk_tree_view_get_column(). +func (v *TreeView) GetColumn(n int) *TreeViewColumn { + c := C.gtk_tree_view_get_column(v.native(), C.gint(n)) + if c == nil { + return nil + } + return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))) +} + +// MoveColumnAfter() is a wrapper around gtk_tree_view_move_column_after(). +func (v *TreeView) MoveColumnAfter(column *TreeViewColumn, baseColumn *TreeViewColumn) { + C.gtk_tree_view_move_column_after(v.native(), column.native(), baseColumn.native()) +} + +// SetExpanderColumn() is a wrapper around gtk_tree_view_set_expander_column(). +func (v *TreeView) SetExpanderColumn(column *TreeViewColumn) { + C.gtk_tree_view_set_expander_column(v.native(), column.native()) +} + +// GetExpanderColumn() is a wrapper around gtk_tree_view_get_expander_column(). +func (v *TreeView) GetExpanderColumn() *TreeViewColumn { + c := C.gtk_tree_view_get_expander_column(v.native()) + if c == nil { + return nil + } + return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))) +} + +// ScrollToPoint() is a wrapper around gtk_tree_view_scroll_to_point(). +func (v *TreeView) ScrollToPoint(treeX, treeY int) { + C.gtk_tree_view_scroll_to_point(v.native(), C.gint(treeX), C.gint(treeY)) +} + +// SetCursor() is a wrapper around gtk_tree_view_set_cursor(). +func (v *TreeView) SetCursor(path *TreePath, focusColumn *TreeViewColumn, startEditing bool) { + C.gtk_tree_view_set_cursor(v.native(), path.native(), focusColumn.native(), gbool(startEditing)) +} + +// SetCursorOnCell() is a wrapper around gtk_tree_view_set_cursor_on_cell(). +func (v *TreeView) SetCursorOnCell(path *TreePath, focusColumn *TreeViewColumn, focusCell *CellRenderer, startEditing bool) { + C.gtk_tree_view_set_cursor_on_cell(v.native(), path.native(), focusColumn.native(), focusCell.native(), gbool(startEditing)) +} + +// GetCursor() is a wrapper around gtk_tree_view_get_cursor(). +func (v *TreeView) GetCursor() (p *TreePath, c *TreeViewColumn) { + var path *C.GtkTreePath + var col *C.GtkTreeViewColumn + + C.gtk_tree_view_get_cursor(v.native(), &path, &col) + + if path != nil { + p = &TreePath{path} + runtime.SetFinalizer(p, (*TreePath).free) + } + + if col != nil { + c = wrapTreeViewColumn(wrapObject(unsafe.Pointer(col))) + } + + return +} + +// RowActivated() is a wrapper around gtk_tree_view_row_activated(). +func (v *TreeView) RowActivated(path *TreePath, column *TreeViewColumn) { + C.gtk_tree_view_row_activated(v.native(), path.native(), column.native()) +} + +// ExpandAll() is a wrapper around gtk_tree_view_expand_all(). +func (v *TreeView) ExpandAll() { + C.gtk_tree_view_expand_all(v.native()) +} + +// CollapseAll() is a wrapper around gtk_tree_view_collapse_all(). +func (v *TreeView) CollapseAll() { + C.gtk_tree_view_collapse_all(v.native()) +} + +// ExpandToPath() is a wrapper around gtk_tree_view_expand_to_path(). +func (v *TreeView) ExpandToPath(path *TreePath) { + C.gtk_tree_view_expand_to_path(v.native(), path.native()) +} + +// ExpandRow() is a wrapper around gtk_tree_view_expand_row(). +func (v *TreeView) ExpandRow(path *TreePath, openAll bool) bool { + return gobool(C.gtk_tree_view_expand_row(v.native(), path.native(), gbool(openAll))) +} + +// CollapseRow() is a wrapper around gtk_tree_view_collapse_row(). +func (v *TreeView) CollapseRow(path *TreePath) bool { + return gobool(C.gtk_tree_view_collapse_row(v.native(), path.native())) +} + +// RowExpanded() is a wrapper around gtk_tree_view_row_expanded(). +func (v *TreeView) RowExpanded(path *TreePath) bool { + return gobool(C.gtk_tree_view_row_expanded(v.native(), path.native())) +} + +// SetReorderable is a wrapper around gtk_tree_view_set_reorderable(). +func (v *TreeView) SetReorderable(b bool) { + C.gtk_tree_view_set_reorderable(v.native(), gbool(b)) +} + +// GetReorderable() is a wrapper around gtk_tree_view_get_reorderable(). +func (v *TreeView) GetReorderable() bool { + return gobool(C.gtk_tree_view_get_reorderable(v.native())) +} + +// GetBinWindow() is a wrapper around gtk_tree_view_get_bin_window(). +func (v *TreeView) GetBinWindow() *gdk.Window { + c := C.gtk_tree_view_get_bin_window(v.native()) + if c == nil { + return nil + } + + w := &gdk.Window{wrapObject(unsafe.Pointer(c))} + return w +} + +// SetEnableSearch is a wrapper around gtk_tree_view_set_enable_search(). +func (v *TreeView) SetEnableSearch(b bool) { + C.gtk_tree_view_set_enable_search(v.native(), gbool(b)) +} + +// GetEnableSearch() is a wrapper around gtk_tree_view_get_enable_search(). +func (v *TreeView) GetEnableSearch() bool { + return gobool(C.gtk_tree_view_get_enable_search(v.native())) +} + +// SetSearchColumn is a wrapper around gtk_tree_view_set_search_column(). +func (v *TreeView) SetSearchColumn(c int) { + C.gtk_tree_view_set_search_column(v.native(), C.gint(c)) +} + +// GetSearchColumn() is a wrapper around gtk_tree_view_get_search_column(). +func (v *TreeView) GetSearchColumn() int { + return int(C.gtk_tree_view_get_search_column(v.native())) +} + +// GetSearchEntry() is a wrapper around gtk_tree_view_get_search_entry(). +func (v *TreeView) GetSearchEntry() *Entry { + c := C.gtk_tree_view_get_search_entry(v.native()) + if c == nil { + return nil + } + return wrapEntry(wrapObject(unsafe.Pointer(c))) +} + +// SetSearchEntry() is a wrapper around gtk_tree_view_set_search_entry(). +func (v *TreeView) SetSearchEntry(e *Entry) { + C.gtk_tree_view_set_search_entry(v.native(), e.native()) +} + +// SetFixedHeightMode is a wrapper around gtk_tree_view_set_fixed_height_mode(). +func (v *TreeView) SetFixedHeightMode(b bool) { + C.gtk_tree_view_set_fixed_height_mode(v.native(), gbool(b)) +} + +// GetFixedHeightMode() is a wrapper around gtk_tree_view_get_fixed_height_mode(). +func (v *TreeView) GetFixedHeightMode() bool { + return gobool(C.gtk_tree_view_get_fixed_height_mode(v.native())) +} + +// SetHoverSelection is a wrapper around gtk_tree_view_set_hover_selection(). +func (v *TreeView) SetHoverSelection(b bool) { + C.gtk_tree_view_set_hover_selection(v.native(), gbool(b)) +} + +// GetHoverSelection() is a wrapper around gtk_tree_view_get_hover_selection(). +func (v *TreeView) GetHoverSelection() bool { + return gobool(C.gtk_tree_view_get_hover_selection(v.native())) +} + +// SetHoverExpand is a wrapper around gtk_tree_view_set_hover_expand(). +func (v *TreeView) SetHoverExpand(b bool) { + C.gtk_tree_view_set_hover_expand(v.native(), gbool(b)) +} + +// GetHoverExpand() is a wrapper around gtk_tree_view_get_hover_expand(). +func (v *TreeView) GetHoverExpand() bool { + return gobool(C.gtk_tree_view_get_hover_expand(v.native())) +} + +// SetRubberBanding is a wrapper around gtk_tree_view_set_rubber_banding(). +func (v *TreeView) SetRubberBanding(b bool) { + C.gtk_tree_view_set_rubber_banding(v.native(), gbool(b)) +} + +// GetRubberBanding() is a wrapper around gtk_tree_view_get_rubber_banding(). +func (v *TreeView) GetRubberBanding() bool { + return gobool(C.gtk_tree_view_get_rubber_banding(v.native())) +} + +// IsRubberBandingActive() is a wrapper around gtk_tree_view_is_rubber_banding_active(). +func (v *TreeView) IsRubberBandingActive() bool { + return gobool(C.gtk_tree_view_is_rubber_banding_active(v.native())) +} + +// SetEnableTreeLines is a wrapper around gtk_tree_view_set_enable_tree_lines(). +func (v *TreeView) SetEnableTreeLines(b bool) { + C.gtk_tree_view_set_enable_tree_lines(v.native(), gbool(b)) +} + +// GetEnableTreeLines() is a wrapper around gtk_tree_view_get_enable_tree_lines(). +func (v *TreeView) GetEnableTreeLines() bool { + return gobool(C.gtk_tree_view_get_enable_tree_lines(v.native())) +} + +// GetTooltipColumn() is a wrapper around gtk_tree_view_get_tooltip_column(). +func (v *TreeView) GetTooltipColumn() int { + return int(C.gtk_tree_view_get_tooltip_column(v.native())) +} + +// SetTooltipColumn() is a wrapper around gtk_tree_view_set_tooltip_column(). +func (v *TreeView) SetTooltipColumn(c int) { + C.gtk_tree_view_set_tooltip_column(v.native(), C.gint(c)) +} + +// void gtk_tree_view_set_tooltip_row () +// void gtk_tree_view_set_tooltip_cell () +// gboolean gtk_tree_view_get_tooltip_context () +// void gtk_tree_view_set_grid_lines () +// GtkTreeViewGridLines gtk_tree_view_get_grid_lines () +// void (*GtkTreeDestroyCountFunc) () +// void gtk_tree_view_set_destroy_count_func () +// gboolean (*GtkTreeViewRowSeparatorFunc) () +// GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func () +// void gtk_tree_view_set_row_separator_func () +// void (*GtkTreeViewSearchPositionFunc) () +// GtkTreeViewSearchPositionFunc gtk_tree_view_get_search_position_func () +// void gtk_tree_view_set_search_position_func () +// void gtk_tree_view_set_search_equal_func () +// GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func () +// void gtk_tree_view_map_expanded_rows () +// GList * gtk_tree_view_get_columns () +// gint gtk_tree_view_insert_column_with_attributes () +// gint gtk_tree_view_insert_column_with_data_func () +// void gtk_tree_view_set_column_drag_function () +// void gtk_tree_view_scroll_to_cell () +// gboolean gtk_tree_view_is_blank_at_pos () +// void gtk_tree_view_get_cell_area () +// void gtk_tree_view_get_background_area () +// void gtk_tree_view_get_visible_rect () +// gboolean gtk_tree_view_get_visible_range () +// void gtk_tree_view_convert_bin_window_to_tree_coords () +// void gtk_tree_view_convert_bin_window_to_widget_coords () +// void gtk_tree_view_convert_tree_to_bin_window_coords () +// void gtk_tree_view_convert_tree_to_widget_coords () +// void gtk_tree_view_convert_widget_to_bin_window_coords () +// void gtk_tree_view_convert_widget_to_tree_coords () +// void gtk_tree_view_enable_model_drag_dest () +// void gtk_tree_view_enable_model_drag_source () +// void gtk_tree_view_unset_rows_drag_source () +// void gtk_tree_view_unset_rows_drag_dest () +// void gtk_tree_view_set_drag_dest_row () +// void gtk_tree_view_get_drag_dest_row () +// gboolean gtk_tree_view_get_dest_row_at_pos () +// cairo_surface_t * gtk_tree_view_create_row_drag_icon () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view_column.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view_column.go new file mode 100644 index 0000000..7e6fde7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/tree_view_column.go @@ -0,0 +1,265 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +/* + * GtkTreeViewColumn + */ + +// TreeViewColumns is a representation of GTK's GtkTreeViewColumn. +type TreeViewColumn struct { + glib.InitiallyUnowned +} + +// native returns a pointer to the underlying GtkTreeViewColumn. +func (v *TreeViewColumn) native() *C.GtkTreeViewColumn { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkTreeViewColumn(p) +} + +func marshalTreeViewColumn(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapTreeViewColumn(obj), nil +} + +func wrapTreeViewColumn(obj *glib.Object) *TreeViewColumn { + return &TreeViewColumn{glib.InitiallyUnowned{obj}} +} + +// TreeViewColumnNew() is a wrapper around gtk_tree_view_column_new(). +func TreeViewColumnNew() (*TreeViewColumn, error) { + c := C.gtk_tree_view_column_new() + if c == nil { + return nil, nilPtrErr + } + return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil +} + +// TreeViewColumnNewWithAttribute() is a wrapper around +// gtk_tree_view_column_new_with_attributes() that only sets one +// attribute for one column. +func TreeViewColumnNewWithAttribute(title string, renderer ICellRenderer, attribute string, column int) (*TreeViewColumn, error) { + t_cstr := C.CString(title) + defer C.free(unsafe.Pointer(t_cstr)) + a_cstr := C.CString(attribute) + defer C.free(unsafe.Pointer(a_cstr)) + c := C._gtk_tree_view_column_new_with_attributes_one((*C.gchar)(t_cstr), + renderer.toCellRenderer(), (*C.gchar)(a_cstr), C.gint(column)) + if c == nil { + return nil, nilPtrErr + } + return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil +} + +// AddAttribute() is a wrapper around gtk_tree_view_column_add_attribute(). +func (v *TreeViewColumn) AddAttribute(renderer ICellRenderer, attribute string, column int) { + cstr := C.CString(attribute) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tree_view_column_add_attribute(v.native(), + renderer.toCellRenderer(), (*C.gchar)(cstr), C.gint(column)) +} + +// SetExpand() is a wrapper around gtk_tree_view_column_set_expand(). +func (v *TreeViewColumn) SetExpand(expand bool) { + C.gtk_tree_view_column_set_expand(v.native(), gbool(expand)) +} + +// GetExpand() is a wrapper around gtk_tree_view_column_get_expand(). +func (v *TreeViewColumn) GetExpand() bool { + c := C.gtk_tree_view_column_get_expand(v.native()) + return gobool(c) +} + +// SetMinWidth() is a wrapper around gtk_tree_view_column_set_min_width(). +func (v *TreeViewColumn) SetMinWidth(minWidth int) { + C.gtk_tree_view_column_set_min_width(v.native(), C.gint(minWidth)) +} + +// GetMinWidth() is a wrapper around gtk_tree_view_column_get_min_width(). +func (v *TreeViewColumn) GetMinWidth() int { + c := C.gtk_tree_view_column_get_min_width(v.native()) + return int(c) +} + +// PackStart() is a wrapper around gtk_tree_view_column_pack_start(). +func (v *TreeViewColumn) PackStart(cell *CellRenderer, expand bool) { + C.gtk_tree_view_column_pack_start(v.native(), cell.native(), gbool(expand)) +} + +// PackEnd() is a wrapper around gtk_tree_view_column_pack_end(). +func (v *TreeViewColumn) PackEnd(cell *CellRenderer, expand bool) { + C.gtk_tree_view_column_pack_end(v.native(), cell.native(), gbool(expand)) +} + +// Clear() is a wrapper around gtk_tree_view_column_clear(). +func (v *TreeViewColumn) Clear() { + C.gtk_tree_view_column_clear(v.native()) +} + +// ClearAttributes() is a wrapper around gtk_tree_view_column_clear_attributes(). +func (v *TreeViewColumn) ClearAttributes(cell *CellRenderer) { + C.gtk_tree_view_column_clear_attributes(v.native(), cell.native()) +} + +// SetSpacing() is a wrapper around gtk_tree_view_column_set_spacing(). +func (v *TreeViewColumn) SetSpacing(spacing int) { + C.gtk_tree_view_column_set_spacing(v.native(), C.gint(spacing)) +} + +// GetSpacing() is a wrapper around gtk_tree_view_column_get_spacing(). +func (v *TreeViewColumn) GetSpacing() int { + return int(C.gtk_tree_view_column_get_spacing(v.native())) +} + +// SetVisible() is a wrapper around gtk_tree_view_column_set_visible(). +func (v *TreeViewColumn) SetVisible(visible bool) { + C.gtk_tree_view_column_set_visible(v.native(), gbool(visible)) +} + +// GetVisible() is a wrapper around gtk_tree_view_column_get_visible(). +func (v *TreeViewColumn) GetVisible() bool { + return gobool(C.gtk_tree_view_column_get_visible(v.native())) +} + +// SetResizable() is a wrapper around gtk_tree_view_column_set_resizable(). +func (v *TreeViewColumn) SetResizable(resizable bool) { + C.gtk_tree_view_column_set_resizable(v.native(), gbool(resizable)) +} + +// GetResizable() is a wrapper around gtk_tree_view_column_get_resizable(). +func (v *TreeViewColumn) GetResizable() bool { + return gobool(C.gtk_tree_view_column_get_resizable(v.native())) +} + +// GetWidth() is a wrapper around gtk_tree_view_column_get_width(). +func (v *TreeViewColumn) GetWidth() int { + return int(C.gtk_tree_view_column_get_width(v.native())) +} + +// SetFixedWidth() is a wrapper around gtk_tree_view_column_set_fixed_width(). +func (v *TreeViewColumn) SetFixedWidth(w int) { + C.gtk_tree_view_column_set_fixed_width(v.native(), C.gint(w)) +} + +// GetFixedWidth() is a wrapper around gtk_tree_view_column_get_fixed_width(). +func (v *TreeViewColumn) GetFixedWidth() int { + return int(C.gtk_tree_view_column_get_fixed_width(v.native())) +} + +// SetMaxWidth() is a wrapper around gtk_tree_view_column_set_max_width(). +func (v *TreeViewColumn) SetMaxWidth(w int) { + C.gtk_tree_view_column_set_max_width(v.native(), C.gint(w)) +} + +// GetMaxWidth() is a wrapper around gtk_tree_view_column_get_max_width(). +func (v *TreeViewColumn) GetMaxWidth() int { + return int(C.gtk_tree_view_column_get_max_width(v.native())) +} + +// Clicked() is a wrapper around gtk_tree_view_column_clicked(). +func (v *TreeViewColumn) Clicked() { + C.gtk_tree_view_column_clicked(v.native()) +} + +// SetTitle() is a wrapper around gtk_tree_view_column_set_title(). +func (v *TreeViewColumn) SetTitle(t string) { + cstr := (*C.gchar)(C.CString(t)) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_tree_view_column_set_title(v.native(), cstr) +} + +// GetTitle() is a wrapper around gtk_tree_view_column_get_title(). +func (v *TreeViewColumn) GetTitle() string { + return C.GoString((*C.char)(C.gtk_tree_view_column_get_title(v.native()))) +} + +// SetClickable() is a wrapper around gtk_tree_view_column_set_clickable(). +func (v *TreeViewColumn) SetClickable(clickable bool) { + C.gtk_tree_view_column_set_clickable(v.native(), gbool(clickable)) +} + +// GetClickable() is a wrapper around gtk_tree_view_column_get_clickable(). +func (v *TreeViewColumn) GetClickable() bool { + return gobool(C.gtk_tree_view_column_get_clickable(v.native())) +} + +// SetReorderable() is a wrapper around gtk_tree_view_column_set_reorderable(). +func (v *TreeViewColumn) SetReorderable(reorderable bool) { + C.gtk_tree_view_column_set_reorderable(v.native(), gbool(reorderable)) +} + +// GetReorderable() is a wrapper around gtk_tree_view_column_get_reorderable(). +func (v *TreeViewColumn) GetReorderable() bool { + return gobool(C.gtk_tree_view_column_get_reorderable(v.native())) +} + +// SetSortIndicator() is a wrapper around gtk_tree_view_column_set_sort_indicator(). +func (v *TreeViewColumn) SetSortIndicator(reorderable bool) { + C.gtk_tree_view_column_set_sort_indicator(v.native(), gbool(reorderable)) +} + +// GetSortIndicator() is a wrapper around gtk_tree_view_column_get_sort_indicator(). +func (v *TreeViewColumn) GetSortIndicator() bool { + return gobool(C.gtk_tree_view_column_get_sort_indicator(v.native())) +} + +// SetSortColumnID() is a wrapper around gtk_tree_view_column_set_sort_column_id(). +func (v *TreeViewColumn) SetSortColumnID(w int) { + C.gtk_tree_view_column_set_sort_column_id(v.native(), C.gint(w)) +} + +// GetSortColumnID() is a wrapper around gtk_tree_view_column_get_sort_column_id(). +func (v *TreeViewColumn) GetSortColumnID() int { + return int(C.gtk_tree_view_column_get_sort_column_id(v.native())) +} + +// CellIsVisible() is a wrapper around gtk_tree_view_column_cell_is_visible(). +func (v *TreeViewColumn) CellIsVisible() bool { + return gobool(C.gtk_tree_view_column_cell_is_visible(v.native())) +} + +// FocusCell() is a wrapper around gtk_tree_view_column_focus_cell(). +func (v *TreeViewColumn) FocusCell(cell *CellRenderer) { + C.gtk_tree_view_column_focus_cell(v.native(), cell.native()) +} + +// QueueResize() is a wrapper around gtk_tree_view_column_queue_resize(). +func (v *TreeViewColumn) QueueResize() { + C.gtk_tree_view_column_queue_resize(v.native()) +} + +// GetXOffset() is a wrapper around gtk_tree_view_column_get_x_offset(). +func (v *TreeViewColumn) GetXOffset() int { + return int(C.gtk_tree_view_column_get_x_offset(v.native())) +} + +// GtkTreeViewColumn * gtk_tree_view_column_new_with_area () +// void gtk_tree_view_column_set_attributes () +// void gtk_tree_view_column_set_cell_data_func () +// void gtk_tree_view_column_set_sizing () +// GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing () +// void gtk_tree_view_column_set_widget () +// GtkWidget * gtk_tree_view_column_get_widget () +// GtkWidget * gtk_tree_view_column_get_button () +// void gtk_tree_view_column_set_alignment () +// gfloat gtk_tree_view_column_get_alignment () +// void gtk_tree_view_column_set_sort_order () +// GtkSortType gtk_tree_view_column_get_sort_order () +// void gtk_tree_view_column_cell_set_cell_data () +// void gtk_tree_view_column_cell_get_size () +// gboolean gtk_tree_view_column_cell_get_position () +// GtkWidget * gtk_tree_view_column_get_tree_view () diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/version.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/version.go new file mode 100644 index 0000000..07fdbd9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/version.go @@ -0,0 +1,30 @@ +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +import "C" +import "errors" + +func CheckVersion(major, minor, micro uint) error { + errChar := C.gtk_check_version(C.guint(major), C.guint(minor), C.guint(micro)) + if errChar == nil { + return nil + } + + return errors.New(C.GoString((*C.char)(errChar))) +} + +func GetMajorVersion() uint { + v := C.gtk_get_major_version() + return uint(v) +} + +func GetMinorVersion() uint { + v := C.gtk_get_minor_version() + return uint(v) +} + +func GetMicroVersion() uint { + v := C.gtk_get_micro_version() + return uint(v) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget.go new file mode 100644 index 0000000..2cfd2ce --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget.go @@ -0,0 +1,612 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "errors" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +/* + * GtkWidget + */ + +// Widget is a representation of GTK's GtkWidget. +type Widget struct { + glib.InitiallyUnowned +} + +// IWidget is an interface type implemented by all structs +// embedding a Widget. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkWidget. +type IWidget interface { + toWidget() *C.GtkWidget + Set(string, interface{}) error +} + +type IWidgetable interface { + toWidget() *C.GtkWidget +} + +func nullableWidget(v IWidgetable) *C.GtkWidget { + if v == nil { + return nil + } + + return v.toWidget() +} + +// native returns a pointer to the underlying GtkWidget. +func (v *Widget) native() *C.GtkWidget { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkWidget(p) +} + +func (v *Widget) toWidget() *C.GtkWidget { + if v == nil { + return nil + } + return v.native() +} + +func marshalWidget(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj), nil +} + +func wrapWidget(obj *glib.Object) *Widget { + return &Widget{glib.InitiallyUnowned{obj}} +} + +// Destroy is a wrapper around gtk_widget_destroy(). +func (v *Widget) Destroy() { + C.gtk_widget_destroy(v.native()) +} + +func (v *Widget) HideOnDelete() { + C._gtk_widget_hide_on_delete(v.native()) +} + +/* TODO +func (v *Widget) DragDestSet(flags DestDefaults, targets []TargetEntry, actions gdk.DragAction) { + C.gtk_drag_dest_set(v.native(), C.GtkDestDefaults(flags), (*C.GtkTargetEntry)(&targets[0]), + C.gint(len(targets)), C.GdkDragAction(actions)) +} +*/ + +// ResetStyle is a wrapper around gtk_widget_reset_style(). +func (v *Widget) ResetStyle() { + C.gtk_widget_reset_style(v.native()) +} + +// InDestruction is a wrapper around gtk_widget_in_destruction(). +func (v *Widget) InDestruction() bool { + return gobool(C.gtk_widget_in_destruction(v.native())) +} + +// TODO(jrick) this may require some rethinking +/* +func (v *Widget) Destroyed(widgetPointer **Widget) { +} +*/ + +// Unparent is a wrapper around gtk_widget_unparent(). +func (v *Widget) Unparent() { + C.gtk_widget_unparent(v.native()) +} + +// Show is a wrapper around gtk_widget_show(). +func (v *Widget) Show() { + C.gtk_widget_show(v.native()) +} + +// Hide is a wrapper around gtk_widget_hide(). +func (v *Widget) Hide() { + C.gtk_widget_hide(v.native()) +} + +// GetCanFocus is a wrapper around gtk_widget_get_can_focus(). +func (v *Widget) GetCanFocus() bool { + c := C.gtk_widget_get_can_focus(v.native()) + return gobool(c) +} + +// SetCanFocus is a wrapper around gtk_widget_set_can_focus(). +func (v *Widget) SetCanFocus(canFocus bool) { + C.gtk_widget_set_can_focus(v.native(), gbool(canFocus)) +} + +// GetCanDefault is a wrapper around gtk_widget_get_can_default(). +func (v *Widget) GetCanDefault() bool { + c := C.gtk_widget_get_can_default(v.native()) + return gobool(c) +} + +// SetCanDefault is a wrapper around gtk_widget_set_can_default(). +func (v *Widget) SetCanDefault(canDefault bool) { + C.gtk_widget_set_can_default(v.native(), gbool(canDefault)) +} + +// GetMapped is a wrapper around gtk_widget_get_mapped(). +func (v *Widget) GetMapped() bool { + c := C.gtk_widget_get_mapped(v.native()) + return gobool(c) +} + +// SetMapped is a wrapper around gtk_widget_set_mapped(). +func (v *Widget) SetMapped(mapped bool) { + C.gtk_widget_set_can_focus(v.native(), gbool(mapped)) +} + +// GetRealized is a wrapper around gtk_widget_get_realized(). +func (v *Widget) GetRealized() bool { + c := C.gtk_widget_get_realized(v.native()) + return gobool(c) +} + +// SetRealized is a wrapper around gtk_widget_set_realized(). +func (v *Widget) SetRealized(realized bool) { + C.gtk_widget_set_realized(v.native(), gbool(realized)) +} + +// GetHasWindow is a wrapper around gtk_widget_get_has_window(). +func (v *Widget) GetHasWindow() bool { + c := C.gtk_widget_get_has_window(v.native()) + return gobool(c) +} + +// SetHasWindow is a wrapper around gtk_widget_set_has_window(). +func (v *Widget) SetHasWindow(hasWindow bool) { + C.gtk_widget_set_has_window(v.native(), gbool(hasWindow)) +} + +// ShowNow is a wrapper around gtk_widget_show_now(). +func (v *Widget) ShowNow() { + C.gtk_widget_show_now(v.native()) +} + +// ShowAll is a wrapper around gtk_widget_show_all(). +func (v *Widget) ShowAll() { + C.gtk_widget_show_all(v.native()) +} + +// SetNoShowAll is a wrapper around gtk_widget_set_no_show_all(). +func (v *Widget) SetNoShowAll(noShowAll bool) { + C.gtk_widget_set_no_show_all(v.native(), gbool(noShowAll)) +} + +// GetNoShowAll is a wrapper around gtk_widget_get_no_show_all(). +func (v *Widget) GetNoShowAll() bool { + c := C.gtk_widget_get_no_show_all(v.native()) + return gobool(c) +} + +// Map is a wrapper around gtk_widget_map(). +func (v *Widget) Map() { + C.gtk_widget_map(v.native()) +} + +// Unmap is a wrapper around gtk_widget_unmap(). +func (v *Widget) Unmap() { + C.gtk_widget_unmap(v.native()) +} + +// QueueDrawArea is a wrapper aroung gtk_widget_queue_draw_area(). +func (v *Widget) QueueDrawArea(x, y, w, h int) { + C.gtk_widget_queue_draw_area(v.native(), C.gint(x), C.gint(y), C.gint(w), C.gint(h)) +} + +//void gtk_widget_realize(GtkWidget *widget); +//void gtk_widget_unrealize(GtkWidget *widget); +//void gtk_widget_draw(GtkWidget *widget, cairo_t *cr); +//void gtk_widget_queue_resize(GtkWidget *widget); +//void gtk_widget_queue_resize_no_redraw(GtkWidget *widget); +//GdkFrameClock *gtk_widget_get_frame_clock(GtkWidget *widget); +//guint gtk_widget_add_tick_callback (GtkWidget *widget, +// GtkTickCallback callback, +// gpointer user_data, +// GDestroyNotify notify); +//void gtk_widget_remove_tick_callback(GtkWidget *widget, guint id); + +// TODO(jrick) GtkAllocation +/* +func (v *Widget) SizeAllocate() { +} +*/ + +// Allocation is a representation of GTK's GtkAllocation type. +type Allocation struct { + gdk.Rectangle +} + +// Native returns a pointer to the underlying GtkAllocation. +func (v *Allocation) native() *C.GtkAllocation { + return (*C.GtkAllocation)(unsafe.Pointer(&v.GdkRectangle)) +} + +// GetAllocatedWidth() is a wrapper around gtk_widget_get_allocated_width(). +func (v *Widget) GetAllocatedWidth() int { + return int(C.gtk_widget_get_allocated_width(v.native())) +} + +// GetAllocatedHeight() is a wrapper around gtk_widget_get_allocated_height(). +func (v *Widget) GetAllocatedHeight() int { + return int(C.gtk_widget_get_allocated_height(v.native())) +} + +// Event() is a wrapper around gtk_widget_event(). +func (v *Widget) Event(event *gdk.Event) bool { + c := C.gtk_widget_event(v.native(), + (*C.GdkEvent)(unsafe.Pointer(event.Native()))) + return gobool(c) +} + +// Activate() is a wrapper around gtk_widget_activate(). +func (v *Widget) Activate() bool { + return gobool(C.gtk_widget_activate(v.native())) +} + +// TODO(jrick) GdkRectangle +/* +func (v *Widget) Intersect() { +} +*/ + +// IsFocus() is a wrapper around gtk_widget_is_focus(). +func (v *Widget) IsFocus() bool { + return gobool(C.gtk_widget_is_focus(v.native())) +} + +// GrabFocus() is a wrapper around gtk_widget_grab_focus(). +func (v *Widget) GrabFocus() { + C.gtk_widget_grab_focus(v.native()) +} + +// GrabDefault() is a wrapper around gtk_widget_grab_default(). +func (v *Widget) GrabDefault() { + C.gtk_widget_grab_default(v.native()) +} + +// SetName() is a wrapper around gtk_widget_set_name(). +func (v *Widget) SetName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_widget_set_name(v.native(), (*C.gchar)(cstr)) +} + +// GetName() is a wrapper around gtk_widget_get_name(). A non-nil +// error is returned in the case that gtk_widget_get_name returns NULL to +// differentiate between NULL and an empty string. +func (v *Widget) GetName() (string, error) { + c := C.gtk_widget_get_name(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// GetSensitive is a wrapper around gtk_widget_get_sensitive(). +func (v *Widget) GetSensitive() bool { + c := C.gtk_widget_get_sensitive(v.native()) + return gobool(c) +} + +// IsSensitive is a wrapper around gtk_widget_is_sensitive(). +func (v *Widget) IsSensitive() bool { + c := C.gtk_widget_is_sensitive(v.native()) + return gobool(c) +} + +// SetSensitive is a wrapper around gtk_widget_set_sensitive(). +func (v *Widget) SetSensitive(sensitive bool) { + C.gtk_widget_set_sensitive(v.native(), gbool(sensitive)) +} + +// GetVisible is a wrapper around gtk_widget_get_visible(). +func (v *Widget) GetVisible() bool { + c := C.gtk_widget_get_visible(v.native()) + return gobool(c) +} + +// SetVisible is a wrapper around gtk_widget_set_visible(). +func (v *Widget) SetVisible(visible bool) { + C.gtk_widget_set_visible(v.native(), gbool(visible)) +} + +// SetParent is a wrapper around gtk_widget_set_parent(). +func (v *Widget) SetParent(parent IWidget) { + C.gtk_widget_set_parent(v.native(), parent.toWidget()) +} + +// GetParent is a wrapper around gtk_widget_get_parent(). +func (v *Widget) GetParent() (*Widget, error) { + c := C.gtk_widget_get_parent(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// SetSizeRequest is a wrapper around gtk_widget_set_size_request(). +func (v *Widget) SetSizeRequest(width, height int) { + C.gtk_widget_set_size_request(v.native(), C.gint(width), C.gint(height)) +} + +// GetSizeRequest is a wrapper around gtk_widget_get_size_request(). +func (v *Widget) GetSizeRequest() (width, height int) { + var w, h C.gint + C.gtk_widget_get_size_request(v.native(), &w, &h) + return int(w), int(h) +} + +// SetParentWindow is a wrapper around gtk_widget_set_parent_window(). +func (v *Widget) SetParentWindow(parentWindow *gdk.Window) { + C.gtk_widget_set_parent_window(v.native(), + (*C.GdkWindow)(unsafe.Pointer(parentWindow.Native()))) +} + +// GetParentWindow is a wrapper around gtk_widget_get_parent_window(). +func (v *Widget) GetParentWindow() (*gdk.Window, error) { + c := C.gtk_widget_get_parent_window(v.native()) + if v == nil { + return nil, nilPtrErr + } + + w := &gdk.Window{wrapObject(unsafe.Pointer(c))} + return w, nil +} + +// SetEvents is a wrapper around gtk_widget_set_events(). +func (v *Widget) SetEvents(events int) { + C.gtk_widget_set_events(v.native(), C.gint(events)) +} + +// GetEvents is a wrapper around gtk_widget_get_events(). +func (v *Widget) GetEvents() int { + return int(C.gtk_widget_get_events(v.native())) +} + +// AddEvents is a wrapper around gtk_widget_add_events(). +func (v *Widget) AddEvents(events int) { + C.gtk_widget_add_events(v.native(), C.gint(events)) +} + +// HasDefault is a wrapper around gtk_widget_has_default(). +func (v *Widget) HasDefault() bool { + c := C.gtk_widget_has_default(v.native()) + return gobool(c) +} + +// HasFocus is a wrapper around gtk_widget_has_focus(). +func (v *Widget) HasFocus() bool { + c := C.gtk_widget_has_focus(v.native()) + return gobool(c) +} + +// HasVisibleFocus is a wrapper around gtk_widget_has_visible_focus(). +func (v *Widget) HasVisibleFocus() bool { + c := C.gtk_widget_has_visible_focus(v.native()) + return gobool(c) +} + +// HasGrab is a wrapper around gtk_widget_has_grab(). +func (v *Widget) HasGrab() bool { + c := C.gtk_widget_has_grab(v.native()) + return gobool(c) +} + +// IsDrawable is a wrapper around gtk_widget_is_drawable(). +func (v *Widget) IsDrawable() bool { + c := C.gtk_widget_is_drawable(v.native()) + return gobool(c) +} + +// IsToplevel is a wrapper around gtk_widget_is_toplevel(). +func (v *Widget) IsToplevel() bool { + c := C.gtk_widget_is_toplevel(v.native()) + return gobool(c) +} + +// TODO(jrick) GdkEventMask +/* +func (v *Widget) SetDeviceEvents() { +} +*/ + +// TODO(jrick) GdkEventMask +/* +func (v *Widget) GetDeviceEvents() { +} +*/ + +// TODO(jrick) GdkEventMask +/* +func (v *Widget) AddDeviceEvents() { +} +*/ + +// SetDeviceEnabled is a wrapper around gtk_widget_set_device_enabled(). +func (v *Widget) SetDeviceEnabled(device *gdk.Device, enabled bool) { + C.gtk_widget_set_device_enabled(v.native(), + (*C.GdkDevice)(unsafe.Pointer(device.Native())), gbool(enabled)) +} + +// GetDeviceEnabled is a wrapper around gtk_widget_get_device_enabled(). +func (v *Widget) GetDeviceEnabled(device *gdk.Device) bool { + c := C.gtk_widget_get_device_enabled(v.native(), + (*C.GdkDevice)(unsafe.Pointer(device.Native()))) + return gobool(c) +} + +// GetToplevel is a wrapper around gtk_widget_get_toplevel(). +func (v *Widget) GetToplevel() (*Widget, error) { + c := C.gtk_widget_get_toplevel(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetTooltipText is a wrapper around gtk_widget_get_tooltip_text(). +// A non-nil error is returned in the case that +// gtk_widget_get_tooltip_text returns NULL to differentiate between NULL +// and an empty string. +func (v *Widget) GetTooltipText() (string, error) { + c := C.gtk_widget_get_tooltip_text(v.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// SetTooltipText is a wrapper around gtk_widget_set_tooltip_text(). +func (v *Widget) SetTooltipText(text string) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_widget_set_tooltip_text(v.native(), (*C.gchar)(cstr)) +} + +// GetHAlign is a wrapper around gtk_widget_get_halign(). +func (v *Widget) GetHAlign() Align { + c := C.gtk_widget_get_halign(v.native()) + return Align(c) +} + +// SetHAlign is a wrapper around gtk_widget_set_halign(). +func (v *Widget) SetHAlign(align Align) { + C.gtk_widget_set_halign(v.native(), C.GtkAlign(align)) +} + +// GetVAlign is a wrapper around gtk_widget_get_valign(). +func (v *Widget) GetVAlign() Align { + c := C.gtk_widget_get_valign(v.native()) + return Align(c) +} + +// SetVAlign is a wrapper around gtk_widget_set_valign(). +func (v *Widget) SetVAlign(align Align) { + C.gtk_widget_set_valign(v.native(), C.GtkAlign(align)) +} + +// GetMarginTop is a wrapper around gtk_widget_get_margin_top(). +func (v *Widget) GetMarginTop() int { + c := C.gtk_widget_get_margin_top(v.native()) + return int(c) +} + +// SetMarginTop is a wrapper around gtk_widget_set_margin_top(). +func (v *Widget) SetMarginTop(margin int) { + C.gtk_widget_set_margin_top(v.native(), C.gint(margin)) +} + +// GetMarginBottom is a wrapper around gtk_widget_get_margin_bottom(). +func (v *Widget) GetMarginBottom() int { + c := C.gtk_widget_get_margin_bottom(v.native()) + return int(c) +} + +// SetMarginBottom is a wrapper around gtk_widget_set_margin_bottom(). +func (v *Widget) SetMarginBottom(margin int) { + C.gtk_widget_set_margin_bottom(v.native(), C.gint(margin)) +} + +// GetHExpand is a wrapper around gtk_widget_get_hexpand(). +func (v *Widget) GetHExpand() bool { + c := C.gtk_widget_get_hexpand(v.native()) + return gobool(c) +} + +// SetHExpand is a wrapper around gtk_widget_set_hexpand(). +func (v *Widget) SetHExpand(expand bool) { + C.gtk_widget_set_hexpand(v.native(), gbool(expand)) +} + +// GetVExpand is a wrapper around gtk_widget_get_vexpand(). +func (v *Widget) GetVExpand() bool { + c := C.gtk_widget_get_vexpand(v.native()) + return gobool(c) +} + +// SetVExpand is a wrapper around gtk_widget_set_vexpand(). +func (v *Widget) SetVExpand(expand bool) { + C.gtk_widget_set_vexpand(v.native(), gbool(expand)) +} + +// TranslateCoordinates is a wrapper around gtk_widget_translate_coordinates(). +func (v *Widget) TranslateCoordinates(dest IWidget, srcX, srcY int) (destX, destY int, e error) { + cdest := nullableWidget(dest) + + var cdestX, cdestY C.gint + c := C.gtk_widget_translate_coordinates(v.native(), cdest, C.gint(srcX), C.gint(srcY), &cdestX, &cdestY) + if !gobool(c) { + return 0, 0, errors.New("translate coordinates failed") + } + return int(cdestX), int(cdestY), nil +} + +// SetVisual is a wrapper around gtk_widget_set_visual(). +func (v *Widget) SetVisual(visual *gdk.Visual) { + C.gtk_widget_set_visual(v.native(), + (*C.GdkVisual)(unsafe.Pointer(visual.Native()))) +} + +// SetAppPaintable is a wrapper around gtk_widget_set_app_paintable(). +func (v *Widget) SetAppPaintable(paintable bool) { + C.gtk_widget_set_app_paintable(v.native(), gbool(paintable)) +} + +// GetAppPaintable is a wrapper around gtk_widget_get_app_paintable(). +func (v *Widget) GetAppPaintable() bool { + c := C.gtk_widget_get_app_paintable(v.native()) + return gobool(c) +} + +// QueueDraw is a wrapper around gtk_widget_queue_draw(). +func (v *Widget) QueueDraw() { + C.gtk_widget_queue_draw(v.native()) +} + +// GetAllocation is a wrapper around gtk_widget_get_allocation(). +func (v *Widget) GetAllocation() *Allocation { + var a Allocation + C.gtk_widget_get_allocation(v.native(), a.native()) + return &a +} + +// SetAllocation is a wrapper around gtk_widget_set_allocation(). +func (v *Widget) SetAllocation(allocation *Allocation) { + C.gtk_widget_set_allocation(v.native(), allocation.native()) +} + +// SizeAllocate is a wrapper around gtk_widget_size_allocate(). +func (v *Widget) SizeAllocate(allocation *Allocation) { + C.gtk_widget_size_allocate(v.native(), allocation.native()) +} + +// SetStateFlags is a wrapper around gtk_widget_set_state_flags(). +func (v *Widget) SetStateFlags(stateFlags StateFlags, clear bool) { + C.gtk_widget_set_state_flags(v.native(), C.GtkStateFlags(stateFlags), gbool(clear)) +} + +// GetWindow is a wrapper around gtk_widget_get_window(). +func (v *Widget) GetWindow() (*gdk.Window, error) { + c := C.gtk_widget_get_window(v.native()) + if c == nil { + return nil, nilPtrErr + } + + w := &gdk.Window{wrapObject(unsafe.Pointer(c))} + return w, nil +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_12.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_12.go new file mode 100644 index 0000000..1bab6a2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_12.go @@ -0,0 +1,46 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +import "C" + +func (v *Widget) SetMarginStart(margin int) { + C.gtk_widget_set_margin_start(v.native(), C.gint(margin)) +} + +func (v *Widget) GetMarginStart() int { + c := C.gtk_widget_get_margin_start(v.native()) + return int(c) +} + +func (v *Widget) SetMarginEnd(margin int) { + C.gtk_widget_set_margin_end(v.native(), C.gint(margin)) +} + +func (v *Widget) GetMarginEnd() int { + c := C.gtk_widget_get_margin_end(v.native()) + return int(c) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_8.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_8.go new file mode 100644 index 0000000..c518764 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/widget_since_3_8.go @@ -0,0 +1,38 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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 +import "C" + +/* + * GtkWidget + */ + +// IsVisible is a wrapper around gtk_widget_is_visible(). +func (v *Widget) IsVisible() bool { + c := C.gtk_widget_is_visible(v.native()) + return gobool(c) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window.go new file mode 100644 index 0000000..6b8d0ca --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window.go @@ -0,0 +1,610 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "errors" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gdk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +/* + * GtkWindow + */ + +// Window is a representation of GTK's GtkWindow. +type Window struct { + Bin +} + +// IWindow is an interface type implemented by all structs embedding a +// Window. It is meant to be used as an argument type for wrapper +// functions that wrap around a C GTK function taking a GtkWindow. +type IWindow interface { + toWindow() *C.GtkWindow +} + +// native returns a pointer to the underlying GtkWindow. +func (v *Window) native() *C.GtkWindow { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkWindow(p) +} + +func (v *Window) toWindow() *C.GtkWindow { + if v == nil { + return nil + } + return v.native() +} + +func marshalWindow(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapWindow(obj), nil +} + +func wrapWindow(obj *glib.Object) *Window { + return &Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// WindowNew is a wrapper around gtk_window_new(). +func WindowNew(t WindowType) (*Window, error) { + c := C.gtk_window_new(C.GtkWindowType(t)) + if c == nil { + return nil, nilPtrErr + } + return wrapWindow(wrapObject(unsafe.Pointer(c))), nil +} + +// SetTitle is a wrapper around gtk_window_set_title(). +func (v *Window) SetTitle(title string) { + cstr := C.CString(title) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_window_set_title(v.native(), (*C.gchar)(cstr)) +} + +// SetResizable is a wrapper around gtk_window_set_resizable(). +func (v *Window) SetResizable(resizable bool) { + C.gtk_window_set_resizable(v.native(), gbool(resizable)) +} + +// GetResizable is a wrapper around gtk_window_get_resizable(). +func (v *Window) GetResizable() bool { + c := C.gtk_window_get_resizable(v.native()) + return gobool(c) +} + +// ActivateFocus is a wrapper around gtk_window_activate_focus(). +func (v *Window) ActivateFocus() bool { + c := C.gtk_window_activate_focus(v.native()) + return gobool(c) +} + +// ActivateDefault is a wrapper around gtk_window_activate_default(). +func (v *Window) ActivateDefault() bool { + c := C.gtk_window_activate_default(v.native()) + return gobool(c) +} + +// SetModal is a wrapper around gtk_window_set_modal(). +func (v *Window) SetModal(modal bool) { + C.gtk_window_set_modal(v.native(), gbool(modal)) +} + +// SetDefaultSize is a wrapper around gtk_window_set_default_size(). +func (v *Window) SetDefaultSize(width, height int) { + C.gtk_window_set_default_size(v.native(), C.gint(width), C.gint(height)) +} + +// SetDefaultGeometry is a wrapper around gtk_window_set_default_geometry(). +func (v *Window) SetDefaultGeometry(width, height int) { + C.gtk_window_set_default_geometry(v.native(), C.gint(width), + C.gint(height)) +} + +// GetScreen is a wrapper around gtk_window_get_screen(). +func (v *Window) GetScreen() (*gdk.Screen, error) { + c := C.gtk_window_get_screen(v.native()) + if c == nil { + return nil, nilPtrErr + } + + s := &gdk.Screen{wrapObject(unsafe.Pointer(c))} + return s, nil +} + +// SetIcon is a wrapper around gtk_window_set_icon(). +func (v *Window) SetIcon(icon *gdk.Pixbuf) { + iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native())) + C.gtk_window_set_icon(v.native(), iconPtr) +} + +// WindowSetDefaultIcon is a wrapper around gtk_window_set_default_icon(). +func WindowSetDefaultIcon(icon *gdk.Pixbuf) { + iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native())) + C.gtk_window_set_default_icon(iconPtr) +} + +// TODO(jrick) GdkGeometry GdkWindowHints. +/* +func (v *Window) SetGeometryHints() { +} +*/ + +// TODO(jrick) GdkGravity. +/* +func (v *Window) SetGravity() { +} +*/ + +// TODO(jrick) GdkGravity. +/* +func (v *Window) GetGravity() { +} +*/ + +// SetPosition is a wrapper around gtk_window_set_position(). +func (v *Window) SetPosition(position WindowPosition) { + C.gtk_window_set_position(v.native(), C.GtkWindowPosition(position)) +} + +// SetTransientFor is a wrapper around gtk_window_set_transient_for(). +func (v *Window) SetTransientFor(parent IWindow) { + var pw *C.GtkWindow = nil + if parent != nil { + pw = parent.toWindow() + } + C.gtk_window_set_transient_for(v.native(), pw) +} + +// SetDestroyWithParent is a wrapper around +// gtk_window_set_destroy_with_parent(). +func (v *Window) SetDestroyWithParent(setting bool) { + C.gtk_window_set_destroy_with_parent(v.native(), gbool(setting)) +} + +// SetHideTitlebarWhenMaximized is a wrapper around +// gtk_window_set_hide_titlebar_when_maximized(). +func (v *Window) SetHideTitlebarWhenMaximized(setting bool) { + C.gtk_window_set_hide_titlebar_when_maximized(v.native(), + gbool(setting)) +} + +// IsActive is a wrapper around gtk_window_is_active(). +func (v *Window) IsActive() bool { + c := C.gtk_window_is_active(v.native()) + return gobool(c) +} + +// HasToplevelFocus is a wrapper around gtk_window_has_toplevel_focus(). +func (v *Window) HasToplevelFocus() bool { + c := C.gtk_window_has_toplevel_focus(v.native()) + return gobool(c) +} + +// GetFocus is a wrapper around gtk_window_get_focus(). +func (v *Window) GetFocus() (*Widget, error) { + c := C.gtk_window_get_focus(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// SetFocus is a wrapper around gtk_window_set_focus(). +func (v *Window) SetFocus(w *Widget) { + C.gtk_window_set_focus(v.native(), w.native()) +} + +// GetDefaultWidget is a wrapper arround gtk_window_get_default_widget(). +func (v *Window) GetDefaultWidget() *Widget { + c := C.gtk_window_get_default_widget(v.native()) + if c == nil { + return nil + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapWidget(obj) +} + +// SetDefault is a wrapper arround gtk_window_set_default(). +func (v *Window) SetDefault(widget IWidget) { + C.gtk_window_set_default(v.native(), widget.toWidget()) +} + +// Present is a wrapper around gtk_window_present(). +func (v *Window) Present() { + C.gtk_window_present(v.native()) +} + +// PresentWithTime is a wrapper around gtk_window_present_with_time(). +func (v *Window) PresentWithTime(ts uint32) { + C.gtk_window_present_with_time(v.native(), C.guint32(ts)) +} + +// Iconify is a wrapper around gtk_window_iconify(). +func (v *Window) Iconify() { + C.gtk_window_iconify(v.native()) +} + +// Deiconify is a wrapper around gtk_window_deiconify(). +func (v *Window) Deiconify() { + C.gtk_window_deiconify(v.native()) +} + +// Stick is a wrapper around gtk_window_stick(). +func (v *Window) Stick() { + C.gtk_window_stick(v.native()) +} + +// Unstick is a wrapper around gtk_window_unstick(). +func (v *Window) Unstick() { + C.gtk_window_unstick(v.native()) +} + +// Maximize is a wrapper around gtk_window_maximize(). +func (v *Window) Maximize() { + C.gtk_window_maximize(v.native()) +} + +// Unmaximize is a wrapper around gtk_window_unmaximize(). +func (v *Window) Unmaximize() { + C.gtk_window_unmaximize(v.native()) +} + +// Fullscreen is a wrapper around gtk_window_fullscreen(). +func (v *Window) Fullscreen() { + C.gtk_window_fullscreen(v.native()) +} + +// Unfullscreen is a wrapper around gtk_window_unfullscreen(). +func (v *Window) Unfullscreen() { + C.gtk_window_unfullscreen(v.native()) +} + +// SetKeepAbove is a wrapper around gtk_window_set_keep_above(). +func (v *Window) SetKeepAbove(setting bool) { + C.gtk_window_set_keep_above(v.native(), gbool(setting)) +} + +// SetKeepBelow is a wrapper around gtk_window_set_keep_below(). +func (v *Window) SetKeepBelow(setting bool) { + C.gtk_window_set_keep_below(v.native(), gbool(setting)) +} + +// SetDecorated is a wrapper around gtk_window_set_decorated(). +func (v *Window) SetDecorated(setting bool) { + C.gtk_window_set_decorated(v.native(), gbool(setting)) +} + +// SetDeletable is a wrapper around gtk_window_set_deletable(). +func (v *Window) SetDeletable(setting bool) { + C.gtk_window_set_deletable(v.native(), gbool(setting)) +} + +// SetSkipTaskbarHint is a wrapper around gtk_window_set_skip_taskbar_hint(). +func (v *Window) SetSkipTaskbarHint(setting bool) { + C.gtk_window_set_skip_taskbar_hint(v.native(), gbool(setting)) +} + +// SetSkipPagerHint is a wrapper around gtk_window_set_skip_pager_hint(). +func (v *Window) SetSkipPagerHint(setting bool) { + C.gtk_window_set_skip_pager_hint(v.native(), gbool(setting)) +} + +// SetUrgencyHint is a wrapper around gtk_window_set_urgency_hint(). +func (v *Window) SetUrgencyHint(setting bool) { + C.gtk_window_set_urgency_hint(v.native(), gbool(setting)) +} + +// SetAcceptFocus is a wrapper around gtk_window_set_accept_focus(). +func (v *Window) SetAcceptFocus(setting bool) { + C.gtk_window_set_accept_focus(v.native(), gbool(setting)) +} + +// SetFocusOnMap is a wrapper around gtk_window_set_focus_on_map(). +func (v *Window) SetFocusOnMap(setting bool) { + C.gtk_window_set_focus_on_map(v.native(), gbool(setting)) +} + +// SetStartupID is a wrapper around gtk_window_set_startup_id(). +func (v *Window) SetStartupID(sid string) { + cstr := (*C.gchar)(C.CString(sid)) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_window_set_startup_id(v.native(), cstr) +} + +// SetRole is a wrapper around gtk_window_set_role(). +func (v *Window) SetRole(s string) { + cstr := (*C.gchar)(C.CString(s)) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_window_set_role(v.native(), cstr) +} + +// SetWMClass is a wrapper around gtk_window_set_wmclass(). +func (v *Window) SetWMClass(name, class string) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + cClass := C.CString(class) + defer C.free(unsafe.Pointer(cClass)) + C.gtk_window_set_wmclass(v.native(), (*C.gchar)(cName), (*C.gchar)(cClass)) +} + +// GetDecorated is a wrapper around gtk_window_get_decorated(). +func (v *Window) GetDecorated() bool { + c := C.gtk_window_get_decorated(v.native()) + return gobool(c) +} + +// GetDeletable is a wrapper around gtk_window_get_deletable(). +func (v *Window) GetDeletable() bool { + c := C.gtk_window_get_deletable(v.native()) + return gobool(c) +} + +// WindowGetDefaultIconName is a wrapper around gtk_window_get_default_icon_name(). +func WindowGetDefaultIconName() (string, error) { + return stringReturn(C.gtk_window_get_default_icon_name()) +} + +// GetDefaultSize is a wrapper around gtk_window_get_default_size(). +func (v *Window) GetDefaultSize() (width, height int) { + var w, h C.gint + C.gtk_window_get_default_size(v.native(), &w, &h) + return int(w), int(h) +} + +// GetDestroyWithParent is a wrapper around +// gtk_window_get_destroy_with_parent(). +func (v *Window) GetDestroyWithParent() bool { + c := C.gtk_window_get_destroy_with_parent(v.native()) + return gobool(c) +} + +// GetHideTitlebarWhenMaximized is a wrapper around +// gtk_window_get_hide_titlebar_when_maximized(). +func (v *Window) GetHideTitlebarWhenMaximized() bool { + c := C.gtk_window_get_hide_titlebar_when_maximized(v.native()) + return gobool(c) +} + +// GetIcon is a wrapper around gtk_window_get_icon(). +func (v *Window) GetIcon() (*gdk.Pixbuf, error) { + c := C.gtk_window_get_icon(v.native()) + if c == nil { + return nil, nilPtrErr + } + + p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} + return p, nil +} + +// GetIconName is a wrapper around gtk_window_get_icon_name(). +func (v *Window) GetIconName() (string, error) { + return stringReturn(C.gtk_window_get_icon_name(v.native())) +} + +// GetModal is a wrapper around gtk_window_get_modal(). +func (v *Window) GetModal() bool { + c := C.gtk_window_get_modal(v.native()) + return gobool(c) +} + +// GetPosition is a wrapper around gtk_window_get_position(). +func (v *Window) GetPosition() (root_x, root_y int) { + var x, y C.gint + C.gtk_window_get_position(v.native(), &x, &y) + return int(x), int(y) +} + +func stringReturn(c *C.gchar) (string, error) { + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// GetRole is a wrapper around gtk_window_get_role(). +func (v *Window) GetRole() (string, error) { + return stringReturn(C.gtk_window_get_role(v.native())) +} + +// GetSize is a wrapper around gtk_window_get_size(). +func (v *Window) GetSize() (width, height int) { + var w, h C.gint + C.gtk_window_get_size(v.native(), &w, &h) + return int(w), int(h) +} + +// GetTitle is a wrapper around gtk_window_get_title(). +func (v *Window) GetTitle() (string, error) { + return stringReturn(C.gtk_window_get_title(v.native())) +} + +// GetTransientFor is a wrapper around gtk_window_get_transient_for(). +func (v *Window) GetTransientFor() (*Window, error) { + c := C.gtk_window_get_transient_for(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWindow(wrapObject(unsafe.Pointer(c))), nil +} + +// GetAttachedTo is a wrapper around gtk_window_get_attached_to(). +func (v *Window) GetAttachedTo() (*Widget, error) { + c := C.gtk_window_get_attached_to(v.native()) + if c == nil { + return nil, nilPtrErr + } + return wrapWidget(wrapObject(unsafe.Pointer(c))), nil +} + +// GetSkipTaskbarHint is a wrapper around gtk_window_get_skip_taskbar_hint(). +func (v *Window) GetSkipTaskbarHint() bool { + c := C.gtk_window_get_skip_taskbar_hint(v.native()) + return gobool(c) +} + +// GetSkipPagerHint is a wrapper around gtk_window_get_skip_pager_hint(). +func (v *Window) GetSkipPagerHint() bool { + c := C.gtk_window_get_skip_taskbar_hint(v.native()) + return gobool(c) +} + +// GetUrgencyHint is a wrapper around gtk_window_get_urgency_hint(). +func (v *Window) GetUrgencyHint() bool { + c := C.gtk_window_get_urgency_hint(v.native()) + return gobool(c) +} + +// GetAcceptFocus is a wrapper around gtk_window_get_accept_focus(). +func (v *Window) GetAcceptFocus() bool { + c := C.gtk_window_get_accept_focus(v.native()) + return gobool(c) +} + +// GetFocusOnMap is a wrapper around gtk_window_get_focus_on_map(). +func (v *Window) GetFocusOnMap() bool { + c := C.gtk_window_get_focus_on_map(v.native()) + return gobool(c) +} + +// HasGroup is a wrapper around gtk_window_has_group(). +func (v *Window) HasGroup() bool { + c := C.gtk_window_has_group(v.native()) + return gobool(c) +} + +// Move is a wrapper around gtk_window_move(). +func (v *Window) Move(x, y int) { + C.gtk_window_move(v.native(), C.gint(x), C.gint(y)) +} + +// Resize is a wrapper around gtk_window_resize(). +func (v *Window) Resize(width, height int) { + C.gtk_window_resize(v.native(), C.gint(width), C.gint(height)) +} + +// ResizeToGeometry is a wrapper around gtk_window_resize_to_geometry(). +func (v *Window) ResizeToGeometry(width, height int) { + C.gtk_window_resize_to_geometry(v.native(), C.gint(width), C.gint(height)) +} + +// WindowSetDefaultIconFromFile is a wrapper around gtk_window_set_default_icon_from_file(). +func WindowSetDefaultIconFromFile(file string) error { + cstr := C.CString(file) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_window_set_default_icon_from_file((*C.gchar)(cstr), &err) + if res == 0 { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// WindowSetDefaultIconName is a wrapper around gtk_window_set_default_icon_name(). +func WindowSetDefaultIconName(s string) { + cstr := (*C.gchar)(C.CString(s)) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_window_set_default_icon_name(cstr) +} + +// SetIconFromFile is a wrapper around gtk_window_set_icon_from_file(). +func (v *Window) SetIconFromFile(file string) error { + cstr := C.CString(file) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_window_set_icon_from_file(v.native(), (*C.gchar)(cstr), &err) + if res == 0 { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// SetIconName is a wrapper around gtk_window_set_icon_name(). +func (v *Window) SetIconName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_window_set_icon_name(v.native(), (*C.gchar)(cstr)) +} + +// SetAutoStartupNotification is a wrapper around +// gtk_window_set_auto_startup_notification(). +// This doesn't seem write. Might need to rethink? +/* +func (v *Window) SetAutoStartupNotification(setting bool) { + C.gtk_window_set_auto_startup_notification(gbool(setting)) +} +*/ + +// GetMnemonicsVisible is a wrapper around +// gtk_window_get_mnemonics_visible(). +func (v *Window) GetMnemonicsVisible() bool { + c := C.gtk_window_get_mnemonics_visible(v.native()) + return gobool(c) +} + +// SetMnemonicsVisible is a wrapper around +// gtk_window_get_mnemonics_visible(). +func (v *Window) SetMnemonicsVisible(setting bool) { + C.gtk_window_set_mnemonics_visible(v.native(), gbool(setting)) +} + +// GetFocusVisible is a wrapper around gtk_window_get_focus_visible(). +func (v *Window) GetFocusVisible() bool { + c := C.gtk_window_get_focus_visible(v.native()) + return gobool(c) +} + +// SetFocusVisible is a wrapper around gtk_window_set_focus_visible(). +func (v *Window) SetFocusVisible(setting bool) { + C.gtk_window_set_focus_visible(v.native(), gbool(setting)) +} + +// GetApplication is a wrapper around gtk_window_get_application(). +func (v *Window) GetApplication() (*Application, error) { + c := C.gtk_window_get_application(v.native()) + if c == nil { + return nil, nilPtrErr + } + + return wrapApplication(wrapObject(unsafe.Pointer(c))), nil +} + +// SetApplication is a wrapper around gtk_window_set_application(). +func (v *Window) SetApplication(a *Application) { + C.gtk_window_set_application(v.native(), a.native()) +} + +// TODO gtk_window_activate_key(). +// TODO gtk_window_add_mnemonic(). +// TODO gtk_window_begin_move_drag(). +// TODO gtk_window_begin_resize_drag(). +// TODO gtk_window_get_default_icon_list(). +// TODO gtk_window_get_group(). +// TODO gtk_window_get_icon_list(). +// TODO gtk_window_get_mnemonic_modifier(). +// TODO gtk_window_get_type_hint(). +// TODO gtk_window_get_window_type(). +// TODO gtk_window_list_toplevels(). +// TODO gtk_window_mnemonic_activate(). +// TODO gtk_window_parse_geometry(). +// TODO gtk_window_propogate_key_event(). +// TODO gtk_window_remove_mnemonic(). +// TODO gtk_window_set_attached_to(). +// TODO gtk_window_set_default_icon_list(). +// TODO gtk_window_set_icon_list(). +// TODO gtk_window_set_mnemonic_modifier(). +// TODO gtk_window_set_screen(). +// TODO gtk_window_set_type_hint(). +// TODO gtk_window_get_resize_grip_area(). diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window_since_3_10.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window_since_3_10.go new file mode 100644 index 0000000..3ee9255 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk/window_since_3_10.go @@ -0,0 +1,27 @@ +// Same copyright and license as the rest of the files in this project +// This file contains accelerator related functions and structures + +// +build !gtk_3_6,!gtk_3_8 +// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +// #include "gtk_since_3_10.go.h" +import "C" + +/* + * GtkWindow + */ + +// SetTitlebar is a wrapper around gtk_window_set_titlebar(). +func (v *Window) SetTitlebar(titlebar IWidget) { + C.gtk_window_set_titlebar(v.native(), titlebar.toWidget()) +} + +// Close is a wrapper around gtk_window_close(). +func (v *Window) Close() { + C.gtk_window_close(v.native()) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go new file mode 100644 index 0000000..3964f42 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.pango_attr_type_get_type()), marshalAttrType}, + {glib.Type(C.pango_underline_get_type()), marshalUnderline}, + } + glib.RegisterGValueMarshalers(tm) +} + +/* PangoColor */ + +// Color is a representation of PangoColor. +type Color struct { + pangoColor *C.PangoColor +} + +// Native returns a pointer to the underlying PangoColor. +func (v *Color) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Color) native() *C.PangoColor { + return (*C.PangoColor)(unsafe.Pointer(v.pangoColor)) +} + +func (v *Color) Set(red, green, blue uint16) { + v.native().red = C.guint16(red) + v.native().green = C.guint16(green) + v.native().blue = C.guint16(blue) +} + +func (v *Color) Get() (red, green, blue uint16) { + return uint16(v.native().red), uint16(v.native().green), uint16(v.native().blue) +} + +//PangoColor *pango_color_copy (const PangoColor *src); +func (v *Color) Copy(c *Color) *Color { + w := new(Color) + w.pangoColor = C.pango_color_copy(v.native()) + return w +} + +//void pango_color_free (PangoColor *color); +func (v *Color) Free() { + C.pango_color_free(v.native()) +} + +//gboolean pango_color_parse (PangoColor *color, +// const char *spec); +func (v *Color) Parse(spec string) bool { + cstr := C.CString(spec) + defer C.free(unsafe.Pointer(cstr)) + c := C.pango_color_parse(v.native(), (*C.char)(cstr)) + return gobool(c) +} + +//gchar *pango_color_to_string(const PangoColor *color); +func (v *Color) ToString() string { + c := C.pango_color_to_string(v.native()) + return C.GoString((*C.char)(c)) +} + +/* --- --- --- Attributes --- --- --- */ + +// AttrList is a representation of PangoAttrList. +type AttrList struct { + pangoAttrList *C.PangoAttrList +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *AttrList) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *AttrList) native() *C.PangoAttrList { + return (*C.PangoAttrList)(unsafe.Pointer(v.pangoAttrList)) +} + +// AttrType is a representation of Pango's PangoAttrType. +type AttrType int + +const ( + ATTR_INVALID AttrType = C.PANGO_ATTR_INVALID /* 0 is an invalid attribute type */ + ATTR_LANGUAGE AttrType = C.PANGO_ATTR_LANGUAGE /* PangoAttrLanguage */ + ATTR_FAMILY AttrType = C.PANGO_ATTR_FAMILY /* PangoAttrString */ + ATTR_STYLE AttrType = C.PANGO_ATTR_STYLE /* PangoAttrInt */ + ATTR_WEIGHT AttrType = C.PANGO_ATTR_WEIGHT /* PangoAttrInt */ + ATTR_VARIANT AttrType = C.PANGO_ATTR_VARIANT /* PangoAttrInt */ + ATTR_STRETCH AttrType = C.PANGO_ATTR_STRETCH /* PangoAttrInt */ + ATTR_SIZE AttrType = C.PANGO_ATTR_SIZE /* PangoAttrSize */ + ATTR_FONT_DESC AttrType = C.PANGO_ATTR_FONT_DESC /* PangoAttrFontDesc */ + ATTR_FOREGROUND AttrType = C.PANGO_ATTR_FOREGROUND /* PangoAttrColor */ + ATTR_BACKGROUND AttrType = C.PANGO_ATTR_BACKGROUND /* PangoAttrColor */ + ATTR_UNDERLINE AttrType = C.PANGO_ATTR_UNDERLINE /* PangoAttrInt */ + ATTR_STRIKETHROUGH AttrType = C.PANGO_ATTR_STRIKETHROUGH /* PangoAttrInt */ + ATTR_RISE AttrType = C.PANGO_ATTR_RISE /* PangoAttrInt */ + ATTR_SHAPE AttrType = C.PANGO_ATTR_SHAPE /* PangoAttrShape */ + ATTR_SCALE AttrType = C.PANGO_ATTR_SCALE /* PangoAttrFloat */ + ATTR_FALLBACK AttrType = C.PANGO_ATTR_FALLBACK /* PangoAttrInt */ + ATTR_LETTER_SPACING AttrType = C.PANGO_ATTR_LETTER_SPACING /* PangoAttrInt */ + ATTR_UNDERLINE_COLOR AttrType = C.PANGO_ATTR_UNDERLINE_COLOR /* PangoAttrColor */ + ATTR_STRIKETHROUGH_COLOR AttrType = C.PANGO_ATTR_STRIKETHROUGH_COLOR /* PangoAttrColor */ + ATTR_ABSOLUTE_SIZE AttrType = C.PANGO_ATTR_ABSOLUTE_SIZE /* PangoAttrSize */ + ATTR_GRAVITY AttrType = C.PANGO_ATTR_GRAVITY /* PangoAttrInt */ + ATTR_GRAVITY_HINT AttrType = C.PANGO_ATTR_GRAVITY_HINT /* PangoAttrInt */ + +) + +func marshalAttrType(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return AttrType(c), nil +} + +// Underline is a representation of Pango's PangoUnderline. +type Underline int + +const ( + UNDERLINE_NONE Underline = C.PANGO_UNDERLINE_NONE + UNDERLINE_SINGLE Underline = C.PANGO_UNDERLINE_SINGLE + UNDERLINE_DOUBLE Underline = C.PANGO_UNDERLINE_DOUBLE + UNDERLINE_LOW Underline = C.PANGO_UNDERLINE_LOW + UNDERLINE_ERROR Underline = C.PANGO_UNDERLINE_ERROR +) + +func marshalUnderline(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Underline(c), nil +} + +const ( + ATTR_INDEX_FROM_TEXT_BEGINNING uint = 0 + ATTR_INDEX_TO_TEXT_END uint = C.G_MAXUINT +) + +// Attribute is a representation of Pango's PangoAttribute. +type Attribute struct { + pangoAttribute *C.PangoAttribute + //start_index, end_index uint +} + +// Native returns a pointer to the underlying PangoColor. +func (v *Attribute) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Attribute) native() *C.PangoAttribute { + return (*C.PangoAttribute)(unsafe.Pointer(v.pangoAttribute)) +} + +/* +//typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute, +// gpointer user_data); +func (v *Attribute) AttrFilterFunc(user_data uintptr) bool { + c := C.PangoAttrFilterFunc(Attribute.native(), C.gpointer(user_data)) + return gobool(c) +} + +//typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer user_data); +func AttrDataCopyFunc(user_data uintptr) uintptr { + c := C.PangoAttrDataCopyFunc(C.gpointer(user_data)) + return uintptr(c) +} +*/ + +// AttrClass is a representation of Pango's PangoAttrClass. +type AttrClass struct { + //PangoAttrType type; +} + +// AttrString is a representation of Pango's PangoAttrString. +type AttrString struct { + Attribute + //char *value; +} + +// AttrLanguage is a representation of Pango's PangoAttrLanguage. +type AttrLanguage struct { + Attribute + //PangoLanguage *value; +} + +// AttrInt is a representation of Pango's PangoAttrInt. +type AttrInt struct { + Attribute + //int value; +} + +// AttrFloat is a representation of Pango's PangoAttrFloat. +type AttrFloat struct { + Attribute + //double value; +} + +// AttrColor is a representation of Pango's AttrColor. +type AttrColor struct { + Attribute + Color +} + +// AttrSize is a representation of Pango's PangoAttrSize. +type AttrSize struct { + Attribute + //int size; + //guint absolute : 1; +} + +// AttrShape is a representation of Pango's PangoAttrShape. +type AttrShape struct { + Attribute + //PangoRectangle ink_rect; + //PangoRectangle logical_rect; + + //gpointer data; + //PangoAttrDataCopyFunc copy_func; + //GDestroyNotify destroy_func; +} + +// AttrFontDesc is a representation of Pango's PangoAttrFontDesc. +type AttrFontDesc struct { + Attribute + //PangoFontDescription *desc; +} + +/* +PangoAttrType pango_attr_type_register (const gchar *name); +const char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST; + +void pango_attribute_init (PangoAttribute *attr, + const PangoAttrClass *klass); +PangoAttribute * pango_attribute_copy (const PangoAttribute *attr); +void pango_attribute_destroy (PangoAttribute *attr); +gboolean pango_attribute_equal (const PangoAttribute *attr1, + const PangoAttribute *attr2) G_GNUC_PURE; + +PangoAttribute *pango_attr_language_new (PangoLanguage *language); +PangoAttribute *pango_attr_family_new (const char *family); +PangoAttribute *pango_attr_foreground_new (guint16 red, + guint16 green, + guint16 blue); +PangoAttribute *pango_attr_background_new (guint16 red, + guint16 green, + guint16 blue); +PangoAttribute *pango_attr_size_new (int size); +PangoAttribute *pango_attr_size_new_absolute (int size); +PangoAttribute *pango_attr_style_new (PangoStyle style); +PangoAttribute *pango_attr_weight_new (PangoWeight weight); +PangoAttribute *pango_attr_variant_new (PangoVariant variant); +PangoAttribute *pango_attr_stretch_new (PangoStretch stretch); +PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc); + +PangoAttribute *pango_attr_underline_new (PangoUnderline underline); +PangoAttribute *pango_attr_underline_color_new (guint16 red, + guint16 green, + guint16 blue); +PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough); +PangoAttribute *pango_attr_strikethrough_color_new (guint16 red, + guint16 green, + guint16 blue); + +PangoAttribute *pango_attr_rise_new (int rise); +PangoAttribute *pango_attr_scale_new (double scale_factor); +PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback); +PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing); + +PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect, + const PangoRectangle *logical_rect); +PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect, + const PangoRectangle *logical_rect, + gpointer data, + PangoAttrDataCopyFunc copy_func, + GDestroyNotify destroy_func); + +PangoAttribute *pango_attr_gravity_new (PangoGravity gravity); +PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint); + +GType pango_attr_list_get_type (void) G_GNUC_CONST; +PangoAttrList * pango_attr_list_new (void); +PangoAttrList * pango_attr_list_ref (PangoAttrList *list); +void pango_attr_list_unref (PangoAttrList *list); +PangoAttrList * pango_attr_list_copy (PangoAttrList *list); +void pango_attr_list_insert (PangoAttrList *list, + PangoAttribute *attr); +void pango_attr_list_insert_before (PangoAttrList *list, + PangoAttribute *attr); +void pango_attr_list_change (PangoAttrList *list, + PangoAttribute *attr); +void pango_attr_list_splice (PangoAttrList *list, + PangoAttrList *other, + gint pos, + gint len); + +PangoAttrList *pango_attr_list_filter (PangoAttrList *list, + PangoAttrFilterFunc func, + gpointer data); + +PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list); + +void pango_attr_iterator_range (PangoAttrIterator *iterator, + gint *start, + gint *end); +gboolean pango_attr_iterator_next (PangoAttrIterator *iterator); +PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator); +void pango_attr_iterator_destroy (PangoAttrIterator *iterator); +PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator, + PangoAttrType type); +void pango_attr_iterator_get_font (PangoAttrIterator *iterator, + PangoFontDescription *desc, + PangoLanguage **language, + GSList **extra_attrs); +GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator); + + +gboolean pango_parse_markup (const char *markup_text, + int length, + gunichar accel_marker, + PangoAttrList **attr_list, + char **text, + gunichar *accel_char, + GError **error); + +GMarkupParseContext * pango_markup_parser_new (gunichar accel_marker); +gboolean pango_markup_parser_finish (GMarkupParseContext *context, + PangoAttrList **attr_list, + char **text, + gunichar *accel_char, + GError **error); +*/ diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go.h new file mode 100644 index 0000000..d1b2e23 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-attributes.go.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +static PangoColor* toPangoColor(void *p) +{ + return ( (PangoColor*) (p) ); +} + diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-context.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-context.go new file mode 100644 index 0000000..66462fe --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-context.go @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" +import ( + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + // {glib.Type(C.pango_alignment_get_type()), marshalAlignment}, + // {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, + // {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, + + // Objects/Interfaces + // {glib.Type(C.pango_context_get_type()), marshalContext}, + } + glib.RegisterGValueMarshalers(tm) +} + +// Context is a representation of PangoContext. +type Context struct { + pangoContext *C.PangoContext +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *Context) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Context) native() *C.PangoContext { + return (*C.PangoContext)(unsafe.Pointer(v.pangoContext)) +} + +/* +func marshalContext(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapContext(obj), nil +} + +func wrapContext(obj *glib.Object) *Context { + return &Context{obj} +} +*/ + +//PangoContext *pango_context_new (void); +func ContextNew() *Context { + c := C.pango_context_new() + + context := new(Context) + context.pangoContext = (*C.PangoContext)(c) + + return context +} + +//void pango_context_changed (PangoContext *context); +//void pango_context_set_font_map (PangoContext *context, +// PangoFontMap *font_map); +//PangoFontMap *pango_context_get_font_map (PangoContext *context); +//guint pango_context_get_serial (PangoContext *context); +//void pango_context_list_families (PangoContext *context, +// PangoFontFamily ***families, +// int *n_families); +//PangoFont * pango_context_load_font (PangoContext *context, +// const PangoFontDescription *desc); +//PangoFontset *pango_context_load_fontset (PangoContext *context, +// const PangoFontDescription *desc, +// PangoLanguage *language); +// +//PangoFontMetrics *pango_context_get_metrics (PangoContext *context, +// const PangoFontDescription *desc, +// PangoLanguage *language); +// +//void pango_context_set_font_description (PangoContext *context, +// const PangoFontDescription *desc); +//PangoFontDescription * pango_context_get_font_description (PangoContext *context); +//PangoLanguage *pango_context_get_language (PangoContext *context); +//void pango_context_set_language (PangoContext *context, +// PangoLanguage *language); +//void pango_context_set_base_dir (PangoContext *context, +// PangoDirection direction); +//PangoDirection pango_context_get_base_dir (PangoContext *context); +//void pango_context_set_base_gravity (PangoContext *context, +// PangoGravity gravity); +//PangoGravity pango_context_get_base_gravity (PangoContext *context); +//PangoGravity pango_context_get_gravity (PangoContext *context); +//void pango_context_set_gravity_hint (PangoContext *context, +// PangoGravityHint hint); +//PangoGravityHint pango_context_get_gravity_hint (PangoContext *context); +// +//void pango_context_set_matrix (PangoContext *context, +// const PangoMatrix *matrix); +//const PangoMatrix * pango_context_get_matrix (PangoContext *context); + +/* Break a string of Unicode characters into segments with + * consistent shaping/language engine and bidrectional level. + * Returns a #GList of #PangoItem's + */ +//GList *pango_itemize (PangoContext *context, +// const char *text, +// int start_index, +// int length, +// PangoAttrList *attrs, +// PangoAttrIterator *cached_iter); +//GList *pango_itemize_with_base_dir (PangoContext *context, +// PangoDirection base_dir, +// const char *text, +// int start_index, +// int length, +// PangoAttrList *attrs, +// PangoAttrIterator *cached_iter); diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-font.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-font.go new file mode 100644 index 0000000..d0f5820 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-font.go @@ -0,0 +1,706 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" +import ( + // "github.com/andre-hub/gotk3/glib" + // "github.com/andre-hub/gotk3/cairo" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + // Objects/Interfaces + {glib.Type(C.pango_font_description_get_type()), marshalFontDescription}, + } + glib.RegisterGValueMarshalers(tm) +} + +// FontDescription is a representation of PangoFontDescription. +type FontDescription struct { + pangoFontDescription *C.PangoFontDescription +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *FontDescription) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *FontDescription) native() *C.PangoFontDescription { + return (*C.PangoFontDescription)(unsafe.Pointer(v.pangoFontDescription)) +} + +// FontMetrics is a representation of PangoFontMetrics. +type FontMetrics struct { + pangoFontMetrics *C.PangoFontMetrics +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *FontMetrics) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *FontMetrics) native() *C.PangoFontMetrics { + return (*C.PangoFontMetrics)(unsafe.Pointer(v.pangoFontMetrics)) +} + +const ( + PANGO_SCALE = C.PANGO_SCALE +) + +type Style int + +const ( + STYLE_NORMAL Style = C.PANGO_STYLE_NORMAL + STYLE_OBLIQUE Style = C.PANGO_STYLE_OBLIQUE + STYLE_ITALIC Style = C.PANGO_STYLE_ITALIC +) + +type Variant int + +const ( + VARIANT_NORMAL Variant = C.PANGO_VARIANT_NORMAL + VARIANT_SMALL_CAPS Variant = C.PANGO_VARIANT_SMALL_CAPS +) + +type Weight int + +const ( + WEIGHT_THIN Weight = C.PANGO_WEIGHT_THIN /* 100 */ + WEIGHT_ULTRALIGHT Weight = C.PANGO_WEIGHT_ULTRALIGHT /* 200 */ + WEIGHT_LIGHT Weight = C.PANGO_WEIGHT_LIGHT /* 300 */ + WEIGHT_SEMILIGHT Weight = 350 /* 350 */ + WEIGHT_BOOK Weight = C.PANGO_WEIGHT_BOOK /* 380 */ + WEIGHT_NORMAL Weight = C.PANGO_WEIGHT_NORMAL /* 400 */ + WEIGHT_MEDIUM Weight = C.PANGO_WEIGHT_MEDIUM /* 500 */ + WEIGHT_SEMIBOLD Weight = C.PANGO_WEIGHT_SEMIBOLD /* 600 */ + WEIGHT_BOLD Weight = C.PANGO_WEIGHT_BOLD /* 700 */ + WEIGHT_ULTRABOLD Weight = C.PANGO_WEIGHT_ULTRABOLD /* 800 */ + WEIGHT_HEAVY Weight = C.PANGO_WEIGHT_HEAVY /* 900 */ + WEIGHT_ULTRAHEAVY Weight = C.PANGO_WEIGHT_ULTRAHEAVY /* 1000 */ + +) + +type Stretch int + +const ( + STRETCH_ULTRA_CONDENSED Stretch = C.PANGO_STRETCH_ULTRA_CONDENSED + STRETCH_EXTRA_CONDENSEDStretch Stretch = C.PANGO_STRETCH_EXTRA_CONDENSED + STRETCH_CONDENSEDStretch Stretch = C.PANGO_STRETCH_CONDENSED + STRETCH_SEMI_CONDENSEDStretch Stretch = C.PANGO_STRETCH_SEMI_CONDENSED + STRETCH_NORMALStretch Stretch = C.PANGO_STRETCH_NORMAL + STRETCH_SEMI_EXPANDEDStretch Stretch = C.PANGO_STRETCH_SEMI_EXPANDED + STRETCH_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXPANDED + STRETCH_EXTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXTRA_EXPANDED + STRETCH_ULTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_ULTRA_EXPANDED +) + +type FontMask int + +const ( + FONT_MASK_FAMILY FontMask = C.PANGO_FONT_MASK_FAMILY /* 1 << 0 */ + FONT_MASK_STYLEFontMask FontMask = C.PANGO_FONT_MASK_STYLE /* 1 << 1 */ + FONT_MASK_VARIANTFontMask FontMask = C.PANGO_FONT_MASK_VARIANT /* 1 << 2 */ + FONT_MASK_WEIGHTFontMask FontMask = C.PANGO_FONT_MASK_WEIGHT /* 1 << 3 */ + FONT_MASK_STRETCHFontMask FontMask = C.PANGO_FONT_MASK_STRETCH /* 1 << 4 */ + FONT_MASK_SIZEFontMask FontMask = C.PANGO_FONT_MASK_SIZE /* 1 << 5 */ + FONT_MASK_GRAVITYFontMask FontMask = C.PANGO_FONT_MASK_GRAVITY /* 1 << 6 */ +) + +type Scale float64 + +const ( + SCALE_XX_SMALL Scale = /* C.PANGO_SCALE_XX_SMALL */ 0.5787037037037 + SCALE_X_SMALL Scale = /*C.PANGO_SCALE_X_SMALL */ 0.6444444444444 + SCALE_SMALL Scale = /*C.PANGO_SCALE_SMALL */ 0.8333333333333 + SCALE_MEDIUM Scale = /*C.PANGO_SCALE_MEDIUM */ 1.0 + SCALE_LARGE Scale = /*C.PANGO_SCALE_LARGE */ 1.2 + SCALE_X_LARGE Scale = /*C.PANGO_SCALE_X_LARGE */ 1.4399999999999 + SCALE_XX_LARGE Scale = /*C.PANGO_SCALE_XX_LARGE */ 1.728 +) + +/* + * PangoFontDescription + */ + +func marshalFontDescription(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + c2 := (*C.PangoFontDescription)(unsafe.Pointer(c)) + return wrapFontDescription(c2), nil +} + +func wrapFontDescription(obj *C.PangoFontDescription) *FontDescription { + return &FontDescription{obj} +} + +//PangoFontDescription *pango_font_description_new (void); +func FontDescriptionNew() *FontDescription { + c := C.pango_font_description_new() + v := new(FontDescription) + v.pangoFontDescription = c + return v +} + +//PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc); +func (v *FontDescription) Copy() *FontDescription { + c := C.pango_font_description_copy(v.native()) + v2 := new(FontDescription) + v2.pangoFontDescription = c + return v2 +} + +//PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription *desc); +func (v *FontDescription) CopyStatic() *FontDescription { + c := C.pango_font_description_copy_static(v.native()) + v2 := new(FontDescription) + v2.pangoFontDescription = c + return v2 +} + +//guint pango_font_description_hash (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) Hash() uint { + c := C.pango_font_description_hash(v.native()) + return uint(c) +} + +//gboolean pango_font_description_equal (const PangoFontDescription *desc1, +// const PangoFontDescription *desc2) G_GNUC_PURE; +func (v *FontDescription) Equal(v2 *FontDescription) bool { + c := C.pango_font_description_equal(v.native(), v2.native()) + return gobool(c) +} + +//void pango_font_description_free (PangoFontDescription *desc); +func (v *FontDescription) Free() { + C.pango_font_description_free(v.native()) +} + +//void pango_font_descriptions_free (PangoFontDescription **descs, +// int n_descs); +//func (v *FontDescription) FontDescriptionsFree(n_descs int) { +// C.pango_font_descriptions_free(v.native(), C.int(n_descs)) +//} + +//void pango_font_description_set_family (PangoFontDescription *desc, +// const char *family); +func (v *FontDescription) SetFamily(family string) { + cstr := C.CString(family) + defer C.free(unsafe.Pointer(cstr)) + C.pango_font_description_set_family(v.native(), (*C.char)(cstr)) +} + +//void pango_font_description_set_family_static (PangoFontDescription *desc, +// const char *family); +func (v *FontDescription) SetFamilyStatic(family string) { + cstr := C.CString(family) + defer C.free(unsafe.Pointer(cstr)) + C.pango_font_description_set_family_static(v.native(), (*C.char)(cstr)) +} + +//const char *pango_font_description_get_family (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetFamily() string { + c := C.pango_font_description_get_family(v.native()) + return C.GoString((*C.char)(c)) +} + +//void pango_font_description_set_style (PangoFontDescription *desc, +// PangoStyle style); +func (v *FontDescription) SetStyle(style Style) { + C.pango_font_description_set_style(v.native(), (C.PangoStyle)(style)) +} + +//PangoStyle pango_font_description_get_style (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetStyle() Style { + c := C.pango_font_description_get_style(v.native()) + return Style(c) +} + +//void pango_font_description_set_variant (PangoFontDescription *desc, +// PangoVariant variant); +//PangoVariant pango_font_description_get_variant (const PangoFontDescription *desc) G_GNUC_PURE; + +//void pango_font_description_set_weight (PangoFontDescription *desc, +// PangoWeight weight); +func (v *FontDescription) SetWeight(weight Weight) { + C.pango_font_description_set_weight(v.native(), (C.PangoWeight)(weight)) +} + +//PangoWeight pango_font_description_get_weight (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetWeight() Weight { + c := C.pango_font_description_get_weight(v.native()) + return Weight(c) +} + +//void pango_font_description_set_stretch (PangoFontDescription *desc, +// PangoStretch stretch); +func (v *FontDescription) SetStretch(stretch Stretch) { + C.pango_font_description_set_stretch(v.native(), (C.PangoStretch)(stretch)) +} + +//PangoStretch pango_font_description_get_stretch (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetStretch() Stretch { + c := C.pango_font_description_get_stretch(v.native()) + return Stretch(c) +} + +//void pango_font_description_set_size (PangoFontDescription *desc, +// gint size); +func (v *FontDescription) SetSize(size int) { + C.pango_font_description_set_size(v.native(), (C.gint)(size)) +} + +//gint pango_font_description_get_size (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetSize() int { + c := C.pango_font_description_get_size(v.native()) + return int(c) +} + +//void pango_font_description_set_absolute_size (PangoFontDescription *desc, +// double size); +func (v *FontDescription) SetAbsoluteSize(size float64) { + C.pango_font_description_set_absolute_size(v.native(), (C.double)(size)) +} + +//gboolean pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetSizeIsAbsolute() bool { + c := C.pango_font_description_get_size_is_absolute(v.native()) + return gobool(c) +} + +//void pango_font_description_set_gravity (PangoFontDescription *desc, +// PangoGravity gravity); +func (v *FontDescription) SetGravity(gravity Gravity) { + C.pango_font_description_set_gravity(v.native(), (C.PangoGravity)(gravity)) +} + +//PangoGravity pango_font_description_get_gravity (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetGravity() Gravity { + c := C.pango_font_description_get_gravity(v.native()) + return Gravity(c) +} + +//PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE; +func (v *FontDescription) GetSetFields() FontMask { + c := C.pango_font_description_get_set_fields(v.native()) + return FontMask(c) +} + +//void pango_font_description_unset_fields (PangoFontDescription *desc, +// PangoFontMask to_unset); +func (v *FontDescription) GetUnsetFields(to_unset FontMask) { + C.pango_font_description_unset_fields(v.native(), (C.PangoFontMask)(to_unset)) +} + +//void pango_font_description_merge (PangoFontDescription *desc, +// const PangoFontDescription *desc_to_merge, +// gboolean replace_existing); +func (v *FontDescription) Merge(desc_to_merge *FontDescription, replace_existing bool) { + C.pango_font_description_merge(v.native(), desc_to_merge.native(), gbool(replace_existing)) +} + +//void pango_font_description_merge_static (PangoFontDescription *desc, +// const PangoFontDescription *desc_to_merge, +// gboolean replace_existing); +func (v *FontDescription) MergeStatic(desc_to_merge *FontDescription, replace_existing bool) { + C.pango_font_description_merge_static(v.native(), desc_to_merge.native(), gbool(replace_existing)) +} + +//gboolean pango_font_description_better_match (const PangoFontDescription *desc, +// const PangoFontDescription *old_match, +// const PangoFontDescription *new_match) G_GNUC_PURE; +func (v *FontDescription) BetterMatch(old_match, new_match *FontDescription) bool { + c := C.pango_font_description_better_match(v.native(), old_match.native(), new_match.native()) + return gobool(c) +} + +//PangoFontDescription *pango_font_description_from_string (const char *str); +func FontDescriptionFromString(str string) *FontDescription { + cstr := C.CString(str) + defer C.free(unsafe.Pointer(cstr)) + c := C.pango_font_description_from_string((*C.char)(cstr)) + v := new(FontDescription) + v.pangoFontDescription = c + return v +} + +//char * pango_font_description_to_string (const PangoFontDescription *desc); +func (v *FontDescription) ToString() string { + c := C.pango_font_description_to_string(v.native()) + return C.GoString((*C.char)(c)) +} + +//char * pango_font_description_to_filename (const PangoFontDescription *desc); +func (v *FontDescription) ToFilename() string { + c := C.pango_font_description_to_filename(v.native()) + return C.GoString((*C.char)(c)) +} + +///* +// * PangoFontMetrics +// */ +// +///** +// * PANGO_TYPE_FONT_METRICS: +// * +// * The #GObject type for #PangoFontMetrics. +// */ +//#define PANGO_TYPE_FONT_METRICS (pango_font_metrics_get_type ()) +//GType pango_font_metrics_get_type (void) G_GNUC_CONST; +//PangoFontMetrics *pango_font_metrics_ref (PangoFontMetrics *metrics); +//void pango_font_metrics_unref (PangoFontMetrics *metrics); +//int pango_font_metrics_get_ascent (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_descent (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_approximate_char_width (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_underline_position (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_underline_thickness (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_strikethrough_position (PangoFontMetrics *metrics) G_GNUC_PURE; +//int pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE; +// +//#ifdef PANGO_ENABLE_BACKEND +// +//PangoFontMetrics *pango_font_metrics_new (void); +// +//struct _PangoFontMetrics +//{ +// guint ref_count; +// +// int ascent; +// int descent; +// int approximate_char_width; +// int approximate_digit_width; +// int underline_position; +// int underline_thickness; +// int strikethrough_position; +// int strikethrough_thickness; +//}; +// +//#endif /* PANGO_ENABLE_BACKEND */ +// +///* +// * PangoFontFamily +// */ +// +///** +// * PANGO_TYPE_FONT_FAMILY: +// * +// * The #GObject type for #PangoFontFamily. +// */ +///** +// * PANGO_FONT_FAMILY: +// * @object: a #GObject. +// * +// * Casts a #GObject to a #PangoFontFamily. +// */ +///** +// * PANGO_IS_FONT_FAMILY: +// * @object: a #GObject. +// * +// * Returns: %TRUE if @object is a #PangoFontFamily. +// */ +//#define PANGO_TYPE_FONT_FAMILY (pango_font_family_get_type ()) +//#define PANGO_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily)) +//#define PANGO_IS_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY)) +// +//typedef struct _PangoFontFamily PangoFontFamily; +//typedef struct _PangoFontFace PangoFontFace; +// +//GType pango_font_family_get_type (void) G_GNUC_CONST; +// +//void pango_font_family_list_faces (PangoFontFamily *family, +// PangoFontFace ***faces, +// int *n_faces); +//const char *pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE; +//gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE; +// +//#ifdef PANGO_ENABLE_BACKEND +// +//#define PANGO_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass)) +//#define PANGO_IS_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY)) +//#define PANGO_FONT_FAMILY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass)) +// +//typedef struct _PangoFontFamilyClass PangoFontFamilyClass; +// +// +///** +// * PangoFontFamily: +// * +// * The #PangoFontFamily structure is used to represent a family of related +// * font faces. The faces in a family share a common design, but differ in +// * slant, weight, width and other aspects. +// */ +//struct _PangoFontFamily +//{ +// GObject parent_instance; +//}; +// +//struct _PangoFontFamilyClass +//{ +// GObjectClass parent_class; +// +// /*< public >*/ +// +// void (*list_faces) (PangoFontFamily *family, +// PangoFontFace ***faces, +// int *n_faces); +// const char * (*get_name) (PangoFontFamily *family); +// gboolean (*is_monospace) (PangoFontFamily *family); +// +// /*< private >*/ +// +// /* Padding for future expansion */ +// void (*_pango_reserved2) (void); +// void (*_pango_reserved3) (void); +// void (*_pango_reserved4) (void); +//}; +// +//#endif /* PANGO_ENABLE_BACKEND */ +// +///* +// * PangoFontFace +// */ +// +///** +// * PANGO_TYPE_FONT_FACE: +// * +// * The #GObject type for #PangoFontFace. +// */ +///** +// * PANGO_FONT_FACE: +// * @object: a #GObject. +// * +// * Casts a #GObject to a #PangoFontFace. +// */ +///** +// * PANGO_IS_FONT_FACE: +// * @object: a #GObject. +// * +// * Returns: %TRUE if @object is a #PangoFontFace. +// */ +//#define PANGO_TYPE_FONT_FACE (pango_font_face_get_type ()) +//#define PANGO_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace)) +//#define PANGO_IS_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE)) +// +//GType pango_font_face_get_type (void) G_GNUC_CONST; +// +//PangoFontDescription *pango_font_face_describe (PangoFontFace *face); +//const char *pango_font_face_get_face_name (PangoFontFace *face) G_GNUC_PURE; +//void pango_font_face_list_sizes (PangoFontFace *face, +// int **sizes, +// int *n_sizes); +//gboolean pango_font_face_is_synthesized (PangoFontFace *face) G_GNUC_PURE; +// +//#ifdef PANGO_ENABLE_BACKEND +// +//#define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass)) +//#define PANGO_IS_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE)) +//#define PANGO_FONT_FACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass)) +// +//typedef struct _PangoFontFaceClass PangoFontFaceClass; +// +///** +// * PangoFontFace: +// * +// * The #PangoFontFace structure is used to represent a group of fonts with +// * the same family, slant, weight, width, but varying sizes. +// */ +//struct _PangoFontFace +//{ +// GObject parent_instance; +//}; +// +//struct _PangoFontFaceClass +//{ +// GObjectClass parent_class; +// +// /*< public >*/ +// +// const char * (*get_face_name) (PangoFontFace *face); +// PangoFontDescription * (*describe) (PangoFontFace *face); +// void (*list_sizes) (PangoFontFace *face, +// int **sizes, +// int *n_sizes); +// gboolean (*is_synthesized) (PangoFontFace *face); +// +// /*< private >*/ +// +// /* Padding for future expansion */ +// void (*_pango_reserved3) (void); +// void (*_pango_reserved4) (void); +//}; +// +//#endif /* PANGO_ENABLE_BACKEND */ +// +///* +// * PangoFont +// */ +// +///** +// * PANGO_TYPE_FONT: +// * +// * The #GObject type for #PangoFont. +// */ +///** +// * PANGO_FONT: +// * @object: a #GObject. +// * +// * Casts a #GObject to a #PangoFont. +// */ +///** +// * PANGO_IS_FONT: +// * @object: a #GObject. +// * +// * Returns: %TRUE if @object is a #PangoFont. +// */ +//#define PANGO_TYPE_FONT (pango_font_get_type ()) +//#define PANGO_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont)) +//#define PANGO_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT)) +// +//GType pango_font_get_type (void) G_GNUC_CONST; +// +//PangoFontDescription *pango_font_describe (PangoFont *font); +//PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont *font); +//PangoCoverage * pango_font_get_coverage (PangoFont *font, +// PangoLanguage *language); +//PangoEngineShape * pango_font_find_shaper (PangoFont *font, +// PangoLanguage *language, +// guint32 ch); +//PangoFontMetrics * pango_font_get_metrics (PangoFont *font, +// PangoLanguage *language); +//void pango_font_get_glyph_extents (PangoFont *font, +// PangoGlyph glyph, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//PangoFontMap *pango_font_get_font_map (PangoFont *font); +// +//#ifdef PANGO_ENABLE_BACKEND +// +//#define PANGO_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass)) +//#define PANGO_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT)) +//#define PANGO_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass)) +// +//typedef struct _PangoFontClass PangoFontClass; +// +///** +// * PangoFont: +// * +// * The #PangoFont structure is used to represent +// * a font in a rendering-system-independent matter. +// * To create an implementation of a #PangoFont, +// * the rendering-system specific code should allocate +// * a larger structure that contains a nested +// * #PangoFont, fill in the klass member of +// * the nested #PangoFont with a pointer to +// * a appropriate #PangoFontClass, then call +// * pango_font_init() on the structure. +// * +// * The #PangoFont structure contains one member +// * which the implementation fills in. +// */ +//struct _PangoFont +//{ +// GObject parent_instance; +//}; +// +//struct _PangoFontClass +//{ +// GObjectClass parent_class; +// +// /*< public >*/ +// +// PangoFontDescription *(*describe) (PangoFont *font); +// PangoCoverage * (*get_coverage) (PangoFont *font, +// PangoLanguage *lang); +// PangoEngineShape * (*find_shaper) (PangoFont *font, +// PangoLanguage *lang, +// guint32 ch); +// void (*get_glyph_extents) (PangoFont *font, +// PangoGlyph glyph, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +// PangoFontMetrics * (*get_metrics) (PangoFont *font, +// PangoLanguage *language); +// PangoFontMap * (*get_font_map) (PangoFont *font); +// PangoFontDescription *(*describe_absolute) (PangoFont *font); +// /*< private >*/ +// +// /* Padding for future expansion */ +// void (*_pango_reserved1) (void); +// void (*_pango_reserved2) (void); +//}; +// +///* used for very rare and miserable situtations that we cannot even +// * draw a hexbox +// */ +//#define PANGO_UNKNOWN_GLYPH_WIDTH 10 +//#define PANGO_UNKNOWN_GLYPH_HEIGHT 14 +// +//#endif /* PANGO_ENABLE_BACKEND */ +// +///** +// * PANGO_GLYPH_EMPTY: +// * +// * The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a +// * special meaning, which is a zero-width empty glyph. This is useful for +// * example in shaper modules, to use as the glyph for various zero-width +// * Unicode characters (those passing pango_is_zero_width()). +// */ +///** +// * PANGO_GLYPH_INVALID_INPUT: +// * +// * The %PANGO_GLYPH_INVALID_INPUT macro represents a #PangoGlyph value that has a +// * special meaning of invalid input. #PangoLayout produces one such glyph +// * per invalid input UTF-8 byte and such a glyph is rendered as a crossed +// * box. +// * +// * Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG +// * on. +// * +// * Since: 1.20 +// */ +///** +// * PANGO_GLYPH_UNKNOWN_FLAG: +// * +// * The %PANGO_GLYPH_UNKNOWN_FLAG macro is a flag value that can be added to +// * a #gunichar value of a valid Unicode character, to produce a #PangoGlyph +// * value, representing an unknown-character glyph for the respective #gunichar. +// */ +///** +// * PANGO_GET_UNKNOWN_GLYPH: +// * @wc: a Unicode character +// * +// * The way this unknown glyphs are rendered is backend specific. For example, +// * a box with the hexadecimal Unicode code-point of the character written in it +// * is what is done in the most common backends. +// * +// * Returns: a #PangoGlyph value that means no glyph was found for @wc. +// */ +//#define PANGO_GLYPH_EMPTY ((PangoGlyph)0x0FFFFFFF) +//#define PANGO_GLYPH_INVALID_INPUT ((PangoGlyph)0xFFFFFFFF) +//#define PANGO_GLYPH_UNKNOWN_FLAG ((PangoGlyph)0x10000000) +//#define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG) +// +// diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph-item.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph-item.go new file mode 100644 index 0000000..1ee9016 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph-item.go @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +// #include +import "C" +import ( + // "github.com/andre-hub/gotk3/glib" + // "github.com/andre-hub/gotk3/cairo" + "unsafe" +) + +// GlyphItem is a representation of PangoGlyphItem. +type GlyphItem struct { + pangoGlyphItem *C.PangoGlyphItem +} + +// Native returns a pointer to the underlying PangoGlyphItem. +func (v *GlyphItem) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *GlyphItem) native() *C.PangoGlyphItem { + return (*C.PangoGlyphItem)(unsafe.Pointer(v.pangoGlyphItem)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph.go new file mode 100644 index 0000000..d41e6da --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-glyph.go @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +// #include +import "C" +import ( + // "github.com/andre-hub/gotk3/glib" + // "github.com/andre-hub/gotk3/cairo" + "unsafe" +) + +// GlyphGeometry is a representation of PangoGlyphGeometry. +type GlyphGeometry struct { + pangoGlyphGeometry *C.PangoGlyphGeometry +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *GlyphGeometry) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *GlyphGeometry) native() *C.PangoGlyphGeometry { + return (*C.PangoGlyphGeometry)(unsafe.Pointer(v.pangoGlyphGeometry)) +} + +// GlyphVisAttr is a representation of PangoGlyphVisAttr. +type GlyphVisAttr struct { + pangoGlyphVisAttr *C.PangoGlyphGeometry +} + +// Native returns a pointer to the underlying PangoGlyphVisAttr. +func (v *GlyphVisAttr) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *GlyphVisAttr) native() *C.PangoGlyphVisAttr { + return (*C.PangoGlyphVisAttr)(unsafe.Pointer(v.pangoGlyphVisAttr)) +} + +// GlyphInfo is a representation of PangoGlyphInfo. +type GlyphInfo struct { + pangoGlyphInfo *C.PangoGlyphInfo +} + +// Native returns a pointer to the underlying PangoGlyphInfo. +func (v *GlyphInfo) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *GlyphInfo) native() *C.PangoGlyphInfo { + return (*C.PangoGlyphInfo)(unsafe.Pointer(v.pangoGlyphInfo)) +} + +// GlyphGeometry is a representation of PangoGlyphString. +type GlyphString struct { + pangoGlyphString *C.PangoGlyphString +} + +// Native returns a pointer to the underlying PangoGlyphString. +func (v *GlyphString) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *GlyphString) native() *C.PangoGlyphString { + return (*C.PangoGlyphString)(unsafe.Pointer(v.pangoGlyphString)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-gravity.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-gravity.go new file mode 100644 index 0000000..7affb63 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-gravity.go @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" + +// "github.com/andre-hub/gotk3/glib" +// "github.com/andre-hub/gotk3/cairo" +// "unsafe" + +type Gravity int + +const ( + GRAVITY_SOUTH Gravity = C.PANGO_GRAVITY_SOUTH + GRAVITY_EAST Gravity = C.PANGO_GRAVITY_EAST + GRAVITY_NORTH Gravity = C.PANGO_GRAVITY_NORTH + GRAVITY_WEST Gravity = C.PANGO_GRAVITY_WEST + GRAVITY_AUTO Gravity = C.PANGO_GRAVITY_AUTO +) + +type GravityHint int + +const ( + GRAVITY_HINT_NATURAL GravityHint = C.PANGO_GRAVITY_HINT_NATURAL + GRAVITY_HINT_STRONG GravityHint = C.PANGO_GRAVITY_HINT_STRONG + GRAVITY_HINT_LINE GravityHint = C.PANGO_GRAVITY_HINT_LINE +) + +//double pango_gravity_to_rotation (PangoGravity gravity) G_GNUC_CONST; +func GravityToRotation(gravity Gravity) float64 { + c := C.pango_gravity_to_rotation((C.PangoGravity)(gravity)) + return float64(c) +} + +//PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix) G_GNUC_PURE; + +//PangoGravity pango_gravity_get_for_script (PangoScript script, +// PangoGravity base_gravity, +// PangoGravityHint hint) G_GNUC_CONST; + +//PangoGravity pango_gravity_get_for_script_and_width +// (PangoScript script, +// gboolean wide, +// PangoGravity base_gravity, +// PangoGravityHint hint) G_GNUC_CONST; diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go new file mode 100644 index 0000000..19bdae6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" +import ( + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" + "unsafe" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.pango_alignment_get_type()), marshalAlignment}, + {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, + {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, + + // Objects/Interfaces + // {glib.Type(C.pango_layout_get_type()), marshalLayout}, + } + glib.RegisterGValueMarshalers(tm) +} + +// Layout is a representation of PangoLayout. +type Layout struct { + pangoLayout *C.PangoLayout +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *Layout) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Layout) native() *C.PangoLayout { + return (*C.PangoLayout)(unsafe.Pointer(v.pangoLayout)) +} + +// LayoutLine is a representation of PangoLayoutLine. +type LayoutLine struct { + pangoLayoutLine *C.PangoLayout +} + +// Native returns a pointer to the underlying PangoLayoutLine. +func (v *LayoutLine) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *LayoutLine) native() *C.PangoLayoutLine { + return (*C.PangoLayoutLine)(unsafe.Pointer(v.pangoLayoutLine)) +} + +/* + * Constants + */ + +// Alignment is a representation of Pango's PangoAlignment. +type Alignment int + +const ( + ALIGN_LEFT Alignment = C.PANGO_ALIGN_LEFT + ALIGN_CENTER Alignment = C.PANGO_ALIGN_CENTER + ALIGN_RIGHT Alignment = C.PANGO_ALIGN_RIGHT +) + +func marshalAlignment(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Alignment(c), nil +} + +// WrapMode is a representation of Pango's PangoWrapMode. +type WrapMode int + +const ( + WRAP_WORD WrapMode = C.PANGO_WRAP_WORD + WRAP_CHAR WrapMode = C.PANGO_WRAP_CHAR + WRAP_WORD_CHAR WrapMode = C.PANGO_WRAP_WORD_CHAR +) + +func marshalWrapMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return WrapMode(c), nil +} + +// EllipsizeMode is a representation of Pango's PangoEllipsizeMode. +type EllipsizeMode int + +const ( + ELLIPSIZE_NONE EllipsizeMode = C.PANGO_ELLIPSIZE_NONE + ELLIPSIZE_START EllipsizeMode = C.PANGO_ELLIPSIZE_START + ELLIPSIZE_MIDDLE EllipsizeMode = C.PANGO_ELLIPSIZE_MIDDLE + ELLIPSIZE_END EllipsizeMode = C.PANGO_ELLIPSIZE_END +) + +func marshalEllipsizeMode(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return EllipsizeMode(c), nil +} + +/* +func marshalLayout(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapLayout(obj), nil +} + +func wrapLayout(obj *glib.Object) *Layout { + return &Layout{obj} +} +*/ + +//PangoLayout *pango_layout_new (PangoContext *context); +func LayoutNew(context *Context) *Layout { + c := C.pango_layout_new(context.native()) + + layout := new(Layout) + layout.pangoLayout = (*C.PangoLayout)(c) + return layout +} + +//PangoLayout *pango_layout_copy (PangoLayout *src); +func (v *Layout) Copy() *Layout { + c := C.pango_layout_copy(v.native()) + + layout := new(Layout) + layout.pangoLayout = (*C.PangoLayout)(c) + return layout +} + +//PangoContext *pango_layout_get_context (PangoLayout *layout); +func (v *Layout) GetContext() *Context { + c := C.pango_layout_get_context(v.native()) + + context := new(Context) + context.pangoContext = (*C.PangoContext)(c) + + return context +} + +//void pango_layout_set_attributes (PangoLayout *layout, +// PangoAttrList *attrs); +func (v *Layout) SetAttributes(attrs *AttrList) { + C.pango_layout_set_attributes(v.native(), attrs.native()) +} + +//PangoAttrList *pango_layout_get_attributes (PangoLayout *layout); +func (v *Layout) GetAttributes() *AttrList { + c := C.pango_layout_get_attributes(v.native()) + + attrList := new(AttrList) + attrList.pangoAttrList = (*C.PangoAttrList)(c) + + return attrList +} + +//void pango_layout_set_text (PangoLayout *layout, +// const char *text, +// int length); +func (v *Layout) SetText(text string, length int) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.pango_layout_set_text(v.native(), (*C.char)(cstr), (C.int)(length)) +} + +//const char *pango_layout_get_text (PangoLayout *layout); +func (v *Layout) GetText() string { + c := C.pango_layout_get_text(v.native()) + return C.GoString((*C.char)(c)) +} + +//gint pango_layout_get_character_count (PangoLayout *layout); +func (v *Layout) GetCharacterCount() int { + c := C.pango_layout_get_character_count(v.native()) + return int(c) +} + +//void pango_layout_set_markup (PangoLayout *layout, +// const char *markup, +// int length); +func (v *Layout) SetMarkup(text string, length int) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.pango_layout_set_markup(v.native(), (*C.char)(cstr), (C.int)(length)) +} + +//void pango_layout_set_markup_with_accel (PangoLayout *layout, +// const char *markup, +// int length, +// gunichar accel_marker, +// gunichar *accel_char); + +/* +func (v *Layout)SetMarkupWithAccel (text string, length int, accel_marker, accel_char rune){ + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.pango_layout_set_markup_with_accel (v.native(), (*C.char)(cstr), (C.int)(length), (C.gunichar)(accel_marker), (C.gunichar)(accel_char) ) +} +*/ + +//void pango_layout_set_font_description (PangoLayout *layout, +// const PangoFontDescription *desc); + +func (v *Layout) SetFontDescription(desc *FontDescription) { + C.pango_layout_set_font_description(v.native(), desc.native()) +} + +//const PangoFontDescription *pango_layout_get_font_description (PangoLayout *layout); + +func (v *Layout) GetFontDescription() *FontDescription { + c := C.pango_layout_get_font_description(v.native()) + + desc := new(FontDescription) + desc.pangoFontDescription = (*C.PangoFontDescription)(c) + + return desc +} + +//void pango_layout_set_width (PangoLayout *layout, +// int width); + +func (v *Layout) SetWidth(width int) { + C.pango_layout_set_width(v.native(), C.int(width)) +} + +//int pango_layout_get_width (PangoLayout *layout); + +func (v *Layout) GetWidth() int { + c := C.pango_layout_get_width(v.native()) + return int(c) +} + +//void pango_layout_set_height (PangoLayout *layout, +// int height); + +func (v *Layout) SetHeight(width int) { + C.pango_layout_set_height(v.native(), C.int(width)) +} + +//int pango_layout_get_height (PangoLayout *layout); + +func (v *Layout) GetHeight() int { + c := C.pango_layout_get_height(v.native()) + return int(c) +} + +//void pango_layout_set_wrap (PangoLayout *layout, +// PangoWrapMode wrap); + +func (v *Layout) SetWrap(wrap WrapMode) { + C.pango_layout_set_wrap(v.native(), C.PangoWrapMode(wrap)) +} + +//PangoWrapMode pango_layout_get_wrap (PangoLayout *layout); + +func (v *Layout) GetWrap() WrapMode { + c := C.pango_layout_get_wrap(v.native()) + return WrapMode(c) +} + +//gboolean pango_layout_is_wrapped (PangoLayout *layout); + +func (v *Layout) IsWrapped() bool { + c := C.pango_layout_is_wrapped(v.native()) + return gobool(c) +} + +//void pango_layout_set_indent (PangoLayout *layout, +// int indent); + +func (v *Layout) SetIndent(indent int) { + C.pango_layout_set_indent(v.native(), C.int(indent)) +} + +//int pango_layout_get_indent (PangoLayout *layout); + +func (v *Layout) GetIndent() int { + c := C.pango_layout_get_indent(v.native()) + return int(c) +} + +//void pango_layout_set_spacing (PangoLayout *layout, +// int spacing); +//int pango_layout_get_spacing (PangoLayout *layout); +//void pango_layout_set_justify (PangoLayout *layout, +// gboolean justify); +//gboolean pango_layout_get_justify (PangoLayout *layout); +//void pango_layout_set_auto_dir (PangoLayout *layout, +// gboolean auto_dir); +//gboolean pango_layout_get_auto_dir (PangoLayout *layout); +//void pango_layout_set_alignment (PangoLayout *layout, +// PangoAlignment alignment); +//PangoAlignment pango_layout_get_alignment (PangoLayout *layout); +// +//void pango_layout_set_tabs (PangoLayout *layout, +// PangoTabArray *tabs); +// +//PangoTabArray* pango_layout_get_tabs (PangoLayout *layout); +// +//void pango_layout_set_single_paragraph_mode (PangoLayout *layout, +// gboolean setting); +//gboolean pango_layout_get_single_paragraph_mode (PangoLayout *layout); +// +//void pango_layout_set_ellipsize (PangoLayout *layout, +// PangoEllipsizeMode ellipsize); +//PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout); +//gboolean pango_layout_is_ellipsized (PangoLayout *layout); +// +//int pango_layout_get_unknown_glyphs_count (PangoLayout *layout); +// +//void pango_layout_context_changed (PangoLayout *layout); +//guint pango_layout_get_serial (PangoLayout *layout); +// +//void pango_layout_get_log_attrs (PangoLayout *layout, +// PangoLogAttr **attrs, +// gint *n_attrs); +// +//const PangoLogAttr *pango_layout_get_log_attrs_readonly (PangoLayout *layout, +// gint *n_attrs); +// +//void pango_layout_index_to_pos (PangoLayout *layout, +// int index_, +// PangoRectangle *pos); +//void pango_layout_index_to_line_x (PangoLayout *layout, +// int index_, +// gboolean trailing, +// int *line, +// int *x_pos); +//void pango_layout_get_cursor_pos (PangoLayout *layout, +// int index_, +// PangoRectangle *strong_pos, +// PangoRectangle *weak_pos); +//void pango_layout_move_cursor_visually (PangoLayout *layout, +// gboolean strong, +// int old_index, +// int old_trailing, +// int direction, +// int *new_index, +// int *new_trailing); +//gboolean pango_layout_xy_to_index (PangoLayout *layout, +// int x, +// int y, +// int *index_, +// int *trailing); +//void pango_layout_get_extents (PangoLayout *layout, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//void pango_layout_get_pixel_extents (PangoLayout *layout, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); + +//void pango_layout_get_size (PangoLayout *layout, +// int *width, +// int *height); +func (v *Layout) GetSize() (int, int) { + var w, h C.int + C.pango_layout_get_size(v.native(), &w, &h) + return int(w), int(h) +} + +//void pango_layout_get_pixel_size (PangoLayout *layout, +// int *width, +// int *height); +//int pango_layout_get_baseline (PangoLayout *layout); +// +//int pango_layout_get_line_count (PangoLayout *layout); +//PangoLayoutLine *pango_layout_get_line (PangoLayout *layout, +// int line); +//PangoLayoutLine *pango_layout_get_line_readonly (PangoLayout *layout, +// int line); +//GSList * pango_layout_get_lines (PangoLayout *layout); +//GSList * pango_layout_get_lines_readonly (PangoLayout *layout); +// +// +//#define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type ()) +// +//GType pango_layout_line_get_type (void) G_GNUC_CONST; +// +//PangoLayoutLine *pango_layout_line_ref (PangoLayoutLine *line); +//void pango_layout_line_unref (PangoLayoutLine *line); +// +//gboolean pango_layout_line_x_to_index (PangoLayoutLine *line, +// int x_pos, +// int *index_, +// int *trailing); +//void pango_layout_line_index_to_x (PangoLayoutLine *line, +// int index_, +// gboolean trailing, +// int *x_pos); +//void pango_layout_line_get_x_ranges (PangoLayoutLine *line, +// int start_index, +// int end_index, +// int **ranges, +// int *n_ranges); +//void pango_layout_line_get_extents (PangoLayoutLine *line, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +// +//typedef struct _PangoLayoutIter PangoLayoutIter; +// +//#define PANGO_TYPE_LAYOUT_ITER (pango_layout_iter_get_type ()) +// +//GType pango_layout_iter_get_type (void) G_GNUC_CONST; +// +//PangoLayoutIter *pango_layout_get_iter (PangoLayout *layout); +//PangoLayoutIter *pango_layout_iter_copy (PangoLayoutIter *iter); +//void pango_layout_iter_free (PangoLayoutIter *iter); +// +//int pango_layout_iter_get_index (PangoLayoutIter *iter); +//PangoLayoutRun *pango_layout_iter_get_run (PangoLayoutIter *iter); +//PangoLayoutRun *pango_layout_iter_get_run_readonly (PangoLayoutIter *iter); +//PangoLayoutLine *pango_layout_iter_get_line (PangoLayoutIter *iter); +//PangoLayoutLine *pango_layout_iter_get_line_readonly (PangoLayoutIter *iter); +//gboolean pango_layout_iter_at_last_line (PangoLayoutIter *iter); +//PangoLayout *pango_layout_iter_get_layout (PangoLayoutIter *iter); +// +//gboolean pango_layout_iter_next_char (PangoLayoutIter *iter); +//gboolean pango_layout_iter_next_cluster (PangoLayoutIter *iter); +//gboolean pango_layout_iter_next_run (PangoLayoutIter *iter); +//gboolean pango_layout_iter_next_line (PangoLayoutIter *iter); +// +//void pango_layout_iter_get_char_extents (PangoLayoutIter *iter, +// PangoRectangle *logical_rect); +//void pango_layout_iter_get_cluster_extents (PangoLayoutIter *iter, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//void pango_layout_iter_get_run_extents (PangoLayoutIter *iter, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//void pango_layout_iter_get_line_extents (PangoLayoutIter *iter, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +/* All the yranges meet, unlike the logical_rect's (i.e. the yranges + * assign between-line spacing to the nearest line) + */ +//void pango_layout_iter_get_line_yrange (PangoLayoutIter *iter, +// int *y0_, +// int *y1_); +//void pango_layout_iter_get_layout_extents (PangoLayoutIter *iter, +// PangoRectangle *ink_rect, +// PangoRectangle *logical_rect); +//int pango_layout_iter_get_baseline (PangoLayoutIter *iter); +// diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go.h new file mode 100644 index 0000000..0f4e2fd --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-layout.go.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +static PangoLayout* toPangoLayout(void *p) +{ + return ( (PangoLayout*) (p) ); +} + diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-types.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-types.go new file mode 100644 index 0000000..bec95ea --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango-types.go @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +// #include +import "C" +import ( + "unsafe" +) + +// LogAttr is a representation of PangoLogAttr. +type LogAttr struct { + pangoLogAttr *C.PangoLogAttr +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *LogAttr) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *LogAttr) native() *C.PangoLogAttr { + return (*C.PangoLogAttr)(unsafe.Pointer(v.pangoLogAttr)) +} + +// EngineLang is a representation of PangoEngineLang. +type EngineLang struct { + pangoEngineLang *C.PangoEngineLang +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *EngineLang) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EngineLang) native() *C.PangoEngineLang { + return (*C.PangoEngineLang)(unsafe.Pointer(v.pangoEngineLang)) +} + +// EngineShape is a representation of PangoEngineShape. +type EngineShape struct { + pangoEngineShape *C.PangoEngineShape +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *EngineShape) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EngineShape) native() *C.PangoEngineShape { + return (*C.PangoEngineShape)(unsafe.Pointer(v.pangoEngineShape)) +} + +// Font is a representation of PangoFont. +type Font struct { + pangoFont *C.PangoFont +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *Font) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Font) native() *C.PangoFont { + return (*C.PangoFont)(unsafe.Pointer(v.pangoFont)) +} + +// FontMap is a representation of PangoFontMap. +type FontMap struct { + pangoFontMap *C.PangoFontMap +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *FontMap) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *FontMap) native() *C.PangoFontMap { + return (*C.PangoFontMap)(unsafe.Pointer(v.pangoFontMap)) +} + +// Rectangle is a representation of PangoRectangle. +type Rectangle struct { + pangoRectangle *C.PangoRectangle +} + +// Native returns a pointer to the underlying PangoLayout. +func (v *Rectangle) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *Rectangle) native() *C.PangoRectangle { + return (*C.PangoRectangle)(unsafe.Pointer(v.pangoRectangle)) +} + +// Glyph is a representation of PangoGlyph +type Glyph uint32 + +//void pango_extents_to_pixels (PangoRectangle *inclusive, +// PangoRectangle *nearest); +func (inclusive *Rectangle) ExtentsToPixels(nearest *Rectangle) { + C.pango_extents_to_pixels(inclusive.native(), nearest.native()) +} + +func RectangleNew(x, y, width, height int) *Rectangle { + r := new(Rectangle) + r.pangoRectangle = C.createPangoRectangle((C.int)(x), (C.int)(y), (C.int)(width), (C.int)(height)) + return r +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go new file mode 100644 index 0000000..b540f73 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go @@ -0,0 +1,56 @@ +// Copyright (c) 2013-2014 Conformal Systems +// +// 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. + +// Go bindings for Pango. +package pango + +// #cgo pkg-config: pango +// #include +// #include "pango.go.h" +import "C" +import ( +// "github.com/andre-hub/gotk3/glib" +// "unsafe" +) + +func init() { + +} + +/* + * Type conversions + */ + +func gbool(b bool) C.gboolean { + if b { + return C.gboolean(1) + } + return C.gboolean(0) +} +func gobool(b C.gboolean) bool { + if b != 0 { + return true + } + return false +} + +/* + * Constantes + */ + +const ( + SCALE int = 1024 +) diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go.h new file mode 100644 index 0000000..74c81e4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pango.go.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#include "pango-attributes.go.h" +#include "pango-layout.go.h" + +#include "pangocairo.go.h" + + + +static PangoRectangle * +createPangoRectangle(int x, int y, int width, int height) +{ + PangoRectangle *r = (PangoRectangle *)malloc(sizeof(PangoRectangle)); + r->x = x; + r->y = y; + r->width = width; + r->height = height; + return r; +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go new file mode 100644 index 0000000..e843668 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015- terrak + * + * This file originated from: http://www.terrak.net/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package pango + +// #cgo pkg-config: pango pangocairo +// #include +// #include +// #include +// #include "pango.go.h" +import "C" +import ( + // "github.com/gotk3/gotk3/glib" + "unsafe" + + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/cairo" +) + +func init() { + // tm := []glib.TypeMarshaler{ + // // Enums + // {glib.Type(C.pango_alignement_get_type()), marshalAlignment}, + // {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, + // {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, + // } + // glib.RegisterGValueMarshalers(tm) +} + +func cairo_context(cr *cairo.Context) *C.cairo_t { + return (*C.cairo_t)(cr.GetCContext()) +} + +/* Convenience + */ +//PangoContext *pango_cairo_create_context (cairo_t *cr); +func CairoCreateContext(cr *cairo.Context) *Context { + c := C.pango_cairo_create_context(cairo_context(cr)) + context := new(Context) + context.pangoContext = (*C.PangoContext)(c) + return context +} + +//PangoLayout *pango_cairo_create_layout (cairo_t *cr); +func CairoCreateLayout(cr *cairo.Context) *Layout { + c := C.pango_cairo_create_layout(cairo_context(cr)) + layout := new(Layout) + layout.pangoLayout = (*C.PangoLayout)(c) + return layout +} + +//void pango_cairo_update_layout (cairo_t *cr, +// PangoLayout *layout); +func CairoUpdateLayout(cr *cairo.Context, v *Layout) { + C.pango_cairo_update_layout(cairo_context(cr), v.native()) +} + +/* + * Rendering + */ +//void pango_cairo_show_glyph_string (cairo_t *cr, +// PangoFont *font, +// PangoGlyphString *glyphs); +func CairoShowGlyphString(cr *cairo.Context, font *Font, glyphs *GlyphString) { + C.pango_cairo_show_glyph_string(cairo_context(cr), font.native(), glyphs.native()) +} + +//void pango_cairo_show_glyph_item (cairo_t *cr, +// const char *text, +// PangoGlyphItem *glyph_item); +func CairoShowGlyphItem(cr *cairo.Context, text string, glyph_item *GlyphItem) { + cstr := C.CString(text) + defer C.free(unsafe.Pointer(cstr)) + C.pango_cairo_show_glyph_item(cairo_context(cr), (*C.char)(cstr), glyph_item.native()) +} + +//void pango_cairo_show_layout_line (cairo_t *cr, +// PangoLayoutLine *line); +func CairoShowLayoutLine(cr *cairo.Context, line *LayoutLine) { + C.pango_cairo_show_layout_line(cairo_context(cr), line.native()) +} + +//void pango_cairo_show_layout (cairo_t *cr, +// PangoLayout *layout); +func CairoShowLayout(cr *cairo.Context, layout *Layout) { + C.pango_cairo_show_layout(cairo_context(cr), layout.native()) +} + +//void pango_cairo_show_error_underline (cairo_t *cr, +// double x, +// double y, +// double width, +// double height); + +/* + * Rendering to a path + */ + +//void pango_cairo_glyph_string_path (cairo_t *cr, +// PangoFont *font, +// PangoGlyphString *glyphs); +func CairoGlyphStringPath(cr *cairo.Context, font *Font, glyphs *GlyphString) { + C.pango_cairo_glyph_string_path(cairo_context(cr), font.native(), glyphs.native()) +} + +//void pango_cairo_layout_line_path (cairo_t *cr, +// PangoLayoutLine *line); +func CairoLayoutLinePath(cr *cairo.Context, line *LayoutLine) { + C.pango_cairo_layout_line_path(cairo_context(cr), line.native()) +} + +//void pango_cairo_layout_path (cairo_t *cr, +// PangoLayout *layout); +func CairoLayoutPath(cr *cairo.Context, layout *Layout) { + C.pango_cairo_layout_path(cairo_context(cr), layout.native()) +} + +//void pango_cairo_error_underline_path (cairo_t *cr, +// double x, +// double y, +// double width, +// double height); +func CairoErrorUnderlinePath(cr *cairo.Context, x, y, width, height float64) { + C.pango_cairo_error_underline_path(cairo_context(cr), C.double(x), C.double(y), C.double(width), C.double(height)) +} diff --git a/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go.h b/Godeps/_workspace/src/github.com/gotk3/gotk3/pango/pangocairo.go.h new file mode 100644 index 0000000..e69de29 diff --git a/fw-settings/builder.go b/fw-settings/builder.go index c66bca2..a82d878 100644 --- a/fw-settings/builder.go +++ b/fw-settings/builder.go @@ -7,8 +7,8 @@ import ( "path/filepath" "reflect" - "github.com/gotk3/gotk3/glib" - "github.com/gotk3/gotk3/gtk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk" "github.com/subgraph/fw-daemon/fw-settings/definitions" ) diff --git a/fw-settings/config.go b/fw-settings/config.go index 6aa2542..6e82d22 100644 --- a/fw-settings/config.go +++ b/fw-settings/config.go @@ -1,8 +1,8 @@ package main import ( - "github.com/gotk3/gotk3/gtk" - "github.com/op/go-logging" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/op/go-logging" ) var levelToId = map[int32]string{ diff --git a/fw-settings/dbus.go b/fw-settings/dbus.go index 5010ce7..a4b9efe 100644 --- a/fw-settings/dbus.go +++ b/fw-settings/dbus.go @@ -1,7 +1,7 @@ package main import ( - "github.com/godbus/dbus" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/godbus/dbus" ) type dbusObject struct { diff --git a/fw-settings/main.go b/fw-settings/main.go index 50017eb..72edc65 100644 --- a/fw-settings/main.go +++ b/fw-settings/main.go @@ -4,8 +4,8 @@ import ( "os" "fmt" - "github.com/gotk3/gotk3/glib" - "github.com/gotk3/gotk3/gtk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/glib" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk" ) func failDialog(parent *gtk.Window, format string, args ...interface{}) { diff --git a/fw-settings/rule_edit.go b/fw-settings/rule_edit.go index a491c2f..c312470 100644 --- a/fw-settings/rule_edit.go +++ b/fw-settings/rule_edit.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/gotk3/gotk3/gtk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk" "net" "strconv" "strings" diff --git a/fw-settings/rules.go b/fw-settings/rules.go index 341c648..78d32a0 100644 --- a/fw-settings/rules.go +++ b/fw-settings/rules.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/gotk3/gotk3/gtk" + "github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/gotk3/gotk3/gtk" "strings" )