Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
9877 lines (8369 sloc) 290 KB
// Copyright (c) 2013-2014 Conformal Systems <info@conformal.com>
//
// This file originated from: http://opensource.conformal.com/
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// 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 additional 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: gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0
// #include <gtk/gtk.h>
// #include "gtk.go.h"
import "C"
import (
"errors"
"fmt"
"reflect"
"runtime"
"sync"
"unsafe"
"github.com/gotk3/gotk3/cairo"
"github.com/gotk3/gotk3/gdk"
"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_corner_type_get_type()), marshalCornerType},
{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_text_direction_get_type()), marshalTextDirection},
{glib.Type(C.gtk_text_search_flags_get_type()), marshalTextSearchFlags},
{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_button_box_get_type()), marshalButtonBox},
{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_progress_get_type()), marshalCellRendererProgress},
{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_frame_get_type()), marshalFrame},
{glib.Type(C.gtk_aspect_frame_get_type()), marshalAspectFrame},
{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_overlay_get_type()), marshalOverlay},
{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_toggle_tool_button_get_type()), marshalToggleToolButton},
{glib.Type(C.gtk_tool_item_get_type()), marshalToolItem},
{glib.Type(C.gtk_tooltip_get_type()), marshalTooltip},
{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_text_mark_get_type()), marshalTextMark},
{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
}
func cGSList(clist *glib.SList) *C.GSList {
if clist == nil {
return nil
}
return (*C.GSList)(unsafe.Pointer(clist.Native()))
}
func free(str ...interface{}) {
for _, s := range str {
switch x := s.(type) {
case *C.char:
C.free(unsafe.Pointer(x))
case []*C.char:
for _, cp := range x {
C.free(unsafe.Pointer(cp))
}
/*
case C.gpointer:
C.g_free(C.gpointer(c))
*/
default:
fmt.Printf("utils.go free(): Unknown type: %T\n", x)
}
}
}
func goString(cstr *C.gchar) string {
return C.GoString((*C.char)(cstr))
}
// 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
}
// TreeViewGridLine is a representation of GTK's GtkTreeViewGridLine.
type TreeViewGridLines int
const (
TREE_VIEW_GRID_LINES_NONE TreeViewGridLines = C.GTK_TREE_VIEW_GRID_LINES_NONE
TREE_VIEW_GRID_LINES_HORIZONTAL TreeViewGridLines = C.GTK_TREE_VIEW_GRID_LINES_HORIZONTAL
TREE_VIEW_GRID_LINES_VERTICAL TreeViewGridLines = C.GTK_TREE_VIEW_GRID_LINES_VERTICAL
TREE_VIEW_GRID_LINES_BOTH TreeViewGridLines = C.GTK_TREE_VIEW_GRID_LINES_BOTH
)
// 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
)
// Use as column id in SetSortColumnId to specify ListStore sorted
// by default column or unsorted
const (
SORT_COLUMN_DEFAULT int = -1
SORT_COLUMN_UNSORTED int = -2
)
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
}
// TextDirection is a representation of GTK's GtkTextDirection.
type TextDirection int
const (
TEXT_DIR_NONE TextDirection = C.GTK_TEXT_DIR_NONE
TEXT_DIR_LTR TextDirection = C.GTK_TEXT_DIR_LTR
TEXT_DIR_RTL TextDirection = C.GTK_TEXT_DIR_RTL
)
func marshalTextDirection(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return TextDirection(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
}
// TextSearchFlags is a representation of GTK's GtkTextSearchFlags.
type TextSearchFlags int
const (
TEXT_SEARCH_VISIBLE_ONLY TextSearchFlags = C.GTK_TEXT_SEARCH_VISIBLE_ONLY
TEXT_SEARCH_TEXT_ONLY TextSearchFlags = C.GTK_TEXT_SEARCH_TEXT_ONLY
TEXT_SEARCH_CASE_INSENSITIVE TextSearchFlags = C.GTK_TEXT_SEARCH_CASE_INSENSITIVE
)
func marshalTextSearchFlags(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return TextSearchFlags(c), nil
}
// CornerType is a representation of GTK's GtkCornerType.
type CornerType int
const (
CORNER_TOP_LEFT CornerType = C.GTK_CORNER_TOP_LEFT
CORNER_BOTTOM_LEFT CornerType = C.GTK_CORNER_BOTTOM_LEFT
CORNER_TOP_RIGHT CornerType = C.GTK_CORNER_TOP_RIGHT
CORNER_BOTTOM_RIGHT CornerType = C.GTK_CORNER_BOTTOM_RIGHT
)
func marshalCornerType(p uintptr) (interface{}, error) {
c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p)))
return CornerType(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] = goString(cstr)
C.free(unsafe.Pointer(cstr))
}
*args = unhandled
} else {
C.gtk_init(nil, nil)
}
}
/*
InitCheck() is a wrapper around gtk_init_check() and works exactly like Init()
only that it doesn't terminate the program if initialization fails.
*/
func InitCheck(args *[]string) error {
success := false
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))
}
success = gobool(C.gtk_init_check((*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] = goString(cstr)
C.free(unsafe.Pointer(cstr))
}
*args = unhandled
} else {
success = gobool(C.gtk_init_check(nil, nil))
}
if success {
return nil
} else {
return errors.New("Unable to initialize GTK")
}
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 {
return goString(C.gtk_assistant_get_page_title(v.native(), page.toWidget()))
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(unsafe.Pointer(c))
return &Builder{obj}, nil
}
// BuilderNewFromFile is a wrapper around gtk_builder_new_from_file().
func BuilderNewFromFile(filePath string) (*Builder, error) {
cstr := C.CString(filePath)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_builder_new_from_file((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(unsafe.Pointer(c))
return &Builder{obj}, nil
}
// BuilderNewFromResource is a wrapper around gtk_builder_new_from_resource().
func BuilderNewFromResource(resourcePath string) (*Builder, error) {
cstr := C.CString(resourcePath)
defer C.free(unsafe.Pointer(cstr))
c := C.gtk_builder_new_from_resource((*C.gchar)(cstr))
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(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(goString(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(goString(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(goString(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
// Interfaces
IActionable
}
// 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 := glib.Take(unsafe.Pointer(c))
return wrapButton(obj), nil
}
func wrapButton(obj *glib.Object) *Button {
actionable := &Actionable{obj}
return &Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}, actionable}
}
// ButtonNew() is a wrapper around gtk_button_new().
func ButtonNew() (*Button, error) {
c := C.gtk_button_new()
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(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 := glib.Take(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 := glib.Take(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 goString(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)
}
// 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 := glib.Take(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{glib.Take(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)
actionable := wrapActionable(obj)
return &ColorButton{Button{Bin{Container{Widget{
glib.InitiallyUnowned{obj}}}}, actionable}, *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(glib.Take(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(glib.Take(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 := glib.Take(unsafe.Pointer(c))
return wrapBox(obj), nil
}
func wrapBox(obj *glib.Object) *Box {
return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}}
}
func (v *Box) toOrientable() *C.GtkOrientable {
if v == nil {
return nil
}
return C.toGtkOrientable(unsafe.Pointer(v.GObject))
}
// GetOrientation() is a wrapper around C.gtk_orientable_get_orientation() for a GtkBox
func (v *Box) GetOrientation() Orientation {
return Orientation(C.gtk_orientable_get_orientation(v.toOrientable()))
}
// SetOrientation() is a wrapper around C.gtk_orientable_set_orientation() for a GtkBox
func (v *Box) SetOrientation(o Orientation) {
C.gtk_orientable_set_orientation(v.toOrientable(), C.GtkOrientation(o))
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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_spinner_new().
func CellRendererSpinnerNew() (*CellRendererSpinner, error) {
c := C.gtk_cell_renderer_spinner_new()
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(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 := glib.Take(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 := glib.Take(unsafe.Pointer(c))
return wrapCellRendererPixbuf(obj), nil
}
/*
* GtkCellRendererProgress
*/
// CellRendererProgress is a representation of GTK's GtkCellRendererProgress.
type CellRendererProgress struct {
CellRenderer
}
// native returns a pointer to the underlying GtkCellRendererProgress.
func (v *CellRendererProgress) native() *C.GtkCellRendererProgress {
if v == nil || v.GObject == nil {
return nil
}
p := unsafe.Pointer(v.GObject)
return C.toGtkCellRendererProgress(p)
}
func marshalCellRendererProgress(p uintptr) (interface{}, error) {
c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
obj := glib.Take(unsafe.Pointer(c))
return wrapCellRendererProgress(obj), nil
}
func wrapCellRendererProgress(obj *glib.Object) *CellRendererProgress {
return &CellRendererProgress{CellRenderer{glib.InitiallyUnowned{obj}}}
}
// CellRendererProgressNew is a wrapper around gtk_cell_renderer_progress_new().
func CellRendererProgressNew() (*CellRendererProgress, error) {
c := C.gtk_cell_renderer_progress_new()
if c == nil {
return nil, nilPtrErr
}
obj := glib.Take(unsafe.Pointer(c))
return wrapCellRendererProgress(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 around 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 := glib.Take(unsafe.Pointer(c))
return wrapCheckButton(obj), nil
}
func wrapCheckButton(obj *glib.Object) *CheckButton {
actionable := wrapActionable(obj)
return &CheckButton{ToggleButton{Button{Bin{Container{Widget{
glib.InitiallyUnowned{obj}}}}, actionable}}}
}
// 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 := glib.Take(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(glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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{glib.Take(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{glib.Take(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 goString(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{glib.Take(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 := glib.Take(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
// GetChildren is a wrapper around gtk_container_get_children().
func (v *Container) GetChildren() *glib.List {
clist := C.gtk_container_get_children(v.native())
glist := glib.WrapList(uintptr(unsafe.Pointer(clist)))
glist.DataWrapper(func(ptr unsafe.Pointer) interface{} {
return wrapWidget(glib.Take(ptr))
})
return glist
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(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))
}
// ChildGetProperty is a wrapper around gtk_container_child_get_property().
func (v *Container) ChildGetProperty(child IWidget, name string, valueType glib.Type) (interface{}, error) {
gv, e := glib.ValueInit(valueType)
if e != nil {
return nil, e
}
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
C.gtk_container_child_get_property(v.native(), child.toWidget(), (*C.gchar)(cstr), (*C.GValue)(unsafe.Pointer(gv.Native())))
return gv.GoValue()
}
// 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.Native())))
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))
}
/*
* 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(glib.Take(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(goString(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(goString(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
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(unsafe.Pointer(c))
return wrapDialog(obj), nil
}
// Run() is a wrapper around gtk_dialog_run().
func (v *Dialog) Run() ResponseType {
c := C.gtk_dialog_run(v.native())
return ResponseType(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 := glib.Take(unsafe.Pointer(c))
return wrapButton(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 := glib.Take(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 := glib.Take(unsafe.Pointer(c))
b := &Box{Container{Widget{glib.InitiallyUnowned{obj}}}}
return b, nil
}
// DialogNewWithButtons() is a wrapper around gtk_dialog_new_with_buttons().
// i.e: []interface{}{"Accept", gtk.RESPONSE_ACCEPT}.
func DialogNewWithButtons(title string, parent IWindow, flags DialogFlags, buttons ...[]interface{}) (dialog *Dialog, err error) {
cstr := (*C.gchar)(C.CString(title))
defer C.free(unsafe.Pointer(cstr))
var w *C.GtkWindow = nil
if parent != nil {
w = parent.toWindow()
}
var cbutton *C.gchar = nil
c := C._gtk_dialog_new_with_buttons(cstr, w, C.GtkDialogFlags(flags), cbutton)
if c == nil {
return nil, nilPtrErr
}
dialog = wrapDialog(glib.Take(unsafe.Pointer(c)))
for idx := 0; idx < len(buttons); idx++ {
cbutton = (*C.gchar)(C.CString(buttons[idx][0].(string)))
defer C.free(unsafe.Pointer(cbutton))
if C.gtk_dialog_add_button(dialog.native(), cbutton, C.gint(buttons[idx][1].(ResponseType))) == nil {
return nil, nilPtrErr
}
}
return
}
// 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 := glib.Take(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 := glib.Take(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 := glib.Take(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 goString(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 := glib.Take(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 goString(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 goString(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{glib.Take(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 := glib.Take(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())
}
// SetIconFromPixbuf is a wrapper around gtk_entry_set_icon_from_pixbuf().
func (v *Entry) SetIconFromPixbuf(iconPos EntryIconPosition, pixbuf *gdk.Pixbuf) {
C.gtk_entry_set_icon_from_pixbuf(v.native(),
C.GtkEntryIconPosition(iconPos),
(*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())))
}
// 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))
}
// RemoveIcon() is a wrapper around gtk_entry_set_icon_from_icon_name()
// with a nil pointer to the icon name.
func (v *Entry) RemoveIcon(iconPos EntryIconPosition) {
C.gtk_entry_set_icon_from_icon_name(v.native(),
C.GtkEntryIconPosition(iconPos), nil)
}
// 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 goString(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 goString(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 goString(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
*/