Gen: Run script
- commit
- 046618190fd0db74ce0414d49202ba493f91912e
- author
- jwijenbergh · · 2024-01-08 16:40 UTC
- parent
- 1e910b3
- signature
- GPG Unverified
1A2298F6C34F96E5The key is unknown
504 files · +37346 -80
M v4/adw/adw-about-window.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -14,6 +16,10 @@ type AboutWindowClass struct { | |||
| 14 | 16 | ParentClass uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *AboutWindowClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | var xShowAboutWindow func(uintptr, string, ...interface{}) | |
| 18 | 24 | ||
| 19 | 25 | // A convenience function for showing an application’s about window. | |
M v4/adw/adw-action-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,6 +17,10 @@ type ActionRowClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *ActionRowClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | // A [class@Gtk.ListBoxRow] used to present actions. | |
| 19 | 25 | // | |
| 20 | 26 | // <picture> | |
M v4/adw/adw-animation-target.go +14 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,12 +16,24 @@ type AnimationTargetFunc func(float64, uintptr) | |||
| 14 | 16 | type AnimationTargetClass struct { | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *AnimationTargetClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | type CallbackAnimationTargetClass struct { | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *CallbackAnimationTargetClass) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | type PropertyAnimationTargetClass struct { | |
| 21 | 31 | } | |
| 22 | 32 | ||
| 33 | + | func (x *PropertyAnimationTargetClass) GoPointer() uintptr { | |
| 34 | + | return uintptr(unsafe.Pointer(x)) | |
| 35 | + | } | |
| 36 | + | ||
| 23 | 37 | // Represents a value [class@Animation] can animate. | |
| 24 | 38 | type AnimationTarget struct { | |
| 25 | 39 | gobject.Object | |
M v4/adw/adw-animation.go +13 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,17 @@ import ( | |||
| 11 | 13 | type AnimationClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *AnimationClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | const ( | |
| 21 | + | // Indicates an [class@Animation] with an infinite duration. | |
| 22 | + | // | |
| 23 | + | // This value is mostly used internally. | |
| 24 | + | DURATION_INFINITE uint = 4294967295 | |
| 25 | + | ) | |
| 26 | + | ||
| 14 | 27 | // Describes the possible states of an [class@Animation]. | |
| 15 | 28 | // | |
| 16 | 29 | // The state can be controlled with [method@Animation.play], | |
M v4/adw/adw-application-window.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -18,6 +20,10 @@ type ApplicationWindowClass struct { | |||
| 18 | 20 | Padding uintptr | |
| 19 | 21 | } | |
| 20 | 22 | ||
| 23 | + | func (x *ApplicationWindowClass) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 21 | 27 | // A freeform application window. | |
| 22 | 28 | // | |
| 23 | 29 | // <picture> | |
M v4/adw/adw-application.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -16,6 +18,10 @@ type ApplicationClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *ApplicationClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A base class for Adwaita applications. | |
| 20 | 26 | // | |
| 21 | 27 | // `AdwApplication` handles library initialization by calling [func@init] in the | |
M v4/adw/adw-avatar.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,6 +15,10 @@ type AvatarClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *AvatarClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A widget displaying an image, with a generated fallback. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-banner.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type BannerClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *BannerClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A bar with contextual information. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-bin.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type BinClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *BinClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A widget with one child. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-button-content.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ButtonContentClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ButtonContentClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A helper widget for creating buttons. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-carousel-indicator-dots.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type CarouselIndicatorDotsClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *CarouselIndicatorDotsClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A dots indicator for [class@Carousel]. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-carousel-indicator-lines.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type CarouselIndicatorLinesClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *CarouselIndicatorLinesClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A lines indicator for [class@Carousel]. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-carousel.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,6 +15,10 @@ type CarouselClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *CarouselClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A paginated scrolling widget. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-clamp-layout.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| @@ -11,6 +13,10 @@ type ClampLayoutClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *ClampLayoutClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // A layout manager constraining its children to a given size. | |
| 15 | 21 | // | |
| 16 | 22 | // <picture> | |
M v4/adw/adw-clamp-scrollable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ClampScrollableClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ClampScrollableClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A scrollable [class@Clamp]. | |
| 16 | 22 | // | |
| 17 | 23 | // `AdwClampScrollable` is a variant of [class@Clamp] that implements the | |
M v4/adw/adw-clamp.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ClampClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ClampClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A widget constraining its child to a given size. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-combo-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -16,6 +18,10 @@ type ComboRowClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *ComboRowClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A [class@Gtk.ListBoxRow] used to choose from a list of items. | |
| 20 | 26 | // | |
| 21 | 27 | // <picture> | |
M v4/adw/adw-entry-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type EntryRowClass struct { | |||
| 14 | 16 | ParentClass uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *EntryRowClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // A [class@Gtk.ListBoxRow] with an embedded text entry. | |
| 18 | 24 | // | |
| 19 | 25 | // <picture> | |
M v4/adw/adw-enum-list-model.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -12,10 +14,18 @@ type EnumListItemClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *EnumListItemClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type EnumListModelClass struct { | |
| 16 | 22 | ParentClass uintptr | |
| 17 | 23 | } | |
| 18 | 24 | ||
| 25 | + | func (x *EnumListModelClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 19 | 29 | // `AdwEnumListItem` is the type of items in a [class@EnumListModel]. | |
| 20 | 30 | type EnumListItem struct { | |
| 21 | 31 | gobject.Object | |
M v4/adw/adw-expander-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,6 +17,10 @@ type ExpanderRowClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *ExpanderRowClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | // A [class@Gtk.ListBoxRow] used to reveal widgets. | |
| 19 | 25 | // | |
| 20 | 26 | // <picture> | |
M v4/adw/adw-flap.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,6 +15,10 @@ type FlapClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *FlapClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // Describes the possible folding behavior of a [class@Flap] widget. | |
| 17 | 23 | type FlapFoldPolicy int | |
| 18 | 24 | ||
M v4/adw/adw-header-bar.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type HeaderBarClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *HeaderBarClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Describes title centering behavior of a [class@HeaderBar] widget. | |
| 16 | 22 | type CenteringPolicy int | |
| 17 | 23 | ||
M v4/adw/adw-leaflet.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,10 +15,18 @@ type LeafletClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *LeafletClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | type LeafletPageClass struct { | |
| 17 | 23 | ParentClass uintptr | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *LeafletPageClass) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | // Describes the possible transitions in a [class@Leaflet] widget. | |
| 21 | 31 | // | |
| 22 | 32 | // New values may be added to this enumeration over time. | |
M v4/adw/adw-message-dialog.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -17,6 +19,10 @@ type MessageDialogClass struct { | |||
| 17 | 19 | Padding uintptr | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *MessageDialogClass) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 20 | 26 | // Describes the possible styles of [class@MessageDialog] response buttons. | |
| 21 | 27 | // | |
| 22 | 28 | // See [method@MessageDialog.set_response_appearance]. | |
M v4/adw/adw-password-entry-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type PasswordEntryRowClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *PasswordEntryRowClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A [class@EntryRow] tailored for entering secrets. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-preferences-group.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -14,6 +16,10 @@ type PreferencesGroupClass struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *PreferencesGroupClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // A group of preference rows. | |
| 18 | 24 | // | |
| 19 | 25 | // <picture> | |
M v4/adw/adw-preferences-page.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -14,6 +16,10 @@ type PreferencesPageClass struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *PreferencesPageClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // A page from [class@PreferencesWindow]. | |
| 18 | 24 | // | |
| 19 | 25 | // <picture> | |
M v4/adw/adw-preferences-row.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,6 +17,10 @@ type PreferencesRowClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *PreferencesRowClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | // A [class@Gtk.ListBoxRow] used to present preferences. | |
| 19 | 25 | // | |
| 20 | 26 | // The `AdwPreferencesRow` widget has a title that [class@PreferencesWindow] | |
M v4/adw/adw-preferences-window.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -16,6 +18,10 @@ type PreferencesWindowClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *PreferencesWindowClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A window to present an application's preferences. | |
| 20 | 26 | // | |
| 21 | 27 | // <picture> | |
M v4/adw/adw-split-button.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -14,6 +16,10 @@ type SplitButtonClass struct { | |||
| 14 | 16 | ParentClass uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *SplitButtonClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // A combined button and dropdown widget. | |
| 18 | 24 | // | |
| 19 | 25 | // <picture> | |
M v4/adw/adw-spring-animation.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type SpringAnimationClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *SpringAnimationClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // A spring-based [class@Animation]. | |
| 15 | 21 | // | |
| 16 | 22 | // `AdwSpringAnimation` implements an animation driven by a physical model of a | |
M v4/adw/adw-spring-params.go +120 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package adw was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Physical parameters of a spring for [class@SpringAnimation]. | |
| 5 | 12 | // | |
| 6 | 13 | // Any spring can be described by three parameters: mass, stiffness and damping. | |
| @@ -33,3 +40,116 @@ package adw | |||
| 33 | 40 | // As such | |
| 34 | 41 | type SpringParams struct { | |
| 35 | 42 | } | |
| 43 | + | ||
| 44 | + | func (x *SpringParams) GoPointer() uintptr { | |
| 45 | + | return uintptr(unsafe.Pointer(x)) | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | var xNewSpringParams func(float64, float64, float64) *SpringParams | |
| 49 | + | ||
| 50 | + | // Creates a new `AdwSpringParams` from @mass, @stiffness and @damping_ratio. | |
| 51 | + | // | |
| 52 | + | // The damping value is calculated from @damping_ratio and the other two | |
| 53 | + | // parameters. | |
| 54 | + | // | |
| 55 | + | // - If @damping_ratio is 0, the spring will not be damped and will oscillate | |
| 56 | + | // endlessly. | |
| 57 | + | // - If @damping_ratio is between 0 and 1, the spring is underdamped and will | |
| 58 | + | // always overshoot. | |
| 59 | + | // - If @damping_ratio is 1, the spring is critically damped and will reach its | |
| 60 | + | // resting position the quickest way possible. | |
| 61 | + | // - If @damping_ratio is larger than 1, the spring is overdamped and will reach | |
| 62 | + | // its resting position faster than it can complete an oscillation. | |
| 63 | + | // | |
| 64 | + | // [ctor@SpringParams.new_full] allows to pass a raw damping value instead. | |
| 65 | + | func NewSpringParams(DampingRatioVar float64, MassVar float64, StiffnessVar float64) *SpringParams { | |
| 66 | + | ||
| 67 | + | cret := xNewSpringParams(DampingRatioVar, MassVar, StiffnessVar) | |
| 68 | + | return cret | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | var xNewFullSpringParams func(float64, float64, float64) *SpringParams | |
| 72 | + | ||
| 73 | + | // Creates a new `AdwSpringParams` from @mass, @stiffness and @damping. | |
| 74 | + | // | |
| 75 | + | // See [ctor@SpringParams.new] for a simplified constructor using damping ratio | |
| 76 | + | // instead of @damping. | |
| 77 | + | func NewFullSpringParams(DampingVar float64, MassVar float64, StiffnessVar float64) *SpringParams { | |
| 78 | + | ||
| 79 | + | cret := xNewFullSpringParams(DampingVar, MassVar, StiffnessVar) | |
| 80 | + | return cret | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xSpringParamsGetDamping func(uintptr) float64 | |
| 84 | + | ||
| 85 | + | // Gets the damping of @self. | |
| 86 | + | func (x *SpringParams) GetDamping() float64 { | |
| 87 | + | ||
| 88 | + | cret := xSpringParamsGetDamping(x.GoPointer()) | |
| 89 | + | return cret | |
| 90 | + | } | |
| 91 | + | ||
| 92 | + | var xSpringParamsGetDampingRatio func(uintptr) float64 | |
| 93 | + | ||
| 94 | + | // Gets the damping ratio of @self. | |
| 95 | + | func (x *SpringParams) GetDampingRatio() float64 { | |
| 96 | + | ||
| 97 | + | cret := xSpringParamsGetDampingRatio(x.GoPointer()) | |
| 98 | + | return cret | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | var xSpringParamsGetMass func(uintptr) float64 | |
| 102 | + | ||
| 103 | + | // Gets the mass of @self. | |
| 104 | + | func (x *SpringParams) GetMass() float64 { | |
| 105 | + | ||
| 106 | + | cret := xSpringParamsGetMass(x.GoPointer()) | |
| 107 | + | return cret | |
| 108 | + | } | |
| 109 | + | ||
| 110 | + | var xSpringParamsGetStiffness func(uintptr) float64 | |
| 111 | + | ||
| 112 | + | // Gets the stiffness of @self. | |
| 113 | + | func (x *SpringParams) GetStiffness() float64 { | |
| 114 | + | ||
| 115 | + | cret := xSpringParamsGetStiffness(x.GoPointer()) | |
| 116 | + | return cret | |
| 117 | + | } | |
| 118 | + | ||
| 119 | + | var xSpringParamsRef func(uintptr) *SpringParams | |
| 120 | + | ||
| 121 | + | // Increases the reference count of @self. | |
| 122 | + | func (x *SpringParams) Ref() *SpringParams { | |
| 123 | + | ||
| 124 | + | cret := xSpringParamsRef(x.GoPointer()) | |
| 125 | + | return cret | |
| 126 | + | } | |
| 127 | + | ||
| 128 | + | var xSpringParamsUnref func(uintptr) | |
| 129 | + | ||
| 130 | + | // Decreases the reference count of @self. | |
| 131 | + | // | |
| 132 | + | // If the last reference is dropped, the structure is freed. | |
| 133 | + | func (x *SpringParams) Unref() { | |
| 134 | + | ||
| 135 | + | xSpringParamsUnref(x.GoPointer()) | |
| 136 | + | ||
| 137 | + | } | |
| 138 | + | ||
| 139 | + | func init() { | |
| 140 | + | lib, err := purego.Dlopen(core.GetPath("ADW"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 141 | + | if err != nil { | |
| 142 | + | panic(err) | |
| 143 | + | } | |
| 144 | + | ||
| 145 | + | core.PuregoSafeRegister(&xNewSpringParams, lib, "adw_spring_params_new") | |
| 146 | + | core.PuregoSafeRegister(&xNewFullSpringParams, lib, "adw_spring_params_new_full") | |
| 147 | + | ||
| 148 | + | core.PuregoSafeRegister(&xSpringParamsGetDamping, lib, "adw_spring_params_get_damping") | |
| 149 | + | core.PuregoSafeRegister(&xSpringParamsGetDampingRatio, lib, "adw_spring_params_get_damping_ratio") | |
| 150 | + | core.PuregoSafeRegister(&xSpringParamsGetMass, lib, "adw_spring_params_get_mass") | |
| 151 | + | core.PuregoSafeRegister(&xSpringParamsGetStiffness, lib, "adw_spring_params_get_stiffness") | |
| 152 | + | core.PuregoSafeRegister(&xSpringParamsRef, lib, "adw_spring_params_ref") | |
| 153 | + | core.PuregoSafeRegister(&xSpringParamsUnref, lib, "adw_spring_params_unref") | |
| 154 | + | ||
| 155 | + | } | |
M v4/adw/adw-squeezer.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,10 +14,18 @@ type SqueezerClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SqueezerClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SqueezerPageClass struct { | |
| 16 | 22 | ParentClass uintptr | |
| 17 | 23 | } | |
| 18 | 24 | ||
| 25 | + | func (x *SqueezerPageClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 19 | 29 | // Describes the possible transitions in a [class@Squeezer] widget. | |
| 20 | 30 | type SqueezerTransitionType int | |
| 21 | 31 | ||
M v4/adw/adw-status-page.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,6 +15,10 @@ type StatusPageClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *StatusPageClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A page used for empty/error states and similar use-cases. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-style-manager.go +53 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -12,6 +14,10 @@ type StyleManagerClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *StyleManagerClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Application color schemes for [property@StyleManager:color-scheme]. | |
| 16 | 22 | type ColorScheme int | |
| 17 | 23 | ||
| @@ -163,6 +169,50 @@ func (c *StyleManager) SetGoPointer(ptr uintptr) { | |||
| 163 | 169 | c.Ptr = ptr | |
| 164 | 170 | } | |
| 165 | 171 | ||
| 172 | + | var xStyleManagerGetDefault func() uintptr | |
| 173 | + | ||
| 174 | + | // Gets the default `AdwStyleManager` instance. | |
| 175 | + | // | |
| 176 | + | // It manages all [class@Gdk.Display] instances unless the style manager for | |
| 177 | + | // that display has an override. | |
| 178 | + | // | |
| 179 | + | // See [func@StyleManager.get_for_display]. | |
| 180 | + | func StyleManagerGetDefault() *StyleManager { | |
| 181 | + | var cls *StyleManager | |
| 182 | + | ||
| 183 | + | cret := xStyleManagerGetDefault() | |
| 184 | + | ||
| 185 | + | if cret == 0 { | |
| 186 | + | return nil | |
| 187 | + | } | |
| 188 | + | gobject.IncreaseRef(cret) | |
| 189 | + | cls = &StyleManager{} | |
| 190 | + | cls.Ptr = cret | |
| 191 | + | return cls | |
| 192 | + | } | |
| 193 | + | ||
| 194 | + | var xStyleManagerGetForDisplay func(uintptr) uintptr | |
| 195 | + | ||
| 196 | + | // Gets the `AdwStyleManager` instance managing @display. | |
| 197 | + | // | |
| 198 | + | // It can be used to override styles for that specific display instead of the | |
| 199 | + | // whole application. | |
| 200 | + | // | |
| 201 | + | // Most applications should use [func@StyleManager.get_default] instead. | |
| 202 | + | func StyleManagerGetForDisplay(DisplayVar *gdk.Display) *StyleManager { | |
| 203 | + | var cls *StyleManager | |
| 204 | + | ||
| 205 | + | cret := xStyleManagerGetForDisplay(DisplayVar.GoPointer()) | |
| 206 | + | ||
| 207 | + | if cret == 0 { | |
| 208 | + | return nil | |
| 209 | + | } | |
| 210 | + | gobject.IncreaseRef(cret) | |
| 211 | + | cls = &StyleManager{} | |
| 212 | + | cls.Ptr = cret | |
| 213 | + | return cls | |
| 214 | + | } | |
| 215 | + | ||
| 166 | 216 | func init() { | |
| 167 | 217 | lib, err := purego.Dlopen(core.GetPath("ADW"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 168 | 218 | if err != nil { | |
| @@ -176,4 +226,7 @@ func init() { | |||
| 176 | 226 | core.PuregoSafeRegister(&xStyleManagerGetSystemSupportsColorSchemes, lib, "adw_style_manager_get_system_supports_color_schemes") | |
| 177 | 227 | core.PuregoSafeRegister(&xStyleManagerSetColorScheme, lib, "adw_style_manager_set_color_scheme") | |
| 178 | 228 | ||
| 229 | + | core.PuregoSafeRegister(&xStyleManagerGetDefault, lib, "adw_style_manager_get_default") | |
| 230 | + | core.PuregoSafeRegister(&xStyleManagerGetForDisplay, lib, "adw_style_manager_get_for_display") | |
| 231 | + | ||
| 179 | 232 | } | |
M v4/adw/adw-swipe-tracker.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type SwipeTrackerClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SwipeTrackerClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A swipe tracker used in [class@Carousel], [class@Flap] and [class@Leaflet]. | |
| 16 | 22 | // | |
| 17 | 23 | // The `AdwSwipeTracker` object can be used for implementing widgets with swipe | |
M v4/adw/adw-swipeable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -14,6 +16,10 @@ type SwipeableInterface struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *SwipeableInterface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // An interface for swipeable widgets. | |
| 18 | 24 | // | |
| 19 | 25 | // The `AdwSwipeable` interface is implemented by all swipeable widgets. | |
M v4/adw/adw-tab-bar.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -13,6 +15,10 @@ type TabBarClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *TabBarClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A tab bar for [class@TabView]. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-tab-button.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type TabButtonClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *TabButtonClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // A button that displays the number of [class@TabView] pages. | |
| 17 | 23 | // | |
| 18 | 24 | // <picture> | |
M v4/adw/adw-tab-overview.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -14,6 +16,10 @@ type TabOverviewClass struct { | |||
| 14 | 16 | ParentClass uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *TabOverviewClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // A tab overview for [class@TabView]. | |
| 18 | 24 | // | |
| 19 | 25 | // <picture> | |
M v4/adw/adw-tab-view.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -13,10 +15,18 @@ type TabPageClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *TabPageClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | type TabViewClass struct { | |
| 17 | 23 | ParentClass uintptr | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *TabViewClass) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | // Describes available shortcuts in an [class@TabView]. | |
| 21 | 31 | // | |
| 22 | 32 | // Shortcuts can be set with [property@TabView:shortcuts], or added/removed | |
M v4/adw/adw-timed-animation.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type TimedAnimationClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *TimedAnimationClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // A time-based [class@Animation]. | |
| 15 | 21 | // | |
| 16 | 22 | // `AdwTimedAnimation` implements a simple animation interpolating the given | |
M v4/adw/adw-toast-overlay.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ToastOverlayClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ToastOverlayClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A widget showing toasts above its content. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-toast.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type ToastClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *ToastClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // [class@Toast] behavior when another toast is already displayed. | |
| 17 | 23 | type ToastPriority int | |
| 18 | 24 | ||
M v4/adw/adw-version.go +12 -0
| @@ -6,6 +6,18 @@ import ( | |||
| 6 | 6 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 7 | ) | |
| 8 | 8 | ||
| 9 | + | const ( | |
| 10 | + | // Adwaita major version component (e.g. 1 if the version is 1.2.3). | |
| 11 | + | MAJOR_VERSION int = 1 | |
| 12 | + | // Adwaita micro version component (e.g. 3 if the version is 1.2.3). | |
| 13 | + | MICRO_VERSION int = 3 | |
| 14 | + | // Adwaita minor version component (e.g. 2 if the version is 1.2.3). | |
| 15 | + | MINOR_VERSION int = 3 | |
| 16 | + | // Adwaita version, encoded as a string, useful for printing and | |
| 17 | + | // concatenation. | |
| 18 | + | VERSION_S string = "1.3.3" | |
| 19 | + | ) | |
| 20 | + | ||
| 9 | 21 | var xGetMajorVersion func() uint | |
| 10 | 22 | ||
| 11 | 23 | // Returns the major version number of the Adwaita library. | |
M v4/adw/adw-view-stack.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,10 +14,18 @@ type ViewStackClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ViewStackClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type ViewStackPageClass struct { | |
| 16 | 22 | ParentClass uintptr | |
| 17 | 23 | } | |
| 18 | 24 | ||
| 25 | + | func (x *ViewStackPageClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 19 | 29 | // A view container for [class@ViewSwitcher]. | |
| 20 | 30 | // | |
| 21 | 31 | // `AdwViewStack` is a container which only shows one page at a time. | |
M v4/adw/adw-view-switcher-bar.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ViewSwitcherBarClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ViewSwitcherBarClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A view switcher action bar. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-view-switcher-title.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ViewSwitcherTitleClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ViewSwitcherTitleClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A view switcher title. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-view-switcher.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ViewSwitcherClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ViewSwitcherClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Describes the adaptive modes of [class@ViewSwitcher]. | |
| 16 | 22 | type ViewSwitcherPolicy int | |
| 17 | 23 | ||
M v4/adw/adw-window-title.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type WindowTitleClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *WindowTitleClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A helper widget for setting a window's title and subtitle. | |
| 16 | 22 | // | |
| 17 | 23 | // <picture> | |
M v4/adw/adw-window.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package adw | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -16,6 +18,10 @@ type WindowClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *WindowClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A freeform window. | |
| 20 | 26 | // | |
| 21 | 27 | // <picture> | |
M v4/cairo/main.go +50 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package cairo | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -9,33 +11,73 @@ import ( | |||
| 9 | 11 | type Context struct { | |
| 10 | 12 | } | |
| 11 | 13 | ||
| 14 | + | func (x *Context) GoPointer() uintptr { | |
| 15 | + | return uintptr(unsafe.Pointer(x)) | |
| 16 | + | } | |
| 17 | + | ||
| 12 | 18 | type Device struct { | |
| 13 | 19 | } | |
| 14 | 20 | ||
| 21 | + | func (x *Device) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 15 | 25 | type Surface struct { | |
| 16 | 26 | } | |
| 17 | 27 | ||
| 28 | + | func (x *Surface) GoPointer() uintptr { | |
| 29 | + | return uintptr(unsafe.Pointer(x)) | |
| 30 | + | } | |
| 31 | + | ||
| 18 | 32 | type Matrix struct { | |
| 19 | 33 | } | |
| 20 | 34 | ||
| 35 | + | func (x *Matrix) GoPointer() uintptr { | |
| 36 | + | return uintptr(unsafe.Pointer(x)) | |
| 37 | + | } | |
| 38 | + | ||
| 21 | 39 | type Pattern struct { | |
| 22 | 40 | } | |
| 23 | 41 | ||
| 42 | + | func (x *Pattern) GoPointer() uintptr { | |
| 43 | + | return uintptr(unsafe.Pointer(x)) | |
| 44 | + | } | |
| 45 | + | ||
| 24 | 46 | type Region struct { | |
| 25 | 47 | } | |
| 26 | 48 | ||
| 49 | + | func (x *Region) GoPointer() uintptr { | |
| 50 | + | return uintptr(unsafe.Pointer(x)) | |
| 51 | + | } | |
| 52 | + | ||
| 27 | 53 | type FontOptions struct { | |
| 28 | 54 | } | |
| 29 | 55 | ||
| 56 | + | func (x *FontOptions) GoPointer() uintptr { | |
| 57 | + | return uintptr(unsafe.Pointer(x)) | |
| 58 | + | } | |
| 59 | + | ||
| 30 | 60 | type FontFace struct { | |
| 31 | 61 | } | |
| 32 | 62 | ||
| 63 | + | func (x *FontFace) GoPointer() uintptr { | |
| 64 | + | return uintptr(unsafe.Pointer(x)) | |
| 65 | + | } | |
| 66 | + | ||
| 33 | 67 | type ScaledFont struct { | |
| 34 | 68 | } | |
| 35 | 69 | ||
| 70 | + | func (x *ScaledFont) GoPointer() uintptr { | |
| 71 | + | return uintptr(unsafe.Pointer(x)) | |
| 72 | + | } | |
| 73 | + | ||
| 36 | 74 | type Path struct { | |
| 37 | 75 | } | |
| 38 | 76 | ||
| 77 | + | func (x *Path) GoPointer() uintptr { | |
| 78 | + | return uintptr(unsafe.Pointer(x)) | |
| 79 | + | } | |
| 80 | + | ||
| 39 | 81 | type Rectangle struct { | |
| 40 | 82 | X float64 | |
| 41 | 83 | ||
| @@ -46,6 +88,10 @@ type Rectangle struct { | |||
| 46 | 88 | Height float64 | |
| 47 | 89 | } | |
| 48 | 90 | ||
| 91 | + | func (x *Rectangle) GoPointer() uintptr { | |
| 92 | + | return uintptr(unsafe.Pointer(x)) | |
| 93 | + | } | |
| 94 | + | ||
| 49 | 95 | type RectangleInt struct { | |
| 50 | 96 | X int32 | |
| 51 | 97 | ||
| @@ -56,6 +102,10 @@ type RectangleInt struct { | |||
| 56 | 102 | Height int32 | |
| 57 | 103 | } | |
| 58 | 104 | ||
| 105 | + | func (x *RectangleInt) GoPointer() uintptr { | |
| 106 | + | return uintptr(unsafe.Pointer(x)) | |
| 107 | + | } | |
| 108 | + | ||
| 59 | 109 | type Status int | |
| 60 | 110 | ||
| 61 | 111 | const ( | |
M v4/gdk/gdkcontentformats.go +146 -0
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | ) | |
| 8 | 11 | ||
| 9 | 12 | // A `GdkContentFormatsBuilder` is an auxiliary struct used to create | |
| @@ -11,10 +14,138 @@ import ( | |||
| 11 | 14 | type ContentFormatsBuilder struct { | |
| 12 | 15 | } | |
| 13 | 16 | ||
| 17 | + | func (x *ContentFormatsBuilder) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | var xNewContentFormatsBuilder func() *ContentFormatsBuilder | |
| 22 | + | ||
| 23 | + | // Create a new `GdkContentFormatsBuilder` object. | |
| 24 | + | // | |
| 25 | + | // The resulting builder would create an empty `GdkContentFormats`. | |
| 26 | + | // Use addition functions to add types to it. | |
| 27 | + | func NewContentFormatsBuilder() *ContentFormatsBuilder { | |
| 28 | + | ||
| 29 | + | cret := xNewContentFormatsBuilder() | |
| 30 | + | return cret | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | var xContentFormatsBuilderAddFormats func(uintptr, *ContentFormats) | |
| 34 | + | ||
| 35 | + | // Appends all formats from @formats to @builder, skipping those that | |
| 36 | + | // already exist. | |
| 37 | + | func (x *ContentFormatsBuilder) AddFormats(FormatsVar *ContentFormats) { | |
| 38 | + | ||
| 39 | + | xContentFormatsBuilderAddFormats(x.GoPointer(), FormatsVar) | |
| 40 | + | ||
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xContentFormatsBuilderAddGtype func(uintptr, []interface{}) | |
| 44 | + | ||
| 45 | + | // Appends @type to @builder if it has not already been added. | |
| 46 | + | func (x *ContentFormatsBuilder) AddGtype(TypeVar []interface{}) { | |
| 47 | + | ||
| 48 | + | xContentFormatsBuilderAddGtype(x.GoPointer(), TypeVar) | |
| 49 | + | ||
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xContentFormatsBuilderAddMimeType func(uintptr, string) | |
| 53 | + | ||
| 54 | + | // Appends @mime_type to @builder if it has not already been added. | |
| 55 | + | func (x *ContentFormatsBuilder) AddMimeType(MimeTypeVar string) { | |
| 56 | + | ||
| 57 | + | xContentFormatsBuilderAddMimeType(x.GoPointer(), MimeTypeVar) | |
| 58 | + | ||
| 59 | + | } | |
| 60 | + | ||
| 61 | + | var xContentFormatsBuilderFreeToFormats func(uintptr) *ContentFormats | |
| 62 | + | ||
| 63 | + | // Creates a new `GdkContentFormats` from the current state of the | |
| 64 | + | // given @builder, and frees the @builder instance. | |
| 65 | + | func (x *ContentFormatsBuilder) FreeToFormats() *ContentFormats { | |
| 66 | + | ||
| 67 | + | cret := xContentFormatsBuilderFreeToFormats(x.GoPointer()) | |
| 68 | + | return cret | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | var xContentFormatsBuilderRef func(uintptr) *ContentFormatsBuilder | |
| 72 | + | ||
| 73 | + | // Acquires a reference on the given @builder. | |
| 74 | + | // | |
| 75 | + | // This function is intended primarily for bindings. | |
| 76 | + | // `GdkContentFormatsBuilder` objects should not be kept around. | |
| 77 | + | func (x *ContentFormatsBuilder) Ref() *ContentFormatsBuilder { | |
| 78 | + | ||
| 79 | + | cret := xContentFormatsBuilderRef(x.GoPointer()) | |
| 80 | + | return cret | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xContentFormatsBuilderToFormats func(uintptr) *ContentFormats | |
| 84 | + | ||
| 85 | + | // Creates a new `GdkContentFormats` from the given @builder. | |
| 86 | + | // | |
| 87 | + | // The given `GdkContentFormatsBuilder` is reset once this function returns; | |
| 88 | + | // you cannot call this function multiple times on the same @builder instance. | |
| 89 | + | // | |
| 90 | + | // This function is intended primarily for bindings. C code should use | |
| 91 | + | // [method@Gdk.ContentFormatsBuilder.free_to_formats]. | |
| 92 | + | func (x *ContentFormatsBuilder) ToFormats() *ContentFormats { | |
| 93 | + | ||
| 94 | + | cret := xContentFormatsBuilderToFormats(x.GoPointer()) | |
| 95 | + | return cret | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | var xContentFormatsBuilderUnref func(uintptr) | |
| 99 | + | ||
| 100 | + | // Releases a reference on the given @builder. | |
| 101 | + | func (x *ContentFormatsBuilder) Unref() { | |
| 102 | + | ||
| 103 | + | xContentFormatsBuilderUnref(x.GoPointer()) | |
| 104 | + | ||
| 105 | + | } | |
| 106 | + | ||
| 14 | 107 | // An opaque type representing a list of files. | |
| 15 | 108 | type FileList struct { | |
| 16 | 109 | } | |
| 17 | 110 | ||
| 111 | + | func (x *FileList) GoPointer() uintptr { | |
| 112 | + | return uintptr(unsafe.Pointer(x)) | |
| 113 | + | } | |
| 114 | + | ||
| 115 | + | var xNewFromArrayFileList func(uintptr, uint) *FileList | |
| 116 | + | ||
| 117 | + | // Creates a new `GdkFileList` for the given array of files. | |
| 118 | + | // | |
| 119 | + | // This function is meant to be used by language bindings. | |
| 120 | + | func NewFromArrayFileList(FilesVar uintptr, NFilesVar uint) *FileList { | |
| 121 | + | ||
| 122 | + | cret := xNewFromArrayFileList(FilesVar, NFilesVar) | |
| 123 | + | return cret | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | var xNewFromListFileList func(*glib.SList) *FileList | |
| 127 | + | ||
| 128 | + | // Creates a new files list container from a singly linked list of | |
| 129 | + | // `GFile` instances. | |
| 130 | + | // | |
| 131 | + | // This function is meant to be used by language bindings | |
| 132 | + | func NewFromListFileList(FilesVar *glib.SList) *FileList { | |
| 133 | + | ||
| 134 | + | cret := xNewFromListFileList(FilesVar) | |
| 135 | + | return cret | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xFileListGetFiles func(uintptr) *glib.SList | |
| 139 | + | ||
| 140 | + | // Retrieves the list of files inside a `GdkFileList`. | |
| 141 | + | // | |
| 142 | + | // This function is meant for language bindings. | |
| 143 | + | func (x *FileList) GetFiles() *glib.SList { | |
| 144 | + | ||
| 145 | + | cret := xFileListGetFiles(x.GoPointer()) | |
| 146 | + | return cret | |
| 147 | + | } | |
| 148 | + | ||
| 18 | 149 | var xContentFormatsParse func(string) *ContentFormats | |
| 19 | 150 | ||
| 20 | 151 | // Parses the given @string into `GdkContentFormats` and | |
| @@ -51,4 +182,19 @@ func init() { | |||
| 51 | 182 | core.PuregoSafeRegister(&xContentFormatsParse, lib, "gdk_content_formats_parse") | |
| 52 | 183 | core.PuregoSafeRegister(&xInternMimeType, lib, "gdk_intern_mime_type") | |
| 53 | 184 | ||
| 185 | + | core.PuregoSafeRegister(&xNewContentFormatsBuilder, lib, "gdk_content_formats_builder_new") | |
| 186 | + | ||
| 187 | + | core.PuregoSafeRegister(&xContentFormatsBuilderAddFormats, lib, "gdk_content_formats_builder_add_formats") | |
| 188 | + | core.PuregoSafeRegister(&xContentFormatsBuilderAddGtype, lib, "gdk_content_formats_builder_add_gtype") | |
| 189 | + | core.PuregoSafeRegister(&xContentFormatsBuilderAddMimeType, lib, "gdk_content_formats_builder_add_mime_type") | |
| 190 | + | core.PuregoSafeRegister(&xContentFormatsBuilderFreeToFormats, lib, "gdk_content_formats_builder_free_to_formats") | |
| 191 | + | core.PuregoSafeRegister(&xContentFormatsBuilderRef, lib, "gdk_content_formats_builder_ref") | |
| 192 | + | core.PuregoSafeRegister(&xContentFormatsBuilderToFormats, lib, "gdk_content_formats_builder_to_formats") | |
| 193 | + | core.PuregoSafeRegister(&xContentFormatsBuilderUnref, lib, "gdk_content_formats_builder_unref") | |
| 194 | + | ||
| 195 | + | core.PuregoSafeRegister(&xNewFromArrayFileList, lib, "gdk_file_list_new_from_array") | |
| 196 | + | core.PuregoSafeRegister(&xNewFromListFileList, lib, "gdk_file_list_new_from_list") | |
| 197 | + | ||
| 198 | + | core.PuregoSafeRegister(&xFileListGetFiles, lib, "gdk_file_list_get_files") | |
| 199 | + | ||
| 54 | 200 | } | |
M v4/gdk/gdkcontentprovider.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -16,6 +18,10 @@ type ContentProviderClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *ContentProviderClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A `GdkContentProvider` is used to provide content for the clipboard or | |
| 20 | 26 | // for drag-and-drop operations in a number of formats. | |
| 21 | 27 | // | |
M v4/gdk/gdkdevice.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -22,6 +24,10 @@ type TimeCoord struct { | |||
| 22 | 24 | Axes uintptr | |
| 23 | 25 | } | |
| 24 | 26 | ||
| 27 | + | func (x *TimeCoord) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 25 | 31 | // An enumeration describing the type of an input device in general terms. | |
| 26 | 32 | type InputSource int | |
| 27 | 33 | ||
M v4/gdk/gdkdevicepad.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -9,6 +11,10 @@ import ( | |||
| 9 | 11 | type DevicePadInterface struct { | |
| 10 | 12 | } | |
| 11 | 13 | ||
| 14 | + | func (x *DevicePadInterface) GoPointer() uintptr { | |
| 15 | + | return uintptr(unsafe.Pointer(x)) | |
| 16 | + | } | |
| 17 | + | ||
| 12 | 18 | // `GdkDevicePad` is an interface implemented by devices of type | |
| 13 | 19 | // %GDK_SOURCE_TABLET_PAD | |
| 14 | 20 | // | |
M v4/gdk/gdkdisplay.go +43 -0
| @@ -533,6 +533,46 @@ func (x *Display) ConnectSettingChanged(cb func(Display, string)) uint32 { | |||
| 533 | 533 | return gobject.SignalConnect(x.GoPointer(), "setting-changed", purego.NewCallback(fcb)) | |
| 534 | 534 | } | |
| 535 | 535 | ||
| 536 | + | var xDisplayGetDefault func() uintptr | |
| 537 | + | ||
| 538 | + | // Gets the default `GdkDisplay`. | |
| 539 | + | // | |
| 540 | + | // This is a convenience function for: | |
| 541 | + | // | |
| 542 | + | // gdk_display_manager_get_default_display (gdk_display_manager_get ()) | |
| 543 | + | func DisplayGetDefault() *Display { | |
| 544 | + | var cls *Display | |
| 545 | + | ||
| 546 | + | cret := xDisplayGetDefault() | |
| 547 | + | ||
| 548 | + | if cret == 0 { | |
| 549 | + | return nil | |
| 550 | + | } | |
| 551 | + | gobject.IncreaseRef(cret) | |
| 552 | + | cls = &Display{} | |
| 553 | + | cls.Ptr = cret | |
| 554 | + | return cls | |
| 555 | + | } | |
| 556 | + | ||
| 557 | + | var xDisplayOpen func(string) uintptr | |
| 558 | + | ||
| 559 | + | // Opens a display. | |
| 560 | + | // | |
| 561 | + | // If opening the display fails, `NULL` is returned. | |
| 562 | + | func DisplayOpen(DisplayNameVar string) *Display { | |
| 563 | + | var cls *Display | |
| 564 | + | ||
| 565 | + | cret := xDisplayOpen(DisplayNameVar) | |
| 566 | + | ||
| 567 | + | if cret == 0 { | |
| 568 | + | return nil | |
| 569 | + | } | |
| 570 | + | gobject.IncreaseRef(cret) | |
| 571 | + | cls = &Display{} | |
| 572 | + | cls.Ptr = cret | |
| 573 | + | return cls | |
| 574 | + | } | |
| 575 | + | ||
| 536 | 576 | func init() { | |
| 537 | 577 | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 538 | 578 | if err != nil { | |
| @@ -566,4 +606,7 @@ func init() { | |||
| 566 | 606 | core.PuregoSafeRegister(&xDisplaySync, lib, "gdk_display_sync") | |
| 567 | 607 | core.PuregoSafeRegister(&xDisplayTranslateKey, lib, "gdk_display_translate_key") | |
| 568 | 608 | ||
| 609 | + | core.PuregoSafeRegister(&xDisplayGetDefault, lib, "gdk_display_get_default") | |
| 610 | + | core.PuregoSafeRegister(&xDisplayOpen, lib, "gdk_display_open") | |
| 611 | + | ||
| 569 | 612 | } | |
M v4/gdk/gdkdisplaymanager.go +27 -0
| @@ -179,6 +179,31 @@ func (x *DisplayManager) ConnectDisplayOpened(cb func(DisplayManager, uintptr)) | |||
| 179 | 179 | return gobject.SignalConnect(x.GoPointer(), "display-opened", purego.NewCallback(fcb)) | |
| 180 | 180 | } | |
| 181 | 181 | ||
| 182 | + | var xDisplayManagerGet func() uintptr | |
| 183 | + | ||
| 184 | + | // Gets the singleton `GdkDisplayManager` object. | |
| 185 | + | // | |
| 186 | + | // When called for the first time, this function consults the | |
| 187 | + | // `GDK_BACKEND` environment variable to find out which of the | |
| 188 | + | // supported GDK backends to use (in case GDK has been compiled | |
| 189 | + | // with multiple backends). | |
| 190 | + | // | |
| 191 | + | // Applications can use [func@set_allowed_backends] to limit what | |
| 192 | + | // backends wil be used. | |
| 193 | + | func DisplayManagerGet() *DisplayManager { | |
| 194 | + | var cls *DisplayManager | |
| 195 | + | ||
| 196 | + | cret := xDisplayManagerGet() | |
| 197 | + | ||
| 198 | + | if cret == 0 { | |
| 199 | + | return nil | |
| 200 | + | } | |
| 201 | + | gobject.IncreaseRef(cret) | |
| 202 | + | cls = &DisplayManager{} | |
| 203 | + | cls.Ptr = cret | |
| 204 | + | return cls | |
| 205 | + | } | |
| 206 | + | ||
| 182 | 207 | func init() { | |
| 183 | 208 | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 184 | 209 | if err != nil { | |
| @@ -191,4 +216,6 @@ func init() { | |||
| 191 | 216 | core.PuregoSafeRegister(&xDisplayManagerOpenDisplay, lib, "gdk_display_manager_open_display") | |
| 192 | 217 | core.PuregoSafeRegister(&xDisplayManagerSetDefaultDisplay, lib, "gdk_display_manager_set_default_display") | |
| 193 | 218 | ||
| 219 | + | core.PuregoSafeRegister(&xDisplayManagerGet, lib, "gdk_display_manager_get") | |
| 220 | + | ||
| 194 | 221 | } | |
M v4/gdk/gdkdrag.go +31 -0
| @@ -248,6 +248,35 @@ func (x *Drag) ConnectDropPerformed(cb func(Drag)) uint32 { | |||
| 248 | 248 | return gobject.SignalConnect(x.GoPointer(), "drop-performed", purego.NewCallback(fcb)) | |
| 249 | 249 | } | |
| 250 | 250 | ||
| 251 | + | var xDragBegin func(uintptr, uintptr, uintptr, DragAction, float64, float64) uintptr | |
| 252 | + | ||
| 253 | + | // Starts a drag and creates a new drag context for it. | |
| 254 | + | // | |
| 255 | + | // This function is called by the drag source. After this call, you | |
| 256 | + | // probably want to set up the drag icon using the surface returned | |
| 257 | + | // by [method@Gdk.Drag.get_drag_surface]. | |
| 258 | + | // | |
| 259 | + | // This function returns a reference to the [class@Gdk.Drag] object, | |
| 260 | + | // but GTK keeps its own reference as well, as long as the DND operation | |
| 261 | + | // is going on. | |
| 262 | + | // | |
| 263 | + | // Note: if @actions include %GDK_ACTION_MOVE, you need to listen for | |
| 264 | + | // the [signal@Gdk.Drag::dnd-finished] signal and delete the data at | |
| 265 | + | // the source if [method@Gdk.Drag.get_selected_action] returns | |
| 266 | + | // %GDK_ACTION_MOVE. | |
| 267 | + | func DragBegin(SurfaceVar *Surface, DeviceVar *Device, ContentVar *ContentProvider, ActionsVar DragAction, DxVar float64, DyVar float64) *Drag { | |
| 268 | + | var cls *Drag | |
| 269 | + | ||
| 270 | + | cret := xDragBegin(SurfaceVar.GoPointer(), DeviceVar.GoPointer(), ContentVar.GoPointer(), ActionsVar, DxVar, DyVar) | |
| 271 | + | ||
| 272 | + | if cret == 0 { | |
| 273 | + | return nil | |
| 274 | + | } | |
| 275 | + | cls = &Drag{} | |
| 276 | + | cls.Ptr = cret | |
| 277 | + | return cls | |
| 278 | + | } | |
| 279 | + | ||
| 251 | 280 | func init() { | |
| 252 | 281 | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 253 | 282 | if err != nil { | |
| @@ -266,4 +295,6 @@ func init() { | |||
| 266 | 295 | core.PuregoSafeRegister(&xDragGetSurface, lib, "gdk_drag_get_surface") | |
| 267 | 296 | core.PuregoSafeRegister(&xDragSetHotspot, lib, "gdk_drag_set_hotspot") | |
| 268 | 297 | ||
| 298 | + | core.PuregoSafeRegister(&xDragBegin, lib, "gdk_drag_begin") | |
| 299 | + | ||
| 269 | 300 | } | |
M v4/gdk/gdkdragsurface.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -10,6 +12,10 @@ import ( | |||
| 10 | 12 | type DragSurfaceInterface struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *DragSurfaceInterface) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | // A `GdkDragSurface` is an interface for surfaces used during DND. | |
| 14 | 20 | type DragSurface interface { | |
| 15 | 21 | GoPointer() uintptr | |
M v4/gdk/gdkenums.go +10 -0
| @@ -1,6 +1,16 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | const ( | |
| 5 | + | // Defines all possible DND actions. | |
| 6 | + | // | |
| 7 | + | // This can be used in [method@Gdk.Drop.status] messages when any drop | |
| 8 | + | // can be accepted or a more specific drop method is not yet known. | |
| 9 | + | ACTION_ALL int = 7 | |
| 10 | + | // A mask covering all entries in `GdkModifierType`. | |
| 11 | + | MODIFIER_MASK int = 469769999 | |
| 12 | + | ) | |
| 13 | + | ||
| 4 | 14 | // Flags describing the current capabilities of a device/tool. | |
| 5 | 15 | type AxisFlags int | |
| 6 | 16 | ||
M v4/gdk/gdkevents.go +26 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,30 @@ import ( | |||
| 12 | 14 | type EventSequence struct { | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *EventSequence) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | const ( | |
| 22 | + | // The middle button. | |
| 23 | + | BUTTON_MIDDLE int = 2 | |
| 24 | + | // The primary button. This is typically the left mouse button, or the | |
| 25 | + | // right button in a left-handed setup. | |
| 26 | + | BUTTON_PRIMARY int = 1 | |
| 27 | + | // The secondary button. This is typically the right mouse button, or the | |
| 28 | + | // left button in a left-handed setup. | |
| 29 | + | BUTTON_SECONDARY int = 3 | |
| 30 | + | // Use this macro as the return value for continuing the propagation of | |
| 31 | + | // an event handler. | |
| 32 | + | EVENT_PROPAGATE bool = false | |
| 33 | + | // Use this macro as the return value for stopping the propagation of | |
| 34 | + | // an event handler. | |
| 35 | + | EVENT_STOP bool = true | |
| 36 | + | // This is the priority that the idle handler processing surface updates | |
| 37 | + | // is given in the main loop. | |
| 38 | + | PRIORITY_REDRAW int = 120 | |
| 39 | + | ) | |
| 40 | + | ||
| 15 | 41 | // Specifies the crossing mode for enter and leave events. | |
| 16 | 42 | type CrossingMode int | |
| 17 | 43 | ||
M v4/gdk/gdkframeclock.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -10,9 +12,17 @@ import ( | |||
| 10 | 12 | type FrameClockClass struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *FrameClockClass) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | type FrameClockPrivate struct { | |
| 14 | 20 | } | |
| 15 | 21 | ||
| 22 | + | func (x *FrameClockPrivate) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 16 | 26 | // Used to represent the different paint clock phases that can be requested. | |
| 17 | 27 | // | |
| 18 | 28 | // The elements of the enumeration correspond to the signals of `GdkFrameClock`. | |
M v4/gdk/gdkframetimings.go +135 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // A `GdkFrameTimings` object holds timing information for a single frame | |
| 5 | 12 | // of the application’s displays. | |
| 6 | 13 | // | |
| @@ -11,3 +18,131 @@ package gdk | |||
| 11 | 18 | // application’s display, such as latency and jitter. | |
| 12 | 19 | type FrameTimings struct { | |
| 13 | 20 | } | |
| 21 | + | ||
| 22 | + | func (x *FrameTimings) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | var xFrameTimingsGetComplete func(uintptr) bool | |
| 27 | + | ||
| 28 | + | // Returns whether @timings are complete. | |
| 29 | + | // | |
| 30 | + | // The timing information in a `GdkFrameTimings` is filled in | |
| 31 | + | // incrementally as the frame as drawn and passed off to the | |
| 32 | + | // window system for processing and display to the user. The | |
| 33 | + | // accessor functions for `GdkFrameTimings` can return 0 to | |
| 34 | + | // indicate an unavailable value for two reasons: either because | |
| 35 | + | // the information is not yet available, or because it isn't | |
| 36 | + | // available at all. | |
| 37 | + | // | |
| 38 | + | // Once this function returns %TRUE for a frame, you can be | |
| 39 | + | // certain that no further values will become available and be | |
| 40 | + | // stored in the `GdkFrameTimings`. | |
| 41 | + | func (x *FrameTimings) GetComplete() bool { | |
| 42 | + | ||
| 43 | + | cret := xFrameTimingsGetComplete(x.GoPointer()) | |
| 44 | + | return cret | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | var xFrameTimingsGetFrameCounter func(uintptr) int64 | |
| 48 | + | ||
| 49 | + | // Gets the frame counter value of the `GdkFrameClock` when | |
| 50 | + | // this frame was drawn. | |
| 51 | + | func (x *FrameTimings) GetFrameCounter() int64 { | |
| 52 | + | ||
| 53 | + | cret := xFrameTimingsGetFrameCounter(x.GoPointer()) | |
| 54 | + | return cret | |
| 55 | + | } | |
| 56 | + | ||
| 57 | + | var xFrameTimingsGetFrameTime func(uintptr) int64 | |
| 58 | + | ||
| 59 | + | // Returns the frame time for the frame. | |
| 60 | + | // | |
| 61 | + | // This is the time value that is typically used to time | |
| 62 | + | // animations for the frame. See [method@Gdk.FrameClock.get_frame_time]. | |
| 63 | + | func (x *FrameTimings) GetFrameTime() int64 { | |
| 64 | + | ||
| 65 | + | cret := xFrameTimingsGetFrameTime(x.GoPointer()) | |
| 66 | + | return cret | |
| 67 | + | } | |
| 68 | + | ||
| 69 | + | var xFrameTimingsGetPredictedPresentationTime func(uintptr) int64 | |
| 70 | + | ||
| 71 | + | // Gets the predicted time at which this frame will be displayed. | |
| 72 | + | // | |
| 73 | + | // Although no predicted time may be available, if one is available, | |
| 74 | + | // it will be available while the frame is being generated, in contrast | |
| 75 | + | // to [method@Gdk.FrameTimings.get_presentation_time], which is only | |
| 76 | + | // available after the frame has been presented. | |
| 77 | + | // | |
| 78 | + | // In general, if you are simply animating, you should use | |
| 79 | + | // [method@Gdk.FrameClock.get_frame_time] rather than this function, | |
| 80 | + | // but this function is useful for applications that want exact control | |
| 81 | + | // over latency. For example, a movie player may want this information | |
| 82 | + | // for Audio/Video synchronization. | |
| 83 | + | func (x *FrameTimings) GetPredictedPresentationTime() int64 { | |
| 84 | + | ||
| 85 | + | cret := xFrameTimingsGetPredictedPresentationTime(x.GoPointer()) | |
| 86 | + | return cret | |
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xFrameTimingsGetPresentationTime func(uintptr) int64 | |
| 90 | + | ||
| 91 | + | // Reurns the presentation time. | |
| 92 | + | // | |
| 93 | + | // This is the time at which the frame became visible to the user. | |
| 94 | + | func (x *FrameTimings) GetPresentationTime() int64 { | |
| 95 | + | ||
| 96 | + | cret := xFrameTimingsGetPresentationTime(x.GoPointer()) | |
| 97 | + | return cret | |
| 98 | + | } | |
| 99 | + | ||
| 100 | + | var xFrameTimingsGetRefreshInterval func(uintptr) int64 | |
| 101 | + | ||
| 102 | + | // Gets the natural interval between presentation times for | |
| 103 | + | // the display that this frame was displayed on. | |
| 104 | + | // | |
| 105 | + | // Frame presentation usually happens during the “vertical | |
| 106 | + | // blanking interval”. | |
| 107 | + | func (x *FrameTimings) GetRefreshInterval() int64 { | |
| 108 | + | ||
| 109 | + | cret := xFrameTimingsGetRefreshInterval(x.GoPointer()) | |
| 110 | + | return cret | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | var xFrameTimingsRef func(uintptr) *FrameTimings | |
| 114 | + | ||
| 115 | + | // Increases the reference count of @timings. | |
| 116 | + | func (x *FrameTimings) Ref() *FrameTimings { | |
| 117 | + | ||
| 118 | + | cret := xFrameTimingsRef(x.GoPointer()) | |
| 119 | + | return cret | |
| 120 | + | } | |
| 121 | + | ||
| 122 | + | var xFrameTimingsUnref func(uintptr) | |
| 123 | + | ||
| 124 | + | // Decreases the reference count of @timings. | |
| 125 | + | // | |
| 126 | + | // If @timings is no longer referenced, it will be freed. | |
| 127 | + | func (x *FrameTimings) Unref() { | |
| 128 | + | ||
| 129 | + | xFrameTimingsUnref(x.GoPointer()) | |
| 130 | + | ||
| 131 | + | } | |
| 132 | + | ||
| 133 | + | func init() { | |
| 134 | + | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 135 | + | if err != nil { | |
| 136 | + | panic(err) | |
| 137 | + | } | |
| 138 | + | ||
| 139 | + | core.PuregoSafeRegister(&xFrameTimingsGetComplete, lib, "gdk_frame_timings_get_complete") | |
| 140 | + | core.PuregoSafeRegister(&xFrameTimingsGetFrameCounter, lib, "gdk_frame_timings_get_frame_counter") | |
| 141 | + | core.PuregoSafeRegister(&xFrameTimingsGetFrameTime, lib, "gdk_frame_timings_get_frame_time") | |
| 142 | + | core.PuregoSafeRegister(&xFrameTimingsGetPredictedPresentationTime, lib, "gdk_frame_timings_get_predicted_presentation_time") | |
| 143 | + | core.PuregoSafeRegister(&xFrameTimingsGetPresentationTime, lib, "gdk_frame_timings_get_presentation_time") | |
| 144 | + | core.PuregoSafeRegister(&xFrameTimingsGetRefreshInterval, lib, "gdk_frame_timings_get_refresh_interval") | |
| 145 | + | core.PuregoSafeRegister(&xFrameTimingsRef, lib, "gdk_frame_timings_ref") | |
| 146 | + | core.PuregoSafeRegister(&xFrameTimingsUnref, lib, "gdk_frame_timings_unref") | |
| 147 | + | ||
| 148 | + | } | |
M v4/gdk/gdkglcontext.go +32 -0
| @@ -373,6 +373,35 @@ func (c *GLContext) SetGoPointer(ptr uintptr) { | |||
| 373 | 373 | c.Ptr = ptr | |
| 374 | 374 | } | |
| 375 | 375 | ||
| 376 | + | var xGLContextClearCurrent func() | |
| 377 | + | ||
| 378 | + | // Clears the current `GdkGLContext`. | |
| 379 | + | // | |
| 380 | + | // Any OpenGL call after this function returns will be ignored | |
| 381 | + | // until [method@Gdk.GLContext.make_current] is called. | |
| 382 | + | func GLContextClearCurrent() { | |
| 383 | + | ||
| 384 | + | xGLContextClearCurrent() | |
| 385 | + | ||
| 386 | + | } | |
| 387 | + | ||
| 388 | + | var xGLContextGetCurrent func() uintptr | |
| 389 | + | ||
| 390 | + | // Retrieves the current `GdkGLContext`. | |
| 391 | + | func GLContextGetCurrent() *GLContext { | |
| 392 | + | var cls *GLContext | |
| 393 | + | ||
| 394 | + | cret := xGLContextGetCurrent() | |
| 395 | + | ||
| 396 | + | if cret == 0 { | |
| 397 | + | return nil | |
| 398 | + | } | |
| 399 | + | gobject.IncreaseRef(cret) | |
| 400 | + | cls = &GLContext{} | |
| 401 | + | cls.Ptr = cret | |
| 402 | + | return cls | |
| 403 | + | } | |
| 404 | + | ||
| 376 | 405 | func init() { | |
| 377 | 406 | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 378 | 407 | if err != nil { | |
| @@ -399,4 +428,7 @@ func init() { | |||
| 399 | 428 | core.PuregoSafeRegister(&xGLContextSetRequiredVersion, lib, "gdk_gl_context_set_required_version") | |
| 400 | 429 | core.PuregoSafeRegister(&xGLContextSetUseEs, lib, "gdk_gl_context_set_use_es") | |
| 401 | 430 | ||
| 431 | + | core.PuregoSafeRegister(&xGLContextClearCurrent, lib, "gdk_gl_context_clear_current") | |
| 432 | + | core.PuregoSafeRegister(&xGLContextGetCurrent, lib, "gdk_gl_context_get_current") | |
| 433 | + | ||
| 402 | 434 | } | |
M v4/gdk/gdkgltexture.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type GLTextureClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *GLTextureClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // A GdkTexture representing a GL texture object. | |
| 15 | 21 | type GLTexture struct { | |
| 16 | 22 | Texture | |
M v4/gdk/gdkmemorytexture.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type MemoryTextureClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *MemoryTextureClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // A `GdkTexture` representing image data in memory. | |
| 15 | 21 | type MemoryTexture struct { | |
| 16 | 22 | Texture | |
M v4/gdk/gdkmonitor.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -10,6 +12,10 @@ import ( | |||
| 10 | 12 | type MonitorClass struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *MonitorClass) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | // This enumeration describes how the red, green and blue components | |
| 14 | 20 | // of physical pixels on an output device are laid out. | |
| 15 | 21 | type SubpixelLayout int | |
M v4/gdk/gdkpaintable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -19,6 +21,10 @@ type PaintableInterface struct { | |||
| 19 | 21 | GIface uintptr | |
| 20 | 22 | } | |
| 21 | 23 | ||
| 24 | + | func (x *PaintableInterface) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 22 | 28 | // `GdkPaintable` is a simple interface used by GTK to represent content that | |
| 23 | 29 | // can be painted. | |
| 24 | 30 | // | |
M v4/gdk/gdkpopup.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -10,6 +12,10 @@ import ( | |||
| 10 | 12 | type PopupInterface struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *PopupInterface) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | // A `GdkPopup` is a surface that is attached to another surface. | |
| 14 | 20 | // | |
| 15 | 21 | // The `GdkPopup` is positioned relative to its parent surface. | |
M v4/gdk/gdkpopuplayout.go +212 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // The `GdkPopupLayout` struct contains information that is | |
| 5 | 12 | // necessary position a [iface@Gdk.Popup] relative to its parent. | |
| 6 | 13 | // | |
| @@ -37,6 +44,184 @@ package gdk | |||
| 37 | 44 | type PopupLayout struct { | |
| 38 | 45 | } | |
| 39 | 46 | ||
| 47 | + | func (x *PopupLayout) GoPointer() uintptr { | |
| 48 | + | return uintptr(unsafe.Pointer(x)) | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | var xNewPopupLayout func(*Rectangle, Gravity, Gravity) *PopupLayout | |
| 52 | + | ||
| 53 | + | // Create a popup layout description. | |
| 54 | + | // | |
| 55 | + | // Used together with [method@Gdk.Popup.present] to describe how a popup | |
| 56 | + | // surface should be placed and behave on-screen. | |
| 57 | + | // | |
| 58 | + | // @anchor_rect is relative to the top-left corner of the surface's parent. | |
| 59 | + | // @rect_anchor and @surface_anchor determine anchor points on @anchor_rect | |
| 60 | + | // and surface to pin together. | |
| 61 | + | // | |
| 62 | + | // The position of @anchor_rect's anchor point can optionally be offset using | |
| 63 | + | // [method@Gdk.PopupLayout.set_offset], which is equivalent to offsetting the | |
| 64 | + | // position of surface. | |
| 65 | + | func NewPopupLayout(AnchorRectVar *Rectangle, RectAnchorVar Gravity, SurfaceAnchorVar Gravity) *PopupLayout { | |
| 66 | + | ||
| 67 | + | cret := xNewPopupLayout(AnchorRectVar, RectAnchorVar, SurfaceAnchorVar) | |
| 68 | + | return cret | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | var xPopupLayoutCopy func(uintptr) *PopupLayout | |
| 72 | + | ||
| 73 | + | // Makes a copy of @layout. | |
| 74 | + | func (x *PopupLayout) Copy() *PopupLayout { | |
| 75 | + | ||
| 76 | + | cret := xPopupLayoutCopy(x.GoPointer()) | |
| 77 | + | return cret | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | var xPopupLayoutEqual func(uintptr, *PopupLayout) bool | |
| 81 | + | ||
| 82 | + | // Check whether @layout and @other has identical layout properties. | |
| 83 | + | func (x *PopupLayout) Equal(OtherVar *PopupLayout) bool { | |
| 84 | + | ||
| 85 | + | cret := xPopupLayoutEqual(x.GoPointer(), OtherVar) | |
| 86 | + | return cret | |
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xPopupLayoutGetAnchorHints func(uintptr) AnchorHints | |
| 90 | + | ||
| 91 | + | // Get the `GdkAnchorHints`. | |
| 92 | + | func (x *PopupLayout) GetAnchorHints() AnchorHints { | |
| 93 | + | ||
| 94 | + | cret := xPopupLayoutGetAnchorHints(x.GoPointer()) | |
| 95 | + | return cret | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | var xPopupLayoutGetAnchorRect func(uintptr) *Rectangle | |
| 99 | + | ||
| 100 | + | // Get the anchor rectangle. | |
| 101 | + | func (x *PopupLayout) GetAnchorRect() *Rectangle { | |
| 102 | + | ||
| 103 | + | cret := xPopupLayoutGetAnchorRect(x.GoPointer()) | |
| 104 | + | return cret | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | var xPopupLayoutGetOffset func(uintptr, int, int) | |
| 108 | + | ||
| 109 | + | // Retrieves the offset for the anchor rectangle. | |
| 110 | + | func (x *PopupLayout) GetOffset(DxVar int, DyVar int) { | |
| 111 | + | ||
| 112 | + | xPopupLayoutGetOffset(x.GoPointer(), DxVar, DyVar) | |
| 113 | + | ||
| 114 | + | } | |
| 115 | + | ||
| 116 | + | var xPopupLayoutGetRectAnchor func(uintptr) Gravity | |
| 117 | + | ||
| 118 | + | // Returns the anchor position on the anchor rectangle. | |
| 119 | + | func (x *PopupLayout) GetRectAnchor() Gravity { | |
| 120 | + | ||
| 121 | + | cret := xPopupLayoutGetRectAnchor(x.GoPointer()) | |
| 122 | + | return cret | |
| 123 | + | } | |
| 124 | + | ||
| 125 | + | var xPopupLayoutGetShadowWidth func(uintptr, int, int, int, int) | |
| 126 | + | ||
| 127 | + | // Obtains the shadow widths of this layout. | |
| 128 | + | func (x *PopupLayout) GetShadowWidth(LeftVar int, RightVar int, TopVar int, BottomVar int) { | |
| 129 | + | ||
| 130 | + | xPopupLayoutGetShadowWidth(x.GoPointer(), LeftVar, RightVar, TopVar, BottomVar) | |
| 131 | + | ||
| 132 | + | } | |
| 133 | + | ||
| 134 | + | var xPopupLayoutGetSurfaceAnchor func(uintptr) Gravity | |
| 135 | + | ||
| 136 | + | // Returns the anchor position on the popup surface. | |
| 137 | + | func (x *PopupLayout) GetSurfaceAnchor() Gravity { | |
| 138 | + | ||
| 139 | + | cret := xPopupLayoutGetSurfaceAnchor(x.GoPointer()) | |
| 140 | + | return cret | |
| 141 | + | } | |
| 142 | + | ||
| 143 | + | var xPopupLayoutRef func(uintptr) *PopupLayout | |
| 144 | + | ||
| 145 | + | // Increases the reference count of @value. | |
| 146 | + | func (x *PopupLayout) Ref() *PopupLayout { | |
| 147 | + | ||
| 148 | + | cret := xPopupLayoutRef(x.GoPointer()) | |
| 149 | + | return cret | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | var xPopupLayoutSetAnchorHints func(uintptr, AnchorHints) | |
| 153 | + | ||
| 154 | + | // Set new anchor hints. | |
| 155 | + | // | |
| 156 | + | // The set @anchor_hints determines how @surface will be moved | |
| 157 | + | // if the anchor points cause it to move off-screen. For example, | |
| 158 | + | // %GDK_ANCHOR_FLIP_X will replace %GDK_GRAVITY_NORTH_WEST with | |
| 159 | + | // %GDK_GRAVITY_NORTH_EAST and vice versa if @surface extends | |
| 160 | + | // beyond the left or right edges of the monitor. | |
| 161 | + | func (x *PopupLayout) SetAnchorHints(AnchorHintsVar AnchorHints) { | |
| 162 | + | ||
| 163 | + | xPopupLayoutSetAnchorHints(x.GoPointer(), AnchorHintsVar) | |
| 164 | + | ||
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xPopupLayoutSetAnchorRect func(uintptr, *Rectangle) | |
| 168 | + | ||
| 169 | + | // Set the anchor rectangle. | |
| 170 | + | func (x *PopupLayout) SetAnchorRect(AnchorRectVar *Rectangle) { | |
| 171 | + | ||
| 172 | + | xPopupLayoutSetAnchorRect(x.GoPointer(), AnchorRectVar) | |
| 173 | + | ||
| 174 | + | } | |
| 175 | + | ||
| 176 | + | var xPopupLayoutSetOffset func(uintptr, int, int) | |
| 177 | + | ||
| 178 | + | // Offset the position of the anchor rectangle with the given delta. | |
| 179 | + | func (x *PopupLayout) SetOffset(DxVar int, DyVar int) { | |
| 180 | + | ||
| 181 | + | xPopupLayoutSetOffset(x.GoPointer(), DxVar, DyVar) | |
| 182 | + | ||
| 183 | + | } | |
| 184 | + | ||
| 185 | + | var xPopupLayoutSetRectAnchor func(uintptr, Gravity) | |
| 186 | + | ||
| 187 | + | // Set the anchor on the anchor rectangle. | |
| 188 | + | func (x *PopupLayout) SetRectAnchor(AnchorVar Gravity) { | |
| 189 | + | ||
| 190 | + | xPopupLayoutSetRectAnchor(x.GoPointer(), AnchorVar) | |
| 191 | + | ||
| 192 | + | } | |
| 193 | + | ||
| 194 | + | var xPopupLayoutSetShadowWidth func(uintptr, int, int, int, int) | |
| 195 | + | ||
| 196 | + | // Sets the shadow width of the popup. | |
| 197 | + | // | |
| 198 | + | // The shadow width corresponds to the part of the computed | |
| 199 | + | // surface size that would consist of the shadow margin | |
| 200 | + | // surrounding the window, would there be any. | |
| 201 | + | func (x *PopupLayout) SetShadowWidth(LeftVar int, RightVar int, TopVar int, BottomVar int) { | |
| 202 | + | ||
| 203 | + | xPopupLayoutSetShadowWidth(x.GoPointer(), LeftVar, RightVar, TopVar, BottomVar) | |
| 204 | + | ||
| 205 | + | } | |
| 206 | + | ||
| 207 | + | var xPopupLayoutSetSurfaceAnchor func(uintptr, Gravity) | |
| 208 | + | ||
| 209 | + | // Set the anchor on the popup surface. | |
| 210 | + | func (x *PopupLayout) SetSurfaceAnchor(AnchorVar Gravity) { | |
| 211 | + | ||
| 212 | + | xPopupLayoutSetSurfaceAnchor(x.GoPointer(), AnchorVar) | |
| 213 | + | ||
| 214 | + | } | |
| 215 | + | ||
| 216 | + | var xPopupLayoutUnref func(uintptr) | |
| 217 | + | ||
| 218 | + | // Decreases the reference count of @value. | |
| 219 | + | func (x *PopupLayout) Unref() { | |
| 220 | + | ||
| 221 | + | xPopupLayoutUnref(x.GoPointer()) | |
| 222 | + | ||
| 223 | + | } | |
| 224 | + | ||
| 40 | 225 | // Positioning hints for aligning a surface relative to a rectangle. | |
| 41 | 226 | // | |
| 42 | 227 | // These hints determine how the surface should be positioned in the case that | |
| @@ -75,3 +260,30 @@ const ( | |||
| 75 | 260 | // allow resizing surface on both axes | |
| 76 | 261 | AnchorResizeValue AnchorHints = 48 | |
| 77 | 262 | ) | |
| 263 | + | ||
| 264 | + | func init() { | |
| 265 | + | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 266 | + | if err != nil { | |
| 267 | + | panic(err) | |
| 268 | + | } | |
| 269 | + | ||
| 270 | + | core.PuregoSafeRegister(&xNewPopupLayout, lib, "gdk_popup_layout_new") | |
| 271 | + | ||
| 272 | + | core.PuregoSafeRegister(&xPopupLayoutCopy, lib, "gdk_popup_layout_copy") | |
| 273 | + | core.PuregoSafeRegister(&xPopupLayoutEqual, lib, "gdk_popup_layout_equal") | |
| 274 | + | core.PuregoSafeRegister(&xPopupLayoutGetAnchorHints, lib, "gdk_popup_layout_get_anchor_hints") | |
| 275 | + | core.PuregoSafeRegister(&xPopupLayoutGetAnchorRect, lib, "gdk_popup_layout_get_anchor_rect") | |
| 276 | + | core.PuregoSafeRegister(&xPopupLayoutGetOffset, lib, "gdk_popup_layout_get_offset") | |
| 277 | + | core.PuregoSafeRegister(&xPopupLayoutGetRectAnchor, lib, "gdk_popup_layout_get_rect_anchor") | |
| 278 | + | core.PuregoSafeRegister(&xPopupLayoutGetShadowWidth, lib, "gdk_popup_layout_get_shadow_width") | |
| 279 | + | core.PuregoSafeRegister(&xPopupLayoutGetSurfaceAnchor, lib, "gdk_popup_layout_get_surface_anchor") | |
| 280 | + | core.PuregoSafeRegister(&xPopupLayoutRef, lib, "gdk_popup_layout_ref") | |
| 281 | + | core.PuregoSafeRegister(&xPopupLayoutSetAnchorHints, lib, "gdk_popup_layout_set_anchor_hints") | |
| 282 | + | core.PuregoSafeRegister(&xPopupLayoutSetAnchorRect, lib, "gdk_popup_layout_set_anchor_rect") | |
| 283 | + | core.PuregoSafeRegister(&xPopupLayoutSetOffset, lib, "gdk_popup_layout_set_offset") | |
| 284 | + | core.PuregoSafeRegister(&xPopupLayoutSetRectAnchor, lib, "gdk_popup_layout_set_rect_anchor") | |
| 285 | + | core.PuregoSafeRegister(&xPopupLayoutSetShadowWidth, lib, "gdk_popup_layout_set_shadow_width") | |
| 286 | + | core.PuregoSafeRegister(&xPopupLayoutSetSurfaceAnchor, lib, "gdk_popup_layout_set_surface_anchor") | |
| 287 | + | core.PuregoSafeRegister(&xPopupLayoutUnref, lib, "gdk_popup_layout_unref") | |
| 288 | + | ||
| 289 | + | } | |
M v4/gdk/gdkrgba.go +137 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // A `GdkRGBA` is used to represent a color, in a way that is compatible | |
| 5 | 12 | // with cairo’s notion of color. | |
| 6 | 13 | // | |
| @@ -19,3 +26,133 @@ type RGBA struct { | |||
| 19 | 26 | ||
| 20 | 27 | Alpha float32 | |
| 21 | 28 | } | |
| 29 | + | ||
| 30 | + | func (x *RGBA) GoPointer() uintptr { | |
| 31 | + | return uintptr(unsafe.Pointer(x)) | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | var xRGBACopy func(uintptr) *RGBA | |
| 35 | + | ||
| 36 | + | // Makes a copy of a `GdkRGBA`. | |
| 37 | + | // | |
| 38 | + | // The result must be freed through [method@Gdk.RGBA.free]. | |
| 39 | + | func (x *RGBA) Copy() *RGBA { | |
| 40 | + | ||
| 41 | + | cret := xRGBACopy(x.GoPointer()) | |
| 42 | + | return cret | |
| 43 | + | } | |
| 44 | + | ||
| 45 | + | var xRGBAEqual func(uintptr, uintptr) bool | |
| 46 | + | ||
| 47 | + | // Compares two `GdkRGBA` colors. | |
| 48 | + | func (x *RGBA) Equal(P2Var uintptr) bool { | |
| 49 | + | ||
| 50 | + | cret := xRGBAEqual(x.GoPointer(), P2Var) | |
| 51 | + | return cret | |
| 52 | + | } | |
| 53 | + | ||
| 54 | + | var xRGBAFree func(uintptr) | |
| 55 | + | ||
| 56 | + | // Frees a `GdkRGBA`. | |
| 57 | + | func (x *RGBA) Free() { | |
| 58 | + | ||
| 59 | + | xRGBAFree(x.GoPointer()) | |
| 60 | + | ||
| 61 | + | } | |
| 62 | + | ||
| 63 | + | var xRGBAHash func(uintptr) uint | |
| 64 | + | ||
| 65 | + | // A hash function suitable for using for a hash | |
| 66 | + | // table that stores `GdkRGBA`s. | |
| 67 | + | func (x *RGBA) Hash() uint { | |
| 68 | + | ||
| 69 | + | cret := xRGBAHash(x.GoPointer()) | |
| 70 | + | return cret | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xRGBAIsClear func(uintptr) bool | |
| 74 | + | ||
| 75 | + | // Checks if an @rgba value is transparent. | |
| 76 | + | // | |
| 77 | + | // That is, drawing with the value would not produce any change. | |
| 78 | + | func (x *RGBA) IsClear() bool { | |
| 79 | + | ||
| 80 | + | cret := xRGBAIsClear(x.GoPointer()) | |
| 81 | + | return cret | |
| 82 | + | } | |
| 83 | + | ||
| 84 | + | var xRGBAIsOpaque func(uintptr) bool | |
| 85 | + | ||
| 86 | + | // Checks if an @rgba value is opaque. | |
| 87 | + | // | |
| 88 | + | // That is, drawing with the value will not retain any results | |
| 89 | + | // from previous contents. | |
| 90 | + | func (x *RGBA) IsOpaque() bool { | |
| 91 | + | ||
| 92 | + | cret := xRGBAIsOpaque(x.GoPointer()) | |
| 93 | + | return cret | |
| 94 | + | } | |
| 95 | + | ||
| 96 | + | var xRGBAParse func(uintptr, string) bool | |
| 97 | + | ||
| 98 | + | // Parses a textual representation of a color. | |
| 99 | + | // | |
| 100 | + | // The string can be either one of: | |
| 101 | + | // | |
| 102 | + | // - A standard name (Taken from the Css specification). | |
| 103 | + | // - A hexadecimal value in the form “\#rgb”, “\#rrggbb”, | |
| 104 | + | // “\#rrrgggbbb” or ”\#rrrrggggbbbb” | |
| 105 | + | // - A hexadecimal value in the form “\#rgba”, “\#rrggbbaa”, | |
| 106 | + | // or ”\#rrrrggggbbbbaaaa” | |
| 107 | + | // - A RGB color in the form “rgb(r,g,b)” (In this case the color | |
| 108 | + | // will have full opacity) | |
| 109 | + | // - A RGBA color in the form “rgba(r,g,b,a)” | |
| 110 | + | // | |
| 111 | + | // Where “r”, “g”, “b” and “a” are respectively the red, green, | |
| 112 | + | // blue and alpha color values. In the last two cases, “r”, “g”, | |
| 113 | + | // and “b” are either integers in the range 0 to 255 or percentage | |
| 114 | + | // values in the range 0% to 100%, and a is a floating point value | |
| 115 | + | // in the range 0 to 1. | |
| 116 | + | func (x *RGBA) Parse(SpecVar string) bool { | |
| 117 | + | ||
| 118 | + | cret := xRGBAParse(x.GoPointer(), SpecVar) | |
| 119 | + | return cret | |
| 120 | + | } | |
| 121 | + | ||
| 122 | + | var xRGBAToString func(uintptr) string | |
| 123 | + | ||
| 124 | + | // Returns a textual specification of @rgba in the form | |
| 125 | + | // `rgb(r,g,b)` or `rgba(r,g,b,a)`, where “r”, “g”, “b” and | |
| 126 | + | // “a” represent the red, green, blue and alpha values | |
| 127 | + | // respectively. “r”, “g”, and “b” are represented as integers | |
| 128 | + | // in the range 0 to 255, and “a” is represented as a floating | |
| 129 | + | // point value in the range 0 to 1. | |
| 130 | + | // | |
| 131 | + | // These string forms are string forms that are supported by | |
| 132 | + | // the CSS3 colors module, and can be parsed by [method@Gdk.RGBA.parse]. | |
| 133 | + | // | |
| 134 | + | // Note that this string representation may lose some precision, | |
| 135 | + | // since “r”, “g” and “b” are represented as 8-bit integers. If | |
| 136 | + | // this is a concern, you should use a different representation. | |
| 137 | + | func (x *RGBA) ToString() string { | |
| 138 | + | ||
| 139 | + | cret := xRGBAToString(x.GoPointer()) | |
| 140 | + | return cret | |
| 141 | + | } | |
| 142 | + | ||
| 143 | + | func init() { | |
| 144 | + | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 145 | + | if err != nil { | |
| 146 | + | panic(err) | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | core.PuregoSafeRegister(&xRGBACopy, lib, "gdk_rgba_copy") | |
| 150 | + | core.PuregoSafeRegister(&xRGBAEqual, lib, "gdk_rgba_equal") | |
| 151 | + | core.PuregoSafeRegister(&xRGBAFree, lib, "gdk_rgba_free") | |
| 152 | + | core.PuregoSafeRegister(&xRGBAHash, lib, "gdk_rgba_hash") | |
| 153 | + | core.PuregoSafeRegister(&xRGBAIsClear, lib, "gdk_rgba_is_clear") | |
| 154 | + | core.PuregoSafeRegister(&xRGBAIsOpaque, lib, "gdk_rgba_is_opaque") | |
| 155 | + | core.PuregoSafeRegister(&xRGBAParse, lib, "gdk_rgba_parse") | |
| 156 | + | core.PuregoSafeRegister(&xRGBAToString, lib, "gdk_rgba_to_string") | |
| 157 | + | ||
| 158 | + | } | |
M v4/gdk/gdksnapshot.go +9 -1
| @@ -1,11 +1,19 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | - | import "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | + | ) | |
| 5 | 9 | ||
| 6 | 10 | type SnapshotClass struct { | |
| 7 | 11 | } | |
| 8 | 12 | ||
| 13 | + | func (x *SnapshotClass) GoPointer() uintptr { | |
| 14 | + | return uintptr(unsafe.Pointer(x)) | |
| 15 | + | } | |
| 16 | + | ||
| 9 | 17 | // Base type for snapshot operations. | |
| 10 | 18 | // | |
| 11 | 19 | // The subclass of `GdkSnapshot` used by GTK is [class@Gtk.Snapshot]. | |
M v4/gdk/gdksurface.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/cairo" | |
| @@ -12,6 +14,10 @@ import ( | |||
| 12 | 14 | type SurfaceClass struct { | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SurfaceClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A `GdkSurface` is a rectangular region on the screen. | |
| 16 | 22 | // | |
| 17 | 23 | // It’s a low-level object, used to implement high-level objects | |
M v4/gdk/gdktexture.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdkpixbuf" | |
| @@ -13,6 +15,10 @@ import ( | |||
| 13 | 15 | type TextureClass struct { | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *TextureClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // Possible errors that can be returned by `GdkTexture` constructors. | |
| 17 | 23 | type TextureError int | |
| 18 | 24 | ||
M v4/gdk/gdktoplevel.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -10,6 +12,10 @@ import ( | |||
| 10 | 12 | type ToplevelInterface struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *ToplevelInterface) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | // A `GdkToplevel` is a freestanding toplevel surface. | |
| 14 | 20 | // | |
| 15 | 21 | // The `GdkToplevel` interface provides useful APIs for interacting with | |
M v4/gdk/gdktoplevellayout.go +165 -0
| @@ -1,6 +1,14 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | + | ) | |
| 11 | + | ||
| 4 | 12 | // The `GdkToplevelLayout` struct contains information that | |
| 5 | 13 | // is necessary to present a sovereign window on screen. | |
| 6 | 14 | // | |
| @@ -12,3 +20,160 @@ package gdk | |||
| 12 | 20 | // etc). | |
| 13 | 21 | type ToplevelLayout struct { | |
| 14 | 22 | } | |
| 23 | + | ||
| 24 | + | func (x *ToplevelLayout) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | var xNewToplevelLayout func() *ToplevelLayout | |
| 29 | + | ||
| 30 | + | // Create a toplevel layout description. | |
| 31 | + | // | |
| 32 | + | // Used together with gdk_toplevel_present() to describe | |
| 33 | + | // how a toplevel surface should be placed and behave on-screen. | |
| 34 | + | // | |
| 35 | + | // The size is in ”application pixels”, not | |
| 36 | + | // ”device pixels” (see gdk_surface_get_scale_factor()). | |
| 37 | + | func NewToplevelLayout() *ToplevelLayout { | |
| 38 | + | ||
| 39 | + | cret := xNewToplevelLayout() | |
| 40 | + | return cret | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xToplevelLayoutCopy func(uintptr) *ToplevelLayout | |
| 44 | + | ||
| 45 | + | // Create a new `GdkToplevelLayout` and copy the contents of @layout into it. | |
| 46 | + | func (x *ToplevelLayout) Copy() *ToplevelLayout { | |
| 47 | + | ||
| 48 | + | cret := xToplevelLayoutCopy(x.GoPointer()) | |
| 49 | + | return cret | |
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xToplevelLayoutEqual func(uintptr, *ToplevelLayout) bool | |
| 53 | + | ||
| 54 | + | // Check whether @layout and @other has identical layout properties. | |
| 55 | + | func (x *ToplevelLayout) Equal(OtherVar *ToplevelLayout) bool { | |
| 56 | + | ||
| 57 | + | cret := xToplevelLayoutEqual(x.GoPointer(), OtherVar) | |
| 58 | + | return cret | |
| 59 | + | } | |
| 60 | + | ||
| 61 | + | var xToplevelLayoutGetFullscreen func(uintptr, bool) bool | |
| 62 | + | ||
| 63 | + | // If the layout specifies whether to the toplevel should go fullscreen, | |
| 64 | + | // the value pointed to by @fullscreen is set to %TRUE if it should go | |
| 65 | + | // fullscreen, or %FALSE, if it should go unfullscreen. | |
| 66 | + | func (x *ToplevelLayout) GetFullscreen(FullscreenVar bool) bool { | |
| 67 | + | ||
| 68 | + | cret := xToplevelLayoutGetFullscreen(x.GoPointer(), FullscreenVar) | |
| 69 | + | return cret | |
| 70 | + | } | |
| 71 | + | ||
| 72 | + | var xToplevelLayoutGetFullscreenMonitor func(uintptr) uintptr | |
| 73 | + | ||
| 74 | + | // Returns the monitor that the layout is fullscreening | |
| 75 | + | // the surface on. | |
| 76 | + | func (x *ToplevelLayout) GetFullscreenMonitor() *Monitor { | |
| 77 | + | var cls *Monitor | |
| 78 | + | ||
| 79 | + | cret := xToplevelLayoutGetFullscreenMonitor(x.GoPointer()) | |
| 80 | + | ||
| 81 | + | if cret == 0 { | |
| 82 | + | return nil | |
| 83 | + | } | |
| 84 | + | gobject.IncreaseRef(cret) | |
| 85 | + | cls = &Monitor{} | |
| 86 | + | cls.Ptr = cret | |
| 87 | + | return cls | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | var xToplevelLayoutGetMaximized func(uintptr, bool) bool | |
| 91 | + | ||
| 92 | + | // If the layout specifies whether to the toplevel should go maximized, | |
| 93 | + | // the value pointed to by @maximized is set to %TRUE if it should go | |
| 94 | + | // fullscreen, or %FALSE, if it should go unmaximized. | |
| 95 | + | func (x *ToplevelLayout) GetMaximized(MaximizedVar bool) bool { | |
| 96 | + | ||
| 97 | + | cret := xToplevelLayoutGetMaximized(x.GoPointer(), MaximizedVar) | |
| 98 | + | return cret | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | var xToplevelLayoutGetResizable func(uintptr) bool | |
| 102 | + | ||
| 103 | + | // Returns whether the layout should allow the user | |
| 104 | + | // to resize the surface. | |
| 105 | + | func (x *ToplevelLayout) GetResizable() bool { | |
| 106 | + | ||
| 107 | + | cret := xToplevelLayoutGetResizable(x.GoPointer()) | |
| 108 | + | return cret | |
| 109 | + | } | |
| 110 | + | ||
| 111 | + | var xToplevelLayoutRef func(uintptr) *ToplevelLayout | |
| 112 | + | ||
| 113 | + | // Increases the reference count of @layout. | |
| 114 | + | func (x *ToplevelLayout) Ref() *ToplevelLayout { | |
| 115 | + | ||
| 116 | + | cret := xToplevelLayoutRef(x.GoPointer()) | |
| 117 | + | return cret | |
| 118 | + | } | |
| 119 | + | ||
| 120 | + | var xToplevelLayoutSetFullscreen func(uintptr, bool, uintptr) | |
| 121 | + | ||
| 122 | + | // Sets whether the layout should cause the surface | |
| 123 | + | // to be fullscreen when presented. | |
| 124 | + | func (x *ToplevelLayout) SetFullscreen(FullscreenVar bool, MonitorVar *Monitor) { | |
| 125 | + | ||
| 126 | + | xToplevelLayoutSetFullscreen(x.GoPointer(), FullscreenVar, MonitorVar.GoPointer()) | |
| 127 | + | ||
| 128 | + | } | |
| 129 | + | ||
| 130 | + | var xToplevelLayoutSetMaximized func(uintptr, bool) | |
| 131 | + | ||
| 132 | + | // Sets whether the layout should cause the surface | |
| 133 | + | // to be maximized when presented. | |
| 134 | + | func (x *ToplevelLayout) SetMaximized(MaximizedVar bool) { | |
| 135 | + | ||
| 136 | + | xToplevelLayoutSetMaximized(x.GoPointer(), MaximizedVar) | |
| 137 | + | ||
| 138 | + | } | |
| 139 | + | ||
| 140 | + | var xToplevelLayoutSetResizable func(uintptr, bool) | |
| 141 | + | ||
| 142 | + | // Sets whether the layout should allow the user | |
| 143 | + | // to resize the surface after it has been presented. | |
| 144 | + | func (x *ToplevelLayout) SetResizable(ResizableVar bool) { | |
| 145 | + | ||
| 146 | + | xToplevelLayoutSetResizable(x.GoPointer(), ResizableVar) | |
| 147 | + | ||
| 148 | + | } | |
| 149 | + | ||
| 150 | + | var xToplevelLayoutUnref func(uintptr) | |
| 151 | + | ||
| 152 | + | // Decreases the reference count of @layout. | |
| 153 | + | func (x *ToplevelLayout) Unref() { | |
| 154 | + | ||
| 155 | + | xToplevelLayoutUnref(x.GoPointer()) | |
| 156 | + | ||
| 157 | + | } | |
| 158 | + | ||
| 159 | + | func init() { | |
| 160 | + | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 161 | + | if err != nil { | |
| 162 | + | panic(err) | |
| 163 | + | } | |
| 164 | + | ||
| 165 | + | core.PuregoSafeRegister(&xNewToplevelLayout, lib, "gdk_toplevel_layout_new") | |
| 166 | + | ||
| 167 | + | core.PuregoSafeRegister(&xToplevelLayoutCopy, lib, "gdk_toplevel_layout_copy") | |
| 168 | + | core.PuregoSafeRegister(&xToplevelLayoutEqual, lib, "gdk_toplevel_layout_equal") | |
| 169 | + | core.PuregoSafeRegister(&xToplevelLayoutGetFullscreen, lib, "gdk_toplevel_layout_get_fullscreen") | |
| 170 | + | core.PuregoSafeRegister(&xToplevelLayoutGetFullscreenMonitor, lib, "gdk_toplevel_layout_get_fullscreen_monitor") | |
| 171 | + | core.PuregoSafeRegister(&xToplevelLayoutGetMaximized, lib, "gdk_toplevel_layout_get_maximized") | |
| 172 | + | core.PuregoSafeRegister(&xToplevelLayoutGetResizable, lib, "gdk_toplevel_layout_get_resizable") | |
| 173 | + | core.PuregoSafeRegister(&xToplevelLayoutRef, lib, "gdk_toplevel_layout_ref") | |
| 174 | + | core.PuregoSafeRegister(&xToplevelLayoutSetFullscreen, lib, "gdk_toplevel_layout_set_fullscreen") | |
| 175 | + | core.PuregoSafeRegister(&xToplevelLayoutSetMaximized, lib, "gdk_toplevel_layout_set_maximized") | |
| 176 | + | core.PuregoSafeRegister(&xToplevelLayoutSetResizable, lib, "gdk_toplevel_layout_set_resizable") | |
| 177 | + | core.PuregoSafeRegister(&xToplevelLayoutUnref, lib, "gdk_toplevel_layout_unref") | |
| 178 | + | ||
| 179 | + | } | |
M v4/gdk/gdktoplevelsize.go +70 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,69 @@ import ( | |||
| 11 | 13 | type ToplevelSize struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *ToplevelSize) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xToplevelSizeGetBounds func(uintptr, int, int) | |
| 21 | + | ||
| 22 | + | // Retrieves the bounds the toplevel is placed within. | |
| 23 | + | // | |
| 24 | + | // The bounds represent the largest size a toplevel may have while still being | |
| 25 | + | // able to fit within some type of boundary. Depending on the backend, this may | |
| 26 | + | // be equivalent to the dimensions of the work area or the monitor on which the | |
| 27 | + | // window is being presented on, or something else that limits the way a | |
| 28 | + | // toplevel can be presented. | |
| 29 | + | func (x *ToplevelSize) GetBounds(BoundsWidthVar int, BoundsHeightVar int) { | |
| 30 | + | ||
| 31 | + | xToplevelSizeGetBounds(x.GoPointer(), BoundsWidthVar, BoundsHeightVar) | |
| 32 | + | ||
| 33 | + | } | |
| 34 | + | ||
| 35 | + | var xToplevelSizeSetMinSize func(uintptr, int, int) | |
| 36 | + | ||
| 37 | + | // Sets the minimum size of the toplevel. | |
| 38 | + | // | |
| 39 | + | // The minimum size corresponds to the limitations the toplevel can be shrunk | |
| 40 | + | // to, without resulting in incorrect painting. A user of a `GdkToplevel` should | |
| 41 | + | // calculate these given both the existing size, and the bounds retrieved from | |
| 42 | + | // the `GdkToplevelSize` object. | |
| 43 | + | // | |
| 44 | + | // The minimum size should be within the bounds (see | |
| 45 | + | // [method@Gdk.ToplevelSize.get_bounds]). | |
| 46 | + | func (x *ToplevelSize) SetMinSize(MinWidthVar int, MinHeightVar int) { | |
| 47 | + | ||
| 48 | + | xToplevelSizeSetMinSize(x.GoPointer(), MinWidthVar, MinHeightVar) | |
| 49 | + | ||
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xToplevelSizeSetShadowWidth func(uintptr, int, int, int, int) | |
| 53 | + | ||
| 54 | + | // Sets the shadows size of the toplevel. | |
| 55 | + | // | |
| 56 | + | // The shadow width corresponds to the part of the computed surface size | |
| 57 | + | // that would consist of the shadow margin surrounding the window, would | |
| 58 | + | // there be any. | |
| 59 | + | func (x *ToplevelSize) SetShadowWidth(LeftVar int, RightVar int, TopVar int, BottomVar int) { | |
| 60 | + | ||
| 61 | + | xToplevelSizeSetShadowWidth(x.GoPointer(), LeftVar, RightVar, TopVar, BottomVar) | |
| 62 | + | ||
| 63 | + | } | |
| 64 | + | ||
| 65 | + | var xToplevelSizeSetSize func(uintptr, int, int) | |
| 66 | + | ||
| 67 | + | // Sets the size the toplevel prefers to be resized to. | |
| 68 | + | // | |
| 69 | + | // The size should be within the bounds (see | |
| 70 | + | // [method@Gdk.ToplevelSize.get_bounds]). The set size should | |
| 71 | + | // be considered as a hint, and should not be assumed to be | |
| 72 | + | // respected by the windowing system, or backend. | |
| 73 | + | func (x *ToplevelSize) SetSize(WidthVar int, HeightVar int) { | |
| 74 | + | ||
| 75 | + | xToplevelSizeSetSize(x.GoPointer(), WidthVar, HeightVar) | |
| 76 | + | ||
| 77 | + | } | |
| 78 | + | ||
| 14 | 79 | var xToplevelSizeGetType func() []interface{} | |
| 15 | 80 | ||
| 16 | 81 | func ToplevelSizeGetType() []interface{} { | |
| @@ -26,4 +91,9 @@ func init() { | |||
| 26 | 91 | } | |
| 27 | 92 | core.PuregoSafeRegister(&xToplevelSizeGetType, lib, "gdk_toplevel_size_get_type") | |
| 28 | 93 | ||
| 94 | + | core.PuregoSafeRegister(&xToplevelSizeGetBounds, lib, "gdk_toplevel_size_get_bounds") | |
| 95 | + | core.PuregoSafeRegister(&xToplevelSizeSetMinSize, lib, "gdk_toplevel_size_set_min_size") | |
| 96 | + | core.PuregoSafeRegister(&xToplevelSizeSetShadowWidth, lib, "gdk_toplevel_size_set_shadow_width") | |
| 97 | + | core.PuregoSafeRegister(&xToplevelSizeSetSize, lib, "gdk_toplevel_size_set_size") | |
| 98 | + | ||
| 29 | 99 | } | |
M v4/gdk/gdktypes.go +300 -0
| @@ -1,6 +1,14 @@ | |||
| 1 | 1 | // Package gdk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | + | ) | |
| 11 | + | ||
| 4 | 12 | // The `GdkContentFormats` structure is used to advertise and negotiate the | |
| 5 | 13 | // format of content. | |
| 6 | 14 | // | |
| @@ -36,6 +44,203 @@ package gdk | |||
| 36 | 44 | type ContentFormats struct { | |
| 37 | 45 | } | |
| 38 | 46 | ||
| 47 | + | func (x *ContentFormats) GoPointer() uintptr { | |
| 48 | + | return uintptr(unsafe.Pointer(x)) | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | var xNewContentFormats func([]string, uint) *ContentFormats | |
| 52 | + | ||
| 53 | + | // Creates a new `GdkContentFormats` from an array of mime types. | |
| 54 | + | // | |
| 55 | + | // The mime types must be valid and different from each other or the | |
| 56 | + | // behavior of the return value is undefined. If you cannot guarantee | |
| 57 | + | // this, use [struct@Gdk.ContentFormatsBuilder] instead. | |
| 58 | + | func NewContentFormats(MimeTypesVar []string, NMimeTypesVar uint) *ContentFormats { | |
| 59 | + | ||
| 60 | + | cret := xNewContentFormats(MimeTypesVar, NMimeTypesVar) | |
| 61 | + | return cret | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xNewForGtypeContentFormats func([]interface{}) *ContentFormats | |
| 65 | + | ||
| 66 | + | // Creates a new `GdkContentFormats` for a given `GType`. | |
| 67 | + | func NewForGtypeContentFormats(TypeVar []interface{}) *ContentFormats { | |
| 68 | + | ||
| 69 | + | cret := xNewForGtypeContentFormats(TypeVar) | |
| 70 | + | return cret | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xContentFormatsContainGtype func(uintptr, []interface{}) bool | |
| 74 | + | ||
| 75 | + | // Checks if a given `GType` is part of the given @formats. | |
| 76 | + | func (x *ContentFormats) ContainGtype(TypeVar []interface{}) bool { | |
| 77 | + | ||
| 78 | + | cret := xContentFormatsContainGtype(x.GoPointer(), TypeVar) | |
| 79 | + | return cret | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | var xContentFormatsContainMimeType func(uintptr, string) bool | |
| 83 | + | ||
| 84 | + | // Checks if a given mime type is part of the given @formats. | |
| 85 | + | func (x *ContentFormats) ContainMimeType(MimeTypeVar string) bool { | |
| 86 | + | ||
| 87 | + | cret := xContentFormatsContainMimeType(x.GoPointer(), MimeTypeVar) | |
| 88 | + | return cret | |
| 89 | + | } | |
| 90 | + | ||
| 91 | + | var xContentFormatsGetGtypes func(uintptr, uint) uintptr | |
| 92 | + | ||
| 93 | + | // Gets the `GType`s included in @formats. | |
| 94 | + | // | |
| 95 | + | // Note that @formats may not contain any `GType`s, in particular when | |
| 96 | + | // they are empty. In that case %NULL will be returned. | |
| 97 | + | func (x *ContentFormats) GetGtypes(NGtypesVar uint) uintptr { | |
| 98 | + | ||
| 99 | + | cret := xContentFormatsGetGtypes(x.GoPointer(), NGtypesVar) | |
| 100 | + | return cret | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | var xContentFormatsGetMimeTypes func(uintptr, uint) uintptr | |
| 104 | + | ||
| 105 | + | // Gets the mime types included in @formats. | |
| 106 | + | // | |
| 107 | + | // Note that @formats may not contain any mime types, in particular | |
| 108 | + | // when they are empty. In that case %NULL will be returned. | |
| 109 | + | func (x *ContentFormats) GetMimeTypes(NMimeTypesVar uint) uintptr { | |
| 110 | + | ||
| 111 | + | cret := xContentFormatsGetMimeTypes(x.GoPointer(), NMimeTypesVar) | |
| 112 | + | return cret | |
| 113 | + | } | |
| 114 | + | ||
| 115 | + | var xContentFormatsMatch func(uintptr, *ContentFormats) bool | |
| 116 | + | ||
| 117 | + | // Checks if @first and @second have any matching formats. | |
| 118 | + | func (x *ContentFormats) Match(SecondVar *ContentFormats) bool { | |
| 119 | + | ||
| 120 | + | cret := xContentFormatsMatch(x.GoPointer(), SecondVar) | |
| 121 | + | return cret | |
| 122 | + | } | |
| 123 | + | ||
| 124 | + | var xContentFormatsMatchGtype func(uintptr, *ContentFormats) []interface{} | |
| 125 | + | ||
| 126 | + | // Finds the first `GType` from @first that is also contained | |
| 127 | + | // in @second. | |
| 128 | + | // | |
| 129 | + | // If no matching `GType` is found, %G_TYPE_INVALID is returned. | |
| 130 | + | func (x *ContentFormats) MatchGtype(SecondVar *ContentFormats) []interface{} { | |
| 131 | + | ||
| 132 | + | cret := xContentFormatsMatchGtype(x.GoPointer(), SecondVar) | |
| 133 | + | return cret | |
| 134 | + | } | |
| 135 | + | ||
| 136 | + | var xContentFormatsMatchMimeType func(uintptr, *ContentFormats) string | |
| 137 | + | ||
| 138 | + | // Finds the first mime type from @first that is also contained | |
| 139 | + | // in @second. | |
| 140 | + | // | |
| 141 | + | // If no matching mime type is found, %NULL is returned. | |
| 142 | + | func (x *ContentFormats) MatchMimeType(SecondVar *ContentFormats) string { | |
| 143 | + | ||
| 144 | + | cret := xContentFormatsMatchMimeType(x.GoPointer(), SecondVar) | |
| 145 | + | return cret | |
| 146 | + | } | |
| 147 | + | ||
| 148 | + | var xContentFormatsPrint func(uintptr, *glib.String) | |
| 149 | + | ||
| 150 | + | // Prints the given @formats into a string for human consumption. | |
| 151 | + | // | |
| 152 | + | // The result of this function can later be parsed with | |
| 153 | + | // [func@Gdk.ContentFormats.parse]. | |
| 154 | + | func (x *ContentFormats) Print(StringVar *glib.String) { | |
| 155 | + | ||
| 156 | + | xContentFormatsPrint(x.GoPointer(), StringVar) | |
| 157 | + | ||
| 158 | + | } | |
| 159 | + | ||
| 160 | + | var xContentFormatsRef func(uintptr) *ContentFormats | |
| 161 | + | ||
| 162 | + | // Increases the reference count of a `GdkContentFormats` by one. | |
| 163 | + | func (x *ContentFormats) Ref() *ContentFormats { | |
| 164 | + | ||
| 165 | + | cret := xContentFormatsRef(x.GoPointer()) | |
| 166 | + | return cret | |
| 167 | + | } | |
| 168 | + | ||
| 169 | + | var xContentFormatsToString func(uintptr) string | |
| 170 | + | ||
| 171 | + | // Prints the given @formats into a human-readable string. | |
| 172 | + | // | |
| 173 | + | // The resulting string can be parsed with [func@Gdk.ContentFormats.parse]. | |
| 174 | + | // | |
| 175 | + | // This is a small wrapper around [method@Gdk.ContentFormats.print] | |
| 176 | + | // to help when debugging. | |
| 177 | + | func (x *ContentFormats) ToString() string { | |
| 178 | + | ||
| 179 | + | cret := xContentFormatsToString(x.GoPointer()) | |
| 180 | + | return cret | |
| 181 | + | } | |
| 182 | + | ||
| 183 | + | var xContentFormatsUnion func(uintptr, *ContentFormats) *ContentFormats | |
| 184 | + | ||
| 185 | + | // Append all missing types from @second to @first, in the order | |
| 186 | + | // they had in @second. | |
| 187 | + | func (x *ContentFormats) Union(SecondVar *ContentFormats) *ContentFormats { | |
| 188 | + | ||
| 189 | + | cret := xContentFormatsUnion(x.GoPointer(), SecondVar) | |
| 190 | + | return cret | |
| 191 | + | } | |
| 192 | + | ||
| 193 | + | var xContentFormatsUnionDeserializeGtypes func(uintptr) *ContentFormats | |
| 194 | + | ||
| 195 | + | // Add GTypes for mime types in @formats for which deserializers are | |
| 196 | + | // registered. | |
| 197 | + | func (x *ContentFormats) UnionDeserializeGtypes() *ContentFormats { | |
| 198 | + | ||
| 199 | + | cret := xContentFormatsUnionDeserializeGtypes(x.GoPointer()) | |
| 200 | + | return cret | |
| 201 | + | } | |
| 202 | + | ||
| 203 | + | var xContentFormatsUnionDeserializeMimeTypes func(uintptr) *ContentFormats | |
| 204 | + | ||
| 205 | + | // Add mime types for GTypes in @formats for which deserializers are | |
| 206 | + | // registered. | |
| 207 | + | func (x *ContentFormats) UnionDeserializeMimeTypes() *ContentFormats { | |
| 208 | + | ||
| 209 | + | cret := xContentFormatsUnionDeserializeMimeTypes(x.GoPointer()) | |
| 210 | + | return cret | |
| 211 | + | } | |
| 212 | + | ||
| 213 | + | var xContentFormatsUnionSerializeGtypes func(uintptr) *ContentFormats | |
| 214 | + | ||
| 215 | + | // Add GTypes for the mime types in @formats for which serializers are | |
| 216 | + | // registered. | |
| 217 | + | func (x *ContentFormats) UnionSerializeGtypes() *ContentFormats { | |
| 218 | + | ||
| 219 | + | cret := xContentFormatsUnionSerializeGtypes(x.GoPointer()) | |
| 220 | + | return cret | |
| 221 | + | } | |
| 222 | + | ||
| 223 | + | var xContentFormatsUnionSerializeMimeTypes func(uintptr) *ContentFormats | |
| 224 | + | ||
| 225 | + | // Add mime types for GTypes in @formats for which serializers are | |
| 226 | + | // registered. | |
| 227 | + | func (x *ContentFormats) UnionSerializeMimeTypes() *ContentFormats { | |
| 228 | + | ||
| 229 | + | cret := xContentFormatsUnionSerializeMimeTypes(x.GoPointer()) | |
| 230 | + | return cret | |
| 231 | + | } | |
| 232 | + | ||
| 233 | + | var xContentFormatsUnref func(uintptr) | |
| 234 | + | ||
| 235 | + | // Decreases the reference count of a `GdkContentFormats` by one. | |
| 236 | + | // | |
| 237 | + | // If the resulting reference count is zero, frees the formats. | |
| 238 | + | func (x *ContentFormats) Unref() { | |
| 239 | + | ||
| 240 | + | xContentFormatsUnref(x.GoPointer()) | |
| 241 | + | ||
| 242 | + | } | |
| 243 | + | ||
| 39 | 244 | // A `GdkKeymapKey` is a hardware key that can be mapped to a keyval. | |
| 40 | 245 | type KeymapKey struct { | |
| 41 | 246 | Keycode uint | |
| @@ -45,6 +250,10 @@ type KeymapKey struct { | |||
| 45 | 250 | Level int | |
| 46 | 251 | } | |
| 47 | 252 | ||
| 253 | + | func (x *KeymapKey) GoPointer() uintptr { | |
| 254 | + | return uintptr(unsafe.Pointer(x)) | |
| 255 | + | } | |
| 256 | + | ||
| 48 | 257 | // A `GdkRectangle` data type for representing rectangles. | |
| 49 | 258 | // | |
| 50 | 259 | // `GdkRectangle` is identical to `cairo_rectangle_t`. Together with Cairo’s | |
| @@ -69,3 +278,94 @@ type Rectangle struct { | |||
| 69 | 278 | ||
| 70 | 279 | Height int | |
| 71 | 280 | } | |
| 281 | + | ||
| 282 | + | func (x *Rectangle) GoPointer() uintptr { | |
| 283 | + | return uintptr(unsafe.Pointer(x)) | |
| 284 | + | } | |
| 285 | + | ||
| 286 | + | var xRectangleContainsPoint func(uintptr, int, int) bool | |
| 287 | + | ||
| 288 | + | // Returns %TRUE if @rect contains the point described by @x and @y. | |
| 289 | + | func (x *Rectangle) ContainsPoint(XVar int, YVar int) bool { | |
| 290 | + | ||
| 291 | + | cret := xRectangleContainsPoint(x.GoPointer(), XVar, YVar) | |
| 292 | + | return cret | |
| 293 | + | } | |
| 294 | + | ||
| 295 | + | var xRectangleEqual func(uintptr, *Rectangle) bool | |
| 296 | + | ||
| 297 | + | // Checks if the two given rectangles are equal. | |
| 298 | + | func (x *Rectangle) Equal(Rect2Var *Rectangle) bool { | |
| 299 | + | ||
| 300 | + | cret := xRectangleEqual(x.GoPointer(), Rect2Var) | |
| 301 | + | return cret | |
| 302 | + | } | |
| 303 | + | ||
| 304 | + | var xRectangleIntersect func(uintptr, *Rectangle, *Rectangle) bool | |
| 305 | + | ||
| 306 | + | // Calculates the intersection of two rectangles. | |
| 307 | + | // | |
| 308 | + | // It is allowed for @dest to be the same as either @src1 or @src2. | |
| 309 | + | // If the rectangles do not intersect, @dest’s width and height is set | |
| 310 | + | // to 0 and its x and y values are undefined. If you are only interested | |
| 311 | + | // in whether the rectangles intersect, but not in the intersecting area | |
| 312 | + | // itself, pass %NULL for @dest. | |
| 313 | + | func (x *Rectangle) Intersect(Src2Var *Rectangle, DestVar *Rectangle) bool { | |
| 314 | + | ||
| 315 | + | cret := xRectangleIntersect(x.GoPointer(), Src2Var, DestVar) | |
| 316 | + | return cret | |
| 317 | + | } | |
| 318 | + | ||
| 319 | + | var xRectangleUnion func(uintptr, *Rectangle, *Rectangle) | |
| 320 | + | ||
| 321 | + | // Calculates the union of two rectangles. | |
| 322 | + | // | |
| 323 | + | // The union of rectangles @src1 and @src2 is the smallest rectangle which | |
| 324 | + | // includes both @src1 and @src2 within it. It is allowed for @dest to be | |
| 325 | + | // the same as either @src1 or @src2. | |
| 326 | + | // | |
| 327 | + | // Note that this function does not ignore 'empty' rectangles (ie. with | |
| 328 | + | // zero width or height). | |
| 329 | + | func (x *Rectangle) Union(Src2Var *Rectangle, DestVar *Rectangle) { | |
| 330 | + | ||
| 331 | + | xRectangleUnion(x.GoPointer(), Src2Var, DestVar) | |
| 332 | + | ||
| 333 | + | } | |
| 334 | + | ||
| 335 | + | const ( | |
| 336 | + | // Represents the current time, and can be used anywhere a time is expected. | |
| 337 | + | CURRENT_TIME int = 0 | |
| 338 | + | ) | |
| 339 | + | ||
| 340 | + | func init() { | |
| 341 | + | lib, err := purego.Dlopen(core.GetPath("GDK"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 342 | + | if err != nil { | |
| 343 | + | panic(err) | |
| 344 | + | } | |
| 345 | + | ||
| 346 | + | core.PuregoSafeRegister(&xNewContentFormats, lib, "gdk_content_formats_new") | |
| 347 | + | core.PuregoSafeRegister(&xNewForGtypeContentFormats, lib, "gdk_content_formats_new_for_gtype") | |
| 348 | + | ||
| 349 | + | core.PuregoSafeRegister(&xContentFormatsContainGtype, lib, "gdk_content_formats_contain_gtype") | |
| 350 | + | core.PuregoSafeRegister(&xContentFormatsContainMimeType, lib, "gdk_content_formats_contain_mime_type") | |
| 351 | + | core.PuregoSafeRegister(&xContentFormatsGetGtypes, lib, "gdk_content_formats_get_gtypes") | |
| 352 | + | core.PuregoSafeRegister(&xContentFormatsGetMimeTypes, lib, "gdk_content_formats_get_mime_types") | |
| 353 | + | core.PuregoSafeRegister(&xContentFormatsMatch, lib, "gdk_content_formats_match") | |
| 354 | + | core.PuregoSafeRegister(&xContentFormatsMatchGtype, lib, "gdk_content_formats_match_gtype") | |
| 355 | + | core.PuregoSafeRegister(&xContentFormatsMatchMimeType, lib, "gdk_content_formats_match_mime_type") | |
| 356 | + | core.PuregoSafeRegister(&xContentFormatsPrint, lib, "gdk_content_formats_print") | |
| 357 | + | core.PuregoSafeRegister(&xContentFormatsRef, lib, "gdk_content_formats_ref") | |
| 358 | + | core.PuregoSafeRegister(&xContentFormatsToString, lib, "gdk_content_formats_to_string") | |
| 359 | + | core.PuregoSafeRegister(&xContentFormatsUnion, lib, "gdk_content_formats_union") | |
| 360 | + | core.PuregoSafeRegister(&xContentFormatsUnionDeserializeGtypes, lib, "gdk_content_formats_union_deserialize_gtypes") | |
| 361 | + | core.PuregoSafeRegister(&xContentFormatsUnionDeserializeMimeTypes, lib, "gdk_content_formats_union_deserialize_mime_types") | |
| 362 | + | core.PuregoSafeRegister(&xContentFormatsUnionSerializeGtypes, lib, "gdk_content_formats_union_serialize_gtypes") | |
| 363 | + | core.PuregoSafeRegister(&xContentFormatsUnionSerializeMimeTypes, lib, "gdk_content_formats_union_serialize_mime_types") | |
| 364 | + | core.PuregoSafeRegister(&xContentFormatsUnref, lib, "gdk_content_formats_unref") | |
| 365 | + | ||
| 366 | + | core.PuregoSafeRegister(&xRectangleContainsPoint, lib, "gdk_rectangle_contains_point") | |
| 367 | + | core.PuregoSafeRegister(&xRectangleEqual, lib, "gdk_rectangle_equal") | |
| 368 | + | core.PuregoSafeRegister(&xRectangleIntersect, lib, "gdk_rectangle_intersect") | |
| 369 | + | core.PuregoSafeRegister(&xRectangleUnion, lib, "gdk_rectangle_union") | |
| 370 | + | ||
| 371 | + | } | |
M v4/gdkpixbuf/gdk-pixbuf-animation.go +28 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdkpixbuf | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -16,6 +18,10 @@ type PixbufAnimationClass struct { | |||
| 16 | 18 | ParentClass uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *PixbufAnimationClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // Modules supporting animations must derive a type from | |
| 20 | 26 | // #GdkPixbufAnimationIter, providing suitable implementations of the | |
| 21 | 27 | // virtual functions. | |
| @@ -23,6 +29,10 @@ type PixbufAnimationIterClass struct { | |||
| 23 | 29 | ParentClass uintptr | |
| 24 | 30 | } | |
| 25 | 31 | ||
| 32 | + | func (x *PixbufAnimationIterClass) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 26 | 36 | // An opaque object representing an animation. | |
| 27 | 37 | // | |
| 28 | 38 | // The GdkPixBuf library provides a simple mechanism to load and | |
| @@ -293,6 +303,22 @@ func (c *PixbufAnimation) SetGoPointer(ptr uintptr) { | |||
| 293 | 303 | c.Ptr = ptr | |
| 294 | 304 | } | |
| 295 | 305 | ||
| 306 | + | var xPixbufAnimationNewFromStreamAsync func(uintptr, uintptr, uintptr, uintptr) | |
| 307 | + | ||
| 308 | + | // Creates a new animation by asynchronously loading an image from an input stream. | |
| 309 | + | // | |
| 310 | + | // For more details see gdk_pixbuf_new_from_stream(), which is the synchronous | |
| 311 | + | // version of this function. | |
| 312 | + | // | |
| 313 | + | // When the operation is finished, `callback` will be called in the main thread. | |
| 314 | + | // You can then call gdk_pixbuf_animation_new_from_stream_finish() to get the | |
| 315 | + | // result of the operation. | |
| 316 | + | func PixbufAnimationNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 317 | + | ||
| 318 | + | xPixbufAnimationNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 319 | + | ||
| 320 | + | } | |
| 321 | + | ||
| 296 | 322 | // An opaque object representing an iterator which points to a | |
| 297 | 323 | // certain position in an animation. | |
| 298 | 324 | type PixbufAnimationIter struct { | |
| @@ -423,6 +449,8 @@ func init() { | |||
| 423 | 449 | core.PuregoSafeRegister(&xPixbufAnimationRef, lib, "gdk_pixbuf_animation_ref") | |
| 424 | 450 | core.PuregoSafeRegister(&xPixbufAnimationUnref, lib, "gdk_pixbuf_animation_unref") | |
| 425 | 451 | ||
| 452 | + | core.PuregoSafeRegister(&xPixbufAnimationNewFromStreamAsync, lib, "gdk_pixbuf_animation_new_from_stream_async") | |
| 453 | + | ||
| 426 | 454 | core.PuregoSafeRegister(&xPixbufAnimationIterAdvance, lib, "gdk_pixbuf_animation_iter_advance") | |
| 427 | 455 | core.PuregoSafeRegister(&xPixbufAnimationIterGetDelayTime, lib, "gdk_pixbuf_animation_iter_get_delay_time") | |
| 428 | 456 | core.PuregoSafeRegister(&xPixbufAnimationIterGetPixbuf, lib, "gdk_pixbuf_animation_iter_get_pixbuf") | |
M v4/gdkpixbuf/gdk-pixbuf-io.go +165 -0
| @@ -2,6 +2,10 @@ | |||
| 2 | 2 | package gdkpixbuf | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 5 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 6 | 10 | "github.com/jwijenbergh/puregotk/v4/gmodule" | |
| 7 | 11 | ) | |
| @@ -119,6 +123,138 @@ type PixbufFormat struct { | |||
| 119 | 123 | License uintptr | |
| 120 | 124 | } | |
| 121 | 125 | ||
| 126 | + | func (x *PixbufFormat) GoPointer() uintptr { | |
| 127 | + | return uintptr(unsafe.Pointer(x)) | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | var xPixbufFormatCopy func(uintptr) *PixbufFormat | |
| 131 | + | ||
| 132 | + | // Creates a copy of `format`. | |
| 133 | + | func (x *PixbufFormat) Copy() *PixbufFormat { | |
| 134 | + | ||
| 135 | + | cret := xPixbufFormatCopy(x.GoPointer()) | |
| 136 | + | return cret | |
| 137 | + | } | |
| 138 | + | ||
| 139 | + | var xPixbufFormatFree func(uintptr) | |
| 140 | + | ||
| 141 | + | // Frees the resources allocated when copying a `GdkPixbufFormat` | |
| 142 | + | // using gdk_pixbuf_format_copy() | |
| 143 | + | func (x *PixbufFormat) Free() { | |
| 144 | + | ||
| 145 | + | xPixbufFormatFree(x.GoPointer()) | |
| 146 | + | ||
| 147 | + | } | |
| 148 | + | ||
| 149 | + | var xPixbufFormatGetDescription func(uintptr) string | |
| 150 | + | ||
| 151 | + | // Returns a description of the format. | |
| 152 | + | func (x *PixbufFormat) GetDescription() string { | |
| 153 | + | ||
| 154 | + | cret := xPixbufFormatGetDescription(x.GoPointer()) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xPixbufFormatGetExtensions func(uintptr) uintptr | |
| 159 | + | ||
| 160 | + | // Returns the filename extensions typically used for files in the | |
| 161 | + | // given format. | |
| 162 | + | func (x *PixbufFormat) GetExtensions() uintptr { | |
| 163 | + | ||
| 164 | + | cret := xPixbufFormatGetExtensions(x.GoPointer()) | |
| 165 | + | return cret | |
| 166 | + | } | |
| 167 | + | ||
| 168 | + | var xPixbufFormatGetLicense func(uintptr) string | |
| 169 | + | ||
| 170 | + | // Returns information about the license of the image loader for the format. | |
| 171 | + | // | |
| 172 | + | // The returned string should be a shorthand for a well known license, e.g. | |
| 173 | + | // "LGPL", "GPL", "QPL", "GPL/QPL", or "other" to indicate some other license. | |
| 174 | + | func (x *PixbufFormat) GetLicense() string { | |
| 175 | + | ||
| 176 | + | cret := xPixbufFormatGetLicense(x.GoPointer()) | |
| 177 | + | return cret | |
| 178 | + | } | |
| 179 | + | ||
| 180 | + | var xPixbufFormatGetMimeTypes func(uintptr) uintptr | |
| 181 | + | ||
| 182 | + | // Returns the mime types supported by the format. | |
| 183 | + | func (x *PixbufFormat) GetMimeTypes() uintptr { | |
| 184 | + | ||
| 185 | + | cret := xPixbufFormatGetMimeTypes(x.GoPointer()) | |
| 186 | + | return cret | |
| 187 | + | } | |
| 188 | + | ||
| 189 | + | var xPixbufFormatGetName func(uintptr) string | |
| 190 | + | ||
| 191 | + | // Returns the name of the format. | |
| 192 | + | func (x *PixbufFormat) GetName() string { | |
| 193 | + | ||
| 194 | + | cret := xPixbufFormatGetName(x.GoPointer()) | |
| 195 | + | return cret | |
| 196 | + | } | |
| 197 | + | ||
| 198 | + | var xPixbufFormatIsDisabled func(uintptr) bool | |
| 199 | + | ||
| 200 | + | // Returns whether this image format is disabled. | |
| 201 | + | // | |
| 202 | + | // See gdk_pixbuf_format_set_disabled(). | |
| 203 | + | func (x *PixbufFormat) IsDisabled() bool { | |
| 204 | + | ||
| 205 | + | cret := xPixbufFormatIsDisabled(x.GoPointer()) | |
| 206 | + | return cret | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | var xPixbufFormatIsSaveOptionSupported func(uintptr, string) bool | |
| 210 | + | ||
| 211 | + | // Returns `TRUE` if the save option specified by @option_key is supported when | |
| 212 | + | // saving a pixbuf using the module implementing @format. | |
| 213 | + | // | |
| 214 | + | // See gdk_pixbuf_save() for more information about option keys. | |
| 215 | + | func (x *PixbufFormat) IsSaveOptionSupported(OptionKeyVar string) bool { | |
| 216 | + | ||
| 217 | + | cret := xPixbufFormatIsSaveOptionSupported(x.GoPointer(), OptionKeyVar) | |
| 218 | + | return cret | |
| 219 | + | } | |
| 220 | + | ||
| 221 | + | var xPixbufFormatIsScalable func(uintptr) bool | |
| 222 | + | ||
| 223 | + | // Returns whether this image format is scalable. | |
| 224 | + | // | |
| 225 | + | // If a file is in a scalable format, it is preferable to load it at | |
| 226 | + | // the desired size, rather than loading it at the default size and | |
| 227 | + | // scaling the resulting pixbuf to the desired size. | |
| 228 | + | func (x *PixbufFormat) IsScalable() bool { | |
| 229 | + | ||
| 230 | + | cret := xPixbufFormatIsScalable(x.GoPointer()) | |
| 231 | + | return cret | |
| 232 | + | } | |
| 233 | + | ||
| 234 | + | var xPixbufFormatIsWritable func(uintptr) bool | |
| 235 | + | ||
| 236 | + | // Returns whether pixbufs can be saved in the given format. | |
| 237 | + | func (x *PixbufFormat) IsWritable() bool { | |
| 238 | + | ||
| 239 | + | cret := xPixbufFormatIsWritable(x.GoPointer()) | |
| 240 | + | return cret | |
| 241 | + | } | |
| 242 | + | ||
| 243 | + | var xPixbufFormatSetDisabled func(uintptr, bool) | |
| 244 | + | ||
| 245 | + | // Disables or enables an image format. | |
| 246 | + | // | |
| 247 | + | // If a format is disabled, GdkPixbuf won't use the image loader for | |
| 248 | + | // this format to load images. | |
| 249 | + | // | |
| 250 | + | // Applications can use this to avoid using image loaders with an | |
| 251 | + | // inappropriate license, see gdk_pixbuf_format_get_license(). | |
| 252 | + | func (x *PixbufFormat) SetDisabled(DisabledVar bool) { | |
| 253 | + | ||
| 254 | + | xPixbufFormatSetDisabled(x.GoPointer(), DisabledVar) | |
| 255 | + | ||
| 256 | + | } | |
| 257 | + | ||
| 122 | 258 | // A `GdkPixbufModule` contains the necessary functions to load and save | |
| 123 | 259 | // images in a certain file format. | |
| 124 | 260 | // | |
| @@ -192,6 +328,10 @@ type PixbufModule struct { | |||
| 192 | 328 | IsSaveOptionSupported PixbufModuleSaveOptionSupportedFunc | |
| 193 | 329 | } | |
| 194 | 330 | ||
| 331 | + | func (x *PixbufModule) GoPointer() uintptr { | |
| 332 | + | return uintptr(unsafe.Pointer(x)) | |
| 333 | + | } | |
| 334 | + | ||
| 195 | 335 | // The signature prefix for a module. | |
| 196 | 336 | // | |
| 197 | 337 | // The signature of a module is a set of prefixes. Prefixes are encoded as | |
| @@ -232,6 +372,10 @@ type PixbufModulePattern struct { | |||
| 232 | 372 | Relevance int | |
| 233 | 373 | } | |
| 234 | 374 | ||
| 375 | + | func (x *PixbufModulePattern) GoPointer() uintptr { | |
| 376 | + | return uintptr(unsafe.Pointer(x)) | |
| 377 | + | } | |
| 378 | + | ||
| 235 | 379 | // Flags which allow a module to specify further details about the supported | |
| 236 | 380 | // operations. | |
| 237 | 381 | type PixbufFormatFlags int | |
| @@ -246,3 +390,24 @@ const ( | |||
| 246 | 390 | // ignores modules that are not marked as threadsafe. (Since 2.28). | |
| 247 | 391 | GdkPixbufFormatThreadsafeValue PixbufFormatFlags = 4 | |
| 248 | 392 | ) | |
| 393 | + | ||
| 394 | + | func init() { | |
| 395 | + | lib, err := purego.Dlopen(core.GetPath("GDKPIXBUF"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 396 | + | if err != nil { | |
| 397 | + | panic(err) | |
| 398 | + | } | |
| 399 | + | ||
| 400 | + | core.PuregoSafeRegister(&xPixbufFormatCopy, lib, "gdk_pixbuf_format_copy") | |
| 401 | + | core.PuregoSafeRegister(&xPixbufFormatFree, lib, "gdk_pixbuf_format_free") | |
| 402 | + | core.PuregoSafeRegister(&xPixbufFormatGetDescription, lib, "gdk_pixbuf_format_get_description") | |
| 403 | + | core.PuregoSafeRegister(&xPixbufFormatGetExtensions, lib, "gdk_pixbuf_format_get_extensions") | |
| 404 | + | core.PuregoSafeRegister(&xPixbufFormatGetLicense, lib, "gdk_pixbuf_format_get_license") | |
| 405 | + | core.PuregoSafeRegister(&xPixbufFormatGetMimeTypes, lib, "gdk_pixbuf_format_get_mime_types") | |
| 406 | + | core.PuregoSafeRegister(&xPixbufFormatGetName, lib, "gdk_pixbuf_format_get_name") | |
| 407 | + | core.PuregoSafeRegister(&xPixbufFormatIsDisabled, lib, "gdk_pixbuf_format_is_disabled") | |
| 408 | + | core.PuregoSafeRegister(&xPixbufFormatIsSaveOptionSupported, lib, "gdk_pixbuf_format_is_save_option_supported") | |
| 409 | + | core.PuregoSafeRegister(&xPixbufFormatIsScalable, lib, "gdk_pixbuf_format_is_scalable") | |
| 410 | + | core.PuregoSafeRegister(&xPixbufFormatIsWritable, lib, "gdk_pixbuf_format_is_writable") | |
| 411 | + | core.PuregoSafeRegister(&xPixbufFormatSetDisabled, lib, "gdk_pixbuf_format_set_disabled") | |
| 412 | + | ||
| 413 | + | } | |
M v4/gdkpixbuf/gdk-pixbuf-loader.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdkpixbuf | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type PixbufLoaderClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *PixbufLoaderClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Incremental image loader. | |
| 16 | 22 | // | |
| 17 | 23 | // `GdkPixbufLoader` provides a way for applications to drive the | |
M v4/gdkpixbuf/gdk-pixbuf-simple-anim.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdkpixbuf | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -9,6 +11,10 @@ import ( | |||
| 9 | 11 | type PixbufSimpleAnimClass struct { | |
| 10 | 12 | } | |
| 11 | 13 | ||
| 14 | + | func (x *PixbufSimpleAnimClass) GoPointer() uintptr { | |
| 15 | + | return uintptr(unsafe.Pointer(x)) | |
| 16 | + | } | |
| 17 | + | ||
| 12 | 18 | // An opaque struct representing a simple animation. | |
| 13 | 19 | type PixbufSimpleAnim struct { | |
| 14 | 20 | PixbufAnimation | |
M v4/gdkpixbuf/gdk-pixbuf.go +146 -0
| @@ -1428,6 +1428,142 @@ func (x *Pixbuf) LoadFinish(ResVar gio.AsyncResult, TypeVar string) (*gio.InputS | |||
| 1428 | 1428 | ||
| 1429 | 1429 | } | |
| 1430 | 1430 | ||
| 1431 | + | var xPixbufCalculateRowstride func(Colorspace, bool, int, int, int) int | |
| 1432 | + | ||
| 1433 | + | // Calculates the rowstride that an image created with those values would | |
| 1434 | + | // have. | |
| 1435 | + | // | |
| 1436 | + | // This function is useful for front-ends and backends that want to check | |
| 1437 | + | // image values without needing to create a `GdkPixbuf`. | |
| 1438 | + | func PixbufCalculateRowstride(ColorspaceVar Colorspace, HasAlphaVar bool, BitsPerSampleVar int, WidthVar int, HeightVar int) int { | |
| 1439 | + | ||
| 1440 | + | cret := xPixbufCalculateRowstride(ColorspaceVar, HasAlphaVar, BitsPerSampleVar, WidthVar, HeightVar) | |
| 1441 | + | return cret | |
| 1442 | + | } | |
| 1443 | + | ||
| 1444 | + | var xPixbufGetFileInfo func(string, int, int) *PixbufFormat | |
| 1445 | + | ||
| 1446 | + | // Parses an image file far enough to determine its format and size. | |
| 1447 | + | func PixbufGetFileInfo(FilenameVar string, WidthVar int, HeightVar int) *PixbufFormat { | |
| 1448 | + | ||
| 1449 | + | cret := xPixbufGetFileInfo(FilenameVar, WidthVar, HeightVar) | |
| 1450 | + | return cret | |
| 1451 | + | } | |
| 1452 | + | ||
| 1453 | + | var xPixbufGetFileInfoAsync func(string, uintptr, uintptr, uintptr) | |
| 1454 | + | ||
| 1455 | + | // Asynchronously parses an image file far enough to determine its | |
| 1456 | + | // format and size. | |
| 1457 | + | // | |
| 1458 | + | // For more details see gdk_pixbuf_get_file_info(), which is the synchronous | |
| 1459 | + | // version of this function. | |
| 1460 | + | // | |
| 1461 | + | // When the operation is finished, @callback will be called in the | |
| 1462 | + | // main thread. You can then call gdk_pixbuf_get_file_info_finish() to | |
| 1463 | + | // get the result of the operation. | |
| 1464 | + | func PixbufGetFileInfoAsync(FilenameVar string, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1465 | + | ||
| 1466 | + | xPixbufGetFileInfoAsync(FilenameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1467 | + | ||
| 1468 | + | } | |
| 1469 | + | ||
| 1470 | + | var xPixbufGetFileInfoFinish func(uintptr, int, int, **glib.Error) *PixbufFormat | |
| 1471 | + | ||
| 1472 | + | // Finishes an asynchronous pixbuf parsing operation started with | |
| 1473 | + | // gdk_pixbuf_get_file_info_async(). | |
| 1474 | + | func PixbufGetFileInfoFinish(AsyncResultVar gio.AsyncResult, WidthVar int, HeightVar int) (*PixbufFormat, error) { | |
| 1475 | + | var cerr *glib.Error | |
| 1476 | + | ||
| 1477 | + | cret := xPixbufGetFileInfoFinish(AsyncResultVar.GoPointer(), WidthVar, HeightVar, &cerr) | |
| 1478 | + | if cerr == nil { | |
| 1479 | + | return cret, nil | |
| 1480 | + | } | |
| 1481 | + | return cret, cerr | |
| 1482 | + | ||
| 1483 | + | } | |
| 1484 | + | ||
| 1485 | + | var xPixbufGetFormats func() *glib.SList | |
| 1486 | + | ||
| 1487 | + | // Obtains the available information about the image formats supported | |
| 1488 | + | // by GdkPixbuf. | |
| 1489 | + | func PixbufGetFormats() *glib.SList { | |
| 1490 | + | ||
| 1491 | + | cret := xPixbufGetFormats() | |
| 1492 | + | return cret | |
| 1493 | + | } | |
| 1494 | + | ||
| 1495 | + | var xPixbufInitModules func(string, **glib.Error) bool | |
| 1496 | + | ||
| 1497 | + | // Initalizes the gdk-pixbuf loader modules referenced by the `loaders.cache` | |
| 1498 | + | // file present inside that directory. | |
| 1499 | + | // | |
| 1500 | + | // This is to be used by applications that want to ship certain loaders | |
| 1501 | + | // in a different location from the system ones. | |
| 1502 | + | // | |
| 1503 | + | // This is needed when the OS or runtime ships a minimal number of loaders | |
| 1504 | + | // so as to reduce the potential attack surface of carefully crafted image | |
| 1505 | + | // files, especially for uncommon file types. Applications that require | |
| 1506 | + | // broader image file types coverage, such as image viewers, would be | |
| 1507 | + | // expected to ship the gdk-pixbuf modules in a separate location, bundled | |
| 1508 | + | // with the application in a separate directory from the OS or runtime- | |
| 1509 | + | // provided modules. | |
| 1510 | + | func PixbufInitModules(PathVar string) (bool, error) { | |
| 1511 | + | var cerr *glib.Error | |
| 1512 | + | ||
| 1513 | + | cret := xPixbufInitModules(PathVar, &cerr) | |
| 1514 | + | if cerr == nil { | |
| 1515 | + | return cret, nil | |
| 1516 | + | } | |
| 1517 | + | return cret, cerr | |
| 1518 | + | ||
| 1519 | + | } | |
| 1520 | + | ||
| 1521 | + | var xPixbufNewFromStreamAsync func(uintptr, uintptr, uintptr, uintptr) | |
| 1522 | + | ||
| 1523 | + | // Creates a new pixbuf by asynchronously loading an image from an input stream. | |
| 1524 | + | // | |
| 1525 | + | // For more details see gdk_pixbuf_new_from_stream(), which is the synchronous | |
| 1526 | + | // version of this function. | |
| 1527 | + | // | |
| 1528 | + | // When the operation is finished, @callback will be called in the main thread. | |
| 1529 | + | // You can then call gdk_pixbuf_new_from_stream_finish() to get the result of | |
| 1530 | + | // the operation. | |
| 1531 | + | func PixbufNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1532 | + | ||
| 1533 | + | xPixbufNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1534 | + | ||
| 1535 | + | } | |
| 1536 | + | ||
| 1537 | + | var xPixbufNewFromStreamAtScaleAsync func(uintptr, int, int, bool, uintptr, uintptr, uintptr) | |
| 1538 | + | ||
| 1539 | + | // Creates a new pixbuf by asynchronously loading an image from an input stream. | |
| 1540 | + | // | |
| 1541 | + | // For more details see gdk_pixbuf_new_from_stream_at_scale(), which is the synchronous | |
| 1542 | + | // version of this function. | |
| 1543 | + | // | |
| 1544 | + | // When the operation is finished, @callback will be called in the main thread. | |
| 1545 | + | // You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation. | |
| 1546 | + | func PixbufNewFromStreamAtScaleAsync(StreamVar *gio.InputStream, WidthVar int, HeightVar int, PreserveAspectRatioVar bool, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1547 | + | ||
| 1548 | + | xPixbufNewFromStreamAtScaleAsync(StreamVar.GoPointer(), WidthVar, HeightVar, PreserveAspectRatioVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1549 | + | ||
| 1550 | + | } | |
| 1551 | + | ||
| 1552 | + | var xPixbufSaveToStreamFinish func(uintptr, **glib.Error) bool | |
| 1553 | + | ||
| 1554 | + | // Finishes an asynchronous pixbuf save operation started with | |
| 1555 | + | // gdk_pixbuf_save_to_stream_async(). | |
| 1556 | + | func PixbufSaveToStreamFinish(AsyncResultVar gio.AsyncResult) (bool, error) { | |
| 1557 | + | var cerr *glib.Error | |
| 1558 | + | ||
| 1559 | + | cret := xPixbufSaveToStreamFinish(AsyncResultVar.GoPointer(), &cerr) | |
| 1560 | + | if cerr == nil { | |
| 1561 | + | return cret, nil | |
| 1562 | + | } | |
| 1563 | + | return cret, cerr | |
| 1564 | + | ||
| 1565 | + | } | |
| 1566 | + | ||
| 1431 | 1567 | func init() { | |
| 1432 | 1568 | lib, err := purego.Dlopen(core.GetPath("GDKPIXBUF"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 1433 | 1569 | if err != nil { | |
| @@ -1492,4 +1628,14 @@ func init() { | |||
| 1492 | 1628 | core.PuregoSafeRegister(&xPixbufSetOption, lib, "gdk_pixbuf_set_option") | |
| 1493 | 1629 | core.PuregoSafeRegister(&xPixbufUnref, lib, "gdk_pixbuf_unref") | |
| 1494 | 1630 | ||
| 1631 | + | core.PuregoSafeRegister(&xPixbufCalculateRowstride, lib, "gdk_pixbuf_calculate_rowstride") | |
| 1632 | + | core.PuregoSafeRegister(&xPixbufGetFileInfo, lib, "gdk_pixbuf_get_file_info") | |
| 1633 | + | core.PuregoSafeRegister(&xPixbufGetFileInfoAsync, lib, "gdk_pixbuf_get_file_info_async") | |
| 1634 | + | core.PuregoSafeRegister(&xPixbufGetFileInfoFinish, lib, "gdk_pixbuf_get_file_info_finish") | |
| 1635 | + | core.PuregoSafeRegister(&xPixbufGetFormats, lib, "gdk_pixbuf_get_formats") | |
| 1636 | + | core.PuregoSafeRegister(&xPixbufInitModules, lib, "gdk_pixbuf_init_modules") | |
| 1637 | + | core.PuregoSafeRegister(&xPixbufNewFromStreamAsync, lib, "gdk_pixbuf_new_from_stream_async") | |
| 1638 | + | core.PuregoSafeRegister(&xPixbufNewFromStreamAtScaleAsync, lib, "gdk_pixbuf_new_from_stream_at_scale_async") | |
| 1639 | + | core.PuregoSafeRegister(&xPixbufSaveToStreamFinish, lib, "gdk_pixbuf_save_to_stream_finish") | |
| 1640 | + | ||
| 1495 | 1641 | } | |
M v4/gio/gaction.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ActionInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ActionInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GAction represents a single named action. | |
| 16 | 22 | // | |
| 17 | 23 | // The main interface to an action is that it can be activated with | |
M v4/gio/gactiongroup.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ActionGroupInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ActionGroupInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GActionGroup represents a group of actions. Actions can be used to | |
| 16 | 22 | // expose functionality in a structured way, either from one part of a | |
| 17 | 23 | // program to another, or to the outside world. Action groups are often | |
M v4/gio/gactionmap.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -27,11 +29,19 @@ type ActionEntry struct { | |||
| 27 | 29 | Padding uintptr | |
| 28 | 30 | } | |
| 29 | 31 | ||
| 32 | + | func (x *ActionEntry) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 30 | 36 | // The virtual function table for #GActionMap. | |
| 31 | 37 | type ActionMapInterface struct { | |
| 32 | 38 | GIface uintptr | |
| 33 | 39 | } | |
| 34 | 40 | ||
| 41 | + | func (x *ActionMapInterface) GoPointer() uintptr { | |
| 42 | + | return uintptr(unsafe.Pointer(x)) | |
| 43 | + | } | |
| 44 | + | ||
| 35 | 45 | // The GActionMap interface is implemented by #GActionGroup | |
| 36 | 46 | // implementations that operate by containing a number of | |
| 37 | 47 | // named #GAction instances, such as #GSimpleActionGroup. | |
M v4/gio/gappinfo.go +14 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,13 +15,25 @@ type AppInfoIface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *AppInfoIface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | type AppLaunchContextClass struct { | |
| 17 | 23 | ParentClass uintptr | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *AppLaunchContextClass) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | type AppLaunchContextPrivate struct { | |
| 21 | 31 | } | |
| 22 | 32 | ||
| 33 | + | func (x *AppLaunchContextPrivate) GoPointer() uintptr { | |
| 34 | + | return uintptr(unsafe.Pointer(x)) | |
| 35 | + | } | |
| 36 | + | ||
| 23 | 37 | // #GAppInfo and #GAppLaunchContext are used for describing and launching | |
| 24 | 38 | // applications installed on the system. | |
| 25 | 39 | // | |
M v4/gio/gapplication.go +89 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type ApplicationClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *ApplicationClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type ApplicationPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *ApplicationPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // A #GApplication is the foundation of an application. It wraps some | |
| 22 | 32 | // low-level platform-specific services and is intended to act as the | |
| 23 | 33 | // foundation for higher-level application classes such as | |
| @@ -1347,6 +1357,82 @@ func (x *Application) RemoveAction(ActionNameVar string) { | |||
| 1347 | 1357 | ||
| 1348 | 1358 | } | |
| 1349 | 1359 | ||
| 1360 | + | var xApplicationGetDefault func() uintptr | |
| 1361 | + | ||
| 1362 | + | // Returns the default #GApplication instance for this process. | |
| 1363 | + | // | |
| 1364 | + | // Normally there is only one #GApplication per process and it becomes | |
| 1365 | + | // the default when it is created. You can exercise more control over | |
| 1366 | + | // this by using g_application_set_default(). | |
| 1367 | + | // | |
| 1368 | + | // If there is no default application then %NULL is returned. | |
| 1369 | + | func ApplicationGetDefault() *Application { | |
| 1370 | + | var cls *Application | |
| 1371 | + | ||
| 1372 | + | cret := xApplicationGetDefault() | |
| 1373 | + | ||
| 1374 | + | if cret == 0 { | |
| 1375 | + | return nil | |
| 1376 | + | } | |
| 1377 | + | gobject.IncreaseRef(cret) | |
| 1378 | + | cls = &Application{} | |
| 1379 | + | cls.Ptr = cret | |
| 1380 | + | return cls | |
| 1381 | + | } | |
| 1382 | + | ||
| 1383 | + | var xApplicationIdIsValid func(string) bool | |
| 1384 | + | ||
| 1385 | + | // Checks if @application_id is a valid application identifier. | |
| 1386 | + | // | |
| 1387 | + | // A valid ID is required for calls to g_application_new() and | |
| 1388 | + | // g_application_set_application_id(). | |
| 1389 | + | // | |
| 1390 | + | // Application identifiers follow the same format as | |
| 1391 | + | // [D-Bus well-known bus names](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus). | |
| 1392 | + | // For convenience, the restrictions on application identifiers are | |
| 1393 | + | // reproduced here: | |
| 1394 | + | // | |
| 1395 | + | // - Application identifiers are composed of 1 or more elements separated by a | |
| 1396 | + | // period (`.`) character. All elements must contain at least one character. | |
| 1397 | + | // | |
| 1398 | + | // - Each element must only contain the ASCII characters `[A-Z][a-z][0-9]_-`, | |
| 1399 | + | // with `-` discouraged in new application identifiers. Each element must not | |
| 1400 | + | // begin with a digit. | |
| 1401 | + | // | |
| 1402 | + | // - Application identifiers must contain at least one `.` (period) character | |
| 1403 | + | // (and thus at least two elements). | |
| 1404 | + | // | |
| 1405 | + | // - Application identifiers must not begin with a `.` (period) character. | |
| 1406 | + | // | |
| 1407 | + | // - Application identifiers must not exceed 255 characters. | |
| 1408 | + | // | |
| 1409 | + | // Note that the hyphen (`-`) character is allowed in application identifiers, | |
| 1410 | + | // but is problematic or not allowed in various specifications and APIs that | |
| 1411 | + | // refer to D-Bus, such as | |
| 1412 | + | // [Flatpak application IDs](http://docs.flatpak.org/en/latest/introduction.html#identifiers), | |
| 1413 | + | // the | |
| 1414 | + | // [`DBusActivatable` interface in the Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus), | |
| 1415 | + | // and the convention that an application's "main" interface and object path | |
| 1416 | + | // resemble its application identifier and bus name. To avoid situations that | |
| 1417 | + | // require special-case handling, it is recommended that new application | |
| 1418 | + | // identifiers consistently replace hyphens with underscores. | |
| 1419 | + | // | |
| 1420 | + | // Like D-Bus interface names, application identifiers should start with the | |
| 1421 | + | // reversed DNS domain name of the author of the interface (in lower-case), and | |
| 1422 | + | // it is conventional for the rest of the application identifier to consist of | |
| 1423 | + | // words run together, with initial capital letters. | |
| 1424 | + | // | |
| 1425 | + | // As with D-Bus interface names, if the author's DNS domain name contains | |
| 1426 | + | // hyphen/minus characters they should be replaced by underscores, and if it | |
| 1427 | + | // contains leading digits they should be escaped by prepending an underscore. | |
| 1428 | + | // For example, if the owner of 7-zip.org used an application identifier for an | |
| 1429 | + | // archiving application, it might be named `org._7_zip.Archiver`. | |
| 1430 | + | func ApplicationIdIsValid(ApplicationIdVar string) bool { | |
| 1431 | + | ||
| 1432 | + | cret := xApplicationIdIsValid(ApplicationIdVar) | |
| 1433 | + | return cret | |
| 1434 | + | } | |
| 1435 | + | ||
| 1350 | 1436 | func init() { | |
| 1351 | 1437 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 1352 | 1438 | if err != nil { | |
| @@ -1390,4 +1476,7 @@ func init() { | |||
| 1390 | 1476 | core.PuregoSafeRegister(&xApplicationUnmarkBusy, lib, "g_application_unmark_busy") | |
| 1391 | 1477 | core.PuregoSafeRegister(&xApplicationWithdrawNotification, lib, "g_application_withdraw_notification") | |
| 1392 | 1478 | ||
| 1479 | + | core.PuregoSafeRegister(&xApplicationGetDefault, lib, "g_application_get_default") | |
| 1480 | + | core.PuregoSafeRegister(&xApplicationIdIsValid, lib, "g_application_id_is_valid") | |
| 1481 | + | ||
| 1393 | 1482 | } | |
M v4/gio/gapplicationcommandline.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -16,9 +18,17 @@ type ApplicationCommandLineClass struct { | |||
| 16 | 18 | Padding uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *ApplicationCommandLineClass) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | type ApplicationCommandLinePrivate struct { | |
| 20 | 26 | } | |
| 21 | 27 | ||
| 28 | + | func (x *ApplicationCommandLinePrivate) GoPointer() uintptr { | |
| 29 | + | return uintptr(unsafe.Pointer(x)) | |
| 30 | + | } | |
| 31 | + | ||
| 22 | 32 | // #GApplicationCommandLine represents a command-line invocation of | |
| 23 | 33 | // an application. It is created by #GApplication and emitted | |
| 24 | 34 | // in the #GApplication::command-line signal and virtual function. | |
M v4/gio/gasyncinitable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type AsyncInitableIface struct { | |||
| 14 | 16 | GIface uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *AsyncInitableIface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // This is the asynchronous version of #GInitable; it behaves the same | |
| 18 | 24 | // in all ways except that initialization is asynchronous. For more details | |
| 19 | 25 | // see the descriptions on #GInitable. | |
M v4/gio/gasyncresult.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type AsyncResultIface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *AsyncResultIface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // Provides a base class for implementing asynchronous function results. | |
| 17 | 23 | // | |
| 18 | 24 | // Asynchronous operations are broken up into two separate operations | |
M v4/gio/gbufferedinputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type BufferedInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *BufferedInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type BufferedInputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *BufferedInputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Buffered input stream implements #GFilterInputStream and provides | |
| 18 | 28 | // for buffered reads. | |
| 19 | 29 | // | |
M v4/gio/gbufferedoutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type BufferedOutputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *BufferedOutputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type BufferedOutputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *BufferedOutputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Buffered output stream implements #GFilterOutputStream and provides | |
| 18 | 28 | // for buffered writes. | |
| 19 | 29 | // | |
M v4/gio/gcancellable.go +29 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type CancellableClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *CancellableClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type CancellablePrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *CancellablePrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // GCancellable is a thread-safe operation cancellation stack used | |
| 19 | 29 | // throughout GIO to allow for cancellation of synchronous and | |
| 20 | 30 | // asynchronous operations. | |
| @@ -345,6 +355,23 @@ func (x *Cancellable) ConnectCancelled(cb func(Cancellable)) uint32 { | |||
| 345 | 355 | return gobject.SignalConnect(x.GoPointer(), "cancelled", purego.NewCallback(fcb)) | |
| 346 | 356 | } | |
| 347 | 357 | ||
| 358 | + | var xCancellableGetCurrent func() uintptr | |
| 359 | + | ||
| 360 | + | // Gets the top cancellable from the stack. | |
| 361 | + | func CancellableGetCurrent() *Cancellable { | |
| 362 | + | var cls *Cancellable | |
| 363 | + | ||
| 364 | + | cret := xCancellableGetCurrent() | |
| 365 | + | ||
| 366 | + | if cret == 0 { | |
| 367 | + | return nil | |
| 368 | + | } | |
| 369 | + | gobject.IncreaseRef(cret) | |
| 370 | + | cls = &Cancellable{} | |
| 371 | + | cls.Ptr = cret | |
| 372 | + | return cls | |
| 373 | + | } | |
| 374 | + | ||
| 348 | 375 | func init() { | |
| 349 | 376 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 350 | 377 | if err != nil { | |
| @@ -366,4 +393,6 @@ func init() { | |||
| 366 | 393 | core.PuregoSafeRegister(&xCancellableSetErrorIfCancelled, lib, "g_cancellable_set_error_if_cancelled") | |
| 367 | 394 | core.PuregoSafeRegister(&xCancellableSourceNew, lib, "g_cancellable_source_new") | |
| 368 | 395 | ||
| 396 | + | core.PuregoSafeRegister(&xCancellableGetCurrent, lib, "g_cancellable_get_current") | |
| 397 | + | ||
| 369 | 398 | } | |
M v4/gio/gcharsetconverter.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type CharsetConverterClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *CharsetConverterClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GCharsetConverter is an implementation of #GConverter based on | |
| 16 | 22 | // GIConv. | |
| 17 | 23 | type CharsetConverter struct { | |
M v4/gio/gconverter.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type ConverterIface struct { | |||
| 14 | 16 | GIface uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *ConverterIface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // #GConverter is implemented by objects that convert | |
| 18 | 24 | // binary data in various ways. The conversion can be | |
| 19 | 25 | // stateful and may fail at any place. | |
M v4/gio/gconverterinputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type ConverterInputStreamClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ConverterInputStreamClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type ConverterInputStreamPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *ConverterInputStreamPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // Converter input stream implements #GInputStream and allows | |
| 19 | 29 | // conversion of data of various types during reading. | |
| 20 | 30 | // | |
M v4/gio/gconverteroutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type ConverterOutputStreamClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ConverterOutputStreamClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type ConverterOutputStreamPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *ConverterOutputStreamPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // Converter output stream implements #GOutputStream and allows | |
| 19 | 29 | // conversion of data of various types during reading. | |
| 20 | 30 | // | |
M v4/gio/gcredentials.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ import ( | |||
| 12 | 14 | type CredentialsClass struct { | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *CredentialsClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GCredentials type is a reference-counted wrapper for native | |
| 16 | 22 | // credentials. This information is typically used for identifying, | |
| 17 | 23 | // authenticating and authorizing other processes. | |
M v4/gio/gdatagrambased.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -16,6 +18,10 @@ type DatagramBasedInterface struct { | |||
| 16 | 18 | GIface uintptr | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *DatagramBasedInterface) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 19 | 25 | // A #GDatagramBased is a networking interface for representing datagram-based | |
| 20 | 26 | // communications. It is a more or less direct mapping of the core parts of the | |
| 21 | 27 | // BSD socket API in a portable GObject interface. It is implemented by | |
M v4/gio/gdatainputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type DataInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *DataInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type DataInputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *DataInputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Data input stream implements #GInputStream and includes functions for | |
| 18 | 28 | // reading structured data directly from a binary input stream. | |
| 19 | 29 | type DataInputStream struct { | |
M v4/gio/gdataoutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type DataOutputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *DataOutputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type DataOutputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *DataOutputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Data output stream implements #GOutputStream and includes functions for | |
| 18 | 28 | // writing data directly to an output stream. | |
| 19 | 29 | type DataOutputStream struct { | |
M v4/gio/gdbusconnection.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -179,6 +181,10 @@ type DBusInterfaceVTable struct { | |||
| 179 | 181 | Padding uintptr | |
| 180 | 182 | } | |
| 181 | 183 | ||
| 184 | + | func (x *DBusInterfaceVTable) GoPointer() uintptr { | |
| 185 | + | return uintptr(unsafe.Pointer(x)) | |
| 186 | + | } | |
| 187 | + | ||
| 182 | 188 | // Virtual table for handling subtrees registered with g_dbus_connection_register_subtree(). | |
| 183 | 189 | type DBusSubtreeVTable struct { | |
| 184 | 190 | Enumerate DBusSubtreeEnumerateFunc | |
| @@ -190,6 +196,10 @@ type DBusSubtreeVTable struct { | |||
| 190 | 196 | Padding uintptr | |
| 191 | 197 | } | |
| 192 | 198 | ||
| 199 | + | func (x *DBusSubtreeVTable) GoPointer() uintptr { | |
| 200 | + | return uintptr(unsafe.Pointer(x)) | |
| 201 | + | } | |
| 202 | + | ||
| 193 | 203 | var xBusGet func(BusType, uintptr, uintptr, uintptr) | |
| 194 | 204 | ||
| 195 | 205 | // Asynchronously connects to the message bus specified by @bus_type. | |
M v4/gio/gdbuserror.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type DBusErrorEntry struct { | |||
| 14 | 16 | DbusErrorName uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *DBusErrorEntry) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | var xDbusErrorEncodeGerror func(*glib.Error) string | |
| 18 | 24 | ||
| 19 | 25 | // Creates a D-Bus error name to use for @error. If @error matches | |
M v4/gio/gdbusinterface.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type DBusInterfaceIface struct { | |||
| 12 | 14 | ParentIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *DBusInterfaceIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GDBusInterface type is the base type for D-Bus interfaces both | |
| 16 | 22 | // on the service side (see #GDBusInterfaceSkeleton) and client side | |
| 17 | 23 | // (see #GDBusProxy). | |
M v4/gio/gdbusinterfaceskeleton.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -17,9 +19,17 @@ type DBusInterfaceSkeletonClass struct { | |||
| 17 | 19 | SignalPadding uintptr | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *DBusInterfaceSkeletonClass) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 20 | 26 | type DBusInterfaceSkeletonPrivate struct { | |
| 21 | 27 | } | |
| 22 | 28 | ||
| 29 | + | func (x *DBusInterfaceSkeletonPrivate) GoPointer() uintptr { | |
| 30 | + | return uintptr(unsafe.Pointer(x)) | |
| 31 | + | } | |
| 32 | + | ||
| 23 | 33 | // Abstract base class for D-Bus interfaces on the service side. | |
| 24 | 34 | type DBusInterfaceSkeleton struct { | |
| 25 | 35 | gobject.Object | |
M v4/gio/gdbusintrospection.go +332 -0
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | ) | |
| 8 | 11 | ||
| 9 | 12 | // Information about an annotation. | |
| @@ -17,6 +20,31 @@ type DBusAnnotationInfo struct { | |||
| 17 | 20 | Annotations uintptr | |
| 18 | 21 | } | |
| 19 | 22 | ||
| 23 | + | func (x *DBusAnnotationInfo) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | var xDBusAnnotationInfoRef func(uintptr) *DBusAnnotationInfo | |
| 28 | + | ||
| 29 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 30 | + | // the reference count. | |
| 31 | + | func (x *DBusAnnotationInfo) Ref() *DBusAnnotationInfo { | |
| 32 | + | ||
| 33 | + | cret := xDBusAnnotationInfoRef(x.GoPointer()) | |
| 34 | + | return cret | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | var xDBusAnnotationInfoUnref func(uintptr) | |
| 38 | + | ||
| 39 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 40 | + | // the reference count of @info. When its reference count drops to 0, | |
| 41 | + | // the memory used is freed. | |
| 42 | + | func (x *DBusAnnotationInfo) Unref() { | |
| 43 | + | ||
| 44 | + | xDBusAnnotationInfoUnref(x.GoPointer()) | |
| 45 | + | ||
| 46 | + | } | |
| 47 | + | ||
| 20 | 48 | // Information about an argument for a method or a signal. | |
| 21 | 49 | type DBusArgInfo struct { | |
| 22 | 50 | RefCount int32 | |
| @@ -28,6 +56,31 @@ type DBusArgInfo struct { | |||
| 28 | 56 | Annotations uintptr | |
| 29 | 57 | } | |
| 30 | 58 | ||
| 59 | + | func (x *DBusArgInfo) GoPointer() uintptr { | |
| 60 | + | return uintptr(unsafe.Pointer(x)) | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | var xDBusArgInfoRef func(uintptr) *DBusArgInfo | |
| 64 | + | ||
| 65 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 66 | + | // the reference count. | |
| 67 | + | func (x *DBusArgInfo) Ref() *DBusArgInfo { | |
| 68 | + | ||
| 69 | + | cret := xDBusArgInfoRef(x.GoPointer()) | |
| 70 | + | return cret | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xDBusArgInfoUnref func(uintptr) | |
| 74 | + | ||
| 75 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 76 | + | // the reference count of @info. When its reference count drops to 0, | |
| 77 | + | // the memory used is freed. | |
| 78 | + | func (x *DBusArgInfo) Unref() { | |
| 79 | + | ||
| 80 | + | xDBusArgInfoUnref(x.GoPointer()) | |
| 81 | + | ||
| 82 | + | } | |
| 83 | + | ||
| 31 | 84 | // Information about a D-Bus interface. | |
| 32 | 85 | type DBusInterfaceInfo struct { | |
| 33 | 86 | RefCount int32 | |
| @@ -43,6 +96,110 @@ type DBusInterfaceInfo struct { | |||
| 43 | 96 | Annotations uintptr | |
| 44 | 97 | } | |
| 45 | 98 | ||
| 99 | + | func (x *DBusInterfaceInfo) GoPointer() uintptr { | |
| 100 | + | return uintptr(unsafe.Pointer(x)) | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | var xDBusInterfaceInfoCacheBuild func(uintptr) | |
| 104 | + | ||
| 105 | + | // Builds a lookup-cache to speed up | |
| 106 | + | // g_dbus_interface_info_lookup_method(), | |
| 107 | + | // g_dbus_interface_info_lookup_signal() and | |
| 108 | + | // g_dbus_interface_info_lookup_property(). | |
| 109 | + | // | |
| 110 | + | // If this has already been called with @info, the existing cache is | |
| 111 | + | // used and its use count is increased. | |
| 112 | + | // | |
| 113 | + | // Note that @info cannot be modified until | |
| 114 | + | // g_dbus_interface_info_cache_release() is called. | |
| 115 | + | func (x *DBusInterfaceInfo) CacheBuild() { | |
| 116 | + | ||
| 117 | + | xDBusInterfaceInfoCacheBuild(x.GoPointer()) | |
| 118 | + | ||
| 119 | + | } | |
| 120 | + | ||
| 121 | + | var xDBusInterfaceInfoCacheRelease func(uintptr) | |
| 122 | + | ||
| 123 | + | // Decrements the usage count for the cache for @info built by | |
| 124 | + | // g_dbus_interface_info_cache_build() (if any) and frees the | |
| 125 | + | // resources used by the cache if the usage count drops to zero. | |
| 126 | + | func (x *DBusInterfaceInfo) CacheRelease() { | |
| 127 | + | ||
| 128 | + | xDBusInterfaceInfoCacheRelease(x.GoPointer()) | |
| 129 | + | ||
| 130 | + | } | |
| 131 | + | ||
| 132 | + | var xDBusInterfaceInfoGenerateXml func(uintptr, uint, *glib.String) | |
| 133 | + | ||
| 134 | + | // Appends an XML representation of @info (and its children) to @string_builder. | |
| 135 | + | // | |
| 136 | + | // This function is typically used for generating introspection XML | |
| 137 | + | // documents at run-time for handling the | |
| 138 | + | // `org.freedesktop.DBus.Introspectable.Introspect` | |
| 139 | + | // method. | |
| 140 | + | func (x *DBusInterfaceInfo) GenerateXml(IndentVar uint, StringBuilderVar *glib.String) { | |
| 141 | + | ||
| 142 | + | xDBusInterfaceInfoGenerateXml(x.GoPointer(), IndentVar, StringBuilderVar) | |
| 143 | + | ||
| 144 | + | } | |
| 145 | + | ||
| 146 | + | var xDBusInterfaceInfoLookupMethod func(uintptr, string) *DBusMethodInfo | |
| 147 | + | ||
| 148 | + | // Looks up information about a method. | |
| 149 | + | // | |
| 150 | + | // The cost of this function is O(n) in number of methods unless | |
| 151 | + | // g_dbus_interface_info_cache_build() has been used on @info. | |
| 152 | + | func (x *DBusInterfaceInfo) LookupMethod(NameVar string) *DBusMethodInfo { | |
| 153 | + | ||
| 154 | + | cret := xDBusInterfaceInfoLookupMethod(x.GoPointer(), NameVar) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xDBusInterfaceInfoLookupProperty func(uintptr, string) *DBusPropertyInfo | |
| 159 | + | ||
| 160 | + | // Looks up information about a property. | |
| 161 | + | // | |
| 162 | + | // The cost of this function is O(n) in number of properties unless | |
| 163 | + | // g_dbus_interface_info_cache_build() has been used on @info. | |
| 164 | + | func (x *DBusInterfaceInfo) LookupProperty(NameVar string) *DBusPropertyInfo { | |
| 165 | + | ||
| 166 | + | cret := xDBusInterfaceInfoLookupProperty(x.GoPointer(), NameVar) | |
| 167 | + | return cret | |
| 168 | + | } | |
| 169 | + | ||
| 170 | + | var xDBusInterfaceInfoLookupSignal func(uintptr, string) *DBusSignalInfo | |
| 171 | + | ||
| 172 | + | // Looks up information about a signal. | |
| 173 | + | // | |
| 174 | + | // The cost of this function is O(n) in number of signals unless | |
| 175 | + | // g_dbus_interface_info_cache_build() has been used on @info. | |
| 176 | + | func (x *DBusInterfaceInfo) LookupSignal(NameVar string) *DBusSignalInfo { | |
| 177 | + | ||
| 178 | + | cret := xDBusInterfaceInfoLookupSignal(x.GoPointer(), NameVar) | |
| 179 | + | return cret | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | var xDBusInterfaceInfoRef func(uintptr) *DBusInterfaceInfo | |
| 183 | + | ||
| 184 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 185 | + | // the reference count. | |
| 186 | + | func (x *DBusInterfaceInfo) Ref() *DBusInterfaceInfo { | |
| 187 | + | ||
| 188 | + | cret := xDBusInterfaceInfoRef(x.GoPointer()) | |
| 189 | + | return cret | |
| 190 | + | } | |
| 191 | + | ||
| 192 | + | var xDBusInterfaceInfoUnref func(uintptr) | |
| 193 | + | ||
| 194 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 195 | + | // the reference count of @info. When its reference count drops to 0, | |
| 196 | + | // the memory used is freed. | |
| 197 | + | func (x *DBusInterfaceInfo) Unref() { | |
| 198 | + | ||
| 199 | + | xDBusInterfaceInfoUnref(x.GoPointer()) | |
| 200 | + | ||
| 201 | + | } | |
| 202 | + | ||
| 46 | 203 | // Information about a method on an D-Bus interface. | |
| 47 | 204 | type DBusMethodInfo struct { | |
| 48 | 205 | RefCount int32 | |
| @@ -56,6 +213,31 @@ type DBusMethodInfo struct { | |||
| 56 | 213 | Annotations uintptr | |
| 57 | 214 | } | |
| 58 | 215 | ||
| 216 | + | func (x *DBusMethodInfo) GoPointer() uintptr { | |
| 217 | + | return uintptr(unsafe.Pointer(x)) | |
| 218 | + | } | |
| 219 | + | ||
| 220 | + | var xDBusMethodInfoRef func(uintptr) *DBusMethodInfo | |
| 221 | + | ||
| 222 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 223 | + | // the reference count. | |
| 224 | + | func (x *DBusMethodInfo) Ref() *DBusMethodInfo { | |
| 225 | + | ||
| 226 | + | cret := xDBusMethodInfoRef(x.GoPointer()) | |
| 227 | + | return cret | |
| 228 | + | } | |
| 229 | + | ||
| 230 | + | var xDBusMethodInfoUnref func(uintptr) | |
| 231 | + | ||
| 232 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 233 | + | // the reference count of @info. When its reference count drops to 0, | |
| 234 | + | // the memory used is freed. | |
| 235 | + | func (x *DBusMethodInfo) Unref() { | |
| 236 | + | ||
| 237 | + | xDBusMethodInfoUnref(x.GoPointer()) | |
| 238 | + | ||
| 239 | + | } | |
| 240 | + | ||
| 59 | 241 | // Information about nodes in a remote object hierarchy. | |
| 60 | 242 | type DBusNodeInfo struct { | |
| 61 | 243 | RefCount int32 | |
| @@ -69,6 +251,75 @@ type DBusNodeInfo struct { | |||
| 69 | 251 | Annotations uintptr | |
| 70 | 252 | } | |
| 71 | 253 | ||
| 254 | + | func (x *DBusNodeInfo) GoPointer() uintptr { | |
| 255 | + | return uintptr(unsafe.Pointer(x)) | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | var xNewForXmlDBusNodeInfo func(string, **glib.Error) *DBusNodeInfo | |
| 259 | + | ||
| 260 | + | // Parses @xml_data and returns a #GDBusNodeInfo representing the data. | |
| 261 | + | // | |
| 262 | + | // The introspection XML must contain exactly one top-level | |
| 263 | + | // <node> element. | |
| 264 | + | // | |
| 265 | + | // Note that this routine is using a | |
| 266 | + | // [GMarkup][glib-Simple-XML-Subset-Parser.description]-based | |
| 267 | + | // parser that only accepts a subset of valid XML documents. | |
| 268 | + | func NewForXmlDBusNodeInfo(XmlDataVar string) (*DBusNodeInfo, error) { | |
| 269 | + | var cerr *glib.Error | |
| 270 | + | ||
| 271 | + | cret := xNewForXmlDBusNodeInfo(XmlDataVar, &cerr) | |
| 272 | + | if cerr == nil { | |
| 273 | + | return cret, nil | |
| 274 | + | } | |
| 275 | + | return cret, cerr | |
| 276 | + | ||
| 277 | + | } | |
| 278 | + | ||
| 279 | + | var xDBusNodeInfoGenerateXml func(uintptr, uint, *glib.String) | |
| 280 | + | ||
| 281 | + | // Appends an XML representation of @info (and its children) to @string_builder. | |
| 282 | + | // | |
| 283 | + | // This function is typically used for generating introspection XML documents at run-time for | |
| 284 | + | // handling the `org.freedesktop.DBus.Introspectable.Introspect` method. | |
| 285 | + | func (x *DBusNodeInfo) GenerateXml(IndentVar uint, StringBuilderVar *glib.String) { | |
| 286 | + | ||
| 287 | + | xDBusNodeInfoGenerateXml(x.GoPointer(), IndentVar, StringBuilderVar) | |
| 288 | + | ||
| 289 | + | } | |
| 290 | + | ||
| 291 | + | var xDBusNodeInfoLookupInterface func(uintptr, string) *DBusInterfaceInfo | |
| 292 | + | ||
| 293 | + | // Looks up information about an interface. | |
| 294 | + | // | |
| 295 | + | // The cost of this function is O(n) in number of interfaces. | |
| 296 | + | func (x *DBusNodeInfo) LookupInterface(NameVar string) *DBusInterfaceInfo { | |
| 297 | + | ||
| 298 | + | cret := xDBusNodeInfoLookupInterface(x.GoPointer(), NameVar) | |
| 299 | + | return cret | |
| 300 | + | } | |
| 301 | + | ||
| 302 | + | var xDBusNodeInfoRef func(uintptr) *DBusNodeInfo | |
| 303 | + | ||
| 304 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 305 | + | // the reference count. | |
| 306 | + | func (x *DBusNodeInfo) Ref() *DBusNodeInfo { | |
| 307 | + | ||
| 308 | + | cret := xDBusNodeInfoRef(x.GoPointer()) | |
| 309 | + | return cret | |
| 310 | + | } | |
| 311 | + | ||
| 312 | + | var xDBusNodeInfoUnref func(uintptr) | |
| 313 | + | ||
| 314 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 315 | + | // the reference count of @info. When its reference count drops to 0, | |
| 316 | + | // the memory used is freed. | |
| 317 | + | func (x *DBusNodeInfo) Unref() { | |
| 318 | + | ||
| 319 | + | xDBusNodeInfoUnref(x.GoPointer()) | |
| 320 | + | ||
| 321 | + | } | |
| 322 | + | ||
| 72 | 323 | // Information about a D-Bus property on a D-Bus interface. | |
| 73 | 324 | type DBusPropertyInfo struct { | |
| 74 | 325 | RefCount int32 | |
| @@ -82,6 +333,31 @@ type DBusPropertyInfo struct { | |||
| 82 | 333 | Annotations uintptr | |
| 83 | 334 | } | |
| 84 | 335 | ||
| 336 | + | func (x *DBusPropertyInfo) GoPointer() uintptr { | |
| 337 | + | return uintptr(unsafe.Pointer(x)) | |
| 338 | + | } | |
| 339 | + | ||
| 340 | + | var xDBusPropertyInfoRef func(uintptr) *DBusPropertyInfo | |
| 341 | + | ||
| 342 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 343 | + | // the reference count. | |
| 344 | + | func (x *DBusPropertyInfo) Ref() *DBusPropertyInfo { | |
| 345 | + | ||
| 346 | + | cret := xDBusPropertyInfoRef(x.GoPointer()) | |
| 347 | + | return cret | |
| 348 | + | } | |
| 349 | + | ||
| 350 | + | var xDBusPropertyInfoUnref func(uintptr) | |
| 351 | + | ||
| 352 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 353 | + | // the reference count of @info. When its reference count drops to 0, | |
| 354 | + | // the memory used is freed. | |
| 355 | + | func (x *DBusPropertyInfo) Unref() { | |
| 356 | + | ||
| 357 | + | xDBusPropertyInfoUnref(x.GoPointer()) | |
| 358 | + | ||
| 359 | + | } | |
| 360 | + | ||
| 85 | 361 | // Information about a signal on a D-Bus interface. | |
| 86 | 362 | type DBusSignalInfo struct { | |
| 87 | 363 | RefCount int32 | |
| @@ -93,6 +369,31 @@ type DBusSignalInfo struct { | |||
| 93 | 369 | Annotations uintptr | |
| 94 | 370 | } | |
| 95 | 371 | ||
| 372 | + | func (x *DBusSignalInfo) GoPointer() uintptr { | |
| 373 | + | return uintptr(unsafe.Pointer(x)) | |
| 374 | + | } | |
| 375 | + | ||
| 376 | + | var xDBusSignalInfoRef func(uintptr) *DBusSignalInfo | |
| 377 | + | ||
| 378 | + | // If @info is statically allocated does nothing. Otherwise increases | |
| 379 | + | // the reference count. | |
| 380 | + | func (x *DBusSignalInfo) Ref() *DBusSignalInfo { | |
| 381 | + | ||
| 382 | + | cret := xDBusSignalInfoRef(x.GoPointer()) | |
| 383 | + | return cret | |
| 384 | + | } | |
| 385 | + | ||
| 386 | + | var xDBusSignalInfoUnref func(uintptr) | |
| 387 | + | ||
| 388 | + | // If @info is statically allocated, does nothing. Otherwise decreases | |
| 389 | + | // the reference count of @info. When its reference count drops to 0, | |
| 390 | + | // the memory used is freed. | |
| 391 | + | func (x *DBusSignalInfo) Unref() { | |
| 392 | + | ||
| 393 | + | xDBusSignalInfoUnref(x.GoPointer()) | |
| 394 | + | ||
| 395 | + | } | |
| 396 | + | ||
| 96 | 397 | var xDbusAnnotationInfoLookup func(uintptr, string) string | |
| 97 | 398 | ||
| 98 | 399 | // Looks up the value of an annotation. | |
| @@ -111,4 +412,35 @@ func init() { | |||
| 111 | 412 | } | |
| 112 | 413 | core.PuregoSafeRegister(&xDbusAnnotationInfoLookup, lib, "g_dbus_annotation_info_lookup") | |
| 113 | 414 | ||
| 415 | + | core.PuregoSafeRegister(&xDBusAnnotationInfoRef, lib, "g_dbus_annotation_info_ref") | |
| 416 | + | core.PuregoSafeRegister(&xDBusAnnotationInfoUnref, lib, "g_dbus_annotation_info_unref") | |
| 417 | + | ||
| 418 | + | core.PuregoSafeRegister(&xDBusArgInfoRef, lib, "g_dbus_arg_info_ref") | |
| 419 | + | core.PuregoSafeRegister(&xDBusArgInfoUnref, lib, "g_dbus_arg_info_unref") | |
| 420 | + | ||
| 421 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoCacheBuild, lib, "g_dbus_interface_info_cache_build") | |
| 422 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoCacheRelease, lib, "g_dbus_interface_info_cache_release") | |
| 423 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoGenerateXml, lib, "g_dbus_interface_info_generate_xml") | |
| 424 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoLookupMethod, lib, "g_dbus_interface_info_lookup_method") | |
| 425 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoLookupProperty, lib, "g_dbus_interface_info_lookup_property") | |
| 426 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoLookupSignal, lib, "g_dbus_interface_info_lookup_signal") | |
| 427 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoRef, lib, "g_dbus_interface_info_ref") | |
| 428 | + | core.PuregoSafeRegister(&xDBusInterfaceInfoUnref, lib, "g_dbus_interface_info_unref") | |
| 429 | + | ||
| 430 | + | core.PuregoSafeRegister(&xDBusMethodInfoRef, lib, "g_dbus_method_info_ref") | |
| 431 | + | core.PuregoSafeRegister(&xDBusMethodInfoUnref, lib, "g_dbus_method_info_unref") | |
| 432 | + | ||
| 433 | + | core.PuregoSafeRegister(&xNewForXmlDBusNodeInfo, lib, "g_dbus_node_info_new_for_xml") | |
| 434 | + | ||
| 435 | + | core.PuregoSafeRegister(&xDBusNodeInfoGenerateXml, lib, "g_dbus_node_info_generate_xml") | |
| 436 | + | core.PuregoSafeRegister(&xDBusNodeInfoLookupInterface, lib, "g_dbus_node_info_lookup_interface") | |
| 437 | + | core.PuregoSafeRegister(&xDBusNodeInfoRef, lib, "g_dbus_node_info_ref") | |
| 438 | + | core.PuregoSafeRegister(&xDBusNodeInfoUnref, lib, "g_dbus_node_info_unref") | |
| 439 | + | ||
| 440 | + | core.PuregoSafeRegister(&xDBusPropertyInfoRef, lib, "g_dbus_property_info_ref") | |
| 441 | + | core.PuregoSafeRegister(&xDBusPropertyInfoUnref, lib, "g_dbus_property_info_unref") | |
| 442 | + | ||
| 443 | + | core.PuregoSafeRegister(&xDBusSignalInfoRef, lib, "g_dbus_signal_info_ref") | |
| 444 | + | core.PuregoSafeRegister(&xDBusSignalInfoUnref, lib, "g_dbus_signal_info_unref") | |
| 445 | + | ||
| 114 | 446 | } | |
M v4/gio/gdbusobject.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type DBusObjectIface struct { | |||
| 12 | 14 | ParentIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *DBusObjectIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GDBusObject type is the base type for D-Bus objects on both | |
| 16 | 22 | // the service side (see #GDBusObjectSkeleton) and the client side | |
| 17 | 23 | // (see #GDBusObjectProxy). It is essentially just a container of | |
M v4/gio/gdbusobjectmanager.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type DBusObjectManagerIface struct { | |||
| 12 | 14 | ParentIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *DBusObjectManagerIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GDBusObjectManager type is the base type for service- and | |
| 16 | 22 | // client-side implementations of the standardized | |
| 17 | 23 | // [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) | |
M v4/gio/gdbusobjectmanagerclient.go +46 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type DBusObjectManagerClientClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DBusObjectManagerClientClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type DBusObjectManagerClientPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *DBusObjectManagerClientPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // #GDBusObjectManagerClient is used to create, monitor and delete object | |
| 22 | 32 | // proxies for remote objects exported by a #GDBusObjectManagerServer (or any | |
| 23 | 33 | // code implementing the | |
| @@ -460,6 +470,39 @@ func (x *DBusObjectManagerClient) Init(CancellableVar *Cancellable) (bool, error | |||
| 460 | 470 | ||
| 461 | 471 | } | |
| 462 | 472 | ||
| 473 | + | var xDBusObjectManagerClientNew func(uintptr, DBusObjectManagerClientFlags, string, string, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) | |
| 474 | + | ||
| 475 | + | // Asynchronously creates a new #GDBusObjectManagerClient object. | |
| 476 | + | // | |
| 477 | + | // This is an asynchronous failable constructor. When the result is | |
| 478 | + | // ready, @callback will be invoked in the | |
| 479 | + | // [thread-default main context][g-main-context-push-thread-default] | |
| 480 | + | // of the thread you are calling this method from. You can | |
| 481 | + | // then call g_dbus_object_manager_client_new_finish() to get the result. See | |
| 482 | + | // g_dbus_object_manager_client_new_sync() for the synchronous version. | |
| 483 | + | func DBusObjectManagerClientNew(ConnectionVar *DBusConnection, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 484 | + | ||
| 485 | + | xDBusObjectManagerClientNew(ConnectionVar.GoPointer(), FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 486 | + | ||
| 487 | + | } | |
| 488 | + | ||
| 489 | + | var xDBusObjectManagerClientNewForBus func(BusType, DBusObjectManagerClientFlags, string, string, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) | |
| 490 | + | ||
| 491 | + | // Like g_dbus_object_manager_client_new() but takes a #GBusType instead of a | |
| 492 | + | // #GDBusConnection. | |
| 493 | + | // | |
| 494 | + | // This is an asynchronous failable constructor. When the result is | |
| 495 | + | // ready, @callback will be invoked in the | |
| 496 | + | // [thread-default main loop][g-main-context-push-thread-default] | |
| 497 | + | // of the thread you are calling this method from. You can | |
| 498 | + | // then call g_dbus_object_manager_client_new_for_bus_finish() to get the result. See | |
| 499 | + | // g_dbus_object_manager_client_new_for_bus_sync() for the synchronous version. | |
| 500 | + | func DBusObjectManagerClientNewForBus(BusTypeVar BusType, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 501 | + | ||
| 502 | + | xDBusObjectManagerClientNewForBus(BusTypeVar, FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 503 | + | ||
| 504 | + | } | |
| 505 | + | ||
| 463 | 506 | func init() { | |
| 464 | 507 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 465 | 508 | if err != nil { | |
| @@ -476,4 +519,7 @@ func init() { | |||
| 476 | 519 | core.PuregoSafeRegister(&xDBusObjectManagerClientGetName, lib, "g_dbus_object_manager_client_get_name") | |
| 477 | 520 | core.PuregoSafeRegister(&xDBusObjectManagerClientGetNameOwner, lib, "g_dbus_object_manager_client_get_name_owner") | |
| 478 | 521 | ||
| 522 | + | core.PuregoSafeRegister(&xDBusObjectManagerClientNew, lib, "g_dbus_object_manager_client_new") | |
| 523 | + | core.PuregoSafeRegister(&xDBusObjectManagerClientNewForBus, lib, "g_dbus_object_manager_client_new_for_bus") | |
| 524 | + | ||
| 479 | 525 | } | |
M v4/gio/gdbusobjectmanagerserver.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type DBusObjectManagerServerClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DBusObjectManagerServerClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type DBusObjectManagerServerPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *DBusObjectManagerServerPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // #GDBusObjectManagerServer is used to export #GDBusObject instances using | |
| 22 | 32 | // the standardized | |
| 23 | 33 | // [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) | |
M v4/gio/gdbusobjectproxy.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type DBusObjectProxyClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DBusObjectProxyClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type DBusObjectProxyPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *DBusObjectProxyPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // A #GDBusObjectProxy is an object used to represent a remote object | |
| 22 | 32 | // with one or more D-Bus interfaces. Normally, you don't instantiate | |
| 23 | 33 | // a #GDBusObjectProxy yourself - typically #GDBusObjectManagerClient | |
M v4/gio/gdbusobjectskeleton.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type DBusObjectSkeletonClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DBusObjectSkeletonClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type DBusObjectSkeletonPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *DBusObjectSkeletonPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // A #GDBusObjectSkeleton instance is essentially a group of D-Bus | |
| 22 | 32 | // interfaces. The set of exported interfaces on the object may be | |
| 23 | 33 | // dynamic and change at runtime. | |
M v4/gio/gdbusproxy.go +59 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type DBusProxyClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DBusProxyClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type DBusProxyPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *DBusProxyPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // #GDBusProxy is a base class used for proxies to access a D-Bus | |
| 22 | 32 | // interface on a remote object. A #GDBusProxy can be constructed for | |
| 23 | 33 | // both well-known and unique names. | |
| @@ -739,6 +749,52 @@ func (x *DBusProxy) Init(CancellableVar *Cancellable) (bool, error) { | |||
| 739 | 749 | ||
| 740 | 750 | } | |
| 741 | 751 | ||
| 752 | + | var xDBusProxyNew func(uintptr, DBusProxyFlags, *DBusInterfaceInfo, string, string, string, uintptr, uintptr, uintptr) | |
| 753 | + | ||
| 754 | + | // Creates a proxy for accessing @interface_name on the remote object | |
| 755 | + | // at @object_path owned by @name at @connection and asynchronously | |
| 756 | + | // loads D-Bus properties unless the | |
| 757 | + | // %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to | |
| 758 | + | // the #GDBusProxy::g-properties-changed signal to get notified about | |
| 759 | + | // property changes. | |
| 760 | + | // | |
| 761 | + | // If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up | |
| 762 | + | // match rules for signals. Connect to the #GDBusProxy::g-signal signal | |
| 763 | + | // to handle signals from the remote object. | |
| 764 | + | // | |
| 765 | + | // If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and | |
| 766 | + | // %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is | |
| 767 | + | // guaranteed to complete immediately without blocking. | |
| 768 | + | // | |
| 769 | + | // If @name is a well-known name and the | |
| 770 | + | // %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION | |
| 771 | + | // flags aren't set and no name owner currently exists, the message bus | |
| 772 | + | // will be requested to launch a name owner for the name. | |
| 773 | + | // | |
| 774 | + | // This is a failable asynchronous constructor - when the proxy is | |
| 775 | + | // ready, @callback will be invoked and you can use | |
| 776 | + | // g_dbus_proxy_new_finish() to get the result. | |
| 777 | + | // | |
| 778 | + | // See g_dbus_proxy_new_sync() and for a synchronous version of this constructor. | |
| 779 | + | // | |
| 780 | + | // #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. | |
| 781 | + | func DBusProxyNew(ConnectionVar *DBusConnection, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 782 | + | ||
| 783 | + | xDBusProxyNew(ConnectionVar.GoPointer(), FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 784 | + | ||
| 785 | + | } | |
| 786 | + | ||
| 787 | + | var xDBusProxyNewForBus func(BusType, DBusProxyFlags, *DBusInterfaceInfo, string, string, string, uintptr, uintptr, uintptr) | |
| 788 | + | ||
| 789 | + | // Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection. | |
| 790 | + | // | |
| 791 | + | // #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. | |
| 792 | + | func DBusProxyNewForBus(BusTypeVar BusType, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 793 | + | ||
| 794 | + | xDBusProxyNewForBus(BusTypeVar, FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 795 | + | ||
| 796 | + | } | |
| 797 | + | ||
| 742 | 798 | func init() { | |
| 743 | 799 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 744 | 800 | if err != nil { | |
| @@ -770,4 +826,7 @@ func init() { | |||
| 770 | 826 | core.PuregoSafeRegister(&xDBusProxySetDefaultTimeout, lib, "g_dbus_proxy_set_default_timeout") | |
| 771 | 827 | core.PuregoSafeRegister(&xDBusProxySetInterfaceInfo, lib, "g_dbus_proxy_set_interface_info") | |
| 772 | 828 | ||
| 829 | + | core.PuregoSafeRegister(&xDBusProxyNew, lib, "g_dbus_proxy_new") | |
| 830 | + | core.PuregoSafeRegister(&xDBusProxyNewForBus, lib, "g_dbus_proxy_new_for_bus") | |
| 831 | + | ||
| 773 | 832 | } | |
M v4/gio/gdebugcontroller.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,10 @@ type DebugControllerInterface struct { | |||
| 11 | 13 | GIface uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *DebugControllerInterface) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GDebugController is an interface to expose control of debugging features and | |
| 15 | 21 | // debug output. | |
| 16 | 22 | // | |
| @@ -61,6 +67,12 @@ func (x *DebugControllerBase) SetDebugEnabled(DebugEnabledVar bool) { | |||
| 61 | 67 | var XGDebugControllerGetDebugEnabled func(uintptr) bool | |
| 62 | 68 | var XGDebugControllerSetDebugEnabled func(uintptr, bool) | |
| 63 | 69 | ||
| 70 | + | const ( | |
| 71 | + | // Extension point for debug control functionality. | |
| 72 | + | // See [Extending GIO][extending-gio]. | |
| 73 | + | DEBUG_CONTROLLER_EXTENSION_POINT_NAME string = "gio-debug-controller" | |
| 74 | + | ) | |
| 75 | + | ||
| 64 | 76 | func init() { | |
| 65 | 77 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 66 | 78 | if err != nil { | |
M v4/gio/gdebugcontrollerdbus.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,6 +17,10 @@ type DebugControllerDBusClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *DebugControllerDBusClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | // #GDebugControllerDBus is an implementation of #GDebugController which exposes | |
| 19 | 25 | // debug settings as a D-Bus object. | |
| 20 | 26 | // | |
M v4/gio/gdesktopappinfo.go +70 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -17,12 +19,20 @@ type DesktopAppInfoClass struct { | |||
| 17 | 19 | ParentClass uintptr | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *DesktopAppInfoClass) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 20 | 26 | // Interface that is used by backends to associate default | |
| 21 | 27 | // handlers with URI schemes. | |
| 22 | 28 | type DesktopAppInfoLookupIface struct { | |
| 23 | 29 | GIface uintptr | |
| 24 | 30 | } | |
| 25 | 31 | ||
| 32 | + | func (x *DesktopAppInfoLookupIface) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 26 | 36 | // #GDesktopAppInfoLookup is an opaque data structure and can only be accessed | |
| 27 | 37 | // using the following functions. | |
| 28 | 38 | type DesktopAppInfoLookup interface { | |
| @@ -65,6 +75,12 @@ func (x *DesktopAppInfoLookupBase) GetDefaultForUriScheme(UriSchemeVar string) * | |||
| 65 | 75 | ||
| 66 | 76 | var XGDesktopAppInfoLookupGetDefaultForUriScheme func(uintptr, string) uintptr | |
| 67 | 77 | ||
| 78 | + | const ( | |
| 79 | + | // Extension point for default handler to URI association. See | |
| 80 | + | // [Extending GIO][extending-gio]. | |
| 81 | + | DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME string = "gio-desktop-app-info-lookup" | |
| 82 | + | ) | |
| 83 | + | ||
| 68 | 84 | // #GDesktopAppInfo is an implementation of #GAppInfo based on | |
| 69 | 85 | // desktop files. | |
| 70 | 86 | // | |
| @@ -684,6 +700,56 @@ func (x *DesktopAppInfo) SupportsUris() bool { | |||
| 684 | 700 | return cret | |
| 685 | 701 | } | |
| 686 | 702 | ||
| 703 | + | var xDesktopAppInfoGetImplementations func(string) *glib.List | |
| 704 | + | ||
| 705 | + | // Gets all applications that implement @interface. | |
| 706 | + | // | |
| 707 | + | // An application implements an interface if that interface is listed in | |
| 708 | + | // the Implements= line of the desktop file of the application. | |
| 709 | + | func DesktopAppInfoGetImplementations(InterfaceVar string) *glib.List { | |
| 710 | + | ||
| 711 | + | cret := xDesktopAppInfoGetImplementations(InterfaceVar) | |
| 712 | + | return cret | |
| 713 | + | } | |
| 714 | + | ||
| 715 | + | var xDesktopAppInfoSearch func(string) uintptr | |
| 716 | + | ||
| 717 | + | // Searches desktop files for ones that match @search_string. | |
| 718 | + | // | |
| 719 | + | // The return value is an array of strvs. Each strv contains a list of | |
| 720 | + | // applications that matched @search_string with an equal score. The | |
| 721 | + | // outer list is sorted by score so that the first strv contains the | |
| 722 | + | // best-matching applications, and so on. | |
| 723 | + | // The algorithm for determining matches is undefined and may change at | |
| 724 | + | // any time. | |
| 725 | + | // | |
| 726 | + | // None of the search results are subjected to the normal validation | |
| 727 | + | // checks performed by g_desktop_app_info_new() (for example, checking that | |
| 728 | + | // the executable referenced by a result exists), and so it is possible for | |
| 729 | + | // g_desktop_app_info_new() to return %NULL when passed an app ID returned by | |
| 730 | + | // this function. It is expected that calling code will do this when | |
| 731 | + | // subsequently creating a #GDesktopAppInfo for each result. | |
| 732 | + | func DesktopAppInfoSearch(SearchStringVar string) uintptr { | |
| 733 | + | ||
| 734 | + | cret := xDesktopAppInfoSearch(SearchStringVar) | |
| 735 | + | return cret | |
| 736 | + | } | |
| 737 | + | ||
| 738 | + | var xDesktopAppInfoSetDesktopEnv func(string) | |
| 739 | + | ||
| 740 | + | // Sets the name of the desktop that the application is running in. | |
| 741 | + | // This is used by g_app_info_should_show() and | |
| 742 | + | // g_desktop_app_info_get_show_in() to evaluate the | |
| 743 | + | // `OnlyShowIn` and `NotShowIn` | |
| 744 | + | // desktop entry fields. | |
| 745 | + | // | |
| 746 | + | // Should be called only once; subsequent calls are ignored. | |
| 747 | + | func DesktopAppInfoSetDesktopEnv(DesktopEnvVar string) { | |
| 748 | + | ||
| 749 | + | xDesktopAppInfoSetDesktopEnv(DesktopEnvVar) | |
| 750 | + | ||
| 751 | + | } | |
| 752 | + | ||
| 687 | 753 | func init() { | |
| 688 | 754 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 689 | 755 | if err != nil { | |
| @@ -713,6 +779,10 @@ func init() { | |||
| 713 | 779 | core.PuregoSafeRegister(&xDesktopAppInfoLaunchUrisAsManagerWithFds, lib, "g_desktop_app_info_launch_uris_as_manager_with_fds") | |
| 714 | 780 | core.PuregoSafeRegister(&xDesktopAppInfoListActions, lib, "g_desktop_app_info_list_actions") | |
| 715 | 781 | ||
| 782 | + | core.PuregoSafeRegister(&xDesktopAppInfoGetImplementations, lib, "g_desktop_app_info_get_implementations") | |
| 783 | + | core.PuregoSafeRegister(&xDesktopAppInfoSearch, lib, "g_desktop_app_info_search") | |
| 784 | + | core.PuregoSafeRegister(&xDesktopAppInfoSetDesktopEnv, lib, "g_desktop_app_info_set_desktop_env") | |
| 785 | + | ||
| 716 | 786 | core.PuregoSafeRegister(&XGDesktopAppInfoLookupGetDefaultForUriScheme, lib, "g_desktop_app_info_lookup_get_default_for_uri_scheme") | |
| 717 | 787 | ||
| 718 | 788 | } | |
M v4/gio/gdrive.go +11 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type DriveIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *DriveIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GDrive - this represent a piece of hardware connected to the machine. | |
| 16 | 22 | // It's generally only created for removable hardware or hardware with | |
| 17 | 23 | // removable media. | |
| @@ -375,6 +381,11 @@ var XGDriveStartFinish func(uintptr, uintptr, **glib.Error) bool | |||
| 375 | 381 | var XGDriveStop func(uintptr, MountUnmountFlags, uintptr, uintptr, uintptr, uintptr) | |
| 376 | 382 | var XGDriveStopFinish func(uintptr, uintptr, **glib.Error) bool | |
| 377 | 383 | ||
| 384 | + | const ( | |
| 385 | + | // The string used to obtain a Unix device path with g_drive_get_identifier(). | |
| 386 | + | DRIVE_IDENTIFIER_KIND_UNIX_DEVICE string = "unix-device" | |
| 387 | + | ) | |
| 388 | + | ||
| 378 | 389 | func init() { | |
| 379 | 390 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 380 | 391 | if err != nil { | |
M v4/gio/gdtlsclientconnection.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type DtlsClientConnectionInterface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *DtlsClientConnectionInterface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GDtlsClientConnection is the client-side subclass of | |
| 17 | 23 | // #GDtlsConnection, representing a client-side DTLS connection. | |
| 18 | 24 | type DtlsClientConnection interface { | |
M v4/gio/gdtlsconnection.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type DtlsConnectionInterface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *DtlsConnectionInterface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GDtlsConnection is the base DTLS connection class type, which wraps | |
| 17 | 23 | // a #GDatagramBased and provides DTLS encryption on top of it. Its | |
| 18 | 24 | // subclasses, #GDtlsClientConnection and #GDtlsServerConnection, | |
M v4/gio/gdtlsserverconnection.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type DtlsServerConnectionInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *DtlsServerConnectionInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GDtlsServerConnection is the server-side subclass of #GDtlsConnection, | |
| 16 | 22 | // representing a server-side DTLS connection. | |
| 17 | 23 | type DtlsServerConnection interface { | |
M v4/gio/gemblem.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type EmblemClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *EmblemClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GEmblem is an implementation of #GIcon that supports | |
| 15 | 21 | // having an emblem, which is an icon with additional properties. | |
| 16 | 22 | // It can than be added to a #GEmblemedIcon. | |
M v4/gio/gemblemedicon.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type EmblemedIconClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *EmblemedIconClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type EmblemedIconPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *EmblemedIconPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GEmblemedIcon is an implementation of #GIcon that supports | |
| 19 | 29 | // adding an emblem to an icon. Adding multiple emblems to an | |
| 20 | 30 | // icon is ensured via g_emblemed_icon_add_emblem(). | |
M v4/gio/gfile.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,6 +17,10 @@ type FileIface struct { | |||
| 15 | 17 | SupportsThreadContexts bool | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *FileIface) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | // #GFile is a high level abstraction for manipulating files on a | |
| 19 | 25 | // virtual file system. #GFiles are lightweight, immutable objects | |
| 20 | 26 | // that do no I/O upon creation. It is necessary to understand that | |
M v4/gio/gfileattribute.go +87 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package gio was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Information about a specific attribute. | |
| 5 | 12 | type FileAttributeInfo struct { | |
| 6 | 13 | Name uintptr | |
| @@ -10,6 +17,10 @@ type FileAttributeInfo struct { | |||
| 10 | 17 | Flags FileAttributeInfoFlags | |
| 11 | 18 | } | |
| 12 | 19 | ||
| 20 | + | func (x *FileAttributeInfo) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 13 | 24 | // Acts as a lightweight registry for possible valid file attributes. | |
| 14 | 25 | // The registry stores Key-Value pair formats as #GFileAttributeInfos. | |
| 15 | 26 | type FileAttributeInfoList struct { | |
| @@ -17,3 +28,79 @@ type FileAttributeInfoList struct { | |||
| 17 | 28 | ||
| 18 | 29 | NInfos int | |
| 19 | 30 | } | |
| 31 | + | ||
| 32 | + | func (x *FileAttributeInfoList) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 36 | + | var xNewFileAttributeInfoList func() *FileAttributeInfoList | |
| 37 | + | ||
| 38 | + | // Creates a new file attribute info list. | |
| 39 | + | func NewFileAttributeInfoList() *FileAttributeInfoList { | |
| 40 | + | ||
| 41 | + | cret := xNewFileAttributeInfoList() | |
| 42 | + | return cret | |
| 43 | + | } | |
| 44 | + | ||
| 45 | + | var xFileAttributeInfoListAdd func(uintptr, string, FileAttributeType, FileAttributeInfoFlags) | |
| 46 | + | ||
| 47 | + | // Adds a new attribute with @name to the @list, setting | |
| 48 | + | // its @type and @flags. | |
| 49 | + | func (x *FileAttributeInfoList) Add(NameVar string, TypeVar FileAttributeType, FlagsVar FileAttributeInfoFlags) { | |
| 50 | + | ||
| 51 | + | xFileAttributeInfoListAdd(x.GoPointer(), NameVar, TypeVar, FlagsVar) | |
| 52 | + | ||
| 53 | + | } | |
| 54 | + | ||
| 55 | + | var xFileAttributeInfoListDup func(uintptr) *FileAttributeInfoList | |
| 56 | + | ||
| 57 | + | // Makes a duplicate of a file attribute info list. | |
| 58 | + | func (x *FileAttributeInfoList) Dup() *FileAttributeInfoList { | |
| 59 | + | ||
| 60 | + | cret := xFileAttributeInfoListDup(x.GoPointer()) | |
| 61 | + | return cret | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xFileAttributeInfoListLookup func(uintptr, string) *FileAttributeInfo | |
| 65 | + | ||
| 66 | + | // Gets the file attribute with the name @name from @list. | |
| 67 | + | func (x *FileAttributeInfoList) Lookup(NameVar string) *FileAttributeInfo { | |
| 68 | + | ||
| 69 | + | cret := xFileAttributeInfoListLookup(x.GoPointer(), NameVar) | |
| 70 | + | return cret | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xFileAttributeInfoListRef func(uintptr) *FileAttributeInfoList | |
| 74 | + | ||
| 75 | + | // References a file attribute info list. | |
| 76 | + | func (x *FileAttributeInfoList) Ref() *FileAttributeInfoList { | |
| 77 | + | ||
| 78 | + | cret := xFileAttributeInfoListRef(x.GoPointer()) | |
| 79 | + | return cret | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | var xFileAttributeInfoListUnref func(uintptr) | |
| 83 | + | ||
| 84 | + | // Removes a reference from the given @list. If the reference count | |
| 85 | + | // falls to zero, the @list is deleted. | |
| 86 | + | func (x *FileAttributeInfoList) Unref() { | |
| 87 | + | ||
| 88 | + | xFileAttributeInfoListUnref(x.GoPointer()) | |
| 89 | + | ||
| 90 | + | } | |
| 91 | + | ||
| 92 | + | func init() { | |
| 93 | + | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 94 | + | if err != nil { | |
| 95 | + | panic(err) | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | core.PuregoSafeRegister(&xNewFileAttributeInfoList, lib, "g_file_attribute_info_list_new") | |
| 99 | + | ||
| 100 | + | core.PuregoSafeRegister(&xFileAttributeInfoListAdd, lib, "g_file_attribute_info_list_add") | |
| 101 | + | core.PuregoSafeRegister(&xFileAttributeInfoListDup, lib, "g_file_attribute_info_list_dup") | |
| 102 | + | core.PuregoSafeRegister(&xFileAttributeInfoListLookup, lib, "g_file_attribute_info_list_lookup") | |
| 103 | + | core.PuregoSafeRegister(&xFileAttributeInfoListRef, lib, "g_file_attribute_info_list_ref") | |
| 104 | + | core.PuregoSafeRegister(&xFileAttributeInfoListUnref, lib, "g_file_attribute_info_list_unref") | |
| 105 | + | ||
| 106 | + | } | |
M v4/gio/gfiledescriptorbased.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,10 @@ type FileDescriptorBasedIface struct { | |||
| 11 | 13 | GIface uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileDescriptorBasedIface) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GFileDescriptorBased is implemented by streams (implementations of | |
| 15 | 21 | // #GInputStream or #GOutputStream) that are based on file descriptors. | |
| 16 | 22 | // | |
M v4/gio/gfileenumerator.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type FileEnumeratorClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *FileEnumeratorClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type FileEnumeratorPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *FileEnumeratorPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GFileEnumerator allows you to operate on a set of #GFiles, | |
| 19 | 29 | // returning a #GFileInfo structure for each file enumerated (e.g. | |
| 20 | 30 | // g_file_enumerate_children() will return a #GFileEnumerator for each | |
M v4/gio/gfileicon.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type FileIconClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileIconClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GFileIcon specifies an icon by pointing to an image file | |
| 15 | 21 | // to be used as icon. | |
| 16 | 22 | type FileIcon struct { | |
M v4/gio/gfileinfo.go +554 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,558 @@ import ( | |||
| 11 | 13 | type FileInfoClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileInfoClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | const ( | |
| 21 | + | // A key in the "access" namespace for checking deletion privileges. | |
| 22 | + | // | |
| 23 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 24 | + | // | |
| 25 | + | // This attribute will be %TRUE if the user is able to delete the file. | |
| 26 | + | FILE_ATTRIBUTE_ACCESS_CAN_DELETE string = "access::can-delete" | |
| 27 | + | // A key in the "access" namespace for getting execution privileges. | |
| 28 | + | // | |
| 29 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 30 | + | // | |
| 31 | + | // This attribute will be %TRUE if the user is able to execute the file. | |
| 32 | + | FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE string = "access::can-execute" | |
| 33 | + | // A key in the "access" namespace for getting read privileges. | |
| 34 | + | // | |
| 35 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 36 | + | // | |
| 37 | + | // This attribute will be %TRUE if the user is able to read the file. | |
| 38 | + | FILE_ATTRIBUTE_ACCESS_CAN_READ string = "access::can-read" | |
| 39 | + | // A key in the "access" namespace for checking renaming privileges. | |
| 40 | + | // | |
| 41 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 42 | + | // | |
| 43 | + | // This attribute will be %TRUE if the user is able to rename the file. | |
| 44 | + | FILE_ATTRIBUTE_ACCESS_CAN_RENAME string = "access::can-rename" | |
| 45 | + | // A key in the "access" namespace for checking trashing privileges. | |
| 46 | + | // | |
| 47 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 48 | + | // | |
| 49 | + | // This attribute will be %TRUE if the user is able to move the file to | |
| 50 | + | // the trash. | |
| 51 | + | FILE_ATTRIBUTE_ACCESS_CAN_TRASH string = "access::can-trash" | |
| 52 | + | // A key in the "access" namespace for getting write privileges. | |
| 53 | + | // | |
| 54 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 55 | + | // | |
| 56 | + | // This attribute will be %TRUE if the user is able to write to the file. | |
| 57 | + | FILE_ATTRIBUTE_ACCESS_CAN_WRITE string = "access::can-write" | |
| 58 | + | // A key in the "dos" namespace for checking if the file's archive flag | |
| 59 | + | // is set. | |
| 60 | + | // | |
| 61 | + | // This attribute is %TRUE if the archive flag is set. | |
| 62 | + | // | |
| 63 | + | // This attribute is only available for DOS file systems. | |
| 64 | + | // | |
| 65 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 66 | + | FILE_ATTRIBUTE_DOS_IS_ARCHIVE string = "dos::is-archive" | |
| 67 | + | // A key in the "dos" namespace for checking if the file is a NTFS mount point | |
| 68 | + | // (a volume mount or a junction point). | |
| 69 | + | // | |
| 70 | + | // This attribute is %TRUE if file is a reparse point of type | |
| 71 | + | // [IO_REPARSE_TAG_MOUNT_POINT](https://msdn.microsoft.com/en-us/library/dd541667.aspx). | |
| 72 | + | // | |
| 73 | + | // This attribute is only available for DOS file systems. | |
| 74 | + | // | |
| 75 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 76 | + | FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT string = "dos::is-mountpoint" | |
| 77 | + | // A key in the "dos" namespace for checking if the file's backup flag | |
| 78 | + | // is set. | |
| 79 | + | // | |
| 80 | + | // This attribute is %TRUE if the backup flag is set. | |
| 81 | + | // | |
| 82 | + | // This attribute is only available for DOS file systems. | |
| 83 | + | // | |
| 84 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 85 | + | FILE_ATTRIBUTE_DOS_IS_SYSTEM string = "dos::is-system" | |
| 86 | + | // A key in the "dos" namespace for getting the file NTFS reparse tag. | |
| 87 | + | // | |
| 88 | + | // This value is 0 for files that are not reparse points. | |
| 89 | + | // | |
| 90 | + | // See the [Reparse Tags](https://msdn.microsoft.com/en-us/library/dd541667.aspx) | |
| 91 | + | // page for possible reparse tag values. | |
| 92 | + | // | |
| 93 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 94 | + | FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG string = "dos::reparse-point-tag" | |
| 95 | + | // A key in the "etag" namespace for getting the value of the file's | |
| 96 | + | // entity tag. | |
| 97 | + | // | |
| 98 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 99 | + | FILE_ATTRIBUTE_ETAG_VALUE string = "etag::value" | |
| 100 | + | // A key in the "filesystem" namespace for getting the number of bytes | |
| 101 | + | // of free space left on the file system. | |
| 102 | + | // | |
| 103 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 104 | + | FILE_ATTRIBUTE_FILESYSTEM_FREE string = "filesystem::free" | |
| 105 | + | // A key in the "filesystem" namespace for checking if the file system | |
| 106 | + | // is read only. | |
| 107 | + | // | |
| 108 | + | // Is set to %TRUE if the file system is read only. | |
| 109 | + | // | |
| 110 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 111 | + | FILE_ATTRIBUTE_FILESYSTEM_READONLY string = "filesystem::readonly" | |
| 112 | + | // A key in the "filesystem" namespace for checking if the file system | |
| 113 | + | // is remote. | |
| 114 | + | // | |
| 115 | + | // Is set to %TRUE if the file system is remote. | |
| 116 | + | // | |
| 117 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 118 | + | FILE_ATTRIBUTE_FILESYSTEM_REMOTE string = "filesystem::remote" | |
| 119 | + | // A key in the "filesystem" namespace for getting the total size (in | |
| 120 | + | // bytes) of the file system, used in g_file_query_filesystem_info(). | |
| 121 | + | // | |
| 122 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 123 | + | FILE_ATTRIBUTE_FILESYSTEM_SIZE string = "filesystem::size" | |
| 124 | + | // A key in the "filesystem" namespace for getting the file system's type. | |
| 125 | + | // | |
| 126 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 127 | + | FILE_ATTRIBUTE_FILESYSTEM_TYPE string = "filesystem::type" | |
| 128 | + | // A key in the "filesystem" namespace for getting the number of bytes | |
| 129 | + | // used by data on the file system. | |
| 130 | + | // | |
| 131 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 132 | + | FILE_ATTRIBUTE_FILESYSTEM_USED string = "filesystem::used" | |
| 133 | + | // A key in the "filesystem" namespace for hinting a file manager | |
| 134 | + | // application whether it should preview (e.g. thumbnail) files on the | |
| 135 | + | // file system. | |
| 136 | + | // | |
| 137 | + | // The value for this key contain a #GFilesystemPreviewType. | |
| 138 | + | FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW string = "filesystem::use-preview" | |
| 139 | + | // A key in the "gvfs" namespace that gets the name of the current | |
| 140 | + | // GVFS backend in use. | |
| 141 | + | // | |
| 142 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 143 | + | FILE_ATTRIBUTE_GVFS_BACKEND string = "gvfs::backend" | |
| 144 | + | // A key in the "id" namespace for getting a file identifier. | |
| 145 | + | // | |
| 146 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 147 | + | // | |
| 148 | + | // An example use would be during listing files, to avoid recursive | |
| 149 | + | // directory scanning. | |
| 150 | + | FILE_ATTRIBUTE_ID_FILE string = "id::file" | |
| 151 | + | // A key in the "id" namespace for getting the file system identifier. | |
| 152 | + | // | |
| 153 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 154 | + | // | |
| 155 | + | // An example use would be during drag and drop to see if the source | |
| 156 | + | // and target are on the same filesystem (default to move) or not (default | |
| 157 | + | // to copy). | |
| 158 | + | FILE_ATTRIBUTE_ID_FILESYSTEM string = "id::filesystem" | |
| 159 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 160 | + | // type G_FILE_TYPE_MOUNTABLE) can be ejected. | |
| 161 | + | // | |
| 162 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 163 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT string = "mountable::can-eject" | |
| 164 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 165 | + | // type G_FILE_TYPE_MOUNTABLE) is mountable. | |
| 166 | + | // | |
| 167 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 168 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT string = "mountable::can-mount" | |
| 169 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 170 | + | // type G_FILE_TYPE_MOUNTABLE) can be polled. | |
| 171 | + | // | |
| 172 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 173 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL string = "mountable::can-poll" | |
| 174 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 175 | + | // type G_FILE_TYPE_MOUNTABLE) can be started. | |
| 176 | + | // | |
| 177 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 178 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_START string = "mountable::can-start" | |
| 179 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 180 | + | // type G_FILE_TYPE_MOUNTABLE) can be started degraded. | |
| 181 | + | // | |
| 182 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 183 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED string = "mountable::can-start-degraded" | |
| 184 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 185 | + | // type G_FILE_TYPE_MOUNTABLE) can be stopped. | |
| 186 | + | // | |
| 187 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 188 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP string = "mountable::can-stop" | |
| 189 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 190 | + | // type G_FILE_TYPE_MOUNTABLE) is unmountable. | |
| 191 | + | // | |
| 192 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 193 | + | FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT string = "mountable::can-unmount" | |
| 194 | + | // A key in the "mountable" namespace for getting the HAL UDI for the mountable | |
| 195 | + | // file. | |
| 196 | + | // | |
| 197 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 198 | + | FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI string = "mountable::hal-udi" | |
| 199 | + | // A key in the "mountable" namespace for checking if a file (of | |
| 200 | + | // type G_FILE_TYPE_MOUNTABLE) is automatically polled for media. | |
| 201 | + | // | |
| 202 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 203 | + | FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC string = "mountable::is-media-check-automatic" | |
| 204 | + | // A key in the "mountable" namespace for getting the #GDriveStartStopType. | |
| 205 | + | // | |
| 206 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 207 | + | FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE string = "mountable::start-stop-type" | |
| 208 | + | // A key in the "mountable" namespace for getting the unix device. | |
| 209 | + | // | |
| 210 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 211 | + | FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE string = "mountable::unix-device" | |
| 212 | + | // A key in the "mountable" namespace for getting the unix device file. | |
| 213 | + | // | |
| 214 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 215 | + | FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE string = "mountable::unix-device-file" | |
| 216 | + | // A key in the "owner" namespace for getting the file owner's group. | |
| 217 | + | // | |
| 218 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 219 | + | FILE_ATTRIBUTE_OWNER_GROUP string = "owner::group" | |
| 220 | + | // A key in the "owner" namespace for getting the user name of the | |
| 221 | + | // file's owner. | |
| 222 | + | // | |
| 223 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 224 | + | FILE_ATTRIBUTE_OWNER_USER string = "owner::user" | |
| 225 | + | // A key in the "owner" namespace for getting the real name of the | |
| 226 | + | // user that owns the file. | |
| 227 | + | // | |
| 228 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 229 | + | FILE_ATTRIBUTE_OWNER_USER_REAL string = "owner::user-real" | |
| 230 | + | // A key in the "preview" namespace for getting a #GIcon that can be | |
| 231 | + | // used to get preview of the file. | |
| 232 | + | // | |
| 233 | + | // For example, it may be a low resolution thumbnail without metadata. | |
| 234 | + | // | |
| 235 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. | |
| 236 | + | // | |
| 237 | + | // The value for this key should contain a #GIcon. | |
| 238 | + | FILE_ATTRIBUTE_PREVIEW_ICON string = "preview::icon" | |
| 239 | + | // A key in the "recent" namespace for getting time, when the metadata for the | |
| 240 | + | // file in `recent:///` was last changed. | |
| 241 | + | // | |
| 242 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_INT64. | |
| 243 | + | FILE_ATTRIBUTE_RECENT_MODIFIED string = "recent::modified" | |
| 244 | + | // A key in the "selinux" namespace for getting the file's SELinux | |
| 245 | + | // context. | |
| 246 | + | // | |
| 247 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 248 | + | // | |
| 249 | + | // Note that this attribute is only available if GLib has been built | |
| 250 | + | // with SELinux support. | |
| 251 | + | FILE_ATTRIBUTE_SELINUX_CONTEXT string = "selinux::context" | |
| 252 | + | // A key in the "standard" namespace for getting the amount of disk space | |
| 253 | + | // that is consumed by the file (in bytes). | |
| 254 | + | // | |
| 255 | + | // This will generally be larger than the file size (due to block size | |
| 256 | + | // overhead) but can occasionally be smaller (for example, for sparse files). | |
| 257 | + | // | |
| 258 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 259 | + | FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE string = "standard::allocated-size" | |
| 260 | + | // A key in the "standard" namespace for getting the content type of the file. | |
| 261 | + | // | |
| 262 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 263 | + | // | |
| 264 | + | // The value for this key should contain a valid content type. | |
| 265 | + | FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE string = "standard::content-type" | |
| 266 | + | // A key in the "standard" namespace for getting the copy name of the file. | |
| 267 | + | // | |
| 268 | + | // The copy name is an optional version of the name. If available it's always | |
| 269 | + | // in UTF8, and corresponds directly to the original filename (only transcoded to | |
| 270 | + | // UTF8). This is useful if you want to copy the file to another filesystem that | |
| 271 | + | // might have a different encoding. If the filename is not a valid string in the | |
| 272 | + | // encoding selected for the filesystem it is in then the copy name will not be set. | |
| 273 | + | // | |
| 274 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 275 | + | FILE_ATTRIBUTE_STANDARD_COPY_NAME string = "standard::copy-name" | |
| 276 | + | // A key in the "standard" namespace for getting the description of the file. | |
| 277 | + | // | |
| 278 | + | // The description is a utf8 string that describes the file, generally containing | |
| 279 | + | // the filename, but can also contain further information. Example descriptions | |
| 280 | + | // could be "filename (on hostname)" for a remote file or "filename (in trash)" | |
| 281 | + | // for a file in the trash. This is useful for instance as the window title | |
| 282 | + | // when displaying a directory or for a bookmarks menu. | |
| 283 | + | // | |
| 284 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 285 | + | FILE_ATTRIBUTE_STANDARD_DESCRIPTION string = "standard::description" | |
| 286 | + | // A key in the "standard" namespace for getting the display name of the file. | |
| 287 | + | // | |
| 288 | + | // A display name is guaranteed to be in UTF-8 and can thus be displayed in | |
| 289 | + | // the UI. It is guaranteed to be set on every file. | |
| 290 | + | // | |
| 291 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 292 | + | FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME string = "standard::display-name" | |
| 293 | + | // A key in the "standard" namespace for edit name of the file. | |
| 294 | + | // | |
| 295 | + | // An edit name is similar to the display name, but it is meant to be | |
| 296 | + | // used when you want to rename the file in the UI. The display name | |
| 297 | + | // might contain information you don't want in the new filename (such as | |
| 298 | + | // "(invalid unicode)" if the filename was in an invalid encoding). | |
| 299 | + | // | |
| 300 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 301 | + | FILE_ATTRIBUTE_STANDARD_EDIT_NAME string = "standard::edit-name" | |
| 302 | + | // A key in the "standard" namespace for getting the fast content type. | |
| 303 | + | // | |
| 304 | + | // The fast content type isn't as reliable as the regular one, as it | |
| 305 | + | // only uses the filename to guess it, but it is faster to calculate than the | |
| 306 | + | // regular content type. | |
| 307 | + | // | |
| 308 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 309 | + | FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE string = "standard::fast-content-type" | |
| 310 | + | // A key in the "standard" namespace for getting the icon for the file. | |
| 311 | + | // | |
| 312 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. | |
| 313 | + | // | |
| 314 | + | // The value for this key should contain a #GIcon. | |
| 315 | + | FILE_ATTRIBUTE_STANDARD_ICON string = "standard::icon" | |
| 316 | + | // A key in the "standard" namespace for checking if a file is a backup file. | |
| 317 | + | // | |
| 318 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 319 | + | FILE_ATTRIBUTE_STANDARD_IS_BACKUP string = "standard::is-backup" | |
| 320 | + | // A key in the "standard" namespace for checking if a file is hidden. | |
| 321 | + | // | |
| 322 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 323 | + | FILE_ATTRIBUTE_STANDARD_IS_HIDDEN string = "standard::is-hidden" | |
| 324 | + | // A key in the "standard" namespace for checking if the file is a symlink. | |
| 325 | + | // Typically the actual type is something else, if we followed the symlink | |
| 326 | + | // to get the type. | |
| 327 | + | // | |
| 328 | + | // On Windows NTFS mountpoints are considered to be symlinks as well. | |
| 329 | + | // | |
| 330 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 331 | + | FILE_ATTRIBUTE_STANDARD_IS_SYMLINK string = "standard::is-symlink" | |
| 332 | + | // A key in the "standard" namespace for checking if a file is virtual. | |
| 333 | + | // | |
| 334 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 335 | + | FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL string = "standard::is-virtual" | |
| 336 | + | // A key in the "standard" namespace for checking if a file is | |
| 337 | + | // volatile. This is meant for opaque, non-POSIX-like backends to | |
| 338 | + | // indicate that the URI is not persistent. Applications should look | |
| 339 | + | // at %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET for the persistent URI. | |
| 340 | + | // | |
| 341 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 342 | + | FILE_ATTRIBUTE_STANDARD_IS_VOLATILE string = "standard::is-volatile" | |
| 343 | + | // A key in the "standard" namespace for getting the name of the file. | |
| 344 | + | // | |
| 345 | + | // The name is the on-disk filename which may not be in any known encoding, | |
| 346 | + | // and can thus not be generally displayed as is. It is guaranteed to be set on | |
| 347 | + | // every file. | |
| 348 | + | // | |
| 349 | + | // Use %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME if you need to display the | |
| 350 | + | // name in a user interface. | |
| 351 | + | // | |
| 352 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. | |
| 353 | + | FILE_ATTRIBUTE_STANDARD_NAME string = "standard::name" | |
| 354 | + | // A key in the "standard" namespace for getting the file's size (in bytes). | |
| 355 | + | // | |
| 356 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 357 | + | FILE_ATTRIBUTE_STANDARD_SIZE string = "standard::size" | |
| 358 | + | // A key in the "standard" namespace for setting the sort order of a file. | |
| 359 | + | // | |
| 360 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_INT32. | |
| 361 | + | // | |
| 362 | + | // An example use would be in file managers, which would use this key | |
| 363 | + | // to set the order files are displayed. Files with smaller sort order | |
| 364 | + | // should be sorted first, and files without sort order as if sort order | |
| 365 | + | // was zero. | |
| 366 | + | FILE_ATTRIBUTE_STANDARD_SORT_ORDER string = "standard::sort-order" | |
| 367 | + | // A key in the "standard" namespace for getting the symbolic icon for the file. | |
| 368 | + | // | |
| 369 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_OBJECT. | |
| 370 | + | // | |
| 371 | + | // The value for this key should contain a #GIcon. | |
| 372 | + | FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON string = "standard::symbolic-icon" | |
| 373 | + | // A key in the "standard" namespace for getting the symlink target, if the file | |
| 374 | + | // is a symlink. | |
| 375 | + | // | |
| 376 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. | |
| 377 | + | FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET string = "standard::symlink-target" | |
| 378 | + | // A key in the "standard" namespace for getting the target URI for the file, in | |
| 379 | + | // the case of %G_FILE_TYPE_SHORTCUT or %G_FILE_TYPE_MOUNTABLE files. | |
| 380 | + | // | |
| 381 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 382 | + | FILE_ATTRIBUTE_STANDARD_TARGET_URI string = "standard::target-uri" | |
| 383 | + | // A key in the "standard" namespace for storing file types. | |
| 384 | + | // | |
| 385 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 386 | + | // | |
| 387 | + | // The value for this key should contain a #GFileType. | |
| 388 | + | FILE_ATTRIBUTE_STANDARD_TYPE string = "standard::type" | |
| 389 | + | // A key in the "thumbnail" namespace for checking if thumbnailing failed. | |
| 390 | + | // | |
| 391 | + | // This attribute is %TRUE if thumbnailing failed. | |
| 392 | + | // | |
| 393 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 394 | + | FILE_ATTRIBUTE_THUMBNAILING_FAILED string = "thumbnail::failed" | |
| 395 | + | // A key in the "thumbnail" namespace for checking whether the thumbnail is outdated. | |
| 396 | + | // | |
| 397 | + | // This attribute is %TRUE if the thumbnail is up-to-date with the file it represents, | |
| 398 | + | // and %FALSE if the file has been modified since the thumbnail was generated. | |
| 399 | + | // | |
| 400 | + | // If %G_FILE_ATTRIBUTE_THUMBNAILING_FAILED is %TRUE and this attribute is %FALSE, | |
| 401 | + | // it indicates that thumbnailing may be attempted again and may succeed. | |
| 402 | + | // | |
| 403 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 404 | + | FILE_ATTRIBUTE_THUMBNAIL_IS_VALID string = "thumbnail::is-valid" | |
| 405 | + | // A key in the "thumbnail" namespace for getting the path to the thumbnail | |
| 406 | + | // image. | |
| 407 | + | // | |
| 408 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. | |
| 409 | + | FILE_ATTRIBUTE_THUMBNAIL_PATH string = "thumbnail::path" | |
| 410 | + | // A key in the "time" namespace for getting the time the file was last | |
| 411 | + | // accessed. | |
| 412 | + | // | |
| 413 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, and | |
| 414 | + | // contains the time since the file was last accessed, in seconds since the | |
| 415 | + | // UNIX epoch. | |
| 416 | + | FILE_ATTRIBUTE_TIME_ACCESS string = "time::access" | |
| 417 | + | // A key in the "time" namespace for getting the microseconds of the time | |
| 418 | + | // the file was last accessed. | |
| 419 | + | // | |
| 420 | + | // This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_ACCESS. | |
| 421 | + | // | |
| 422 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 423 | + | FILE_ATTRIBUTE_TIME_ACCESS_USEC string = "time::access-usec" | |
| 424 | + | // A key in the "time" namespace for getting the time the file was last | |
| 425 | + | // changed. | |
| 426 | + | // | |
| 427 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, | |
| 428 | + | // and contains the time since the file was last changed, in seconds since | |
| 429 | + | // the UNIX epoch. | |
| 430 | + | // | |
| 431 | + | // This corresponds to the traditional UNIX ctime. | |
| 432 | + | FILE_ATTRIBUTE_TIME_CHANGED string = "time::changed" | |
| 433 | + | // A key in the "time" namespace for getting the microseconds of the time | |
| 434 | + | // the file was last changed. | |
| 435 | + | // | |
| 436 | + | // This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_CHANGED. | |
| 437 | + | // | |
| 438 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 439 | + | FILE_ATTRIBUTE_TIME_CHANGED_USEC string = "time::changed-usec" | |
| 440 | + | // A key in the "time" namespace for getting the time the file was created. | |
| 441 | + | // | |
| 442 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, | |
| 443 | + | // and contains the time since the file was created, in seconds since the UNIX | |
| 444 | + | // epoch. | |
| 445 | + | // | |
| 446 | + | // This may correspond to Linux `stx_btime`, FreeBSD `st_birthtim`, NetBSD | |
| 447 | + | // `st_birthtime` or NTFS `ctime`. | |
| 448 | + | FILE_ATTRIBUTE_TIME_CREATED string = "time::created" | |
| 449 | + | // A key in the "time" namespace for getting the microseconds of the time | |
| 450 | + | // the file was created. | |
| 451 | + | // | |
| 452 | + | // This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_CREATED. | |
| 453 | + | // | |
| 454 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 455 | + | FILE_ATTRIBUTE_TIME_CREATED_USEC string = "time::created-usec" | |
| 456 | + | // A key in the "time" namespace for getting the time the file was last | |
| 457 | + | // modified. | |
| 458 | + | // | |
| 459 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64, and | |
| 460 | + | // contains the time since the file was modified, in seconds since the UNIX | |
| 461 | + | // epoch. | |
| 462 | + | FILE_ATTRIBUTE_TIME_MODIFIED string = "time::modified" | |
| 463 | + | // A key in the "time" namespace for getting the microseconds of the time | |
| 464 | + | // the file was last modified. | |
| 465 | + | // | |
| 466 | + | // This should be used in conjunction with %G_FILE_ATTRIBUTE_TIME_MODIFIED. | |
| 467 | + | // | |
| 468 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 469 | + | FILE_ATTRIBUTE_TIME_MODIFIED_USEC string = "time::modified-usec" | |
| 470 | + | // A key in the "trash" namespace for getting the deletion date and time | |
| 471 | + | // of a file inside the `trash:///` folder. | |
| 472 | + | // | |
| 473 | + | // The format of the returned string is `YYYY-MM-DDThh:mm:ss`. | |
| 474 | + | // | |
| 475 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_STRING. | |
| 476 | + | FILE_ATTRIBUTE_TRASH_DELETION_DATE string = "trash::deletion-date" | |
| 477 | + | // A key in the "trash" namespace for getting the number of (toplevel) items | |
| 478 | + | // that are present in the `trash:///` folder. | |
| 479 | + | // | |
| 480 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 481 | + | FILE_ATTRIBUTE_TRASH_ITEM_COUNT string = "trash::item-count" | |
| 482 | + | // A key in the "trash" namespace for getting the original path of a file | |
| 483 | + | // inside the `trash:///` folder before it was trashed. | |
| 484 | + | // | |
| 485 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING. | |
| 486 | + | FILE_ATTRIBUTE_TRASH_ORIG_PATH string = "trash::orig-path" | |
| 487 | + | // A key in the "unix" namespace for getting the number of blocks allocated | |
| 488 | + | // for the file. | |
| 489 | + | // | |
| 490 | + | // This attribute is only available for UNIX file systems. | |
| 491 | + | // | |
| 492 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 493 | + | FILE_ATTRIBUTE_UNIX_BLOCKS string = "unix::blocks" | |
| 494 | + | // A key in the "unix" namespace for getting the block size for the file | |
| 495 | + | // system. | |
| 496 | + | // | |
| 497 | + | // This attribute is only available for UNIX file systems. | |
| 498 | + | // | |
| 499 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 500 | + | FILE_ATTRIBUTE_UNIX_BLOCK_SIZE string = "unix::block-size" | |
| 501 | + | // A key in the "unix" namespace for getting the device id of the device the | |
| 502 | + | // file is located on (see stat() documentation). | |
| 503 | + | // | |
| 504 | + | // This attribute is only available for UNIX file systems. | |
| 505 | + | // | |
| 506 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 507 | + | FILE_ATTRIBUTE_UNIX_DEVICE string = "unix::device" | |
| 508 | + | // A key in the "unix" namespace for getting the group ID for the file. | |
| 509 | + | // | |
| 510 | + | // This attribute is only available for UNIX file systems. | |
| 511 | + | // | |
| 512 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 513 | + | FILE_ATTRIBUTE_UNIX_GID string = "unix::gid" | |
| 514 | + | // A key in the "unix" namespace for getting the inode of the file. | |
| 515 | + | // | |
| 516 | + | // This attribute is only available for UNIX file systems. | |
| 517 | + | // | |
| 518 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. | |
| 519 | + | FILE_ATTRIBUTE_UNIX_INODE string = "unix::inode" | |
| 520 | + | // A key in the "unix" namespace for checking if the file represents a | |
| 521 | + | // UNIX mount point. | |
| 522 | + | // | |
| 523 | + | // This attribute is %TRUE if the file is a UNIX mount point. | |
| 524 | + | // | |
| 525 | + | // Since 2.58, `/` is considered to be a mount point. | |
| 526 | + | // | |
| 527 | + | // This attribute is only available for UNIX file systems. | |
| 528 | + | // | |
| 529 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. | |
| 530 | + | FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT string = "unix::is-mountpoint" | |
| 531 | + | // A key in the "unix" namespace for getting the mode of the file | |
| 532 | + | // (e.g. whether the file is a regular file, symlink, etc). | |
| 533 | + | // | |
| 534 | + | // See the documentation for `lstat()`: this attribute is equivalent to | |
| 535 | + | // the `st_mode` member of `struct stat`, and includes both the file type | |
| 536 | + | // and permissions. | |
| 537 | + | // | |
| 538 | + | // This attribute is only available for UNIX file systems. | |
| 539 | + | // | |
| 540 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 541 | + | FILE_ATTRIBUTE_UNIX_MODE string = "unix::mode" | |
| 542 | + | // A key in the "unix" namespace for getting the number of hard links | |
| 543 | + | // for a file. | |
| 544 | + | // | |
| 545 | + | // See the documentation for `lstat()`. | |
| 546 | + | // | |
| 547 | + | // This attribute is only available for UNIX file systems. | |
| 548 | + | // | |
| 549 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 550 | + | FILE_ATTRIBUTE_UNIX_NLINK string = "unix::nlink" | |
| 551 | + | // A key in the "unix" namespace for getting the device ID for the file | |
| 552 | + | // (if it is a special file). | |
| 553 | + | // | |
| 554 | + | // See the documentation for `lstat()`. | |
| 555 | + | // | |
| 556 | + | // This attribute is only available for UNIX file systems. | |
| 557 | + | // | |
| 558 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 559 | + | FILE_ATTRIBUTE_UNIX_RDEV string = "unix::rdev" | |
| 560 | + | // A key in the "unix" namespace for getting the user ID for the file. | |
| 561 | + | // | |
| 562 | + | // This attribute is only available for UNIX file systems. | |
| 563 | + | // | |
| 564 | + | // Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT32. | |
| 565 | + | FILE_ATTRIBUTE_UNIX_UID string = "unix::uid" | |
| 566 | + | ) | |
| 567 | + | ||
| 14 | 568 | // Functionality for manipulating basic metadata for files. #GFileInfo | |
| 15 | 569 | // implements methods for getting information that all files should | |
| 16 | 570 | // contain, and allows for manipulation of extended attributes. | |
M v4/gio/gfileinputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type FileInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type FileInputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *FileInputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // GFileInputStream provides input streams that take their | |
| 18 | 28 | // content from a file. | |
| 19 | 29 | // | |
M v4/gio/gfileiostream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type FileIOStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileIOStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type FileIOStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *FileIOStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // GFileIOStream provides io streams that both read and write to the same | |
| 18 | 28 | // file handle. | |
| 19 | 29 | // | |
M v4/gio/gfilemonitor.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type FileMonitorClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileMonitorClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type FileMonitorPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *FileMonitorPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Monitors a file or directory for changes. | |
| 18 | 28 | // | |
| 19 | 29 | // To obtain a #GFileMonitor for a file or directory, use | |
M v4/gio/gfilenamecompleter.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,10 @@ type FilenameCompleterClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FilenameCompleterClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // Completes partial file and directory names given a partial string by | |
| 15 | 21 | // looking in the file system for clues. Can return a list of possible | |
| 16 | 22 | // completion strings for widget implementations. | |
M v4/gio/gfileoutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type FileOutputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FileOutputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type FileOutputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *FileOutputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // GFileOutputStream provides output streams that write their | |
| 18 | 28 | // content to a file. | |
| 19 | 29 | // | |
M v4/gio/gfilterinputstream.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,10 @@ type FilterInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FilterInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // Base class for input stream implementations that perform some | |
| 15 | 21 | // kind of filtering operation on a base stream. Typical examples | |
| 16 | 22 | // of filtering operations are character set conversion, compression | |
M v4/gio/gfilteroutputstream.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,6 +13,10 @@ type FilterOutputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *FilterOutputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // Base class for output stream implementations that perform some | |
| 15 | 21 | // kind of filtering operation on a base stream. Typical examples | |
| 16 | 22 | // of filtering operations are character set conversion, compression | |
M v4/gio/gicon.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type IconIface struct { | |||
| 14 | 16 | GIface uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *IconIface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // #GIcon is a very minimal interface for icons. It provides functions | |
| 18 | 24 | // for checking the equality of two icons, hashing of icons and | |
| 19 | 25 | // serializing an icon to and from strings. | |
M v4/gio/ginetaddress.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type InetAddressClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *InetAddressClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type InetAddressPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *InetAddressPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // #GInetAddress represents an IPv4 or IPv6 internet address. Use | |
| 18 | 28 | // g_resolver_lookup_by_name() or g_resolver_lookup_by_name_async() to | |
| 19 | 29 | // look up the #GInetAddress for a hostname. Use | |
M v4/gio/ginetaddressmask.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type InetAddressMaskClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *InetAddressMaskClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type InetAddressMaskPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *InetAddressMaskPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GInetAddressMask represents a range of IPv4 or IPv6 addresses | |
| 19 | 29 | // described by a base address and a length indicating how many bits | |
| 20 | 30 | // of the base address are relevant for matching purposes. These are | |
M v4/gio/ginetsocketaddress.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type InetSocketAddressClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *InetSocketAddressClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type InetSocketAddressPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *InetSocketAddressPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // An IPv4 or IPv6 socket address; that is, the combination of a | |
| 18 | 28 | // #GInetAddress and a port number. | |
| 19 | 29 | type InetSocketAddress struct { | |
M v4/gio/ginitable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type InitableIface struct { | |||
| 14 | 16 | GIface uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *InitableIface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // #GInitable is implemented by objects that can fail during | |
| 18 | 24 | // initialization. If an object implements this interface then | |
| 19 | 25 | // it must be initialized as the first thing after construction, | |
M v4/gio/ginputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type InputStreamClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *InputStreamClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type InputStreamPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *InputStreamPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GInputStream has functions to read from a stream (g_input_stream_read()), | |
| 19 | 29 | // to close a stream (g_input_stream_close()) and to skip some content | |
| 20 | 30 | // (g_input_stream_skip()). | |
M v4/gio/gio-2.0.go +175 -0
| @@ -101,6 +101,30 @@ func (x *AppInfoMonitor) ConnectChanged(cb func(AppInfoMonitor)) uint32 { | |||
| 101 | 101 | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 102 | 102 | } | |
| 103 | 103 | ||
| 104 | + | var xAppInfoMonitorGet func() uintptr | |
| 105 | + | ||
| 106 | + | // Gets the #GAppInfoMonitor for the current thread-default main | |
| 107 | + | // context. | |
| 108 | + | // | |
| 109 | + | // The #GAppInfoMonitor will emit a "changed" signal in the | |
| 110 | + | // thread-default main context whenever the list of installed | |
| 111 | + | // applications (as reported by g_app_info_get_all()) may have changed. | |
| 112 | + | // | |
| 113 | + | // You must only call g_object_unref() on the return value from under | |
| 114 | + | // the same main context as you created it. | |
| 115 | + | func AppInfoMonitorGet() *AppInfoMonitor { | |
| 116 | + | var cls *AppInfoMonitor | |
| 117 | + | ||
| 118 | + | cret := xAppInfoMonitorGet() | |
| 119 | + | ||
| 120 | + | if cret == 0 { | |
| 121 | + | return nil | |
| 122 | + | } | |
| 123 | + | cls = &AppInfoMonitor{} | |
| 124 | + | cls.Ptr = cret | |
| 125 | + | return cls | |
| 126 | + | } | |
| 127 | + | ||
| 104 | 128 | // #GBytesIcon specifies an image held in memory in a common format (usually | |
| 105 | 129 | // png) to be used as icon. | |
| 106 | 130 | type BytesIcon struct { | |
| @@ -519,6 +543,34 @@ func (x *DBusActionGroup) ChangeActionStateFull(ActionNameVar string, ValueVar * | |||
| 519 | 543 | ||
| 520 | 544 | } | |
| 521 | 545 | ||
| 546 | + | var xDBusActionGroupGet func(uintptr, string, string) uintptr | |
| 547 | + | ||
| 548 | + | // Obtains a #GDBusActionGroup for the action group which is exported at | |
| 549 | + | // the given @bus_name and @object_path. | |
| 550 | + | // | |
| 551 | + | // The thread default main context is taken at the time of this call. | |
| 552 | + | // All signals on the menu model (and any linked models) are reported | |
| 553 | + | // with respect to this context. All calls on the returned menu model | |
| 554 | + | // (and linked models) must also originate from this same context, with | |
| 555 | + | // the thread default main context unchanged. | |
| 556 | + | // | |
| 557 | + | // This call is non-blocking. The returned action group may or may not | |
| 558 | + | // already be filled in. The correct thing to do is connect the signals | |
| 559 | + | // for the action group to monitor for changes and then to call | |
| 560 | + | // g_action_group_list_actions() to get the initial list. | |
| 561 | + | func DBusActionGroupGet(ConnectionVar *DBusConnection, BusNameVar string, ObjectPathVar string) *DBusActionGroup { | |
| 562 | + | var cls *DBusActionGroup | |
| 563 | + | ||
| 564 | + | cret := xDBusActionGroupGet(ConnectionVar.GoPointer(), BusNameVar, ObjectPathVar) | |
| 565 | + | ||
| 566 | + | if cret == 0 { | |
| 567 | + | return nil | |
| 568 | + | } | |
| 569 | + | cls = &DBusActionGroup{} | |
| 570 | + | cls.Ptr = cret | |
| 571 | + | return cls | |
| 572 | + | } | |
| 573 | + | ||
| 522 | 574 | // The #GDBusAuthObserver type provides a mechanism for participating | |
| 523 | 575 | // in how a #GDBusServer (or a #GDBusConnection) authenticates remote | |
| 524 | 576 | // peers. Simply instantiate a #GDBusAuthObserver and connect to the | |
| @@ -1963,6 +2015,64 @@ func (x *DBusConnection) Init(CancellableVar *Cancellable) (bool, error) { | |||
| 1963 | 2015 | ||
| 1964 | 2016 | } | |
| 1965 | 2017 | ||
| 2018 | + | var xDBusConnectionNew func(uintptr, string, DBusConnectionFlags, uintptr, uintptr, uintptr, uintptr) | |
| 2019 | + | ||
| 2020 | + | // Asynchronously sets up a D-Bus connection for exchanging D-Bus messages | |
| 2021 | + | // with the end represented by @stream. | |
| 2022 | + | // | |
| 2023 | + | // If @stream is a #GSocketConnection, then the corresponding #GSocket | |
| 2024 | + | // will be put into non-blocking mode. | |
| 2025 | + | // | |
| 2026 | + | // The D-Bus connection will interact with @stream from a worker thread. | |
| 2027 | + | // As a result, the caller should not interact with @stream after this | |
| 2028 | + | // method has been called, except by calling g_object_unref() on it. | |
| 2029 | + | // | |
| 2030 | + | // If @observer is not %NULL it may be used to control the | |
| 2031 | + | // authentication process. | |
| 2032 | + | // | |
| 2033 | + | // When the operation is finished, @callback will be invoked. You can | |
| 2034 | + | // then call g_dbus_connection_new_finish() to get the result of the | |
| 2035 | + | // operation. | |
| 2036 | + | // | |
| 2037 | + | // This is an asynchronous failable constructor. See | |
| 2038 | + | // g_dbus_connection_new_sync() for the synchronous | |
| 2039 | + | // version. | |
| 2040 | + | func DBusConnectionNew(StreamVar *IOStream, GuidVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2041 | + | ||
| 2042 | + | xDBusConnectionNew(StreamVar.GoPointer(), GuidVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2043 | + | ||
| 2044 | + | } | |
| 2045 | + | ||
| 2046 | + | var xDBusConnectionNewForAddress func(string, DBusConnectionFlags, uintptr, uintptr, uintptr, uintptr) | |
| 2047 | + | ||
| 2048 | + | // Asynchronously connects and sets up a D-Bus client connection for | |
| 2049 | + | // exchanging D-Bus messages with an endpoint specified by @address | |
| 2050 | + | // which must be in the | |
| 2051 | + | // [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses). | |
| 2052 | + | // | |
| 2053 | + | // This constructor can only be used to initiate client-side | |
| 2054 | + | // connections - use g_dbus_connection_new() if you need to act as the | |
| 2055 | + | // server. In particular, @flags cannot contain the | |
| 2056 | + | // %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER, | |
| 2057 | + | // %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS or | |
| 2058 | + | // %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flags. | |
| 2059 | + | // | |
| 2060 | + | // When the operation is finished, @callback will be invoked. You can | |
| 2061 | + | // then call g_dbus_connection_new_for_address_finish() to get the result of | |
| 2062 | + | // the operation. | |
| 2063 | + | // | |
| 2064 | + | // If @observer is not %NULL it may be used to control the | |
| 2065 | + | // authentication process. | |
| 2066 | + | // | |
| 2067 | + | // This is an asynchronous failable constructor. See | |
| 2068 | + | // g_dbus_connection_new_for_address_sync() for the synchronous | |
| 2069 | + | // version. | |
| 2070 | + | func DBusConnectionNewForAddress(AddressVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2071 | + | ||
| 2072 | + | xDBusConnectionNewForAddress(AddressVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2073 | + | ||
| 2074 | + | } | |
| 2075 | + | ||
| 1966 | 2076 | // #GDBusMenuModel is an implementation of #GMenuModel that can be used | |
| 1967 | 2077 | // as a proxy for a menu model that is exported over D-Bus with | |
| 1968 | 2078 | // g_dbus_connection_export_menu_model(). | |
| @@ -1984,6 +2094,29 @@ func (c *DBusMenuModel) SetGoPointer(ptr uintptr) { | |||
| 1984 | 2094 | c.Ptr = ptr | |
| 1985 | 2095 | } | |
| 1986 | 2096 | ||
| 2097 | + | var xDBusMenuModelGet func(uintptr, string, string) uintptr | |
| 2098 | + | ||
| 2099 | + | // Obtains a #GDBusMenuModel for the menu model which is exported | |
| 2100 | + | // at the given @bus_name and @object_path. | |
| 2101 | + | // | |
| 2102 | + | // The thread default main context is taken at the time of this call. | |
| 2103 | + | // All signals on the menu model (and any linked models) are reported | |
| 2104 | + | // with respect to this context. All calls on the returned menu model | |
| 2105 | + | // (and linked models) must also originate from this same context, with | |
| 2106 | + | // the thread default main context unchanged. | |
| 2107 | + | func DBusMenuModelGet(ConnectionVar *DBusConnection, BusNameVar string, ObjectPathVar string) *DBusMenuModel { | |
| 2108 | + | var cls *DBusMenuModel | |
| 2109 | + | ||
| 2110 | + | cret := xDBusMenuModelGet(ConnectionVar.GoPointer(), BusNameVar, ObjectPathVar) | |
| 2111 | + | ||
| 2112 | + | if cret == 0 { | |
| 2113 | + | return nil | |
| 2114 | + | } | |
| 2115 | + | cls = &DBusMenuModel{} | |
| 2116 | + | cls.Ptr = cret | |
| 2117 | + | return cls | |
| 2118 | + | } | |
| 2119 | + | ||
| 1987 | 2120 | // A type for representing D-Bus messages that can be sent or received | |
| 1988 | 2121 | // on a #GDBusConnection. | |
| 1989 | 2122 | type DBusMessage struct { | |
| @@ -2614,6 +2747,21 @@ func (c *DBusMessage) SetGoPointer(ptr uintptr) { | |||
| 2614 | 2747 | c.Ptr = ptr | |
| 2615 | 2748 | } | |
| 2616 | 2749 | ||
| 2750 | + | var xDBusMessageBytesNeeded func(uintptr, uint, **glib.Error) int | |
| 2751 | + | ||
| 2752 | + | // Utility function to calculate how many bytes are needed to | |
| 2753 | + | // completely deserialize the D-Bus message stored at @blob. | |
| 2754 | + | func DBusMessageBytesNeeded(BlobVar uintptr, BlobLenVar uint) (int, error) { | |
| 2755 | + | var cerr *glib.Error | |
| 2756 | + | ||
| 2757 | + | cret := xDBusMessageBytesNeeded(BlobVar, BlobLenVar, &cerr) | |
| 2758 | + | if cerr == nil { | |
| 2759 | + | return cret, nil | |
| 2760 | + | } | |
| 2761 | + | return cret, cerr | |
| 2762 | + | ||
| 2763 | + | } | |
| 2764 | + | ||
| 2617 | 2765 | // Instances of the #GDBusMethodInvocation class are used when | |
| 2618 | 2766 | // handling D-Bus method calls. It provides a way to asynchronously | |
| 2619 | 2767 | // return results and errors. | |
| @@ -5773,6 +5921,20 @@ func (c *TestDBus) SetGoPointer(ptr uintptr) { | |||
| 5773 | 5921 | c.Ptr = ptr | |
| 5774 | 5922 | } | |
| 5775 | 5923 | ||
| 5924 | + | var xTestDBusUnset func() | |
| 5925 | + | ||
| 5926 | + | // Unset DISPLAY and DBUS_SESSION_BUS_ADDRESS env variables to ensure the test | |
| 5927 | + | // won't use user's session bus. | |
| 5928 | + | // | |
| 5929 | + | // This is useful for unit tests that want to verify behaviour when no session | |
| 5930 | + | // bus is running. It is not necessary to call this if unit test already calls | |
| 5931 | + | // g_test_dbus_up() before acquiring the session bus. | |
| 5932 | + | func TestDBusUnset() { | |
| 5933 | + | ||
| 5934 | + | xTestDBusUnset() | |
| 5935 | + | ||
| 5936 | + | } | |
| 5937 | + | ||
| 5776 | 5938 | func init() { | |
| 5777 | 5939 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 5778 | 5940 | if err != nil { | |
| @@ -5784,10 +5946,14 @@ func init() { | |||
| 5784 | 5946 | core.PuregoSafeRegister(&xTlsChannelBindingErrorQuark, lib, "g_tls_channel_binding_error_quark") | |
| 5785 | 5947 | core.PuregoSafeRegister(&xTlsErrorQuark, lib, "g_tls_error_quark") | |
| 5786 | 5948 | ||
| 5949 | + | core.PuregoSafeRegister(&xAppInfoMonitorGet, lib, "g_app_info_monitor_get") | |
| 5950 | + | ||
| 5787 | 5951 | core.PuregoSafeRegister(&xNewBytesIcon, lib, "g_bytes_icon_new") | |
| 5788 | 5952 | ||
| 5789 | 5953 | core.PuregoSafeRegister(&xBytesIconGetBytes, lib, "g_bytes_icon_get_bytes") | |
| 5790 | 5954 | ||
| 5955 | + | core.PuregoSafeRegister(&xDBusActionGroupGet, lib, "g_dbus_action_group_get") | |
| 5956 | + | ||
| 5791 | 5957 | core.PuregoSafeRegister(&xNewDBusAuthObserver, lib, "g_dbus_auth_observer_new") | |
| 5792 | 5958 | ||
| 5793 | 5959 | core.PuregoSafeRegister(&xDBusAuthObserverAllowMechanism, lib, "g_dbus_auth_observer_allow_mechanism") | |
| @@ -5840,6 +6006,11 @@ func init() { | |||
| 5840 | 6006 | core.PuregoSafeRegister(&xDBusConnectionUnregisterObject, lib, "g_dbus_connection_unregister_object") | |
| 5841 | 6007 | core.PuregoSafeRegister(&xDBusConnectionUnregisterSubtree, lib, "g_dbus_connection_unregister_subtree") | |
| 5842 | 6008 | ||
| 6009 | + | core.PuregoSafeRegister(&xDBusConnectionNew, lib, "g_dbus_connection_new") | |
| 6010 | + | core.PuregoSafeRegister(&xDBusConnectionNewForAddress, lib, "g_dbus_connection_new_for_address") | |
| 6011 | + | ||
| 6012 | + | core.PuregoSafeRegister(&xDBusMenuModelGet, lib, "g_dbus_menu_model_get") | |
| 6013 | + | ||
| 5843 | 6014 | core.PuregoSafeRegister(&xNewDBusMessage, lib, "g_dbus_message_new") | |
| 5844 | 6015 | core.PuregoSafeRegister(&xNewFromBlobDBusMessage, lib, "g_dbus_message_new_from_blob") | |
| 5845 | 6016 | core.PuregoSafeRegister(&xNewMethodCallDBusMessage, lib, "g_dbus_message_new_method_call") | |
| @@ -5890,6 +6061,8 @@ func init() { | |||
| 5890 | 6061 | core.PuregoSafeRegister(&xDBusMessageToBlob, lib, "g_dbus_message_to_blob") | |
| 5891 | 6062 | core.PuregoSafeRegister(&xDBusMessageToGerror, lib, "g_dbus_message_to_gerror") | |
| 5892 | 6063 | ||
| 6064 | + | core.PuregoSafeRegister(&xDBusMessageBytesNeeded, lib, "g_dbus_message_bytes_needed") | |
| 6065 | + | ||
| 5893 | 6066 | core.PuregoSafeRegister(&xDBusMethodInvocationGetConnection, lib, "g_dbus_method_invocation_get_connection") | |
| 5894 | 6067 | core.PuregoSafeRegister(&xDBusMethodInvocationGetInterfaceName, lib, "g_dbus_method_invocation_get_interface_name") | |
| 5895 | 6068 | core.PuregoSafeRegister(&xDBusMethodInvocationGetMessage, lib, "g_dbus_method_invocation_get_message") | |
| @@ -6040,4 +6213,6 @@ func init() { | |||
| 6040 | 6213 | core.PuregoSafeRegister(&xTestDBusStop, lib, "g_test_dbus_stop") | |
| 6041 | 6214 | core.PuregoSafeRegister(&xTestDBusUp, lib, "g_test_dbus_up") | |
| 6042 | 6215 | ||
| 6216 | + | core.PuregoSafeRegister(&xTestDBusUnset, lib, "g_test_dbus_unset") | |
| 6217 | + | ||
| 6043 | 6218 | } | |
M v4/gio/giomodule.go +74 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type IOModuleClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *IOModuleClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // Represents a scope for loading IO modules. A scope can be used for blocking | |
| 15 | 21 | // duplicate modules, or blocking a module you don't want to load. | |
| 16 | 22 | // | |
| @@ -19,6 +25,30 @@ type IOModuleClass struct { | |||
| 19 | 25 | type IOModuleScope struct { | |
| 20 | 26 | } | |
| 21 | 27 | ||
| 28 | + | func (x *IOModuleScope) GoPointer() uintptr { | |
| 29 | + | return uintptr(unsafe.Pointer(x)) | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | var xIOModuleScopeBlock func(uintptr, string) | |
| 33 | + | ||
| 34 | + | // Block modules with the given @basename from being loaded when | |
| 35 | + | // this scope is used with g_io_modules_scan_all_in_directory_with_scope() | |
| 36 | + | // or g_io_modules_load_all_in_directory_with_scope(). | |
| 37 | + | func (x *IOModuleScope) Block(BasenameVar string) { | |
| 38 | + | ||
| 39 | + | xIOModuleScopeBlock(x.GoPointer(), BasenameVar) | |
| 40 | + | ||
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xIOModuleScopeFree func(uintptr) | |
| 44 | + | ||
| 45 | + | // Free a module scope. | |
| 46 | + | func (x *IOModuleScope) Free() { | |
| 47 | + | ||
| 48 | + | xIOModuleScopeFree(x.GoPointer()) | |
| 49 | + | ||
| 50 | + | } | |
| 51 | + | ||
| 22 | 52 | var xIoExtensionPointImplement func(string, []interface{}, string, int) *IOExtension | |
| 23 | 53 | ||
| 24 | 54 | // Registers @type as extension for the extension point with name | |
| @@ -229,6 +259,45 @@ func (x *IOModule) Use() { | |||
| 229 | 259 | ||
| 230 | 260 | } | |
| 231 | 261 | ||
| 262 | + | var xIOModuleQuery func() []string | |
| 263 | + | ||
| 264 | + | // Optional API for GIO modules to implement. | |
| 265 | + | // | |
| 266 | + | // Should return a list of all the extension points that may be | |
| 267 | + | // implemented in this module. | |
| 268 | + | // | |
| 269 | + | // This method will not be called in normal use, however it may be | |
| 270 | + | // called when probing existing modules and recording which extension | |
| 271 | + | // points that this model is used for. This means we won't have to | |
| 272 | + | // load and initialize this module unless its needed. | |
| 273 | + | // | |
| 274 | + | // If this function is not implemented by the module the module will | |
| 275 | + | // always be loaded, initialized and then unloaded on application | |
| 276 | + | // startup so that it can register its extension points during init. | |
| 277 | + | // | |
| 278 | + | // Note that a module need not actually implement all the extension | |
| 279 | + | // points that g_io_module_query() returns, since the exact list of | |
| 280 | + | // extension may depend on runtime issues. However all extension | |
| 281 | + | // points actually implemented must be returned by g_io_module_query() | |
| 282 | + | // (if defined). | |
| 283 | + | // | |
| 284 | + | // When installing a module that implements g_io_module_query() you must | |
| 285 | + | // run gio-querymodules in order to build the cache files required for | |
| 286 | + | // lazy loading. | |
| 287 | + | // | |
| 288 | + | // Since 2.56, this function should be named `g_io_<modulename>_query`, where | |
| 289 | + | // `modulename` is the plugin’s filename with the `lib` or `libgio` prefix and | |
| 290 | + | // everything after the first dot removed, and with `-` replaced with `_` | |
| 291 | + | // throughout. For example, `libgiognutls-helper.so` becomes `gnutls_helper`. | |
| 292 | + | // Using the new symbol names avoids name clashes when building modules | |
| 293 | + | // statically. The old symbol names continue to be supported, but cannot be used | |
| 294 | + | // for static builds. | |
| 295 | + | func IOModuleQuery() []string { | |
| 296 | + | ||
| 297 | + | cret := xIOModuleQuery() | |
| 298 | + | return cret | |
| 299 | + | } | |
| 300 | + | ||
| 232 | 301 | func init() { | |
| 233 | 302 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 234 | 303 | if err != nil { | |
| @@ -242,9 +311,14 @@ func init() { | |||
| 242 | 311 | core.PuregoSafeRegister(&xIoModulesScanAllInDirectory, lib, "g_io_modules_scan_all_in_directory") | |
| 243 | 312 | core.PuregoSafeRegister(&xIoModulesScanAllInDirectoryWithScope, lib, "g_io_modules_scan_all_in_directory_with_scope") | |
| 244 | 313 | ||
| 314 | + | core.PuregoSafeRegister(&xIOModuleScopeBlock, lib, "g_io_module_scope_block") | |
| 315 | + | core.PuregoSafeRegister(&xIOModuleScopeFree, lib, "g_io_module_scope_free") | |
| 316 | + | ||
| 245 | 317 | core.PuregoSafeRegister(&xNewIOModule, lib, "g_io_module_new") | |
| 246 | 318 | ||
| 247 | 319 | core.PuregoSafeRegister(&xIOModuleLoad, lib, "g_io_module_load") | |
| 248 | 320 | core.PuregoSafeRegister(&xIOModuleUnload, lib, "g_io_module_unload") | |
| 249 | 321 | ||
| 322 | + | core.PuregoSafeRegister(&xIOModuleQuery, lib, "g_io_module_query") | |
| 323 | + | ||
| 250 | 324 | } | |
M v4/gio/giostream.go +26 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type IOStreamClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *IOStreamClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type IOStreamPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *IOStreamPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // GIOStream represents an object that has both read and write streams. | |
| 19 | 29 | // Generally the two streams act as separate input and output streams, | |
| 20 | 30 | // but they share some common resources and state. For instance, for | |
| @@ -251,6 +261,20 @@ func (c *IOStream) SetGoPointer(ptr uintptr) { | |||
| 251 | 261 | c.Ptr = ptr | |
| 252 | 262 | } | |
| 253 | 263 | ||
| 264 | + | var xIOStreamSpliceFinish func(uintptr, **glib.Error) bool | |
| 265 | + | ||
| 266 | + | // Finishes an asynchronous io stream splice operation. | |
| 267 | + | func IOStreamSpliceFinish(ResultVar AsyncResult) (bool, error) { | |
| 268 | + | var cerr *glib.Error | |
| 269 | + | ||
| 270 | + | cret := xIOStreamSpliceFinish(ResultVar.GoPointer(), &cerr) | |
| 271 | + | if cerr == nil { | |
| 272 | + | return cret, nil | |
| 273 | + | } | |
| 274 | + | return cret, cerr | |
| 275 | + | ||
| 276 | + | } | |
| 277 | + | ||
| 254 | 278 | func init() { | |
| 255 | 279 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 256 | 280 | if err != nil { | |
| @@ -268,4 +292,6 @@ func init() { | |||
| 268 | 292 | core.PuregoSafeRegister(&xIOStreamSetPending, lib, "g_io_stream_set_pending") | |
| 269 | 293 | core.PuregoSafeRegister(&xIOStreamSpliceAsync, lib, "g_io_stream_splice_async") | |
| 270 | 294 | ||
| 295 | + | core.PuregoSafeRegister(&xIOStreamSpliceFinish, lib, "g_io_stream_splice_finish") | |
| 296 | + | ||
| 271 | 297 | } | |
M v4/gio/giotypes.go +557 -1
| @@ -1,7 +1,14 @@ | |||
| 1 | 1 | // Package gio was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | - | import "github.com/jwijenbergh/puregotk/v4/glib" | |
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | + | ) | |
| 5 | 12 | ||
| 6 | 13 | // Type definition for a function that will be called back when an asynchronous | |
| 7 | 14 | // operation within GIO has been completed. #GAsyncReadyCallback | |
| @@ -97,23 +104,267 @@ type SocketSourceFunc func(uintptr, glib.IOCondition, uintptr) bool | |||
| 97 | 104 | type FileAttributeMatcher struct { | |
| 98 | 105 | } | |
| 99 | 106 | ||
| 107 | + | func (x *FileAttributeMatcher) GoPointer() uintptr { | |
| 108 | + | return uintptr(unsafe.Pointer(x)) | |
| 109 | + | } | |
| 110 | + | ||
| 111 | + | var xNewFileAttributeMatcher func(string) *FileAttributeMatcher | |
| 112 | + | ||
| 113 | + | // Creates a new file attribute matcher, which matches attributes | |
| 114 | + | // against a given string. #GFileAttributeMatchers are reference | |
| 115 | + | // counted structures, and are created with a reference count of 1. If | |
| 116 | + | // the number of references falls to 0, the #GFileAttributeMatcher is | |
| 117 | + | // automatically destroyed. | |
| 118 | + | // | |
| 119 | + | // The @attributes string should be formatted with specific keys separated | |
| 120 | + | // from namespaces with a double colon. Several "namespace::key" strings may be | |
| 121 | + | // concatenated with a single comma (e.g. "standard::type,standard::is-hidden"). | |
| 122 | + | // The wildcard "*" may be used to match all keys and namespaces, or | |
| 123 | + | // "namespace::*" will match all keys in a given namespace. | |
| 124 | + | // | |
| 125 | + | // ## Examples of file attribute matcher strings and results | |
| 126 | + | // | |
| 127 | + | // - `"*"`: matches all attributes. | |
| 128 | + | // - `"standard::is-hidden"`: matches only the key is-hidden in the | |
| 129 | + | // standard namespace. | |
| 130 | + | // - `"standard::type,unix::*"`: matches the type key in the standard | |
| 131 | + | // namespace and all keys in the unix namespace. | |
| 132 | + | func NewFileAttributeMatcher(AttributesVar string) *FileAttributeMatcher { | |
| 133 | + | ||
| 134 | + | cret := xNewFileAttributeMatcher(AttributesVar) | |
| 135 | + | return cret | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xFileAttributeMatcherEnumerateNamespace func(uintptr, string) bool | |
| 139 | + | ||
| 140 | + | // Checks if the matcher will match all of the keys in a given namespace. | |
| 141 | + | // This will always return %TRUE if a wildcard character is in use (e.g. if | |
| 142 | + | // matcher was created with "standard::*" and @ns is "standard", or if matcher was created | |
| 143 | + | // using "*" and namespace is anything.) | |
| 144 | + | // | |
| 145 | + | // TODO: this is awkwardly worded. | |
| 146 | + | func (x *FileAttributeMatcher) EnumerateNamespace(NsVar string) bool { | |
| 147 | + | ||
| 148 | + | cret := xFileAttributeMatcherEnumerateNamespace(x.GoPointer(), NsVar) | |
| 149 | + | return cret | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | var xFileAttributeMatcherEnumerateNext func(uintptr) string | |
| 153 | + | ||
| 154 | + | // Gets the next matched attribute from a #GFileAttributeMatcher. | |
| 155 | + | func (x *FileAttributeMatcher) EnumerateNext() string { | |
| 156 | + | ||
| 157 | + | cret := xFileAttributeMatcherEnumerateNext(x.GoPointer()) | |
| 158 | + | return cret | |
| 159 | + | } | |
| 160 | + | ||
| 161 | + | var xFileAttributeMatcherMatches func(uintptr, string) bool | |
| 162 | + | ||
| 163 | + | // Checks if an attribute will be matched by an attribute matcher. If | |
| 164 | + | // the matcher was created with the "*" matching string, this function | |
| 165 | + | // will always return %TRUE. | |
| 166 | + | func (x *FileAttributeMatcher) Matches(AttributeVar string) bool { | |
| 167 | + | ||
| 168 | + | cret := xFileAttributeMatcherMatches(x.GoPointer(), AttributeVar) | |
| 169 | + | return cret | |
| 170 | + | } | |
| 171 | + | ||
| 172 | + | var xFileAttributeMatcherMatchesOnly func(uintptr, string) bool | |
| 173 | + | ||
| 174 | + | // Checks if a attribute matcher only matches a given attribute. Always | |
| 175 | + | // returns %FALSE if "*" was used when creating the matcher. | |
| 176 | + | func (x *FileAttributeMatcher) MatchesOnly(AttributeVar string) bool { | |
| 177 | + | ||
| 178 | + | cret := xFileAttributeMatcherMatchesOnly(x.GoPointer(), AttributeVar) | |
| 179 | + | return cret | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | var xFileAttributeMatcherRef func(uintptr) *FileAttributeMatcher | |
| 183 | + | ||
| 184 | + | // References a file attribute matcher. | |
| 185 | + | func (x *FileAttributeMatcher) Ref() *FileAttributeMatcher { | |
| 186 | + | ||
| 187 | + | cret := xFileAttributeMatcherRef(x.GoPointer()) | |
| 188 | + | return cret | |
| 189 | + | } | |
| 190 | + | ||
| 191 | + | var xFileAttributeMatcherSubtract func(uintptr, *FileAttributeMatcher) *FileAttributeMatcher | |
| 192 | + | ||
| 193 | + | // Subtracts all attributes of @subtract from @matcher and returns | |
| 194 | + | // a matcher that supports those attributes. | |
| 195 | + | // | |
| 196 | + | // Note that currently it is not possible to remove a single | |
| 197 | + | // attribute when the @matcher matches the whole namespace - or remove | |
| 198 | + | // a namespace or attribute when the matcher matches everything. This | |
| 199 | + | // is a limitation of the current implementation, but may be fixed | |
| 200 | + | // in the future. | |
| 201 | + | func (x *FileAttributeMatcher) Subtract(SubtractVar *FileAttributeMatcher) *FileAttributeMatcher { | |
| 202 | + | ||
| 203 | + | cret := xFileAttributeMatcherSubtract(x.GoPointer(), SubtractVar) | |
| 204 | + | return cret | |
| 205 | + | } | |
| 206 | + | ||
| 207 | + | var xFileAttributeMatcherToString func(uintptr) string | |
| 208 | + | ||
| 209 | + | // Prints what the matcher is matching against. The format will be | |
| 210 | + | // equal to the format passed to g_file_attribute_matcher_new(). | |
| 211 | + | // The output however, might not be identical, as the matcher may | |
| 212 | + | // decide to use a different order or omit needless parts. | |
| 213 | + | func (x *FileAttributeMatcher) ToString() string { | |
| 214 | + | ||
| 215 | + | cret := xFileAttributeMatcherToString(x.GoPointer()) | |
| 216 | + | return cret | |
| 217 | + | } | |
| 218 | + | ||
| 219 | + | var xFileAttributeMatcherUnref func(uintptr) | |
| 220 | + | ||
| 221 | + | // Unreferences @matcher. If the reference count falls below 1, | |
| 222 | + | // the @matcher is automatically freed. | |
| 223 | + | func (x *FileAttributeMatcher) Unref() { | |
| 224 | + | ||
| 225 | + | xFileAttributeMatcherUnref(x.GoPointer()) | |
| 226 | + | ||
| 227 | + | } | |
| 228 | + | ||
| 100 | 229 | // #GIOExtension is an opaque data structure and can only be accessed | |
| 101 | 230 | // using the following functions. | |
| 102 | 231 | type IOExtension struct { | |
| 103 | 232 | } | |
| 104 | 233 | ||
| 234 | + | func (x *IOExtension) GoPointer() uintptr { | |
| 235 | + | return uintptr(unsafe.Pointer(x)) | |
| 236 | + | } | |
| 237 | + | ||
| 238 | + | var xIOExtensionGetName func(uintptr) string | |
| 239 | + | ||
| 240 | + | // Gets the name under which @extension was registered. | |
| 241 | + | // | |
| 242 | + | // Note that the same type may be registered as extension | |
| 243 | + | // for multiple extension points, under different names. | |
| 244 | + | func (x *IOExtension) GetName() string { | |
| 245 | + | ||
| 246 | + | cret := xIOExtensionGetName(x.GoPointer()) | |
| 247 | + | return cret | |
| 248 | + | } | |
| 249 | + | ||
| 250 | + | var xIOExtensionGetPriority func(uintptr) int | |
| 251 | + | ||
| 252 | + | // Gets the priority with which @extension was registered. | |
| 253 | + | func (x *IOExtension) GetPriority() int { | |
| 254 | + | ||
| 255 | + | cret := xIOExtensionGetPriority(x.GoPointer()) | |
| 256 | + | return cret | |
| 257 | + | } | |
| 258 | + | ||
| 259 | + | var xIOExtensionGetType func(uintptr) []interface{} | |
| 260 | + | ||
| 261 | + | // Gets the type associated with @extension. | |
| 262 | + | func (x *IOExtension) GetType() []interface{} { | |
| 263 | + | ||
| 264 | + | cret := xIOExtensionGetType(x.GoPointer()) | |
| 265 | + | return cret | |
| 266 | + | } | |
| 267 | + | ||
| 268 | + | var xIOExtensionRefClass func(uintptr) *gobject.TypeClass | |
| 269 | + | ||
| 270 | + | // Gets a reference to the class for the type that is | |
| 271 | + | // associated with @extension. | |
| 272 | + | func (x *IOExtension) RefClass() *gobject.TypeClass { | |
| 273 | + | ||
| 274 | + | cret := xIOExtensionRefClass(x.GoPointer()) | |
| 275 | + | return cret | |
| 276 | + | } | |
| 277 | + | ||
| 105 | 278 | // #GIOExtensionPoint is an opaque data structure and can only be accessed | |
| 106 | 279 | // using the following functions. | |
| 107 | 280 | type IOExtensionPoint struct { | |
| 108 | 281 | } | |
| 109 | 282 | ||
| 283 | + | func (x *IOExtensionPoint) GoPointer() uintptr { | |
| 284 | + | return uintptr(unsafe.Pointer(x)) | |
| 285 | + | } | |
| 286 | + | ||
| 287 | + | var xIOExtensionPointGetExtensionByName func(uintptr, string) *IOExtension | |
| 288 | + | ||
| 289 | + | // Finds a #GIOExtension for an extension point by name. | |
| 290 | + | func (x *IOExtensionPoint) GetExtensionByName(NameVar string) *IOExtension { | |
| 291 | + | ||
| 292 | + | cret := xIOExtensionPointGetExtensionByName(x.GoPointer(), NameVar) | |
| 293 | + | return cret | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | var xIOExtensionPointGetExtensions func(uintptr) *glib.List | |
| 297 | + | ||
| 298 | + | // Gets a list of all extensions that implement this extension point. | |
| 299 | + | // The list is sorted by priority, beginning with the highest priority. | |
| 300 | + | func (x *IOExtensionPoint) GetExtensions() *glib.List { | |
| 301 | + | ||
| 302 | + | cret := xIOExtensionPointGetExtensions(x.GoPointer()) | |
| 303 | + | return cret | |
| 304 | + | } | |
| 305 | + | ||
| 306 | + | var xIOExtensionPointGetRequiredType func(uintptr) []interface{} | |
| 307 | + | ||
| 308 | + | // Gets the required type for @extension_point. | |
| 309 | + | func (x *IOExtensionPoint) GetRequiredType() []interface{} { | |
| 310 | + | ||
| 311 | + | cret := xIOExtensionPointGetRequiredType(x.GoPointer()) | |
| 312 | + | return cret | |
| 313 | + | } | |
| 314 | + | ||
| 315 | + | var xIOExtensionPointSetRequiredType func(uintptr, []interface{}) | |
| 316 | + | ||
| 317 | + | // Sets the required type for @extension_point to @type. | |
| 318 | + | // All implementations must henceforth have this type. | |
| 319 | + | func (x *IOExtensionPoint) SetRequiredType(TypeVar []interface{}) { | |
| 320 | + | ||
| 321 | + | xIOExtensionPointSetRequiredType(x.GoPointer(), TypeVar) | |
| 322 | + | ||
| 323 | + | } | |
| 324 | + | ||
| 110 | 325 | // Opaque class for defining and scheduling IO jobs. | |
| 111 | 326 | type IOSchedulerJob struct { | |
| 112 | 327 | } | |
| 113 | 328 | ||
| 329 | + | func (x *IOSchedulerJob) GoPointer() uintptr { | |
| 330 | + | return uintptr(unsafe.Pointer(x)) | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | var xIOSchedulerJobSendToMainloop func(uintptr, uintptr, uintptr, uintptr) bool | |
| 334 | + | ||
| 335 | + | // Used from an I/O job to send a callback to be run in the thread | |
| 336 | + | // that the job was started from, waiting for the result (and thus | |
| 337 | + | // blocking the I/O job). | |
| 338 | + | func (x *IOSchedulerJob) SendToMainloop(FuncVar glib.SourceFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify) bool { | |
| 339 | + | ||
| 340 | + | cret := xIOSchedulerJobSendToMainloop(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 341 | + | return cret | |
| 342 | + | } | |
| 343 | + | ||
| 344 | + | var xIOSchedulerJobSendToMainloopAsync func(uintptr, uintptr, uintptr, uintptr) | |
| 345 | + | ||
| 346 | + | // Used from an I/O job to send a callback to be run asynchronously in | |
| 347 | + | // the thread that the job was started from. The callback will be run | |
| 348 | + | // when the main loop is available, but at that time the I/O job might | |
| 349 | + | // have finished. The return value from the callback is ignored. | |
| 350 | + | // | |
| 351 | + | // Note that if you are passing the @user_data from g_io_scheduler_push_job() | |
| 352 | + | // on to this function you have to ensure that it is not freed before | |
| 353 | + | // @func is called, either by passing %NULL as @notify to | |
| 354 | + | // g_io_scheduler_push_job() or by using refcounting for @user_data. | |
| 355 | + | func (x *IOSchedulerJob) SendToMainloopAsync(FuncVar glib.SourceFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 356 | + | ||
| 357 | + | xIOSchedulerJobSendToMainloopAsync(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 358 | + | ||
| 359 | + | } | |
| 360 | + | ||
| 114 | 361 | type IOStreamAdapter struct { | |
| 115 | 362 | } | |
| 116 | 363 | ||
| 364 | + | func (x *IOStreamAdapter) GoPointer() uintptr { | |
| 365 | + | return uintptr(unsafe.Pointer(x)) | |
| 366 | + | } | |
| 367 | + | ||
| 117 | 368 | // Structure used for scatter/gather data input when receiving multiple | |
| 118 | 369 | // messages or packets in one go. You generally pass in an array of empty | |
| 119 | 370 | // #GInputVectors and the operation will use all the buffers as if they | |
| @@ -149,6 +400,10 @@ type InputMessage struct { | |||
| 149 | 400 | NumControlMessages uint | |
| 150 | 401 | } | |
| 151 | 402 | ||
| 403 | + | func (x *InputMessage) GoPointer() uintptr { | |
| 404 | + | return uintptr(unsafe.Pointer(x)) | |
| 405 | + | } | |
| 406 | + | ||
| 152 | 407 | // Structure used for scatter/gather data input. | |
| 153 | 408 | // You generally pass in an array of #GInputVectors | |
| 154 | 409 | // and the operation will store the read data starting in the | |
| @@ -159,6 +414,10 @@ type InputVector struct { | |||
| 159 | 414 | Size uint | |
| 160 | 415 | } | |
| 161 | 416 | ||
| 417 | + | func (x *InputVector) GoPointer() uintptr { | |
| 418 | + | return uintptr(unsafe.Pointer(x)) | |
| 419 | + | } | |
| 420 | + | ||
| 162 | 421 | // Structure used for scatter/gather data output when sending multiple | |
| 163 | 422 | // messages or packets in one go. You generally pass in an array of | |
| 164 | 423 | // #GOutputVectors and the operation will use all the buffers as if they | |
| @@ -180,6 +439,10 @@ type OutputMessage struct { | |||
| 180 | 439 | NumControlMessages uint | |
| 181 | 440 | } | |
| 182 | 441 | ||
| 442 | + | func (x *OutputMessage) GoPointer() uintptr { | |
| 443 | + | return uintptr(unsafe.Pointer(x)) | |
| 444 | + | } | |
| 445 | + | ||
| 183 | 446 | // Structure used for scatter/gather data output. | |
| 184 | 447 | // You generally pass in an array of #GOutputVectors | |
| 185 | 448 | // and the operation will use all the buffers as if they were | |
| @@ -190,6 +453,10 @@ type OutputVector struct { | |||
| 190 | 453 | Size uint | |
| 191 | 454 | } | |
| 192 | 455 | ||
| 456 | + | func (x *OutputVector) GoPointer() uintptr { | |
| 457 | + | return uintptr(unsafe.Pointer(x)) | |
| 458 | + | } | |
| 459 | + | ||
| 193 | 460 | // Applications and libraries often contain binary or textual data that is | |
| 194 | 461 | // really part of the application, rather than user data. For instance | |
| 195 | 462 | // #GtkBuilder .ui files, splashscreen images, GMenu markup XML, CSS files, | |
| @@ -333,6 +600,166 @@ type OutputVector struct { | |||
| 333 | 600 | type Resource struct { | |
| 334 | 601 | } | |
| 335 | 602 | ||
| 603 | + | func (x *Resource) GoPointer() uintptr { | |
| 604 | + | return uintptr(unsafe.Pointer(x)) | |
| 605 | + | } | |
| 606 | + | ||
| 607 | + | var xNewFromDataResource func(*glib.Bytes, **glib.Error) *Resource | |
| 608 | + | ||
| 609 | + | // Creates a GResource from a reference to the binary resource bundle. | |
| 610 | + | // This will keep a reference to @data while the resource lives, so | |
| 611 | + | // the data should not be modified or freed. | |
| 612 | + | // | |
| 613 | + | // If you want to use this resource in the global resource namespace you need | |
| 614 | + | // to register it with g_resources_register(). | |
| 615 | + | // | |
| 616 | + | // Note: @data must be backed by memory that is at least pointer aligned. | |
| 617 | + | // Otherwise this function will internally create a copy of the memory since | |
| 618 | + | // GLib 2.56, or in older versions fail and exit the process. | |
| 619 | + | // | |
| 620 | + | // If @data is empty or corrupt, %G_RESOURCE_ERROR_INTERNAL will be returned. | |
| 621 | + | func NewFromDataResource(DataVar *glib.Bytes) (*Resource, error) { | |
| 622 | + | var cerr *glib.Error | |
| 623 | + | ||
| 624 | + | cret := xNewFromDataResource(DataVar, &cerr) | |
| 625 | + | if cerr == nil { | |
| 626 | + | return cret, nil | |
| 627 | + | } | |
| 628 | + | return cret, cerr | |
| 629 | + | ||
| 630 | + | } | |
| 631 | + | ||
| 632 | + | var xResourceRegister func(uintptr) | |
| 633 | + | ||
| 634 | + | // Registers the resource with the process-global set of resources. | |
| 635 | + | // Once a resource is registered the files in it can be accessed | |
| 636 | + | // with the global resource lookup functions like g_resources_lookup_data(). | |
| 637 | + | func (x *Resource) Register() { | |
| 638 | + | ||
| 639 | + | xResourceRegister(x.GoPointer()) | |
| 640 | + | ||
| 641 | + | } | |
| 642 | + | ||
| 643 | + | var xResourceUnregister func(uintptr) | |
| 644 | + | ||
| 645 | + | // Unregisters the resource from the process-global set of resources. | |
| 646 | + | func (x *Resource) Unregister() { | |
| 647 | + | ||
| 648 | + | xResourceUnregister(x.GoPointer()) | |
| 649 | + | ||
| 650 | + | } | |
| 651 | + | ||
| 652 | + | var xResourceEnumerateChildren func(uintptr, string, ResourceLookupFlags, **glib.Error) []string | |
| 653 | + | ||
| 654 | + | // Returns all the names of children at the specified @path in the resource. | |
| 655 | + | // The return result is a %NULL terminated list of strings which should | |
| 656 | + | // be released with g_strfreev(). | |
| 657 | + | // | |
| 658 | + | // If @path is invalid or does not exist in the #GResource, | |
| 659 | + | // %G_RESOURCE_ERROR_NOT_FOUND will be returned. | |
| 660 | + | // | |
| 661 | + | // @lookup_flags controls the behaviour of the lookup. | |
| 662 | + | func (x *Resource) EnumerateChildren(PathVar string, LookupFlagsVar ResourceLookupFlags) ([]string, error) { | |
| 663 | + | var cerr *glib.Error | |
| 664 | + | ||
| 665 | + | cret := xResourceEnumerateChildren(x.GoPointer(), PathVar, LookupFlagsVar, &cerr) | |
| 666 | + | if cerr == nil { | |
| 667 | + | return cret, nil | |
| 668 | + | } | |
| 669 | + | return cret, cerr | |
| 670 | + | ||
| 671 | + | } | |
| 672 | + | ||
| 673 | + | var xResourceGetInfo func(uintptr, string, ResourceLookupFlags, uint, uint32, **glib.Error) bool | |
| 674 | + | ||
| 675 | + | // Looks for a file at the specified @path in the resource and | |
| 676 | + | // if found returns information about it. | |
| 677 | + | // | |
| 678 | + | // @lookup_flags controls the behaviour of the lookup. | |
| 679 | + | func (x *Resource) GetInfo(PathVar string, LookupFlagsVar ResourceLookupFlags, SizeVar uint, FlagsVar uint32) (bool, error) { | |
| 680 | + | var cerr *glib.Error | |
| 681 | + | ||
| 682 | + | cret := xResourceGetInfo(x.GoPointer(), PathVar, LookupFlagsVar, SizeVar, FlagsVar, &cerr) | |
| 683 | + | if cerr == nil { | |
| 684 | + | return cret, nil | |
| 685 | + | } | |
| 686 | + | return cret, cerr | |
| 687 | + | ||
| 688 | + | } | |
| 689 | + | ||
| 690 | + | var xResourceLookupData func(uintptr, string, ResourceLookupFlags, **glib.Error) *glib.Bytes | |
| 691 | + | ||
| 692 | + | // Looks for a file at the specified @path in the resource and | |
| 693 | + | // returns a #GBytes that lets you directly access the data in | |
| 694 | + | // memory. | |
| 695 | + | // | |
| 696 | + | // The data is always followed by a zero byte, so you | |
| 697 | + | // can safely use the data as a C string. However, that byte | |
| 698 | + | // is not included in the size of the GBytes. | |
| 699 | + | // | |
| 700 | + | // For uncompressed resource files this is a pointer directly into | |
| 701 | + | // the resource bundle, which is typically in some readonly data section | |
| 702 | + | // in the program binary. For compressed files we allocate memory on | |
| 703 | + | // the heap and automatically uncompress the data. | |
| 704 | + | // | |
| 705 | + | // @lookup_flags controls the behaviour of the lookup. | |
| 706 | + | func (x *Resource) LookupData(PathVar string, LookupFlagsVar ResourceLookupFlags) (*glib.Bytes, error) { | |
| 707 | + | var cerr *glib.Error | |
| 708 | + | ||
| 709 | + | cret := xResourceLookupData(x.GoPointer(), PathVar, LookupFlagsVar, &cerr) | |
| 710 | + | if cerr == nil { | |
| 711 | + | return cret, nil | |
| 712 | + | } | |
| 713 | + | return cret, cerr | |
| 714 | + | ||
| 715 | + | } | |
| 716 | + | ||
| 717 | + | var xResourceOpenStream func(uintptr, string, ResourceLookupFlags, **glib.Error) uintptr | |
| 718 | + | ||
| 719 | + | // Looks for a file at the specified @path in the resource and | |
| 720 | + | // returns a #GInputStream that lets you read the data. | |
| 721 | + | // | |
| 722 | + | // @lookup_flags controls the behaviour of the lookup. | |
| 723 | + | func (x *Resource) OpenStream(PathVar string, LookupFlagsVar ResourceLookupFlags) (*InputStream, error) { | |
| 724 | + | var cls *InputStream | |
| 725 | + | var cerr *glib.Error | |
| 726 | + | ||
| 727 | + | cret := xResourceOpenStream(x.GoPointer(), PathVar, LookupFlagsVar, &cerr) | |
| 728 | + | ||
| 729 | + | if cret == 0 { | |
| 730 | + | return nil, cerr | |
| 731 | + | } | |
| 732 | + | cls = &InputStream{} | |
| 733 | + | cls.Ptr = cret | |
| 734 | + | if cerr == nil { | |
| 735 | + | return cls, nil | |
| 736 | + | } | |
| 737 | + | return cls, cerr | |
| 738 | + | ||
| 739 | + | } | |
| 740 | + | ||
| 741 | + | var xResourceRef func(uintptr) *Resource | |
| 742 | + | ||
| 743 | + | // Atomically increments the reference count of @resource by one. This | |
| 744 | + | // function is MT-safe and may be called from any thread. | |
| 745 | + | func (x *Resource) Ref() *Resource { | |
| 746 | + | ||
| 747 | + | cret := xResourceRef(x.GoPointer()) | |
| 748 | + | return cret | |
| 749 | + | } | |
| 750 | + | ||
| 751 | + | var xResourceUnref func(uintptr) | |
| 752 | + | ||
| 753 | + | // Atomically decrements the reference count of @resource by one. If the | |
| 754 | + | // reference count drops to 0, all memory allocated by the resource is | |
| 755 | + | // released. This function is MT-safe and may be called from any | |
| 756 | + | // thread. | |
| 757 | + | func (x *Resource) Unref() { | |
| 758 | + | ||
| 759 | + | xResourceUnref(x.GoPointer()) | |
| 760 | + | ||
| 761 | + | } | |
| 762 | + | ||
| 336 | 763 | // SRV (service) records are used by some network protocols to provide | |
| 337 | 764 | // service-specific aliasing and load-balancing. For example, XMPP | |
| 338 | 765 | // (Jabber) uses SRV records to locate the XMPP server for a domain; | |
| @@ -349,3 +776,132 @@ type Resource struct { | |||
| 349 | 776 | // #GSrvTarget at all. | |
| 350 | 777 | type SrvTarget struct { | |
| 351 | 778 | } | |
| 779 | + | ||
| 780 | + | func (x *SrvTarget) GoPointer() uintptr { | |
| 781 | + | return uintptr(unsafe.Pointer(x)) | |
| 782 | + | } | |
| 783 | + | ||
| 784 | + | var xNewSrvTarget func(string, uint16, uint16, uint16) *SrvTarget | |
| 785 | + | ||
| 786 | + | // Creates a new #GSrvTarget with the given parameters. | |
| 787 | + | // | |
| 788 | + | // You should not need to use this; normally #GSrvTargets are | |
| 789 | + | // created by #GResolver. | |
| 790 | + | func NewSrvTarget(HostnameVar string, PortVar uint16, PriorityVar uint16, WeightVar uint16) *SrvTarget { | |
| 791 | + | ||
| 792 | + | cret := xNewSrvTarget(HostnameVar, PortVar, PriorityVar, WeightVar) | |
| 793 | + | return cret | |
| 794 | + | } | |
| 795 | + | ||
| 796 | + | var xSrvTargetCopy func(uintptr) *SrvTarget | |
| 797 | + | ||
| 798 | + | // Copies @target | |
| 799 | + | func (x *SrvTarget) Copy() *SrvTarget { | |
| 800 | + | ||
| 801 | + | cret := xSrvTargetCopy(x.GoPointer()) | |
| 802 | + | return cret | |
| 803 | + | } | |
| 804 | + | ||
| 805 | + | var xSrvTargetFree func(uintptr) | |
| 806 | + | ||
| 807 | + | // Frees @target | |
| 808 | + | func (x *SrvTarget) Free() { | |
| 809 | + | ||
| 810 | + | xSrvTargetFree(x.GoPointer()) | |
| 811 | + | ||
| 812 | + | } | |
| 813 | + | ||
| 814 | + | var xSrvTargetGetHostname func(uintptr) string | |
| 815 | + | ||
| 816 | + | // Gets @target's hostname (in ASCII form; if you are going to present | |
| 817 | + | // this to the user, you should use g_hostname_is_ascii_encoded() to | |
| 818 | + | // check if it contains encoded Unicode segments, and use | |
| 819 | + | // g_hostname_to_unicode() to convert it if it does.) | |
| 820 | + | func (x *SrvTarget) GetHostname() string { | |
| 821 | + | ||
| 822 | + | cret := xSrvTargetGetHostname(x.GoPointer()) | |
| 823 | + | return cret | |
| 824 | + | } | |
| 825 | + | ||
| 826 | + | var xSrvTargetGetPort func(uintptr) uint16 | |
| 827 | + | ||
| 828 | + | // Gets @target's port | |
| 829 | + | func (x *SrvTarget) GetPort() uint16 { | |
| 830 | + | ||
| 831 | + | cret := xSrvTargetGetPort(x.GoPointer()) | |
| 832 | + | return cret | |
| 833 | + | } | |
| 834 | + | ||
| 835 | + | var xSrvTargetGetPriority func(uintptr) uint16 | |
| 836 | + | ||
| 837 | + | // Gets @target's priority. You should not need to look at this; | |
| 838 | + | // #GResolver already sorts the targets according to the algorithm in | |
| 839 | + | // RFC 2782. | |
| 840 | + | func (x *SrvTarget) GetPriority() uint16 { | |
| 841 | + | ||
| 842 | + | cret := xSrvTargetGetPriority(x.GoPointer()) | |
| 843 | + | return cret | |
| 844 | + | } | |
| 845 | + | ||
| 846 | + | var xSrvTargetGetWeight func(uintptr) uint16 | |
| 847 | + | ||
| 848 | + | // Gets @target's weight. You should not need to look at this; | |
| 849 | + | // #GResolver already sorts the targets according to the algorithm in | |
| 850 | + | // RFC 2782. | |
| 851 | + | func (x *SrvTarget) GetWeight() uint16 { | |
| 852 | + | ||
| 853 | + | cret := xSrvTargetGetWeight(x.GoPointer()) | |
| 854 | + | return cret | |
| 855 | + | } | |
| 856 | + | ||
| 857 | + | func init() { | |
| 858 | + | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 859 | + | if err != nil { | |
| 860 | + | panic(err) | |
| 861 | + | } | |
| 862 | + | ||
| 863 | + | core.PuregoSafeRegister(&xNewFileAttributeMatcher, lib, "g_file_attribute_matcher_new") | |
| 864 | + | ||
| 865 | + | core.PuregoSafeRegister(&xFileAttributeMatcherEnumerateNamespace, lib, "g_file_attribute_matcher_enumerate_namespace") | |
| 866 | + | core.PuregoSafeRegister(&xFileAttributeMatcherEnumerateNext, lib, "g_file_attribute_matcher_enumerate_next") | |
| 867 | + | core.PuregoSafeRegister(&xFileAttributeMatcherMatches, lib, "g_file_attribute_matcher_matches") | |
| 868 | + | core.PuregoSafeRegister(&xFileAttributeMatcherMatchesOnly, lib, "g_file_attribute_matcher_matches_only") | |
| 869 | + | core.PuregoSafeRegister(&xFileAttributeMatcherRef, lib, "g_file_attribute_matcher_ref") | |
| 870 | + | core.PuregoSafeRegister(&xFileAttributeMatcherSubtract, lib, "g_file_attribute_matcher_subtract") | |
| 871 | + | core.PuregoSafeRegister(&xFileAttributeMatcherToString, lib, "g_file_attribute_matcher_to_string") | |
| 872 | + | core.PuregoSafeRegister(&xFileAttributeMatcherUnref, lib, "g_file_attribute_matcher_unref") | |
| 873 | + | ||
| 874 | + | core.PuregoSafeRegister(&xIOExtensionGetName, lib, "g_io_extension_get_name") | |
| 875 | + | core.PuregoSafeRegister(&xIOExtensionGetPriority, lib, "g_io_extension_get_priority") | |
| 876 | + | core.PuregoSafeRegister(&xIOExtensionGetType, lib, "g_io_extension_get_type") | |
| 877 | + | core.PuregoSafeRegister(&xIOExtensionRefClass, lib, "g_io_extension_ref_class") | |
| 878 | + | ||
| 879 | + | core.PuregoSafeRegister(&xIOExtensionPointGetExtensionByName, lib, "g_io_extension_point_get_extension_by_name") | |
| 880 | + | core.PuregoSafeRegister(&xIOExtensionPointGetExtensions, lib, "g_io_extension_point_get_extensions") | |
| 881 | + | core.PuregoSafeRegister(&xIOExtensionPointGetRequiredType, lib, "g_io_extension_point_get_required_type") | |
| 882 | + | core.PuregoSafeRegister(&xIOExtensionPointSetRequiredType, lib, "g_io_extension_point_set_required_type") | |
| 883 | + | ||
| 884 | + | core.PuregoSafeRegister(&xIOSchedulerJobSendToMainloop, lib, "g_io_scheduler_job_send_to_mainloop") | |
| 885 | + | core.PuregoSafeRegister(&xIOSchedulerJobSendToMainloopAsync, lib, "g_io_scheduler_job_send_to_mainloop_async") | |
| 886 | + | ||
| 887 | + | core.PuregoSafeRegister(&xNewFromDataResource, lib, "g_resource_new_from_data") | |
| 888 | + | ||
| 889 | + | core.PuregoSafeRegister(&xResourceRegister, lib, "g_resources_register") | |
| 890 | + | core.PuregoSafeRegister(&xResourceUnregister, lib, "g_resources_unregister") | |
| 891 | + | core.PuregoSafeRegister(&xResourceEnumerateChildren, lib, "g_resource_enumerate_children") | |
| 892 | + | core.PuregoSafeRegister(&xResourceGetInfo, lib, "g_resource_get_info") | |
| 893 | + | core.PuregoSafeRegister(&xResourceLookupData, lib, "g_resource_lookup_data") | |
| 894 | + | core.PuregoSafeRegister(&xResourceOpenStream, lib, "g_resource_open_stream") | |
| 895 | + | core.PuregoSafeRegister(&xResourceRef, lib, "g_resource_ref") | |
| 896 | + | core.PuregoSafeRegister(&xResourceUnref, lib, "g_resource_unref") | |
| 897 | + | ||
| 898 | + | core.PuregoSafeRegister(&xNewSrvTarget, lib, "g_srv_target_new") | |
| 899 | + | ||
| 900 | + | core.PuregoSafeRegister(&xSrvTargetCopy, lib, "g_srv_target_copy") | |
| 901 | + | core.PuregoSafeRegister(&xSrvTargetFree, lib, "g_srv_target_free") | |
| 902 | + | core.PuregoSafeRegister(&xSrvTargetGetHostname, lib, "g_srv_target_get_hostname") | |
| 903 | + | core.PuregoSafeRegister(&xSrvTargetGetPort, lib, "g_srv_target_get_port") | |
| 904 | + | core.PuregoSafeRegister(&xSrvTargetGetPriority, lib, "g_srv_target_get_priority") | |
| 905 | + | core.PuregoSafeRegister(&xSrvTargetGetWeight, lib, "g_srv_target_get_weight") | |
| 906 | + | ||
| 907 | + | } | |
M v4/gio/glistmodel.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type ListModelInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ListModelInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GListModel is an interface that represents a mutable list of | |
| 16 | 22 | // #GObjects. Its main intention is as a model for various widgets in | |
| 17 | 23 | // user interfaces, such as list views, but it can also be used as a | |
M v4/gio/gliststore.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ListStoreClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ListStoreClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GListStore is a simple implementation of #GListModel that stores all | |
| 16 | 22 | // items in memory. | |
| 17 | 23 | // | |
M v4/gio/gloadableicon.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type LoadableIconIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *LoadableIconIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Extends the #GIcon interface and adds the ability to | |
| 16 | 22 | // load icons from streams. | |
| 17 | 23 | type LoadableIcon interface { | |
M v4/gio/gmemoryinputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type MemoryInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *MemoryInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type MemoryInputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *MemoryInputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // #GMemoryInputStream is a class for using arbitrary | |
| 18 | 28 | // memory chunks as input for GIO streaming input operations. | |
| 19 | 29 | // | |
M v4/gio/gmemorymonitor.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,10 @@ type MemoryMonitorInterface struct { | |||
| 11 | 13 | GIface uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *MemoryMonitorInterface) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GMemoryMonitor will monitor system memory and suggest to the application | |
| 15 | 21 | // when to free memory so as to leave more room for other applications. | |
| 16 | 22 | // It is implemented on Linux using the [Low Memory Monitor](https://gitlab.freedesktop.org/hadess/low-memory-monitor/) | |
| @@ -76,6 +82,12 @@ func (x *MemoryMonitorBase) SetGoPointer(ptr uintptr) { | |||
| 76 | 82 | x.Ptr = ptr | |
| 77 | 83 | } | |
| 78 | 84 | ||
| 85 | + | const ( | |
| 86 | + | // Extension point for memory usage monitoring functionality. | |
| 87 | + | // See [Extending GIO][extending-gio]. | |
| 88 | + | MEMORY_MONITOR_EXTENSION_POINT_NAME string = "gio-memory-monitor" | |
| 89 | + | ) | |
| 90 | + | ||
| 79 | 91 | var xMemoryMonitorDupDefault func() uintptr | |
| 80 | 92 | ||
| 81 | 93 | // Gets a reference to the default #GMemoryMonitor for the system. | |
M v4/gio/gmemoryoutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -17,9 +19,17 @@ type MemoryOutputStreamClass struct { | |||
| 17 | 19 | ParentClass uintptr | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *MemoryOutputStreamClass) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 20 | 26 | type MemoryOutputStreamPrivate struct { | |
| 21 | 27 | } | |
| 22 | 28 | ||
| 29 | + | func (x *MemoryOutputStreamPrivate) GoPointer() uintptr { | |
| 30 | + | return uintptr(unsafe.Pointer(x)) | |
| 31 | + | } | |
| 32 | + | ||
| 23 | 33 | // #GMemoryOutputStream is a class for using arbitrary | |
| 24 | 34 | // memory chunks as output for GIO streaming output operations. | |
| 25 | 35 | // | |
M v4/gio/gmenumodel.go +64 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,23 +14,85 @@ type MenuAttributeIterClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *MenuAttributeIterClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type MenuAttributeIterPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *MenuAttributeIterPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | type MenuLinkIterClass struct { | |
| 19 | 29 | ParentClass uintptr | |
| 20 | 30 | } | |
| 21 | 31 | ||
| 32 | + | func (x *MenuLinkIterClass) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 22 | 36 | type MenuLinkIterPrivate struct { | |
| 23 | 37 | } | |
| 24 | 38 | ||
| 39 | + | func (x *MenuLinkIterPrivate) GoPointer() uintptr { | |
| 40 | + | return uintptr(unsafe.Pointer(x)) | |
| 41 | + | } | |
| 42 | + | ||
| 25 | 43 | type MenuModelClass struct { | |
| 26 | 44 | ParentClass uintptr | |
| 27 | 45 | } | |
| 28 | 46 | ||
| 47 | + | func (x *MenuModelClass) GoPointer() uintptr { | |
| 48 | + | return uintptr(unsafe.Pointer(x)) | |
| 49 | + | } | |
| 50 | + | ||
| 29 | 51 | type MenuModelPrivate struct { | |
| 30 | 52 | } | |
| 31 | 53 | ||
| 54 | + | func (x *MenuModelPrivate) GoPointer() uintptr { | |
| 55 | + | return uintptr(unsafe.Pointer(x)) | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | const ( | |
| 59 | + | // The menu item attribute which holds the action name of the item. Action | |
| 60 | + | // names are namespaced with an identifier for the action group in which the | |
| 61 | + | // action resides. For example, "win." for window-specific actions and "app." | |
| 62 | + | // for application-wide actions. | |
| 63 | + | // | |
| 64 | + | // See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute(). | |
| 65 | + | MENU_ATTRIBUTE_ACTION string = "action" | |
| 66 | + | // The menu item attribute that holds the namespace for all action names in | |
| 67 | + | // menus that are linked from this item. | |
| 68 | + | MENU_ATTRIBUTE_ACTION_NAMESPACE string = "action-namespace" | |
| 69 | + | // The menu item attribute which holds the icon of the item. | |
| 70 | + | // | |
| 71 | + | // The icon is stored in the format returned by g_icon_serialize(). | |
| 72 | + | // | |
| 73 | + | // This attribute is intended only to represent 'noun' icons such as | |
| 74 | + | // favicons for a webpage, or application icons. It should not be used | |
| 75 | + | // for 'verbs' (ie: stock icons). | |
| 76 | + | MENU_ATTRIBUTE_ICON string = "icon" | |
| 77 | + | // The menu item attribute which holds the label of the item. | |
| 78 | + | MENU_ATTRIBUTE_LABEL string = "label" | |
| 79 | + | // The menu item attribute which holds the target with which the item's action | |
| 80 | + | // will be activated. | |
| 81 | + | // | |
| 82 | + | // See also g_menu_item_set_action_and_target() | |
| 83 | + | MENU_ATTRIBUTE_TARGET string = "target" | |
| 84 | + | // The name of the link that associates a menu item with a section. The linked | |
| 85 | + | // menu will usually be shown in place of the menu item, using the item's label | |
| 86 | + | // as a header. | |
| 87 | + | // | |
| 88 | + | // See also g_menu_item_set_link(). | |
| 89 | + | MENU_LINK_SECTION string = "section" | |
| 90 | + | // The name of the link that associates a menu item with a submenu. | |
| 91 | + | // | |
| 92 | + | // See also g_menu_item_set_link(). | |
| 93 | + | MENU_LINK_SUBMENU string = "submenu" | |
| 94 | + | ) | |
| 95 | + | ||
| 32 | 96 | // #GMenuAttributeIter is an opaque structure type. You must access it | |
| 33 | 97 | // using the functions below. | |
| 34 | 98 | type MenuAttributeIter struct { | |
M v4/gio/gmount.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type MountIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *MountIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GMount interface represents user-visible mounts. Note, when | |
| 16 | 22 | // porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume. | |
| 17 | 23 | // | |
M v4/gio/gmountoperation.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type MountOperationClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *MountOperationClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type MountOperationPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *MountOperationPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // #GMountOperation provides a mechanism for interacting with the user. | |
| 18 | 28 | // It can be used for authenticating mountable operations, such as loop | |
| 19 | 29 | // mounting files, hard drive partitions or server locations. It can | |
M v4/gio/gnativesocketaddress.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -10,9 +12,17 @@ type NativeSocketAddressClass struct { | |||
| 10 | 12 | ParentClass uintptr | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *NativeSocketAddressClass) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | type NativeSocketAddressPrivate struct { | |
| 14 | 20 | } | |
| 15 | 21 | ||
| 22 | + | func (x *NativeSocketAddressPrivate) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 16 | 26 | // A socket address of some unknown native type. | |
| 17 | 27 | type NativeSocketAddress struct { | |
| 18 | 28 | SocketAddress | |
M v4/gio/gnativevolumemonitor.go +10 -0
| @@ -1,10 +1,20 @@ | |||
| 1 | 1 | // Package gio was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | + | import "unsafe" | |
| 5 | + | ||
| 4 | 6 | type NativeVolumeMonitorClass struct { | |
| 5 | 7 | ParentClass uintptr | |
| 6 | 8 | } | |
| 7 | 9 | ||
| 10 | + | func (x *NativeVolumeMonitorClass) GoPointer() uintptr { | |
| 11 | + | return uintptr(unsafe.Pointer(x)) | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | const ( | |
| 15 | + | NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME string = "gio-native-volume-monitor" | |
| 16 | + | ) | |
| 17 | + | ||
| 8 | 18 | type NativeVolumeMonitor struct { | |
| 9 | 19 | VolumeMonitor | |
| 10 | 20 | } | |
M v4/gio/gnetworkaddress.go +81 -0
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -11,9 +14,17 @@ type NetworkAddressClass struct { | |||
| 11 | 14 | ParentClass uintptr | |
| 12 | 15 | } | |
| 13 | 16 | ||
| 17 | + | func (x *NetworkAddressClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 14 | 21 | type NetworkAddressPrivate struct { | |
| 15 | 22 | } | |
| 16 | 23 | ||
| 24 | + | func (x *NetworkAddressPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 17 | 28 | // #GNetworkAddress provides an easy way to resolve a hostname and | |
| 18 | 29 | // then attempt to connect to that host, handling the possibility of | |
| 19 | 30 | // multiple IP addresses and multiple address families. | |
| @@ -167,6 +178,73 @@ func (x *NetworkAddress) ToString() string { | |||
| 167 | 178 | return cret | |
| 168 | 179 | } | |
| 169 | 180 | ||
| 181 | + | var xNetworkAddressParse func(string, uint16, **glib.Error) uintptr | |
| 182 | + | ||
| 183 | + | // Creates a new #GSocketConnectable for connecting to the given | |
| 184 | + | // @hostname and @port. May fail and return %NULL in case | |
| 185 | + | // parsing @host_and_port fails. | |
| 186 | + | // | |
| 187 | + | // @host_and_port may be in any of a number of recognised formats; an IPv6 | |
| 188 | + | // address, an IPv4 address, or a domain name (in which case a DNS | |
| 189 | + | // lookup is performed). Quoting with [] is supported for all address | |
| 190 | + | // types. A port override may be specified in the usual way with a | |
| 191 | + | // colon. | |
| 192 | + | // | |
| 193 | + | // If no port is specified in @host_and_port then @default_port will be | |
| 194 | + | // used as the port number to connect to. | |
| 195 | + | // | |
| 196 | + | // In general, @host_and_port is expected to be provided by the user | |
| 197 | + | // (allowing them to give the hostname, and a port override if necessary) | |
| 198 | + | // and @default_port is expected to be provided by the application. | |
| 199 | + | // | |
| 200 | + | // (The port component of @host_and_port can also be specified as a | |
| 201 | + | // service name rather than as a numeric port, but this functionality | |
| 202 | + | // is deprecated, because it depends on the contents of /etc/services, | |
| 203 | + | // which is generally quite sparse on platforms other than Linux.) | |
| 204 | + | func NetworkAddressParse(HostAndPortVar string, DefaultPortVar uint16) (*NetworkAddress, error) { | |
| 205 | + | var cls *NetworkAddress | |
| 206 | + | var cerr *glib.Error | |
| 207 | + | ||
| 208 | + | cret := xNetworkAddressParse(HostAndPortVar, DefaultPortVar, &cerr) | |
| 209 | + | ||
| 210 | + | if cret == 0 { | |
| 211 | + | return nil, cerr | |
| 212 | + | } | |
| 213 | + | cls = &NetworkAddress{} | |
| 214 | + | cls.Ptr = cret | |
| 215 | + | if cerr == nil { | |
| 216 | + | return cls, nil | |
| 217 | + | } | |
| 218 | + | return cls, cerr | |
| 219 | + | ||
| 220 | + | } | |
| 221 | + | ||
| 222 | + | var xNetworkAddressParseUri func(string, uint16, **glib.Error) uintptr | |
| 223 | + | ||
| 224 | + | // Creates a new #GSocketConnectable for connecting to the given | |
| 225 | + | // @uri. May fail and return %NULL in case parsing @uri fails. | |
| 226 | + | // | |
| 227 | + | // Using this rather than g_network_address_new() or | |
| 228 | + | // g_network_address_parse() allows #GSocketClient to determine | |
| 229 | + | // when to use application-specific proxy protocols. | |
| 230 | + | func NetworkAddressParseUri(UriVar string, DefaultPortVar uint16) (*NetworkAddress, error) { | |
| 231 | + | var cls *NetworkAddress | |
| 232 | + | var cerr *glib.Error | |
| 233 | + | ||
| 234 | + | cret := xNetworkAddressParseUri(UriVar, DefaultPortVar, &cerr) | |
| 235 | + | ||
| 236 | + | if cret == 0 { | |
| 237 | + | return nil, cerr | |
| 238 | + | } | |
| 239 | + | cls = &NetworkAddress{} | |
| 240 | + | cls.Ptr = cret | |
| 241 | + | if cerr == nil { | |
| 242 | + | return cls, nil | |
| 243 | + | } | |
| 244 | + | return cls, cerr | |
| 245 | + | ||
| 246 | + | } | |
| 247 | + | ||
| 170 | 248 | func init() { | |
| 171 | 249 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 172 | 250 | if err != nil { | |
| @@ -180,4 +258,7 @@ func init() { | |||
| 180 | 258 | core.PuregoSafeRegister(&xNetworkAddressGetPort, lib, "g_network_address_get_port") | |
| 181 | 259 | core.PuregoSafeRegister(&xNetworkAddressGetScheme, lib, "g_network_address_get_scheme") | |
| 182 | 260 | ||
| 261 | + | core.PuregoSafeRegister(&xNetworkAddressParse, lib, "g_network_address_parse") | |
| 262 | + | core.PuregoSafeRegister(&xNetworkAddressParseUri, lib, "g_network_address_parse_uri") | |
| 263 | + | ||
| 183 | 264 | } | |
M v4/gio/gnetworkmonitor.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type NetworkMonitorInterface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *NetworkMonitorInterface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GNetworkMonitor provides an easy-to-use cross-platform API | |
| 17 | 23 | // for monitoring network connectivity. On Linux, the available | |
| 18 | 24 | // implementations are based on the kernel's netlink interface and | |
| @@ -147,6 +153,12 @@ var XGNetworkMonitorGetConnectivity func(uintptr) NetworkConnectivity | |||
| 147 | 153 | var XGNetworkMonitorGetNetworkAvailable func(uintptr) bool | |
| 148 | 154 | var XGNetworkMonitorGetNetworkMetered func(uintptr) bool | |
| 149 | 155 | ||
| 156 | + | const ( | |
| 157 | + | // Extension point for network status monitoring functionality. | |
| 158 | + | // See [Extending GIO][extending-gio]. | |
| 159 | + | NETWORK_MONITOR_EXTENSION_POINT_NAME string = "gio-network-monitor" | |
| 160 | + | ) | |
| 161 | + | ||
| 150 | 162 | var xNetworkMonitorGetDefault func() uintptr | |
| 151 | 163 | ||
| 152 | 164 | // Gets the default #GNetworkMonitor for the system. | |
M v4/gio/gnetworkservice.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type NetworkServiceClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *NetworkServiceClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type NetworkServicePrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *NetworkServicePrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Like #GNetworkAddress does with hostnames, #GNetworkService | |
| 18 | 28 | // provides an easy way to resolve a SRV record, and then attempt to | |
| 19 | 29 | // connect to one of the hosts that implements that service, handling | |
M v4/gio/goutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type OutputStreamClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *OutputStreamClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type OutputStreamPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *OutputStreamPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GOutputStream has functions to write to a stream (g_output_stream_write()), | |
| 19 | 29 | // to close a stream (g_output_stream_close()) and to flush pending writes | |
| 20 | 30 | // (g_output_stream_flush()). | |
M v4/gio/gpermission.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,9 +16,17 @@ type PermissionClass struct { | |||
| 14 | 16 | Reserved uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *PermissionClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | type PermissionPrivate struct { | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *PermissionPrivate) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | // A #GPermission represents the status of the caller's permission to | |
| 21 | 31 | // perform a certain action. | |
| 22 | 32 | // | |
M v4/gio/gpollableinputstream.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -21,6 +23,10 @@ type PollableInputStreamInterface struct { | |||
| 21 | 23 | GIface uintptr | |
| 22 | 24 | } | |
| 23 | 25 | ||
| 26 | + | func (x *PollableInputStreamInterface) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 24 | 30 | // #GPollableInputStream is implemented by #GInputStreams that | |
| 25 | 31 | // can be polled for readiness to read. This can be used when | |
| 26 | 32 | // interfacing with a non-GIO API that expects | |
M v4/gio/gpollableoutputstream.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -27,6 +29,10 @@ type PollableOutputStreamInterface struct { | |||
| 27 | 29 | GIface uintptr | |
| 28 | 30 | } | |
| 29 | 31 | ||
| 32 | + | func (x *PollableOutputStreamInterface) GoPointer() uintptr { | |
| 33 | + | return uintptr(unsafe.Pointer(x)) | |
| 34 | + | } | |
| 35 | + | ||
| 30 | 36 | // #GPollableOutputStream is implemented by #GOutputStreams that | |
| 31 | 37 | // can be polled for readiness to write. This can be used when | |
| 32 | 38 | // interfacing with a non-GIO API that expects | |
M v4/gio/gpowerprofilemonitor.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,10 @@ type PowerProfileMonitorInterface struct { | |||
| 11 | 13 | GIface uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *PowerProfileMonitorInterface) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GPowerProfileMonitor makes it possible for applications as well as OS components | |
| 15 | 21 | // to monitor system power profiles and act upon them. It currently only exports | |
| 16 | 22 | // whether the system is in “Power Saver” mode (known as “Low Power” mode on | |
| @@ -63,6 +69,12 @@ func (x *PowerProfileMonitorBase) GetPowerSaverEnabled() bool { | |||
| 63 | 69 | ||
| 64 | 70 | var XGPowerProfileMonitorGetPowerSaverEnabled func(uintptr) bool | |
| 65 | 71 | ||
| 72 | + | const ( | |
| 73 | + | // Extension point for power profile usage monitoring functionality. | |
| 74 | + | // See [Extending GIO][extending-gio]. | |
| 75 | + | POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME string = "gio-power-profile-monitor" | |
| 76 | + | ) | |
| 77 | + | ||
| 66 | 78 | var xPowerProfileMonitorDupDefault func() uintptr | |
| 67 | 79 | ||
| 68 | 80 | // Gets a reference to the default #GPowerProfileMonitor for the system. | |
M v4/gio/gproxy.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ProxyInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ProxyInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // A #GProxy handles connecting to a remote host via a given type of | |
| 16 | 22 | // proxy server. It is implemented by the 'gio-proxy' extension point. | |
| 17 | 23 | // The extensions are named after their proxy protocol name. As an | |
| @@ -104,6 +110,12 @@ var XGProxyConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr, uintpt | |||
| 104 | 110 | var XGProxyConnectFinish func(uintptr, uintptr, **glib.Error) uintptr | |
| 105 | 111 | var XGProxySupportsHostname func(uintptr) bool | |
| 106 | 112 | ||
| 113 | + | const ( | |
| 114 | + | // Extension point for proxy functionality. | |
| 115 | + | // See [Extending GIO][extending-gio]. | |
| 116 | + | PROXY_EXTENSION_POINT_NAME string = "gio-proxy" | |
| 117 | + | ) | |
| 118 | + | ||
| 107 | 119 | var xProxyGetDefaultForProtocol func(string) uintptr | |
| 108 | 120 | ||
| 109 | 121 | // Find the `gio-proxy` extension point for a proxy implementation that supports | |
M v4/gio/gproxyaddress.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,9 +13,17 @@ type ProxyAddressClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *ProxyAddressClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type ProxyAddressPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *ProxyAddressPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // Support for proxied #GInetSocketAddress. | |
| 18 | 28 | type ProxyAddress struct { | |
| 19 | 29 | InetSocketAddress | |
M v4/gio/gproxyaddressenumerator.go +10 -0
| @@ -1,14 +1,24 @@ | |||
| 1 | 1 | // Package gio was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | + | import "unsafe" | |
| 5 | + | ||
| 4 | 6 | // Class structure for #GProxyAddressEnumerator. | |
| 5 | 7 | type ProxyAddressEnumeratorClass struct { | |
| 6 | 8 | ParentClass uintptr | |
| 7 | 9 | } | |
| 8 | 10 | ||
| 11 | + | func (x *ProxyAddressEnumeratorClass) GoPointer() uintptr { | |
| 12 | + | return uintptr(unsafe.Pointer(x)) | |
| 13 | + | } | |
| 14 | + | ||
| 9 | 15 | type ProxyAddressEnumeratorPrivate struct { | |
| 10 | 16 | } | |
| 11 | 17 | ||
| 18 | + | func (x *ProxyAddressEnumeratorPrivate) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 12 | 22 | // #GProxyAddressEnumerator is a wrapper around #GSocketAddressEnumerator which | |
| 13 | 23 | // takes the #GSocketAddress instances returned by the #GSocketAddressEnumerator | |
| 14 | 24 | // and wraps them in #GProxyAddress instances, using the given | |
M v4/gio/gproxyresolver.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type ProxyResolverInterface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *ProxyResolverInterface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GProxyResolver provides synchronous and asynchronous network proxy | |
| 17 | 23 | // resolution. #GProxyResolver is used within #GSocketClient through | |
| 18 | 24 | // the method g_socket_connectable_proxy_enumerate(). | |
| @@ -102,6 +108,12 @@ var XGProxyResolverLookup func(uintptr, string, uintptr, **glib.Error) uintptr | |||
| 102 | 108 | var XGProxyResolverLookupAsync func(uintptr, string, uintptr, uintptr, uintptr) | |
| 103 | 109 | var XGProxyResolverLookupFinish func(uintptr, uintptr, **glib.Error) uintptr | |
| 104 | 110 | ||
| 111 | + | const ( | |
| 112 | + | // Extension point for proxy resolving functionality. | |
| 113 | + | // See [Extending GIO][extending-gio]. | |
| 114 | + | PROXY_RESOLVER_EXTENSION_POINT_NAME string = "gio-proxy-resolver" | |
| 115 | + | ) | |
| 116 | + | ||
| 105 | 117 | var xProxyResolverGetDefault func() uintptr | |
| 106 | 118 | ||
| 107 | 119 | // Gets the default #GProxyResolver for the system. | |
M v4/gio/gremoteactiongroup.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type RemoteActionGroupInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *RemoteActionGroupInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The GRemoteActionGroup interface is implemented by #GActionGroup | |
| 16 | 22 | // instances that either transmit action invocations to other processes | |
| 17 | 23 | // or receive action invocations in the local process from other | |
M v4/gio/gresolver.go +56 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type ResolverClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ResolverClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type ResolverPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *ResolverPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // Flags to modify lookup behavior. | |
| 19 | 29 | type ResolverNameLookupFlags int | |
| 20 | 30 | ||
| @@ -372,6 +382,48 @@ func (x *Resolver) ConnectReload(cb func(Resolver)) uint32 { | |||
| 372 | 382 | return gobject.SignalConnect(x.GoPointer(), "reload", purego.NewCallback(fcb)) | |
| 373 | 383 | } | |
| 374 | 384 | ||
| 385 | + | var xResolverFreeAddresses func(*glib.List) | |
| 386 | + | ||
| 387 | + | // Frees @addresses (which should be the return value from | |
| 388 | + | // g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()). | |
| 389 | + | // (This is a convenience method; you can also simply free the results | |
| 390 | + | // by hand.) | |
| 391 | + | func ResolverFreeAddresses(AddressesVar *glib.List) { | |
| 392 | + | ||
| 393 | + | xResolverFreeAddresses(AddressesVar) | |
| 394 | + | ||
| 395 | + | } | |
| 396 | + | ||
| 397 | + | var xResolverFreeTargets func(*glib.List) | |
| 398 | + | ||
| 399 | + | // Frees @targets (which should be the return value from | |
| 400 | + | // g_resolver_lookup_service() or g_resolver_lookup_service_finish()). | |
| 401 | + | // (This is a convenience method; you can also simply free the | |
| 402 | + | // results by hand.) | |
| 403 | + | func ResolverFreeTargets(TargetsVar *glib.List) { | |
| 404 | + | ||
| 405 | + | xResolverFreeTargets(TargetsVar) | |
| 406 | + | ||
| 407 | + | } | |
| 408 | + | ||
| 409 | + | var xResolverGetDefault func() uintptr | |
| 410 | + | ||
| 411 | + | // Gets the default #GResolver. You should unref it when you are done | |
| 412 | + | // with it. #GResolver may use its reference count as a hint about how | |
| 413 | + | // many threads it should allocate for concurrent DNS resolutions. | |
| 414 | + | func ResolverGetDefault() *Resolver { | |
| 415 | + | var cls *Resolver | |
| 416 | + | ||
| 417 | + | cret := xResolverGetDefault() | |
| 418 | + | ||
| 419 | + | if cret == 0 { | |
| 420 | + | return nil | |
| 421 | + | } | |
| 422 | + | cls = &Resolver{} | |
| 423 | + | cls.Ptr = cret | |
| 424 | + | return cls | |
| 425 | + | } | |
| 426 | + | ||
| 375 | 427 | func init() { | |
| 376 | 428 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 377 | 429 | if err != nil { | |
| @@ -395,4 +447,8 @@ func init() { | |||
| 395 | 447 | core.PuregoSafeRegister(&xResolverLookupServiceFinish, lib, "g_resolver_lookup_service_finish") | |
| 396 | 448 | core.PuregoSafeRegister(&xResolverSetDefault, lib, "g_resolver_set_default") | |
| 397 | 449 | ||
| 450 | + | core.PuregoSafeRegister(&xResolverFreeAddresses, lib, "g_resolver_free_addresses") | |
| 451 | + | core.PuregoSafeRegister(&xResolverFreeTargets, lib, "g_resolver_free_targets") | |
| 452 | + | core.PuregoSafeRegister(&xResolverGetDefault, lib, "g_resolver_get_default") | |
| 453 | + | ||
| 398 | 454 | } | |
M v4/gio/gresource.go +50 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -21,6 +23,50 @@ type StaticResource struct { | |||
| 21 | 23 | Padding uintptr | |
| 22 | 24 | } | |
| 23 | 25 | ||
| 26 | + | func (x *StaticResource) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 30 | + | var xStaticResourceFini func(uintptr) | |
| 31 | + | ||
| 32 | + | // Finalized a GResource initialized by g_static_resource_init(). | |
| 33 | + | // | |
| 34 | + | // This is normally used by code generated by | |
| 35 | + | // [glib-compile-resources][glib-compile-resources] | |
| 36 | + | // and is not typically used by other code. | |
| 37 | + | func (x *StaticResource) Fini() { | |
| 38 | + | ||
| 39 | + | xStaticResourceFini(x.GoPointer()) | |
| 40 | + | ||
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xStaticResourceGetResource func(uintptr) *Resource | |
| 44 | + | ||
| 45 | + | // Gets the GResource that was registered by a call to g_static_resource_init(). | |
| 46 | + | // | |
| 47 | + | // This is normally used by code generated by | |
| 48 | + | // [glib-compile-resources][glib-compile-resources] | |
| 49 | + | // and is not typically used by other code. | |
| 50 | + | func (x *StaticResource) GetResource() *Resource { | |
| 51 | + | ||
| 52 | + | cret := xStaticResourceGetResource(x.GoPointer()) | |
| 53 | + | return cret | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | var xStaticResourceInit func(uintptr) | |
| 57 | + | ||
| 58 | + | // Initializes a GResource from static data using a | |
| 59 | + | // GStaticResource. | |
| 60 | + | // | |
| 61 | + | // This is normally used by code generated by | |
| 62 | + | // [glib-compile-resources][glib-compile-resources] | |
| 63 | + | // and is not typically used by other code. | |
| 64 | + | func (x *StaticResource) Init() { | |
| 65 | + | ||
| 66 | + | xStaticResourceInit(x.GoPointer()) | |
| 67 | + | ||
| 68 | + | } | |
| 69 | + | ||
| 24 | 70 | var xResourceLoad func(string, **glib.Error) *Resource | |
| 25 | 71 | ||
| 26 | 72 | // Loads a binary resource bundle and creates a #GResource representation of it, allowing | |
| @@ -165,4 +211,8 @@ func init() { | |||
| 165 | 211 | core.PuregoSafeRegister(&xResourcesRegister, lib, "g_resources_register") | |
| 166 | 212 | core.PuregoSafeRegister(&xResourcesUnregister, lib, "g_resources_unregister") | |
| 167 | 213 | ||
| 214 | + | core.PuregoSafeRegister(&xStaticResourceFini, lib, "g_static_resource_fini") | |
| 215 | + | core.PuregoSafeRegister(&xStaticResourceGetResource, lib, "g_static_resource_get_resource") | |
| 216 | + | core.PuregoSafeRegister(&xStaticResourceInit, lib, "g_static_resource_init") | |
| 217 | + | ||
| 168 | 218 | } | |
M v4/gio/gseekable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type SeekableIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SeekableIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GSeekable is implemented by streams (implementations of | |
| 16 | 22 | // #GInputStream or #GOutputStream) that support seeking. | |
| 17 | 23 | // | |
M v4/gio/gsettings.go +64 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -35,9 +37,17 @@ type SettingsClass struct { | |||
| 35 | 37 | Padding uintptr | |
| 36 | 38 | } | |
| 37 | 39 | ||
| 40 | + | func (x *SettingsClass) GoPointer() uintptr { | |
| 41 | + | return uintptr(unsafe.Pointer(x)) | |
| 42 | + | } | |
| 43 | + | ||
| 38 | 44 | type SettingsPrivate struct { | |
| 39 | 45 | } | |
| 40 | 46 | ||
| 47 | + | func (x *SettingsPrivate) GoPointer() uintptr { | |
| 48 | + | return uintptr(unsafe.Pointer(x)) | |
| 49 | + | } | |
| 50 | + | ||
| 41 | 51 | // Flags used when creating a binding. These flags determine in which | |
| 42 | 52 | // direction the binding works. The default is to synchronize in both | |
| 43 | 53 | // directions. | |
| @@ -1309,6 +1319,55 @@ func (x *Settings) ConnectWritableChanged(cb func(Settings, string)) uint32 { | |||
| 1309 | 1319 | return gobject.SignalConnect(x.GoPointer(), "writable-changed", purego.NewCallback(fcb)) | |
| 1310 | 1320 | } | |
| 1311 | 1321 | ||
| 1322 | + | var xSettingsListRelocatableSchemas func() uintptr | |
| 1323 | + | ||
| 1324 | + | // Deprecated. | |
| 1325 | + | func SettingsListRelocatableSchemas() uintptr { | |
| 1326 | + | ||
| 1327 | + | cret := xSettingsListRelocatableSchemas() | |
| 1328 | + | return cret | |
| 1329 | + | } | |
| 1330 | + | ||
| 1331 | + | var xSettingsListSchemas func() uintptr | |
| 1332 | + | ||
| 1333 | + | // Deprecated. | |
| 1334 | + | func SettingsListSchemas() uintptr { | |
| 1335 | + | ||
| 1336 | + | cret := xSettingsListSchemas() | |
| 1337 | + | return cret | |
| 1338 | + | } | |
| 1339 | + | ||
| 1340 | + | var xSettingsSync func() | |
| 1341 | + | ||
| 1342 | + | // Ensures that all pending operations are complete for the default backend. | |
| 1343 | + | // | |
| 1344 | + | // Writes made to a #GSettings are handled asynchronously. For this | |
| 1345 | + | // reason, it is very unlikely that the changes have it to disk by the | |
| 1346 | + | // time g_settings_set() returns. | |
| 1347 | + | // | |
| 1348 | + | // This call will block until all of the writes have made it to the | |
| 1349 | + | // backend. Since the mainloop is not running, no change notifications | |
| 1350 | + | // will be dispatched during this call (but some may be queued by the | |
| 1351 | + | // time the call is done). | |
| 1352 | + | func SettingsSync() { | |
| 1353 | + | ||
| 1354 | + | xSettingsSync() | |
| 1355 | + | ||
| 1356 | + | } | |
| 1357 | + | ||
| 1358 | + | var xSettingsUnbind func(uintptr, string) | |
| 1359 | + | ||
| 1360 | + | // Removes an existing binding for @property on @object. | |
| 1361 | + | // | |
| 1362 | + | // Note that bindings are automatically removed when the | |
| 1363 | + | // object is finalized, so it is rarely necessary to call this | |
| 1364 | + | // function. | |
| 1365 | + | func SettingsUnbind(ObjectVar *gobject.Object, PropertyVar string) { | |
| 1366 | + | ||
| 1367 | + | xSettingsUnbind(ObjectVar.GoPointer(), PropertyVar) | |
| 1368 | + | ||
| 1369 | + | } | |
| 1370 | + | ||
| 1312 | 1371 | func init() { | |
| 1313 | 1372 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 1314 | 1373 | if err != nil { | |
| @@ -1364,4 +1423,9 @@ func init() { | |||
| 1364 | 1423 | core.PuregoSafeRegister(&xSettingsSetUint64, lib, "g_settings_set_uint64") | |
| 1365 | 1424 | core.PuregoSafeRegister(&xSettingsSetValue, lib, "g_settings_set_value") | |
| 1366 | 1425 | ||
| 1426 | + | core.PuregoSafeRegister(&xSettingsListRelocatableSchemas, lib, "g_settings_list_relocatable_schemas") | |
| 1427 | + | core.PuregoSafeRegister(&xSettingsListSchemas, lib, "g_settings_list_schemas") | |
| 1428 | + | core.PuregoSafeRegister(&xSettingsSync, lib, "g_settings_sync") | |
| 1429 | + | core.PuregoSafeRegister(&xSettingsUnbind, lib, "g_settings_unbind") | |
| 1430 | + | ||
| 1367 | 1431 | } | |
M v4/gio/gsettingsbackend.go +53 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,22 @@ type SettingsBackendClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *SettingsBackendClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type SettingsBackendPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *SettingsBackendPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | const ( | |
| 32 | + | // Extension point for #GSettingsBackend functionality. | |
| 33 | + | SETTINGS_BACKEND_EXTENSION_POINT_NAME string = "gsettings-backend" | |
| 34 | + | ) | |
| 35 | + | ||
| 21 | 36 | var xKeyfileSettingsBackendNew func(string, string, string) uintptr | |
| 22 | 37 | ||
| 23 | 38 | // Creates a keyfile-backed #GSettingsBackend. | |
| @@ -291,6 +306,41 @@ func (c *SettingsBackend) SetGoPointer(ptr uintptr) { | |||
| 291 | 306 | c.Ptr = ptr | |
| 292 | 307 | } | |
| 293 | 308 | ||
| 309 | + | var xSettingsBackendFlattenTree func(*glib.Tree, string, uintptr, uintptr) | |
| 310 | + | ||
| 311 | + | // Calculate the longest common prefix of all keys in a tree and write | |
| 312 | + | // out an array of the key names relative to that prefix and, | |
| 313 | + | // optionally, the value to store at each of those keys. | |
| 314 | + | // | |
| 315 | + | // You must free the value returned in @path, @keys and @values using | |
| 316 | + | // g_free(). You should not attempt to free or unref the contents of | |
| 317 | + | // @keys or @values. | |
| 318 | + | func SettingsBackendFlattenTree(TreeVar *glib.Tree, PathVar string, KeysVar uintptr, ValuesVar uintptr) { | |
| 319 | + | ||
| 320 | + | xSettingsBackendFlattenTree(TreeVar, PathVar, KeysVar, ValuesVar) | |
| 321 | + | ||
| 322 | + | } | |
| 323 | + | ||
| 324 | + | var xSettingsBackendGetDefault func() uintptr | |
| 325 | + | ||
| 326 | + | // Returns the default #GSettingsBackend. It is possible to override | |
| 327 | + | // the default by setting the `GSETTINGS_BACKEND` environment variable | |
| 328 | + | // to the name of a settings backend. | |
| 329 | + | // | |
| 330 | + | // The user gets a reference to the backend. | |
| 331 | + | func SettingsBackendGetDefault() *SettingsBackend { | |
| 332 | + | var cls *SettingsBackend | |
| 333 | + | ||
| 334 | + | cret := xSettingsBackendGetDefault() | |
| 335 | + | ||
| 336 | + | if cret == 0 { | |
| 337 | + | return nil | |
| 338 | + | } | |
| 339 | + | cls = &SettingsBackend{} | |
| 340 | + | cls.Ptr = cret | |
| 341 | + | return cls | |
| 342 | + | } | |
| 343 | + | ||
| 294 | 344 | func init() { | |
| 295 | 345 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 296 | 346 | if err != nil { | |
| @@ -307,4 +357,7 @@ func init() { | |||
| 307 | 357 | core.PuregoSafeRegister(&xSettingsBackendPathWritableChanged, lib, "g_settings_backend_path_writable_changed") | |
| 308 | 358 | core.PuregoSafeRegister(&xSettingsBackendWritableChanged, lib, "g_settings_backend_writable_changed") | |
| 309 | 359 | ||
| 360 | + | core.PuregoSafeRegister(&xSettingsBackendFlattenTree, lib, "g_settings_backend_flatten_tree") | |
| 361 | + | core.PuregoSafeRegister(&xSettingsBackendGetDefault, lib, "g_settings_backend_get_default") | |
| 362 | + | ||
| 310 | 363 | } | |
M v4/gio/gsettingsschema.go +379 -0
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | ) | |
| 8 | 11 | ||
| 9 | 12 | // The #GSettingsSchemaSource and #GSettingsSchema APIs provide a | |
| @@ -106,15 +109,365 @@ import ( | |||
| 106 | 109 | type SettingsSchema struct { | |
| 107 | 110 | } | |
| 108 | 111 | ||
| 112 | + | func (x *SettingsSchema) GoPointer() uintptr { | |
| 113 | + | return uintptr(unsafe.Pointer(x)) | |
| 114 | + | } | |
| 115 | + | ||
| 116 | + | var xSettingsSchemaGetId func(uintptr) string | |
| 117 | + | ||
| 118 | + | // Get the ID of @schema. | |
| 119 | + | func (x *SettingsSchema) GetId() string { | |
| 120 | + | ||
| 121 | + | cret := xSettingsSchemaGetId(x.GoPointer()) | |
| 122 | + | return cret | |
| 123 | + | } | |
| 124 | + | ||
| 125 | + | var xSettingsSchemaGetKey func(uintptr, string) *SettingsSchemaKey | |
| 126 | + | ||
| 127 | + | // Gets the key named @name from @schema. | |
| 128 | + | // | |
| 129 | + | // It is a programmer error to request a key that does not exist. See | |
| 130 | + | // g_settings_schema_list_keys(). | |
| 131 | + | func (x *SettingsSchema) GetKey(NameVar string) *SettingsSchemaKey { | |
| 132 | + | ||
| 133 | + | cret := xSettingsSchemaGetKey(x.GoPointer(), NameVar) | |
| 134 | + | return cret | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | var xSettingsSchemaGetPath func(uintptr) string | |
| 138 | + | ||
| 139 | + | // Gets the path associated with @schema, or %NULL. | |
| 140 | + | // | |
| 141 | + | // Schemas may be single-instance or relocatable. Single-instance | |
| 142 | + | // schemas correspond to exactly one set of keys in the backend | |
| 143 | + | // database: those located at the path returned by this function. | |
| 144 | + | // | |
| 145 | + | // Relocatable schemas can be referenced by other schemas and can | |
| 146 | + | // therefore describe multiple sets of keys at different locations. For | |
| 147 | + | // relocatable schemas, this function will return %NULL. | |
| 148 | + | func (x *SettingsSchema) GetPath() string { | |
| 149 | + | ||
| 150 | + | cret := xSettingsSchemaGetPath(x.GoPointer()) | |
| 151 | + | return cret | |
| 152 | + | } | |
| 153 | + | ||
| 154 | + | var xSettingsSchemaHasKey func(uintptr, string) bool | |
| 155 | + | ||
| 156 | + | // Checks if @schema has a key named @name. | |
| 157 | + | func (x *SettingsSchema) HasKey(NameVar string) bool { | |
| 158 | + | ||
| 159 | + | cret := xSettingsSchemaHasKey(x.GoPointer(), NameVar) | |
| 160 | + | return cret | |
| 161 | + | } | |
| 162 | + | ||
| 163 | + | var xSettingsSchemaListChildren func(uintptr) uintptr | |
| 164 | + | ||
| 165 | + | // Gets the list of children in @schema. | |
| 166 | + | // | |
| 167 | + | // You should free the return value with g_strfreev() when you are done | |
| 168 | + | // with it. | |
| 169 | + | func (x *SettingsSchema) ListChildren() uintptr { | |
| 170 | + | ||
| 171 | + | cret := xSettingsSchemaListChildren(x.GoPointer()) | |
| 172 | + | return cret | |
| 173 | + | } | |
| 174 | + | ||
| 175 | + | var xSettingsSchemaListKeys func(uintptr) uintptr | |
| 176 | + | ||
| 177 | + | // Introspects the list of keys on @schema. | |
| 178 | + | // | |
| 179 | + | // You should probably not be calling this function from "normal" code | |
| 180 | + | // (since you should already know what keys are in your schema). This | |
| 181 | + | // function is intended for introspection reasons. | |
| 182 | + | func (x *SettingsSchema) ListKeys() uintptr { | |
| 183 | + | ||
| 184 | + | cret := xSettingsSchemaListKeys(x.GoPointer()) | |
| 185 | + | return cret | |
| 186 | + | } | |
| 187 | + | ||
| 188 | + | var xSettingsSchemaRef func(uintptr) *SettingsSchema | |
| 189 | + | ||
| 190 | + | // Increase the reference count of @schema, returning a new reference. | |
| 191 | + | func (x *SettingsSchema) Ref() *SettingsSchema { | |
| 192 | + | ||
| 193 | + | cret := xSettingsSchemaRef(x.GoPointer()) | |
| 194 | + | return cret | |
| 195 | + | } | |
| 196 | + | ||
| 197 | + | var xSettingsSchemaUnref func(uintptr) | |
| 198 | + | ||
| 199 | + | // Decrease the reference count of @schema, possibly freeing it. | |
| 200 | + | func (x *SettingsSchema) Unref() { | |
| 201 | + | ||
| 202 | + | xSettingsSchemaUnref(x.GoPointer()) | |
| 203 | + | ||
| 204 | + | } | |
| 205 | + | ||
| 109 | 206 | // #GSettingsSchemaKey is an opaque data structure and can only be accessed | |
| 110 | 207 | // using the following functions. | |
| 111 | 208 | type SettingsSchemaKey struct { | |
| 112 | 209 | } | |
| 113 | 210 | ||
| 211 | + | func (x *SettingsSchemaKey) GoPointer() uintptr { | |
| 212 | + | return uintptr(unsafe.Pointer(x)) | |
| 213 | + | } | |
| 214 | + | ||
| 215 | + | var xSettingsSchemaKeyGetDefaultValue func(uintptr) *glib.Variant | |
| 216 | + | ||
| 217 | + | // Gets the default value for @key. | |
| 218 | + | // | |
| 219 | + | // Note that this is the default value according to the schema. System | |
| 220 | + | // administrator defaults and lockdown are not visible via this API. | |
| 221 | + | func (x *SettingsSchemaKey) GetDefaultValue() *glib.Variant { | |
| 222 | + | ||
| 223 | + | cret := xSettingsSchemaKeyGetDefaultValue(x.GoPointer()) | |
| 224 | + | return cret | |
| 225 | + | } | |
| 226 | + | ||
| 227 | + | var xSettingsSchemaKeyGetDescription func(uintptr) string | |
| 228 | + | ||
| 229 | + | // Gets the description for @key. | |
| 230 | + | // | |
| 231 | + | // If no description has been provided in the schema for @key, returns | |
| 232 | + | // %NULL. | |
| 233 | + | // | |
| 234 | + | // The description can be one sentence to several paragraphs in length. | |
| 235 | + | // Paragraphs are delimited with a double newline. Descriptions can be | |
| 236 | + | // translated and the value returned from this function is is the | |
| 237 | + | // current locale. | |
| 238 | + | // | |
| 239 | + | // This function is slow. The summary and description information for | |
| 240 | + | // the schemas is not stored in the compiled schema database so this | |
| 241 | + | // function has to parse all of the source XML files in the schema | |
| 242 | + | // directory. | |
| 243 | + | func (x *SettingsSchemaKey) GetDescription() string { | |
| 244 | + | ||
| 245 | + | cret := xSettingsSchemaKeyGetDescription(x.GoPointer()) | |
| 246 | + | return cret | |
| 247 | + | } | |
| 248 | + | ||
| 249 | + | var xSettingsSchemaKeyGetName func(uintptr) string | |
| 250 | + | ||
| 251 | + | // Gets the name of @key. | |
| 252 | + | func (x *SettingsSchemaKey) GetName() string { | |
| 253 | + | ||
| 254 | + | cret := xSettingsSchemaKeyGetName(x.GoPointer()) | |
| 255 | + | return cret | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | var xSettingsSchemaKeyGetRange func(uintptr) *glib.Variant | |
| 259 | + | ||
| 260 | + | // Queries the range of a key. | |
| 261 | + | // | |
| 262 | + | // This function will return a #GVariant that fully describes the range | |
| 263 | + | // of values that are valid for @key. | |
| 264 | + | // | |
| 265 | + | // The type of #GVariant returned is `(sv)`. The string describes | |
| 266 | + | // the type of range restriction in effect. The type and meaning of | |
| 267 | + | // the value contained in the variant depends on the string. | |
| 268 | + | // | |
| 269 | + | // If the string is `'type'` then the variant contains an empty array. | |
| 270 | + | // The element type of that empty array is the expected type of value | |
| 271 | + | // and all values of that type are valid. | |
| 272 | + | // | |
| 273 | + | // If the string is `'enum'` then the variant contains an array | |
| 274 | + | // enumerating the possible values. Each item in the array is | |
| 275 | + | // a possible valid value and no other values are valid. | |
| 276 | + | // | |
| 277 | + | // If the string is `'flags'` then the variant contains an array. Each | |
| 278 | + | // item in the array is a value that may appear zero or one times in an | |
| 279 | + | // array to be used as the value for this key. For example, if the | |
| 280 | + | // variant contained the array `['x', 'y']` then the valid values for | |
| 281 | + | // the key would be `[]`, `['x']`, `['y']`, `['x', 'y']` and | |
| 282 | + | // `['y', 'x']`. | |
| 283 | + | // | |
| 284 | + | // Finally, if the string is `'range'` then the variant contains a pair | |
| 285 | + | // of like-typed values -- the minimum and maximum permissible values | |
| 286 | + | // for this key. | |
| 287 | + | // | |
| 288 | + | // This information should not be used by normal programs. It is | |
| 289 | + | // considered to be a hint for introspection purposes. Normal programs | |
| 290 | + | // should already know what is permitted by their own schema. The | |
| 291 | + | // format may change in any way in the future -- but particularly, new | |
| 292 | + | // forms may be added to the possibilities described above. | |
| 293 | + | // | |
| 294 | + | // You should free the returned value with g_variant_unref() when it is | |
| 295 | + | // no longer needed. | |
| 296 | + | func (x *SettingsSchemaKey) GetRange() *glib.Variant { | |
| 297 | + | ||
| 298 | + | cret := xSettingsSchemaKeyGetRange(x.GoPointer()) | |
| 299 | + | return cret | |
| 300 | + | } | |
| 301 | + | ||
| 302 | + | var xSettingsSchemaKeyGetSummary func(uintptr) string | |
| 303 | + | ||
| 304 | + | // Gets the summary for @key. | |
| 305 | + | // | |
| 306 | + | // If no summary has been provided in the schema for @key, returns | |
| 307 | + | // %NULL. | |
| 308 | + | // | |
| 309 | + | // The summary is a short description of the purpose of the key; usually | |
| 310 | + | // one short sentence. Summaries can be translated and the value | |
| 311 | + | // returned from this function is is the current locale. | |
| 312 | + | // | |
| 313 | + | // This function is slow. The summary and description information for | |
| 314 | + | // the schemas is not stored in the compiled schema database so this | |
| 315 | + | // function has to parse all of the source XML files in the schema | |
| 316 | + | // directory. | |
| 317 | + | func (x *SettingsSchemaKey) GetSummary() string { | |
| 318 | + | ||
| 319 | + | cret := xSettingsSchemaKeyGetSummary(x.GoPointer()) | |
| 320 | + | return cret | |
| 321 | + | } | |
| 322 | + | ||
| 323 | + | var xSettingsSchemaKeyGetValueType func(uintptr) *glib.VariantType | |
| 324 | + | ||
| 325 | + | // Gets the #GVariantType of @key. | |
| 326 | + | func (x *SettingsSchemaKey) GetValueType() *glib.VariantType { | |
| 327 | + | ||
| 328 | + | cret := xSettingsSchemaKeyGetValueType(x.GoPointer()) | |
| 329 | + | return cret | |
| 330 | + | } | |
| 331 | + | ||
| 332 | + | var xSettingsSchemaKeyRangeCheck func(uintptr, *glib.Variant) bool | |
| 333 | + | ||
| 334 | + | // Checks if the given @value is within the | |
| 335 | + | // permitted range for @key. | |
| 336 | + | // | |
| 337 | + | // It is a programmer error if @value is not of the correct type — you | |
| 338 | + | // must check for this first. | |
| 339 | + | func (x *SettingsSchemaKey) RangeCheck(ValueVar *glib.Variant) bool { | |
| 340 | + | ||
| 341 | + | cret := xSettingsSchemaKeyRangeCheck(x.GoPointer(), ValueVar) | |
| 342 | + | return cret | |
| 343 | + | } | |
| 344 | + | ||
| 345 | + | var xSettingsSchemaKeyRef func(uintptr) *SettingsSchemaKey | |
| 346 | + | ||
| 347 | + | // Increase the reference count of @key, returning a new reference. | |
| 348 | + | func (x *SettingsSchemaKey) Ref() *SettingsSchemaKey { | |
| 349 | + | ||
| 350 | + | cret := xSettingsSchemaKeyRef(x.GoPointer()) | |
| 351 | + | return cret | |
| 352 | + | } | |
| 353 | + | ||
| 354 | + | var xSettingsSchemaKeyUnref func(uintptr) | |
| 355 | + | ||
| 356 | + | // Decrease the reference count of @key, possibly freeing it. | |
| 357 | + | func (x *SettingsSchemaKey) Unref() { | |
| 358 | + | ||
| 359 | + | xSettingsSchemaKeyUnref(x.GoPointer()) | |
| 360 | + | ||
| 361 | + | } | |
| 362 | + | ||
| 114 | 363 | // This is an opaque structure type. You may not access it directly. | |
| 115 | 364 | type SettingsSchemaSource struct { | |
| 116 | 365 | } | |
| 117 | 366 | ||
| 367 | + | func (x *SettingsSchemaSource) GoPointer() uintptr { | |
| 368 | + | return uintptr(unsafe.Pointer(x)) | |
| 369 | + | } | |
| 370 | + | ||
| 371 | + | var xNewFromDirectorySettingsSchemaSource func(string, *SettingsSchemaSource, bool, **glib.Error) *SettingsSchemaSource | |
| 372 | + | ||
| 373 | + | // Attempts to create a new schema source corresponding to the contents | |
| 374 | + | // of the given directory. | |
| 375 | + | // | |
| 376 | + | // This function is not required for normal uses of #GSettings but it | |
| 377 | + | // may be useful to authors of plugin management systems. | |
| 378 | + | // | |
| 379 | + | // The directory should contain a file called `gschemas.compiled` as | |
| 380 | + | // produced by the [glib-compile-schemas][glib-compile-schemas] tool. | |
| 381 | + | // | |
| 382 | + | // If @trusted is %TRUE then `gschemas.compiled` is trusted not to be | |
| 383 | + | // corrupted. This assumption has a performance advantage, but can result | |
| 384 | + | // in crashes or inconsistent behaviour in the case of a corrupted file. | |
| 385 | + | // Generally, you should set @trusted to %TRUE for files installed by the | |
| 386 | + | // system and to %FALSE for files in the home directory. | |
| 387 | + | // | |
| 388 | + | // In either case, an empty file or some types of corruption in the file will | |
| 389 | + | // result in %G_FILE_ERROR_INVAL being returned. | |
| 390 | + | // | |
| 391 | + | // If @parent is non-%NULL then there are two effects. | |
| 392 | + | // | |
| 393 | + | // First, if g_settings_schema_source_lookup() is called with the | |
| 394 | + | // @recursive flag set to %TRUE and the schema can not be found in the | |
| 395 | + | // source, the lookup will recurse to the parent. | |
| 396 | + | // | |
| 397 | + | // Second, any references to other schemas specified within this | |
| 398 | + | // source (ie: `child` or `extends`) references may be resolved | |
| 399 | + | // from the @parent. | |
| 400 | + | // | |
| 401 | + | // For this second reason, except in very unusual situations, the | |
| 402 | + | // @parent should probably be given as the default schema source, as | |
| 403 | + | // returned by g_settings_schema_source_get_default(). | |
| 404 | + | func NewFromDirectorySettingsSchemaSource(DirectoryVar string, ParentVar *SettingsSchemaSource, TrustedVar bool) (*SettingsSchemaSource, error) { | |
| 405 | + | var cerr *glib.Error | |
| 406 | + | ||
| 407 | + | cret := xNewFromDirectorySettingsSchemaSource(DirectoryVar, ParentVar, TrustedVar, &cerr) | |
| 408 | + | if cerr == nil { | |
| 409 | + | return cret, nil | |
| 410 | + | } | |
| 411 | + | return cret, cerr | |
| 412 | + | ||
| 413 | + | } | |
| 414 | + | ||
| 415 | + | var xSettingsSchemaSourceListSchemas func(uintptr, bool, uintptr, uintptr) | |
| 416 | + | ||
| 417 | + | // Lists the schemas in a given source. | |
| 418 | + | // | |
| 419 | + | // If @recursive is %TRUE then include parent sources. If %FALSE then | |
| 420 | + | // only include the schemas from one source (ie: one directory). You | |
| 421 | + | // probably want %TRUE. | |
| 422 | + | // | |
| 423 | + | // Non-relocatable schemas are those for which you can call | |
| 424 | + | // g_settings_new(). Relocatable schemas are those for which you must | |
| 425 | + | // use g_settings_new_with_path(). | |
| 426 | + | // | |
| 427 | + | // Do not call this function from normal programs. This is designed for | |
| 428 | + | // use by database editors, commandline tools, etc. | |
| 429 | + | func (x *SettingsSchemaSource) ListSchemas(RecursiveVar bool, NonRelocatableVar uintptr, RelocatableVar uintptr) { | |
| 430 | + | ||
| 431 | + | xSettingsSchemaSourceListSchemas(x.GoPointer(), RecursiveVar, NonRelocatableVar, RelocatableVar) | |
| 432 | + | ||
| 433 | + | } | |
| 434 | + | ||
| 435 | + | var xSettingsSchemaSourceLookup func(uintptr, string, bool) *SettingsSchema | |
| 436 | + | ||
| 437 | + | // Looks up a schema with the identifier @schema_id in @source. | |
| 438 | + | // | |
| 439 | + | // This function is not required for normal uses of #GSettings but it | |
| 440 | + | // may be useful to authors of plugin management systems or to those who | |
| 441 | + | // want to introspect the content of schemas. | |
| 442 | + | // | |
| 443 | + | // If the schema isn't found directly in @source and @recursive is %TRUE | |
| 444 | + | // then the parent sources will also be checked. | |
| 445 | + | // | |
| 446 | + | // If the schema isn't found, %NULL is returned. | |
| 447 | + | func (x *SettingsSchemaSource) Lookup(SchemaIdVar string, RecursiveVar bool) *SettingsSchema { | |
| 448 | + | ||
| 449 | + | cret := xSettingsSchemaSourceLookup(x.GoPointer(), SchemaIdVar, RecursiveVar) | |
| 450 | + | return cret | |
| 451 | + | } | |
| 452 | + | ||
| 453 | + | var xSettingsSchemaSourceRef func(uintptr) *SettingsSchemaSource | |
| 454 | + | ||
| 455 | + | // Increase the reference count of @source, returning a new reference. | |
| 456 | + | func (x *SettingsSchemaSource) Ref() *SettingsSchemaSource { | |
| 457 | + | ||
| 458 | + | cret := xSettingsSchemaSourceRef(x.GoPointer()) | |
| 459 | + | return cret | |
| 460 | + | } | |
| 461 | + | ||
| 462 | + | var xSettingsSchemaSourceUnref func(uintptr) | |
| 463 | + | ||
| 464 | + | // Decrease the reference count of @source, possibly freeing it. | |
| 465 | + | func (x *SettingsSchemaSource) Unref() { | |
| 466 | + | ||
| 467 | + | xSettingsSchemaSourceUnref(x.GoPointer()) | |
| 468 | + | ||
| 469 | + | } | |
| 470 | + | ||
| 118 | 471 | var xSettingsSchemaSourceGetDefault func() *SettingsSchemaSource | |
| 119 | 472 | ||
| 120 | 473 | // Gets the default system schema source. | |
| @@ -143,4 +496,30 @@ func init() { | |||
| 143 | 496 | } | |
| 144 | 497 | core.PuregoSafeRegister(&xSettingsSchemaSourceGetDefault, lib, "g_settings_schema_source_get_default") | |
| 145 | 498 | ||
| 499 | + | core.PuregoSafeRegister(&xSettingsSchemaGetId, lib, "g_settings_schema_get_id") | |
| 500 | + | core.PuregoSafeRegister(&xSettingsSchemaGetKey, lib, "g_settings_schema_get_key") | |
| 501 | + | core.PuregoSafeRegister(&xSettingsSchemaGetPath, lib, "g_settings_schema_get_path") | |
| 502 | + | core.PuregoSafeRegister(&xSettingsSchemaHasKey, lib, "g_settings_schema_has_key") | |
| 503 | + | core.PuregoSafeRegister(&xSettingsSchemaListChildren, lib, "g_settings_schema_list_children") | |
| 504 | + | core.PuregoSafeRegister(&xSettingsSchemaListKeys, lib, "g_settings_schema_list_keys") | |
| 505 | + | core.PuregoSafeRegister(&xSettingsSchemaRef, lib, "g_settings_schema_ref") | |
| 506 | + | core.PuregoSafeRegister(&xSettingsSchemaUnref, lib, "g_settings_schema_unref") | |
| 507 | + | ||
| 508 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetDefaultValue, lib, "g_settings_schema_key_get_default_value") | |
| 509 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetDescription, lib, "g_settings_schema_key_get_description") | |
| 510 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetName, lib, "g_settings_schema_key_get_name") | |
| 511 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetRange, lib, "g_settings_schema_key_get_range") | |
| 512 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetSummary, lib, "g_settings_schema_key_get_summary") | |
| 513 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyGetValueType, lib, "g_settings_schema_key_get_value_type") | |
| 514 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyRangeCheck, lib, "g_settings_schema_key_range_check") | |
| 515 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyRef, lib, "g_settings_schema_key_ref") | |
| 516 | + | core.PuregoSafeRegister(&xSettingsSchemaKeyUnref, lib, "g_settings_schema_key_unref") | |
| 517 | + | ||
| 518 | + | core.PuregoSafeRegister(&xNewFromDirectorySettingsSchemaSource, lib, "g_settings_schema_source_new_from_directory") | |
| 519 | + | ||
| 520 | + | core.PuregoSafeRegister(&xSettingsSchemaSourceListSchemas, lib, "g_settings_schema_source_list_schemas") | |
| 521 | + | core.PuregoSafeRegister(&xSettingsSchemaSourceLookup, lib, "g_settings_schema_source_lookup") | |
| 522 | + | core.PuregoSafeRegister(&xSettingsSchemaSourceRef, lib, "g_settings_schema_source_ref") | |
| 523 | + | core.PuregoSafeRegister(&xSettingsSchemaSourceUnref, lib, "g_settings_schema_source_unref") | |
| 524 | + | ||
| 146 | 525 | } | |
M v4/gio/gsimpleactiongroup.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,9 +16,17 @@ type SimpleActionGroupClass struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *SimpleActionGroupClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | type SimpleActionGroupPrivate struct { | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *SimpleActionGroupPrivate) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | // #GSimpleActionGroup is a hash table filled with #GAction objects, | |
| 21 | 31 | // implementing the #GActionGroup and #GActionMap interfaces. | |
| 22 | 32 | type SimpleActionGroup struct { | |
M v4/gio/gsimpleasyncresult.go +28 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type SimpleAsyncResultClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *SimpleAsyncResultClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | var xSimpleAsyncReportErrorInIdle func(uintptr, uintptr, uintptr, glib.Quark, int, string, ...interface{}) | |
| 15 | 21 | ||
| 16 | 22 | // Reports an error in an asynchronous function in an idle function by | |
| @@ -559,6 +565,26 @@ func (x *SimpleAsyncResult) LegacyPropagateError() (bool, error) { | |||
| 559 | 565 | ||
| 560 | 566 | } | |
| 561 | 567 | ||
| 568 | + | var xSimpleAsyncResultIsValid func(uintptr, uintptr, uintptr) bool | |
| 569 | + | ||
| 570 | + | // Ensures that the data passed to the _finish function of an async | |
| 571 | + | // operation is consistent. Three checks are performed. | |
| 572 | + | // | |
| 573 | + | // First, @result is checked to ensure that it is really a | |
| 574 | + | // #GSimpleAsyncResult. Second, @source is checked to ensure that it | |
| 575 | + | // matches the source object of @result. Third, @source_tag is | |
| 576 | + | // checked to ensure that it is equal to the @source_tag argument given | |
| 577 | + | // to g_simple_async_result_new() (which, by convention, is a pointer | |
| 578 | + | // to the _async function corresponding to the _finish function from | |
| 579 | + | // which this function is called). (Alternatively, if either | |
| 580 | + | // @source_tag or @result's source tag is %NULL, then the source tag | |
| 581 | + | // check is skipped.) | |
| 582 | + | func SimpleAsyncResultIsValid(ResultVar AsyncResult, SourceVar *gobject.Object, SourceTagVar uintptr) bool { | |
| 583 | + | ||
| 584 | + | cret := xSimpleAsyncResultIsValid(ResultVar.GoPointer(), SourceVar.GoPointer(), SourceTagVar) | |
| 585 | + | return cret | |
| 586 | + | } | |
| 587 | + | ||
| 562 | 588 | func init() { | |
| 563 | 589 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 564 | 590 | if err != nil { | |
| @@ -591,4 +617,6 @@ func init() { | |||
| 591 | 617 | core.PuregoSafeRegister(&xSimpleAsyncResultSetOpResGssize, lib, "g_simple_async_result_set_op_res_gssize") | |
| 592 | 618 | core.PuregoSafeRegister(&xSimpleAsyncResultTakeError, lib, "g_simple_async_result_take_error") | |
| 593 | 619 | ||
| 620 | + | core.PuregoSafeRegister(&xSimpleAsyncResultIsValid, lib, "g_simple_async_result_is_valid") | |
| 621 | + | ||
| 594 | 622 | } | |
M v4/gio/gsimpleproxyresolver.go +31 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type SimpleProxyResolverClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SimpleProxyResolverClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SimpleProxyResolverPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SimpleProxyResolverPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GSimpleProxyResolver is a simple #GProxyResolver implementation | |
| 19 | 29 | // that handles a single default proxy, multiple URI-scheme-specific | |
| 20 | 30 | // proxies, and a list of hosts that proxies should not be used for. | |
| @@ -141,6 +151,25 @@ func (x *SimpleProxyResolver) LookupFinish(ResultVar AsyncResult) (uintptr, erro | |||
| 141 | 151 | ||
| 142 | 152 | } | |
| 143 | 153 | ||
| 154 | + | var xSimpleProxyResolverNew func(string, uintptr) uintptr | |
| 155 | + | ||
| 156 | + | // Creates a new #GSimpleProxyResolver. See | |
| 157 | + | // #GSimpleProxyResolver:default-proxy and | |
| 158 | + | // #GSimpleProxyResolver:ignore-hosts for more details on how the | |
| 159 | + | // arguments are interpreted. | |
| 160 | + | func SimpleProxyResolverNew(DefaultProxyVar string, IgnoreHostsVar uintptr) *ProxyResolverBase { | |
| 161 | + | var cls *ProxyResolverBase | |
| 162 | + | ||
| 163 | + | cret := xSimpleProxyResolverNew(DefaultProxyVar, IgnoreHostsVar) | |
| 164 | + | ||
| 165 | + | if cret == 0 { | |
| 166 | + | return nil | |
| 167 | + | } | |
| 168 | + | cls = &ProxyResolverBase{} | |
| 169 | + | cls.Ptr = cret | |
| 170 | + | return cls | |
| 171 | + | } | |
| 172 | + | ||
| 144 | 173 | func init() { | |
| 145 | 174 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 146 | 175 | if err != nil { | |
| @@ -151,4 +180,6 @@ func init() { | |||
| 151 | 180 | core.PuregoSafeRegister(&xSimpleProxyResolverSetIgnoreHosts, lib, "g_simple_proxy_resolver_set_ignore_hosts") | |
| 152 | 181 | core.PuregoSafeRegister(&xSimpleProxyResolverSetUriProxy, lib, "g_simple_proxy_resolver_set_uri_proxy") | |
| 153 | 182 | ||
| 183 | + | core.PuregoSafeRegister(&xSimpleProxyResolverNew, lib, "g_simple_proxy_resolver_new") | |
| 184 | + | ||
| 154 | 185 | } | |
M v4/gio/gsocket.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type SocketClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SocketPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SocketPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // A #GSocket is a low-level networking primitive. It is a more or less | |
| 19 | 29 | // direct mapping of the BSD socket API in a portable GObject based API. | |
| 20 | 30 | // It supports both the UNIX socket implementations and winsock2 on Windows. | |
M v4/gio/gsocketaddress.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type SocketAddressClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketAddressClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GSocketAddress is the equivalent of struct sockaddr in the BSD | |
| 16 | 22 | // sockets API. This is an abstract class; use #GInetSocketAddress | |
| 17 | 23 | // for internet sockets, or #GUnixSocketAddress for UNIX domain sockets. | |
M v4/gio/gsocketaddressenumerator.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type SocketAddressEnumeratorClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *SocketAddressEnumeratorClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GSocketAddressEnumerator is an enumerator type for #GSocketAddress | |
| 17 | 23 | // instances. It is returned by enumeration functions such as | |
| 18 | 24 | // g_socket_connectable_enumerate(), which returns a #GSocketAddressEnumerator | |
M v4/gio/gsocketclient.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type SocketClientClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketClientClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SocketClientPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SocketClientPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GSocketClient is a lightweight high-level utility class for connecting to | |
| 19 | 29 | // a network host using a connection oriented socket type. | |
| 20 | 30 | // | |
M v4/gio/gsocketconnectable.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -12,6 +14,10 @@ type SocketConnectableIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketConnectableIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // Objects that describe one or more potential socket endpoints | |
| 16 | 22 | // implement #GSocketConnectable. Callers can then use | |
| 17 | 23 | // g_socket_connectable_enumerate() to get a #GSocketAddressEnumerator | |
M v4/gio/gsocketconnection.go +37 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type SocketConnectionClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketConnectionClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SocketConnectionPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SocketConnectionPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // #GSocketConnection is a #GIOStream for a connected socket. They | |
| 19 | 29 | // can be created either by #GSocketClient when connecting to a host, | |
| 20 | 30 | // or by #GSocketListener when accepting a new client. | |
| @@ -169,6 +179,30 @@ func (c *SocketConnection) SetGoPointer(ptr uintptr) { | |||
| 169 | 179 | c.Ptr = ptr | |
| 170 | 180 | } | |
| 171 | 181 | ||
| 182 | + | var xSocketConnectionFactoryLookupType func(SocketFamily, SocketType, int) []interface{} | |
| 183 | + | ||
| 184 | + | // Looks up the #GType to be used when creating socket connections on | |
| 185 | + | // sockets with the specified @family, @type and @protocol_id. | |
| 186 | + | // | |
| 187 | + | // If no type is registered, the #GSocketConnection base type is returned. | |
| 188 | + | func SocketConnectionFactoryLookupType(FamilyVar SocketFamily, TypeVar SocketType, ProtocolIdVar int) []interface{} { | |
| 189 | + | ||
| 190 | + | cret := xSocketConnectionFactoryLookupType(FamilyVar, TypeVar, ProtocolIdVar) | |
| 191 | + | return cret | |
| 192 | + | } | |
| 193 | + | ||
| 194 | + | var xSocketConnectionFactoryRegisterType func([]interface{}, SocketFamily, SocketType, int) | |
| 195 | + | ||
| 196 | + | // Looks up the #GType to be used when creating socket connections on | |
| 197 | + | // sockets with the specified @family, @type and @protocol. | |
| 198 | + | // | |
| 199 | + | // If no type is registered, the #GSocketConnection base type is returned. | |
| 200 | + | func SocketConnectionFactoryRegisterType(GTypeVar []interface{}, FamilyVar SocketFamily, TypeVar SocketType, ProtocolVar int) { | |
| 201 | + | ||
| 202 | + | xSocketConnectionFactoryRegisterType(GTypeVar, FamilyVar, TypeVar, ProtocolVar) | |
| 203 | + | ||
| 204 | + | } | |
| 205 | + | ||
| 172 | 206 | func init() { | |
| 173 | 207 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 174 | 208 | if err != nil { | |
| @@ -183,4 +217,7 @@ func init() { | |||
| 183 | 217 | core.PuregoSafeRegister(&xSocketConnectionGetSocket, lib, "g_socket_connection_get_socket") | |
| 184 | 218 | core.PuregoSafeRegister(&xSocketConnectionIsConnected, lib, "g_socket_connection_is_connected") | |
| 185 | 219 | ||
| 220 | + | core.PuregoSafeRegister(&xSocketConnectionFactoryLookupType, lib, "g_socket_connection_factory_lookup_type") | |
| 221 | + | core.PuregoSafeRegister(&xSocketConnectionFactoryRegisterType, lib, "g_socket_connection_factory_register_type") | |
| 222 | + | ||
| 186 | 223 | } | |
M v4/gio/gsocketcontrolmessage.go +34 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,9 +14,17 @@ type SocketControlMessageClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketControlMessageClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SocketControlMessagePrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SocketControlMessagePrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // A #GSocketControlMessage is a special-purpose utility message that | |
| 19 | 29 | // can be sent to or received from a #GSocket. These types of | |
| 20 | 30 | // messages are often called "ancillary data". | |
| @@ -97,6 +107,28 @@ func (c *SocketControlMessage) SetGoPointer(ptr uintptr) { | |||
| 97 | 107 | c.Ptr = ptr | |
| 98 | 108 | } | |
| 99 | 109 | ||
| 110 | + | var xSocketControlMessageDeserialize func(int, int, uint, uintptr) uintptr | |
| 111 | + | ||
| 112 | + | // Tries to deserialize a socket control message of a given | |
| 113 | + | // @level and @type. This will ask all known (to GType) subclasses | |
| 114 | + | // of #GSocketControlMessage if they can understand this kind | |
| 115 | + | // of message and if so deserialize it into a #GSocketControlMessage. | |
| 116 | + | // | |
| 117 | + | // If there is no implementation for this kind of control message, %NULL | |
| 118 | + | // will be returned. | |
| 119 | + | func SocketControlMessageDeserialize(LevelVar int, TypeVar int, SizeVar uint, DataVar uintptr) *SocketControlMessage { | |
| 120 | + | var cls *SocketControlMessage | |
| 121 | + | ||
| 122 | + | cret := xSocketControlMessageDeserialize(LevelVar, TypeVar, SizeVar, DataVar) | |
| 123 | + | ||
| 124 | + | if cret == 0 { | |
| 125 | + | return nil | |
| 126 | + | } | |
| 127 | + | cls = &SocketControlMessage{} | |
| 128 | + | cls.Ptr = cret | |
| 129 | + | return cls | |
| 130 | + | } | |
| 131 | + | ||
| 100 | 132 | func init() { | |
| 101 | 133 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 102 | 134 | if err != nil { | |
| @@ -108,4 +140,6 @@ func init() { | |||
| 108 | 140 | core.PuregoSafeRegister(&xSocketControlMessageGetSize, lib, "g_socket_control_message_get_size") | |
| 109 | 141 | core.PuregoSafeRegister(&xSocketControlMessageSerialize, lib, "g_socket_control_message_serialize") | |
| 110 | 142 | ||
| 143 | + | core.PuregoSafeRegister(&xSocketControlMessageDeserialize, lib, "g_socket_control_message_deserialize") | |
| 144 | + | ||
| 111 | 145 | } | |
M v4/gio/gsocketlistener.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,9 +15,17 @@ type SocketListenerClass struct { | |||
| 13 | 15 | ParentClass uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *SocketListenerClass) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | type SocketListenerPrivate struct { | |
| 17 | 23 | } | |
| 18 | 24 | ||
| 25 | + | func (x *SocketListenerPrivate) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 19 | 29 | // A #GSocketListener is an object that keeps track of a set | |
| 20 | 30 | // of server sockets and helps you accept sockets from any of the | |
| 21 | 31 | // socket, either sync or async. | |
M v4/gio/gsocketservice.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,9 +14,17 @@ type SocketServiceClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *SocketServiceClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type SocketServicePrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *SocketServicePrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // A #GSocketService is an object that represents a service that | |
| 19 | 29 | // is provided to the network or over local sockets. When a new | |
| 20 | 30 | // connection is made to the service the #GSocketService::incoming | |
M v4/gio/gtask.go +54 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -28,6 +30,10 @@ type TaskThreadFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 28 | 30 | type TaskClass struct { | |
| 29 | 31 | } | |
| 30 | 32 | ||
| 33 | + | func (x *TaskClass) GoPointer() uintptr { | |
| 34 | + | return uintptr(unsafe.Pointer(x)) | |
| 35 | + | } | |
| 36 | + | ||
| 31 | 37 | // A #GTask represents and manages a cancellable "task". | |
| 32 | 38 | // | |
| 33 | 39 | // ## Asynchronous operations | |
| @@ -1120,6 +1126,50 @@ func (x *Task) LegacyPropagateError() (bool, error) { | |||
| 1120 | 1126 | ||
| 1121 | 1127 | } | |
| 1122 | 1128 | ||
| 1129 | + | var xTaskIsValid func(uintptr, uintptr) bool | |
| 1130 | + | ||
| 1131 | + | // Checks that @result is a #GTask, and that @source_object is its | |
| 1132 | + | // source object (or that @source_object is %NULL and @result has no | |
| 1133 | + | // source object). This can be used in g_return_if_fail() checks. | |
| 1134 | + | func TaskIsValid(ResultVar AsyncResult, SourceObjectVar *gobject.Object) bool { | |
| 1135 | + | ||
| 1136 | + | cret := xTaskIsValid(ResultVar.GoPointer(), SourceObjectVar.GoPointer()) | |
| 1137 | + | return cret | |
| 1138 | + | } | |
| 1139 | + | ||
| 1140 | + | var xTaskReportError func(uintptr, uintptr, uintptr, uintptr, *glib.Error) | |
| 1141 | + | ||
| 1142 | + | // Creates a #GTask and then immediately calls g_task_return_error() | |
| 1143 | + | // on it. Use this in the wrapper function of an asynchronous method | |
| 1144 | + | // when you want to avoid even calling the virtual method. You can | |
| 1145 | + | // then use g_async_result_is_tagged() in the finish method wrapper to | |
| 1146 | + | // check if the result there is tagged as having been created by the | |
| 1147 | + | // wrapper method, and deal with it appropriately if so. | |
| 1148 | + | // | |
| 1149 | + | // See also g_task_report_new_error(). | |
| 1150 | + | func TaskReportError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, ErrorVar *glib.Error) { | |
| 1151 | + | ||
| 1152 | + | xTaskReportError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, ErrorVar) | |
| 1153 | + | ||
| 1154 | + | } | |
| 1155 | + | ||
| 1156 | + | var xTaskReportNewError func(uintptr, uintptr, uintptr, uintptr, glib.Quark, int, string, ...interface{}) | |
| 1157 | + | ||
| 1158 | + | // Creates a #GTask and then immediately calls | |
| 1159 | + | // g_task_return_new_error() on it. Use this in the wrapper function | |
| 1160 | + | // of an asynchronous method when you want to avoid even calling the | |
| 1161 | + | // virtual method. You can then use g_async_result_is_tagged() in the | |
| 1162 | + | // finish method wrapper to check if the result there is tagged as | |
| 1163 | + | // having been created by the wrapper method, and deal with it | |
| 1164 | + | // appropriately if so. | |
| 1165 | + | // | |
| 1166 | + | // See also g_task_report_error(). | |
| 1167 | + | func TaskReportNewError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) { | |
| 1168 | + | ||
| 1169 | + | xTaskReportNewError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 1170 | + | ||
| 1171 | + | } | |
| 1172 | + | ||
| 1123 | 1173 | func init() { | |
| 1124 | 1174 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 1125 | 1175 | if err != nil { | |
| @@ -1160,4 +1210,8 @@ func init() { | |||
| 1160 | 1210 | core.PuregoSafeRegister(&xTaskSetSourceTag, lib, "g_task_set_source_tag") | |
| 1161 | 1211 | core.PuregoSafeRegister(&xTaskSetTaskData, lib, "g_task_set_task_data") | |
| 1162 | 1212 | ||
| 1213 | + | core.PuregoSafeRegister(&xTaskIsValid, lib, "g_task_is_valid") | |
| 1214 | + | core.PuregoSafeRegister(&xTaskReportError, lib, "g_task_report_error") | |
| 1215 | + | core.PuregoSafeRegister(&xTaskReportNewError, lib, "g_task_report_new_error") | |
| 1216 | + | ||
| 1163 | 1217 | } | |
M v4/gio/gtcpconnection.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -10,9 +12,17 @@ type TcpConnectionClass struct { | |||
| 10 | 12 | ParentClass uintptr | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *TcpConnectionClass) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | type TcpConnectionPrivate struct { | |
| 14 | 20 | } | |
| 15 | 21 | ||
| 22 | + | func (x *TcpConnectionPrivate) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 16 | 26 | // This is the subclass of #GSocketConnection that is created | |
| 17 | 27 | // for TCP/IP sockets. | |
| 18 | 28 | type TcpConnection struct { | |
M v4/gio/gtcpwrapperconnection.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type TcpWrapperConnectionClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *TcpWrapperConnectionClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type TcpWrapperConnectionPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *TcpWrapperConnectionPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // A #GTcpWrapperConnection can be used to wrap a #GIOStream that is | |
| 18 | 28 | // based on a #GSocket, but which is not actually a | |
| 19 | 29 | // #GSocketConnection. This is used by #GSocketClient so that it can | |
M v4/gio/gthemedicon.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,6 +13,10 @@ import ( | |||
| 11 | 13 | type ThemedIconClass struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *ThemedIconClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | // #GThemedIcon is an implementation of #GIcon that supports icon themes. | |
| 15 | 21 | // #GThemedIcon contains a list of all of the icons present in an icon | |
| 16 | 22 | // theme, so that icons can be looked up quickly. #GThemedIcon does | |
M v4/gio/gthreadedsocketservice.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -11,9 +13,17 @@ type ThreadedSocketServiceClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *ThreadedSocketServiceClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type ThreadedSocketServicePrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *ThreadedSocketServicePrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // A #GThreadedSocketService is a simple subclass of #GSocketService | |
| 18 | 28 | // that handles incoming connections by creating a worker thread and | |
| 19 | 29 | // dispatching the connection to it by emitting the | |
M v4/gio/gtlsbackend.go +12 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,6 +14,10 @@ type TlsBackendInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *TlsBackendInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // TLS (Transport Layer Security, aka SSL) and DTLS backend. | |
| 16 | 22 | type TlsBackend interface { | |
| 17 | 23 | GoPointer() uintptr | |
| @@ -136,6 +142,12 @@ var XGTlsBackendSetDefaultDatabase func(uintptr, uintptr) | |||
| 136 | 142 | var XGTlsBackendSupportsDtls func(uintptr) bool | |
| 137 | 143 | var XGTlsBackendSupportsTls func(uintptr) bool | |
| 138 | 144 | ||
| 145 | + | const ( | |
| 146 | + | // Extension point for TLS functionality via #GTlsBackend. | |
| 147 | + | // See [Extending GIO][extending-gio]. | |
| 148 | + | TLS_BACKEND_EXTENSION_POINT_NAME string = "gio-tls-backend" | |
| 149 | + | ) | |
| 150 | + | ||
| 139 | 151 | var xTlsBackendGetDefault func() uintptr | |
| 140 | 152 | ||
| 141 | 153 | // Gets the default #GTlsBackend for the system. | |
M v4/gio/gtlscertificate.go +30 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,9 +16,17 @@ type TlsCertificateClass struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *TlsCertificateClass) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | type TlsCertificatePrivate struct { | |
| 18 | 24 | } | |
| 19 | 25 | ||
| 26 | + | func (x *TlsCertificatePrivate) GoPointer() uintptr { | |
| 27 | + | return uintptr(unsafe.Pointer(x)) | |
| 28 | + | } | |
| 29 | + | ||
| 20 | 30 | // A certificate used for TLS authentication and encryption. | |
| 21 | 31 | // This can represent either a certificate only (eg, the certificate | |
| 22 | 32 | // received by a client from a server), or the combination of | |
| @@ -372,6 +382,24 @@ func (c *TlsCertificate) SetGoPointer(ptr uintptr) { | |||
| 372 | 382 | c.Ptr = ptr | |
| 373 | 383 | } | |
| 374 | 384 | ||
| 385 | + | var xTlsCertificateListNewFromFile func(string, **glib.Error) *glib.List | |
| 386 | + | ||
| 387 | + | // Creates one or more #GTlsCertificates from the PEM-encoded | |
| 388 | + | // data in @file. If @file cannot be read or parsed, the function will | |
| 389 | + | // return %NULL and set @error. If @file does not contain any | |
| 390 | + | // PEM-encoded certificates, this will return an empty list and not | |
| 391 | + | // set @error. | |
| 392 | + | func TlsCertificateListNewFromFile(FileVar string) (*glib.List, error) { | |
| 393 | + | var cerr *glib.Error | |
| 394 | + | ||
| 395 | + | cret := xTlsCertificateListNewFromFile(FileVar, &cerr) | |
| 396 | + | if cerr == nil { | |
| 397 | + | return cret, nil | |
| 398 | + | } | |
| 399 | + | return cret, cerr | |
| 400 | + | ||
| 401 | + | } | |
| 402 | + | ||
| 375 | 403 | func init() { | |
| 376 | 404 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 377 | 405 | if err != nil { | |
| @@ -395,4 +423,6 @@ func init() { | |||
| 395 | 423 | core.PuregoSafeRegister(&xTlsCertificateIsSame, lib, "g_tls_certificate_is_same") | |
| 396 | 424 | core.PuregoSafeRegister(&xTlsCertificateVerify, lib, "g_tls_certificate_verify") | |
| 397 | 425 | ||
| 426 | + | core.PuregoSafeRegister(&xTlsCertificateListNewFromFile, lib, "g_tls_certificate_list_new_from_file") | |
| 427 | + | ||
| 398 | 428 | } | |
M v4/gio/gtlsclientconnection.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,6 +15,10 @@ type TlsClientConnectionInterface struct { | |||
| 13 | 15 | GIface uintptr | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *TlsClientConnectionInterface) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // #GTlsClientConnection is the client-side subclass of | |
| 17 | 23 | // #GTlsConnection, representing a client-side TLS connection. | |
| 18 | 24 | type TlsClientConnection interface { | |
M v4/gio/gtlsconnection.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type TlsConnectionClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *TlsConnectionClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type TlsConnectionPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *TlsConnectionPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // #GTlsConnection is the base TLS connection class type, which wraps | |
| 22 | 32 | // a #GIOStream and provides TLS encryption on top of it. Its | |
| 23 | 33 | // subclasses, #GTlsClientConnection and #GTlsServerConnection, | |
M v4/gio/gtlsdatabase.go +19 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -17,9 +19,26 @@ type TlsDatabaseClass struct { | |||
| 17 | 19 | Padding uintptr | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *TlsDatabaseClass) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 20 | 26 | type TlsDatabasePrivate struct { | |
| 21 | 27 | } | |
| 22 | 28 | ||
| 29 | + | func (x *TlsDatabasePrivate) GoPointer() uintptr { | |
| 30 | + | return uintptr(unsafe.Pointer(x)) | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | const ( | |
| 34 | + | // The purpose used to verify the client certificate in a TLS connection. | |
| 35 | + | // Used by TLS servers. | |
| 36 | + | TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT string = "1.3.6.1.5.5.7.3.2" | |
| 37 | + | // The purpose used to verify the server certificate in a TLS connection. This | |
| 38 | + | // is the most common purpose in use. Used by TLS clients. | |
| 39 | + | TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER string = "1.3.6.1.5.5.7.3.1" | |
| 40 | + | ) | |
| 41 | + | ||
| 23 | 42 | // #GTlsDatabase is used to look up certificates and other information | |
| 24 | 43 | // from a certificate or key store. It is an abstract base class which | |
| 25 | 44 | // TLS library specific subtypes override. | |
M v4/gio/gtlsfiledatabase.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -14,6 +16,10 @@ type TlsFileDatabaseInterface struct { | |||
| 14 | 16 | Padding uintptr | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *TlsFileDatabaseInterface) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | // #GTlsFileDatabase is implemented by #GTlsDatabase objects which load | |
| 18 | 24 | // their certificate information from a file. It is an interface which | |
| 19 | 25 | // TLS library specific subtypes implement. | |
M v4/gio/gtlsinteraction.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -28,9 +30,17 @@ type TlsInteractionClass struct { | |||
| 28 | 30 | Padding uintptr | |
| 29 | 31 | } | |
| 30 | 32 | ||
| 33 | + | func (x *TlsInteractionClass) GoPointer() uintptr { | |
| 34 | + | return uintptr(unsafe.Pointer(x)) | |
| 35 | + | } | |
| 36 | + | ||
| 31 | 37 | type TlsInteractionPrivate struct { | |
| 32 | 38 | } | |
| 33 | 39 | ||
| 40 | + | func (x *TlsInteractionPrivate) GoPointer() uintptr { | |
| 41 | + | return uintptr(unsafe.Pointer(x)) | |
| 42 | + | } | |
| 43 | + | ||
| 34 | 44 | // #GTlsInteraction provides a mechanism for the TLS connection and database | |
| 35 | 45 | // code to interact with the user. It can be used to ask the user for passwords. | |
| 36 | 46 | // | |
M v4/gio/gtlspassword.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -15,9 +17,17 @@ type TlsPasswordClass struct { | |||
| 15 | 17 | Padding uintptr | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *TlsPasswordClass) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | type TlsPasswordPrivate struct { | |
| 19 | 25 | } | |
| 20 | 26 | ||
| 27 | + | func (x *TlsPasswordPrivate) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 21 | 31 | // Holds a password used in TLS. | |
| 22 | 32 | type TlsPassword struct { | |
| 23 | 33 | gobject.Object | |
M v4/gio/gtlsserverconnection.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type TlsServerConnectionInterface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *TlsServerConnectionInterface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GTlsServerConnection is the server-side subclass of #GTlsConnection, | |
| 16 | 22 | // representing a server-side TLS connection. | |
| 17 | 23 | type TlsServerConnection interface { | |
M v4/gio/gunixconnection.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type UnixConnectionClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *UnixConnectionClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type UnixConnectionPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *UnixConnectionPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // This is the subclass of #GSocketConnection that is created | |
| 18 | 28 | // for UNIX domain sockets. | |
| 19 | 29 | // | |
M v4/gio/gunixcredentialsmessage.go +21 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| @@ -12,9 +14,17 @@ type UnixCredentialsMessageClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *UnixCredentialsMessageClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type UnixCredentialsMessagePrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *UnixCredentialsMessagePrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // This #GSocketControlMessage contains a #GCredentials instance. It | |
| 19 | 29 | // may be sent using g_socket_send_message() and received using | |
| 20 | 30 | // g_socket_receive_message() over UNIX sockets (ie: sockets in the | |
| @@ -101,6 +111,15 @@ func (c *UnixCredentialsMessage) SetGoPointer(ptr uintptr) { | |||
| 101 | 111 | c.Ptr = ptr | |
| 102 | 112 | } | |
| 103 | 113 | ||
| 114 | + | var xUnixCredentialsMessageIsSupported func() bool | |
| 115 | + | ||
| 116 | + | // Checks if passing #GCredentials on a #GSocket is supported on this platform. | |
| 117 | + | func UnixCredentialsMessageIsSupported() bool { | |
| 118 | + | ||
| 119 | + | cret := xUnixCredentialsMessageIsSupported() | |
| 120 | + | return cret | |
| 121 | + | } | |
| 122 | + | ||
| 104 | 123 | func init() { | |
| 105 | 124 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 106 | 125 | if err != nil { | |
| @@ -112,4 +131,6 @@ func init() { | |||
| 112 | 131 | ||
| 113 | 132 | core.PuregoSafeRegister(&xUnixCredentialsMessageGetCredentials, lib, "g_unix_credentials_message_get_credentials") | |
| 114 | 133 | ||
| 134 | + | core.PuregoSafeRegister(&xUnixCredentialsMessageIsSupported, lib, "g_unix_credentials_message_is_supported") | |
| 135 | + | ||
| 115 | 136 | } | |
M v4/gio/gunixfdlist.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type UnixFDListClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *UnixFDListClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type UnixFDListPrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *UnixFDListPrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // A #GUnixFDList contains a list of file descriptors. It owns the file | |
| 19 | 29 | // descriptors that it contains, closing them when finalized. | |
| 20 | 30 | // | |
M v4/gio/gunixfdmessage.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,9 +14,17 @@ type UnixFDMessageClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *UnixFDMessageClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | type UnixFDMessagePrivate struct { | |
| 16 | 22 | } | |
| 17 | 23 | ||
| 24 | + | func (x *UnixFDMessagePrivate) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 18 | 28 | // This #GSocketControlMessage contains a #GUnixFDList. | |
| 19 | 29 | // It may be sent using g_socket_send_message() and received using | |
| 20 | 30 | // g_socket_receive_message() over UNIX sockets (ie: sockets in the | |
M v4/gio/gunixinputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type UnixInputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *UnixInputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type UnixInputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *UnixInputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // #GUnixInputStream implements #GInputStream for reading from a UNIX | |
| 18 | 28 | // file descriptor, including asynchronous operations. (If the file | |
| 19 | 29 | // descriptor refers to a socket or pipe, this will use poll() to do | |
M v4/gio/gunixmounts.go +196 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -13,14 +15,167 @@ import ( | |||
| 13 | 15 | type UnixMountEntry struct { | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *UnixMountEntry) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | type UnixMountMonitorClass struct { | |
| 17 | 23 | } | |
| 18 | 24 | ||
| 25 | + | func (x *UnixMountMonitorClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 19 | 29 | // Defines a Unix mount point (e.g. <filename>/dev</filename>). | |
| 20 | 30 | // This corresponds roughly to a fstab entry. | |
| 21 | 31 | type UnixMountPoint struct { | |
| 22 | 32 | } | |
| 23 | 33 | ||
| 34 | + | func (x *UnixMountPoint) GoPointer() uintptr { | |
| 35 | + | return uintptr(unsafe.Pointer(x)) | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | var xUnixMountPointCompare func(uintptr, *UnixMountPoint) int | |
| 39 | + | ||
| 40 | + | // Compares two unix mount points. | |
| 41 | + | func (x *UnixMountPoint) Compare(Mount2Var *UnixMountPoint) int { | |
| 42 | + | ||
| 43 | + | cret := xUnixMountPointCompare(x.GoPointer(), Mount2Var) | |
| 44 | + | return cret | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | var xUnixMountPointCopy func(uintptr) *UnixMountPoint | |
| 48 | + | ||
| 49 | + | // Makes a copy of @mount_point. | |
| 50 | + | func (x *UnixMountPoint) Copy() *UnixMountPoint { | |
| 51 | + | ||
| 52 | + | cret := xUnixMountPointCopy(x.GoPointer()) | |
| 53 | + | return cret | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | var xUnixMountPointFree func(uintptr) | |
| 57 | + | ||
| 58 | + | // Frees a unix mount point. | |
| 59 | + | func (x *UnixMountPoint) Free() { | |
| 60 | + | ||
| 61 | + | xUnixMountPointFree(x.GoPointer()) | |
| 62 | + | ||
| 63 | + | } | |
| 64 | + | ||
| 65 | + | var xUnixMountPointGetDevicePath func(uintptr) string | |
| 66 | + | ||
| 67 | + | // Gets the device path for a unix mount point. | |
| 68 | + | func (x *UnixMountPoint) GetDevicePath() string { | |
| 69 | + | ||
| 70 | + | cret := xUnixMountPointGetDevicePath(x.GoPointer()) | |
| 71 | + | return cret | |
| 72 | + | } | |
| 73 | + | ||
| 74 | + | var xUnixMountPointGetFsType func(uintptr) string | |
| 75 | + | ||
| 76 | + | // Gets the file system type for the mount point. | |
| 77 | + | func (x *UnixMountPoint) GetFsType() string { | |
| 78 | + | ||
| 79 | + | cret := xUnixMountPointGetFsType(x.GoPointer()) | |
| 80 | + | return cret | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xUnixMountPointGetMountPath func(uintptr) string | |
| 84 | + | ||
| 85 | + | // Gets the mount path for a unix mount point. | |
| 86 | + | func (x *UnixMountPoint) GetMountPath() string { | |
| 87 | + | ||
| 88 | + | cret := xUnixMountPointGetMountPath(x.GoPointer()) | |
| 89 | + | return cret | |
| 90 | + | } | |
| 91 | + | ||
| 92 | + | var xUnixMountPointGetOptions func(uintptr) string | |
| 93 | + | ||
| 94 | + | // Gets the options for the mount point. | |
| 95 | + | func (x *UnixMountPoint) GetOptions() string { | |
| 96 | + | ||
| 97 | + | cret := xUnixMountPointGetOptions(x.GoPointer()) | |
| 98 | + | return cret | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | var xUnixMountPointGuessCanEject func(uintptr) bool | |
| 102 | + | ||
| 103 | + | // Guesses whether a Unix mount point can be ejected. | |
| 104 | + | func (x *UnixMountPoint) GuessCanEject() bool { | |
| 105 | + | ||
| 106 | + | cret := xUnixMountPointGuessCanEject(x.GoPointer()) | |
| 107 | + | return cret | |
| 108 | + | } | |
| 109 | + | ||
| 110 | + | var xUnixMountPointGuessIcon func(uintptr) uintptr | |
| 111 | + | ||
| 112 | + | // Guesses the icon of a Unix mount point. | |
| 113 | + | func (x *UnixMountPoint) GuessIcon() *IconBase { | |
| 114 | + | var cls *IconBase | |
| 115 | + | ||
| 116 | + | cret := xUnixMountPointGuessIcon(x.GoPointer()) | |
| 117 | + | ||
| 118 | + | if cret == 0 { | |
| 119 | + | return nil | |
| 120 | + | } | |
| 121 | + | cls = &IconBase{} | |
| 122 | + | cls.Ptr = cret | |
| 123 | + | return cls | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | var xUnixMountPointGuessName func(uintptr) string | |
| 127 | + | ||
| 128 | + | // Guesses the name of a Unix mount point. | |
| 129 | + | // The result is a translated string. | |
| 130 | + | func (x *UnixMountPoint) GuessName() string { | |
| 131 | + | ||
| 132 | + | cret := xUnixMountPointGuessName(x.GoPointer()) | |
| 133 | + | return cret | |
| 134 | + | } | |
| 135 | + | ||
| 136 | + | var xUnixMountPointGuessSymbolicIcon func(uintptr) uintptr | |
| 137 | + | ||
| 138 | + | // Guesses the symbolic icon of a Unix mount point. | |
| 139 | + | func (x *UnixMountPoint) GuessSymbolicIcon() *IconBase { | |
| 140 | + | var cls *IconBase | |
| 141 | + | ||
| 142 | + | cret := xUnixMountPointGuessSymbolicIcon(x.GoPointer()) | |
| 143 | + | ||
| 144 | + | if cret == 0 { | |
| 145 | + | return nil | |
| 146 | + | } | |
| 147 | + | cls = &IconBase{} | |
| 148 | + | cls.Ptr = cret | |
| 149 | + | return cls | |
| 150 | + | } | |
| 151 | + | ||
| 152 | + | var xUnixMountPointIsLoopback func(uintptr) bool | |
| 153 | + | ||
| 154 | + | // Checks if a unix mount point is a loopback device. | |
| 155 | + | func (x *UnixMountPoint) IsLoopback() bool { | |
| 156 | + | ||
| 157 | + | cret := xUnixMountPointIsLoopback(x.GoPointer()) | |
| 158 | + | return cret | |
| 159 | + | } | |
| 160 | + | ||
| 161 | + | var xUnixMountPointIsReadonly func(uintptr) bool | |
| 162 | + | ||
| 163 | + | // Checks if a unix mount point is read only. | |
| 164 | + | func (x *UnixMountPoint) IsReadonly() bool { | |
| 165 | + | ||
| 166 | + | cret := xUnixMountPointIsReadonly(x.GoPointer()) | |
| 167 | + | return cret | |
| 168 | + | } | |
| 169 | + | ||
| 170 | + | var xUnixMountPointIsUserMountable func(uintptr) bool | |
| 171 | + | ||
| 172 | + | // Checks if a unix mount point is mountable by the user. | |
| 173 | + | func (x *UnixMountPoint) IsUserMountable() bool { | |
| 174 | + | ||
| 175 | + | cret := xUnixMountPointIsUserMountable(x.GoPointer()) | |
| 176 | + | return cret | |
| 177 | + | } | |
| 178 | + | ||
| 24 | 179 | var xUnixIsMountPathSystemInternal func(string) bool | |
| 25 | 180 | ||
| 26 | 181 | // Determines if @mount_path is considered an implementation of the | |
| @@ -393,6 +548,30 @@ func (x *UnixMountMonitor) ConnectMountsChanged(cb func(UnixMountMonitor)) uint3 | |||
| 393 | 548 | return gobject.SignalConnect(x.GoPointer(), "mounts-changed", purego.NewCallback(fcb)) | |
| 394 | 549 | } | |
| 395 | 550 | ||
| 551 | + | var xUnixMountMonitorGet func() uintptr | |
| 552 | + | ||
| 553 | + | // Gets the #GUnixMountMonitor for the current thread-default main | |
| 554 | + | // context. | |
| 555 | + | // | |
| 556 | + | // The mount monitor can be used to monitor for changes to the list of | |
| 557 | + | // mounted filesystems as well as the list of mount points (ie: fstab | |
| 558 | + | // entries). | |
| 559 | + | // | |
| 560 | + | // You must only call g_object_unref() on the return value from under | |
| 561 | + | // the same main context as you called this function. | |
| 562 | + | func UnixMountMonitorGet() *UnixMountMonitor { | |
| 563 | + | var cls *UnixMountMonitor | |
| 564 | + | ||
| 565 | + | cret := xUnixMountMonitorGet() | |
| 566 | + | ||
| 567 | + | if cret == 0 { | |
| 568 | + | return nil | |
| 569 | + | } | |
| 570 | + | cls = &UnixMountMonitor{} | |
| 571 | + | cls.Ptr = cret | |
| 572 | + | return cls | |
| 573 | + | } | |
| 574 | + | ||
| 396 | 575 | func init() { | |
| 397 | 576 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 398 | 577 | if err != nil { | |
| @@ -424,8 +603,25 @@ func init() { | |||
| 424 | 603 | core.PuregoSafeRegister(&xUnixMountsChangedSince, lib, "g_unix_mounts_changed_since") | |
| 425 | 604 | core.PuregoSafeRegister(&xUnixMountsGet, lib, "g_unix_mounts_get") | |
| 426 | 605 | ||
| 606 | + | core.PuregoSafeRegister(&xUnixMountPointCompare, lib, "g_unix_mount_point_compare") | |
| 607 | + | core.PuregoSafeRegister(&xUnixMountPointCopy, lib, "g_unix_mount_point_copy") | |
| 608 | + | core.PuregoSafeRegister(&xUnixMountPointFree, lib, "g_unix_mount_point_free") | |
| 609 | + | core.PuregoSafeRegister(&xUnixMountPointGetDevicePath, lib, "g_unix_mount_point_get_device_path") | |
| 610 | + | core.PuregoSafeRegister(&xUnixMountPointGetFsType, lib, "g_unix_mount_point_get_fs_type") | |
| 611 | + | core.PuregoSafeRegister(&xUnixMountPointGetMountPath, lib, "g_unix_mount_point_get_mount_path") | |
| 612 | + | core.PuregoSafeRegister(&xUnixMountPointGetOptions, lib, "g_unix_mount_point_get_options") | |
| 613 | + | core.PuregoSafeRegister(&xUnixMountPointGuessCanEject, lib, "g_unix_mount_point_guess_can_eject") | |
| 614 | + | core.PuregoSafeRegister(&xUnixMountPointGuessIcon, lib, "g_unix_mount_point_guess_icon") | |
| 615 | + | core.PuregoSafeRegister(&xUnixMountPointGuessName, lib, "g_unix_mount_point_guess_name") | |
| 616 | + | core.PuregoSafeRegister(&xUnixMountPointGuessSymbolicIcon, lib, "g_unix_mount_point_guess_symbolic_icon") | |
| 617 | + | core.PuregoSafeRegister(&xUnixMountPointIsLoopback, lib, "g_unix_mount_point_is_loopback") | |
| 618 | + | core.PuregoSafeRegister(&xUnixMountPointIsReadonly, lib, "g_unix_mount_point_is_readonly") | |
| 619 | + | core.PuregoSafeRegister(&xUnixMountPointIsUserMountable, lib, "g_unix_mount_point_is_user_mountable") | |
| 620 | + | ||
| 427 | 621 | core.PuregoSafeRegister(&xNewUnixMountMonitor, lib, "g_unix_mount_monitor_new") | |
| 428 | 622 | ||
| 429 | 623 | core.PuregoSafeRegister(&xUnixMountMonitorSetRateLimit, lib, "g_unix_mount_monitor_set_rate_limit") | |
| 430 | 624 | ||
| 625 | + | core.PuregoSafeRegister(&xUnixMountMonitorGet, lib, "g_unix_mount_monitor_get") | |
| 626 | + | ||
| 431 | 627 | } | |
M v4/gio/gunixoutputstream.go +10 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -11,9 +13,17 @@ type UnixOutputStreamClass struct { | |||
| 11 | 13 | ParentClass uintptr | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *UnixOutputStreamClass) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 14 | 20 | type UnixOutputStreamPrivate struct { | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 23 | + | func (x *UnixOutputStreamPrivate) GoPointer() uintptr { | |
| 24 | + | return uintptr(unsafe.Pointer(x)) | |
| 25 | + | } | |
| 26 | + | ||
| 17 | 27 | // #GUnixOutputStream implements #GOutputStream for writing to a UNIX | |
| 18 | 28 | // file descriptor, including asynchronous operations. (If the file | |
| 19 | 29 | // descriptor refers to a socket or pipe, this will use poll() to do | |
M v4/gio/gunixsocketaddress.go +21 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -10,9 +12,17 @@ type UnixSocketAddressClass struct { | |||
| 10 | 12 | ParentClass uintptr | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *UnixSocketAddressClass) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | type UnixSocketAddressPrivate struct { | |
| 14 | 20 | } | |
| 15 | 21 | ||
| 22 | + | func (x *UnixSocketAddressPrivate) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 16 | 26 | // Support for UNIX-domain (also known as local) sockets. | |
| 17 | 27 | // | |
| 18 | 28 | // UNIX domain sockets are generally visible in the filesystem. | |
| @@ -221,6 +231,15 @@ func (x *UnixSocketAddress) ToString() string { | |||
| 221 | 231 | return cret | |
| 222 | 232 | } | |
| 223 | 233 | ||
| 234 | + | var xUnixSocketAddressAbstractNamesSupported func() bool | |
| 235 | + | ||
| 236 | + | // Checks if abstract UNIX domain socket names are supported. | |
| 237 | + | func UnixSocketAddressAbstractNamesSupported() bool { | |
| 238 | + | ||
| 239 | + | cret := xUnixSocketAddressAbstractNamesSupported() | |
| 240 | + | return cret | |
| 241 | + | } | |
| 242 | + | ||
| 224 | 243 | func init() { | |
| 225 | 244 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 226 | 245 | if err != nil { | |
| @@ -236,4 +255,6 @@ func init() { | |||
| 236 | 255 | core.PuregoSafeRegister(&xUnixSocketAddressGetPath, lib, "g_unix_socket_address_get_path") | |
| 237 | 256 | core.PuregoSafeRegister(&xUnixSocketAddressGetPathLen, lib, "g_unix_socket_address_get_path_len") | |
| 238 | 257 | ||
| 258 | + | core.PuregoSafeRegister(&xUnixSocketAddressAbstractNamesSupported, lib, "g_unix_socket_address_abstract_names_supported") | |
| 259 | + | ||
| 239 | 260 | } | |
M v4/gio/gvfs.go +49 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -20,6 +22,16 @@ type VfsClass struct { | |||
| 20 | 22 | ParentClass uintptr | |
| 21 | 23 | } | |
| 22 | 24 | ||
| 25 | + | func (x *VfsClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | const ( | |
| 30 | + | // Extension point for #GVfs functionality. | |
| 31 | + | // See [Extending GIO][extending-gio]. | |
| 32 | + | VFS_EXTENSION_POINT_NAME string = "gio-vfs" | |
| 33 | + | ) | |
| 34 | + | ||
| 23 | 35 | // Entry point for using GIO functionality. | |
| 24 | 36 | type Vfs struct { | |
| 25 | 37 | gobject.Object | |
| @@ -149,6 +161,40 @@ func (c *Vfs) SetGoPointer(ptr uintptr) { | |||
| 149 | 161 | c.Ptr = ptr | |
| 150 | 162 | } | |
| 151 | 163 | ||
| 164 | + | var xVfsGetDefault func() uintptr | |
| 165 | + | ||
| 166 | + | // Gets the default #GVfs for the system. | |
| 167 | + | func VfsGetDefault() *Vfs { | |
| 168 | + | var cls *Vfs | |
| 169 | + | ||
| 170 | + | cret := xVfsGetDefault() | |
| 171 | + | ||
| 172 | + | if cret == 0 { | |
| 173 | + | return nil | |
| 174 | + | } | |
| 175 | + | gobject.IncreaseRef(cret) | |
| 176 | + | cls = &Vfs{} | |
| 177 | + | cls.Ptr = cret | |
| 178 | + | return cls | |
| 179 | + | } | |
| 180 | + | ||
| 181 | + | var xVfsGetLocal func() uintptr | |
| 182 | + | ||
| 183 | + | // Gets the local #GVfs for the system. | |
| 184 | + | func VfsGetLocal() *Vfs { | |
| 185 | + | var cls *Vfs | |
| 186 | + | ||
| 187 | + | cret := xVfsGetLocal() | |
| 188 | + | ||
| 189 | + | if cret == 0 { | |
| 190 | + | return nil | |
| 191 | + | } | |
| 192 | + | gobject.IncreaseRef(cret) | |
| 193 | + | cls = &Vfs{} | |
| 194 | + | cls.Ptr = cret | |
| 195 | + | return cls | |
| 196 | + | } | |
| 197 | + | ||
| 152 | 198 | func init() { | |
| 153 | 199 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 154 | 200 | if err != nil { | |
| @@ -163,4 +209,7 @@ func init() { | |||
| 163 | 209 | core.PuregoSafeRegister(&xVfsRegisterUriScheme, lib, "g_vfs_register_uri_scheme") | |
| 164 | 210 | core.PuregoSafeRegister(&xVfsUnregisterUriScheme, lib, "g_vfs_unregister_uri_scheme") | |
| 165 | 211 | ||
| 212 | + | core.PuregoSafeRegister(&xVfsGetDefault, lib, "g_vfs_get_default") | |
| 213 | + | core.PuregoSafeRegister(&xVfsGetLocal, lib, "g_vfs_get_local") | |
| 214 | + | ||
| 166 | 215 | } | |
M v4/gio/gvolume.go +29 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type VolumeIface struct { | |||
| 12 | 14 | GIface uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *VolumeIface) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // The #GVolume interface represents user-visible objects that can be | |
| 16 | 22 | // mounted. Note, when porting from GnomeVFS, #GVolume is the moral | |
| 17 | 23 | // equivalent of #GnomeVFSDrive. | |
| @@ -339,6 +345,29 @@ var XGVolumeMount func(uintptr, MountMountFlags, uintptr, uintptr, uintptr, uint | |||
| 339 | 345 | var XGVolumeMountFinish func(uintptr, uintptr, **glib.Error) bool | |
| 340 | 346 | var XGVolumeShouldAutomount func(uintptr) bool | |
| 341 | 347 | ||
| 348 | + | const ( | |
| 349 | + | // The string used to obtain the volume class with g_volume_get_identifier(). | |
| 350 | + | // | |
| 351 | + | // Known volume classes include `device`, `network`, and `loop`. Other | |
| 352 | + | // classes may be added in the future. | |
| 353 | + | // | |
| 354 | + | // This is intended to be used by applications to classify #GVolume | |
| 355 | + | // instances into different sections - for example a file manager or | |
| 356 | + | // file chooser can use this information to show `network` volumes under | |
| 357 | + | // a "Network" heading and `device` volumes under a "Devices" heading. | |
| 358 | + | VOLUME_IDENTIFIER_KIND_CLASS string = "class" | |
| 359 | + | // The string used to obtain a Hal UDI with g_volume_get_identifier(). | |
| 360 | + | VOLUME_IDENTIFIER_KIND_HAL_UDI string = "hal-udi" | |
| 361 | + | // The string used to obtain a filesystem label with g_volume_get_identifier(). | |
| 362 | + | VOLUME_IDENTIFIER_KIND_LABEL string = "label" | |
| 363 | + | // The string used to obtain a NFS mount with g_volume_get_identifier(). | |
| 364 | + | VOLUME_IDENTIFIER_KIND_NFS_MOUNT string = "nfs-mount" | |
| 365 | + | // The string used to obtain a Unix device path with g_volume_get_identifier(). | |
| 366 | + | VOLUME_IDENTIFIER_KIND_UNIX_DEVICE string = "unix-device" | |
| 367 | + | // The string used to obtain a UUID with g_volume_get_identifier(). | |
| 368 | + | VOLUME_IDENTIFIER_KIND_UUID string = "uuid" | |
| 369 | + | ) | |
| 370 | + | ||
| 342 | 371 | func init() { | |
| 343 | 372 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 344 | 373 | if err != nil { | |
M v4/gio/gvolumemonitor.go +74 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,16 @@ type VolumeMonitorClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *VolumeMonitorClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | const ( | |
| 22 | + | // Extension point for volume monitor functionality. | |
| 23 | + | // See [Extending GIO][extending-gio]. | |
| 24 | + | VOLUME_MONITOR_EXTENSION_POINT_NAME string = "gio-volume-monitor" | |
| 25 | + | ) | |
| 26 | + | ||
| 15 | 27 | // #GVolumeMonitor is for listing the user interesting devices and volumes | |
| 16 | 28 | // on the computer. In other words, what a file selector or file manager | |
| 17 | 29 | // would show in a sidebar. | |
| @@ -256,6 +268,65 @@ func (x *VolumeMonitor) ConnectVolumeRemoved(cb func(VolumeMonitor, uintptr)) ui | |||
| 256 | 268 | return gobject.SignalConnect(x.GoPointer(), "volume-removed", purego.NewCallback(fcb)) | |
| 257 | 269 | } | |
| 258 | 270 | ||
| 271 | + | var xVolumeMonitorAdoptOrphanMount func(uintptr) uintptr | |
| 272 | + | ||
| 273 | + | // This function should be called by any #GVolumeMonitor | |
| 274 | + | // implementation when a new #GMount object is created that is not | |
| 275 | + | // associated with a #GVolume object. It must be called just before | |
| 276 | + | // emitting the @mount_added signal. | |
| 277 | + | // | |
| 278 | + | // If the return value is not %NULL, the caller must associate the | |
| 279 | + | // returned #GVolume object with the #GMount. This involves returning | |
| 280 | + | // it in its g_mount_get_volume() implementation. The caller must | |
| 281 | + | // also listen for the "removed" signal on the returned object | |
| 282 | + | // and give up its reference when handling that signal | |
| 283 | + | // | |
| 284 | + | // Similarly, if implementing g_volume_monitor_adopt_orphan_mount(), | |
| 285 | + | // the implementor must take a reference to @mount and return it in | |
| 286 | + | // its g_volume_get_mount() implemented. Also, the implementor must | |
| 287 | + | // listen for the "unmounted" signal on @mount and give up its | |
| 288 | + | // reference upon handling that signal. | |
| 289 | + | // | |
| 290 | + | // There are two main use cases for this function. | |
| 291 | + | // | |
| 292 | + | // One is when implementing a user space file system driver that reads | |
| 293 | + | // blocks of a block device that is already represented by the native | |
| 294 | + | // volume monitor (for example a CD Audio file system driver). Such | |
| 295 | + | // a driver will generate its own #GMount object that needs to be | |
| 296 | + | // associated with the #GVolume object that represents the volume. | |
| 297 | + | // | |
| 298 | + | // The other is for implementing a #GVolumeMonitor whose sole purpose | |
| 299 | + | // is to return #GVolume objects representing entries in the users | |
| 300 | + | // "favorite servers" list or similar. | |
| 301 | + | func VolumeMonitorAdoptOrphanMount(MountVar Mount) *VolumeBase { | |
| 302 | + | var cls *VolumeBase | |
| 303 | + | ||
| 304 | + | cret := xVolumeMonitorAdoptOrphanMount(MountVar.GoPointer()) | |
| 305 | + | ||
| 306 | + | if cret == 0 { | |
| 307 | + | return nil | |
| 308 | + | } | |
| 309 | + | cls = &VolumeBase{} | |
| 310 | + | cls.Ptr = cret | |
| 311 | + | return cls | |
| 312 | + | } | |
| 313 | + | ||
| 314 | + | var xVolumeMonitorGet func() uintptr | |
| 315 | + | ||
| 316 | + | // Gets the volume monitor used by gio. | |
| 317 | + | func VolumeMonitorGet() *VolumeMonitor { | |
| 318 | + | var cls *VolumeMonitor | |
| 319 | + | ||
| 320 | + | cret := xVolumeMonitorGet() | |
| 321 | + | ||
| 322 | + | if cret == 0 { | |
| 323 | + | return nil | |
| 324 | + | } | |
| 325 | + | cls = &VolumeMonitor{} | |
| 326 | + | cls.Ptr = cret | |
| 327 | + | return cls | |
| 328 | + | } | |
| 329 | + | ||
| 259 | 330 | func init() { | |
| 260 | 331 | lib, err := purego.Dlopen(core.GetPath("GIO"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 261 | 332 | if err != nil { | |
| @@ -268,4 +339,7 @@ func init() { | |||
| 268 | 339 | core.PuregoSafeRegister(&xVolumeMonitorGetVolumeForUuid, lib, "g_volume_monitor_get_volume_for_uuid") | |
| 269 | 340 | core.PuregoSafeRegister(&xVolumeMonitorGetVolumes, lib, "g_volume_monitor_get_volumes") | |
| 270 | 341 | ||
| 342 | + | core.PuregoSafeRegister(&xVolumeMonitorAdoptOrphanMount, lib, "g_volume_monitor_adopt_orphan_mount") | |
| 343 | + | core.PuregoSafeRegister(&xVolumeMonitorGet, lib, "g_volume_monitor_get") | |
| 344 | + | ||
| 271 | 345 | } | |
M v4/gio/gzlibcompressor.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ZlibCompressorClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ZlibCompressorClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GZlibCompressor is an implementation of #GConverter that | |
| 16 | 22 | // compresses data using zlib. | |
| 17 | 23 | type ZlibCompressor struct { | |
M v4/gio/gzlibdecompressor.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -12,6 +14,10 @@ type ZlibDecompressorClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *ZlibDecompressorClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GZlibDecompressor is an implementation of #GConverter that | |
| 16 | 22 | // decompresses data compressed with zlib. | |
| 17 | 23 | type ZlibDecompressor struct { | |
M v4/glib/garray.go +263 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -13,6 +15,10 @@ type Array struct { | |||
| 13 | 15 | Len uint | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *Array) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | // Contains the public fields of a GByteArray. | |
| 17 | 23 | type ByteArray struct { | |
| 18 | 24 | Data byte | |
| @@ -20,6 +26,10 @@ type ByteArray struct { | |||
| 20 | 26 | Len uint | |
| 21 | 27 | } | |
| 22 | 28 | ||
| 29 | + | func (x *ByteArray) GoPointer() uintptr { | |
| 30 | + | return uintptr(unsafe.Pointer(x)) | |
| 31 | + | } | |
| 32 | + | ||
| 23 | 33 | // A simple refcounted data type representing an immutable sequence of zero or | |
| 24 | 34 | // more bytes from an unspecified origin. | |
| 25 | 35 | // | |
| @@ -47,6 +57,238 @@ type ByteArray struct { | |||
| 47 | 57 | type Bytes struct { | |
| 48 | 58 | } | |
| 49 | 59 | ||
| 60 | + | func (x *Bytes) GoPointer() uintptr { | |
| 61 | + | return uintptr(unsafe.Pointer(x)) | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xNewBytes func(uintptr, uint) *Bytes | |
| 65 | + | ||
| 66 | + | // Creates a new #GBytes from @data. | |
| 67 | + | // | |
| 68 | + | // @data is copied. If @size is 0, @data may be %NULL. | |
| 69 | + | func NewBytes(DataVar uintptr, SizeVar uint) *Bytes { | |
| 70 | + | ||
| 71 | + | cret := xNewBytes(DataVar, SizeVar) | |
| 72 | + | return cret | |
| 73 | + | } | |
| 74 | + | ||
| 75 | + | var xNewStaticBytes func(uintptr, uint) *Bytes | |
| 76 | + | ||
| 77 | + | // Creates a new #GBytes from static data. | |
| 78 | + | // | |
| 79 | + | // @data must be static (ie: never modified or freed). It may be %NULL if @size | |
| 80 | + | // is 0. | |
| 81 | + | func NewStaticBytes(DataVar uintptr, SizeVar uint) *Bytes { | |
| 82 | + | ||
| 83 | + | cret := xNewStaticBytes(DataVar, SizeVar) | |
| 84 | + | return cret | |
| 85 | + | } | |
| 86 | + | ||
| 87 | + | var xNewTakeBytes func(uintptr, uint) *Bytes | |
| 88 | + | ||
| 89 | + | // Creates a new #GBytes from @data. | |
| 90 | + | // | |
| 91 | + | // After this call, @data belongs to the bytes and may no longer be | |
| 92 | + | // modified by the caller. g_free() will be called on @data when the | |
| 93 | + | // bytes is no longer in use. Because of this @data must have been created by | |
| 94 | + | // a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many | |
| 95 | + | // functions that wrap these calls (such as g_new(), g_strdup(), etc). | |
| 96 | + | // | |
| 97 | + | // For creating #GBytes with memory from other allocators, see | |
| 98 | + | // g_bytes_new_with_free_func(). | |
| 99 | + | // | |
| 100 | + | // @data may be %NULL if @size is 0. | |
| 101 | + | func NewTakeBytes(DataVar uintptr, SizeVar uint) *Bytes { | |
| 102 | + | ||
| 103 | + | cret := xNewTakeBytes(DataVar, SizeVar) | |
| 104 | + | return cret | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | var xNewWithFreeFuncBytes func(uintptr, uint, uintptr, uintptr) *Bytes | |
| 108 | + | ||
| 109 | + | // Creates a #GBytes from @data. | |
| 110 | + | // | |
| 111 | + | // When the last reference is dropped, @free_func will be called with the | |
| 112 | + | // @user_data argument. | |
| 113 | + | // | |
| 114 | + | // @data must not be modified after this call is made until @free_func has | |
| 115 | + | // been called to indicate that the bytes is no longer in use. | |
| 116 | + | // | |
| 117 | + | // @data may be %NULL if @size is 0. | |
| 118 | + | func NewWithFreeFuncBytes(DataVar uintptr, SizeVar uint, FreeFuncVar DestroyNotify, UserDataVar uintptr) *Bytes { | |
| 119 | + | ||
| 120 | + | cret := xNewWithFreeFuncBytes(DataVar, SizeVar, purego.NewCallback(FreeFuncVar), UserDataVar) | |
| 121 | + | return cret | |
| 122 | + | } | |
| 123 | + | ||
| 124 | + | var xBytesCompare func(uintptr, uintptr) int | |
| 125 | + | ||
| 126 | + | // Compares the two #GBytes values. | |
| 127 | + | // | |
| 128 | + | // This function can be used to sort GBytes instances in lexicographical order. | |
| 129 | + | // | |
| 130 | + | // If @bytes1 and @bytes2 have different length but the shorter one is a | |
| 131 | + | // prefix of the longer one then the shorter one is considered to be less than | |
| 132 | + | // the longer one. Otherwise the first byte where both differ is used for | |
| 133 | + | // comparison. If @bytes1 has a smaller value at that position it is | |
| 134 | + | // considered less, otherwise greater than @bytes2. | |
| 135 | + | func (x *Bytes) Compare(Bytes2Var uintptr) int { | |
| 136 | + | ||
| 137 | + | cret := xBytesCompare(x.GoPointer(), Bytes2Var) | |
| 138 | + | return cret | |
| 139 | + | } | |
| 140 | + | ||
| 141 | + | var xBytesEqual func(uintptr, uintptr) bool | |
| 142 | + | ||
| 143 | + | // Compares the two #GBytes values being pointed to and returns | |
| 144 | + | // %TRUE if they are equal. | |
| 145 | + | // | |
| 146 | + | // This function can be passed to g_hash_table_new() as the @key_equal_func | |
| 147 | + | // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable. | |
| 148 | + | func (x *Bytes) Equal(Bytes2Var uintptr) bool { | |
| 149 | + | ||
| 150 | + | cret := xBytesEqual(x.GoPointer(), Bytes2Var) | |
| 151 | + | return cret | |
| 152 | + | } | |
| 153 | + | ||
| 154 | + | var xBytesGetData func(uintptr, uint) uintptr | |
| 155 | + | ||
| 156 | + | // Get the byte data in the #GBytes. This data should not be modified. | |
| 157 | + | // | |
| 158 | + | // This function will always return the same pointer for a given #GBytes. | |
| 159 | + | // | |
| 160 | + | // %NULL may be returned if @size is 0. This is not guaranteed, as the #GBytes | |
| 161 | + | // may represent an empty string with @data non-%NULL and @size as 0. %NULL will | |
| 162 | + | // not be returned if @size is non-zero. | |
| 163 | + | func (x *Bytes) GetData(SizeVar uint) uintptr { | |
| 164 | + | ||
| 165 | + | cret := xBytesGetData(x.GoPointer(), SizeVar) | |
| 166 | + | return cret | |
| 167 | + | } | |
| 168 | + | ||
| 169 | + | var xBytesGetRegion func(uintptr, uint, uint, uint) uintptr | |
| 170 | + | ||
| 171 | + | // Gets a pointer to a region in @bytes. | |
| 172 | + | // | |
| 173 | + | // The region starts at @offset many bytes from the start of the data | |
| 174 | + | // and contains @n_elements many elements of @element_size size. | |
| 175 | + | // | |
| 176 | + | // @n_elements may be zero, but @element_size must always be non-zero. | |
| 177 | + | // Ideally, @element_size is a static constant (eg: sizeof a struct). | |
| 178 | + | // | |
| 179 | + | // This function does careful bounds checking (including checking for | |
| 180 | + | // arithmetic overflows) and returns a non-%NULL pointer if the | |
| 181 | + | // specified region lies entirely within the @bytes. If the region is | |
| 182 | + | // in some way out of range, or if an overflow has occurred, then %NULL | |
| 183 | + | // is returned. | |
| 184 | + | // | |
| 185 | + | // Note: it is possible to have a valid zero-size region. In this case, | |
| 186 | + | // the returned pointer will be equal to the base pointer of the data of | |
| 187 | + | // @bytes, plus @offset. This will be non-%NULL except for the case | |
| 188 | + | // where @bytes itself was a zero-sized region. Since it is unlikely | |
| 189 | + | // that you will be using this function to check for a zero-sized region | |
| 190 | + | // in a zero-sized @bytes, %NULL effectively always means "error". | |
| 191 | + | func (x *Bytes) GetRegion(ElementSizeVar uint, OffsetVar uint, NElementsVar uint) uintptr { | |
| 192 | + | ||
| 193 | + | cret := xBytesGetRegion(x.GoPointer(), ElementSizeVar, OffsetVar, NElementsVar) | |
| 194 | + | return cret | |
| 195 | + | } | |
| 196 | + | ||
| 197 | + | var xBytesGetSize func(uintptr) uint | |
| 198 | + | ||
| 199 | + | // Get the size of the byte data in the #GBytes. | |
| 200 | + | // | |
| 201 | + | // This function will always return the same value for a given #GBytes. | |
| 202 | + | func (x *Bytes) GetSize() uint { | |
| 203 | + | ||
| 204 | + | cret := xBytesGetSize(x.GoPointer()) | |
| 205 | + | return cret | |
| 206 | + | } | |
| 207 | + | ||
| 208 | + | var xBytesHash func(uintptr) uint | |
| 209 | + | ||
| 210 | + | // Creates an integer hash code for the byte data in the #GBytes. | |
| 211 | + | // | |
| 212 | + | // This function can be passed to g_hash_table_new() as the @key_hash_func | |
| 213 | + | // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable. | |
| 214 | + | func (x *Bytes) Hash() uint { | |
| 215 | + | ||
| 216 | + | cret := xBytesHash(x.GoPointer()) | |
| 217 | + | return cret | |
| 218 | + | } | |
| 219 | + | ||
| 220 | + | var xBytesNewFromBytes func(uintptr, uint, uint) *Bytes | |
| 221 | + | ||
| 222 | + | // Creates a #GBytes which is a subsection of another #GBytes. The @offset + | |
| 223 | + | // @length may not be longer than the size of @bytes. | |
| 224 | + | // | |
| 225 | + | // A reference to @bytes will be held by the newly created #GBytes until | |
| 226 | + | // the byte data is no longer needed. | |
| 227 | + | // | |
| 228 | + | // Since 2.56, if @offset is 0 and @length matches the size of @bytes, then | |
| 229 | + | // @bytes will be returned with the reference count incremented by 1. If @bytes | |
| 230 | + | // is a slice of another #GBytes, then the resulting #GBytes will reference | |
| 231 | + | // the same #GBytes instead of @bytes. This allows consumers to simplify the | |
| 232 | + | // usage of #GBytes when asynchronously writing to streams. | |
| 233 | + | func (x *Bytes) NewFromBytes(OffsetVar uint, LengthVar uint) *Bytes { | |
| 234 | + | ||
| 235 | + | cret := xBytesNewFromBytes(x.GoPointer(), OffsetVar, LengthVar) | |
| 236 | + | return cret | |
| 237 | + | } | |
| 238 | + | ||
| 239 | + | var xBytesRef func(uintptr) *Bytes | |
| 240 | + | ||
| 241 | + | // Increase the reference count on @bytes. | |
| 242 | + | func (x *Bytes) Ref() *Bytes { | |
| 243 | + | ||
| 244 | + | cret := xBytesRef(x.GoPointer()) | |
| 245 | + | return cret | |
| 246 | + | } | |
| 247 | + | ||
| 248 | + | var xBytesUnref func(uintptr) | |
| 249 | + | ||
| 250 | + | // Releases a reference on @bytes. This may result in the bytes being | |
| 251 | + | // freed. If @bytes is %NULL, it will return immediately. | |
| 252 | + | func (x *Bytes) Unref() { | |
| 253 | + | ||
| 254 | + | xBytesUnref(x.GoPointer()) | |
| 255 | + | ||
| 256 | + | } | |
| 257 | + | ||
| 258 | + | var xBytesUnrefToArray func(uintptr) uintptr | |
| 259 | + | ||
| 260 | + | // Unreferences the bytes, and returns a new mutable #GByteArray containing | |
| 261 | + | // the same byte data. | |
| 262 | + | // | |
| 263 | + | // As an optimization, the byte data is transferred to the array without copying | |
| 264 | + | // if this was the last reference to bytes and bytes was created with | |
| 265 | + | // g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all | |
| 266 | + | // other cases the data is copied. | |
| 267 | + | // | |
| 268 | + | // Do not use it if @bytes contains more than %G_MAXUINT | |
| 269 | + | // bytes. #GByteArray stores the length of its data in #guint, which | |
| 270 | + | // may be shorter than #gsize, that @bytes is using. | |
| 271 | + | func (x *Bytes) UnrefToArray() uintptr { | |
| 272 | + | ||
| 273 | + | cret := xBytesUnrefToArray(x.GoPointer()) | |
| 274 | + | return cret | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | var xBytesUnrefToData func(uintptr, uint) uintptr | |
| 278 | + | ||
| 279 | + | // Unreferences the bytes, and returns a pointer the same byte data | |
| 280 | + | // contents. | |
| 281 | + | // | |
| 282 | + | // As an optimization, the byte data is returned without copying if this was | |
| 283 | + | // the last reference to bytes and bytes was created with g_bytes_new(), | |
| 284 | + | // g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the | |
| 285 | + | // data is copied. | |
| 286 | + | func (x *Bytes) UnrefToData(SizeVar uint) uintptr { | |
| 287 | + | ||
| 288 | + | cret := xBytesUnrefToData(x.GoPointer(), SizeVar) | |
| 289 | + | return cret | |
| 290 | + | } | |
| 291 | + | ||
| 50 | 292 | // Contains the public fields of a pointer array. | |
| 51 | 293 | type PtrArray struct { | |
| 52 | 294 | Pdata uintptr | |
| @@ -54,6 +296,10 @@ type PtrArray struct { | |||
| 54 | 296 | Len uint | |
| 55 | 297 | } | |
| 56 | 298 | ||
| 299 | + | func (x *PtrArray) GoPointer() uintptr { | |
| 300 | + | return uintptr(unsafe.Pointer(x)) | |
| 301 | + | } | |
| 302 | + | ||
| 57 | 303 | var xByteArrayFree func(uintptr, bool) byte | |
| 58 | 304 | ||
| 59 | 305 | // Frees the memory allocated by the #GByteArray. If @free_segment is | |
| @@ -174,4 +420,21 @@ func init() { | |||
| 174 | 420 | core.PuregoSafeRegister(&xPtrArrayFind, lib, "g_ptr_array_find") | |
| 175 | 421 | core.PuregoSafeRegister(&xPtrArrayFindWithEqualFunc, lib, "g_ptr_array_find_with_equal_func") | |
| 176 | 422 | ||
| 423 | + | core.PuregoSafeRegister(&xNewBytes, lib, "g_bytes_new") | |
| 424 | + | core.PuregoSafeRegister(&xNewStaticBytes, lib, "g_bytes_new_static") | |
| 425 | + | core.PuregoSafeRegister(&xNewTakeBytes, lib, "g_bytes_new_take") | |
| 426 | + | core.PuregoSafeRegister(&xNewWithFreeFuncBytes, lib, "g_bytes_new_with_free_func") | |
| 427 | + | ||
| 428 | + | core.PuregoSafeRegister(&xBytesCompare, lib, "g_bytes_compare") | |
| 429 | + | core.PuregoSafeRegister(&xBytesEqual, lib, "g_bytes_equal") | |
| 430 | + | core.PuregoSafeRegister(&xBytesGetData, lib, "g_bytes_get_data") | |
| 431 | + | core.PuregoSafeRegister(&xBytesGetRegion, lib, "g_bytes_get_region") | |
| 432 | + | core.PuregoSafeRegister(&xBytesGetSize, lib, "g_bytes_get_size") | |
| 433 | + | core.PuregoSafeRegister(&xBytesHash, lib, "g_bytes_hash") | |
| 434 | + | core.PuregoSafeRegister(&xBytesNewFromBytes, lib, "g_bytes_new_from_bytes") | |
| 435 | + | core.PuregoSafeRegister(&xBytesRef, lib, "g_bytes_ref") | |
| 436 | + | core.PuregoSafeRegister(&xBytesUnref, lib, "g_bytes_unref") | |
| 437 | + | core.PuregoSafeRegister(&xBytesUnrefToArray, lib, "g_bytes_unref_to_array") | |
| 438 | + | core.PuregoSafeRegister(&xBytesUnrefToData, lib, "g_bytes_unref_to_data") | |
| 439 | + | ||
| 177 | 440 | } | |
M v4/glib/gasyncqueue.go +413 -0
| @@ -1,8 +1,421 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // An opaque data structure which represents an asynchronous queue. | |
| 5 | 12 | // | |
| 6 | 13 | // It should only be accessed through the `g_async_queue_*` functions. | |
| 7 | 14 | type AsyncQueue struct { | |
| 8 | 15 | } | |
| 16 | + | ||
| 17 | + | func (x *AsyncQueue) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | var xAsyncQueueLength func(uintptr) int | |
| 22 | + | ||
| 23 | + | // Returns the length of the queue. | |
| 24 | + | // | |
| 25 | + | // Actually this function returns the number of data items in | |
| 26 | + | // the queue minus the number of waiting threads, so a negative | |
| 27 | + | // value means waiting threads, and a positive value means available | |
| 28 | + | // entries in the @queue. A return value of 0 could mean n entries | |
| 29 | + | // in the queue and n threads waiting. This can happen due to locking | |
| 30 | + | // of the queue or due to scheduling. | |
| 31 | + | func (x *AsyncQueue) Length() int { | |
| 32 | + | ||
| 33 | + | cret := xAsyncQueueLength(x.GoPointer()) | |
| 34 | + | return cret | |
| 35 | + | } | |
| 36 | + | ||
| 37 | + | var xAsyncQueueLengthUnlocked func(uintptr) int | |
| 38 | + | ||
| 39 | + | // Returns the length of the queue. | |
| 40 | + | // | |
| 41 | + | // Actually this function returns the number of data items in | |
| 42 | + | // the queue minus the number of waiting threads, so a negative | |
| 43 | + | // value means waiting threads, and a positive value means available | |
| 44 | + | // entries in the @queue. A return value of 0 could mean n entries | |
| 45 | + | // in the queue and n threads waiting. This can happen due to locking | |
| 46 | + | // of the queue or due to scheduling. | |
| 47 | + | // | |
| 48 | + | // This function must be called while holding the @queue's lock. | |
| 49 | + | func (x *AsyncQueue) LengthUnlocked() int { | |
| 50 | + | ||
| 51 | + | cret := xAsyncQueueLengthUnlocked(x.GoPointer()) | |
| 52 | + | return cret | |
| 53 | + | } | |
| 54 | + | ||
| 55 | + | var xAsyncQueueLock func(uintptr) | |
| 56 | + | ||
| 57 | + | // Acquires the @queue's lock. If another thread is already | |
| 58 | + | // holding the lock, this call will block until the lock | |
| 59 | + | // becomes available. | |
| 60 | + | // | |
| 61 | + | // Call g_async_queue_unlock() to drop the lock again. | |
| 62 | + | // | |
| 63 | + | // While holding the lock, you can only call the | |
| 64 | + | // g_async_queue_*_unlocked() functions on @queue. Otherwise, | |
| 65 | + | // deadlock may occur. | |
| 66 | + | func (x *AsyncQueue) Lock() { | |
| 67 | + | ||
| 68 | + | xAsyncQueueLock(x.GoPointer()) | |
| 69 | + | ||
| 70 | + | } | |
| 71 | + | ||
| 72 | + | var xAsyncQueuePop func(uintptr) uintptr | |
| 73 | + | ||
| 74 | + | // Pops data from the @queue. If @queue is empty, this function | |
| 75 | + | // blocks until data becomes available. | |
| 76 | + | func (x *AsyncQueue) Pop() uintptr { | |
| 77 | + | ||
| 78 | + | cret := xAsyncQueuePop(x.GoPointer()) | |
| 79 | + | return cret | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | var xAsyncQueuePopUnlocked func(uintptr) uintptr | |
| 83 | + | ||
| 84 | + | // Pops data from the @queue. If @queue is empty, this function | |
| 85 | + | // blocks until data becomes available. | |
| 86 | + | // | |
| 87 | + | // This function must be called while holding the @queue's lock. | |
| 88 | + | func (x *AsyncQueue) PopUnlocked() uintptr { | |
| 89 | + | ||
| 90 | + | cret := xAsyncQueuePopUnlocked(x.GoPointer()) | |
| 91 | + | return cret | |
| 92 | + | } | |
| 93 | + | ||
| 94 | + | var xAsyncQueuePush func(uintptr, uintptr) | |
| 95 | + | ||
| 96 | + | // Pushes the @data into the @queue. @data must not be %NULL. | |
| 97 | + | func (x *AsyncQueue) Push(DataVar uintptr) { | |
| 98 | + | ||
| 99 | + | xAsyncQueuePush(x.GoPointer(), DataVar) | |
| 100 | + | ||
| 101 | + | } | |
| 102 | + | ||
| 103 | + | var xAsyncQueuePushFront func(uintptr, uintptr) | |
| 104 | + | ||
| 105 | + | // Pushes the @item into the @queue. @item must not be %NULL. | |
| 106 | + | // In contrast to g_async_queue_push(), this function | |
| 107 | + | // pushes the new item ahead of the items already in the queue, | |
| 108 | + | // so that it will be the next one to be popped off the queue. | |
| 109 | + | func (x *AsyncQueue) PushFront(ItemVar uintptr) { | |
| 110 | + | ||
| 111 | + | xAsyncQueuePushFront(x.GoPointer(), ItemVar) | |
| 112 | + | ||
| 113 | + | } | |
| 114 | + | ||
| 115 | + | var xAsyncQueuePushFrontUnlocked func(uintptr, uintptr) | |
| 116 | + | ||
| 117 | + | // Pushes the @item into the @queue. @item must not be %NULL. | |
| 118 | + | // In contrast to g_async_queue_push_unlocked(), this function | |
| 119 | + | // pushes the new item ahead of the items already in the queue, | |
| 120 | + | // so that it will be the next one to be popped off the queue. | |
| 121 | + | // | |
| 122 | + | // This function must be called while holding the @queue's lock. | |
| 123 | + | func (x *AsyncQueue) PushFrontUnlocked(ItemVar uintptr) { | |
| 124 | + | ||
| 125 | + | xAsyncQueuePushFrontUnlocked(x.GoPointer(), ItemVar) | |
| 126 | + | ||
| 127 | + | } | |
| 128 | + | ||
| 129 | + | var xAsyncQueuePushSorted func(uintptr, uintptr, uintptr, uintptr) | |
| 130 | + | ||
| 131 | + | // Inserts @data into @queue using @func to determine the new | |
| 132 | + | // position. | |
| 133 | + | // | |
| 134 | + | // This function requires that the @queue is sorted before pushing on | |
| 135 | + | // new elements, see g_async_queue_sort(). | |
| 136 | + | // | |
| 137 | + | // This function will lock @queue before it sorts the queue and unlock | |
| 138 | + | // it when it is finished. | |
| 139 | + | // | |
| 140 | + | // For an example of @func see g_async_queue_sort(). | |
| 141 | + | func (x *AsyncQueue) PushSorted(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 142 | + | ||
| 143 | + | xAsyncQueuePushSorted(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 144 | + | ||
| 145 | + | } | |
| 146 | + | ||
| 147 | + | var xAsyncQueuePushSortedUnlocked func(uintptr, uintptr, uintptr, uintptr) | |
| 148 | + | ||
| 149 | + | // Inserts @data into @queue using @func to determine the new | |
| 150 | + | // position. | |
| 151 | + | // | |
| 152 | + | // The sort function @func is passed two elements of the @queue. | |
| 153 | + | // It should return 0 if they are equal, a negative value if the | |
| 154 | + | // first element should be higher in the @queue or a positive value | |
| 155 | + | // if the first element should be lower in the @queue than the second | |
| 156 | + | // element. | |
| 157 | + | // | |
| 158 | + | // This function requires that the @queue is sorted before pushing on | |
| 159 | + | // new elements, see g_async_queue_sort(). | |
| 160 | + | // | |
| 161 | + | // This function must be called while holding the @queue's lock. | |
| 162 | + | // | |
| 163 | + | // For an example of @func see g_async_queue_sort(). | |
| 164 | + | func (x *AsyncQueue) PushSortedUnlocked(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 165 | + | ||
| 166 | + | xAsyncQueuePushSortedUnlocked(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 167 | + | ||
| 168 | + | } | |
| 169 | + | ||
| 170 | + | var xAsyncQueuePushUnlocked func(uintptr, uintptr) | |
| 171 | + | ||
| 172 | + | // Pushes the @data into the @queue. @data must not be %NULL. | |
| 173 | + | // | |
| 174 | + | // This function must be called while holding the @queue's lock. | |
| 175 | + | func (x *AsyncQueue) PushUnlocked(DataVar uintptr) { | |
| 176 | + | ||
| 177 | + | xAsyncQueuePushUnlocked(x.GoPointer(), DataVar) | |
| 178 | + | ||
| 179 | + | } | |
| 180 | + | ||
| 181 | + | var xAsyncQueueRef func(uintptr) *AsyncQueue | |
| 182 | + | ||
| 183 | + | // Increases the reference count of the asynchronous @queue by 1. | |
| 184 | + | // You do not need to hold the lock to call this function. | |
| 185 | + | func (x *AsyncQueue) Ref() *AsyncQueue { | |
| 186 | + | ||
| 187 | + | cret := xAsyncQueueRef(x.GoPointer()) | |
| 188 | + | return cret | |
| 189 | + | } | |
| 190 | + | ||
| 191 | + | var xAsyncQueueRefUnlocked func(uintptr) | |
| 192 | + | ||
| 193 | + | // Increases the reference count of the asynchronous @queue by 1. | |
| 194 | + | func (x *AsyncQueue) RefUnlocked() { | |
| 195 | + | ||
| 196 | + | xAsyncQueueRefUnlocked(x.GoPointer()) | |
| 197 | + | ||
| 198 | + | } | |
| 199 | + | ||
| 200 | + | var xAsyncQueueRemove func(uintptr, uintptr) bool | |
| 201 | + | ||
| 202 | + | // Remove an item from the queue. | |
| 203 | + | func (x *AsyncQueue) Remove(ItemVar uintptr) bool { | |
| 204 | + | ||
| 205 | + | cret := xAsyncQueueRemove(x.GoPointer(), ItemVar) | |
| 206 | + | return cret | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | var xAsyncQueueRemoveUnlocked func(uintptr, uintptr) bool | |
| 210 | + | ||
| 211 | + | // Remove an item from the queue. | |
| 212 | + | // | |
| 213 | + | // This function must be called while holding the @queue's lock. | |
| 214 | + | func (x *AsyncQueue) RemoveUnlocked(ItemVar uintptr) bool { | |
| 215 | + | ||
| 216 | + | cret := xAsyncQueueRemoveUnlocked(x.GoPointer(), ItemVar) | |
| 217 | + | return cret | |
| 218 | + | } | |
| 219 | + | ||
| 220 | + | var xAsyncQueueSort func(uintptr, uintptr, uintptr) | |
| 221 | + | ||
| 222 | + | // Sorts @queue using @func. | |
| 223 | + | // | |
| 224 | + | // The sort function @func is passed two elements of the @queue. | |
| 225 | + | // It should return 0 if they are equal, a negative value if the | |
| 226 | + | // first element should be higher in the @queue or a positive value | |
| 227 | + | // if the first element should be lower in the @queue than the second | |
| 228 | + | // element. | |
| 229 | + | // | |
| 230 | + | // This function will lock @queue before it sorts the queue and unlock | |
| 231 | + | // it when it is finished. | |
| 232 | + | // | |
| 233 | + | // If you were sorting a list of priority numbers to make sure the | |
| 234 | + | // lowest priority would be at the top of the queue, you could use: | |
| 235 | + | // |[<!-- language="C" --> | |
| 236 | + | // | |
| 237 | + | // gint32 id1; | |
| 238 | + | // gint32 id2; | |
| 239 | + | // | |
| 240 | + | // id1 = GPOINTER_TO_INT (element1); | |
| 241 | + | // id2 = GPOINTER_TO_INT (element2); | |
| 242 | + | // | |
| 243 | + | // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1); | |
| 244 | + | // | |
| 245 | + | // ]| | |
| 246 | + | func (x *AsyncQueue) Sort(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 247 | + | ||
| 248 | + | xAsyncQueueSort(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 249 | + | ||
| 250 | + | } | |
| 251 | + | ||
| 252 | + | var xAsyncQueueSortUnlocked func(uintptr, uintptr, uintptr) | |
| 253 | + | ||
| 254 | + | // Sorts @queue using @func. | |
| 255 | + | // | |
| 256 | + | // The sort function @func is passed two elements of the @queue. | |
| 257 | + | // It should return 0 if they are equal, a negative value if the | |
| 258 | + | // first element should be higher in the @queue or a positive value | |
| 259 | + | // if the first element should be lower in the @queue than the second | |
| 260 | + | // element. | |
| 261 | + | // | |
| 262 | + | // This function must be called while holding the @queue's lock. | |
| 263 | + | func (x *AsyncQueue) SortUnlocked(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 264 | + | ||
| 265 | + | xAsyncQueueSortUnlocked(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 266 | + | ||
| 267 | + | } | |
| 268 | + | ||
| 269 | + | var xAsyncQueueTimedPop func(uintptr, *TimeVal) uintptr | |
| 270 | + | ||
| 271 | + | // Pops data from the @queue. If the queue is empty, blocks until | |
| 272 | + | // @end_time or until data becomes available. | |
| 273 | + | // | |
| 274 | + | // If no data is received before @end_time, %NULL is returned. | |
| 275 | + | // | |
| 276 | + | // To easily calculate @end_time, a combination of g_get_real_time() | |
| 277 | + | // and g_time_val_add() can be used. | |
| 278 | + | func (x *AsyncQueue) TimedPop(EndTimeVar *TimeVal) uintptr { | |
| 279 | + | ||
| 280 | + | cret := xAsyncQueueTimedPop(x.GoPointer(), EndTimeVar) | |
| 281 | + | return cret | |
| 282 | + | } | |
| 283 | + | ||
| 284 | + | var xAsyncQueueTimedPopUnlocked func(uintptr, *TimeVal) uintptr | |
| 285 | + | ||
| 286 | + | // Pops data from the @queue. If the queue is empty, blocks until | |
| 287 | + | // @end_time or until data becomes available. | |
| 288 | + | // | |
| 289 | + | // If no data is received before @end_time, %NULL is returned. | |
| 290 | + | // | |
| 291 | + | // To easily calculate @end_time, a combination of g_get_real_time() | |
| 292 | + | // and g_time_val_add() can be used. | |
| 293 | + | // | |
| 294 | + | // This function must be called while holding the @queue's lock. | |
| 295 | + | func (x *AsyncQueue) TimedPopUnlocked(EndTimeVar *TimeVal) uintptr { | |
| 296 | + | ||
| 297 | + | cret := xAsyncQueueTimedPopUnlocked(x.GoPointer(), EndTimeVar) | |
| 298 | + | return cret | |
| 299 | + | } | |
| 300 | + | ||
| 301 | + | var xAsyncQueueTimeoutPop func(uintptr, uint64) uintptr | |
| 302 | + | ||
| 303 | + | // Pops data from the @queue. If the queue is empty, blocks for | |
| 304 | + | // @timeout microseconds, or until data becomes available. | |
| 305 | + | // | |
| 306 | + | // If no data is received before the timeout, %NULL is returned. | |
| 307 | + | func (x *AsyncQueue) TimeoutPop(TimeoutVar uint64) uintptr { | |
| 308 | + | ||
| 309 | + | cret := xAsyncQueueTimeoutPop(x.GoPointer(), TimeoutVar) | |
| 310 | + | return cret | |
| 311 | + | } | |
| 312 | + | ||
| 313 | + | var xAsyncQueueTimeoutPopUnlocked func(uintptr, uint64) uintptr | |
| 314 | + | ||
| 315 | + | // Pops data from the @queue. If the queue is empty, blocks for | |
| 316 | + | // @timeout microseconds, or until data becomes available. | |
| 317 | + | // | |
| 318 | + | // If no data is received before the timeout, %NULL is returned. | |
| 319 | + | // | |
| 320 | + | // This function must be called while holding the @queue's lock. | |
| 321 | + | func (x *AsyncQueue) TimeoutPopUnlocked(TimeoutVar uint64) uintptr { | |
| 322 | + | ||
| 323 | + | cret := xAsyncQueueTimeoutPopUnlocked(x.GoPointer(), TimeoutVar) | |
| 324 | + | return cret | |
| 325 | + | } | |
| 326 | + | ||
| 327 | + | var xAsyncQueueTryPop func(uintptr) uintptr | |
| 328 | + | ||
| 329 | + | // Tries to pop data from the @queue. If no data is available, | |
| 330 | + | // %NULL is returned. | |
| 331 | + | func (x *AsyncQueue) TryPop() uintptr { | |
| 332 | + | ||
| 333 | + | cret := xAsyncQueueTryPop(x.GoPointer()) | |
| 334 | + | return cret | |
| 335 | + | } | |
| 336 | + | ||
| 337 | + | var xAsyncQueueTryPopUnlocked func(uintptr) uintptr | |
| 338 | + | ||
| 339 | + | // Tries to pop data from the @queue. If no data is available, | |
| 340 | + | // %NULL is returned. | |
| 341 | + | // | |
| 342 | + | // This function must be called while holding the @queue's lock. | |
| 343 | + | func (x *AsyncQueue) TryPopUnlocked() uintptr { | |
| 344 | + | ||
| 345 | + | cret := xAsyncQueueTryPopUnlocked(x.GoPointer()) | |
| 346 | + | return cret | |
| 347 | + | } | |
| 348 | + | ||
| 349 | + | var xAsyncQueueUnlock func(uintptr) | |
| 350 | + | ||
| 351 | + | // Releases the queue's lock. | |
| 352 | + | // | |
| 353 | + | // Calling this function when you have not acquired | |
| 354 | + | // the with g_async_queue_lock() leads to undefined | |
| 355 | + | // behaviour. | |
| 356 | + | func (x *AsyncQueue) Unlock() { | |
| 357 | + | ||
| 358 | + | xAsyncQueueUnlock(x.GoPointer()) | |
| 359 | + | ||
| 360 | + | } | |
| 361 | + | ||
| 362 | + | var xAsyncQueueUnref func(uintptr) | |
| 363 | + | ||
| 364 | + | // Decreases the reference count of the asynchronous @queue by 1. | |
| 365 | + | // | |
| 366 | + | // If the reference count went to 0, the @queue will be destroyed | |
| 367 | + | // and the memory allocated will be freed. So you are not allowed | |
| 368 | + | // to use the @queue afterwards, as it might have disappeared. | |
| 369 | + | // You do not need to hold the lock to call this function. | |
| 370 | + | func (x *AsyncQueue) Unref() { | |
| 371 | + | ||
| 372 | + | xAsyncQueueUnref(x.GoPointer()) | |
| 373 | + | ||
| 374 | + | } | |
| 375 | + | ||
| 376 | + | var xAsyncQueueUnrefAndUnlock func(uintptr) | |
| 377 | + | ||
| 378 | + | // Decreases the reference count of the asynchronous @queue by 1 | |
| 379 | + | // and releases the lock. This function must be called while holding | |
| 380 | + | // the @queue's lock. If the reference count went to 0, the @queue | |
| 381 | + | // will be destroyed and the memory allocated will be freed. | |
| 382 | + | func (x *AsyncQueue) UnrefAndUnlock() { | |
| 383 | + | ||
| 384 | + | xAsyncQueueUnrefAndUnlock(x.GoPointer()) | |
| 385 | + | ||
| 386 | + | } | |
| 387 | + | ||
| 388 | + | func init() { | |
| 389 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 390 | + | if err != nil { | |
| 391 | + | panic(err) | |
| 392 | + | } | |
| 393 | + | ||
| 394 | + | core.PuregoSafeRegister(&xAsyncQueueLength, lib, "g_async_queue_length") | |
| 395 | + | core.PuregoSafeRegister(&xAsyncQueueLengthUnlocked, lib, "g_async_queue_length_unlocked") | |
| 396 | + | core.PuregoSafeRegister(&xAsyncQueueLock, lib, "g_async_queue_lock") | |
| 397 | + | core.PuregoSafeRegister(&xAsyncQueuePop, lib, "g_async_queue_pop") | |
| 398 | + | core.PuregoSafeRegister(&xAsyncQueuePopUnlocked, lib, "g_async_queue_pop_unlocked") | |
| 399 | + | core.PuregoSafeRegister(&xAsyncQueuePush, lib, "g_async_queue_push") | |
| 400 | + | core.PuregoSafeRegister(&xAsyncQueuePushFront, lib, "g_async_queue_push_front") | |
| 401 | + | core.PuregoSafeRegister(&xAsyncQueuePushFrontUnlocked, lib, "g_async_queue_push_front_unlocked") | |
| 402 | + | core.PuregoSafeRegister(&xAsyncQueuePushSorted, lib, "g_async_queue_push_sorted") | |
| 403 | + | core.PuregoSafeRegister(&xAsyncQueuePushSortedUnlocked, lib, "g_async_queue_push_sorted_unlocked") | |
| 404 | + | core.PuregoSafeRegister(&xAsyncQueuePushUnlocked, lib, "g_async_queue_push_unlocked") | |
| 405 | + | core.PuregoSafeRegister(&xAsyncQueueRef, lib, "g_async_queue_ref") | |
| 406 | + | core.PuregoSafeRegister(&xAsyncQueueRefUnlocked, lib, "g_async_queue_ref_unlocked") | |
| 407 | + | core.PuregoSafeRegister(&xAsyncQueueRemove, lib, "g_async_queue_remove") | |
| 408 | + | core.PuregoSafeRegister(&xAsyncQueueRemoveUnlocked, lib, "g_async_queue_remove_unlocked") | |
| 409 | + | core.PuregoSafeRegister(&xAsyncQueueSort, lib, "g_async_queue_sort") | |
| 410 | + | core.PuregoSafeRegister(&xAsyncQueueSortUnlocked, lib, "g_async_queue_sort_unlocked") | |
| 411 | + | core.PuregoSafeRegister(&xAsyncQueueTimedPop, lib, "g_async_queue_timed_pop") | |
| 412 | + | core.PuregoSafeRegister(&xAsyncQueueTimedPopUnlocked, lib, "g_async_queue_timed_pop_unlocked") | |
| 413 | + | core.PuregoSafeRegister(&xAsyncQueueTimeoutPop, lib, "g_async_queue_timeout_pop") | |
| 414 | + | core.PuregoSafeRegister(&xAsyncQueueTimeoutPopUnlocked, lib, "g_async_queue_timeout_pop_unlocked") | |
| 415 | + | core.PuregoSafeRegister(&xAsyncQueueTryPop, lib, "g_async_queue_try_pop") | |
| 416 | + | core.PuregoSafeRegister(&xAsyncQueueTryPopUnlocked, lib, "g_async_queue_try_pop_unlocked") | |
| 417 | + | core.PuregoSafeRegister(&xAsyncQueueUnlock, lib, "g_async_queue_unlock") | |
| 418 | + | core.PuregoSafeRegister(&xAsyncQueueUnref, lib, "g_async_queue_unref") | |
| 419 | + | core.PuregoSafeRegister(&xAsyncQueueUnrefAndUnlock, lib, "g_async_queue_unref_and_unlock") | |
| 420 | + | ||
| 421 | + | } | |
M v4/glib/gbookmarkfile.go +861 -0
| @@ -1,10 +1,816 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // An opaque data structure representing a set of bookmarks. | |
| 5 | 12 | type BookmarkFile struct { | |
| 6 | 13 | } | |
| 7 | 14 | ||
| 15 | + | func (x *BookmarkFile) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | var xBookmarkFileAddApplication func(uintptr, string, string, string) | |
| 20 | + | ||
| 21 | + | // Adds the application with @name and @exec to the list of | |
| 22 | + | // applications that have registered a bookmark for @uri into | |
| 23 | + | // @bookmark. | |
| 24 | + | // | |
| 25 | + | // Every bookmark inside a #GBookmarkFile must have at least an | |
| 26 | + | // application registered. Each application must provide a name, a | |
| 27 | + | // command line useful for launching the bookmark, the number of times | |
| 28 | + | // the bookmark has been registered by the application and the last | |
| 29 | + | // time the application registered this bookmark. | |
| 30 | + | // | |
| 31 | + | // If @name is %NULL, the name of the application will be the | |
| 32 | + | // same returned by g_get_application_name(); if @exec is %NULL, the | |
| 33 | + | // command line will be a composition of the program name as | |
| 34 | + | // returned by g_get_prgname() and the "\%u" modifier, which will be | |
| 35 | + | // expanded to the bookmark's URI. | |
| 36 | + | // | |
| 37 | + | // This function will automatically take care of updating the | |
| 38 | + | // registrations count and timestamping in case an application | |
| 39 | + | // with the same @name had already registered a bookmark for | |
| 40 | + | // @uri inside @bookmark. | |
| 41 | + | // | |
| 42 | + | // If no bookmark for @uri is found, one is created. | |
| 43 | + | func (x *BookmarkFile) AddApplication(UriVar string, NameVar string, ExecVar string) { | |
| 44 | + | ||
| 45 | + | xBookmarkFileAddApplication(x.GoPointer(), UriVar, NameVar, ExecVar) | |
| 46 | + | ||
| 47 | + | } | |
| 48 | + | ||
| 49 | + | var xBookmarkFileAddGroup func(uintptr, string, string) | |
| 50 | + | ||
| 51 | + | // Adds @group to the list of groups to which the bookmark for @uri | |
| 52 | + | // belongs to. | |
| 53 | + | // | |
| 54 | + | // If no bookmark for @uri is found then it is created. | |
| 55 | + | func (x *BookmarkFile) AddGroup(UriVar string, GroupVar string) { | |
| 56 | + | ||
| 57 | + | xBookmarkFileAddGroup(x.GoPointer(), UriVar, GroupVar) | |
| 58 | + | ||
| 59 | + | } | |
| 60 | + | ||
| 61 | + | var xBookmarkFileFree func(uintptr) | |
| 62 | + | ||
| 63 | + | // Frees a #GBookmarkFile. | |
| 64 | + | func (x *BookmarkFile) Free() { | |
| 65 | + | ||
| 66 | + | xBookmarkFileFree(x.GoPointer()) | |
| 67 | + | ||
| 68 | + | } | |
| 69 | + | ||
| 70 | + | var xBookmarkFileGetAdded func(uintptr, string, **Error) int32 | |
| 71 | + | ||
| 72 | + | // Gets the time the bookmark for @uri was added to @bookmark | |
| 73 | + | // | |
| 74 | + | // In the event the URI cannot be found, -1 is returned and | |
| 75 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 76 | + | func (x *BookmarkFile) GetAdded(UriVar string) (int32, error) { | |
| 77 | + | var cerr *Error | |
| 78 | + | ||
| 79 | + | cret := xBookmarkFileGetAdded(x.GoPointer(), UriVar, &cerr) | |
| 80 | + | if cerr == nil { | |
| 81 | + | return cret, nil | |
| 82 | + | } | |
| 83 | + | return cret, cerr | |
| 84 | + | ||
| 85 | + | } | |
| 86 | + | ||
| 87 | + | var xBookmarkFileGetAddedDateTime func(uintptr, string, **Error) *DateTime | |
| 88 | + | ||
| 89 | + | // Gets the time the bookmark for @uri was added to @bookmark | |
| 90 | + | // | |
| 91 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 92 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 93 | + | func (x *BookmarkFile) GetAddedDateTime(UriVar string) (*DateTime, error) { | |
| 94 | + | var cerr *Error | |
| 95 | + | ||
| 96 | + | cret := xBookmarkFileGetAddedDateTime(x.GoPointer(), UriVar, &cerr) | |
| 97 | + | if cerr == nil { | |
| 98 | + | return cret, nil | |
| 99 | + | } | |
| 100 | + | return cret, cerr | |
| 101 | + | ||
| 102 | + | } | |
| 103 | + | ||
| 104 | + | var xBookmarkFileGetAppInfo func(uintptr, string, string, string, uint, int32, **Error) bool | |
| 105 | + | ||
| 106 | + | // Gets the registration information of @app_name for the bookmark for | |
| 107 | + | // @uri. See g_bookmark_file_set_application_info() for more information about | |
| 108 | + | // the returned data. | |
| 109 | + | // | |
| 110 | + | // The string returned in @app_exec must be freed. | |
| 111 | + | // | |
| 112 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 113 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the | |
| 114 | + | // event that no application with name @app_name has registered a bookmark | |
| 115 | + | // for @uri, %FALSE is returned and error is set to | |
| 116 | + | // %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting | |
| 117 | + | // the command line fails, an error of the %G_SHELL_ERROR domain is | |
| 118 | + | // set and %FALSE is returned. | |
| 119 | + | func (x *BookmarkFile) GetAppInfo(UriVar string, NameVar string, ExecVar string, CountVar uint, StampVar int32) (bool, error) { | |
| 120 | + | var cerr *Error | |
| 121 | + | ||
| 122 | + | cret := xBookmarkFileGetAppInfo(x.GoPointer(), UriVar, NameVar, ExecVar, CountVar, StampVar, &cerr) | |
| 123 | + | if cerr == nil { | |
| 124 | + | return cret, nil | |
| 125 | + | } | |
| 126 | + | return cret, cerr | |
| 127 | + | ||
| 128 | + | } | |
| 129 | + | ||
| 130 | + | var xBookmarkFileGetApplicationInfo func(uintptr, string, string, string, uint, **DateTime, **Error) bool | |
| 131 | + | ||
| 132 | + | // Gets the registration information of @app_name for the bookmark for | |
| 133 | + | // @uri. See g_bookmark_file_set_application_info() for more information about | |
| 134 | + | // the returned data. | |
| 135 | + | // | |
| 136 | + | // The string returned in @app_exec must be freed. | |
| 137 | + | // | |
| 138 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 139 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the | |
| 140 | + | // event that no application with name @app_name has registered a bookmark | |
| 141 | + | // for @uri, %FALSE is returned and error is set to | |
| 142 | + | // %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting | |
| 143 | + | // the command line fails, an error of the %G_SHELL_ERROR domain is | |
| 144 | + | // set and %FALSE is returned. | |
| 145 | + | func (x *BookmarkFile) GetApplicationInfo(UriVar string, NameVar string, ExecVar string, CountVar uint, StampVar **DateTime) (bool, error) { | |
| 146 | + | var cerr *Error | |
| 147 | + | ||
| 148 | + | cret := xBookmarkFileGetApplicationInfo(x.GoPointer(), UriVar, NameVar, ExecVar, CountVar, StampVar, &cerr) | |
| 149 | + | if cerr == nil { | |
| 150 | + | return cret, nil | |
| 151 | + | } | |
| 152 | + | return cret, cerr | |
| 153 | + | ||
| 154 | + | } | |
| 155 | + | ||
| 156 | + | var xBookmarkFileGetApplications func(uintptr, string, uint, **Error) uintptr | |
| 157 | + | ||
| 158 | + | // Retrieves the names of the applications that have registered the | |
| 159 | + | // bookmark for @uri. | |
| 160 | + | // | |
| 161 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 162 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 163 | + | func (x *BookmarkFile) GetApplications(UriVar string, LengthVar uint) (uintptr, error) { | |
| 164 | + | var cerr *Error | |
| 165 | + | ||
| 166 | + | cret := xBookmarkFileGetApplications(x.GoPointer(), UriVar, LengthVar, &cerr) | |
| 167 | + | if cerr == nil { | |
| 168 | + | return cret, nil | |
| 169 | + | } | |
| 170 | + | return cret, cerr | |
| 171 | + | ||
| 172 | + | } | |
| 173 | + | ||
| 174 | + | var xBookmarkFileGetDescription func(uintptr, string, **Error) string | |
| 175 | + | ||
| 176 | + | // Retrieves the description of the bookmark for @uri. | |
| 177 | + | // | |
| 178 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 179 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 180 | + | func (x *BookmarkFile) GetDescription(UriVar string) (string, error) { | |
| 181 | + | var cerr *Error | |
| 182 | + | ||
| 183 | + | cret := xBookmarkFileGetDescription(x.GoPointer(), UriVar, &cerr) | |
| 184 | + | if cerr == nil { | |
| 185 | + | return cret, nil | |
| 186 | + | } | |
| 187 | + | return cret, cerr | |
| 188 | + | ||
| 189 | + | } | |
| 190 | + | ||
| 191 | + | var xBookmarkFileGetGroups func(uintptr, string, uint, **Error) uintptr | |
| 192 | + | ||
| 193 | + | // Retrieves the list of group names of the bookmark for @uri. | |
| 194 | + | // | |
| 195 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 196 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 197 | + | // | |
| 198 | + | // The returned array is %NULL terminated, so @length may optionally | |
| 199 | + | // be %NULL. | |
| 200 | + | func (x *BookmarkFile) GetGroups(UriVar string, LengthVar uint) (uintptr, error) { | |
| 201 | + | var cerr *Error | |
| 202 | + | ||
| 203 | + | cret := xBookmarkFileGetGroups(x.GoPointer(), UriVar, LengthVar, &cerr) | |
| 204 | + | if cerr == nil { | |
| 205 | + | return cret, nil | |
| 206 | + | } | |
| 207 | + | return cret, cerr | |
| 208 | + | ||
| 209 | + | } | |
| 210 | + | ||
| 211 | + | var xBookmarkFileGetIcon func(uintptr, string, string, string, **Error) bool | |
| 212 | + | ||
| 213 | + | // Gets the icon of the bookmark for @uri. | |
| 214 | + | // | |
| 215 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 216 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 217 | + | func (x *BookmarkFile) GetIcon(UriVar string, HrefVar string, MimeTypeVar string) (bool, error) { | |
| 218 | + | var cerr *Error | |
| 219 | + | ||
| 220 | + | cret := xBookmarkFileGetIcon(x.GoPointer(), UriVar, HrefVar, MimeTypeVar, &cerr) | |
| 221 | + | if cerr == nil { | |
| 222 | + | return cret, nil | |
| 223 | + | } | |
| 224 | + | return cret, cerr | |
| 225 | + | ||
| 226 | + | } | |
| 227 | + | ||
| 228 | + | var xBookmarkFileGetIsPrivate func(uintptr, string, **Error) bool | |
| 229 | + | ||
| 230 | + | // Gets whether the private flag of the bookmark for @uri is set. | |
| 231 | + | // | |
| 232 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 233 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the | |
| 234 | + | // event that the private flag cannot be found, %FALSE is returned and | |
| 235 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. | |
| 236 | + | func (x *BookmarkFile) GetIsPrivate(UriVar string) (bool, error) { | |
| 237 | + | var cerr *Error | |
| 238 | + | ||
| 239 | + | cret := xBookmarkFileGetIsPrivate(x.GoPointer(), UriVar, &cerr) | |
| 240 | + | if cerr == nil { | |
| 241 | + | return cret, nil | |
| 242 | + | } | |
| 243 | + | return cret, cerr | |
| 244 | + | ||
| 245 | + | } | |
| 246 | + | ||
| 247 | + | var xBookmarkFileGetMimeType func(uintptr, string, **Error) string | |
| 248 | + | ||
| 249 | + | // Retrieves the MIME type of the resource pointed by @uri. | |
| 250 | + | // | |
| 251 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 252 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the | |
| 253 | + | // event that the MIME type cannot be found, %NULL is returned and | |
| 254 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. | |
| 255 | + | func (x *BookmarkFile) GetMimeType(UriVar string) (string, error) { | |
| 256 | + | var cerr *Error | |
| 257 | + | ||
| 258 | + | cret := xBookmarkFileGetMimeType(x.GoPointer(), UriVar, &cerr) | |
| 259 | + | if cerr == nil { | |
| 260 | + | return cret, nil | |
| 261 | + | } | |
| 262 | + | return cret, cerr | |
| 263 | + | ||
| 264 | + | } | |
| 265 | + | ||
| 266 | + | var xBookmarkFileGetModified func(uintptr, string, **Error) int32 | |
| 267 | + | ||
| 268 | + | // Gets the time when the bookmark for @uri was last modified. | |
| 269 | + | // | |
| 270 | + | // In the event the URI cannot be found, -1 is returned and | |
| 271 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 272 | + | func (x *BookmarkFile) GetModified(UriVar string) (int32, error) { | |
| 273 | + | var cerr *Error | |
| 274 | + | ||
| 275 | + | cret := xBookmarkFileGetModified(x.GoPointer(), UriVar, &cerr) | |
| 276 | + | if cerr == nil { | |
| 277 | + | return cret, nil | |
| 278 | + | } | |
| 279 | + | return cret, cerr | |
| 280 | + | ||
| 281 | + | } | |
| 282 | + | ||
| 283 | + | var xBookmarkFileGetModifiedDateTime func(uintptr, string, **Error) *DateTime | |
| 284 | + | ||
| 285 | + | // Gets the time when the bookmark for @uri was last modified. | |
| 286 | + | // | |
| 287 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 288 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 289 | + | func (x *BookmarkFile) GetModifiedDateTime(UriVar string) (*DateTime, error) { | |
| 290 | + | var cerr *Error | |
| 291 | + | ||
| 292 | + | cret := xBookmarkFileGetModifiedDateTime(x.GoPointer(), UriVar, &cerr) | |
| 293 | + | if cerr == nil { | |
| 294 | + | return cret, nil | |
| 295 | + | } | |
| 296 | + | return cret, cerr | |
| 297 | + | ||
| 298 | + | } | |
| 299 | + | ||
| 300 | + | var xBookmarkFileGetSize func(uintptr) int | |
| 301 | + | ||
| 302 | + | // Gets the number of bookmarks inside @bookmark. | |
| 303 | + | func (x *BookmarkFile) GetSize() int { | |
| 304 | + | ||
| 305 | + | cret := xBookmarkFileGetSize(x.GoPointer()) | |
| 306 | + | return cret | |
| 307 | + | } | |
| 308 | + | ||
| 309 | + | var xBookmarkFileGetTitle func(uintptr, string, **Error) string | |
| 310 | + | ||
| 311 | + | // Returns the title of the bookmark for @uri. | |
| 312 | + | // | |
| 313 | + | // If @uri is %NULL, the title of @bookmark is returned. | |
| 314 | + | // | |
| 315 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 316 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 317 | + | func (x *BookmarkFile) GetTitle(UriVar string) (string, error) { | |
| 318 | + | var cerr *Error | |
| 319 | + | ||
| 320 | + | cret := xBookmarkFileGetTitle(x.GoPointer(), UriVar, &cerr) | |
| 321 | + | if cerr == nil { | |
| 322 | + | return cret, nil | |
| 323 | + | } | |
| 324 | + | return cret, cerr | |
| 325 | + | ||
| 326 | + | } | |
| 327 | + | ||
| 328 | + | var xBookmarkFileGetUris func(uintptr, uint) uintptr | |
| 329 | + | ||
| 330 | + | // Returns all URIs of the bookmarks in the bookmark file @bookmark. | |
| 331 | + | // The array of returned URIs will be %NULL-terminated, so @length may | |
| 332 | + | // optionally be %NULL. | |
| 333 | + | func (x *BookmarkFile) GetUris(LengthVar uint) uintptr { | |
| 334 | + | ||
| 335 | + | cret := xBookmarkFileGetUris(x.GoPointer(), LengthVar) | |
| 336 | + | return cret | |
| 337 | + | } | |
| 338 | + | ||
| 339 | + | var xBookmarkFileGetVisited func(uintptr, string, **Error) int32 | |
| 340 | + | ||
| 341 | + | // Gets the time the bookmark for @uri was last visited. | |
| 342 | + | // | |
| 343 | + | // In the event the URI cannot be found, -1 is returned and | |
| 344 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 345 | + | func (x *BookmarkFile) GetVisited(UriVar string) (int32, error) { | |
| 346 | + | var cerr *Error | |
| 347 | + | ||
| 348 | + | cret := xBookmarkFileGetVisited(x.GoPointer(), UriVar, &cerr) | |
| 349 | + | if cerr == nil { | |
| 350 | + | return cret, nil | |
| 351 | + | } | |
| 352 | + | return cret, cerr | |
| 353 | + | ||
| 354 | + | } | |
| 355 | + | ||
| 356 | + | var xBookmarkFileGetVisitedDateTime func(uintptr, string, **Error) *DateTime | |
| 357 | + | ||
| 358 | + | // Gets the time the bookmark for @uri was last visited. | |
| 359 | + | // | |
| 360 | + | // In the event the URI cannot be found, %NULL is returned and | |
| 361 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 362 | + | func (x *BookmarkFile) GetVisitedDateTime(UriVar string) (*DateTime, error) { | |
| 363 | + | var cerr *Error | |
| 364 | + | ||
| 365 | + | cret := xBookmarkFileGetVisitedDateTime(x.GoPointer(), UriVar, &cerr) | |
| 366 | + | if cerr == nil { | |
| 367 | + | return cret, nil | |
| 368 | + | } | |
| 369 | + | return cret, cerr | |
| 370 | + | ||
| 371 | + | } | |
| 372 | + | ||
| 373 | + | var xBookmarkFileHasApplication func(uintptr, string, string, **Error) bool | |
| 374 | + | ||
| 375 | + | // Checks whether the bookmark for @uri inside @bookmark has been | |
| 376 | + | // registered by application @name. | |
| 377 | + | // | |
| 378 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 379 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 380 | + | func (x *BookmarkFile) HasApplication(UriVar string, NameVar string) (bool, error) { | |
| 381 | + | var cerr *Error | |
| 382 | + | ||
| 383 | + | cret := xBookmarkFileHasApplication(x.GoPointer(), UriVar, NameVar, &cerr) | |
| 384 | + | if cerr == nil { | |
| 385 | + | return cret, nil | |
| 386 | + | } | |
| 387 | + | return cret, cerr | |
| 388 | + | ||
| 389 | + | } | |
| 390 | + | ||
| 391 | + | var xBookmarkFileHasGroup func(uintptr, string, string, **Error) bool | |
| 392 | + | ||
| 393 | + | // Checks whether @group appears in the list of groups to which | |
| 394 | + | // the bookmark for @uri belongs to. | |
| 395 | + | // | |
| 396 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 397 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 398 | + | func (x *BookmarkFile) HasGroup(UriVar string, GroupVar string) (bool, error) { | |
| 399 | + | var cerr *Error | |
| 400 | + | ||
| 401 | + | cret := xBookmarkFileHasGroup(x.GoPointer(), UriVar, GroupVar, &cerr) | |
| 402 | + | if cerr == nil { | |
| 403 | + | return cret, nil | |
| 404 | + | } | |
| 405 | + | return cret, cerr | |
| 406 | + | ||
| 407 | + | } | |
| 408 | + | ||
| 409 | + | var xBookmarkFileHasItem func(uintptr, string) bool | |
| 410 | + | ||
| 411 | + | // Looks whether the desktop bookmark has an item with its URI set to @uri. | |
| 412 | + | func (x *BookmarkFile) HasItem(UriVar string) bool { | |
| 413 | + | ||
| 414 | + | cret := xBookmarkFileHasItem(x.GoPointer(), UriVar) | |
| 415 | + | return cret | |
| 416 | + | } | |
| 417 | + | ||
| 418 | + | var xBookmarkFileLoadFromData func(uintptr, uintptr, uint, **Error) bool | |
| 419 | + | ||
| 420 | + | // Loads a bookmark file from memory into an empty #GBookmarkFile | |
| 421 | + | // structure. If the object cannot be created then @error is set to a | |
| 422 | + | // #GBookmarkFileError. | |
| 423 | + | func (x *BookmarkFile) LoadFromData(DataVar uintptr, LengthVar uint) (bool, error) { | |
| 424 | + | var cerr *Error | |
| 425 | + | ||
| 426 | + | cret := xBookmarkFileLoadFromData(x.GoPointer(), DataVar, LengthVar, &cerr) | |
| 427 | + | if cerr == nil { | |
| 428 | + | return cret, nil | |
| 429 | + | } | |
| 430 | + | return cret, cerr | |
| 431 | + | ||
| 432 | + | } | |
| 433 | + | ||
| 434 | + | var xBookmarkFileLoadFromDataDirs func(uintptr, string, string, **Error) bool | |
| 435 | + | ||
| 436 | + | // This function looks for a desktop bookmark file named @file in the | |
| 437 | + | // paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), | |
| 438 | + | // loads the file into @bookmark and returns the file's full path in | |
| 439 | + | // @full_path. If the file could not be loaded then @error is | |
| 440 | + | // set to either a #GFileError or #GBookmarkFileError. | |
| 441 | + | func (x *BookmarkFile) LoadFromDataDirs(FileVar string, FullPathVar string) (bool, error) { | |
| 442 | + | var cerr *Error | |
| 443 | + | ||
| 444 | + | cret := xBookmarkFileLoadFromDataDirs(x.GoPointer(), FileVar, FullPathVar, &cerr) | |
| 445 | + | if cerr == nil { | |
| 446 | + | return cret, nil | |
| 447 | + | } | |
| 448 | + | return cret, cerr | |
| 449 | + | ||
| 450 | + | } | |
| 451 | + | ||
| 452 | + | var xBookmarkFileLoadFromFile func(uintptr, string, **Error) bool | |
| 453 | + | ||
| 454 | + | // Loads a desktop bookmark file into an empty #GBookmarkFile structure. | |
| 455 | + | // If the file could not be loaded then @error is set to either a #GFileError | |
| 456 | + | // or #GBookmarkFileError. | |
| 457 | + | func (x *BookmarkFile) LoadFromFile(FilenameVar string) (bool, error) { | |
| 458 | + | var cerr *Error | |
| 459 | + | ||
| 460 | + | cret := xBookmarkFileLoadFromFile(x.GoPointer(), FilenameVar, &cerr) | |
| 461 | + | if cerr == nil { | |
| 462 | + | return cret, nil | |
| 463 | + | } | |
| 464 | + | return cret, cerr | |
| 465 | + | ||
| 466 | + | } | |
| 467 | + | ||
| 468 | + | var xBookmarkFileMoveItem func(uintptr, string, string, **Error) bool | |
| 469 | + | ||
| 470 | + | // Changes the URI of a bookmark item from @old_uri to @new_uri. Any | |
| 471 | + | // existing bookmark for @new_uri will be overwritten. If @new_uri is | |
| 472 | + | // %NULL, then the bookmark is removed. | |
| 473 | + | // | |
| 474 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 475 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 476 | + | func (x *BookmarkFile) MoveItem(OldUriVar string, NewUriVar string) (bool, error) { | |
| 477 | + | var cerr *Error | |
| 478 | + | ||
| 479 | + | cret := xBookmarkFileMoveItem(x.GoPointer(), OldUriVar, NewUriVar, &cerr) | |
| 480 | + | if cerr == nil { | |
| 481 | + | return cret, nil | |
| 482 | + | } | |
| 483 | + | return cret, cerr | |
| 484 | + | ||
| 485 | + | } | |
| 486 | + | ||
| 487 | + | var xBookmarkFileRemoveApplication func(uintptr, string, string, **Error) bool | |
| 488 | + | ||
| 489 | + | // Removes application registered with @name from the list of applications | |
| 490 | + | // that have registered a bookmark for @uri inside @bookmark. | |
| 491 | + | // | |
| 492 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 493 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 494 | + | // In the event that no application with name @app_name has registered | |
| 495 | + | // a bookmark for @uri, %FALSE is returned and error is set to | |
| 496 | + | // %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. | |
| 497 | + | func (x *BookmarkFile) RemoveApplication(UriVar string, NameVar string) (bool, error) { | |
| 498 | + | var cerr *Error | |
| 499 | + | ||
| 500 | + | cret := xBookmarkFileRemoveApplication(x.GoPointer(), UriVar, NameVar, &cerr) | |
| 501 | + | if cerr == nil { | |
| 502 | + | return cret, nil | |
| 503 | + | } | |
| 504 | + | return cret, cerr | |
| 505 | + | ||
| 506 | + | } | |
| 507 | + | ||
| 508 | + | var xBookmarkFileRemoveGroup func(uintptr, string, string, **Error) bool | |
| 509 | + | ||
| 510 | + | // Removes @group from the list of groups to which the bookmark | |
| 511 | + | // for @uri belongs to. | |
| 512 | + | // | |
| 513 | + | // In the event the URI cannot be found, %FALSE is returned and | |
| 514 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. | |
| 515 | + | // In the event no group was defined, %FALSE is returned and | |
| 516 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. | |
| 517 | + | func (x *BookmarkFile) RemoveGroup(UriVar string, GroupVar string) (bool, error) { | |
| 518 | + | var cerr *Error | |
| 519 | + | ||
| 520 | + | cret := xBookmarkFileRemoveGroup(x.GoPointer(), UriVar, GroupVar, &cerr) | |
| 521 | + | if cerr == nil { | |
| 522 | + | return cret, nil | |
| 523 | + | } | |
| 524 | + | return cret, cerr | |
| 525 | + | ||
| 526 | + | } | |
| 527 | + | ||
| 528 | + | var xBookmarkFileRemoveItem func(uintptr, string, **Error) bool | |
| 529 | + | ||
| 530 | + | // Removes the bookmark for @uri from the bookmark file @bookmark. | |
| 531 | + | func (x *BookmarkFile) RemoveItem(UriVar string) (bool, error) { | |
| 532 | + | var cerr *Error | |
| 533 | + | ||
| 534 | + | cret := xBookmarkFileRemoveItem(x.GoPointer(), UriVar, &cerr) | |
| 535 | + | if cerr == nil { | |
| 536 | + | return cret, nil | |
| 537 | + | } | |
| 538 | + | return cret, cerr | |
| 539 | + | ||
| 540 | + | } | |
| 541 | + | ||
| 542 | + | var xBookmarkFileSetAdded func(uintptr, string, int32) | |
| 543 | + | ||
| 544 | + | // Sets the time the bookmark for @uri was added into @bookmark. | |
| 545 | + | // | |
| 546 | + | // If no bookmark for @uri is found then it is created. | |
| 547 | + | func (x *BookmarkFile) SetAdded(UriVar string, AddedVar int32) { | |
| 548 | + | ||
| 549 | + | xBookmarkFileSetAdded(x.GoPointer(), UriVar, AddedVar) | |
| 550 | + | ||
| 551 | + | } | |
| 552 | + | ||
| 553 | + | var xBookmarkFileSetAddedDateTime func(uintptr, string, *DateTime) | |
| 554 | + | ||
| 555 | + | // Sets the time the bookmark for @uri was added into @bookmark. | |
| 556 | + | // | |
| 557 | + | // If no bookmark for @uri is found then it is created. | |
| 558 | + | func (x *BookmarkFile) SetAddedDateTime(UriVar string, AddedVar *DateTime) { | |
| 559 | + | ||
| 560 | + | xBookmarkFileSetAddedDateTime(x.GoPointer(), UriVar, AddedVar) | |
| 561 | + | ||
| 562 | + | } | |
| 563 | + | ||
| 564 | + | var xBookmarkFileSetAppInfo func(uintptr, string, string, string, int, int32, **Error) bool | |
| 565 | + | ||
| 566 | + | // Sets the meta-data of application @name inside the list of | |
| 567 | + | // applications that have registered a bookmark for @uri inside | |
| 568 | + | // @bookmark. | |
| 569 | + | // | |
| 570 | + | // You should rarely use this function; use g_bookmark_file_add_application() | |
| 571 | + | // and g_bookmark_file_remove_application() instead. | |
| 572 | + | // | |
| 573 | + | // @name can be any UTF-8 encoded string used to identify an | |
| 574 | + | // application. | |
| 575 | + | // @exec can have one of these two modifiers: "\%f", which will | |
| 576 | + | // be expanded as the local file name retrieved from the bookmark's | |
| 577 | + | // URI; "\%u", which will be expanded as the bookmark's URI. | |
| 578 | + | // The expansion is done automatically when retrieving the stored | |
| 579 | + | // command line using the g_bookmark_file_get_application_info() function. | |
| 580 | + | // @count is the number of times the application has registered the | |
| 581 | + | // bookmark; if is < 0, the current registration count will be increased | |
| 582 | + | // by one, if is 0, the application with @name will be removed from | |
| 583 | + | // the list of registered applications. | |
| 584 | + | // @stamp is the Unix time of the last registration; if it is -1, the | |
| 585 | + | // current time will be used. | |
| 586 | + | // | |
| 587 | + | // If you try to remove an application by setting its registration count to | |
| 588 | + | // zero, and no bookmark for @uri is found, %FALSE is returned and | |
| 589 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, | |
| 590 | + | // in the event that no application @name has registered a bookmark | |
| 591 | + | // for @uri, %FALSE is returned and error is set to | |
| 592 | + | // %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark | |
| 593 | + | // for @uri is found, one is created. | |
| 594 | + | func (x *BookmarkFile) SetAppInfo(UriVar string, NameVar string, ExecVar string, CountVar int, StampVar int32) (bool, error) { | |
| 595 | + | var cerr *Error | |
| 596 | + | ||
| 597 | + | cret := xBookmarkFileSetAppInfo(x.GoPointer(), UriVar, NameVar, ExecVar, CountVar, StampVar, &cerr) | |
| 598 | + | if cerr == nil { | |
| 599 | + | return cret, nil | |
| 600 | + | } | |
| 601 | + | return cret, cerr | |
| 602 | + | ||
| 603 | + | } | |
| 604 | + | ||
| 605 | + | var xBookmarkFileSetApplicationInfo func(uintptr, string, string, string, int, *DateTime, **Error) bool | |
| 606 | + | ||
| 607 | + | // Sets the meta-data of application @name inside the list of | |
| 608 | + | // applications that have registered a bookmark for @uri inside | |
| 609 | + | // @bookmark. | |
| 610 | + | // | |
| 611 | + | // You should rarely use this function; use g_bookmark_file_add_application() | |
| 612 | + | // and g_bookmark_file_remove_application() instead. | |
| 613 | + | // | |
| 614 | + | // @name can be any UTF-8 encoded string used to identify an | |
| 615 | + | // application. | |
| 616 | + | // @exec can have one of these two modifiers: "\%f", which will | |
| 617 | + | // be expanded as the local file name retrieved from the bookmark's | |
| 618 | + | // URI; "\%u", which will be expanded as the bookmark's URI. | |
| 619 | + | // The expansion is done automatically when retrieving the stored | |
| 620 | + | // command line using the g_bookmark_file_get_application_info() function. | |
| 621 | + | // @count is the number of times the application has registered the | |
| 622 | + | // bookmark; if is < 0, the current registration count will be increased | |
| 623 | + | // by one, if is 0, the application with @name will be removed from | |
| 624 | + | // the list of registered applications. | |
| 625 | + | // @stamp is the Unix time of the last registration. | |
| 626 | + | // | |
| 627 | + | // If you try to remove an application by setting its registration count to | |
| 628 | + | // zero, and no bookmark for @uri is found, %FALSE is returned and | |
| 629 | + | // @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, | |
| 630 | + | // in the event that no application @name has registered a bookmark | |
| 631 | + | // for @uri, %FALSE is returned and error is set to | |
| 632 | + | // %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark | |
| 633 | + | // for @uri is found, one is created. | |
| 634 | + | func (x *BookmarkFile) SetApplicationInfo(UriVar string, NameVar string, ExecVar string, CountVar int, StampVar *DateTime) (bool, error) { | |
| 635 | + | var cerr *Error | |
| 636 | + | ||
| 637 | + | cret := xBookmarkFileSetApplicationInfo(x.GoPointer(), UriVar, NameVar, ExecVar, CountVar, StampVar, &cerr) | |
| 638 | + | if cerr == nil { | |
| 639 | + | return cret, nil | |
| 640 | + | } | |
| 641 | + | return cret, cerr | |
| 642 | + | ||
| 643 | + | } | |
| 644 | + | ||
| 645 | + | var xBookmarkFileSetDescription func(uintptr, string, string) | |
| 646 | + | ||
| 647 | + | // Sets @description as the description of the bookmark for @uri. | |
| 648 | + | // | |
| 649 | + | // If @uri is %NULL, the description of @bookmark is set. | |
| 650 | + | // | |
| 651 | + | // If a bookmark for @uri cannot be found then it is created. | |
| 652 | + | func (x *BookmarkFile) SetDescription(UriVar string, DescriptionVar string) { | |
| 653 | + | ||
| 654 | + | xBookmarkFileSetDescription(x.GoPointer(), UriVar, DescriptionVar) | |
| 655 | + | ||
| 656 | + | } | |
| 657 | + | ||
| 658 | + | var xBookmarkFileSetGroups func(uintptr, string, uintptr, uint) | |
| 659 | + | ||
| 660 | + | // Sets a list of group names for the item with URI @uri. Each previously | |
| 661 | + | // set group name list is removed. | |
| 662 | + | // | |
| 663 | + | // If @uri cannot be found then an item for it is created. | |
| 664 | + | func (x *BookmarkFile) SetGroups(UriVar string, GroupsVar uintptr, LengthVar uint) { | |
| 665 | + | ||
| 666 | + | xBookmarkFileSetGroups(x.GoPointer(), UriVar, GroupsVar, LengthVar) | |
| 667 | + | ||
| 668 | + | } | |
| 669 | + | ||
| 670 | + | var xBookmarkFileSetIcon func(uintptr, string, string, string) | |
| 671 | + | ||
| 672 | + | // Sets the icon for the bookmark for @uri. If @href is %NULL, unsets | |
| 673 | + | // the currently set icon. @href can either be a full URL for the icon | |
| 674 | + | // file or the icon name following the Icon Naming specification. | |
| 675 | + | // | |
| 676 | + | // If no bookmark for @uri is found one is created. | |
| 677 | + | func (x *BookmarkFile) SetIcon(UriVar string, HrefVar string, MimeTypeVar string) { | |
| 678 | + | ||
| 679 | + | xBookmarkFileSetIcon(x.GoPointer(), UriVar, HrefVar, MimeTypeVar) | |
| 680 | + | ||
| 681 | + | } | |
| 682 | + | ||
| 683 | + | var xBookmarkFileSetIsPrivate func(uintptr, string, bool) | |
| 684 | + | ||
| 685 | + | // Sets the private flag of the bookmark for @uri. | |
| 686 | + | // | |
| 687 | + | // If a bookmark for @uri cannot be found then it is created. | |
| 688 | + | func (x *BookmarkFile) SetIsPrivate(UriVar string, IsPrivateVar bool) { | |
| 689 | + | ||
| 690 | + | xBookmarkFileSetIsPrivate(x.GoPointer(), UriVar, IsPrivateVar) | |
| 691 | + | ||
| 692 | + | } | |
| 693 | + | ||
| 694 | + | var xBookmarkFileSetMimeType func(uintptr, string, string) | |
| 695 | + | ||
| 696 | + | // Sets @mime_type as the MIME type of the bookmark for @uri. | |
| 697 | + | // | |
| 698 | + | // If a bookmark for @uri cannot be found then it is created. | |
| 699 | + | func (x *BookmarkFile) SetMimeType(UriVar string, MimeTypeVar string) { | |
| 700 | + | ||
| 701 | + | xBookmarkFileSetMimeType(x.GoPointer(), UriVar, MimeTypeVar) | |
| 702 | + | ||
| 703 | + | } | |
| 704 | + | ||
| 705 | + | var xBookmarkFileSetModified func(uintptr, string, int32) | |
| 706 | + | ||
| 707 | + | // Sets the last time the bookmark for @uri was last modified. | |
| 708 | + | // | |
| 709 | + | // If no bookmark for @uri is found then it is created. | |
| 710 | + | // | |
| 711 | + | // The "modified" time should only be set when the bookmark's meta-data | |
| 712 | + | // was actually changed. Every function of #GBookmarkFile that | |
| 713 | + | // modifies a bookmark also changes the modification time, except for | |
| 714 | + | // g_bookmark_file_set_visited_date_time(). | |
| 715 | + | func (x *BookmarkFile) SetModified(UriVar string, ModifiedVar int32) { | |
| 716 | + | ||
| 717 | + | xBookmarkFileSetModified(x.GoPointer(), UriVar, ModifiedVar) | |
| 718 | + | ||
| 719 | + | } | |
| 720 | + | ||
| 721 | + | var xBookmarkFileSetModifiedDateTime func(uintptr, string, *DateTime) | |
| 722 | + | ||
| 723 | + | // Sets the last time the bookmark for @uri was last modified. | |
| 724 | + | // | |
| 725 | + | // If no bookmark for @uri is found then it is created. | |
| 726 | + | // | |
| 727 | + | // The "modified" time should only be set when the bookmark's meta-data | |
| 728 | + | // was actually changed. Every function of #GBookmarkFile that | |
| 729 | + | // modifies a bookmark also changes the modification time, except for | |
| 730 | + | // g_bookmark_file_set_visited_date_time(). | |
| 731 | + | func (x *BookmarkFile) SetModifiedDateTime(UriVar string, ModifiedVar *DateTime) { | |
| 732 | + | ||
| 733 | + | xBookmarkFileSetModifiedDateTime(x.GoPointer(), UriVar, ModifiedVar) | |
| 734 | + | ||
| 735 | + | } | |
| 736 | + | ||
| 737 | + | var xBookmarkFileSetTitle func(uintptr, string, string) | |
| 738 | + | ||
| 739 | + | // Sets @title as the title of the bookmark for @uri inside the | |
| 740 | + | // bookmark file @bookmark. | |
| 741 | + | // | |
| 742 | + | // If @uri is %NULL, the title of @bookmark is set. | |
| 743 | + | // | |
| 744 | + | // If a bookmark for @uri cannot be found then it is created. | |
| 745 | + | func (x *BookmarkFile) SetTitle(UriVar string, TitleVar string) { | |
| 746 | + | ||
| 747 | + | xBookmarkFileSetTitle(x.GoPointer(), UriVar, TitleVar) | |
| 748 | + | ||
| 749 | + | } | |
| 750 | + | ||
| 751 | + | var xBookmarkFileSetVisited func(uintptr, string, int32) | |
| 752 | + | ||
| 753 | + | // Sets the time the bookmark for @uri was last visited. | |
| 754 | + | // | |
| 755 | + | // If no bookmark for @uri is found then it is created. | |
| 756 | + | // | |
| 757 | + | // The "visited" time should only be set if the bookmark was launched, | |
| 758 | + | // either using the command line retrieved by g_bookmark_file_get_application_info() | |
| 759 | + | // or by the default application for the bookmark's MIME type, retrieved | |
| 760 | + | // using g_bookmark_file_get_mime_type(). Changing the "visited" time | |
| 761 | + | // does not affect the "modified" time. | |
| 762 | + | func (x *BookmarkFile) SetVisited(UriVar string, VisitedVar int32) { | |
| 763 | + | ||
| 764 | + | xBookmarkFileSetVisited(x.GoPointer(), UriVar, VisitedVar) | |
| 765 | + | ||
| 766 | + | } | |
| 767 | + | ||
| 768 | + | var xBookmarkFileSetVisitedDateTime func(uintptr, string, *DateTime) | |
| 769 | + | ||
| 770 | + | // Sets the time the bookmark for @uri was last visited. | |
| 771 | + | // | |
| 772 | + | // If no bookmark for @uri is found then it is created. | |
| 773 | + | // | |
| 774 | + | // The "visited" time should only be set if the bookmark was launched, | |
| 775 | + | // either using the command line retrieved by g_bookmark_file_get_application_info() | |
| 776 | + | // or by the default application for the bookmark's MIME type, retrieved | |
| 777 | + | // using g_bookmark_file_get_mime_type(). Changing the "visited" time | |
| 778 | + | // does not affect the "modified" time. | |
| 779 | + | func (x *BookmarkFile) SetVisitedDateTime(UriVar string, VisitedVar *DateTime) { | |
| 780 | + | ||
| 781 | + | xBookmarkFileSetVisitedDateTime(x.GoPointer(), UriVar, VisitedVar) | |
| 782 | + | ||
| 783 | + | } | |
| 784 | + | ||
| 785 | + | var xBookmarkFileToData func(uintptr, uint, **Error) uintptr | |
| 786 | + | ||
| 787 | + | // This function outputs @bookmark as a string. | |
| 788 | + | func (x *BookmarkFile) ToData(LengthVar uint) (uintptr, error) { | |
| 789 | + | var cerr *Error | |
| 790 | + | ||
| 791 | + | cret := xBookmarkFileToData(x.GoPointer(), LengthVar, &cerr) | |
| 792 | + | if cerr == nil { | |
| 793 | + | return cret, nil | |
| 794 | + | } | |
| 795 | + | return cret, cerr | |
| 796 | + | ||
| 797 | + | } | |
| 798 | + | ||
| 799 | + | var xBookmarkFileToFile func(uintptr, string, **Error) bool | |
| 800 | + | ||
| 801 | + | // This function outputs @bookmark into a file. The write process is | |
| 802 | + | // guaranteed to be atomic by using g_file_set_contents() internally. | |
| 803 | + | func (x *BookmarkFile) ToFile(FilenameVar string) (bool, error) { | |
| 804 | + | var cerr *Error | |
| 805 | + | ||
| 806 | + | cret := xBookmarkFileToFile(x.GoPointer(), FilenameVar, &cerr) | |
| 807 | + | if cerr == nil { | |
| 808 | + | return cret, nil | |
| 809 | + | } | |
| 810 | + | return cret, cerr | |
| 811 | + | ||
| 812 | + | } | |
| 813 | + | ||
| 8 | 814 | // Error codes returned by bookmark file parsing. | |
| 9 | 815 | type BookmarkFileError int | |
| 10 | 816 | ||
| @@ -29,3 +835,58 @@ const ( | |||
| 29 | 835 | // requested file was not found | |
| 30 | 836 | GBookmarkFileErrorFileNotFoundValue BookmarkFileError = 7 | |
| 31 | 837 | ) | |
| 838 | + | ||
| 839 | + | func init() { | |
| 840 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 841 | + | if err != nil { | |
| 842 | + | panic(err) | |
| 843 | + | } | |
| 844 | + | ||
| 845 | + | core.PuregoSafeRegister(&xBookmarkFileAddApplication, lib, "g_bookmark_file_add_application") | |
| 846 | + | core.PuregoSafeRegister(&xBookmarkFileAddGroup, lib, "g_bookmark_file_add_group") | |
| 847 | + | core.PuregoSafeRegister(&xBookmarkFileFree, lib, "g_bookmark_file_free") | |
| 848 | + | core.PuregoSafeRegister(&xBookmarkFileGetAdded, lib, "g_bookmark_file_get_added") | |
| 849 | + | core.PuregoSafeRegister(&xBookmarkFileGetAddedDateTime, lib, "g_bookmark_file_get_added_date_time") | |
| 850 | + | core.PuregoSafeRegister(&xBookmarkFileGetAppInfo, lib, "g_bookmark_file_get_app_info") | |
| 851 | + | core.PuregoSafeRegister(&xBookmarkFileGetApplicationInfo, lib, "g_bookmark_file_get_application_info") | |
| 852 | + | core.PuregoSafeRegister(&xBookmarkFileGetApplications, lib, "g_bookmark_file_get_applications") | |
| 853 | + | core.PuregoSafeRegister(&xBookmarkFileGetDescription, lib, "g_bookmark_file_get_description") | |
| 854 | + | core.PuregoSafeRegister(&xBookmarkFileGetGroups, lib, "g_bookmark_file_get_groups") | |
| 855 | + | core.PuregoSafeRegister(&xBookmarkFileGetIcon, lib, "g_bookmark_file_get_icon") | |
| 856 | + | core.PuregoSafeRegister(&xBookmarkFileGetIsPrivate, lib, "g_bookmark_file_get_is_private") | |
| 857 | + | core.PuregoSafeRegister(&xBookmarkFileGetMimeType, lib, "g_bookmark_file_get_mime_type") | |
| 858 | + | core.PuregoSafeRegister(&xBookmarkFileGetModified, lib, "g_bookmark_file_get_modified") | |
| 859 | + | core.PuregoSafeRegister(&xBookmarkFileGetModifiedDateTime, lib, "g_bookmark_file_get_modified_date_time") | |
| 860 | + | core.PuregoSafeRegister(&xBookmarkFileGetSize, lib, "g_bookmark_file_get_size") | |
| 861 | + | core.PuregoSafeRegister(&xBookmarkFileGetTitle, lib, "g_bookmark_file_get_title") | |
| 862 | + | core.PuregoSafeRegister(&xBookmarkFileGetUris, lib, "g_bookmark_file_get_uris") | |
| 863 | + | core.PuregoSafeRegister(&xBookmarkFileGetVisited, lib, "g_bookmark_file_get_visited") | |
| 864 | + | core.PuregoSafeRegister(&xBookmarkFileGetVisitedDateTime, lib, "g_bookmark_file_get_visited_date_time") | |
| 865 | + | core.PuregoSafeRegister(&xBookmarkFileHasApplication, lib, "g_bookmark_file_has_application") | |
| 866 | + | core.PuregoSafeRegister(&xBookmarkFileHasGroup, lib, "g_bookmark_file_has_group") | |
| 867 | + | core.PuregoSafeRegister(&xBookmarkFileHasItem, lib, "g_bookmark_file_has_item") | |
| 868 | + | core.PuregoSafeRegister(&xBookmarkFileLoadFromData, lib, "g_bookmark_file_load_from_data") | |
| 869 | + | core.PuregoSafeRegister(&xBookmarkFileLoadFromDataDirs, lib, "g_bookmark_file_load_from_data_dirs") | |
| 870 | + | core.PuregoSafeRegister(&xBookmarkFileLoadFromFile, lib, "g_bookmark_file_load_from_file") | |
| 871 | + | core.PuregoSafeRegister(&xBookmarkFileMoveItem, lib, "g_bookmark_file_move_item") | |
| 872 | + | core.PuregoSafeRegister(&xBookmarkFileRemoveApplication, lib, "g_bookmark_file_remove_application") | |
| 873 | + | core.PuregoSafeRegister(&xBookmarkFileRemoveGroup, lib, "g_bookmark_file_remove_group") | |
| 874 | + | core.PuregoSafeRegister(&xBookmarkFileRemoveItem, lib, "g_bookmark_file_remove_item") | |
| 875 | + | core.PuregoSafeRegister(&xBookmarkFileSetAdded, lib, "g_bookmark_file_set_added") | |
| 876 | + | core.PuregoSafeRegister(&xBookmarkFileSetAddedDateTime, lib, "g_bookmark_file_set_added_date_time") | |
| 877 | + | core.PuregoSafeRegister(&xBookmarkFileSetAppInfo, lib, "g_bookmark_file_set_app_info") | |
| 878 | + | core.PuregoSafeRegister(&xBookmarkFileSetApplicationInfo, lib, "g_bookmark_file_set_application_info") | |
| 879 | + | core.PuregoSafeRegister(&xBookmarkFileSetDescription, lib, "g_bookmark_file_set_description") | |
| 880 | + | core.PuregoSafeRegister(&xBookmarkFileSetGroups, lib, "g_bookmark_file_set_groups") | |
| 881 | + | core.PuregoSafeRegister(&xBookmarkFileSetIcon, lib, "g_bookmark_file_set_icon") | |
| 882 | + | core.PuregoSafeRegister(&xBookmarkFileSetIsPrivate, lib, "g_bookmark_file_set_is_private") | |
| 883 | + | core.PuregoSafeRegister(&xBookmarkFileSetMimeType, lib, "g_bookmark_file_set_mime_type") | |
| 884 | + | core.PuregoSafeRegister(&xBookmarkFileSetModified, lib, "g_bookmark_file_set_modified") | |
| 885 | + | core.PuregoSafeRegister(&xBookmarkFileSetModifiedDateTime, lib, "g_bookmark_file_set_modified_date_time") | |
| 886 | + | core.PuregoSafeRegister(&xBookmarkFileSetTitle, lib, "g_bookmark_file_set_title") | |
| 887 | + | core.PuregoSafeRegister(&xBookmarkFileSetVisited, lib, "g_bookmark_file_set_visited") | |
| 888 | + | core.PuregoSafeRegister(&xBookmarkFileSetVisitedDateTime, lib, "g_bookmark_file_set_visited_date_time") | |
| 889 | + | core.PuregoSafeRegister(&xBookmarkFileToData, lib, "g_bookmark_file_to_data") | |
| 890 | + | core.PuregoSafeRegister(&xBookmarkFileToFile, lib, "g_bookmark_file_to_file") | |
| 891 | + | ||
| 892 | + | } | |
M v4/glib/gchecksum.go +103 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -13,6 +15,98 @@ import ( | |||
| 13 | 15 | type Checksum struct { | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *Checksum) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 22 | + | var xNewChecksum func(ChecksumType) *Checksum | |
| 23 | + | ||
| 24 | + | // Creates a new #GChecksum, using the checksum algorithm @checksum_type. | |
| 25 | + | // If the @checksum_type is not known, %NULL is returned. | |
| 26 | + | // A #GChecksum can be used to compute the checksum, or digest, of an | |
| 27 | + | // arbitrary binary blob, using different hashing algorithms. | |
| 28 | + | // | |
| 29 | + | // A #GChecksum works by feeding a binary blob through g_checksum_update() | |
| 30 | + | // until there is data to be checked; the digest can then be extracted | |
| 31 | + | // using g_checksum_get_string(), which will return the checksum as a | |
| 32 | + | // hexadecimal string; or g_checksum_get_digest(), which will return a | |
| 33 | + | // vector of raw bytes. Once either g_checksum_get_string() or | |
| 34 | + | // g_checksum_get_digest() have been called on a #GChecksum, the checksum | |
| 35 | + | // will be closed and it won't be possible to call g_checksum_update() | |
| 36 | + | // on it anymore. | |
| 37 | + | func NewChecksum(ChecksumTypeVar ChecksumType) *Checksum { | |
| 38 | + | ||
| 39 | + | cret := xNewChecksum(ChecksumTypeVar) | |
| 40 | + | return cret | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xChecksumCopy func(uintptr) *Checksum | |
| 44 | + | ||
| 45 | + | // Copies a #GChecksum. If @checksum has been closed, by calling | |
| 46 | + | // g_checksum_get_string() or g_checksum_get_digest(), the copied | |
| 47 | + | // checksum will be closed as well. | |
| 48 | + | func (x *Checksum) Copy() *Checksum { | |
| 49 | + | ||
| 50 | + | cret := xChecksumCopy(x.GoPointer()) | |
| 51 | + | return cret | |
| 52 | + | } | |
| 53 | + | ||
| 54 | + | var xChecksumFree func(uintptr) | |
| 55 | + | ||
| 56 | + | // Frees the memory allocated for @checksum. | |
| 57 | + | func (x *Checksum) Free() { | |
| 58 | + | ||
| 59 | + | xChecksumFree(x.GoPointer()) | |
| 60 | + | ||
| 61 | + | } | |
| 62 | + | ||
| 63 | + | var xChecksumGetDigest func(uintptr, uintptr, uint) | |
| 64 | + | ||
| 65 | + | // Gets the digest from @checksum as a raw binary vector and places it | |
| 66 | + | // into @buffer. The size of the digest depends on the type of checksum. | |
| 67 | + | // | |
| 68 | + | // Once this function has been called, the #GChecksum is closed and can | |
| 69 | + | // no longer be updated with g_checksum_update(). | |
| 70 | + | func (x *Checksum) GetDigest(BufferVar uintptr, DigestLenVar uint) { | |
| 71 | + | ||
| 72 | + | xChecksumGetDigest(x.GoPointer(), BufferVar, DigestLenVar) | |
| 73 | + | ||
| 74 | + | } | |
| 75 | + | ||
| 76 | + | var xChecksumGetString func(uintptr) string | |
| 77 | + | ||
| 78 | + | // Gets the digest as a hexadecimal string. | |
| 79 | + | // | |
| 80 | + | // Once this function has been called the #GChecksum can no longer be | |
| 81 | + | // updated with g_checksum_update(). | |
| 82 | + | // | |
| 83 | + | // The hexadecimal characters will be lower case. | |
| 84 | + | func (x *Checksum) GetString() string { | |
| 85 | + | ||
| 86 | + | cret := xChecksumGetString(x.GoPointer()) | |
| 87 | + | return cret | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | var xChecksumReset func(uintptr) | |
| 91 | + | ||
| 92 | + | // Resets the state of the @checksum back to its initial state. | |
| 93 | + | func (x *Checksum) Reset() { | |
| 94 | + | ||
| 95 | + | xChecksumReset(x.GoPointer()) | |
| 96 | + | ||
| 97 | + | } | |
| 98 | + | ||
| 99 | + | var xChecksumUpdate func(uintptr, uintptr, int) | |
| 100 | + | ||
| 101 | + | // Feeds @data into an existing #GChecksum. The checksum must still be | |
| 102 | + | // open, that is g_checksum_get_string() or g_checksum_get_digest() must | |
| 103 | + | // not have been called on @checksum. | |
| 104 | + | func (x *Checksum) Update(DataVar uintptr, LengthVar int) { | |
| 105 | + | ||
| 106 | + | xChecksumUpdate(x.GoPointer(), DataVar, LengthVar) | |
| 107 | + | ||
| 108 | + | } | |
| 109 | + | ||
| 16 | 110 | // The hashing algorithm to be used by #GChecksum when performing the | |
| 17 | 111 | // digest of some data. | |
| 18 | 112 | // | |
| @@ -90,4 +184,13 @@ func init() { | |||
| 90 | 184 | core.PuregoSafeRegister(&xComputeChecksumForData, lib, "g_compute_checksum_for_data") | |
| 91 | 185 | core.PuregoSafeRegister(&xComputeChecksumForString, lib, "g_compute_checksum_for_string") | |
| 92 | 186 | ||
| 187 | + | core.PuregoSafeRegister(&xNewChecksum, lib, "g_checksum_new") | |
| 188 | + | ||
| 189 | + | core.PuregoSafeRegister(&xChecksumCopy, lib, "g_checksum_copy") | |
| 190 | + | core.PuregoSafeRegister(&xChecksumFree, lib, "g_checksum_free") | |
| 191 | + | core.PuregoSafeRegister(&xChecksumGetDigest, lib, "g_checksum_get_digest") | |
| 192 | + | core.PuregoSafeRegister(&xChecksumGetString, lib, "g_checksum_get_string") | |
| 193 | + | core.PuregoSafeRegister(&xChecksumReset, lib, "g_checksum_reset") | |
| 194 | + | core.PuregoSafeRegister(&xChecksumUpdate, lib, "g_checksum_update") | |
| 195 | + | ||
| 93 | 196 | } | |
M v4/glib/gconvert.go +46 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,47 @@ import ( | |||
| 11 | 13 | type IConv struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *IConv) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xIConvGIconv func(uintptr, string, uint, string, uint) uint | |
| 21 | + | ||
| 22 | + | // Same as the standard UNIX routine iconv(), but | |
| 23 | + | // may be implemented via libiconv on UNIX flavors that lack | |
| 24 | + | // a native implementation. | |
| 25 | + | // | |
| 26 | + | // GLib provides g_convert() and g_locale_to_utf8() which are likely | |
| 27 | + | // more convenient than the raw iconv wrappers. | |
| 28 | + | // | |
| 29 | + | // Note that the behaviour of iconv() for characters which are valid in the | |
| 30 | + | // input character set, but which have no representation in the output character | |
| 31 | + | // set, is implementation defined. This function may return success (with a | |
| 32 | + | // positive number of non-reversible conversions as replacement characters were | |
| 33 | + | // used), or it may return -1 and set an error such as %EILSEQ, in such a | |
| 34 | + | // situation. | |
| 35 | + | func (x *IConv) GIconv(InbufVar string, InbytesLeftVar uint, OutbufVar string, OutbytesLeftVar uint) uint { | |
| 36 | + | ||
| 37 | + | cret := xIConvGIconv(x.GoPointer(), InbufVar, InbytesLeftVar, OutbufVar, OutbytesLeftVar) | |
| 38 | + | return cret | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | var xIConvClose func(uintptr) int | |
| 42 | + | ||
| 43 | + | // Same as the standard UNIX routine iconv_close(), but | |
| 44 | + | // may be implemented via libiconv on UNIX flavors that lack | |
| 45 | + | // a native implementation. Should be called to clean up | |
| 46 | + | // the conversion descriptor from g_iconv_open() when | |
| 47 | + | // you are done converting things. | |
| 48 | + | // | |
| 49 | + | // GLib provides g_convert() and g_locale_to_utf8() which are likely | |
| 50 | + | // more convenient than the raw iconv wrappers. | |
| 51 | + | func (x *IConv) Close() int { | |
| 52 | + | ||
| 53 | + | cret := xIConvClose(x.GoPointer()) | |
| 54 | + | return cret | |
| 55 | + | } | |
| 56 | + | ||
| 14 | 57 | // Error codes returned by character set conversion routines. | |
| 15 | 58 | type ConvertError int | |
| 16 | 59 | ||
| @@ -398,4 +441,7 @@ func init() { | |||
| 398 | 441 | core.PuregoSafeRegister(&xLocaleToUtf8, lib, "g_locale_to_utf8") | |
| 399 | 442 | core.PuregoSafeRegister(&xUriListExtractUris, lib, "g_uri_list_extract_uris") | |
| 400 | 443 | ||
| 444 | + | core.PuregoSafeRegister(&xIConvGIconv, lib, "g_iconv") | |
| 445 | + | core.PuregoSafeRegister(&xIConvClose, lib, "g_iconv_close") | |
| 446 | + | ||
| 401 | 447 | } | |
M v4/glib/gdataset.go +13 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -23,6 +25,17 @@ type DuplicateFunc func(uintptr, uintptr) uintptr | |||
| 23 | 25 | type Data struct { | |
| 24 | 26 | } | |
| 25 | 27 | ||
| 28 | + | func (x *Data) GoPointer() uintptr { | |
| 29 | + | return uintptr(unsafe.Pointer(x)) | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | const ( | |
| 33 | + | // A bitmask that restricts the possible flags passed to | |
| 34 | + | // g_datalist_set_flags(). Passing a flags value where | |
| 35 | + | // flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. | |
| 36 | + | DATALIST_FLAGS_MASK int = 3 | |
| 37 | + | ) | |
| 38 | + | ||
| 26 | 39 | var xDatalistClear func(**Data) | |
| 27 | 40 | ||
| 28 | 41 | // Frees all the data elements of the datalist. | |
M v4/glib/gdate.go +486 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -31,6 +33,441 @@ type Date struct { | |||
| 31 | 33 | Year uint | |
| 32 | 34 | } | |
| 33 | 35 | ||
| 36 | + | func (x *Date) GoPointer() uintptr { | |
| 37 | + | return uintptr(unsafe.Pointer(x)) | |
| 38 | + | } | |
| 39 | + | ||
| 40 | + | var xNewDate func() *Date | |
| 41 | + | ||
| 42 | + | // Allocates a #GDate and initializes | |
| 43 | + | // it to a safe state. The new date will | |
| 44 | + | // be cleared (as if you'd called g_date_clear()) but invalid (it won't | |
| 45 | + | // represent an existing day). Free the return value with g_date_free(). | |
| 46 | + | func NewDate() *Date { | |
| 47 | + | ||
| 48 | + | cret := xNewDate() | |
| 49 | + | return cret | |
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xNewDmyDate func(DateDay, DateMonth, DateYear) *Date | |
| 53 | + | ||
| 54 | + | // Create a new #GDate representing the given day-month-year triplet. | |
| 55 | + | // | |
| 56 | + | // The triplet you pass in must represent a valid date. Use g_date_valid_dmy() | |
| 57 | + | // if needed to validate it. The returned #GDate is guaranteed to be non-%NULL | |
| 58 | + | // and valid. | |
| 59 | + | func NewDmyDate(DayVar DateDay, MonthVar DateMonth, YearVar DateYear) *Date { | |
| 60 | + | ||
| 61 | + | cret := xNewDmyDate(DayVar, MonthVar, YearVar) | |
| 62 | + | return cret | |
| 63 | + | } | |
| 64 | + | ||
| 65 | + | var xNewJulianDate func(uint32) *Date | |
| 66 | + | ||
| 67 | + | // Create a new #GDate representing the given Julian date. | |
| 68 | + | // | |
| 69 | + | // The @julian_day you pass in must be valid. Use g_date_valid_julian() if | |
| 70 | + | // needed to validate it. The returned #GDate is guaranteed to be non-%NULL and | |
| 71 | + | // valid. | |
| 72 | + | func NewJulianDate(JulianDayVar uint32) *Date { | |
| 73 | + | ||
| 74 | + | cret := xNewJulianDate(JulianDayVar) | |
| 75 | + | return cret | |
| 76 | + | } | |
| 77 | + | ||
| 78 | + | var xDateAddDays func(uintptr, uint) | |
| 79 | + | ||
| 80 | + | // Increments a date some number of days. | |
| 81 | + | // To move forward by weeks, add weeks*7 days. | |
| 82 | + | // The date must be valid. | |
| 83 | + | func (x *Date) AddDays(NDaysVar uint) { | |
| 84 | + | ||
| 85 | + | xDateAddDays(x.GoPointer(), NDaysVar) | |
| 86 | + | ||
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xDateAddMonths func(uintptr, uint) | |
| 90 | + | ||
| 91 | + | // Increments a date by some number of months. | |
| 92 | + | // If the day of the month is greater than 28, | |
| 93 | + | // this routine may change the day of the month | |
| 94 | + | // (because the destination month may not have | |
| 95 | + | // the current day in it). The date must be valid. | |
| 96 | + | func (x *Date) AddMonths(NMonthsVar uint) { | |
| 97 | + | ||
| 98 | + | xDateAddMonths(x.GoPointer(), NMonthsVar) | |
| 99 | + | ||
| 100 | + | } | |
| 101 | + | ||
| 102 | + | var xDateAddYears func(uintptr, uint) | |
| 103 | + | ||
| 104 | + | // Increments a date by some number of years. | |
| 105 | + | // If the date is February 29, and the destination | |
| 106 | + | // year is not a leap year, the date will be changed | |
| 107 | + | // to February 28. The date must be valid. | |
| 108 | + | func (x *Date) AddYears(NYearsVar uint) { | |
| 109 | + | ||
| 110 | + | xDateAddYears(x.GoPointer(), NYearsVar) | |
| 111 | + | ||
| 112 | + | } | |
| 113 | + | ||
| 114 | + | var xDateClamp func(uintptr, *Date, *Date) | |
| 115 | + | ||
| 116 | + | // If @date is prior to @min_date, sets @date equal to @min_date. | |
| 117 | + | // If @date falls after @max_date, sets @date equal to @max_date. | |
| 118 | + | // Otherwise, @date is unchanged. | |
| 119 | + | // Either of @min_date and @max_date may be %NULL. | |
| 120 | + | // All non-%NULL dates must be valid. | |
| 121 | + | func (x *Date) Clamp(MinDateVar *Date, MaxDateVar *Date) { | |
| 122 | + | ||
| 123 | + | xDateClamp(x.GoPointer(), MinDateVar, MaxDateVar) | |
| 124 | + | ||
| 125 | + | } | |
| 126 | + | ||
| 127 | + | var xDateClear func(uintptr, uint) | |
| 128 | + | ||
| 129 | + | // Initializes one or more #GDate structs to a safe but invalid | |
| 130 | + | // state. The cleared dates will not represent an existing date, but will | |
| 131 | + | // not contain garbage. Useful to init a date declared on the stack. | |
| 132 | + | // Validity can be tested with g_date_valid(). | |
| 133 | + | func (x *Date) Clear(NDatesVar uint) { | |
| 134 | + | ||
| 135 | + | xDateClear(x.GoPointer(), NDatesVar) | |
| 136 | + | ||
| 137 | + | } | |
| 138 | + | ||
| 139 | + | var xDateCompare func(uintptr, *Date) int | |
| 140 | + | ||
| 141 | + | // qsort()-style comparison function for dates. | |
| 142 | + | // Both dates must be valid. | |
| 143 | + | func (x *Date) Compare(RhsVar *Date) int { | |
| 144 | + | ||
| 145 | + | cret := xDateCompare(x.GoPointer(), RhsVar) | |
| 146 | + | return cret | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | var xDateCopy func(uintptr) *Date | |
| 150 | + | ||
| 151 | + | // Copies a GDate to a newly-allocated GDate. If the input was invalid | |
| 152 | + | // (as determined by g_date_valid()), the invalid state will be copied | |
| 153 | + | // as is into the new object. | |
| 154 | + | func (x *Date) Copy() *Date { | |
| 155 | + | ||
| 156 | + | cret := xDateCopy(x.GoPointer()) | |
| 157 | + | return cret | |
| 158 | + | } | |
| 159 | + | ||
| 160 | + | var xDateDaysBetween func(uintptr, *Date) int | |
| 161 | + | ||
| 162 | + | // Computes the number of days between two dates. | |
| 163 | + | // If @date2 is prior to @date1, the returned value is negative. | |
| 164 | + | // Both dates must be valid. | |
| 165 | + | func (x *Date) DaysBetween(Date2Var *Date) int { | |
| 166 | + | ||
| 167 | + | cret := xDateDaysBetween(x.GoPointer(), Date2Var) | |
| 168 | + | return cret | |
| 169 | + | } | |
| 170 | + | ||
| 171 | + | var xDateFree func(uintptr) | |
| 172 | + | ||
| 173 | + | // Frees a #GDate returned from g_date_new(). | |
| 174 | + | func (x *Date) Free() { | |
| 175 | + | ||
| 176 | + | xDateFree(x.GoPointer()) | |
| 177 | + | ||
| 178 | + | } | |
| 179 | + | ||
| 180 | + | var xDateGetDay func(uintptr) DateDay | |
| 181 | + | ||
| 182 | + | // Returns the day of the month. The date must be valid. | |
| 183 | + | func (x *Date) GetDay() DateDay { | |
| 184 | + | ||
| 185 | + | cret := xDateGetDay(x.GoPointer()) | |
| 186 | + | return cret | |
| 187 | + | } | |
| 188 | + | ||
| 189 | + | var xDateGetDayOfYear func(uintptr) uint | |
| 190 | + | ||
| 191 | + | // Returns the day of the year, where Jan 1 is the first day of the | |
| 192 | + | // year. The date must be valid. | |
| 193 | + | func (x *Date) GetDayOfYear() uint { | |
| 194 | + | ||
| 195 | + | cret := xDateGetDayOfYear(x.GoPointer()) | |
| 196 | + | return cret | |
| 197 | + | } | |
| 198 | + | ||
| 199 | + | var xDateGetIso8601WeekOfYear func(uintptr) uint | |
| 200 | + | ||
| 201 | + | // Returns the week of the year, where weeks are interpreted according | |
| 202 | + | // to ISO 8601. | |
| 203 | + | func (x *Date) GetIso8601WeekOfYear() uint { | |
| 204 | + | ||
| 205 | + | cret := xDateGetIso8601WeekOfYear(x.GoPointer()) | |
| 206 | + | return cret | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | var xDateGetJulian func(uintptr) uint32 | |
| 210 | + | ||
| 211 | + | // Returns the Julian day or "serial number" of the #GDate. The | |
| 212 | + | // Julian day is simply the number of days since January 1, Year 1; i.e., | |
| 213 | + | // January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2, | |
| 214 | + | // etc. The date must be valid. | |
| 215 | + | func (x *Date) GetJulian() uint32 { | |
| 216 | + | ||
| 217 | + | cret := xDateGetJulian(x.GoPointer()) | |
| 218 | + | return cret | |
| 219 | + | } | |
| 220 | + | ||
| 221 | + | var xDateGetMondayWeekOfYear func(uintptr) uint | |
| 222 | + | ||
| 223 | + | // Returns the week of the year, where weeks are understood to start on | |
| 224 | + | // Monday. If the date is before the first Monday of the year, return 0. | |
| 225 | + | // The date must be valid. | |
| 226 | + | func (x *Date) GetMondayWeekOfYear() uint { | |
| 227 | + | ||
| 228 | + | cret := xDateGetMondayWeekOfYear(x.GoPointer()) | |
| 229 | + | return cret | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | var xDateGetMonth func(uintptr) DateMonth | |
| 233 | + | ||
| 234 | + | // Returns the month of the year. The date must be valid. | |
| 235 | + | func (x *Date) GetMonth() DateMonth { | |
| 236 | + | ||
| 237 | + | cret := xDateGetMonth(x.GoPointer()) | |
| 238 | + | return cret | |
| 239 | + | } | |
| 240 | + | ||
| 241 | + | var xDateGetSundayWeekOfYear func(uintptr) uint | |
| 242 | + | ||
| 243 | + | // Returns the week of the year during which this date falls, if | |
| 244 | + | // weeks are understood to begin on Sunday. The date must be valid. | |
| 245 | + | // Can return 0 if the day is before the first Sunday of the year. | |
| 246 | + | func (x *Date) GetSundayWeekOfYear() uint { | |
| 247 | + | ||
| 248 | + | cret := xDateGetSundayWeekOfYear(x.GoPointer()) | |
| 249 | + | return cret | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | var xDateGetWeekday func(uintptr) DateWeekday | |
| 253 | + | ||
| 254 | + | // Returns the day of the week for a #GDate. The date must be valid. | |
| 255 | + | func (x *Date) GetWeekday() DateWeekday { | |
| 256 | + | ||
| 257 | + | cret := xDateGetWeekday(x.GoPointer()) | |
| 258 | + | return cret | |
| 259 | + | } | |
| 260 | + | ||
| 261 | + | var xDateGetYear func(uintptr) DateYear | |
| 262 | + | ||
| 263 | + | // Returns the year of a #GDate. The date must be valid. | |
| 264 | + | func (x *Date) GetYear() DateYear { | |
| 265 | + | ||
| 266 | + | cret := xDateGetYear(x.GoPointer()) | |
| 267 | + | return cret | |
| 268 | + | } | |
| 269 | + | ||
| 270 | + | var xDateIsFirstOfMonth func(uintptr) bool | |
| 271 | + | ||
| 272 | + | // Returns %TRUE if the date is on the first of a month. | |
| 273 | + | // The date must be valid. | |
| 274 | + | func (x *Date) IsFirstOfMonth() bool { | |
| 275 | + | ||
| 276 | + | cret := xDateIsFirstOfMonth(x.GoPointer()) | |
| 277 | + | return cret | |
| 278 | + | } | |
| 279 | + | ||
| 280 | + | var xDateIsLastOfMonth func(uintptr) bool | |
| 281 | + | ||
| 282 | + | // Returns %TRUE if the date is the last day of the month. | |
| 283 | + | // The date must be valid. | |
| 284 | + | func (x *Date) IsLastOfMonth() bool { | |
| 285 | + | ||
| 286 | + | cret := xDateIsLastOfMonth(x.GoPointer()) | |
| 287 | + | return cret | |
| 288 | + | } | |
| 289 | + | ||
| 290 | + | var xDateOrder func(uintptr, *Date) | |
| 291 | + | ||
| 292 | + | // Checks if @date1 is less than or equal to @date2, | |
| 293 | + | // and swap the values if this is not the case. | |
| 294 | + | func (x *Date) Order(Date2Var *Date) { | |
| 295 | + | ||
| 296 | + | xDateOrder(x.GoPointer(), Date2Var) | |
| 297 | + | ||
| 298 | + | } | |
| 299 | + | ||
| 300 | + | var xDateSetDay func(uintptr, DateDay) | |
| 301 | + | ||
| 302 | + | // Sets the day of the month for a #GDate. If the resulting | |
| 303 | + | // day-month-year triplet is invalid, the date will be invalid. | |
| 304 | + | func (x *Date) SetDay(DayVar DateDay) { | |
| 305 | + | ||
| 306 | + | xDateSetDay(x.GoPointer(), DayVar) | |
| 307 | + | ||
| 308 | + | } | |
| 309 | + | ||
| 310 | + | var xDateSetDmy func(uintptr, DateDay, DateMonth, DateYear) | |
| 311 | + | ||
| 312 | + | // Sets the value of a #GDate from a day, month, and year. | |
| 313 | + | // The day-month-year triplet must be valid; if you aren't | |
| 314 | + | // sure it is, call g_date_valid_dmy() to check before you | |
| 315 | + | // set it. | |
| 316 | + | func (x *Date) SetDmy(DayVar DateDay, MonthVar DateMonth, YVar DateYear) { | |
| 317 | + | ||
| 318 | + | xDateSetDmy(x.GoPointer(), DayVar, MonthVar, YVar) | |
| 319 | + | ||
| 320 | + | } | |
| 321 | + | ||
| 322 | + | var xDateSetJulian func(uintptr, uint32) | |
| 323 | + | ||
| 324 | + | // Sets the value of a #GDate from a Julian day number. | |
| 325 | + | func (x *Date) SetJulian(JulianDateVar uint32) { | |
| 326 | + | ||
| 327 | + | xDateSetJulian(x.GoPointer(), JulianDateVar) | |
| 328 | + | ||
| 329 | + | } | |
| 330 | + | ||
| 331 | + | var xDateSetMonth func(uintptr, DateMonth) | |
| 332 | + | ||
| 333 | + | // Sets the month of the year for a #GDate. If the resulting | |
| 334 | + | // day-month-year triplet is invalid, the date will be invalid. | |
| 335 | + | func (x *Date) SetMonth(MonthVar DateMonth) { | |
| 336 | + | ||
| 337 | + | xDateSetMonth(x.GoPointer(), MonthVar) | |
| 338 | + | ||
| 339 | + | } | |
| 340 | + | ||
| 341 | + | var xDateSetParse func(uintptr, string) | |
| 342 | + | ||
| 343 | + | // Parses a user-inputted string @str, and try to figure out what date it | |
| 344 | + | // represents, taking the [current locale][setlocale] into account. If the | |
| 345 | + | // string is successfully parsed, the date will be valid after the call. | |
| 346 | + | // Otherwise, it will be invalid. You should check using g_date_valid() | |
| 347 | + | // to see whether the parsing succeeded. | |
| 348 | + | // | |
| 349 | + | // This function is not appropriate for file formats and the like; it | |
| 350 | + | // isn't very precise, and its exact behavior varies with the locale. | |
| 351 | + | // It's intended to be a heuristic routine that guesses what the user | |
| 352 | + | // means by a given string (and it does work pretty well in that | |
| 353 | + | // capacity). | |
| 354 | + | func (x *Date) SetParse(StrVar string) { | |
| 355 | + | ||
| 356 | + | xDateSetParse(x.GoPointer(), StrVar) | |
| 357 | + | ||
| 358 | + | } | |
| 359 | + | ||
| 360 | + | var xDateSetTime func(uintptr, Time) | |
| 361 | + | ||
| 362 | + | // Sets the value of a date from a #GTime value. | |
| 363 | + | // The time to date conversion is done using the user's current timezone. | |
| 364 | + | func (x *Date) SetTime(TimeVar Time) { | |
| 365 | + | ||
| 366 | + | xDateSetTime(x.GoPointer(), TimeVar) | |
| 367 | + | ||
| 368 | + | } | |
| 369 | + | ||
| 370 | + | var xDateSetTimeT func(uintptr, int32) | |
| 371 | + | ||
| 372 | + | // Sets the value of a date to the date corresponding to a time | |
| 373 | + | // specified as a time_t. The time to date conversion is done using | |
| 374 | + | // the user's current timezone. | |
| 375 | + | // | |
| 376 | + | // To set the value of a date to the current day, you could write: | |
| 377 | + | // |[<!-- language="C" --> | |
| 378 | + | // | |
| 379 | + | // time_t now = time (NULL); | |
| 380 | + | // if (now == (time_t) -1) | |
| 381 | + | // // handle the error | |
| 382 | + | // g_date_set_time_t (date, now); | |
| 383 | + | // | |
| 384 | + | // ]| | |
| 385 | + | func (x *Date) SetTimeT(TimetVar int32) { | |
| 386 | + | ||
| 387 | + | xDateSetTimeT(x.GoPointer(), TimetVar) | |
| 388 | + | ||
| 389 | + | } | |
| 390 | + | ||
| 391 | + | var xDateSetTimeVal func(uintptr, *TimeVal) | |
| 392 | + | ||
| 393 | + | // Sets the value of a date from a #GTimeVal value. Note that the | |
| 394 | + | // @tv_usec member is ignored, because #GDate can't make use of the | |
| 395 | + | // additional precision. | |
| 396 | + | // | |
| 397 | + | // The time to date conversion is done using the user's current timezone. | |
| 398 | + | func (x *Date) SetTimeVal(TimevalVar *TimeVal) { | |
| 399 | + | ||
| 400 | + | xDateSetTimeVal(x.GoPointer(), TimevalVar) | |
| 401 | + | ||
| 402 | + | } | |
| 403 | + | ||
| 404 | + | var xDateSetYear func(uintptr, DateYear) | |
| 405 | + | ||
| 406 | + | // Sets the year for a #GDate. If the resulting day-month-year | |
| 407 | + | // triplet is invalid, the date will be invalid. | |
| 408 | + | func (x *Date) SetYear(YearVar DateYear) { | |
| 409 | + | ||
| 410 | + | xDateSetYear(x.GoPointer(), YearVar) | |
| 411 | + | ||
| 412 | + | } | |
| 413 | + | ||
| 414 | + | var xDateSubtractDays func(uintptr, uint) | |
| 415 | + | ||
| 416 | + | // Moves a date some number of days into the past. | |
| 417 | + | // To move by weeks, just move by weeks*7 days. | |
| 418 | + | // The date must be valid. | |
| 419 | + | func (x *Date) SubtractDays(NDaysVar uint) { | |
| 420 | + | ||
| 421 | + | xDateSubtractDays(x.GoPointer(), NDaysVar) | |
| 422 | + | ||
| 423 | + | } | |
| 424 | + | ||
| 425 | + | var xDateSubtractMonths func(uintptr, uint) | |
| 426 | + | ||
| 427 | + | // Moves a date some number of months into the past. | |
| 428 | + | // If the current day of the month doesn't exist in | |
| 429 | + | // the destination month, the day of the month | |
| 430 | + | // may change. The date must be valid. | |
| 431 | + | func (x *Date) SubtractMonths(NMonthsVar uint) { | |
| 432 | + | ||
| 433 | + | xDateSubtractMonths(x.GoPointer(), NMonthsVar) | |
| 434 | + | ||
| 435 | + | } | |
| 436 | + | ||
| 437 | + | var xDateSubtractYears func(uintptr, uint) | |
| 438 | + | ||
| 439 | + | // Moves a date some number of years into the past. | |
| 440 | + | // If the current day doesn't exist in the destination | |
| 441 | + | // year (i.e. it's February 29 and you move to a non-leap-year) | |
| 442 | + | // then the day is changed to February 29. The date | |
| 443 | + | // must be valid. | |
| 444 | + | func (x *Date) SubtractYears(NYearsVar uint) { | |
| 445 | + | ||
| 446 | + | xDateSubtractYears(x.GoPointer(), NYearsVar) | |
| 447 | + | ||
| 448 | + | } | |
| 449 | + | ||
| 450 | + | var xDateToStructTm func(uintptr, uintptr) | |
| 451 | + | ||
| 452 | + | // Fills in the date-related bits of a struct tm using the @date value. | |
| 453 | + | // Initializes the non-date parts with something safe but meaningless. | |
| 454 | + | func (x *Date) ToStructTm(TmVar uintptr) { | |
| 455 | + | ||
| 456 | + | xDateToStructTm(x.GoPointer(), TmVar) | |
| 457 | + | ||
| 458 | + | } | |
| 459 | + | ||
| 460 | + | var xDateValid func(uintptr) bool | |
| 461 | + | ||
| 462 | + | // Returns %TRUE if the #GDate represents an existing day. The date must not | |
| 463 | + | // contain garbage; it should have been initialized with g_date_clear() | |
| 464 | + | // if it wasn't allocated by one of the g_date_new() variants. | |
| 465 | + | func (x *Date) Valid() bool { | |
| 466 | + | ||
| 467 | + | cret := xDateValid(x.GoPointer()) | |
| 468 | + | return cret | |
| 469 | + | } | |
| 470 | + | ||
| 34 | 471 | // Integer representing a day of the month; between 1 and 31. | |
| 35 | 472 | // | |
| 36 | 473 | // The %G_DATE_BAD_DAY value represents an invalid day of the month. | |
| @@ -68,6 +505,15 @@ type DateYear = uint16 | |||
| 68 | 505 | // ]| | |
| 69 | 506 | type Time = int32 | |
| 70 | 507 | ||
| 508 | + | const ( | |
| 509 | + | // Represents an invalid #GDateDay. | |
| 510 | + | DATE_BAD_DAY int = 0 | |
| 511 | + | // Represents an invalid Julian day number. | |
| 512 | + | DATE_BAD_JULIAN int = 0 | |
| 513 | + | // Represents an invalid year. | |
| 514 | + | DATE_BAD_YEAR int = 0 | |
| 515 | + | ) | |
| 516 | + | ||
| 71 | 517 | // This enumeration isn't used in the API, but may be useful if you need | |
| 72 | 518 | // to mark a number as a day, month, or year. | |
| 73 | 519 | type DateDMY int | |
| @@ -293,4 +739,44 @@ func init() { | |||
| 293 | 739 | core.PuregoSafeRegister(&xDateValidWeekday, lib, "g_date_valid_weekday") | |
| 294 | 740 | core.PuregoSafeRegister(&xDateValidYear, lib, "g_date_valid_year") | |
| 295 | 741 | ||
| 742 | + | core.PuregoSafeRegister(&xNewDate, lib, "g_date_new") | |
| 743 | + | core.PuregoSafeRegister(&xNewDmyDate, lib, "g_date_new_dmy") | |
| 744 | + | core.PuregoSafeRegister(&xNewJulianDate, lib, "g_date_new_julian") | |
| 745 | + | ||
| 746 | + | core.PuregoSafeRegister(&xDateAddDays, lib, "g_date_add_days") | |
| 747 | + | core.PuregoSafeRegister(&xDateAddMonths, lib, "g_date_add_months") | |
| 748 | + | core.PuregoSafeRegister(&xDateAddYears, lib, "g_date_add_years") | |
| 749 | + | core.PuregoSafeRegister(&xDateClamp, lib, "g_date_clamp") | |
| 750 | + | core.PuregoSafeRegister(&xDateClear, lib, "g_date_clear") | |
| 751 | + | core.PuregoSafeRegister(&xDateCompare, lib, "g_date_compare") | |
| 752 | + | core.PuregoSafeRegister(&xDateCopy, lib, "g_date_copy") | |
| 753 | + | core.PuregoSafeRegister(&xDateDaysBetween, lib, "g_date_days_between") | |
| 754 | + | core.PuregoSafeRegister(&xDateFree, lib, "g_date_free") | |
| 755 | + | core.PuregoSafeRegister(&xDateGetDay, lib, "g_date_get_day") | |
| 756 | + | core.PuregoSafeRegister(&xDateGetDayOfYear, lib, "g_date_get_day_of_year") | |
| 757 | + | core.PuregoSafeRegister(&xDateGetIso8601WeekOfYear, lib, "g_date_get_iso8601_week_of_year") | |
| 758 | + | core.PuregoSafeRegister(&xDateGetJulian, lib, "g_date_get_julian") | |
| 759 | + | core.PuregoSafeRegister(&xDateGetMondayWeekOfYear, lib, "g_date_get_monday_week_of_year") | |
| 760 | + | core.PuregoSafeRegister(&xDateGetMonth, lib, "g_date_get_month") | |
| 761 | + | core.PuregoSafeRegister(&xDateGetSundayWeekOfYear, lib, "g_date_get_sunday_week_of_year") | |
| 762 | + | core.PuregoSafeRegister(&xDateGetWeekday, lib, "g_date_get_weekday") | |
| 763 | + | core.PuregoSafeRegister(&xDateGetYear, lib, "g_date_get_year") | |
| 764 | + | core.PuregoSafeRegister(&xDateIsFirstOfMonth, lib, "g_date_is_first_of_month") | |
| 765 | + | core.PuregoSafeRegister(&xDateIsLastOfMonth, lib, "g_date_is_last_of_month") | |
| 766 | + | core.PuregoSafeRegister(&xDateOrder, lib, "g_date_order") | |
| 767 | + | core.PuregoSafeRegister(&xDateSetDay, lib, "g_date_set_day") | |
| 768 | + | core.PuregoSafeRegister(&xDateSetDmy, lib, "g_date_set_dmy") | |
| 769 | + | core.PuregoSafeRegister(&xDateSetJulian, lib, "g_date_set_julian") | |
| 770 | + | core.PuregoSafeRegister(&xDateSetMonth, lib, "g_date_set_month") | |
| 771 | + | core.PuregoSafeRegister(&xDateSetParse, lib, "g_date_set_parse") | |
| 772 | + | core.PuregoSafeRegister(&xDateSetTime, lib, "g_date_set_time") | |
| 773 | + | core.PuregoSafeRegister(&xDateSetTimeT, lib, "g_date_set_time_t") | |
| 774 | + | core.PuregoSafeRegister(&xDateSetTimeVal, lib, "g_date_set_time_val") | |
| 775 | + | core.PuregoSafeRegister(&xDateSetYear, lib, "g_date_set_year") | |
| 776 | + | core.PuregoSafeRegister(&xDateSubtractDays, lib, "g_date_subtract_days") | |
| 777 | + | core.PuregoSafeRegister(&xDateSubtractMonths, lib, "g_date_subtract_months") | |
| 778 | + | core.PuregoSafeRegister(&xDateSubtractYears, lib, "g_date_subtract_years") | |
| 779 | + | core.PuregoSafeRegister(&xDateToStructTm, lib, "g_date_to_struct_tm") | |
| 780 | + | core.PuregoSafeRegister(&xDateValid, lib, "g_date_valid") | |
| 781 | + | ||
| 296 | 782 | } | |
M v4/glib/gdatetime.go +883 -0
| @@ -1,9 +1,892 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // An opaque structure that represents a date and time, including a time zone. | |
| 5 | 12 | type DateTime struct { | |
| 6 | 13 | } | |
| 7 | 14 | ||
| 15 | + | func (x *DateTime) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | var xNewDateTime func(*TimeZone, int, int, int, int, int, float64) *DateTime | |
| 20 | + | ||
| 21 | + | // Creates a new #GDateTime corresponding to the given date and time in | |
| 22 | + | // the time zone @tz. | |
| 23 | + | // | |
| 24 | + | // The @year must be between 1 and 9999, @month between 1 and 12 and @day | |
| 25 | + | // between 1 and 28, 29, 30 or 31 depending on the month and the year. | |
| 26 | + | // | |
| 27 | + | // @hour must be between 0 and 23 and @minute must be between 0 and 59. | |
| 28 | + | // | |
| 29 | + | // @seconds must be at least 0.0 and must be strictly less than 60.0. | |
| 30 | + | // It will be rounded down to the nearest microsecond. | |
| 31 | + | // | |
| 32 | + | // If the given time is not representable in the given time zone (for | |
| 33 | + | // example, 02:30 on March 14th 2010 in Toronto, due to daylight savings | |
| 34 | + | // time) then the time will be rounded up to the nearest existing time | |
| 35 | + | // (in this case, 03:00). If this matters to you then you should verify | |
| 36 | + | // the return value for containing the same as the numbers you gave. | |
| 37 | + | // | |
| 38 | + | // In the case that the given time is ambiguous in the given time zone | |
| 39 | + | // (for example, 01:30 on November 7th 2010 in Toronto, due to daylight | |
| 40 | + | // savings time) then the time falling within standard (ie: | |
| 41 | + | // non-daylight) time is taken. | |
| 42 | + | // | |
| 43 | + | // It not considered a programmer error for the values to this function | |
| 44 | + | // to be out of range, but in the case that they are, the function will | |
| 45 | + | // return %NULL. | |
| 46 | + | // | |
| 47 | + | // You should release the return value by calling g_date_time_unref() | |
| 48 | + | // when you are done with it. | |
| 49 | + | func NewDateTime(TzVar *TimeZone, YearVar int, MonthVar int, DayVar int, HourVar int, MinuteVar int, SecondsVar float64) *DateTime { | |
| 50 | + | ||
| 51 | + | cret := xNewDateTime(TzVar, YearVar, MonthVar, DayVar, HourVar, MinuteVar, SecondsVar) | |
| 52 | + | return cret | |
| 53 | + | } | |
| 54 | + | ||
| 55 | + | var xNewFromIso8601DateTime func(string, *TimeZone) *DateTime | |
| 56 | + | ||
| 57 | + | // Creates a #GDateTime corresponding to the given | |
| 58 | + | // [ISO 8601 formatted string](https://en.wikipedia.org/wiki/ISO_8601) | |
| 59 | + | // @text. ISO 8601 strings of the form <date><sep><time><tz> are supported, with | |
| 60 | + | // some extensions from [RFC 3339](https://tools.ietf.org/html/rfc3339) as | |
| 61 | + | // mentioned below. | |
| 62 | + | // | |
| 63 | + | // Note that as #GDateTime "is oblivious to leap seconds", leap seconds information | |
| 64 | + | // in an ISO-8601 string will be ignored, so a `23:59:60` time would be parsed as | |
| 65 | + | // `23:59:59`. | |
| 66 | + | // | |
| 67 | + | // <sep> is the separator and can be either 'T', 't' or ' '. The latter two | |
| 68 | + | // separators are an extension from | |
| 69 | + | // [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6). | |
| 70 | + | // | |
| 71 | + | // <date> is in the form: | |
| 72 | + | // | |
| 73 | + | // - `YYYY-MM-DD` - Year/month/day, e.g. 2016-08-24. | |
| 74 | + | // - `YYYYMMDD` - Same as above without dividers. | |
| 75 | + | // - `YYYY-DDD` - Ordinal day where DDD is from 001 to 366, e.g. 2016-237. | |
| 76 | + | // - `YYYYDDD` - Same as above without dividers. | |
| 77 | + | // - `YYYY-Www-D` - Week day where ww is from 01 to 52 and D from 1-7, | |
| 78 | + | // e.g. 2016-W34-3. | |
| 79 | + | // - `YYYYWwwD` - Same as above without dividers. | |
| 80 | + | // | |
| 81 | + | // <time> is in the form: | |
| 82 | + | // | |
| 83 | + | // - `hh:mm:ss(.sss)` - Hours, minutes, seconds (subseconds), e.g. 22:10:42.123. | |
| 84 | + | // - `hhmmss(.sss)` - Same as above without dividers. | |
| 85 | + | // | |
| 86 | + | // <tz> is an optional timezone suffix of the form: | |
| 87 | + | // | |
| 88 | + | // - `Z` - UTC. | |
| 89 | + | // - `+hh:mm` or `-hh:mm` - Offset from UTC in hours and minutes, e.g. +12:00. | |
| 90 | + | // - `+hh` or `-hh` - Offset from UTC in hours, e.g. +12. | |
| 91 | + | // | |
| 92 | + | // If the timezone is not provided in @text it must be provided in @default_tz | |
| 93 | + | // (this field is otherwise ignored). | |
| 94 | + | // | |
| 95 | + | // This call can fail (returning %NULL) if @text is not a valid ISO 8601 | |
| 96 | + | // formatted string. | |
| 97 | + | // | |
| 98 | + | // You should release the return value by calling g_date_time_unref() | |
| 99 | + | // when you are done with it. | |
| 100 | + | func NewFromIso8601DateTime(TextVar string, DefaultTzVar *TimeZone) *DateTime { | |
| 101 | + | ||
| 102 | + | cret := xNewFromIso8601DateTime(TextVar, DefaultTzVar) | |
| 103 | + | return cret | |
| 104 | + | } | |
| 105 | + | ||
| 106 | + | var xNewFromTimevalLocalDateTime func(*TimeVal) *DateTime | |
| 107 | + | ||
| 108 | + | // Creates a #GDateTime corresponding to the given #GTimeVal @tv in the | |
| 109 | + | // local time zone. | |
| 110 | + | // | |
| 111 | + | // The time contained in a #GTimeVal is always stored in the form of | |
| 112 | + | // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the | |
| 113 | + | // local time offset. | |
| 114 | + | // | |
| 115 | + | // This call can fail (returning %NULL) if @tv represents a time outside | |
| 116 | + | // of the supported range of #GDateTime. | |
| 117 | + | // | |
| 118 | + | // You should release the return value by calling g_date_time_unref() | |
| 119 | + | // when you are done with it. | |
| 120 | + | func NewFromTimevalLocalDateTime(TvVar *TimeVal) *DateTime { | |
| 121 | + | ||
| 122 | + | cret := xNewFromTimevalLocalDateTime(TvVar) | |
| 123 | + | return cret | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | var xNewFromTimevalUtcDateTime func(*TimeVal) *DateTime | |
| 127 | + | ||
| 128 | + | // Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC. | |
| 129 | + | // | |
| 130 | + | // The time contained in a #GTimeVal is always stored in the form of | |
| 131 | + | // seconds elapsed since 1970-01-01 00:00:00 UTC. | |
| 132 | + | // | |
| 133 | + | // This call can fail (returning %NULL) if @tv represents a time outside | |
| 134 | + | // of the supported range of #GDateTime. | |
| 135 | + | // | |
| 136 | + | // You should release the return value by calling g_date_time_unref() | |
| 137 | + | // when you are done with it. | |
| 138 | + | func NewFromTimevalUtcDateTime(TvVar *TimeVal) *DateTime { | |
| 139 | + | ||
| 140 | + | cret := xNewFromTimevalUtcDateTime(TvVar) | |
| 141 | + | return cret | |
| 142 | + | } | |
| 143 | + | ||
| 144 | + | var xNewFromUnixLocalDateTime func(int64) *DateTime | |
| 145 | + | ||
| 146 | + | // Creates a #GDateTime corresponding to the given Unix time @t in the | |
| 147 | + | // local time zone. | |
| 148 | + | // | |
| 149 | + | // Unix time is the number of seconds that have elapsed since 1970-01-01 | |
| 150 | + | // 00:00:00 UTC, regardless of the local time offset. | |
| 151 | + | // | |
| 152 | + | // This call can fail (returning %NULL) if @t represents a time outside | |
| 153 | + | // of the supported range of #GDateTime. | |
| 154 | + | // | |
| 155 | + | // You should release the return value by calling g_date_time_unref() | |
| 156 | + | // when you are done with it. | |
| 157 | + | func NewFromUnixLocalDateTime(TVar int64) *DateTime { | |
| 158 | + | ||
| 159 | + | cret := xNewFromUnixLocalDateTime(TVar) | |
| 160 | + | return cret | |
| 161 | + | } | |
| 162 | + | ||
| 163 | + | var xNewFromUnixUtcDateTime func(int64) *DateTime | |
| 164 | + | ||
| 165 | + | // Creates a #GDateTime corresponding to the given Unix time @t in UTC. | |
| 166 | + | // | |
| 167 | + | // Unix time is the number of seconds that have elapsed since 1970-01-01 | |
| 168 | + | // 00:00:00 UTC. | |
| 169 | + | // | |
| 170 | + | // This call can fail (returning %NULL) if @t represents a time outside | |
| 171 | + | // of the supported range of #GDateTime. | |
| 172 | + | // | |
| 173 | + | // You should release the return value by calling g_date_time_unref() | |
| 174 | + | // when you are done with it. | |
| 175 | + | func NewFromUnixUtcDateTime(TVar int64) *DateTime { | |
| 176 | + | ||
| 177 | + | cret := xNewFromUnixUtcDateTime(TVar) | |
| 178 | + | return cret | |
| 179 | + | } | |
| 180 | + | ||
| 181 | + | var xNewLocalDateTime func(int, int, int, int, int, float64) *DateTime | |
| 182 | + | ||
| 183 | + | // Creates a new #GDateTime corresponding to the given date and time in | |
| 184 | + | // the local time zone. | |
| 185 | + | // | |
| 186 | + | // This call is equivalent to calling g_date_time_new() with the time | |
| 187 | + | // zone returned by g_time_zone_new_local(). | |
| 188 | + | func NewLocalDateTime(YearVar int, MonthVar int, DayVar int, HourVar int, MinuteVar int, SecondsVar float64) *DateTime { | |
| 189 | + | ||
| 190 | + | cret := xNewLocalDateTime(YearVar, MonthVar, DayVar, HourVar, MinuteVar, SecondsVar) | |
| 191 | + | return cret | |
| 192 | + | } | |
| 193 | + | ||
| 194 | + | var xNewNowDateTime func(*TimeZone) *DateTime | |
| 195 | + | ||
| 196 | + | // Creates a #GDateTime corresponding to this exact instant in the given | |
| 197 | + | // time zone @tz. The time is as accurate as the system allows, to a | |
| 198 | + | // maximum accuracy of 1 microsecond. | |
| 199 | + | // | |
| 200 | + | // This function will always succeed unless GLib is still being used after the | |
| 201 | + | // year 9999. | |
| 202 | + | // | |
| 203 | + | // You should release the return value by calling g_date_time_unref() | |
| 204 | + | // when you are done with it. | |
| 205 | + | func NewNowDateTime(TzVar *TimeZone) *DateTime { | |
| 206 | + | ||
| 207 | + | cret := xNewNowDateTime(TzVar) | |
| 208 | + | return cret | |
| 209 | + | } | |
| 210 | + | ||
| 211 | + | var xNewNowLocalDateTime func() *DateTime | |
| 212 | + | ||
| 213 | + | // Creates a #GDateTime corresponding to this exact instant in the local | |
| 214 | + | // time zone. | |
| 215 | + | // | |
| 216 | + | // This is equivalent to calling g_date_time_new_now() with the time | |
| 217 | + | // zone returned by g_time_zone_new_local(). | |
| 218 | + | func NewNowLocalDateTime() *DateTime { | |
| 219 | + | ||
| 220 | + | cret := xNewNowLocalDateTime() | |
| 221 | + | return cret | |
| 222 | + | } | |
| 223 | + | ||
| 224 | + | var xNewNowUtcDateTime func() *DateTime | |
| 225 | + | ||
| 226 | + | // Creates a #GDateTime corresponding to this exact instant in UTC. | |
| 227 | + | // | |
| 228 | + | // This is equivalent to calling g_date_time_new_now() with the time | |
| 229 | + | // zone returned by g_time_zone_new_utc(). | |
| 230 | + | func NewNowUtcDateTime() *DateTime { | |
| 231 | + | ||
| 232 | + | cret := xNewNowUtcDateTime() | |
| 233 | + | return cret | |
| 234 | + | } | |
| 235 | + | ||
| 236 | + | var xNewUtcDateTime func(int, int, int, int, int, float64) *DateTime | |
| 237 | + | ||
| 238 | + | // Creates a new #GDateTime corresponding to the given date and time in | |
| 239 | + | // UTC. | |
| 240 | + | // | |
| 241 | + | // This call is equivalent to calling g_date_time_new() with the time | |
| 242 | + | // zone returned by g_time_zone_new_utc(). | |
| 243 | + | func NewUtcDateTime(YearVar int, MonthVar int, DayVar int, HourVar int, MinuteVar int, SecondsVar float64) *DateTime { | |
| 244 | + | ||
| 245 | + | cret := xNewUtcDateTime(YearVar, MonthVar, DayVar, HourVar, MinuteVar, SecondsVar) | |
| 246 | + | return cret | |
| 247 | + | } | |
| 248 | + | ||
| 249 | + | var xDateTimeAdd func(uintptr, TimeSpan) *DateTime | |
| 250 | + | ||
| 251 | + | // Creates a copy of @datetime and adds the specified timespan to the copy. | |
| 252 | + | func (x *DateTime) Add(TimespanVar TimeSpan) *DateTime { | |
| 253 | + | ||
| 254 | + | cret := xDateTimeAdd(x.GoPointer(), TimespanVar) | |
| 255 | + | return cret | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | var xDateTimeAddDays func(uintptr, int) *DateTime | |
| 259 | + | ||
| 260 | + | // Creates a copy of @datetime and adds the specified number of days to the | |
| 261 | + | // copy. Add negative values to subtract days. | |
| 262 | + | func (x *DateTime) AddDays(DaysVar int) *DateTime { | |
| 263 | + | ||
| 264 | + | cret := xDateTimeAddDays(x.GoPointer(), DaysVar) | |
| 265 | + | return cret | |
| 266 | + | } | |
| 267 | + | ||
| 268 | + | var xDateTimeAddFull func(uintptr, int, int, int, int, int, float64) *DateTime | |
| 269 | + | ||
| 270 | + | // Creates a new #GDateTime adding the specified values to the current date and | |
| 271 | + | // time in @datetime. Add negative values to subtract. | |
| 272 | + | func (x *DateTime) AddFull(YearsVar int, MonthsVar int, DaysVar int, HoursVar int, MinutesVar int, SecondsVar float64) *DateTime { | |
| 273 | + | ||
| 274 | + | cret := xDateTimeAddFull(x.GoPointer(), YearsVar, MonthsVar, DaysVar, HoursVar, MinutesVar, SecondsVar) | |
| 275 | + | return cret | |
| 276 | + | } | |
| 277 | + | ||
| 278 | + | var xDateTimeAddHours func(uintptr, int) *DateTime | |
| 279 | + | ||
| 280 | + | // Creates a copy of @datetime and adds the specified number of hours. | |
| 281 | + | // Add negative values to subtract hours. | |
| 282 | + | func (x *DateTime) AddHours(HoursVar int) *DateTime { | |
| 283 | + | ||
| 284 | + | cret := xDateTimeAddHours(x.GoPointer(), HoursVar) | |
| 285 | + | return cret | |
| 286 | + | } | |
| 287 | + | ||
| 288 | + | var xDateTimeAddMinutes func(uintptr, int) *DateTime | |
| 289 | + | ||
| 290 | + | // Creates a copy of @datetime adding the specified number of minutes. | |
| 291 | + | // Add negative values to subtract minutes. | |
| 292 | + | func (x *DateTime) AddMinutes(MinutesVar int) *DateTime { | |
| 293 | + | ||
| 294 | + | cret := xDateTimeAddMinutes(x.GoPointer(), MinutesVar) | |
| 295 | + | return cret | |
| 296 | + | } | |
| 297 | + | ||
| 298 | + | var xDateTimeAddMonths func(uintptr, int) *DateTime | |
| 299 | + | ||
| 300 | + | // Creates a copy of @datetime and adds the specified number of months to the | |
| 301 | + | // copy. Add negative values to subtract months. | |
| 302 | + | // | |
| 303 | + | // The day of the month of the resulting #GDateTime is clamped to the number | |
| 304 | + | // of days in the updated calendar month. For example, if adding 1 month to | |
| 305 | + | // 31st January 2018, the result would be 28th February 2018. In 2020 (a leap | |
| 306 | + | // year), the result would be 29th February. | |
| 307 | + | func (x *DateTime) AddMonths(MonthsVar int) *DateTime { | |
| 308 | + | ||
| 309 | + | cret := xDateTimeAddMonths(x.GoPointer(), MonthsVar) | |
| 310 | + | return cret | |
| 311 | + | } | |
| 312 | + | ||
| 313 | + | var xDateTimeAddSeconds func(uintptr, float64) *DateTime | |
| 314 | + | ||
| 315 | + | // Creates a copy of @datetime and adds the specified number of seconds. | |
| 316 | + | // Add negative values to subtract seconds. | |
| 317 | + | func (x *DateTime) AddSeconds(SecondsVar float64) *DateTime { | |
| 318 | + | ||
| 319 | + | cret := xDateTimeAddSeconds(x.GoPointer(), SecondsVar) | |
| 320 | + | return cret | |
| 321 | + | } | |
| 322 | + | ||
| 323 | + | var xDateTimeAddWeeks func(uintptr, int) *DateTime | |
| 324 | + | ||
| 325 | + | // Creates a copy of @datetime and adds the specified number of weeks to the | |
| 326 | + | // copy. Add negative values to subtract weeks. | |
| 327 | + | func (x *DateTime) AddWeeks(WeeksVar int) *DateTime { | |
| 328 | + | ||
| 329 | + | cret := xDateTimeAddWeeks(x.GoPointer(), WeeksVar) | |
| 330 | + | return cret | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | var xDateTimeAddYears func(uintptr, int) *DateTime | |
| 334 | + | ||
| 335 | + | // Creates a copy of @datetime and adds the specified number of years to the | |
| 336 | + | // copy. Add negative values to subtract years. | |
| 337 | + | // | |
| 338 | + | // As with g_date_time_add_months(), if the resulting date would be 29th | |
| 339 | + | // February on a non-leap year, the day will be clamped to 28th February. | |
| 340 | + | func (x *DateTime) AddYears(YearsVar int) *DateTime { | |
| 341 | + | ||
| 342 | + | cret := xDateTimeAddYears(x.GoPointer(), YearsVar) | |
| 343 | + | return cret | |
| 344 | + | } | |
| 345 | + | ||
| 346 | + | var xDateTimeCompare func(uintptr, uintptr) int | |
| 347 | + | ||
| 348 | + | // A comparison function for #GDateTimes that is suitable | |
| 349 | + | // as a #GCompareFunc. Both #GDateTimes must be non-%NULL. | |
| 350 | + | func (x *DateTime) Compare(Dt2Var uintptr) int { | |
| 351 | + | ||
| 352 | + | cret := xDateTimeCompare(x.GoPointer(), Dt2Var) | |
| 353 | + | return cret | |
| 354 | + | } | |
| 355 | + | ||
| 356 | + | var xDateTimeDifference func(uintptr, *DateTime) TimeSpan | |
| 357 | + | ||
| 358 | + | // Calculates the difference in time between @end and @begin. The | |
| 359 | + | // #GTimeSpan that is returned is effectively @end - @begin (ie: | |
| 360 | + | // positive if the first parameter is larger). | |
| 361 | + | func (x *DateTime) Difference(BeginVar *DateTime) TimeSpan { | |
| 362 | + | ||
| 363 | + | cret := xDateTimeDifference(x.GoPointer(), BeginVar) | |
| 364 | + | return cret | |
| 365 | + | } | |
| 366 | + | ||
| 367 | + | var xDateTimeEqual func(uintptr, uintptr) bool | |
| 368 | + | ||
| 369 | + | // Checks to see if @dt1 and @dt2 are equal. | |
| 370 | + | // | |
| 371 | + | // Equal here means that they represent the same moment after converting | |
| 372 | + | // them to the same time zone. | |
| 373 | + | func (x *DateTime) Equal(Dt2Var uintptr) bool { | |
| 374 | + | ||
| 375 | + | cret := xDateTimeEqual(x.GoPointer(), Dt2Var) | |
| 376 | + | return cret | |
| 377 | + | } | |
| 378 | + | ||
| 379 | + | var xDateTimeFormat func(uintptr, string) string | |
| 380 | + | ||
| 381 | + | // Creates a newly allocated string representing the requested @format. | |
| 382 | + | // | |
| 383 | + | // The format strings understood by this function are a subset of the | |
| 384 | + | // strftime() format language as specified by C99. The \%D, \%U and \%W | |
| 385 | + | // conversions are not supported, nor is the 'E' modifier. The GNU | |
| 386 | + | // extensions \%k, \%l, \%s and \%P are supported, however, as are the | |
| 387 | + | // '0', '_' and '-' modifiers. The Python extension \%f is also supported. | |
| 388 | + | // | |
| 389 | + | // In contrast to strftime(), this function always produces a UTF-8 | |
| 390 | + | // string, regardless of the current locale. Note that the rendering of | |
| 391 | + | // many formats is locale-dependent and may not match the strftime() | |
| 392 | + | // output exactly. | |
| 393 | + | // | |
| 394 | + | // The following format specifiers are supported: | |
| 395 | + | // | |
| 396 | + | // - \%a: the abbreviated weekday name according to the current locale | |
| 397 | + | // - \%A: the full weekday name according to the current locale | |
| 398 | + | // - \%b: the abbreviated month name according to the current locale | |
| 399 | + | // - \%B: the full month name according to the current locale | |
| 400 | + | // - \%c: the preferred date and time representation for the current locale | |
| 401 | + | // - \%C: the century number (year/100) as a 2-digit integer (00-99) | |
| 402 | + | // - \%d: the day of the month as a decimal number (range 01 to 31) | |
| 403 | + | // - \%e: the day of the month as a decimal number (range 1 to 31) | |
| 404 | + | // - \%F: equivalent to `%Y-%m-%d` (the ISO 8601 date format) | |
| 405 | + | // - \%g: the last two digits of the ISO 8601 week-based year as a | |
| 406 | + | // decimal number (00-99). This works well with \%V and \%u. | |
| 407 | + | // - \%G: the ISO 8601 week-based year as a decimal number. This works | |
| 408 | + | // well with \%V and \%u. | |
| 409 | + | // - \%h: equivalent to \%b | |
| 410 | + | // - \%H: the hour as a decimal number using a 24-hour clock (range 00 to 23) | |
| 411 | + | // - \%I: the hour as a decimal number using a 12-hour clock (range 01 to 12) | |
| 412 | + | // - \%j: the day of the year as a decimal number (range 001 to 366) | |
| 413 | + | // - \%k: the hour (24-hour clock) as a decimal number (range 0 to 23); | |
| 414 | + | // single digits are preceded by a blank | |
| 415 | + | // - \%l: the hour (12-hour clock) as a decimal number (range 1 to 12); | |
| 416 | + | // single digits are preceded by a blank | |
| 417 | + | // - \%m: the month as a decimal number (range 01 to 12) | |
| 418 | + | // - \%M: the minute as a decimal number (range 00 to 59) | |
| 419 | + | // - \%f: the microsecond as a decimal number (range 000000 to 999999) | |
| 420 | + | // - \%p: either "AM" or "PM" according to the given time value, or the | |
| 421 | + | // corresponding strings for the current locale. Noon is treated as | |
| 422 | + | // "PM" and midnight as "AM". Use of this format specifier is discouraged, as | |
| 423 | + | // many locales have no concept of AM/PM formatting. Use \%c or \%X instead. | |
| 424 | + | // - \%P: like \%p but lowercase: "am" or "pm" or a corresponding string for | |
| 425 | + | // the current locale. Use of this format specifier is discouraged, as | |
| 426 | + | // many locales have no concept of AM/PM formatting. Use \%c or \%X instead. | |
| 427 | + | // - \%r: the time in a.m. or p.m. notation. Use of this format specifier is | |
| 428 | + | // discouraged, as many locales have no concept of AM/PM formatting. Use \%c | |
| 429 | + | // or \%X instead. | |
| 430 | + | // - \%R: the time in 24-hour notation (\%H:\%M) | |
| 431 | + | // - \%s: the number of seconds since the Epoch, that is, since 1970-01-01 | |
| 432 | + | // 00:00:00 UTC | |
| 433 | + | // - \%S: the second as a decimal number (range 00 to 60) | |
| 434 | + | // - \%t: a tab character | |
| 435 | + | // - \%T: the time in 24-hour notation with seconds (\%H:\%M:\%S) | |
| 436 | + | // - \%u: the ISO 8601 standard day of the week as a decimal, range 1 to 7, | |
| 437 | + | // Monday being 1. This works well with \%G and \%V. | |
| 438 | + | // - \%V: the ISO 8601 standard week number of the current year as a decimal | |
| 439 | + | // number, range 01 to 53, where week 1 is the first week that has at | |
| 440 | + | // least 4 days in the new year. See g_date_time_get_week_of_year(). | |
| 441 | + | // This works well with \%G and \%u. | |
| 442 | + | // - \%w: the day of the week as a decimal, range 0 to 6, Sunday being 0. | |
| 443 | + | // This is not the ISO 8601 standard format -- use \%u instead. | |
| 444 | + | // - \%x: the preferred date representation for the current locale without | |
| 445 | + | // the time | |
| 446 | + | // - \%X: the preferred time representation for the current locale without | |
| 447 | + | // the date | |
| 448 | + | // - \%y: the year as a decimal number without the century | |
| 449 | + | // - \%Y: the year as a decimal number including the century | |
| 450 | + | // - \%z: the time zone as an offset from UTC (+hhmm) | |
| 451 | + | // - \%:z: the time zone as an offset from UTC (+hh:mm). | |
| 452 | + | // This is a gnulib strftime() extension. Since: 2.38 | |
| 453 | + | // - \%::z: the time zone as an offset from UTC (+hh:mm:ss). This is a | |
| 454 | + | // gnulib strftime() extension. Since: 2.38 | |
| 455 | + | // - \%:::z: the time zone as an offset from UTC, with : to necessary | |
| 456 | + | // precision (e.g., -04, +05:30). This is a gnulib strftime() extension. Since: 2.38 | |
| 457 | + | // - \%Z: the time zone or name or abbreviation | |
| 458 | + | // - \%\%: a literal \% character | |
| 459 | + | // | |
| 460 | + | // Some conversion specifications can be modified by preceding the | |
| 461 | + | // conversion specifier by one or more modifier characters. The | |
| 462 | + | // following modifiers are supported for many of the numeric | |
| 463 | + | // conversions: | |
| 464 | + | // | |
| 465 | + | // - O: Use alternative numeric symbols, if the current locale supports those. | |
| 466 | + | // - _: Pad a numeric result with spaces. This overrides the default padding | |
| 467 | + | // for the specifier. | |
| 468 | + | // - -: Do not pad a numeric result. This overrides the default padding | |
| 469 | + | // for the specifier. | |
| 470 | + | // - 0: Pad a numeric result with zeros. This overrides the default padding | |
| 471 | + | // for the specifier. | |
| 472 | + | // | |
| 473 | + | // Additionally, when O is used with B, b, or h, it produces the alternative | |
| 474 | + | // form of a month name. The alternative form should be used when the month | |
| 475 | + | // name is used without a day number (e.g., standalone). It is required in | |
| 476 | + | // some languages (Baltic, Slavic, Greek, and more) due to their grammatical | |
| 477 | + | // rules. For other languages there is no difference. \%OB is a GNU and BSD | |
| 478 | + | // strftime() extension expected to be added to the future POSIX specification, | |
| 479 | + | // \%Ob and \%Oh are GNU strftime() extensions. Since: 2.56 | |
| 480 | + | func (x *DateTime) Format(FormatVar string) string { | |
| 481 | + | ||
| 482 | + | cret := xDateTimeFormat(x.GoPointer(), FormatVar) | |
| 483 | + | return cret | |
| 484 | + | } | |
| 485 | + | ||
| 486 | + | var xDateTimeFormatIso8601 func(uintptr) string | |
| 487 | + | ||
| 488 | + | // Format @datetime in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601), | |
| 489 | + | // including the date, time and time zone, and return that as a UTF-8 encoded | |
| 490 | + | // string. | |
| 491 | + | // | |
| 492 | + | // Since GLib 2.66, this will output to sub-second precision if needed. | |
| 493 | + | func (x *DateTime) FormatIso8601() string { | |
| 494 | + | ||
| 495 | + | cret := xDateTimeFormatIso8601(x.GoPointer()) | |
| 496 | + | return cret | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | var xDateTimeGetDayOfMonth func(uintptr) int | |
| 500 | + | ||
| 501 | + | // Retrieves the day of the month represented by @datetime in the gregorian | |
| 502 | + | // calendar. | |
| 503 | + | func (x *DateTime) GetDayOfMonth() int { | |
| 504 | + | ||
| 505 | + | cret := xDateTimeGetDayOfMonth(x.GoPointer()) | |
| 506 | + | return cret | |
| 507 | + | } | |
| 508 | + | ||
| 509 | + | var xDateTimeGetDayOfWeek func(uintptr) int | |
| 510 | + | ||
| 511 | + | // Retrieves the ISO 8601 day of the week on which @datetime falls (1 is | |
| 512 | + | // Monday, 2 is Tuesday... 7 is Sunday). | |
| 513 | + | func (x *DateTime) GetDayOfWeek() int { | |
| 514 | + | ||
| 515 | + | cret := xDateTimeGetDayOfWeek(x.GoPointer()) | |
| 516 | + | return cret | |
| 517 | + | } | |
| 518 | + | ||
| 519 | + | var xDateTimeGetDayOfYear func(uintptr) int | |
| 520 | + | ||
| 521 | + | // Retrieves the day of the year represented by @datetime in the Gregorian | |
| 522 | + | // calendar. | |
| 523 | + | func (x *DateTime) GetDayOfYear() int { | |
| 524 | + | ||
| 525 | + | cret := xDateTimeGetDayOfYear(x.GoPointer()) | |
| 526 | + | return cret | |
| 527 | + | } | |
| 528 | + | ||
| 529 | + | var xDateTimeGetHour func(uintptr) int | |
| 530 | + | ||
| 531 | + | // Retrieves the hour of the day represented by @datetime | |
| 532 | + | func (x *DateTime) GetHour() int { | |
| 533 | + | ||
| 534 | + | cret := xDateTimeGetHour(x.GoPointer()) | |
| 535 | + | return cret | |
| 536 | + | } | |
| 537 | + | ||
| 538 | + | var xDateTimeGetMicrosecond func(uintptr) int | |
| 539 | + | ||
| 540 | + | // Retrieves the microsecond of the date represented by @datetime | |
| 541 | + | func (x *DateTime) GetMicrosecond() int { | |
| 542 | + | ||
| 543 | + | cret := xDateTimeGetMicrosecond(x.GoPointer()) | |
| 544 | + | return cret | |
| 545 | + | } | |
| 546 | + | ||
| 547 | + | var xDateTimeGetMinute func(uintptr) int | |
| 548 | + | ||
| 549 | + | // Retrieves the minute of the hour represented by @datetime | |
| 550 | + | func (x *DateTime) GetMinute() int { | |
| 551 | + | ||
| 552 | + | cret := xDateTimeGetMinute(x.GoPointer()) | |
| 553 | + | return cret | |
| 554 | + | } | |
| 555 | + | ||
| 556 | + | var xDateTimeGetMonth func(uintptr) int | |
| 557 | + | ||
| 558 | + | // Retrieves the month of the year represented by @datetime in the Gregorian | |
| 559 | + | // calendar. | |
| 560 | + | func (x *DateTime) GetMonth() int { | |
| 561 | + | ||
| 562 | + | cret := xDateTimeGetMonth(x.GoPointer()) | |
| 563 | + | return cret | |
| 564 | + | } | |
| 565 | + | ||
| 566 | + | var xDateTimeGetSecond func(uintptr) int | |
| 567 | + | ||
| 568 | + | // Retrieves the second of the minute represented by @datetime | |
| 569 | + | func (x *DateTime) GetSecond() int { | |
| 570 | + | ||
| 571 | + | cret := xDateTimeGetSecond(x.GoPointer()) | |
| 572 | + | return cret | |
| 573 | + | } | |
| 574 | + | ||
| 575 | + | var xDateTimeGetSeconds func(uintptr) float64 | |
| 576 | + | ||
| 577 | + | // Retrieves the number of seconds since the start of the last minute, | |
| 578 | + | // including the fractional part. | |
| 579 | + | func (x *DateTime) GetSeconds() float64 { | |
| 580 | + | ||
| 581 | + | cret := xDateTimeGetSeconds(x.GoPointer()) | |
| 582 | + | return cret | |
| 583 | + | } | |
| 584 | + | ||
| 585 | + | var xDateTimeGetTimezone func(uintptr) *TimeZone | |
| 586 | + | ||
| 587 | + | // Get the time zone for this @datetime. | |
| 588 | + | func (x *DateTime) GetTimezone() *TimeZone { | |
| 589 | + | ||
| 590 | + | cret := xDateTimeGetTimezone(x.GoPointer()) | |
| 591 | + | return cret | |
| 592 | + | } | |
| 593 | + | ||
| 594 | + | var xDateTimeGetTimezoneAbbreviation func(uintptr) string | |
| 595 | + | ||
| 596 | + | // Determines the time zone abbreviation to be used at the time and in | |
| 597 | + | // the time zone of @datetime. | |
| 598 | + | // | |
| 599 | + | // For example, in Toronto this is currently "EST" during the winter | |
| 600 | + | // months and "EDT" during the summer months when daylight savings | |
| 601 | + | // time is in effect. | |
| 602 | + | func (x *DateTime) GetTimezoneAbbreviation() string { | |
| 603 | + | ||
| 604 | + | cret := xDateTimeGetTimezoneAbbreviation(x.GoPointer()) | |
| 605 | + | return cret | |
| 606 | + | } | |
| 607 | + | ||
| 608 | + | var xDateTimeGetUtcOffset func(uintptr) TimeSpan | |
| 609 | + | ||
| 610 | + | // Determines the offset to UTC in effect at the time and in the time | |
| 611 | + | // zone of @datetime. | |
| 612 | + | // | |
| 613 | + | // The offset is the number of microseconds that you add to UTC time to | |
| 614 | + | // arrive at local time for the time zone (ie: negative numbers for time | |
| 615 | + | // zones west of GMT, positive numbers for east). | |
| 616 | + | // | |
| 617 | + | // If @datetime represents UTC time, then the offset is always zero. | |
| 618 | + | func (x *DateTime) GetUtcOffset() TimeSpan { | |
| 619 | + | ||
| 620 | + | cret := xDateTimeGetUtcOffset(x.GoPointer()) | |
| 621 | + | return cret | |
| 622 | + | } | |
| 623 | + | ||
| 624 | + | var xDateTimeGetWeekNumberingYear func(uintptr) int | |
| 625 | + | ||
| 626 | + | // Returns the ISO 8601 week-numbering year in which the week containing | |
| 627 | + | // @datetime falls. | |
| 628 | + | // | |
| 629 | + | // This function, taken together with g_date_time_get_week_of_year() and | |
| 630 | + | // g_date_time_get_day_of_week() can be used to determine the full ISO | |
| 631 | + | // week date on which @datetime falls. | |
| 632 | + | // | |
| 633 | + | // This is usually equal to the normal Gregorian year (as returned by | |
| 634 | + | // g_date_time_get_year()), except as detailed below: | |
| 635 | + | // | |
| 636 | + | // For Thursday, the week-numbering year is always equal to the usual | |
| 637 | + | // calendar year. For other days, the number is such that every day | |
| 638 | + | // within a complete week (Monday to Sunday) is contained within the | |
| 639 | + | // same week-numbering year. | |
| 640 | + | // | |
| 641 | + | // For Monday, Tuesday and Wednesday occurring near the end of the year, | |
| 642 | + | // this may mean that the week-numbering year is one greater than the | |
| 643 | + | // calendar year (so that these days have the same week-numbering year | |
| 644 | + | // as the Thursday occurring early in the next year). | |
| 645 | + | // | |
| 646 | + | // For Friday, Saturday and Sunday occurring near the start of the year, | |
| 647 | + | // this may mean that the week-numbering year is one less than the | |
| 648 | + | // calendar year (so that these days have the same week-numbering year | |
| 649 | + | // as the Thursday occurring late in the previous year). | |
| 650 | + | // | |
| 651 | + | // An equivalent description is that the week-numbering year is equal to | |
| 652 | + | // the calendar year containing the majority of the days in the current | |
| 653 | + | // week (Monday to Sunday). | |
| 654 | + | // | |
| 655 | + | // Note that January 1 0001 in the proleptic Gregorian calendar is a | |
| 656 | + | // Monday, so this function never returns 0. | |
| 657 | + | func (x *DateTime) GetWeekNumberingYear() int { | |
| 658 | + | ||
| 659 | + | cret := xDateTimeGetWeekNumberingYear(x.GoPointer()) | |
| 660 | + | return cret | |
| 661 | + | } | |
| 662 | + | ||
| 663 | + | var xDateTimeGetWeekOfYear func(uintptr) int | |
| 664 | + | ||
| 665 | + | // Returns the ISO 8601 week number for the week containing @datetime. | |
| 666 | + | // The ISO 8601 week number is the same for every day of the week (from | |
| 667 | + | // Moday through Sunday). That can produce some unusual results | |
| 668 | + | // (described below). | |
| 669 | + | // | |
| 670 | + | // The first week of the year is week 1. This is the week that contains | |
| 671 | + | // the first Thursday of the year. Equivalently, this is the first week | |
| 672 | + | // that has more than 4 of its days falling within the calendar year. | |
| 673 | + | // | |
| 674 | + | // The value 0 is never returned by this function. Days contained | |
| 675 | + | // within a year but occurring before the first ISO 8601 week of that | |
| 676 | + | // year are considered as being contained in the last week of the | |
| 677 | + | // previous year. Similarly, the final days of a calendar year may be | |
| 678 | + | // considered as being part of the first ISO 8601 week of the next year | |
| 679 | + | // if 4 or more days of that week are contained within the new year. | |
| 680 | + | func (x *DateTime) GetWeekOfYear() int { | |
| 681 | + | ||
| 682 | + | cret := xDateTimeGetWeekOfYear(x.GoPointer()) | |
| 683 | + | return cret | |
| 684 | + | } | |
| 685 | + | ||
| 686 | + | var xDateTimeGetYear func(uintptr) int | |
| 687 | + | ||
| 688 | + | // Retrieves the year represented by @datetime in the Gregorian calendar. | |
| 689 | + | func (x *DateTime) GetYear() int { | |
| 690 | + | ||
| 691 | + | cret := xDateTimeGetYear(x.GoPointer()) | |
| 692 | + | return cret | |
| 693 | + | } | |
| 694 | + | ||
| 695 | + | var xDateTimeGetYmd func(uintptr, int, int, int) | |
| 696 | + | ||
| 697 | + | // Retrieves the Gregorian day, month, and year of a given #GDateTime. | |
| 698 | + | func (x *DateTime) GetYmd(YearVar int, MonthVar int, DayVar int) { | |
| 699 | + | ||
| 700 | + | xDateTimeGetYmd(x.GoPointer(), YearVar, MonthVar, DayVar) | |
| 701 | + | ||
| 702 | + | } | |
| 703 | + | ||
| 704 | + | var xDateTimeHash func(uintptr) uint | |
| 705 | + | ||
| 706 | + | // Hashes @datetime into a #guint, suitable for use within #GHashTable. | |
| 707 | + | func (x *DateTime) Hash() uint { | |
| 708 | + | ||
| 709 | + | cret := xDateTimeHash(x.GoPointer()) | |
| 710 | + | return cret | |
| 711 | + | } | |
| 712 | + | ||
| 713 | + | var xDateTimeIsDaylightSavings func(uintptr) bool | |
| 714 | + | ||
| 715 | + | // Determines if daylight savings time is in effect at the time and in | |
| 716 | + | // the time zone of @datetime. | |
| 717 | + | func (x *DateTime) IsDaylightSavings() bool { | |
| 718 | + | ||
| 719 | + | cret := xDateTimeIsDaylightSavings(x.GoPointer()) | |
| 720 | + | return cret | |
| 721 | + | } | |
| 722 | + | ||
| 723 | + | var xDateTimeRef func(uintptr) *DateTime | |
| 724 | + | ||
| 725 | + | // Atomically increments the reference count of @datetime by one. | |
| 726 | + | func (x *DateTime) Ref() *DateTime { | |
| 727 | + | ||
| 728 | + | cret := xDateTimeRef(x.GoPointer()) | |
| 729 | + | return cret | |
| 730 | + | } | |
| 731 | + | ||
| 732 | + | var xDateTimeToLocal func(uintptr) *DateTime | |
| 733 | + | ||
| 734 | + | // Creates a new #GDateTime corresponding to the same instant in time as | |
| 735 | + | // @datetime, but in the local time zone. | |
| 736 | + | // | |
| 737 | + | // This call is equivalent to calling g_date_time_to_timezone() with the | |
| 738 | + | // time zone returned by g_time_zone_new_local(). | |
| 739 | + | func (x *DateTime) ToLocal() *DateTime { | |
| 740 | + | ||
| 741 | + | cret := xDateTimeToLocal(x.GoPointer()) | |
| 742 | + | return cret | |
| 743 | + | } | |
| 744 | + | ||
| 745 | + | var xDateTimeToTimeval func(uintptr, *TimeVal) bool | |
| 746 | + | ||
| 747 | + | // Stores the instant in time that @datetime represents into @tv. | |
| 748 | + | // | |
| 749 | + | // The time contained in a #GTimeVal is always stored in the form of | |
| 750 | + | // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time | |
| 751 | + | // zone associated with @datetime. | |
| 752 | + | // | |
| 753 | + | // On systems where 'long' is 32bit (ie: all 32bit systems and all | |
| 754 | + | // Windows systems), a #GTimeVal is incapable of storing the entire | |
| 755 | + | // range of values that #GDateTime is capable of expressing. On those | |
| 756 | + | // systems, this function returns %FALSE to indicate that the time is | |
| 757 | + | // out of range. | |
| 758 | + | // | |
| 759 | + | // On systems where 'long' is 64bit, this function never fails. | |
| 760 | + | func (x *DateTime) ToTimeval(TvVar *TimeVal) bool { | |
| 761 | + | ||
| 762 | + | cret := xDateTimeToTimeval(x.GoPointer(), TvVar) | |
| 763 | + | return cret | |
| 764 | + | } | |
| 765 | + | ||
| 766 | + | var xDateTimeToTimezone func(uintptr, *TimeZone) *DateTime | |
| 767 | + | ||
| 768 | + | // Create a new #GDateTime corresponding to the same instant in time as | |
| 769 | + | // @datetime, but in the time zone @tz. | |
| 770 | + | // | |
| 771 | + | // This call can fail in the case that the time goes out of bounds. For | |
| 772 | + | // example, converting 0001-01-01 00:00:00 UTC to a time zone west of | |
| 773 | + | // Greenwich will fail (due to the year 0 being out of range). | |
| 774 | + | func (x *DateTime) ToTimezone(TzVar *TimeZone) *DateTime { | |
| 775 | + | ||
| 776 | + | cret := xDateTimeToTimezone(x.GoPointer(), TzVar) | |
| 777 | + | return cret | |
| 778 | + | } | |
| 779 | + | ||
| 780 | + | var xDateTimeToUnix func(uintptr) int64 | |
| 781 | + | ||
| 782 | + | // Gives the Unix time corresponding to @datetime, rounding down to the | |
| 783 | + | // nearest second. | |
| 784 | + | // | |
| 785 | + | // Unix time is the number of seconds that have elapsed since 1970-01-01 | |
| 786 | + | // 00:00:00 UTC, regardless of the time zone associated with @datetime. | |
| 787 | + | func (x *DateTime) ToUnix() int64 { | |
| 788 | + | ||
| 789 | + | cret := xDateTimeToUnix(x.GoPointer()) | |
| 790 | + | return cret | |
| 791 | + | } | |
| 792 | + | ||
| 793 | + | var xDateTimeToUtc func(uintptr) *DateTime | |
| 794 | + | ||
| 795 | + | // Creates a new #GDateTime corresponding to the same instant in time as | |
| 796 | + | // @datetime, but in UTC. | |
| 797 | + | // | |
| 798 | + | // This call is equivalent to calling g_date_time_to_timezone() with the | |
| 799 | + | // time zone returned by g_time_zone_new_utc(). | |
| 800 | + | func (x *DateTime) ToUtc() *DateTime { | |
| 801 | + | ||
| 802 | + | cret := xDateTimeToUtc(x.GoPointer()) | |
| 803 | + | return cret | |
| 804 | + | } | |
| 805 | + | ||
| 806 | + | var xDateTimeUnref func(uintptr) | |
| 807 | + | ||
| 808 | + | // Atomically decrements the reference count of @datetime by one. | |
| 809 | + | // | |
| 810 | + | // When the reference count reaches zero, the resources allocated by | |
| 811 | + | // @datetime are freed | |
| 812 | + | func (x *DateTime) Unref() { | |
| 813 | + | ||
| 814 | + | xDateTimeUnref(x.GoPointer()) | |
| 815 | + | ||
| 816 | + | } | |
| 817 | + | ||
| 8 | 818 | // A value representing an interval of time, in microseconds. | |
| 9 | 819 | type TimeSpan = int64 | |
| 820 | + | ||
| 821 | + | const ( | |
| 822 | + | // Evaluates to a time span of one day. | |
| 823 | + | TIME_SPAN_DAY int64 = 86400000000 | |
| 824 | + | // Evaluates to a time span of one hour. | |
| 825 | + | TIME_SPAN_HOUR int64 = 3600000000 | |
| 826 | + | // Evaluates to a time span of one millisecond. | |
| 827 | + | TIME_SPAN_MILLISECOND int64 = 1000 | |
| 828 | + | // Evaluates to a time span of one minute. | |
| 829 | + | TIME_SPAN_MINUTE int64 = 60000000 | |
| 830 | + | // Evaluates to a time span of one second. | |
| 831 | + | TIME_SPAN_SECOND int64 = 1000000 | |
| 832 | + | ) | |
| 833 | + | ||
| 834 | + | func init() { | |
| 835 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 836 | + | if err != nil { | |
| 837 | + | panic(err) | |
| 838 | + | } | |
| 839 | + | ||
| 840 | + | core.PuregoSafeRegister(&xNewDateTime, lib, "g_date_time_new") | |
| 841 | + | core.PuregoSafeRegister(&xNewFromIso8601DateTime, lib, "g_date_time_new_from_iso8601") | |
| 842 | + | core.PuregoSafeRegister(&xNewFromTimevalLocalDateTime, lib, "g_date_time_new_from_timeval_local") | |
| 843 | + | core.PuregoSafeRegister(&xNewFromTimevalUtcDateTime, lib, "g_date_time_new_from_timeval_utc") | |
| 844 | + | core.PuregoSafeRegister(&xNewFromUnixLocalDateTime, lib, "g_date_time_new_from_unix_local") | |
| 845 | + | core.PuregoSafeRegister(&xNewFromUnixUtcDateTime, lib, "g_date_time_new_from_unix_utc") | |
| 846 | + | core.PuregoSafeRegister(&xNewLocalDateTime, lib, "g_date_time_new_local") | |
| 847 | + | core.PuregoSafeRegister(&xNewNowDateTime, lib, "g_date_time_new_now") | |
| 848 | + | core.PuregoSafeRegister(&xNewNowLocalDateTime, lib, "g_date_time_new_now_local") | |
| 849 | + | core.PuregoSafeRegister(&xNewNowUtcDateTime, lib, "g_date_time_new_now_utc") | |
| 850 | + | core.PuregoSafeRegister(&xNewUtcDateTime, lib, "g_date_time_new_utc") | |
| 851 | + | ||
| 852 | + | core.PuregoSafeRegister(&xDateTimeAdd, lib, "g_date_time_add") | |
| 853 | + | core.PuregoSafeRegister(&xDateTimeAddDays, lib, "g_date_time_add_days") | |
| 854 | + | core.PuregoSafeRegister(&xDateTimeAddFull, lib, "g_date_time_add_full") | |
| 855 | + | core.PuregoSafeRegister(&xDateTimeAddHours, lib, "g_date_time_add_hours") | |
| 856 | + | core.PuregoSafeRegister(&xDateTimeAddMinutes, lib, "g_date_time_add_minutes") | |
| 857 | + | core.PuregoSafeRegister(&xDateTimeAddMonths, lib, "g_date_time_add_months") | |
| 858 | + | core.PuregoSafeRegister(&xDateTimeAddSeconds, lib, "g_date_time_add_seconds") | |
| 859 | + | core.PuregoSafeRegister(&xDateTimeAddWeeks, lib, "g_date_time_add_weeks") | |
| 860 | + | core.PuregoSafeRegister(&xDateTimeAddYears, lib, "g_date_time_add_years") | |
| 861 | + | core.PuregoSafeRegister(&xDateTimeCompare, lib, "g_date_time_compare") | |
| 862 | + | core.PuregoSafeRegister(&xDateTimeDifference, lib, "g_date_time_difference") | |
| 863 | + | core.PuregoSafeRegister(&xDateTimeEqual, lib, "g_date_time_equal") | |
| 864 | + | core.PuregoSafeRegister(&xDateTimeFormat, lib, "g_date_time_format") | |
| 865 | + | core.PuregoSafeRegister(&xDateTimeFormatIso8601, lib, "g_date_time_format_iso8601") | |
| 866 | + | core.PuregoSafeRegister(&xDateTimeGetDayOfMonth, lib, "g_date_time_get_day_of_month") | |
| 867 | + | core.PuregoSafeRegister(&xDateTimeGetDayOfWeek, lib, "g_date_time_get_day_of_week") | |
| 868 | + | core.PuregoSafeRegister(&xDateTimeGetDayOfYear, lib, "g_date_time_get_day_of_year") | |
| 869 | + | core.PuregoSafeRegister(&xDateTimeGetHour, lib, "g_date_time_get_hour") | |
| 870 | + | core.PuregoSafeRegister(&xDateTimeGetMicrosecond, lib, "g_date_time_get_microsecond") | |
| 871 | + | core.PuregoSafeRegister(&xDateTimeGetMinute, lib, "g_date_time_get_minute") | |
| 872 | + | core.PuregoSafeRegister(&xDateTimeGetMonth, lib, "g_date_time_get_month") | |
| 873 | + | core.PuregoSafeRegister(&xDateTimeGetSecond, lib, "g_date_time_get_second") | |
| 874 | + | core.PuregoSafeRegister(&xDateTimeGetSeconds, lib, "g_date_time_get_seconds") | |
| 875 | + | core.PuregoSafeRegister(&xDateTimeGetTimezone, lib, "g_date_time_get_timezone") | |
| 876 | + | core.PuregoSafeRegister(&xDateTimeGetTimezoneAbbreviation, lib, "g_date_time_get_timezone_abbreviation") | |
| 877 | + | core.PuregoSafeRegister(&xDateTimeGetUtcOffset, lib, "g_date_time_get_utc_offset") | |
| 878 | + | core.PuregoSafeRegister(&xDateTimeGetWeekNumberingYear, lib, "g_date_time_get_week_numbering_year") | |
| 879 | + | core.PuregoSafeRegister(&xDateTimeGetWeekOfYear, lib, "g_date_time_get_week_of_year") | |
| 880 | + | core.PuregoSafeRegister(&xDateTimeGetYear, lib, "g_date_time_get_year") | |
| 881 | + | core.PuregoSafeRegister(&xDateTimeGetYmd, lib, "g_date_time_get_ymd") | |
| 882 | + | core.PuregoSafeRegister(&xDateTimeHash, lib, "g_date_time_hash") | |
| 883 | + | core.PuregoSafeRegister(&xDateTimeIsDaylightSavings, lib, "g_date_time_is_daylight_savings") | |
| 884 | + | core.PuregoSafeRegister(&xDateTimeRef, lib, "g_date_time_ref") | |
| 885 | + | core.PuregoSafeRegister(&xDateTimeToLocal, lib, "g_date_time_to_local") | |
| 886 | + | core.PuregoSafeRegister(&xDateTimeToTimeval, lib, "g_date_time_to_timeval") | |
| 887 | + | core.PuregoSafeRegister(&xDateTimeToTimezone, lib, "g_date_time_to_timezone") | |
| 888 | + | core.PuregoSafeRegister(&xDateTimeToUnix, lib, "g_date_time_to_unix") | |
| 889 | + | core.PuregoSafeRegister(&xDateTimeToUtc, lib, "g_date_time_to_utc") | |
| 890 | + | core.PuregoSafeRegister(&xDateTimeUnref, lib, "g_date_time_unref") | |
| 891 | + | ||
| 892 | + | } | |
M v4/glib/gdir.go +63 -0
| @@ -1,6 +1,69 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // An opaque structure representing an opened directory. | |
| 5 | 12 | type Dir struct { | |
| 6 | 13 | } | |
| 14 | + | ||
| 15 | + | func (x *Dir) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | var xDirClose func(uintptr) | |
| 20 | + | ||
| 21 | + | // Closes the directory and deallocates all related resources. | |
| 22 | + | func (x *Dir) Close() { | |
| 23 | + | ||
| 24 | + | xDirClose(x.GoPointer()) | |
| 25 | + | ||
| 26 | + | } | |
| 27 | + | ||
| 28 | + | var xDirReadName func(uintptr) string | |
| 29 | + | ||
| 30 | + | // Retrieves the name of another entry in the directory, or %NULL. | |
| 31 | + | // The order of entries returned from this function is not defined, | |
| 32 | + | // and may vary by file system or other operating-system dependent | |
| 33 | + | // factors. | |
| 34 | + | // | |
| 35 | + | // %NULL may also be returned in case of errors. On Unix, you can | |
| 36 | + | // check `errno` to find out if %NULL was returned because of an error. | |
| 37 | + | // | |
| 38 | + | // On Unix, the '.' and '..' entries are omitted, and the returned | |
| 39 | + | // name is in the on-disk encoding. | |
| 40 | + | // | |
| 41 | + | // On Windows, as is true of all GLib functions which operate on | |
| 42 | + | // filenames, the returned name is in UTF-8. | |
| 43 | + | func (x *Dir) ReadName() string { | |
| 44 | + | ||
| 45 | + | cret := xDirReadName(x.GoPointer()) | |
| 46 | + | return cret | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | var xDirRewind func(uintptr) | |
| 50 | + | ||
| 51 | + | // Resets the given directory. The next call to g_dir_read_name() | |
| 52 | + | // will return the first entry again. | |
| 53 | + | func (x *Dir) Rewind() { | |
| 54 | + | ||
| 55 | + | xDirRewind(x.GoPointer()) | |
| 56 | + | ||
| 57 | + | } | |
| 58 | + | ||
| 59 | + | func init() { | |
| 60 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 61 | + | if err != nil { | |
| 62 | + | panic(err) | |
| 63 | + | } | |
| 64 | + | ||
| 65 | + | core.PuregoSafeRegister(&xDirClose, lib, "g_dir_close") | |
| 66 | + | core.PuregoSafeRegister(&xDirReadName, lib, "g_dir_read_name") | |
| 67 | + | core.PuregoSafeRegister(&xDirRewind, lib, "g_dir_rewind") | |
| 68 | + | ||
| 69 | + | } | |
M v4/glib/gerror.go +82 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -43,6 +45,78 @@ type Error struct { | |||
| 43 | 45 | Message uintptr | |
| 44 | 46 | } | |
| 45 | 47 | ||
| 48 | + | func (x *Error) GoPointer() uintptr { | |
| 49 | + | return uintptr(unsafe.Pointer(x)) | |
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xNewError func(Quark, int, string, ...interface{}) *Error | |
| 53 | + | ||
| 54 | + | // Creates a new #GError with the given @domain and @code, | |
| 55 | + | // and a message formatted with @format. | |
| 56 | + | func NewError(DomainVar Quark, CodeVar int, FormatVar string, varArgs ...interface{}) *Error { | |
| 57 | + | ||
| 58 | + | cret := xNewError(DomainVar, CodeVar, FormatVar, varArgs...) | |
| 59 | + | return cret | |
| 60 | + | } | |
| 61 | + | ||
| 62 | + | var xNewLiteralError func(Quark, int, string) *Error | |
| 63 | + | ||
| 64 | + | // Creates a new #GError; unlike g_error_new(), @message is | |
| 65 | + | // not a printf()-style format string. Use this function if | |
| 66 | + | // @message contains text you don't have control over, | |
| 67 | + | // that could include printf() escape sequences. | |
| 68 | + | func NewLiteralError(DomainVar Quark, CodeVar int, MessageVar string) *Error { | |
| 69 | + | ||
| 70 | + | cret := xNewLiteralError(DomainVar, CodeVar, MessageVar) | |
| 71 | + | return cret | |
| 72 | + | } | |
| 73 | + | ||
| 74 | + | var xNewValistError func(Quark, int, string, []interface{}) *Error | |
| 75 | + | ||
| 76 | + | // Creates a new #GError with the given @domain and @code, | |
| 77 | + | // and a message formatted with @format. | |
| 78 | + | func NewValistError(DomainVar Quark, CodeVar int, FormatVar string, ArgsVar []interface{}) *Error { | |
| 79 | + | ||
| 80 | + | cret := xNewValistError(DomainVar, CodeVar, FormatVar, ArgsVar) | |
| 81 | + | return cret | |
| 82 | + | } | |
| 83 | + | ||
| 84 | + | var xErrorCopy func(uintptr) *Error | |
| 85 | + | ||
| 86 | + | // Makes a copy of @error. | |
| 87 | + | func (x *Error) Copy() *Error { | |
| 88 | + | ||
| 89 | + | cret := xErrorCopy(x.GoPointer()) | |
| 90 | + | return cret | |
| 91 | + | } | |
| 92 | + | ||
| 93 | + | var xErrorFree func(uintptr) | |
| 94 | + | ||
| 95 | + | // Frees a #GError and associated resources. | |
| 96 | + | func (x *Error) Free() { | |
| 97 | + | ||
| 98 | + | xErrorFree(x.GoPointer()) | |
| 99 | + | ||
| 100 | + | } | |
| 101 | + | ||
| 102 | + | var xErrorMatches func(uintptr, Quark, int) bool | |
| 103 | + | ||
| 104 | + | // Returns %TRUE if @error matches @domain and @code, %FALSE | |
| 105 | + | // otherwise. In particular, when @error is %NULL, %FALSE will | |
| 106 | + | // be returned. | |
| 107 | + | // | |
| 108 | + | // If @domain contains a `FAILED` (or otherwise generic) error code, | |
| 109 | + | // you should generally not check for it explicitly, but should | |
| 110 | + | // instead treat any not-explicitly-recognized error code as being | |
| 111 | + | // equivalent to the `FAILED` code. This way, if the domain is | |
| 112 | + | // extended in the future to provide a more specific error code for | |
| 113 | + | // a certain case, your code will still work. | |
| 114 | + | func (x *Error) Matches(DomainVar Quark, CodeVar int) bool { | |
| 115 | + | ||
| 116 | + | cret := xErrorMatches(x.GoPointer(), DomainVar, CodeVar) | |
| 117 | + | return cret | |
| 118 | + | } | |
| 119 | + | ||
| 46 | 120 | var xClearError func() | |
| 47 | 121 | ||
| 48 | 122 | // If @err or *@err is %NULL, does nothing. Otherwise, | |
| @@ -145,4 +219,12 @@ func init() { | |||
| 145 | 219 | core.PuregoSafeRegister(&xSetError, lib, "g_set_error") | |
| 146 | 220 | core.PuregoSafeRegister(&xSetErrorLiteral, lib, "g_set_error_literal") | |
| 147 | 221 | ||
| 222 | + | core.PuregoSafeRegister(&xNewError, lib, "g_error_new") | |
| 223 | + | core.PuregoSafeRegister(&xNewLiteralError, lib, "g_error_new_literal") | |
| 224 | + | core.PuregoSafeRegister(&xNewValistError, lib, "g_error_new_valist") | |
| 225 | + | ||
| 226 | + | core.PuregoSafeRegister(&xErrorCopy, lib, "g_error_copy") | |
| 227 | + | core.PuregoSafeRegister(&xErrorFree, lib, "g_error_free") | |
| 228 | + | core.PuregoSafeRegister(&xErrorMatches, lib, "g_error_matches") | |
| 229 | + | ||
| 148 | 230 | } | |
M v4/glib/ghash.go +119 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -19,6 +21,10 @@ type HRFunc func(uintptr, uintptr, uintptr) bool | |||
| 19 | 21 | type HashTable struct { | |
| 20 | 22 | } | |
| 21 | 23 | ||
| 24 | + | func (x *HashTable) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 22 | 28 | // A GHashTableIter structure represents an iterator that can be used | |
| 23 | 29 | // to iterate over the elements of a #GHashTable. GHashTableIter | |
| 24 | 30 | // structures are typically allocated on the stack and then initialized | |
| @@ -40,6 +46,112 @@ type HashTableIter struct { | |||
| 40 | 46 | Dummy6 uintptr | |
| 41 | 47 | } | |
| 42 | 48 | ||
| 49 | + | func (x *HashTableIter) GoPointer() uintptr { | |
| 50 | + | return uintptr(unsafe.Pointer(x)) | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | var xHashTableIterGetHashTable func(uintptr) *HashTable | |
| 54 | + | ||
| 55 | + | // Returns the #GHashTable associated with @iter. | |
| 56 | + | func (x *HashTableIter) GetHashTable() *HashTable { | |
| 57 | + | ||
| 58 | + | cret := xHashTableIterGetHashTable(x.GoPointer()) | |
| 59 | + | return cret | |
| 60 | + | } | |
| 61 | + | ||
| 62 | + | var xHashTableIterInit func(uintptr, *HashTable) | |
| 63 | + | ||
| 64 | + | // Initializes a key/value pair iterator and associates it with | |
| 65 | + | // @hash_table. Modifying the hash table after calling this function | |
| 66 | + | // invalidates the returned iterator. | |
| 67 | + | // | |
| 68 | + | // The iteration order of a #GHashTableIter over the keys/values in a hash | |
| 69 | + | // table is not defined. | |
| 70 | + | // | |
| 71 | + | // |[<!-- language="C" --> | |
| 72 | + | // GHashTableIter iter; | |
| 73 | + | // gpointer key, value; | |
| 74 | + | // | |
| 75 | + | // g_hash_table_iter_init (&iter, hash_table); | |
| 76 | + | // while (g_hash_table_iter_next (&iter, &key, &value)) | |
| 77 | + | // | |
| 78 | + | // { | |
| 79 | + | // // do something with key and value | |
| 80 | + | // } | |
| 81 | + | // | |
| 82 | + | // ]| | |
| 83 | + | func (x *HashTableIter) Init(HashTableVar *HashTable) { | |
| 84 | + | ||
| 85 | + | xHashTableIterInit(x.GoPointer(), HashTableVar) | |
| 86 | + | ||
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xHashTableIterNext func(uintptr, uintptr, uintptr) bool | |
| 90 | + | ||
| 91 | + | // Advances @iter and retrieves the key and/or value that are now | |
| 92 | + | // pointed to as a result of this advancement. If %FALSE is returned, | |
| 93 | + | // @key and @value are not set, and the iterator becomes invalid. | |
| 94 | + | func (x *HashTableIter) Next(KeyVar uintptr, ValueVar uintptr) bool { | |
| 95 | + | ||
| 96 | + | cret := xHashTableIterNext(x.GoPointer(), KeyVar, ValueVar) | |
| 97 | + | return cret | |
| 98 | + | } | |
| 99 | + | ||
| 100 | + | var xHashTableIterRemove func(uintptr) | |
| 101 | + | ||
| 102 | + | // Removes the key/value pair currently pointed to by the iterator | |
| 103 | + | // from its associated #GHashTable. Can only be called after | |
| 104 | + | // g_hash_table_iter_next() returned %TRUE, and cannot be called | |
| 105 | + | // more than once for the same key/value pair. | |
| 106 | + | // | |
| 107 | + | // If the #GHashTable was created using g_hash_table_new_full(), | |
| 108 | + | // the key and value are freed using the supplied destroy functions, | |
| 109 | + | // otherwise you have to make sure that any dynamically allocated | |
| 110 | + | // values are freed yourself. | |
| 111 | + | // | |
| 112 | + | // It is safe to continue iterating the #GHashTable afterward: | |
| 113 | + | // |[<!-- language="C" --> | |
| 114 | + | // while (g_hash_table_iter_next (&iter, &key, &value)) | |
| 115 | + | // | |
| 116 | + | // { | |
| 117 | + | // if (condition) | |
| 118 | + | // g_hash_table_iter_remove (&iter); | |
| 119 | + | // } | |
| 120 | + | // | |
| 121 | + | // ]| | |
| 122 | + | func (x *HashTableIter) Remove() { | |
| 123 | + | ||
| 124 | + | xHashTableIterRemove(x.GoPointer()) | |
| 125 | + | ||
| 126 | + | } | |
| 127 | + | ||
| 128 | + | var xHashTableIterReplace func(uintptr, uintptr) | |
| 129 | + | ||
| 130 | + | // Replaces the value currently pointed to by the iterator | |
| 131 | + | // from its associated #GHashTable. Can only be called after | |
| 132 | + | // g_hash_table_iter_next() returned %TRUE. | |
| 133 | + | // | |
| 134 | + | // If you supplied a @value_destroy_func when creating the | |
| 135 | + | // #GHashTable, the old value is freed using that function. | |
| 136 | + | func (x *HashTableIter) Replace(ValueVar uintptr) { | |
| 137 | + | ||
| 138 | + | xHashTableIterReplace(x.GoPointer(), ValueVar) | |
| 139 | + | ||
| 140 | + | } | |
| 141 | + | ||
| 142 | + | var xHashTableIterSteal func(uintptr) | |
| 143 | + | ||
| 144 | + | // Removes the key/value pair currently pointed to by the | |
| 145 | + | // iterator from its associated #GHashTable, without calling | |
| 146 | + | // the key and value destroy functions. Can only be called | |
| 147 | + | // after g_hash_table_iter_next() returned %TRUE, and cannot | |
| 148 | + | // be called more than once for the same key/value pair. | |
| 149 | + | func (x *HashTableIter) Steal() { | |
| 150 | + | ||
| 151 | + | xHashTableIterSteal(x.GoPointer()) | |
| 152 | + | ||
| 153 | + | } | |
| 154 | + | ||
| 43 | 155 | var xDirectEqual func(uintptr, uintptr) bool | |
| 44 | 156 | ||
| 45 | 157 | // Compares two #gpointer arguments and returns %TRUE if they are equal. | |
| @@ -438,4 +550,11 @@ func init() { | |||
| 438 | 550 | core.PuregoSafeRegister(&xStrEqual, lib, "g_str_equal") | |
| 439 | 551 | core.PuregoSafeRegister(&xStrHash, lib, "g_str_hash") | |
| 440 | 552 | ||
| 553 | + | core.PuregoSafeRegister(&xHashTableIterGetHashTable, lib, "g_hash_table_iter_get_hash_table") | |
| 554 | + | core.PuregoSafeRegister(&xHashTableIterInit, lib, "g_hash_table_iter_init") | |
| 555 | + | core.PuregoSafeRegister(&xHashTableIterNext, lib, "g_hash_table_iter_next") | |
| 556 | + | core.PuregoSafeRegister(&xHashTableIterRemove, lib, "g_hash_table_iter_remove") | |
| 557 | + | core.PuregoSafeRegister(&xHashTableIterReplace, lib, "g_hash_table_iter_replace") | |
| 558 | + | core.PuregoSafeRegister(&xHashTableIterSteal, lib, "g_hash_table_iter_steal") | |
| 559 | + | ||
| 441 | 560 | } | |
M v4/glib/ghmac.go +88 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -12,6 +14,85 @@ import ( | |||
| 12 | 14 | type Hmac struct { | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *Hmac) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | var xHmacCopy func(uintptr) *Hmac | |
| 22 | + | ||
| 23 | + | // Copies a #GHmac. If @hmac has been closed, by calling | |
| 24 | + | // g_hmac_get_string() or g_hmac_get_digest(), the copied | |
| 25 | + | // HMAC will be closed as well. | |
| 26 | + | func (x *Hmac) Copy() *Hmac { | |
| 27 | + | ||
| 28 | + | cret := xHmacCopy(x.GoPointer()) | |
| 29 | + | return cret | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | var xHmacGetDigest func(uintptr, uintptr, uint) | |
| 33 | + | ||
| 34 | + | // Gets the digest from @checksum as a raw binary array and places it | |
| 35 | + | // into @buffer. The size of the digest depends on the type of checksum. | |
| 36 | + | // | |
| 37 | + | // Once this function has been called, the #GHmac is closed and can | |
| 38 | + | // no longer be updated with g_checksum_update(). | |
| 39 | + | func (x *Hmac) GetDigest(BufferVar uintptr, DigestLenVar uint) { | |
| 40 | + | ||
| 41 | + | xHmacGetDigest(x.GoPointer(), BufferVar, DigestLenVar) | |
| 42 | + | ||
| 43 | + | } | |
| 44 | + | ||
| 45 | + | var xHmacGetString func(uintptr) string | |
| 46 | + | ||
| 47 | + | // Gets the HMAC as a hexadecimal string. | |
| 48 | + | // | |
| 49 | + | // Once this function has been called the #GHmac can no longer be | |
| 50 | + | // updated with g_hmac_update(). | |
| 51 | + | // | |
| 52 | + | // The hexadecimal characters will be lower case. | |
| 53 | + | func (x *Hmac) GetString() string { | |
| 54 | + | ||
| 55 | + | cret := xHmacGetString(x.GoPointer()) | |
| 56 | + | return cret | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | var xHmacRef func(uintptr) *Hmac | |
| 60 | + | ||
| 61 | + | // Atomically increments the reference count of @hmac by one. | |
| 62 | + | // | |
| 63 | + | // This function is MT-safe and may be called from any thread. | |
| 64 | + | func (x *Hmac) Ref() *Hmac { | |
| 65 | + | ||
| 66 | + | cret := xHmacRef(x.GoPointer()) | |
| 67 | + | return cret | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | var xHmacUnref func(uintptr) | |
| 71 | + | ||
| 72 | + | // Atomically decrements the reference count of @hmac by one. | |
| 73 | + | // | |
| 74 | + | // If the reference count drops to 0, all keys and values will be | |
| 75 | + | // destroyed, and all memory allocated by the hash table is released. | |
| 76 | + | // This function is MT-safe and may be called from any thread. | |
| 77 | + | // Frees the memory allocated for @hmac. | |
| 78 | + | func (x *Hmac) Unref() { | |
| 79 | + | ||
| 80 | + | xHmacUnref(x.GoPointer()) | |
| 81 | + | ||
| 82 | + | } | |
| 83 | + | ||
| 84 | + | var xHmacUpdate func(uintptr, uintptr, int) | |
| 85 | + | ||
| 86 | + | // Feeds @data into an existing #GHmac. | |
| 87 | + | // | |
| 88 | + | // The HMAC must still be open, that is g_hmac_get_string() or | |
| 89 | + | // g_hmac_get_digest() must not have been called on @hmac. | |
| 90 | + | func (x *Hmac) Update(DataVar uintptr, LengthVar int) { | |
| 91 | + | ||
| 92 | + | xHmacUpdate(x.GoPointer(), DataVar, LengthVar) | |
| 93 | + | ||
| 94 | + | } | |
| 95 | + | ||
| 15 | 96 | var xComputeHmacForBytes func(ChecksumType, *Bytes, *Bytes) string | |
| 16 | 97 | ||
| 17 | 98 | // Computes the HMAC for a binary @data. This is a | |
| @@ -58,4 +139,11 @@ func init() { | |||
| 58 | 139 | core.PuregoSafeRegister(&xComputeHmacForData, lib, "g_compute_hmac_for_data") | |
| 59 | 140 | core.PuregoSafeRegister(&xComputeHmacForString, lib, "g_compute_hmac_for_string") | |
| 60 | 141 | ||
| 142 | + | core.PuregoSafeRegister(&xHmacCopy, lib, "g_hmac_copy") | |
| 143 | + | core.PuregoSafeRegister(&xHmacGetDigest, lib, "g_hmac_get_digest") | |
| 144 | + | core.PuregoSafeRegister(&xHmacGetString, lib, "g_hmac_get_string") | |
| 145 | + | core.PuregoSafeRegister(&xHmacRef, lib, "g_hmac_ref") | |
| 146 | + | core.PuregoSafeRegister(&xHmacUnref, lib, "g_hmac_unref") | |
| 147 | + | core.PuregoSafeRegister(&xHmacUpdate, lib, "g_hmac_update") | |
| 148 | + | ||
| 61 | 149 | } | |
M v4/glib/ghook.go +94 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -50,6 +52,20 @@ type Hook struct { | |||
| 50 | 52 | Destroy DestroyNotify | |
| 51 | 53 | } | |
| 52 | 54 | ||
| 55 | + | func (x *Hook) GoPointer() uintptr { | |
| 56 | + | return uintptr(unsafe.Pointer(x)) | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | var xHookCompareIds func(uintptr, *Hook) int | |
| 60 | + | ||
| 61 | + | // Compares the ids of two #GHook elements, returning a negative value | |
| 62 | + | // if the second id is greater than the first. | |
| 63 | + | func (x *Hook) CompareIds(SiblingVar *Hook) int { | |
| 64 | + | ||
| 65 | + | cret := xHookCompareIds(x.GoPointer(), SiblingVar) | |
| 66 | + | return cret | |
| 67 | + | } | |
| 68 | + | ||
| 53 | 69 | // The #GHookList struct represents a list of hook functions. | |
| 54 | 70 | type HookList struct { | |
| 55 | 71 | SeqId uint32 | |
| @@ -67,6 +83,75 @@ type HookList struct { | |||
| 67 | 83 | Dummy uintptr | |
| 68 | 84 | } | |
| 69 | 85 | ||
| 86 | + | func (x *HookList) GoPointer() uintptr { | |
| 87 | + | return uintptr(unsafe.Pointer(x)) | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | var xHookListClear func(uintptr) | |
| 91 | + | ||
| 92 | + | // Removes all the #GHook elements from a #GHookList. | |
| 93 | + | func (x *HookList) Clear() { | |
| 94 | + | ||
| 95 | + | xHookListClear(x.GoPointer()) | |
| 96 | + | ||
| 97 | + | } | |
| 98 | + | ||
| 99 | + | var xHookListInit func(uintptr, uint) | |
| 100 | + | ||
| 101 | + | // Initializes a #GHookList. | |
| 102 | + | // This must be called before the #GHookList is used. | |
| 103 | + | func (x *HookList) Init(HookSizeVar uint) { | |
| 104 | + | ||
| 105 | + | xHookListInit(x.GoPointer(), HookSizeVar) | |
| 106 | + | ||
| 107 | + | } | |
| 108 | + | ||
| 109 | + | var xHookListInvoke func(uintptr, bool) | |
| 110 | + | ||
| 111 | + | // Calls all of the #GHook functions in a #GHookList. | |
| 112 | + | func (x *HookList) Invoke(MayRecurseVar bool) { | |
| 113 | + | ||
| 114 | + | xHookListInvoke(x.GoPointer(), MayRecurseVar) | |
| 115 | + | ||
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xHookListInvokeCheck func(uintptr, bool) | |
| 119 | + | ||
| 120 | + | // Calls all of the #GHook functions in a #GHookList. | |
| 121 | + | // Any function which returns %FALSE is removed from the #GHookList. | |
| 122 | + | func (x *HookList) InvokeCheck(MayRecurseVar bool) { | |
| 123 | + | ||
| 124 | + | xHookListInvokeCheck(x.GoPointer(), MayRecurseVar) | |
| 125 | + | ||
| 126 | + | } | |
| 127 | + | ||
| 128 | + | var xHookListMarshal func(uintptr, bool, uintptr, uintptr) | |
| 129 | + | ||
| 130 | + | // Calls a function on each valid #GHook. | |
| 131 | + | func (x *HookList) Marshal(MayRecurseVar bool, MarshallerVar HookMarshaller, MarshalDataVar uintptr) { | |
| 132 | + | ||
| 133 | + | xHookListMarshal(x.GoPointer(), MayRecurseVar, purego.NewCallback(MarshallerVar), MarshalDataVar) | |
| 134 | + | ||
| 135 | + | } | |
| 136 | + | ||
| 137 | + | var xHookListMarshalCheck func(uintptr, bool, uintptr, uintptr) | |
| 138 | + | ||
| 139 | + | // Calls a function on each valid #GHook and destroys it if the | |
| 140 | + | // function returns %FALSE. | |
| 141 | + | func (x *HookList) MarshalCheck(MayRecurseVar bool, MarshallerVar HookCheckMarshaller, MarshalDataVar uintptr) { | |
| 142 | + | ||
| 143 | + | xHookListMarshalCheck(x.GoPointer(), MayRecurseVar, purego.NewCallback(MarshallerVar), MarshalDataVar) | |
| 144 | + | ||
| 145 | + | } | |
| 146 | + | ||
| 147 | + | const ( | |
| 148 | + | // The position of the first bit which is not reserved for internal | |
| 149 | + | // use be the #GHook implementation, i.e. | |
| 150 | + | // `1 << G_HOOK_FLAG_USER_SHIFT` is the first | |
| 151 | + | // bit which can be used for application-defined flags. | |
| 152 | + | HOOK_FLAG_USER_SHIFT int = 4 | |
| 153 | + | ) | |
| 154 | + | ||
| 70 | 155 | // Flags used internally in the #GHook implementation. | |
| 71 | 156 | type HookFlagMask int | |
| 72 | 157 | ||
| @@ -151,4 +236,13 @@ func init() { | |||
| 151 | 236 | core.PuregoSafeRegister(&xHookPrepend, lib, "g_hook_prepend") | |
| 152 | 237 | core.PuregoSafeRegister(&xHookUnref, lib, "g_hook_unref") | |
| 153 | 238 | ||
| 239 | + | core.PuregoSafeRegister(&xHookCompareIds, lib, "g_hook_compare_ids") | |
| 240 | + | ||
| 241 | + | core.PuregoSafeRegister(&xHookListClear, lib, "g_hook_list_clear") | |
| 242 | + | core.PuregoSafeRegister(&xHookListInit, lib, "g_hook_list_init") | |
| 243 | + | core.PuregoSafeRegister(&xHookListInvoke, lib, "g_hook_list_invoke") | |
| 244 | + | core.PuregoSafeRegister(&xHookListInvokeCheck, lib, "g_hook_list_invoke_check") | |
| 245 | + | core.PuregoSafeRegister(&xHookListMarshal, lib, "g_hook_list_marshal") | |
| 246 | + | core.PuregoSafeRegister(&xHookListMarshalCheck, lib, "g_hook_list_marshal_check") | |
| 247 | + | ||
| 154 | 248 | } | |
M v4/glib/giochannel.go +532 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -56,11 +58,506 @@ type IOChannel struct { | |||
| 56 | 58 | Reserved2 uintptr | |
| 57 | 59 | } | |
| 58 | 60 | ||
| 61 | + | func (x *IOChannel) GoPointer() uintptr { | |
| 62 | + | return uintptr(unsafe.Pointer(x)) | |
| 63 | + | } | |
| 64 | + | ||
| 65 | + | var xNewFileIOChannel func(string, string, **Error) *IOChannel | |
| 66 | + | ||
| 67 | + | // Open a file @filename as a #GIOChannel using mode @mode. This | |
| 68 | + | // channel will be closed when the last reference to it is dropped, | |
| 69 | + | // so there is no need to call g_io_channel_close() (though doing | |
| 70 | + | // so will not cause problems, as long as no attempt is made to | |
| 71 | + | // access the channel after it is closed). | |
| 72 | + | func NewFileIOChannel(FilenameVar string, ModeVar string) (*IOChannel, error) { | |
| 73 | + | var cerr *Error | |
| 74 | + | ||
| 75 | + | cret := xNewFileIOChannel(FilenameVar, ModeVar, &cerr) | |
| 76 | + | if cerr == nil { | |
| 77 | + | return cret, nil | |
| 78 | + | } | |
| 79 | + | return cret, cerr | |
| 80 | + | ||
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xUnixNewIOChannel func(int) *IOChannel | |
| 84 | + | ||
| 85 | + | // Creates a new #GIOChannel given a file descriptor. On UNIX systems | |
| 86 | + | // this works for plain files, pipes, and sockets. | |
| 87 | + | // | |
| 88 | + | // The returned #GIOChannel has a reference count of 1. | |
| 89 | + | // | |
| 90 | + | // The default encoding for #GIOChannel is UTF-8. If your application | |
| 91 | + | // is reading output from a command using via pipe, you may need to set | |
| 92 | + | // the encoding to the encoding of the current locale (see | |
| 93 | + | // g_get_charset()) with the g_io_channel_set_encoding() function. | |
| 94 | + | // By default, the fd passed will not be closed when the final reference | |
| 95 | + | // to the #GIOChannel data structure is dropped. | |
| 96 | + | // | |
| 97 | + | // If you want to read raw binary data without interpretation, then | |
| 98 | + | // call the g_io_channel_set_encoding() function with %NULL for the | |
| 99 | + | // encoding argument. | |
| 100 | + | // | |
| 101 | + | // This function is available in GLib on Windows, too, but you should | |
| 102 | + | // avoid using it on Windows. The domain of file descriptors and | |
| 103 | + | // sockets overlap. There is no way for GLib to know which one you mean | |
| 104 | + | // in case the argument you pass to this function happens to be both a | |
| 105 | + | // valid file descriptor and socket. If that happens a warning is | |
| 106 | + | // issued, and GLib assumes that it is the file descriptor you mean. | |
| 107 | + | func UnixNewIOChannel(FdVar int) *IOChannel { | |
| 108 | + | ||
| 109 | + | cret := xUnixNewIOChannel(FdVar) | |
| 110 | + | return cret | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | var xIOChannelClose func(uintptr) | |
| 114 | + | ||
| 115 | + | // Close an IO channel. Any pending data to be written will be | |
| 116 | + | // flushed, ignoring errors. The channel will not be freed until the | |
| 117 | + | // last reference is dropped using g_io_channel_unref(). | |
| 118 | + | func (x *IOChannel) Close() { | |
| 119 | + | ||
| 120 | + | xIOChannelClose(x.GoPointer()) | |
| 121 | + | ||
| 122 | + | } | |
| 123 | + | ||
| 124 | + | var xIOChannelFlush func(uintptr) IOStatus | |
| 125 | + | ||
| 126 | + | // Flushes the write buffer for the GIOChannel. | |
| 127 | + | func (x *IOChannel) Flush() (IOStatus, error) { | |
| 128 | + | var cerr *Error | |
| 129 | + | ||
| 130 | + | cret := xIOChannelFlush(x.GoPointer()) | |
| 131 | + | if cerr == nil { | |
| 132 | + | return cret, nil | |
| 133 | + | } | |
| 134 | + | return cret, cerr | |
| 135 | + | ||
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xIOChannelGetBufferCondition func(uintptr) IOCondition | |
| 139 | + | ||
| 140 | + | // This function returns a #GIOCondition depending on whether there | |
| 141 | + | // is data to be read/space to write data in the internal buffers in | |
| 142 | + | // the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set. | |
| 143 | + | func (x *IOChannel) GetBufferCondition() IOCondition { | |
| 144 | + | ||
| 145 | + | cret := xIOChannelGetBufferCondition(x.GoPointer()) | |
| 146 | + | return cret | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | var xIOChannelGetBufferSize func(uintptr) uint | |
| 150 | + | ||
| 151 | + | // Gets the buffer size. | |
| 152 | + | func (x *IOChannel) GetBufferSize() uint { | |
| 153 | + | ||
| 154 | + | cret := xIOChannelGetBufferSize(x.GoPointer()) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xIOChannelGetBuffered func(uintptr) bool | |
| 159 | + | ||
| 160 | + | // Returns whether @channel is buffered. | |
| 161 | + | func (x *IOChannel) GetBuffered() bool { | |
| 162 | + | ||
| 163 | + | cret := xIOChannelGetBuffered(x.GoPointer()) | |
| 164 | + | return cret | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xIOChannelGetCloseOnUnref func(uintptr) bool | |
| 168 | + | ||
| 169 | + | // Returns whether the file/socket/whatever associated with @channel | |
| 170 | + | // will be closed when @channel receives its final unref and is | |
| 171 | + | // destroyed. The default value of this is %TRUE for channels created | |
| 172 | + | // by g_io_channel_new_file (), and %FALSE for all other channels. | |
| 173 | + | func (x *IOChannel) GetCloseOnUnref() bool { | |
| 174 | + | ||
| 175 | + | cret := xIOChannelGetCloseOnUnref(x.GoPointer()) | |
| 176 | + | return cret | |
| 177 | + | } | |
| 178 | + | ||
| 179 | + | var xIOChannelGetEncoding func(uintptr) string | |
| 180 | + | ||
| 181 | + | // Gets the encoding for the input/output of the channel. | |
| 182 | + | // The internal encoding is always UTF-8. The encoding %NULL | |
| 183 | + | // makes the channel safe for binary data. | |
| 184 | + | func (x *IOChannel) GetEncoding() string { | |
| 185 | + | ||
| 186 | + | cret := xIOChannelGetEncoding(x.GoPointer()) | |
| 187 | + | return cret | |
| 188 | + | } | |
| 189 | + | ||
| 190 | + | var xIOChannelGetFlags func(uintptr) IOFlags | |
| 191 | + | ||
| 192 | + | // Gets the current flags for a #GIOChannel, including read-only | |
| 193 | + | // flags such as %G_IO_FLAG_IS_READABLE. | |
| 194 | + | // | |
| 195 | + | // The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE | |
| 196 | + | // are cached for internal use by the channel when it is created. | |
| 197 | + | // If they should change at some later point (e.g. partial shutdown | |
| 198 | + | // of a socket with the UNIX shutdown() function), the user | |
| 199 | + | // should immediately call g_io_channel_get_flags() to update | |
| 200 | + | // the internal values of these flags. | |
| 201 | + | func (x *IOChannel) GetFlags() IOFlags { | |
| 202 | + | ||
| 203 | + | cret := xIOChannelGetFlags(x.GoPointer()) | |
| 204 | + | return cret | |
| 205 | + | } | |
| 206 | + | ||
| 207 | + | var xIOChannelGetLineTerm func(uintptr, int) string | |
| 208 | + | ||
| 209 | + | // This returns the string that #GIOChannel uses to determine | |
| 210 | + | // where in the file a line break occurs. A value of %NULL | |
| 211 | + | // indicates autodetection. | |
| 212 | + | func (x *IOChannel) GetLineTerm(LengthVar int) string { | |
| 213 | + | ||
| 214 | + | cret := xIOChannelGetLineTerm(x.GoPointer(), LengthVar) | |
| 215 | + | return cret | |
| 216 | + | } | |
| 217 | + | ||
| 218 | + | var xIOChannelInit func(uintptr) | |
| 219 | + | ||
| 220 | + | // Initializes a #GIOChannel struct. | |
| 221 | + | // | |
| 222 | + | // This is called by each of the above functions when creating a | |
| 223 | + | // #GIOChannel, and so is not often needed by the application | |
| 224 | + | // programmer (unless you are creating a new type of #GIOChannel). | |
| 225 | + | func (x *IOChannel) Init() { | |
| 226 | + | ||
| 227 | + | xIOChannelInit(x.GoPointer()) | |
| 228 | + | ||
| 229 | + | } | |
| 230 | + | ||
| 231 | + | var xIOChannelRead func(uintptr, string, uint, uint) IOError | |
| 232 | + | ||
| 233 | + | // Reads data from a #GIOChannel. | |
| 234 | + | func (x *IOChannel) Read(BufVar string, CountVar uint, BytesReadVar uint) IOError { | |
| 235 | + | ||
| 236 | + | cret := xIOChannelRead(x.GoPointer(), BufVar, CountVar, BytesReadVar) | |
| 237 | + | return cret | |
| 238 | + | } | |
| 239 | + | ||
| 240 | + | var xIOChannelReadChars func(uintptr, uintptr, uint, uint, **Error) IOStatus | |
| 241 | + | ||
| 242 | + | // Replacement for g_io_channel_read() with the new API. | |
| 243 | + | func (x *IOChannel) ReadChars(BufVar uintptr, CountVar uint, BytesReadVar uint) (IOStatus, error) { | |
| 244 | + | var cerr *Error | |
| 245 | + | ||
| 246 | + | cret := xIOChannelReadChars(x.GoPointer(), BufVar, CountVar, BytesReadVar, &cerr) | |
| 247 | + | if cerr == nil { | |
| 248 | + | return cret, nil | |
| 249 | + | } | |
| 250 | + | return cret, cerr | |
| 251 | + | ||
| 252 | + | } | |
| 253 | + | ||
| 254 | + | var xIOChannelReadLine func(uintptr, string, uint, uint, **Error) IOStatus | |
| 255 | + | ||
| 256 | + | // Reads a line, including the terminating character(s), | |
| 257 | + | // from a #GIOChannel into a newly-allocated string. | |
| 258 | + | // @str_return will contain allocated memory if the return | |
| 259 | + | // is %G_IO_STATUS_NORMAL. | |
| 260 | + | func (x *IOChannel) ReadLine(StrReturnVar string, LengthVar uint, TerminatorPosVar uint) (IOStatus, error) { | |
| 261 | + | var cerr *Error | |
| 262 | + | ||
| 263 | + | cret := xIOChannelReadLine(x.GoPointer(), StrReturnVar, LengthVar, TerminatorPosVar, &cerr) | |
| 264 | + | if cerr == nil { | |
| 265 | + | return cret, nil | |
| 266 | + | } | |
| 267 | + | return cret, cerr | |
| 268 | + | ||
| 269 | + | } | |
| 270 | + | ||
| 271 | + | var xIOChannelReadLineString func(uintptr, *String, uint, **Error) IOStatus | |
| 272 | + | ||
| 273 | + | // Reads a line from a #GIOChannel, using a #GString as a buffer. | |
| 274 | + | func (x *IOChannel) ReadLineString(BufferVar *String, TerminatorPosVar uint) (IOStatus, error) { | |
| 275 | + | var cerr *Error | |
| 276 | + | ||
| 277 | + | cret := xIOChannelReadLineString(x.GoPointer(), BufferVar, TerminatorPosVar, &cerr) | |
| 278 | + | if cerr == nil { | |
| 279 | + | return cret, nil | |
| 280 | + | } | |
| 281 | + | return cret, cerr | |
| 282 | + | ||
| 283 | + | } | |
| 284 | + | ||
| 285 | + | var xIOChannelReadToEnd func(uintptr, uintptr, uint, **Error) IOStatus | |
| 286 | + | ||
| 287 | + | // Reads all the remaining data from the file. | |
| 288 | + | func (x *IOChannel) ReadToEnd(StrReturnVar uintptr, LengthVar uint) (IOStatus, error) { | |
| 289 | + | var cerr *Error | |
| 290 | + | ||
| 291 | + | cret := xIOChannelReadToEnd(x.GoPointer(), StrReturnVar, LengthVar, &cerr) | |
| 292 | + | if cerr == nil { | |
| 293 | + | return cret, nil | |
| 294 | + | } | |
| 295 | + | return cret, cerr | |
| 296 | + | ||
| 297 | + | } | |
| 298 | + | ||
| 299 | + | var xIOChannelReadUnichar func(uintptr, uint32, **Error) IOStatus | |
| 300 | + | ||
| 301 | + | // Reads a Unicode character from @channel. | |
| 302 | + | // This function cannot be called on a channel with %NULL encoding. | |
| 303 | + | func (x *IOChannel) ReadUnichar(ThecharVar uint32) (IOStatus, error) { | |
| 304 | + | var cerr *Error | |
| 305 | + | ||
| 306 | + | cret := xIOChannelReadUnichar(x.GoPointer(), ThecharVar, &cerr) | |
| 307 | + | if cerr == nil { | |
| 308 | + | return cret, nil | |
| 309 | + | } | |
| 310 | + | return cret, cerr | |
| 311 | + | ||
| 312 | + | } | |
| 313 | + | ||
| 314 | + | var xIOChannelRef func(uintptr) *IOChannel | |
| 315 | + | ||
| 316 | + | // Increments the reference count of a #GIOChannel. | |
| 317 | + | func (x *IOChannel) Ref() *IOChannel { | |
| 318 | + | ||
| 319 | + | cret := xIOChannelRef(x.GoPointer()) | |
| 320 | + | return cret | |
| 321 | + | } | |
| 322 | + | ||
| 323 | + | var xIOChannelSeek func(uintptr, int64, SeekType) IOError | |
| 324 | + | ||
| 325 | + | // Sets the current position in the #GIOChannel, similar to the standard | |
| 326 | + | // library function fseek(). | |
| 327 | + | func (x *IOChannel) Seek(OffsetVar int64, TypeVar SeekType) IOError { | |
| 328 | + | ||
| 329 | + | cret := xIOChannelSeek(x.GoPointer(), OffsetVar, TypeVar) | |
| 330 | + | return cret | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | var xIOChannelSeekPosition func(uintptr, int64, SeekType, **Error) IOStatus | |
| 334 | + | ||
| 335 | + | // Replacement for g_io_channel_seek() with the new API. | |
| 336 | + | func (x *IOChannel) SeekPosition(OffsetVar int64, TypeVar SeekType) (IOStatus, error) { | |
| 337 | + | var cerr *Error | |
| 338 | + | ||
| 339 | + | cret := xIOChannelSeekPosition(x.GoPointer(), OffsetVar, TypeVar, &cerr) | |
| 340 | + | if cerr == nil { | |
| 341 | + | return cret, nil | |
| 342 | + | } | |
| 343 | + | return cret, cerr | |
| 344 | + | ||
| 345 | + | } | |
| 346 | + | ||
| 347 | + | var xIOChannelSetBufferSize func(uintptr, uint) | |
| 348 | + | ||
| 349 | + | // Sets the buffer size. | |
| 350 | + | func (x *IOChannel) SetBufferSize(SizeVar uint) { | |
| 351 | + | ||
| 352 | + | xIOChannelSetBufferSize(x.GoPointer(), SizeVar) | |
| 353 | + | ||
| 354 | + | } | |
| 355 | + | ||
| 356 | + | var xIOChannelSetBuffered func(uintptr, bool) | |
| 357 | + | ||
| 358 | + | // The buffering state can only be set if the channel's encoding | |
| 359 | + | // is %NULL. For any other encoding, the channel must be buffered. | |
| 360 | + | // | |
| 361 | + | // A buffered channel can only be set unbuffered if the channel's | |
| 362 | + | // internal buffers have been flushed. Newly created channels or | |
| 363 | + | // channels which have returned %G_IO_STATUS_EOF | |
| 364 | + | // not require such a flush. For write-only channels, a call to | |
| 365 | + | // g_io_channel_flush () is sufficient. For all other channels, | |
| 366 | + | // the buffers may be flushed by a call to g_io_channel_seek_position (). | |
| 367 | + | // This includes the possibility of seeking with seek type %G_SEEK_CUR | |
| 368 | + | // and an offset of zero. Note that this means that socket-based | |
| 369 | + | // channels cannot be set unbuffered once they have had data | |
| 370 | + | // read from them. | |
| 371 | + | // | |
| 372 | + | // On unbuffered channels, it is safe to mix read and write | |
| 373 | + | // calls from the new and old APIs, if this is necessary for | |
| 374 | + | // maintaining old code. | |
| 375 | + | // | |
| 376 | + | // The default state of the channel is buffered. | |
| 377 | + | func (x *IOChannel) SetBuffered(BufferedVar bool) { | |
| 378 | + | ||
| 379 | + | xIOChannelSetBuffered(x.GoPointer(), BufferedVar) | |
| 380 | + | ||
| 381 | + | } | |
| 382 | + | ||
| 383 | + | var xIOChannelSetCloseOnUnref func(uintptr, bool) | |
| 384 | + | ||
| 385 | + | // Whether to close the channel on the final unref of the #GIOChannel | |
| 386 | + | // data structure. The default value of this is %TRUE for channels | |
| 387 | + | // created by g_io_channel_new_file (), and %FALSE for all other channels. | |
| 388 | + | // | |
| 389 | + | // Setting this flag to %TRUE for a channel you have already closed | |
| 390 | + | // can cause problems when the final reference to the #GIOChannel is dropped. | |
| 391 | + | func (x *IOChannel) SetCloseOnUnref(DoCloseVar bool) { | |
| 392 | + | ||
| 393 | + | xIOChannelSetCloseOnUnref(x.GoPointer(), DoCloseVar) | |
| 394 | + | ||
| 395 | + | } | |
| 396 | + | ||
| 397 | + | var xIOChannelSetEncoding func(uintptr, string, **Error) IOStatus | |
| 398 | + | ||
| 399 | + | // Sets the encoding for the input/output of the channel. | |
| 400 | + | // The internal encoding is always UTF-8. The default encoding | |
| 401 | + | // for the external file is UTF-8. | |
| 402 | + | // | |
| 403 | + | // The encoding %NULL is safe to use with binary data. | |
| 404 | + | // | |
| 405 | + | // The encoding can only be set if one of the following conditions | |
| 406 | + | // is true: | |
| 407 | + | // | |
| 408 | + | // - The channel was just created, and has not been written to or read from yet. | |
| 409 | + | // | |
| 410 | + | // - The channel is write-only. | |
| 411 | + | // | |
| 412 | + | // - The channel is a file, and the file pointer was just repositioned | |
| 413 | + | // by a call to g_io_channel_seek_position(). (This flushes all the | |
| 414 | + | // internal buffers.) | |
| 415 | + | // | |
| 416 | + | // - The current encoding is %NULL or UTF-8. | |
| 417 | + | // | |
| 418 | + | // - One of the (new API) read functions has just returned %G_IO_STATUS_EOF | |
| 419 | + | // (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL). | |
| 420 | + | // | |
| 421 | + | // - One of the functions g_io_channel_read_chars() or | |
| 422 | + | // g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or | |
| 423 | + | // %G_IO_STATUS_ERROR. This may be useful in the case of | |
| 424 | + | // %G_CONVERT_ERROR_ILLEGAL_SEQUENCE. | |
| 425 | + | // Returning one of these statuses from g_io_channel_read_line(), | |
| 426 | + | // g_io_channel_read_line_string(), or g_io_channel_read_to_end() | |
| 427 | + | // does not guarantee that the encoding can be changed. | |
| 428 | + | // | |
| 429 | + | // Channels which do not meet one of the above conditions cannot call | |
| 430 | + | // g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if | |
| 431 | + | // they are "seekable", cannot call g_io_channel_write_chars() after | |
| 432 | + | // calling one of the API "read" functions. | |
| 433 | + | func (x *IOChannel) SetEncoding(EncodingVar string) (IOStatus, error) { | |
| 434 | + | var cerr *Error | |
| 435 | + | ||
| 436 | + | cret := xIOChannelSetEncoding(x.GoPointer(), EncodingVar, &cerr) | |
| 437 | + | if cerr == nil { | |
| 438 | + | return cret, nil | |
| 439 | + | } | |
| 440 | + | return cret, cerr | |
| 441 | + | ||
| 442 | + | } | |
| 443 | + | ||
| 444 | + | var xIOChannelSetFlags func(uintptr, IOFlags, **Error) IOStatus | |
| 445 | + | ||
| 446 | + | // Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK). | |
| 447 | + | func (x *IOChannel) SetFlags(FlagsVar IOFlags) (IOStatus, error) { | |
| 448 | + | var cerr *Error | |
| 449 | + | ||
| 450 | + | cret := xIOChannelSetFlags(x.GoPointer(), FlagsVar, &cerr) | |
| 451 | + | if cerr == nil { | |
| 452 | + | return cret, nil | |
| 453 | + | } | |
| 454 | + | return cret, cerr | |
| 455 | + | ||
| 456 | + | } | |
| 457 | + | ||
| 458 | + | var xIOChannelSetLineTerm func(uintptr, string, int) | |
| 459 | + | ||
| 460 | + | // This sets the string that #GIOChannel uses to determine | |
| 461 | + | // where in the file a line break occurs. | |
| 462 | + | func (x *IOChannel) SetLineTerm(LineTermVar string, LengthVar int) { | |
| 463 | + | ||
| 464 | + | xIOChannelSetLineTerm(x.GoPointer(), LineTermVar, LengthVar) | |
| 465 | + | ||
| 466 | + | } | |
| 467 | + | ||
| 468 | + | var xIOChannelShutdown func(uintptr, bool, **Error) IOStatus | |
| 469 | + | ||
| 470 | + | // Close an IO channel. Any pending data to be written will be | |
| 471 | + | // flushed if @flush is %TRUE. The channel will not be freed until the | |
| 472 | + | // last reference is dropped using g_io_channel_unref(). | |
| 473 | + | func (x *IOChannel) Shutdown(FlushVar bool) (IOStatus, error) { | |
| 474 | + | var cerr *Error | |
| 475 | + | ||
| 476 | + | cret := xIOChannelShutdown(x.GoPointer(), FlushVar, &cerr) | |
| 477 | + | if cerr == nil { | |
| 478 | + | return cret, nil | |
| 479 | + | } | |
| 480 | + | return cret, cerr | |
| 481 | + | ||
| 482 | + | } | |
| 483 | + | ||
| 484 | + | var xIOChannelUnixGetFd func(uintptr) int | |
| 485 | + | ||
| 486 | + | // Returns the file descriptor of the #GIOChannel. | |
| 487 | + | // | |
| 488 | + | // On Windows this function returns the file descriptor or socket of | |
| 489 | + | // the #GIOChannel. | |
| 490 | + | func (x *IOChannel) UnixGetFd() int { | |
| 491 | + | ||
| 492 | + | cret := xIOChannelUnixGetFd(x.GoPointer()) | |
| 493 | + | return cret | |
| 494 | + | } | |
| 495 | + | ||
| 496 | + | var xIOChannelUnref func(uintptr) | |
| 497 | + | ||
| 498 | + | // Decrements the reference count of a #GIOChannel. | |
| 499 | + | func (x *IOChannel) Unref() { | |
| 500 | + | ||
| 501 | + | xIOChannelUnref(x.GoPointer()) | |
| 502 | + | ||
| 503 | + | } | |
| 504 | + | ||
| 505 | + | var xIOChannelWrite func(uintptr, string, uint, uint) IOError | |
| 506 | + | ||
| 507 | + | // Writes data to a #GIOChannel. | |
| 508 | + | func (x *IOChannel) Write(BufVar string, CountVar uint, BytesWrittenVar uint) IOError { | |
| 509 | + | ||
| 510 | + | cret := xIOChannelWrite(x.GoPointer(), BufVar, CountVar, BytesWrittenVar) | |
| 511 | + | return cret | |
| 512 | + | } | |
| 513 | + | ||
| 514 | + | var xIOChannelWriteChars func(uintptr, uintptr, int, uint, **Error) IOStatus | |
| 515 | + | ||
| 516 | + | // Replacement for g_io_channel_write() with the new API. | |
| 517 | + | // | |
| 518 | + | // On seekable channels with encodings other than %NULL or UTF-8, generic | |
| 519 | + | // mixing of reading and writing is not allowed. A call to g_io_channel_write_chars () | |
| 520 | + | // may only be made on a channel from which data has been read in the | |
| 521 | + | // cases described in the documentation for g_io_channel_set_encoding (). | |
| 522 | + | func (x *IOChannel) WriteChars(BufVar uintptr, CountVar int, BytesWrittenVar uint) (IOStatus, error) { | |
| 523 | + | var cerr *Error | |
| 524 | + | ||
| 525 | + | cret := xIOChannelWriteChars(x.GoPointer(), BufVar, CountVar, BytesWrittenVar, &cerr) | |
| 526 | + | if cerr == nil { | |
| 527 | + | return cret, nil | |
| 528 | + | } | |
| 529 | + | return cret, cerr | |
| 530 | + | ||
| 531 | + | } | |
| 532 | + | ||
| 533 | + | var xIOChannelWriteUnichar func(uintptr, uint32, **Error) IOStatus | |
| 534 | + | ||
| 535 | + | // Writes a Unicode character to @channel. | |
| 536 | + | // This function cannot be called on a channel with %NULL encoding. | |
| 537 | + | func (x *IOChannel) WriteUnichar(ThecharVar uint32) (IOStatus, error) { | |
| 538 | + | var cerr *Error | |
| 539 | + | ||
| 540 | + | cret := xIOChannelWriteUnichar(x.GoPointer(), ThecharVar, &cerr) | |
| 541 | + | if cerr == nil { | |
| 542 | + | return cret, nil | |
| 543 | + | } | |
| 544 | + | return cret, cerr | |
| 545 | + | ||
| 546 | + | } | |
| 547 | + | ||
| 59 | 548 | // A table of functions used to handle different types of #GIOChannel | |
| 60 | 549 | // in a generic way. | |
| 61 | 550 | type IOFuncs struct { | |
| 62 | 551 | } | |
| 63 | 552 | ||
| 553 | + | func (x *IOFuncs) GoPointer() uintptr { | |
| 554 | + | return uintptr(unsafe.Pointer(x)) | |
| 555 | + | } | |
| 556 | + | ||
| 557 | + | const ( | |
| 558 | + | WIN32_MSG_HANDLE int = 19981206 | |
| 559 | + | ) | |
| 560 | + | ||
| 64 | 561 | // Specifies properties of a #GIOChannel. Some of the flags can only be | |
| 65 | 562 | // read with g_io_channel_get_flags(), but not changed with | |
| 66 | 563 | // g_io_channel_set_flags(). | |
| @@ -234,4 +731,39 @@ func init() { | |||
| 234 | 731 | core.PuregoSafeRegister(&xIoChannelErrorFromErrno, lib, "g_io_channel_error_from_errno") | |
| 235 | 732 | core.PuregoSafeRegister(&xIoCreateWatch, lib, "g_io_create_watch") | |
| 236 | 733 | ||
| 734 | + | core.PuregoSafeRegister(&xNewFileIOChannel, lib, "g_io_channel_new_file") | |
| 735 | + | core.PuregoSafeRegister(&xUnixNewIOChannel, lib, "g_io_channel_unix_new") | |
| 736 | + | ||
| 737 | + | core.PuregoSafeRegister(&xIOChannelClose, lib, "g_io_channel_close") | |
| 738 | + | core.PuregoSafeRegister(&xIOChannelFlush, lib, "g_io_channel_flush") | |
| 739 | + | core.PuregoSafeRegister(&xIOChannelGetBufferCondition, lib, "g_io_channel_get_buffer_condition") | |
| 740 | + | core.PuregoSafeRegister(&xIOChannelGetBufferSize, lib, "g_io_channel_get_buffer_size") | |
| 741 | + | core.PuregoSafeRegister(&xIOChannelGetBuffered, lib, "g_io_channel_get_buffered") | |
| 742 | + | core.PuregoSafeRegister(&xIOChannelGetCloseOnUnref, lib, "g_io_channel_get_close_on_unref") | |
| 743 | + | core.PuregoSafeRegister(&xIOChannelGetEncoding, lib, "g_io_channel_get_encoding") | |
| 744 | + | core.PuregoSafeRegister(&xIOChannelGetFlags, lib, "g_io_channel_get_flags") | |
| 745 | + | core.PuregoSafeRegister(&xIOChannelGetLineTerm, lib, "g_io_channel_get_line_term") | |
| 746 | + | core.PuregoSafeRegister(&xIOChannelInit, lib, "g_io_channel_init") | |
| 747 | + | core.PuregoSafeRegister(&xIOChannelRead, lib, "g_io_channel_read") | |
| 748 | + | core.PuregoSafeRegister(&xIOChannelReadChars, lib, "g_io_channel_read_chars") | |
| 749 | + | core.PuregoSafeRegister(&xIOChannelReadLine, lib, "g_io_channel_read_line") | |
| 750 | + | core.PuregoSafeRegister(&xIOChannelReadLineString, lib, "g_io_channel_read_line_string") | |
| 751 | + | core.PuregoSafeRegister(&xIOChannelReadToEnd, lib, "g_io_channel_read_to_end") | |
| 752 | + | core.PuregoSafeRegister(&xIOChannelReadUnichar, lib, "g_io_channel_read_unichar") | |
| 753 | + | core.PuregoSafeRegister(&xIOChannelRef, lib, "g_io_channel_ref") | |
| 754 | + | core.PuregoSafeRegister(&xIOChannelSeek, lib, "g_io_channel_seek") | |
| 755 | + | core.PuregoSafeRegister(&xIOChannelSeekPosition, lib, "g_io_channel_seek_position") | |
| 756 | + | core.PuregoSafeRegister(&xIOChannelSetBufferSize, lib, "g_io_channel_set_buffer_size") | |
| 757 | + | core.PuregoSafeRegister(&xIOChannelSetBuffered, lib, "g_io_channel_set_buffered") | |
| 758 | + | core.PuregoSafeRegister(&xIOChannelSetCloseOnUnref, lib, "g_io_channel_set_close_on_unref") | |
| 759 | + | core.PuregoSafeRegister(&xIOChannelSetEncoding, lib, "g_io_channel_set_encoding") | |
| 760 | + | core.PuregoSafeRegister(&xIOChannelSetFlags, lib, "g_io_channel_set_flags") | |
| 761 | + | core.PuregoSafeRegister(&xIOChannelSetLineTerm, lib, "g_io_channel_set_line_term") | |
| 762 | + | core.PuregoSafeRegister(&xIOChannelShutdown, lib, "g_io_channel_shutdown") | |
| 763 | + | core.PuregoSafeRegister(&xIOChannelUnixGetFd, lib, "g_io_channel_unix_get_fd") | |
| 764 | + | core.PuregoSafeRegister(&xIOChannelUnref, lib, "g_io_channel_unref") | |
| 765 | + | core.PuregoSafeRegister(&xIOChannelWrite, lib, "g_io_channel_write") | |
| 766 | + | core.PuregoSafeRegister(&xIOChannelWriteChars, lib, "g_io_channel_write_chars") | |
| 767 | + | core.PuregoSafeRegister(&xIOChannelWriteUnichar, lib, "g_io_channel_write_unichar") | |
| 768 | + | ||
| 237 | 769 | } | |
M v4/glib/gkeyfile.go +931 -0
| @@ -1,11 +1,883 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // The GKeyFile struct contains only private data | |
| 5 | 12 | // and should not be accessed directly. | |
| 6 | 13 | type KeyFile struct { | |
| 7 | 14 | } | |
| 8 | 15 | ||
| 16 | + | func (x *KeyFile) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xNewKeyFile func() *KeyFile | |
| 21 | + | ||
| 22 | + | // Creates a new empty #GKeyFile object. Use | |
| 23 | + | // g_key_file_load_from_file(), g_key_file_load_from_data(), | |
| 24 | + | // g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to | |
| 25 | + | // read an existing key file. | |
| 26 | + | func NewKeyFile() *KeyFile { | |
| 27 | + | ||
| 28 | + | cret := xNewKeyFile() | |
| 29 | + | return cret | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | var xKeyFileFree func(uintptr) | |
| 33 | + | ||
| 34 | + | // Clears all keys and groups from @key_file, and decreases the | |
| 35 | + | // reference count by 1. If the reference count reaches zero, | |
| 36 | + | // frees the key file and all its allocated memory. | |
| 37 | + | func (x *KeyFile) Free() { | |
| 38 | + | ||
| 39 | + | xKeyFileFree(x.GoPointer()) | |
| 40 | + | ||
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xKeyFileGetBoolean func(uintptr, string, string, **Error) bool | |
| 44 | + | ||
| 45 | + | // Returns the value associated with @key under @group_name as a | |
| 46 | + | // boolean. | |
| 47 | + | // | |
| 48 | + | // If @key cannot be found then %FALSE is returned and @error is set | |
| 49 | + | // to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value | |
| 50 | + | // associated with @key cannot be interpreted as a boolean then %FALSE | |
| 51 | + | // is returned and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 52 | + | func (x *KeyFile) GetBoolean(GroupNameVar string, KeyVar string) (bool, error) { | |
| 53 | + | var cerr *Error | |
| 54 | + | ||
| 55 | + | cret := xKeyFileGetBoolean(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 56 | + | if cerr == nil { | |
| 57 | + | return cret, nil | |
| 58 | + | } | |
| 59 | + | return cret, cerr | |
| 60 | + | ||
| 61 | + | } | |
| 62 | + | ||
| 63 | + | var xKeyFileGetBooleanList func(uintptr, string, string, uint, **Error) uintptr | |
| 64 | + | ||
| 65 | + | // Returns the values associated with @key under @group_name as | |
| 66 | + | // booleans. | |
| 67 | + | // | |
| 68 | + | // If @key cannot be found then %NULL is returned and @error is set to | |
| 69 | + | // %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated | |
| 70 | + | // with @key cannot be interpreted as booleans then %NULL is returned | |
| 71 | + | // and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 72 | + | func (x *KeyFile) GetBooleanList(GroupNameVar string, KeyVar string, LengthVar uint) (uintptr, error) { | |
| 73 | + | var cerr *Error | |
| 74 | + | ||
| 75 | + | cret := xKeyFileGetBooleanList(x.GoPointer(), GroupNameVar, KeyVar, LengthVar, &cerr) | |
| 76 | + | if cerr == nil { | |
| 77 | + | return cret, nil | |
| 78 | + | } | |
| 79 | + | return cret, cerr | |
| 80 | + | ||
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xKeyFileGetComment func(uintptr, string, string, **Error) string | |
| 84 | + | ||
| 85 | + | // Retrieves a comment above @key from @group_name. | |
| 86 | + | // If @key is %NULL then @comment will be read from above | |
| 87 | + | // @group_name. If both @key and @group_name are %NULL, then | |
| 88 | + | // @comment will be read from above the first group in the file. | |
| 89 | + | // | |
| 90 | + | // Note that the returned string does not include the '#' comment markers, | |
| 91 | + | // but does include any whitespace after them (on each line). It includes | |
| 92 | + | // the line breaks between lines, but does not include the final line break. | |
| 93 | + | func (x *KeyFile) GetComment(GroupNameVar string, KeyVar string) (string, error) { | |
| 94 | + | var cerr *Error | |
| 95 | + | ||
| 96 | + | cret := xKeyFileGetComment(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 97 | + | if cerr == nil { | |
| 98 | + | return cret, nil | |
| 99 | + | } | |
| 100 | + | return cret, cerr | |
| 101 | + | ||
| 102 | + | } | |
| 103 | + | ||
| 104 | + | var xKeyFileGetDouble func(uintptr, string, string, **Error) float64 | |
| 105 | + | ||
| 106 | + | // Returns the value associated with @key under @group_name as a | |
| 107 | + | // double. If @group_name is %NULL, the start_group is used. | |
| 108 | + | // | |
| 109 | + | // If @key cannot be found then 0.0 is returned and @error is set to | |
| 110 | + | // %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated | |
| 111 | + | // with @key cannot be interpreted as a double then 0.0 is returned | |
| 112 | + | // and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 113 | + | func (x *KeyFile) GetDouble(GroupNameVar string, KeyVar string) (float64, error) { | |
| 114 | + | var cerr *Error | |
| 115 | + | ||
| 116 | + | cret := xKeyFileGetDouble(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 117 | + | if cerr == nil { | |
| 118 | + | return cret, nil | |
| 119 | + | } | |
| 120 | + | return cret, cerr | |
| 121 | + | ||
| 122 | + | } | |
| 123 | + | ||
| 124 | + | var xKeyFileGetDoubleList func(uintptr, string, string, uint, **Error) uintptr | |
| 125 | + | ||
| 126 | + | // Returns the values associated with @key under @group_name as | |
| 127 | + | // doubles. | |
| 128 | + | // | |
| 129 | + | // If @key cannot be found then %NULL is returned and @error is set to | |
| 130 | + | // %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated | |
| 131 | + | // with @key cannot be interpreted as doubles then %NULL is returned | |
| 132 | + | // and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 133 | + | func (x *KeyFile) GetDoubleList(GroupNameVar string, KeyVar string, LengthVar uint) (uintptr, error) { | |
| 134 | + | var cerr *Error | |
| 135 | + | ||
| 136 | + | cret := xKeyFileGetDoubleList(x.GoPointer(), GroupNameVar, KeyVar, LengthVar, &cerr) | |
| 137 | + | if cerr == nil { | |
| 138 | + | return cret, nil | |
| 139 | + | } | |
| 140 | + | return cret, cerr | |
| 141 | + | ||
| 142 | + | } | |
| 143 | + | ||
| 144 | + | var xKeyFileGetGroups func(uintptr, uint) uintptr | |
| 145 | + | ||
| 146 | + | // Returns all groups in the key file loaded with @key_file. | |
| 147 | + | // The array of returned groups will be %NULL-terminated, so | |
| 148 | + | // @length may optionally be %NULL. | |
| 149 | + | func (x *KeyFile) GetGroups(LengthVar uint) uintptr { | |
| 150 | + | ||
| 151 | + | cret := xKeyFileGetGroups(x.GoPointer(), LengthVar) | |
| 152 | + | return cret | |
| 153 | + | } | |
| 154 | + | ||
| 155 | + | var xKeyFileGetInt64 func(uintptr, string, string, **Error) int64 | |
| 156 | + | ||
| 157 | + | // Returns the value associated with @key under @group_name as a signed | |
| 158 | + | // 64-bit integer. This is similar to g_key_file_get_integer() but can return | |
| 159 | + | // 64-bit results without truncation. | |
| 160 | + | func (x *KeyFile) GetInt64(GroupNameVar string, KeyVar string) (int64, error) { | |
| 161 | + | var cerr *Error | |
| 162 | + | ||
| 163 | + | cret := xKeyFileGetInt64(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 164 | + | if cerr == nil { | |
| 165 | + | return cret, nil | |
| 166 | + | } | |
| 167 | + | return cret, cerr | |
| 168 | + | ||
| 169 | + | } | |
| 170 | + | ||
| 171 | + | var xKeyFileGetInteger func(uintptr, string, string, **Error) int | |
| 172 | + | ||
| 173 | + | // Returns the value associated with @key under @group_name as an | |
| 174 | + | // integer. | |
| 175 | + | // | |
| 176 | + | // If @key cannot be found then 0 is returned and @error is set to | |
| 177 | + | // %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated | |
| 178 | + | // with @key cannot be interpreted as an integer, or is out of range | |
| 179 | + | // for a #gint, then 0 is returned | |
| 180 | + | // and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 181 | + | func (x *KeyFile) GetInteger(GroupNameVar string, KeyVar string) (int, error) { | |
| 182 | + | var cerr *Error | |
| 183 | + | ||
| 184 | + | cret := xKeyFileGetInteger(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 185 | + | if cerr == nil { | |
| 186 | + | return cret, nil | |
| 187 | + | } | |
| 188 | + | return cret, cerr | |
| 189 | + | ||
| 190 | + | } | |
| 191 | + | ||
| 192 | + | var xKeyFileGetIntegerList func(uintptr, string, string, uint, **Error) uintptr | |
| 193 | + | ||
| 194 | + | // Returns the values associated with @key under @group_name as | |
| 195 | + | // integers. | |
| 196 | + | // | |
| 197 | + | // If @key cannot be found then %NULL is returned and @error is set to | |
| 198 | + | // %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated | |
| 199 | + | // with @key cannot be interpreted as integers, or are out of range for | |
| 200 | + | // #gint, then %NULL is returned | |
| 201 | + | // and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE. | |
| 202 | + | func (x *KeyFile) GetIntegerList(GroupNameVar string, KeyVar string, LengthVar uint) (uintptr, error) { | |
| 203 | + | var cerr *Error | |
| 204 | + | ||
| 205 | + | cret := xKeyFileGetIntegerList(x.GoPointer(), GroupNameVar, KeyVar, LengthVar, &cerr) | |
| 206 | + | if cerr == nil { | |
| 207 | + | return cret, nil | |
| 208 | + | } | |
| 209 | + | return cret, cerr | |
| 210 | + | ||
| 211 | + | } | |
| 212 | + | ||
| 213 | + | var xKeyFileGetKeys func(uintptr, string, uint, **Error) uintptr | |
| 214 | + | ||
| 215 | + | // Returns all keys for the group name @group_name. The array of | |
| 216 | + | // returned keys will be %NULL-terminated, so @length may | |
| 217 | + | // optionally be %NULL. In the event that the @group_name cannot | |
| 218 | + | // be found, %NULL is returned and @error is set to | |
| 219 | + | // %G_KEY_FILE_ERROR_GROUP_NOT_FOUND. | |
| 220 | + | func (x *KeyFile) GetKeys(GroupNameVar string, LengthVar uint) (uintptr, error) { | |
| 221 | + | var cerr *Error | |
| 222 | + | ||
| 223 | + | cret := xKeyFileGetKeys(x.GoPointer(), GroupNameVar, LengthVar, &cerr) | |
| 224 | + | if cerr == nil { | |
| 225 | + | return cret, nil | |
| 226 | + | } | |
| 227 | + | return cret, cerr | |
| 228 | + | ||
| 229 | + | } | |
| 230 | + | ||
| 231 | + | var xKeyFileGetLocaleForKey func(uintptr, string, string, string) string | |
| 232 | + | ||
| 233 | + | // Returns the actual locale which the result of | |
| 234 | + | // g_key_file_get_locale_string() or g_key_file_get_locale_string_list() | |
| 235 | + | // came from. | |
| 236 | + | // | |
| 237 | + | // If calling g_key_file_get_locale_string() or | |
| 238 | + | // g_key_file_get_locale_string_list() with exactly the same @key_file, | |
| 239 | + | // @group_name, @key and @locale, the result of those functions will | |
| 240 | + | // have originally been tagged with the locale that is the result of | |
| 241 | + | // this function. | |
| 242 | + | func (x *KeyFile) GetLocaleForKey(GroupNameVar string, KeyVar string, LocaleVar string) string { | |
| 243 | + | ||
| 244 | + | cret := xKeyFileGetLocaleForKey(x.GoPointer(), GroupNameVar, KeyVar, LocaleVar) | |
| 245 | + | return cret | |
| 246 | + | } | |
| 247 | + | ||
| 248 | + | var xKeyFileGetLocaleString func(uintptr, string, string, string, **Error) string | |
| 249 | + | ||
| 250 | + | // Returns the value associated with @key under @group_name | |
| 251 | + | // translated in the given @locale if available. If @locale is | |
| 252 | + | // %NULL then the current locale is assumed. | |
| 253 | + | // | |
| 254 | + | // If @locale is to be non-%NULL, or if the current locale will change over | |
| 255 | + | // the lifetime of the #GKeyFile, it must be loaded with | |
| 256 | + | // %G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales. | |
| 257 | + | // | |
| 258 | + | // If @key cannot be found then %NULL is returned and @error is set | |
| 259 | + | // to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated | |
| 260 | + | // with @key cannot be interpreted or no suitable translation can | |
| 261 | + | // be found then the untranslated value is returned. | |
| 262 | + | func (x *KeyFile) GetLocaleString(GroupNameVar string, KeyVar string, LocaleVar string) (string, error) { | |
| 263 | + | var cerr *Error | |
| 264 | + | ||
| 265 | + | cret := xKeyFileGetLocaleString(x.GoPointer(), GroupNameVar, KeyVar, LocaleVar, &cerr) | |
| 266 | + | if cerr == nil { | |
| 267 | + | return cret, nil | |
| 268 | + | } | |
| 269 | + | return cret, cerr | |
| 270 | + | ||
| 271 | + | } | |
| 272 | + | ||
| 273 | + | var xKeyFileGetLocaleStringList func(uintptr, string, string, string, uint, **Error) uintptr | |
| 274 | + | ||
| 275 | + | // Returns the values associated with @key under @group_name | |
| 276 | + | // translated in the given @locale if available. If @locale is | |
| 277 | + | // %NULL then the current locale is assumed. | |
| 278 | + | // | |
| 279 | + | // If @locale is to be non-%NULL, or if the current locale will change over | |
| 280 | + | // the lifetime of the #GKeyFile, it must be loaded with | |
| 281 | + | // %G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales. | |
| 282 | + | // | |
| 283 | + | // If @key cannot be found then %NULL is returned and @error is set | |
| 284 | + | // to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated | |
| 285 | + | // with @key cannot be interpreted or no suitable translations | |
| 286 | + | // can be found then the untranslated values are returned. The | |
| 287 | + | // returned array is %NULL-terminated, so @length may optionally | |
| 288 | + | // be %NULL. | |
| 289 | + | func (x *KeyFile) GetLocaleStringList(GroupNameVar string, KeyVar string, LocaleVar string, LengthVar uint) (uintptr, error) { | |
| 290 | + | var cerr *Error | |
| 291 | + | ||
| 292 | + | cret := xKeyFileGetLocaleStringList(x.GoPointer(), GroupNameVar, KeyVar, LocaleVar, LengthVar, &cerr) | |
| 293 | + | if cerr == nil { | |
| 294 | + | return cret, nil | |
| 295 | + | } | |
| 296 | + | return cret, cerr | |
| 297 | + | ||
| 298 | + | } | |
| 299 | + | ||
| 300 | + | var xKeyFileGetStartGroup func(uintptr) string | |
| 301 | + | ||
| 302 | + | // Returns the name of the start group of the file. | |
| 303 | + | func (x *KeyFile) GetStartGroup() string { | |
| 304 | + | ||
| 305 | + | cret := xKeyFileGetStartGroup(x.GoPointer()) | |
| 306 | + | return cret | |
| 307 | + | } | |
| 308 | + | ||
| 309 | + | var xKeyFileGetString func(uintptr, string, string, **Error) string | |
| 310 | + | ||
| 311 | + | // Returns the string value associated with @key under @group_name. | |
| 312 | + | // Unlike g_key_file_get_value(), this function handles escape sequences | |
| 313 | + | // like \s. | |
| 314 | + | // | |
| 315 | + | // In the event the key cannot be found, %NULL is returned and | |
| 316 | + | // @error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the | |
| 317 | + | // event that the @group_name cannot be found, %NULL is returned | |
| 318 | + | // and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND. | |
| 319 | + | func (x *KeyFile) GetString(GroupNameVar string, KeyVar string) (string, error) { | |
| 320 | + | var cerr *Error | |
| 321 | + | ||
| 322 | + | cret := xKeyFileGetString(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 323 | + | if cerr == nil { | |
| 324 | + | return cret, nil | |
| 325 | + | } | |
| 326 | + | return cret, cerr | |
| 327 | + | ||
| 328 | + | } | |
| 329 | + | ||
| 330 | + | var xKeyFileGetStringList func(uintptr, string, string, uint, **Error) uintptr | |
| 331 | + | ||
| 332 | + | // Returns the values associated with @key under @group_name. | |
| 333 | + | // | |
| 334 | + | // In the event the key cannot be found, %NULL is returned and | |
| 335 | + | // @error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the | |
| 336 | + | // event that the @group_name cannot be found, %NULL is returned | |
| 337 | + | // and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND. | |
| 338 | + | func (x *KeyFile) GetStringList(GroupNameVar string, KeyVar string, LengthVar uint) (uintptr, error) { | |
| 339 | + | var cerr *Error | |
| 340 | + | ||
| 341 | + | cret := xKeyFileGetStringList(x.GoPointer(), GroupNameVar, KeyVar, LengthVar, &cerr) | |
| 342 | + | if cerr == nil { | |
| 343 | + | return cret, nil | |
| 344 | + | } | |
| 345 | + | return cret, cerr | |
| 346 | + | ||
| 347 | + | } | |
| 348 | + | ||
| 349 | + | var xKeyFileGetUint64 func(uintptr, string, string, **Error) uint64 | |
| 350 | + | ||
| 351 | + | // Returns the value associated with @key under @group_name as an unsigned | |
| 352 | + | // 64-bit integer. This is similar to g_key_file_get_integer() but can return | |
| 353 | + | // large positive results without truncation. | |
| 354 | + | func (x *KeyFile) GetUint64(GroupNameVar string, KeyVar string) (uint64, error) { | |
| 355 | + | var cerr *Error | |
| 356 | + | ||
| 357 | + | cret := xKeyFileGetUint64(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 358 | + | if cerr == nil { | |
| 359 | + | return cret, nil | |
| 360 | + | } | |
| 361 | + | return cret, cerr | |
| 362 | + | ||
| 363 | + | } | |
| 364 | + | ||
| 365 | + | var xKeyFileGetValue func(uintptr, string, string, **Error) string | |
| 366 | + | ||
| 367 | + | // Returns the raw value associated with @key under @group_name. | |
| 368 | + | // Use g_key_file_get_string() to retrieve an unescaped UTF-8 string. | |
| 369 | + | // | |
| 370 | + | // In the event the key cannot be found, %NULL is returned and | |
| 371 | + | // @error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the | |
| 372 | + | // event that the @group_name cannot be found, %NULL is returned | |
| 373 | + | // and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND. | |
| 374 | + | func (x *KeyFile) GetValue(GroupNameVar string, KeyVar string) (string, error) { | |
| 375 | + | var cerr *Error | |
| 376 | + | ||
| 377 | + | cret := xKeyFileGetValue(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 378 | + | if cerr == nil { | |
| 379 | + | return cret, nil | |
| 380 | + | } | |
| 381 | + | return cret, cerr | |
| 382 | + | ||
| 383 | + | } | |
| 384 | + | ||
| 385 | + | var xKeyFileHasGroup func(uintptr, string) bool | |
| 386 | + | ||
| 387 | + | // Looks whether the key file has the group @group_name. | |
| 388 | + | func (x *KeyFile) HasGroup(GroupNameVar string) bool { | |
| 389 | + | ||
| 390 | + | cret := xKeyFileHasGroup(x.GoPointer(), GroupNameVar) | |
| 391 | + | return cret | |
| 392 | + | } | |
| 393 | + | ||
| 394 | + | var xKeyFileHasKey func(uintptr, string, string, **Error) bool | |
| 395 | + | ||
| 396 | + | // Looks whether the key file has the key @key in the group | |
| 397 | + | // @group_name. | |
| 398 | + | // | |
| 399 | + | // Note that this function does not follow the rules for #GError strictly; | |
| 400 | + | // the return value both carries meaning and signals an error. To use | |
| 401 | + | // this function, you must pass a #GError pointer in @error, and check | |
| 402 | + | // whether it is not %NULL to see if an error occurred. | |
| 403 | + | // | |
| 404 | + | // Language bindings should use g_key_file_get_value() to test whether | |
| 405 | + | // or not a key exists. | |
| 406 | + | func (x *KeyFile) HasKey(GroupNameVar string, KeyVar string) (bool, error) { | |
| 407 | + | var cerr *Error | |
| 408 | + | ||
| 409 | + | cret := xKeyFileHasKey(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 410 | + | if cerr == nil { | |
| 411 | + | return cret, nil | |
| 412 | + | } | |
| 413 | + | return cret, cerr | |
| 414 | + | ||
| 415 | + | } | |
| 416 | + | ||
| 417 | + | var xKeyFileLoadFromBytes func(uintptr, *Bytes, KeyFileFlags, **Error) bool | |
| 418 | + | ||
| 419 | + | // Loads a key file from the data in @bytes into an empty #GKeyFile structure. | |
| 420 | + | // If the object cannot be created then %error is set to a #GKeyFileError. | |
| 421 | + | func (x *KeyFile) LoadFromBytes(BytesVar *Bytes, FlagsVar KeyFileFlags) (bool, error) { | |
| 422 | + | var cerr *Error | |
| 423 | + | ||
| 424 | + | cret := xKeyFileLoadFromBytes(x.GoPointer(), BytesVar, FlagsVar, &cerr) | |
| 425 | + | if cerr == nil { | |
| 426 | + | return cret, nil | |
| 427 | + | } | |
| 428 | + | return cret, cerr | |
| 429 | + | ||
| 430 | + | } | |
| 431 | + | ||
| 432 | + | var xKeyFileLoadFromData func(uintptr, string, uint, KeyFileFlags, **Error) bool | |
| 433 | + | ||
| 434 | + | // Loads a key file from memory into an empty #GKeyFile structure. | |
| 435 | + | // If the object cannot be created then %error is set to a #GKeyFileError. | |
| 436 | + | func (x *KeyFile) LoadFromData(DataVar string, LengthVar uint, FlagsVar KeyFileFlags) (bool, error) { | |
| 437 | + | var cerr *Error | |
| 438 | + | ||
| 439 | + | cret := xKeyFileLoadFromData(x.GoPointer(), DataVar, LengthVar, FlagsVar, &cerr) | |
| 440 | + | if cerr == nil { | |
| 441 | + | return cret, nil | |
| 442 | + | } | |
| 443 | + | return cret, cerr | |
| 444 | + | ||
| 445 | + | } | |
| 446 | + | ||
| 447 | + | var xKeyFileLoadFromDataDirs func(uintptr, string, string, KeyFileFlags, **Error) bool | |
| 448 | + | ||
| 449 | + | // This function looks for a key file named @file in the paths | |
| 450 | + | // returned from g_get_user_data_dir() and g_get_system_data_dirs(), | |
| 451 | + | // loads the file into @key_file and returns the file's full path in | |
| 452 | + | // @full_path. If the file could not be loaded then an %error is | |
| 453 | + | // set to either a #GFileError or #GKeyFileError. | |
| 454 | + | func (x *KeyFile) LoadFromDataDirs(FileVar string, FullPathVar string, FlagsVar KeyFileFlags) (bool, error) { | |
| 455 | + | var cerr *Error | |
| 456 | + | ||
| 457 | + | cret := xKeyFileLoadFromDataDirs(x.GoPointer(), FileVar, FullPathVar, FlagsVar, &cerr) | |
| 458 | + | if cerr == nil { | |
| 459 | + | return cret, nil | |
| 460 | + | } | |
| 461 | + | return cret, cerr | |
| 462 | + | ||
| 463 | + | } | |
| 464 | + | ||
| 465 | + | var xKeyFileLoadFromDirs func(uintptr, string, uintptr, string, KeyFileFlags, **Error) bool | |
| 466 | + | ||
| 467 | + | // This function looks for a key file named @file in the paths | |
| 468 | + | // specified in @search_dirs, loads the file into @key_file and | |
| 469 | + | // returns the file's full path in @full_path. | |
| 470 | + | // | |
| 471 | + | // If the file could not be found in any of the @search_dirs, | |
| 472 | + | // %G_KEY_FILE_ERROR_NOT_FOUND is returned. If | |
| 473 | + | // the file is found but the OS returns an error when opening or reading the | |
| 474 | + | // file, a %G_FILE_ERROR is returned. If there is a problem parsing the file, a | |
| 475 | + | // %G_KEY_FILE_ERROR is returned. | |
| 476 | + | func (x *KeyFile) LoadFromDirs(FileVar string, SearchDirsVar uintptr, FullPathVar string, FlagsVar KeyFileFlags) (bool, error) { | |
| 477 | + | var cerr *Error | |
| 478 | + | ||
| 479 | + | cret := xKeyFileLoadFromDirs(x.GoPointer(), FileVar, SearchDirsVar, FullPathVar, FlagsVar, &cerr) | |
| 480 | + | if cerr == nil { | |
| 481 | + | return cret, nil | |
| 482 | + | } | |
| 483 | + | return cret, cerr | |
| 484 | + | ||
| 485 | + | } | |
| 486 | + | ||
| 487 | + | var xKeyFileLoadFromFile func(uintptr, string, KeyFileFlags, **Error) bool | |
| 488 | + | ||
| 489 | + | // Loads a key file into an empty #GKeyFile structure. | |
| 490 | + | // | |
| 491 | + | // If the OS returns an error when opening or reading the file, a | |
| 492 | + | // %G_FILE_ERROR is returned. If there is a problem parsing the file, a | |
| 493 | + | // %G_KEY_FILE_ERROR is returned. | |
| 494 | + | // | |
| 495 | + | // This function will never return a %G_KEY_FILE_ERROR_NOT_FOUND error. If the | |
| 496 | + | // @file is not found, %G_FILE_ERROR_NOENT is returned. | |
| 497 | + | func (x *KeyFile) LoadFromFile(FileVar string, FlagsVar KeyFileFlags) (bool, error) { | |
| 498 | + | var cerr *Error | |
| 499 | + | ||
| 500 | + | cret := xKeyFileLoadFromFile(x.GoPointer(), FileVar, FlagsVar, &cerr) | |
| 501 | + | if cerr == nil { | |
| 502 | + | return cret, nil | |
| 503 | + | } | |
| 504 | + | return cret, cerr | |
| 505 | + | ||
| 506 | + | } | |
| 507 | + | ||
| 508 | + | var xKeyFileRef func(uintptr) *KeyFile | |
| 509 | + | ||
| 510 | + | // Increases the reference count of @key_file. | |
| 511 | + | func (x *KeyFile) Ref() *KeyFile { | |
| 512 | + | ||
| 513 | + | cret := xKeyFileRef(x.GoPointer()) | |
| 514 | + | return cret | |
| 515 | + | } | |
| 516 | + | ||
| 517 | + | var xKeyFileRemoveComment func(uintptr, string, string, **Error) bool | |
| 518 | + | ||
| 519 | + | // Removes a comment above @key from @group_name. | |
| 520 | + | // If @key is %NULL then @comment will be removed above @group_name. | |
| 521 | + | // If both @key and @group_name are %NULL, then @comment will | |
| 522 | + | // be removed above the first group in the file. | |
| 523 | + | func (x *KeyFile) RemoveComment(GroupNameVar string, KeyVar string) (bool, error) { | |
| 524 | + | var cerr *Error | |
| 525 | + | ||
| 526 | + | cret := xKeyFileRemoveComment(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 527 | + | if cerr == nil { | |
| 528 | + | return cret, nil | |
| 529 | + | } | |
| 530 | + | return cret, cerr | |
| 531 | + | ||
| 532 | + | } | |
| 533 | + | ||
| 534 | + | var xKeyFileRemoveGroup func(uintptr, string, **Error) bool | |
| 535 | + | ||
| 536 | + | // Removes the specified group, @group_name, | |
| 537 | + | // from the key file. | |
| 538 | + | func (x *KeyFile) RemoveGroup(GroupNameVar string) (bool, error) { | |
| 539 | + | var cerr *Error | |
| 540 | + | ||
| 541 | + | cret := xKeyFileRemoveGroup(x.GoPointer(), GroupNameVar, &cerr) | |
| 542 | + | if cerr == nil { | |
| 543 | + | return cret, nil | |
| 544 | + | } | |
| 545 | + | return cret, cerr | |
| 546 | + | ||
| 547 | + | } | |
| 548 | + | ||
| 549 | + | var xKeyFileRemoveKey func(uintptr, string, string, **Error) bool | |
| 550 | + | ||
| 551 | + | // Removes @key in @group_name from the key file. | |
| 552 | + | func (x *KeyFile) RemoveKey(GroupNameVar string, KeyVar string) (bool, error) { | |
| 553 | + | var cerr *Error | |
| 554 | + | ||
| 555 | + | cret := xKeyFileRemoveKey(x.GoPointer(), GroupNameVar, KeyVar, &cerr) | |
| 556 | + | if cerr == nil { | |
| 557 | + | return cret, nil | |
| 558 | + | } | |
| 559 | + | return cret, cerr | |
| 560 | + | ||
| 561 | + | } | |
| 562 | + | ||
| 563 | + | var xKeyFileSaveToFile func(uintptr, string, **Error) bool | |
| 564 | + | ||
| 565 | + | // Writes the contents of @key_file to @filename using | |
| 566 | + | // g_file_set_contents(). If you need stricter guarantees about durability of | |
| 567 | + | // the written file than are provided by g_file_set_contents(), use | |
| 568 | + | // g_file_set_contents_full() with the return value of g_key_file_to_data(). | |
| 569 | + | // | |
| 570 | + | // This function can fail for any of the reasons that | |
| 571 | + | // g_file_set_contents() may fail. | |
| 572 | + | func (x *KeyFile) SaveToFile(FilenameVar string) (bool, error) { | |
| 573 | + | var cerr *Error | |
| 574 | + | ||
| 575 | + | cret := xKeyFileSaveToFile(x.GoPointer(), FilenameVar, &cerr) | |
| 576 | + | if cerr == nil { | |
| 577 | + | return cret, nil | |
| 578 | + | } | |
| 579 | + | return cret, cerr | |
| 580 | + | ||
| 581 | + | } | |
| 582 | + | ||
| 583 | + | var xKeyFileSetBoolean func(uintptr, string, string, bool) | |
| 584 | + | ||
| 585 | + | // Associates a new boolean value with @key under @group_name. | |
| 586 | + | // If @key cannot be found then it is created. | |
| 587 | + | func (x *KeyFile) SetBoolean(GroupNameVar string, KeyVar string, ValueVar bool) { | |
| 588 | + | ||
| 589 | + | xKeyFileSetBoolean(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 590 | + | ||
| 591 | + | } | |
| 592 | + | ||
| 593 | + | var xKeyFileSetBooleanList func(uintptr, string, string, uintptr, uint) | |
| 594 | + | ||
| 595 | + | // Associates a list of boolean values with @key under @group_name. | |
| 596 | + | // If @key cannot be found then it is created. | |
| 597 | + | // If @group_name is %NULL, the start_group is used. | |
| 598 | + | func (x *KeyFile) SetBooleanList(GroupNameVar string, KeyVar string, ListVar uintptr, LengthVar uint) { | |
| 599 | + | ||
| 600 | + | xKeyFileSetBooleanList(x.GoPointer(), GroupNameVar, KeyVar, ListVar, LengthVar) | |
| 601 | + | ||
| 602 | + | } | |
| 603 | + | ||
| 604 | + | var xKeyFileSetComment func(uintptr, string, string, string, **Error) bool | |
| 605 | + | ||
| 606 | + | // Places a comment above @key from @group_name. | |
| 607 | + | // | |
| 608 | + | // If @key is %NULL then @comment will be written above @group_name. | |
| 609 | + | // If both @key and @group_name are %NULL, then @comment will be | |
| 610 | + | // written above the first group in the file. | |
| 611 | + | // | |
| 612 | + | // Note that this function prepends a '#' comment marker to | |
| 613 | + | // each line of @comment. | |
| 614 | + | func (x *KeyFile) SetComment(GroupNameVar string, KeyVar string, CommentVar string) (bool, error) { | |
| 615 | + | var cerr *Error | |
| 616 | + | ||
| 617 | + | cret := xKeyFileSetComment(x.GoPointer(), GroupNameVar, KeyVar, CommentVar, &cerr) | |
| 618 | + | if cerr == nil { | |
| 619 | + | return cret, nil | |
| 620 | + | } | |
| 621 | + | return cret, cerr | |
| 622 | + | ||
| 623 | + | } | |
| 624 | + | ||
| 625 | + | var xKeyFileSetDouble func(uintptr, string, string, float64) | |
| 626 | + | ||
| 627 | + | // Associates a new double value with @key under @group_name. | |
| 628 | + | // If @key cannot be found then it is created. | |
| 629 | + | func (x *KeyFile) SetDouble(GroupNameVar string, KeyVar string, ValueVar float64) { | |
| 630 | + | ||
| 631 | + | xKeyFileSetDouble(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 632 | + | ||
| 633 | + | } | |
| 634 | + | ||
| 635 | + | var xKeyFileSetDoubleList func(uintptr, string, string, uintptr, uint) | |
| 636 | + | ||
| 637 | + | // Associates a list of double values with @key under | |
| 638 | + | // @group_name. If @key cannot be found then it is created. | |
| 639 | + | func (x *KeyFile) SetDoubleList(GroupNameVar string, KeyVar string, ListVar uintptr, LengthVar uint) { | |
| 640 | + | ||
| 641 | + | xKeyFileSetDoubleList(x.GoPointer(), GroupNameVar, KeyVar, ListVar, LengthVar) | |
| 642 | + | ||
| 643 | + | } | |
| 644 | + | ||
| 645 | + | var xKeyFileSetInt64 func(uintptr, string, string, int64) | |
| 646 | + | ||
| 647 | + | // Associates a new integer value with @key under @group_name. | |
| 648 | + | // If @key cannot be found then it is created. | |
| 649 | + | func (x *KeyFile) SetInt64(GroupNameVar string, KeyVar string, ValueVar int64) { | |
| 650 | + | ||
| 651 | + | xKeyFileSetInt64(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 652 | + | ||
| 653 | + | } | |
| 654 | + | ||
| 655 | + | var xKeyFileSetInteger func(uintptr, string, string, int) | |
| 656 | + | ||
| 657 | + | // Associates a new integer value with @key under @group_name. | |
| 658 | + | // If @key cannot be found then it is created. | |
| 659 | + | func (x *KeyFile) SetInteger(GroupNameVar string, KeyVar string, ValueVar int) { | |
| 660 | + | ||
| 661 | + | xKeyFileSetInteger(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 662 | + | ||
| 663 | + | } | |
| 664 | + | ||
| 665 | + | var xKeyFileSetIntegerList func(uintptr, string, string, uintptr, uint) | |
| 666 | + | ||
| 667 | + | // Associates a list of integer values with @key under @group_name. | |
| 668 | + | // If @key cannot be found then it is created. | |
| 669 | + | func (x *KeyFile) SetIntegerList(GroupNameVar string, KeyVar string, ListVar uintptr, LengthVar uint) { | |
| 670 | + | ||
| 671 | + | xKeyFileSetIntegerList(x.GoPointer(), GroupNameVar, KeyVar, ListVar, LengthVar) | |
| 672 | + | ||
| 673 | + | } | |
| 674 | + | ||
| 675 | + | var xKeyFileSetListSeparator func(uintptr, byte) | |
| 676 | + | ||
| 677 | + | // Sets the character which is used to separate | |
| 678 | + | // values in lists. Typically ';' or ',' are used | |
| 679 | + | // as separators. The default list separator is ';'. | |
| 680 | + | func (x *KeyFile) SetListSeparator(SeparatorVar byte) { | |
| 681 | + | ||
| 682 | + | xKeyFileSetListSeparator(x.GoPointer(), SeparatorVar) | |
| 683 | + | ||
| 684 | + | } | |
| 685 | + | ||
| 686 | + | var xKeyFileSetLocaleString func(uintptr, string, string, string, string) | |
| 687 | + | ||
| 688 | + | // Associates a string value for @key and @locale under @group_name. | |
| 689 | + | // If the translation for @key cannot be found then it is created. | |
| 690 | + | func (x *KeyFile) SetLocaleString(GroupNameVar string, KeyVar string, LocaleVar string, StringVar string) { | |
| 691 | + | ||
| 692 | + | xKeyFileSetLocaleString(x.GoPointer(), GroupNameVar, KeyVar, LocaleVar, StringVar) | |
| 693 | + | ||
| 694 | + | } | |
| 695 | + | ||
| 696 | + | var xKeyFileSetLocaleStringList func(uintptr, string, string, string, uintptr, uint) | |
| 697 | + | ||
| 698 | + | // Associates a list of string values for @key and @locale under | |
| 699 | + | // @group_name. If the translation for @key cannot be found then | |
| 700 | + | // it is created. | |
| 701 | + | func (x *KeyFile) SetLocaleStringList(GroupNameVar string, KeyVar string, LocaleVar string, ListVar uintptr, LengthVar uint) { | |
| 702 | + | ||
| 703 | + | xKeyFileSetLocaleStringList(x.GoPointer(), GroupNameVar, KeyVar, LocaleVar, ListVar, LengthVar) | |
| 704 | + | ||
| 705 | + | } | |
| 706 | + | ||
| 707 | + | var xKeyFileSetString func(uintptr, string, string, string) | |
| 708 | + | ||
| 709 | + | // Associates a new string value with @key under @group_name. | |
| 710 | + | // If @key cannot be found then it is created. | |
| 711 | + | // If @group_name cannot be found then it is created. | |
| 712 | + | // Unlike g_key_file_set_value(), this function handles characters | |
| 713 | + | // that need escaping, such as newlines. | |
| 714 | + | func (x *KeyFile) SetString(GroupNameVar string, KeyVar string, StringVar string) { | |
| 715 | + | ||
| 716 | + | xKeyFileSetString(x.GoPointer(), GroupNameVar, KeyVar, StringVar) | |
| 717 | + | ||
| 718 | + | } | |
| 719 | + | ||
| 720 | + | var xKeyFileSetStringList func(uintptr, string, string, uintptr, uint) | |
| 721 | + | ||
| 722 | + | // Associates a list of string values for @key under @group_name. | |
| 723 | + | // If @key cannot be found then it is created. | |
| 724 | + | // If @group_name cannot be found then it is created. | |
| 725 | + | func (x *KeyFile) SetStringList(GroupNameVar string, KeyVar string, ListVar uintptr, LengthVar uint) { | |
| 726 | + | ||
| 727 | + | xKeyFileSetStringList(x.GoPointer(), GroupNameVar, KeyVar, ListVar, LengthVar) | |
| 728 | + | ||
| 729 | + | } | |
| 730 | + | ||
| 731 | + | var xKeyFileSetUint64 func(uintptr, string, string, uint64) | |
| 732 | + | ||
| 733 | + | // Associates a new integer value with @key under @group_name. | |
| 734 | + | // If @key cannot be found then it is created. | |
| 735 | + | func (x *KeyFile) SetUint64(GroupNameVar string, KeyVar string, ValueVar uint64) { | |
| 736 | + | ||
| 737 | + | xKeyFileSetUint64(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 738 | + | ||
| 739 | + | } | |
| 740 | + | ||
| 741 | + | var xKeyFileSetValue func(uintptr, string, string, string) | |
| 742 | + | ||
| 743 | + | // Associates a new value with @key under @group_name. | |
| 744 | + | // | |
| 745 | + | // If @key cannot be found then it is created. If @group_name cannot | |
| 746 | + | // be found then it is created. To set an UTF-8 string which may contain | |
| 747 | + | // characters that need escaping (such as newlines or spaces), use | |
| 748 | + | // g_key_file_set_string(). | |
| 749 | + | func (x *KeyFile) SetValue(GroupNameVar string, KeyVar string, ValueVar string) { | |
| 750 | + | ||
| 751 | + | xKeyFileSetValue(x.GoPointer(), GroupNameVar, KeyVar, ValueVar) | |
| 752 | + | ||
| 753 | + | } | |
| 754 | + | ||
| 755 | + | var xKeyFileToData func(uintptr, uint, **Error) string | |
| 756 | + | ||
| 757 | + | // This function outputs @key_file as a string. | |
| 758 | + | // | |
| 759 | + | // Note that this function never reports an error, | |
| 760 | + | // so it is safe to pass %NULL as @error. | |
| 761 | + | func (x *KeyFile) ToData(LengthVar uint) (string, error) { | |
| 762 | + | var cerr *Error | |
| 763 | + | ||
| 764 | + | cret := xKeyFileToData(x.GoPointer(), LengthVar, &cerr) | |
| 765 | + | if cerr == nil { | |
| 766 | + | return cret, nil | |
| 767 | + | } | |
| 768 | + | return cret, cerr | |
| 769 | + | ||
| 770 | + | } | |
| 771 | + | ||
| 772 | + | var xKeyFileUnref func(uintptr) | |
| 773 | + | ||
| 774 | + | // Decreases the reference count of @key_file by 1. If the reference count | |
| 775 | + | // reaches zero, frees the key file and all its allocated memory. | |
| 776 | + | func (x *KeyFile) Unref() { | |
| 777 | + | ||
| 778 | + | xKeyFileUnref(x.GoPointer()) | |
| 779 | + | ||
| 780 | + | } | |
| 781 | + | ||
| 782 | + | const ( | |
| 783 | + | // The name of the main group of a desktop entry file, as defined in the | |
| 784 | + | // [Desktop Entry Specification](http://freedesktop.org/Standards/desktop-entry-spec). | |
| 785 | + | // Consult the specification for more | |
| 786 | + | // details about the meanings of the keys below. | |
| 787 | + | KEY_FILE_DESKTOP_GROUP string = "Desktop Entry" | |
| 788 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string list | |
| 789 | + | // giving the available application actions. | |
| 790 | + | KEY_FILE_DESKTOP_KEY_ACTIONS string = "Actions" | |
| 791 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list | |
| 792 | + | // of strings giving the categories in which the desktop entry | |
| 793 | + | // should be shown in a menu. | |
| 794 | + | KEY_FILE_DESKTOP_KEY_CATEGORIES string = "Categories" | |
| 795 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized | |
| 796 | + | // string giving the tooltip for the desktop entry. | |
| 797 | + | KEY_FILE_DESKTOP_KEY_COMMENT string = "Comment" | |
| 798 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean | |
| 799 | + | // set to true if the application is D-Bus activatable. | |
| 800 | + | KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE string = "DBusActivatable" | |
| 801 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 802 | + | // giving the command line to execute. It is only valid for desktop | |
| 803 | + | // entries with the `Application` type. | |
| 804 | + | KEY_FILE_DESKTOP_KEY_EXEC string = "Exec" | |
| 805 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized | |
| 806 | + | // string giving the generic name of the desktop entry. | |
| 807 | + | KEY_FILE_DESKTOP_KEY_GENERIC_NAME string = "GenericName" | |
| 808 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean | |
| 809 | + | // stating whether the desktop entry has been deleted by the user. | |
| 810 | + | KEY_FILE_DESKTOP_KEY_HIDDEN string = "Hidden" | |
| 811 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized | |
| 812 | + | // string giving the name of the icon to be displayed for the desktop | |
| 813 | + | // entry. | |
| 814 | + | KEY_FILE_DESKTOP_KEY_ICON string = "Icon" | |
| 815 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list | |
| 816 | + | // of strings giving the MIME types supported by this desktop entry. | |
| 817 | + | KEY_FILE_DESKTOP_KEY_MIME_TYPE string = "MimeType" | |
| 818 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a localized | |
| 819 | + | // string giving the specific name of the desktop entry. | |
| 820 | + | KEY_FILE_DESKTOP_KEY_NAME string = "Name" | |
| 821 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of | |
| 822 | + | // strings identifying the environments that should not display the | |
| 823 | + | // desktop entry. | |
| 824 | + | KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN string = "NotShowIn" | |
| 825 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean | |
| 826 | + | // stating whether the desktop entry should be shown in menus. | |
| 827 | + | KEY_FILE_DESKTOP_KEY_NO_DISPLAY string = "NoDisplay" | |
| 828 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a list of | |
| 829 | + | // strings identifying the environments that should display the | |
| 830 | + | // desktop entry. | |
| 831 | + | KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN string = "OnlyShowIn" | |
| 832 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 833 | + | // containing the working directory to run the program in. It is only | |
| 834 | + | // valid for desktop entries with the `Application` type. | |
| 835 | + | KEY_FILE_DESKTOP_KEY_PATH string = "Path" | |
| 836 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean | |
| 837 | + | // stating whether the application supports the | |
| 838 | + | // [Startup Notification Protocol Specification](http://www.freedesktop.org/Standards/startup-notification-spec). | |
| 839 | + | KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY string = "StartupNotify" | |
| 840 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is string | |
| 841 | + | // identifying the WM class or name hint of a window that the application | |
| 842 | + | // will create, which can be used to emulate Startup Notification with | |
| 843 | + | // older applications. | |
| 844 | + | KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS string = "StartupWMClass" | |
| 845 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a boolean | |
| 846 | + | // stating whether the program should be run in a terminal window. | |
| 847 | + | // | |
| 848 | + | // It is only valid for desktop entries with the `Application` type. | |
| 849 | + | KEY_FILE_DESKTOP_KEY_TERMINAL string = "Terminal" | |
| 850 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 851 | + | // giving the file name of a binary on disk used to determine if the | |
| 852 | + | // program is actually installed. It is only valid for desktop entries | |
| 853 | + | // with the `Application` type. | |
| 854 | + | KEY_FILE_DESKTOP_KEY_TRY_EXEC string = "TryExec" | |
| 855 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 856 | + | // giving the type of the desktop entry. | |
| 857 | + | // | |
| 858 | + | // Usually %G_KEY_FILE_DESKTOP_TYPE_APPLICATION, | |
| 859 | + | // %G_KEY_FILE_DESKTOP_TYPE_LINK, or | |
| 860 | + | // %G_KEY_FILE_DESKTOP_TYPE_DIRECTORY. | |
| 861 | + | KEY_FILE_DESKTOP_KEY_TYPE string = "Type" | |
| 862 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 863 | + | // giving the URL to access. It is only valid for desktop entries | |
| 864 | + | // with the `Link` type. | |
| 865 | + | KEY_FILE_DESKTOP_KEY_URL string = "URL" | |
| 866 | + | // A key under %G_KEY_FILE_DESKTOP_GROUP, whose value is a string | |
| 867 | + | // giving the version of the Desktop Entry Specification used for | |
| 868 | + | // the desktop entry file. | |
| 869 | + | KEY_FILE_DESKTOP_KEY_VERSION string = "Version" | |
| 870 | + | // The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop | |
| 871 | + | // entries representing applications. | |
| 872 | + | KEY_FILE_DESKTOP_TYPE_APPLICATION string = "Application" | |
| 873 | + | // The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop | |
| 874 | + | // entries representing directories. | |
| 875 | + | KEY_FILE_DESKTOP_TYPE_DIRECTORY string = "Directory" | |
| 876 | + | // The value of the %G_KEY_FILE_DESKTOP_KEY_TYPE, key for desktop | |
| 877 | + | // entries representing links to documents. | |
| 878 | + | KEY_FILE_DESKTOP_TYPE_LINK string = "Link" | |
| 879 | + | ) | |
| 880 | + | ||
| 9 | 881 | // Flags which influence the parsing. | |
| 10 | 882 | type KeyFileFlags int | |
| 11 | 883 | ||
| @@ -44,3 +916,62 @@ const ( | |||
| 44 | 916 | // a value could not be parsed | |
| 45 | 917 | GKeyFileErrorInvalidValueValue KeyFileError = 5 | |
| 46 | 918 | ) | |
| 919 | + | ||
| 920 | + | func init() { | |
| 921 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 922 | + | if err != nil { | |
| 923 | + | panic(err) | |
| 924 | + | } | |
| 925 | + | ||
| 926 | + | core.PuregoSafeRegister(&xNewKeyFile, lib, "g_key_file_new") | |
| 927 | + | ||
| 928 | + | core.PuregoSafeRegister(&xKeyFileFree, lib, "g_key_file_free") | |
| 929 | + | core.PuregoSafeRegister(&xKeyFileGetBoolean, lib, "g_key_file_get_boolean") | |
| 930 | + | core.PuregoSafeRegister(&xKeyFileGetBooleanList, lib, "g_key_file_get_boolean_list") | |
| 931 | + | core.PuregoSafeRegister(&xKeyFileGetComment, lib, "g_key_file_get_comment") | |
| 932 | + | core.PuregoSafeRegister(&xKeyFileGetDouble, lib, "g_key_file_get_double") | |
| 933 | + | core.PuregoSafeRegister(&xKeyFileGetDoubleList, lib, "g_key_file_get_double_list") | |
| 934 | + | core.PuregoSafeRegister(&xKeyFileGetGroups, lib, "g_key_file_get_groups") | |
| 935 | + | core.PuregoSafeRegister(&xKeyFileGetInt64, lib, "g_key_file_get_int64") | |
| 936 | + | core.PuregoSafeRegister(&xKeyFileGetInteger, lib, "g_key_file_get_integer") | |
| 937 | + | core.PuregoSafeRegister(&xKeyFileGetIntegerList, lib, "g_key_file_get_integer_list") | |
| 938 | + | core.PuregoSafeRegister(&xKeyFileGetKeys, lib, "g_key_file_get_keys") | |
| 939 | + | core.PuregoSafeRegister(&xKeyFileGetLocaleForKey, lib, "g_key_file_get_locale_for_key") | |
| 940 | + | core.PuregoSafeRegister(&xKeyFileGetLocaleString, lib, "g_key_file_get_locale_string") | |
| 941 | + | core.PuregoSafeRegister(&xKeyFileGetLocaleStringList, lib, "g_key_file_get_locale_string_list") | |
| 942 | + | core.PuregoSafeRegister(&xKeyFileGetStartGroup, lib, "g_key_file_get_start_group") | |
| 943 | + | core.PuregoSafeRegister(&xKeyFileGetString, lib, "g_key_file_get_string") | |
| 944 | + | core.PuregoSafeRegister(&xKeyFileGetStringList, lib, "g_key_file_get_string_list") | |
| 945 | + | core.PuregoSafeRegister(&xKeyFileGetUint64, lib, "g_key_file_get_uint64") | |
| 946 | + | core.PuregoSafeRegister(&xKeyFileGetValue, lib, "g_key_file_get_value") | |
| 947 | + | core.PuregoSafeRegister(&xKeyFileHasGroup, lib, "g_key_file_has_group") | |
| 948 | + | core.PuregoSafeRegister(&xKeyFileHasKey, lib, "g_key_file_has_key") | |
| 949 | + | core.PuregoSafeRegister(&xKeyFileLoadFromBytes, lib, "g_key_file_load_from_bytes") | |
| 950 | + | core.PuregoSafeRegister(&xKeyFileLoadFromData, lib, "g_key_file_load_from_data") | |
| 951 | + | core.PuregoSafeRegister(&xKeyFileLoadFromDataDirs, lib, "g_key_file_load_from_data_dirs") | |
| 952 | + | core.PuregoSafeRegister(&xKeyFileLoadFromDirs, lib, "g_key_file_load_from_dirs") | |
| 953 | + | core.PuregoSafeRegister(&xKeyFileLoadFromFile, lib, "g_key_file_load_from_file") | |
| 954 | + | core.PuregoSafeRegister(&xKeyFileRef, lib, "g_key_file_ref") | |
| 955 | + | core.PuregoSafeRegister(&xKeyFileRemoveComment, lib, "g_key_file_remove_comment") | |
| 956 | + | core.PuregoSafeRegister(&xKeyFileRemoveGroup, lib, "g_key_file_remove_group") | |
| 957 | + | core.PuregoSafeRegister(&xKeyFileRemoveKey, lib, "g_key_file_remove_key") | |
| 958 | + | core.PuregoSafeRegister(&xKeyFileSaveToFile, lib, "g_key_file_save_to_file") | |
| 959 | + | core.PuregoSafeRegister(&xKeyFileSetBoolean, lib, "g_key_file_set_boolean") | |
| 960 | + | core.PuregoSafeRegister(&xKeyFileSetBooleanList, lib, "g_key_file_set_boolean_list") | |
| 961 | + | core.PuregoSafeRegister(&xKeyFileSetComment, lib, "g_key_file_set_comment") | |
| 962 | + | core.PuregoSafeRegister(&xKeyFileSetDouble, lib, "g_key_file_set_double") | |
| 963 | + | core.PuregoSafeRegister(&xKeyFileSetDoubleList, lib, "g_key_file_set_double_list") | |
| 964 | + | core.PuregoSafeRegister(&xKeyFileSetInt64, lib, "g_key_file_set_int64") | |
| 965 | + | core.PuregoSafeRegister(&xKeyFileSetInteger, lib, "g_key_file_set_integer") | |
| 966 | + | core.PuregoSafeRegister(&xKeyFileSetIntegerList, lib, "g_key_file_set_integer_list") | |
| 967 | + | core.PuregoSafeRegister(&xKeyFileSetListSeparator, lib, "g_key_file_set_list_separator") | |
| 968 | + | core.PuregoSafeRegister(&xKeyFileSetLocaleString, lib, "g_key_file_set_locale_string") | |
| 969 | + | core.PuregoSafeRegister(&xKeyFileSetLocaleStringList, lib, "g_key_file_set_locale_string_list") | |
| 970 | + | core.PuregoSafeRegister(&xKeyFileSetString, lib, "g_key_file_set_string") | |
| 971 | + | core.PuregoSafeRegister(&xKeyFileSetStringList, lib, "g_key_file_set_string_list") | |
| 972 | + | core.PuregoSafeRegister(&xKeyFileSetUint64, lib, "g_key_file_set_uint64") | |
| 973 | + | core.PuregoSafeRegister(&xKeyFileSetValue, lib, "g_key_file_set_value") | |
| 974 | + | core.PuregoSafeRegister(&xKeyFileToData, lib, "g_key_file_to_data") | |
| 975 | + | core.PuregoSafeRegister(&xKeyFileUnref, lib, "g_key_file_unref") | |
| 976 | + | ||
| 977 | + | } | |
M v4/glib/glibconfig.go +163 -0
| @@ -9,3 +9,166 @@ package glib | |||
| 9 | 9 | // GPid is used in GLib only for descendant processes spawned with | |
| 10 | 10 | // the g_spawn functions. | |
| 11 | 11 | type Pid = int | |
| 12 | + | ||
| 13 | + | const ( | |
| 14 | + | // The directory separator character. | |
| 15 | + | // This is '/' on UNIX machines and '\' under Windows. | |
| 16 | + | DIR_SEPARATOR int = 47 | |
| 17 | + | // The directory separator as a string. | |
| 18 | + | // This is "/" on UNIX machines and "\" under Windows. | |
| 19 | + | DIR_SEPARATOR_S string = "/" | |
| 20 | + | // This is the platform dependent conversion specifier for scanning and | |
| 21 | + | // printing values of type #gint16. It is a string literal, but doesn't | |
| 22 | + | // include the percent-sign, such that you can add precision and length | |
| 23 | + | // modifiers between percent-sign and conversion specifier. | |
| 24 | + | // | |
| 25 | + | // |[<!-- language="C" --> | |
| 26 | + | // gint16 in; | |
| 27 | + | // gint32 out; | |
| 28 | + | // sscanf ("42", "%" G_GINT16_FORMAT, &in) | |
| 29 | + | // out = in * 1000; | |
| 30 | + | // g_print ("%" G_GINT32_FORMAT, out); | |
| 31 | + | // ]| | |
| 32 | + | GINT16_FORMAT string = "hi" | |
| 33 | + | // The platform dependent length modifier for conversion specifiers | |
| 34 | + | // for scanning and printing values of type #gint16 or #guint16. It | |
| 35 | + | // is a string literal, but doesn't include the percent-sign, such | |
| 36 | + | // that you can add precision and length modifiers between percent-sign | |
| 37 | + | // and conversion specifier and append a conversion specifier. | |
| 38 | + | // | |
| 39 | + | // The following example prints "0x7b"; | |
| 40 | + | // |[<!-- language="C" --> | |
| 41 | + | // gint16 value = 123; | |
| 42 | + | // g_print ("%#" G_GINT16_MODIFIER "x", value); | |
| 43 | + | // ]| | |
| 44 | + | GINT16_MODIFIER string = "h" | |
| 45 | + | // This is the platform dependent conversion specifier for scanning | |
| 46 | + | // and printing values of type #gint32. See also %G_GINT16_FORMAT. | |
| 47 | + | GINT32_FORMAT string = "i" | |
| 48 | + | // The platform dependent length modifier for conversion specifiers | |
| 49 | + | // for scanning and printing values of type #gint32 or #guint32. It | |
| 50 | + | // is a string literal. See also %G_GINT16_MODIFIER. | |
| 51 | + | GINT32_MODIFIER string = "" | |
| 52 | + | // This is the platform dependent conversion specifier for scanning | |
| 53 | + | // and printing values of type #gint64. See also %G_GINT16_FORMAT. | |
| 54 | + | // | |
| 55 | + | // Some platforms do not support scanning and printing 64-bit integers, | |
| 56 | + | // even though the types are supported. On such platforms %G_GINT64_FORMAT | |
| 57 | + | // is not defined. Note that scanf() may not support 64-bit integers, even | |
| 58 | + | // if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() | |
| 59 | + | // is not recommended for parsing anyway; consider using g_ascii_strtoull() | |
| 60 | + | // instead. | |
| 61 | + | GINT64_FORMAT string = "li" | |
| 62 | + | // The platform dependent length modifier for conversion specifiers | |
| 63 | + | // for scanning and printing values of type #gint64 or #guint64. | |
| 64 | + | // It is a string literal. | |
| 65 | + | // | |
| 66 | + | // Some platforms do not support printing 64-bit integers, even | |
| 67 | + | // though the types are supported. On such platforms %G_GINT64_MODIFIER | |
| 68 | + | // is not defined. | |
| 69 | + | GINT64_MODIFIER string = "l" | |
| 70 | + | // This is the platform dependent conversion specifier for scanning | |
| 71 | + | // and printing values of type #gintptr. | |
| 72 | + | GINTPTR_FORMAT string = "li" | |
| 73 | + | // The platform dependent length modifier for conversion specifiers | |
| 74 | + | // for scanning and printing values of type #gintptr or #guintptr. | |
| 75 | + | // It is a string literal. | |
| 76 | + | GINTPTR_MODIFIER string = "l" | |
| 77 | + | // This is the platform dependent conversion specifier for scanning | |
| 78 | + | // and printing values of type #gsize. See also %G_GINT16_FORMAT. | |
| 79 | + | GSIZE_FORMAT string = "lu" | |
| 80 | + | // The platform dependent length modifier for conversion specifiers | |
| 81 | + | // for scanning and printing values of type #gsize. It | |
| 82 | + | // is a string literal. | |
| 83 | + | GSIZE_MODIFIER string = "l" | |
| 84 | + | // This is the platform dependent conversion specifier for scanning | |
| 85 | + | // and printing values of type #gssize. See also %G_GINT16_FORMAT. | |
| 86 | + | GSSIZE_FORMAT string = "li" | |
| 87 | + | // The platform dependent length modifier for conversion specifiers | |
| 88 | + | // for scanning and printing values of type #gssize. It | |
| 89 | + | // is a string literal. | |
| 90 | + | GSSIZE_MODIFIER string = "l" | |
| 91 | + | // This is the platform dependent conversion specifier for scanning | |
| 92 | + | // and printing values of type #guint16. See also %G_GINT16_FORMAT | |
| 93 | + | GUINT16_FORMAT string = "hu" | |
| 94 | + | // This is the platform dependent conversion specifier for scanning | |
| 95 | + | // and printing values of type #guint32. See also %G_GINT16_FORMAT. | |
| 96 | + | GUINT32_FORMAT string = "u" | |
| 97 | + | // This is the platform dependent conversion specifier for scanning | |
| 98 | + | // and printing values of type #guint64. See also %G_GINT16_FORMAT. | |
| 99 | + | // | |
| 100 | + | // Some platforms do not support scanning and printing 64-bit integers, | |
| 101 | + | // even though the types are supported. On such platforms %G_GUINT64_FORMAT | |
| 102 | + | // is not defined. Note that scanf() may not support 64-bit integers, even | |
| 103 | + | // if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() | |
| 104 | + | // is not recommended for parsing anyway; consider using g_ascii_strtoull() | |
| 105 | + | // instead. | |
| 106 | + | GUINT64_FORMAT string = "lu" | |
| 107 | + | // This is the platform dependent conversion specifier | |
| 108 | + | // for scanning and printing values of type #guintptr. | |
| 109 | + | GUINTPTR_FORMAT string = "lu" | |
| 110 | + | ||
| 111 | + | HAVE_GINT64 int = 1 | |
| 112 | + | ||
| 113 | + | HAVE_GNUC_VARARGS int = 1 | |
| 114 | + | // Defined to 1 if gcc-style visibility handling is supported. | |
| 115 | + | HAVE_GNUC_VISIBILITY int = 1 | |
| 116 | + | ||
| 117 | + | HAVE_GROWING_STACK int = 0 | |
| 118 | + | ||
| 119 | + | HAVE_ISO_VARARGS int = 1 | |
| 120 | + | // The major version number of the GLib library. | |
| 121 | + | // | |
| 122 | + | // Like #glib_major_version, but from the headers used at | |
| 123 | + | // application compile time, rather than from the library | |
| 124 | + | // linked against at application run time. | |
| 125 | + | MAJOR_VERSION int = 2 | |
| 126 | + | // The micro version number of the GLib library. | |
| 127 | + | // | |
| 128 | + | // Like #gtk_micro_version, but from the headers used at | |
| 129 | + | // application compile time, rather than from the library | |
| 130 | + | // linked against at application run time. | |
| 131 | + | MICRO_VERSION int = 3 | |
| 132 | + | // The minor version number of the GLib library. | |
| 133 | + | // | |
| 134 | + | // Like #gtk_minor_version, but from the headers used at | |
| 135 | + | // application compile time, rather than from the library | |
| 136 | + | // linked against at application run time. | |
| 137 | + | MINOR_VERSION int = 72 | |
| 138 | + | ||
| 139 | + | MODULE_SUFFIX string = "so" | |
| 140 | + | // A format specifier that can be used in printf()-style format strings | |
| 141 | + | // when printing a #GPid. | |
| 142 | + | PID_FORMAT string = "i" | |
| 143 | + | // A format specifier that can be used in printf()-style format strings | |
| 144 | + | // when printing the @fd member of a #GPollFD. | |
| 145 | + | POLLFD_FORMAT string = "%d" | |
| 146 | + | // The search path separator character. | |
| 147 | + | // This is ':' on UNIX machines and ';' under Windows. | |
| 148 | + | SEARCHPATH_SEPARATOR int = 58 | |
| 149 | + | // The search path separator as a string. | |
| 150 | + | // This is ":" on UNIX machines and ";" under Windows. | |
| 151 | + | SEARCHPATH_SEPARATOR_S string = ":" | |
| 152 | + | ||
| 153 | + | SIZEOF_LONG int = 8 | |
| 154 | + | ||
| 155 | + | SIZEOF_SIZE_T int = 8 | |
| 156 | + | ||
| 157 | + | SIZEOF_SSIZE_T int = 8 | |
| 158 | + | ||
| 159 | + | SIZEOF_VOID_P int = 8 | |
| 160 | + | ||
| 161 | + | SYSDEF_AF_INET int = 2 | |
| 162 | + | ||
| 163 | + | SYSDEF_AF_INET6 int = 10 | |
| 164 | + | ||
| 165 | + | SYSDEF_AF_UNIX int = 1 | |
| 166 | + | ||
| 167 | + | SYSDEF_MSG_DONTROUTE int = 4 | |
| 168 | + | ||
| 169 | + | SYSDEF_MSG_OOB int = 1 | |
| 170 | + | ||
| 171 | + | SYSDEF_MSG_PEEK int = 2 | |
| 172 | + | ||
| 173 | + | VA_COPY_AS_ARRAY int = 1 | |
| 174 | + | ) | |
M v4/glib/glist.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -15,6 +17,10 @@ type List struct { | |||
| 15 | 17 | Prev *List | |
| 16 | 18 | } | |
| 17 | 19 | ||
| 20 | + | func (x *List) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 18 | 24 | var xClearList func(**List, uintptr) | |
| 19 | 25 | ||
| 20 | 26 | // Clears a pointer to a #GList, freeing it and, optionally, freeing its elements using @destroy. | |
M v4/glib/gmain.go +1192 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -42,11 +44,495 @@ type SourceFunc func(uintptr) bool | |||
| 42 | 44 | type MainContext struct { | |
| 43 | 45 | } | |
| 44 | 46 | ||
| 47 | + | func (x *MainContext) GoPointer() uintptr { | |
| 48 | + | return uintptr(unsafe.Pointer(x)) | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | var xNewMainContext func() *MainContext | |
| 52 | + | ||
| 53 | + | // Creates a new #GMainContext structure. | |
| 54 | + | func NewMainContext() *MainContext { | |
| 55 | + | ||
| 56 | + | cret := xNewMainContext() | |
| 57 | + | return cret | |
| 58 | + | } | |
| 59 | + | ||
| 60 | + | var xNewWithFlagsMainContext func(MainContextFlags) *MainContext | |
| 61 | + | ||
| 62 | + | // Creates a new #GMainContext structure. | |
| 63 | + | func NewWithFlagsMainContext(FlagsVar MainContextFlags) *MainContext { | |
| 64 | + | ||
| 65 | + | cret := xNewWithFlagsMainContext(FlagsVar) | |
| 66 | + | return cret | |
| 67 | + | } | |
| 68 | + | ||
| 69 | + | var xMainContextAcquire func(uintptr) bool | |
| 70 | + | ||
| 71 | + | // Tries to become the owner of the specified context. | |
| 72 | + | // If some other thread is the owner of the context, | |
| 73 | + | // returns %FALSE immediately. Ownership is properly | |
| 74 | + | // recursive: the owner can require ownership again | |
| 75 | + | // and will release ownership when g_main_context_release() | |
| 76 | + | // is called as many times as g_main_context_acquire(). | |
| 77 | + | // | |
| 78 | + | // You must be the owner of a context before you | |
| 79 | + | // can call g_main_context_prepare(), g_main_context_query(), | |
| 80 | + | // g_main_context_check(), g_main_context_dispatch(). | |
| 81 | + | func (x *MainContext) Acquire() bool { | |
| 82 | + | ||
| 83 | + | cret := xMainContextAcquire(x.GoPointer()) | |
| 84 | + | return cret | |
| 85 | + | } | |
| 86 | + | ||
| 87 | + | var xMainContextAddPoll func(uintptr, *PollFD, int) | |
| 88 | + | ||
| 89 | + | // Adds a file descriptor to the set of file descriptors polled for | |
| 90 | + | // this context. This will very seldom be used directly. Instead | |
| 91 | + | // a typical event source will use g_source_add_unix_fd() instead. | |
| 92 | + | func (x *MainContext) AddPoll(FdVar *PollFD, PriorityVar int) { | |
| 93 | + | ||
| 94 | + | xMainContextAddPoll(x.GoPointer(), FdVar, PriorityVar) | |
| 95 | + | ||
| 96 | + | } | |
| 97 | + | ||
| 98 | + | var xMainContextCheck func(uintptr, int, uintptr, int) bool | |
| 99 | + | ||
| 100 | + | // Passes the results of polling back to the main loop. You should be | |
| 101 | + | // careful to pass @fds and its length @n_fds as received from | |
| 102 | + | // g_main_context_query(), as this functions relies on assumptions | |
| 103 | + | // on how @fds is filled. | |
| 104 | + | // | |
| 105 | + | // You must have successfully acquired the context with | |
| 106 | + | // g_main_context_acquire() before you may call this function. | |
| 107 | + | func (x *MainContext) Check(MaxPriorityVar int, FdsVar uintptr, NFdsVar int) bool { | |
| 108 | + | ||
| 109 | + | cret := xMainContextCheck(x.GoPointer(), MaxPriorityVar, FdsVar, NFdsVar) | |
| 110 | + | return cret | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | var xMainContextDispatch func(uintptr) | |
| 114 | + | ||
| 115 | + | // Dispatches all pending sources. | |
| 116 | + | // | |
| 117 | + | // You must have successfully acquired the context with | |
| 118 | + | // g_main_context_acquire() before you may call this function. | |
| 119 | + | func (x *MainContext) Dispatch() { | |
| 120 | + | ||
| 121 | + | xMainContextDispatch(x.GoPointer()) | |
| 122 | + | ||
| 123 | + | } | |
| 124 | + | ||
| 125 | + | var xMainContextFindSourceByFuncsUserData func(uintptr, *SourceFuncs, uintptr) *Source | |
| 126 | + | ||
| 127 | + | // Finds a source with the given source functions and user data. If | |
| 128 | + | // multiple sources exist with the same source function and user data, | |
| 129 | + | // the first one found will be returned. | |
| 130 | + | func (x *MainContext) FindSourceByFuncsUserData(FuncsVar *SourceFuncs, UserDataVar uintptr) *Source { | |
| 131 | + | ||
| 132 | + | cret := xMainContextFindSourceByFuncsUserData(x.GoPointer(), FuncsVar, UserDataVar) | |
| 133 | + | return cret | |
| 134 | + | } | |
| 135 | + | ||
| 136 | + | var xMainContextFindSourceById func(uintptr, uint) *Source | |
| 137 | + | ||
| 138 | + | // Finds a #GSource given a pair of context and ID. | |
| 139 | + | // | |
| 140 | + | // It is a programmer error to attempt to look up a non-existent source. | |
| 141 | + | // | |
| 142 | + | // More specifically: source IDs can be reissued after a source has been | |
| 143 | + | // destroyed and therefore it is never valid to use this function with a | |
| 144 | + | // source ID which may have already been removed. An example is when | |
| 145 | + | // scheduling an idle to run in another thread with g_idle_add(): the | |
| 146 | + | // idle may already have run and been removed by the time this function | |
| 147 | + | // is called on its (now invalid) source ID. This source ID may have | |
| 148 | + | // been reissued, leading to the operation being performed against the | |
| 149 | + | // wrong source. | |
| 150 | + | func (x *MainContext) FindSourceById(SourceIdVar uint) *Source { | |
| 151 | + | ||
| 152 | + | cret := xMainContextFindSourceById(x.GoPointer(), SourceIdVar) | |
| 153 | + | return cret | |
| 154 | + | } | |
| 155 | + | ||
| 156 | + | var xMainContextFindSourceByUserData func(uintptr, uintptr) *Source | |
| 157 | + | ||
| 158 | + | // Finds a source with the given user data for the callback. If | |
| 159 | + | // multiple sources exist with the same user data, the first | |
| 160 | + | // one found will be returned. | |
| 161 | + | func (x *MainContext) FindSourceByUserData(UserDataVar uintptr) *Source { | |
| 162 | + | ||
| 163 | + | cret := xMainContextFindSourceByUserData(x.GoPointer(), UserDataVar) | |
| 164 | + | return cret | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xMainContextGetPollFunc func(uintptr) uintptr | |
| 168 | + | ||
| 169 | + | // Gets the poll function set by g_main_context_set_poll_func(). | |
| 170 | + | func (x *MainContext) GetPollFunc() uintptr { | |
| 171 | + | ||
| 172 | + | cret := xMainContextGetPollFunc(x.GoPointer()) | |
| 173 | + | return cret | |
| 174 | + | } | |
| 175 | + | ||
| 176 | + | var xMainContextInvoke func(uintptr, uintptr, uintptr) | |
| 177 | + | ||
| 178 | + | // Invokes a function in such a way that @context is owned during the | |
| 179 | + | // invocation of @function. | |
| 180 | + | // | |
| 181 | + | // If @context is %NULL then the global default main context — as | |
| 182 | + | // returned by g_main_context_default() — is used. | |
| 183 | + | // | |
| 184 | + | // If @context is owned by the current thread, @function is called | |
| 185 | + | // directly. Otherwise, if @context is the thread-default main context | |
| 186 | + | // of the current thread and g_main_context_acquire() succeeds, then | |
| 187 | + | // @function is called and g_main_context_release() is called | |
| 188 | + | // afterwards. | |
| 189 | + | // | |
| 190 | + | // In any other case, an idle source is created to call @function and | |
| 191 | + | // that source is attached to @context (presumably to be run in another | |
| 192 | + | // thread). The idle source is attached with %G_PRIORITY_DEFAULT | |
| 193 | + | // priority. If you want a different priority, use | |
| 194 | + | // g_main_context_invoke_full(). | |
| 195 | + | // | |
| 196 | + | // Note that, as with normal idle functions, @function should probably | |
| 197 | + | // return %FALSE. If it returns %TRUE, it will be continuously run in a | |
| 198 | + | // loop (and may prevent this call from returning). | |
| 199 | + | func (x *MainContext) Invoke(FunctionVar SourceFunc, DataVar uintptr) { | |
| 200 | + | ||
| 201 | + | xMainContextInvoke(x.GoPointer(), purego.NewCallback(FunctionVar), DataVar) | |
| 202 | + | ||
| 203 | + | } | |
| 204 | + | ||
| 205 | + | var xMainContextInvokeFull func(uintptr, int, uintptr, uintptr, uintptr) | |
| 206 | + | ||
| 207 | + | // Invokes a function in such a way that @context is owned during the | |
| 208 | + | // invocation of @function. | |
| 209 | + | // | |
| 210 | + | // This function is the same as g_main_context_invoke() except that it | |
| 211 | + | // lets you specify the priority in case @function ends up being | |
| 212 | + | // scheduled as an idle and also lets you give a #GDestroyNotify for @data. | |
| 213 | + | // | |
| 214 | + | // @notify should not assume that it is called from any particular | |
| 215 | + | // thread or with any particular context acquired. | |
| 216 | + | func (x *MainContext) InvokeFull(PriorityVar int, FunctionVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) { | |
| 217 | + | ||
| 218 | + | xMainContextInvokeFull(x.GoPointer(), PriorityVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 219 | + | ||
| 220 | + | } | |
| 221 | + | ||
| 222 | + | var xMainContextIsOwner func(uintptr) bool | |
| 223 | + | ||
| 224 | + | // Determines whether this thread holds the (recursive) | |
| 225 | + | // ownership of this #GMainContext. This is useful to | |
| 226 | + | // know before waiting on another thread that may be | |
| 227 | + | // blocking to get ownership of @context. | |
| 228 | + | func (x *MainContext) IsOwner() bool { | |
| 229 | + | ||
| 230 | + | cret := xMainContextIsOwner(x.GoPointer()) | |
| 231 | + | return cret | |
| 232 | + | } | |
| 233 | + | ||
| 234 | + | var xMainContextIteration func(uintptr, bool) bool | |
| 235 | + | ||
| 236 | + | // Runs a single iteration for the given main loop. This involves | |
| 237 | + | // checking to see if any event sources are ready to be processed, | |
| 238 | + | // then if no events sources are ready and @may_block is %TRUE, waiting | |
| 239 | + | // for a source to become ready, then dispatching the highest priority | |
| 240 | + | // events sources that are ready. Otherwise, if @may_block is %FALSE | |
| 241 | + | // sources are not waited to become ready, only those highest priority | |
| 242 | + | // events sources will be dispatched (if any), that are ready at this | |
| 243 | + | // given moment without further waiting. | |
| 244 | + | // | |
| 245 | + | // Note that even when @may_block is %TRUE, it is still possible for | |
| 246 | + | // g_main_context_iteration() to return %FALSE, since the wait may | |
| 247 | + | // be interrupted for other reasons than an event source becoming ready. | |
| 248 | + | func (x *MainContext) Iteration(MayBlockVar bool) bool { | |
| 249 | + | ||
| 250 | + | cret := xMainContextIteration(x.GoPointer(), MayBlockVar) | |
| 251 | + | return cret | |
| 252 | + | } | |
| 253 | + | ||
| 254 | + | var xMainContextPending func(uintptr) bool | |
| 255 | + | ||
| 256 | + | // Checks if any sources have pending events for the given context. | |
| 257 | + | func (x *MainContext) Pending() bool { | |
| 258 | + | ||
| 259 | + | cret := xMainContextPending(x.GoPointer()) | |
| 260 | + | return cret | |
| 261 | + | } | |
| 262 | + | ||
| 263 | + | var xMainContextPopThreadDefault func(uintptr) | |
| 264 | + | ||
| 265 | + | // Pops @context off the thread-default context stack (verifying that | |
| 266 | + | // it was on the top of the stack). | |
| 267 | + | func (x *MainContext) PopThreadDefault() { | |
| 268 | + | ||
| 269 | + | xMainContextPopThreadDefault(x.GoPointer()) | |
| 270 | + | ||
| 271 | + | } | |
| 272 | + | ||
| 273 | + | var xMainContextPrepare func(uintptr, int) bool | |
| 274 | + | ||
| 275 | + | // Prepares to poll sources within a main loop. The resulting information | |
| 276 | + | // for polling is determined by calling g_main_context_query (). | |
| 277 | + | // | |
| 278 | + | // You must have successfully acquired the context with | |
| 279 | + | // g_main_context_acquire() before you may call this function. | |
| 280 | + | func (x *MainContext) Prepare(PriorityVar int) bool { | |
| 281 | + | ||
| 282 | + | cret := xMainContextPrepare(x.GoPointer(), PriorityVar) | |
| 283 | + | return cret | |
| 284 | + | } | |
| 285 | + | ||
| 286 | + | var xMainContextPushThreadDefault func(uintptr) | |
| 287 | + | ||
| 288 | + | // Acquires @context and sets it as the thread-default context for the | |
| 289 | + | // current thread. This will cause certain asynchronous operations | |
| 290 | + | // (such as most [gio][gio]-based I/O) which are | |
| 291 | + | // started in this thread to run under @context and deliver their | |
| 292 | + | // results to its main loop, rather than running under the global | |
| 293 | + | // default context in the main thread. Note that calling this function | |
| 294 | + | // changes the context returned by g_main_context_get_thread_default(), | |
| 295 | + | // not the one returned by g_main_context_default(), so it does not affect | |
| 296 | + | // the context used by functions like g_idle_add(). | |
| 297 | + | // | |
| 298 | + | // Normally you would call this function shortly after creating a new | |
| 299 | + | // thread, passing it a #GMainContext which will be run by a | |
| 300 | + | // #GMainLoop in that thread, to set a new default context for all | |
| 301 | + | // async operations in that thread. In this case you may not need to | |
| 302 | + | // ever call g_main_context_pop_thread_default(), assuming you want the | |
| 303 | + | // new #GMainContext to be the default for the whole lifecycle of the | |
| 304 | + | // thread. | |
| 305 | + | // | |
| 306 | + | // If you don't have control over how the new thread was created (e.g. | |
| 307 | + | // in the new thread isn't newly created, or if the thread life | |
| 308 | + | // cycle is managed by a #GThreadPool), it is always suggested to wrap | |
| 309 | + | // the logic that needs to use the new #GMainContext inside a | |
| 310 | + | // g_main_context_push_thread_default() / g_main_context_pop_thread_default() | |
| 311 | + | // pair, otherwise threads that are re-used will end up never explicitly | |
| 312 | + | // releasing the #GMainContext reference they hold. | |
| 313 | + | // | |
| 314 | + | // In some cases you may want to schedule a single operation in a | |
| 315 | + | // non-default context, or temporarily use a non-default context in | |
| 316 | + | // the main thread. In that case, you can wrap the call to the | |
| 317 | + | // asynchronous operation inside a | |
| 318 | + | // g_main_context_push_thread_default() / | |
| 319 | + | // g_main_context_pop_thread_default() pair, but it is up to you to | |
| 320 | + | // ensure that no other asynchronous operations accidentally get | |
| 321 | + | // started while the non-default context is active. | |
| 322 | + | // | |
| 323 | + | // Beware that libraries that predate this function may not correctly | |
| 324 | + | // handle being used from a thread with a thread-default context. Eg, | |
| 325 | + | // see g_file_supports_thread_contexts(). | |
| 326 | + | func (x *MainContext) PushThreadDefault() { | |
| 327 | + | ||
| 328 | + | xMainContextPushThreadDefault(x.GoPointer()) | |
| 329 | + | ||
| 330 | + | } | |
| 331 | + | ||
| 332 | + | var xMainContextQuery func(uintptr, int, int, uintptr, int) int | |
| 333 | + | ||
| 334 | + | // Determines information necessary to poll this main loop. You should | |
| 335 | + | // be careful to pass the resulting @fds array and its length @n_fds | |
| 336 | + | // as is when calling g_main_context_check(), as this function relies | |
| 337 | + | // on assumptions made when the array is filled. | |
| 338 | + | // | |
| 339 | + | // You must have successfully acquired the context with | |
| 340 | + | // g_main_context_acquire() before you may call this function. | |
| 341 | + | func (x *MainContext) Query(MaxPriorityVar int, TimeoutVar int, FdsVar uintptr, NFdsVar int) int { | |
| 342 | + | ||
| 343 | + | cret := xMainContextQuery(x.GoPointer(), MaxPriorityVar, TimeoutVar, FdsVar, NFdsVar) | |
| 344 | + | return cret | |
| 345 | + | } | |
| 346 | + | ||
| 347 | + | var xMainContextRef func(uintptr) *MainContext | |
| 348 | + | ||
| 349 | + | // Increases the reference count on a #GMainContext object by one. | |
| 350 | + | func (x *MainContext) Ref() *MainContext { | |
| 351 | + | ||
| 352 | + | cret := xMainContextRef(x.GoPointer()) | |
| 353 | + | return cret | |
| 354 | + | } | |
| 355 | + | ||
| 356 | + | var xMainContextRelease func(uintptr) | |
| 357 | + | ||
| 358 | + | // Releases ownership of a context previously acquired by this thread | |
| 359 | + | // with g_main_context_acquire(). If the context was acquired multiple | |
| 360 | + | // times, the ownership will be released only when g_main_context_release() | |
| 361 | + | // is called as many times as it was acquired. | |
| 362 | + | func (x *MainContext) Release() { | |
| 363 | + | ||
| 364 | + | xMainContextRelease(x.GoPointer()) | |
| 365 | + | ||
| 366 | + | } | |
| 367 | + | ||
| 368 | + | var xMainContextRemovePoll func(uintptr, *PollFD) | |
| 369 | + | ||
| 370 | + | // Removes file descriptor from the set of file descriptors to be | |
| 371 | + | // polled for a particular context. | |
| 372 | + | func (x *MainContext) RemovePoll(FdVar *PollFD) { | |
| 373 | + | ||
| 374 | + | xMainContextRemovePoll(x.GoPointer(), FdVar) | |
| 375 | + | ||
| 376 | + | } | |
| 377 | + | ||
| 378 | + | var xMainContextSetPollFunc func(uintptr, uintptr) | |
| 379 | + | ||
| 380 | + | // Sets the function to use to handle polling of file descriptors. It | |
| 381 | + | // will be used instead of the poll() system call | |
| 382 | + | // (or GLib's replacement function, which is used where | |
| 383 | + | // poll() isn't available). | |
| 384 | + | // | |
| 385 | + | // This function could possibly be used to integrate the GLib event | |
| 386 | + | // loop with an external event loop. | |
| 387 | + | func (x *MainContext) SetPollFunc(FuncVar PollFunc) { | |
| 388 | + | ||
| 389 | + | xMainContextSetPollFunc(x.GoPointer(), purego.NewCallback(FuncVar)) | |
| 390 | + | ||
| 391 | + | } | |
| 392 | + | ||
| 393 | + | var xMainContextUnref func(uintptr) | |
| 394 | + | ||
| 395 | + | // Decreases the reference count on a #GMainContext object by one. If | |
| 396 | + | // the result is zero, free the context and free all associated memory. | |
| 397 | + | func (x *MainContext) Unref() { | |
| 398 | + | ||
| 399 | + | xMainContextUnref(x.GoPointer()) | |
| 400 | + | ||
| 401 | + | } | |
| 402 | + | ||
| 403 | + | var xMainContextWait func(uintptr, *Cond, *Mutex) bool | |
| 404 | + | ||
| 405 | + | // Tries to become the owner of the specified context, | |
| 406 | + | // as with g_main_context_acquire(). But if another thread | |
| 407 | + | // is the owner, atomically drop @mutex and wait on @cond until | |
| 408 | + | // that owner releases ownership or until @cond is signaled, then | |
| 409 | + | // try again (once) to become the owner. | |
| 410 | + | func (x *MainContext) Wait(CondVar *Cond, MutexVar *Mutex) bool { | |
| 411 | + | ||
| 412 | + | cret := xMainContextWait(x.GoPointer(), CondVar, MutexVar) | |
| 413 | + | return cret | |
| 414 | + | } | |
| 415 | + | ||
| 416 | + | var xMainContextWakeup func(uintptr) | |
| 417 | + | ||
| 418 | + | // If @context is currently blocking in g_main_context_iteration() | |
| 419 | + | // waiting for a source to become ready, cause it to stop blocking | |
| 420 | + | // and return. Otherwise, cause the next invocation of | |
| 421 | + | // g_main_context_iteration() to return without blocking. | |
| 422 | + | // | |
| 423 | + | // This API is useful for low-level control over #GMainContext; for | |
| 424 | + | // example, integrating it with main loop implementations such as | |
| 425 | + | // #GMainLoop. | |
| 426 | + | // | |
| 427 | + | // Another related use for this function is when implementing a main | |
| 428 | + | // loop with a termination condition, computed from multiple threads: | |
| 429 | + | // | |
| 430 | + | // |[<!-- language="C" --> | |
| 431 | + | // | |
| 432 | + | // #define NUM_TASKS 10 | |
| 433 | + | // static gint tasks_remaining = NUM_TASKS; // (atomic) | |
| 434 | + | // ... | |
| 435 | + | // | |
| 436 | + | // while (g_atomic_int_get (&tasks_remaining) != 0) | |
| 437 | + | // g_main_context_iteration (NULL, TRUE); | |
| 438 | + | // | |
| 439 | + | // ]| | |
| 440 | + | // | |
| 441 | + | // Then in a thread: | |
| 442 | + | // |[<!-- language="C" --> | |
| 443 | + | // | |
| 444 | + | // perform_work(); | |
| 445 | + | // | |
| 446 | + | // if (g_atomic_int_dec_and_test (&tasks_remaining)) | |
| 447 | + | // g_main_context_wakeup (NULL); | |
| 448 | + | // | |
| 449 | + | // ]| | |
| 450 | + | func (x *MainContext) Wakeup() { | |
| 451 | + | ||
| 452 | + | xMainContextWakeup(x.GoPointer()) | |
| 453 | + | ||
| 454 | + | } | |
| 455 | + | ||
| 45 | 456 | // The `GMainLoop` struct is an opaque data type | |
| 46 | 457 | // representing the main event loop of a GLib or GTK+ application. | |
| 47 | 458 | type MainLoop struct { | |
| 48 | 459 | } | |
| 49 | 460 | ||
| 461 | + | func (x *MainLoop) GoPointer() uintptr { | |
| 462 | + | return uintptr(unsafe.Pointer(x)) | |
| 463 | + | } | |
| 464 | + | ||
| 465 | + | var xNewMainLoop func(*MainContext, bool) *MainLoop | |
| 466 | + | ||
| 467 | + | // Creates a new #GMainLoop structure. | |
| 468 | + | func NewMainLoop(ContextVar *MainContext, IsRunningVar bool) *MainLoop { | |
| 469 | + | ||
| 470 | + | cret := xNewMainLoop(ContextVar, IsRunningVar) | |
| 471 | + | return cret | |
| 472 | + | } | |
| 473 | + | ||
| 474 | + | var xMainLoopGetContext func(uintptr) *MainContext | |
| 475 | + | ||
| 476 | + | // Returns the #GMainContext of @loop. | |
| 477 | + | func (x *MainLoop) GetContext() *MainContext { | |
| 478 | + | ||
| 479 | + | cret := xMainLoopGetContext(x.GoPointer()) | |
| 480 | + | return cret | |
| 481 | + | } | |
| 482 | + | ||
| 483 | + | var xMainLoopIsRunning func(uintptr) bool | |
| 484 | + | ||
| 485 | + | // Checks to see if the main loop is currently being run via g_main_loop_run(). | |
| 486 | + | func (x *MainLoop) IsRunning() bool { | |
| 487 | + | ||
| 488 | + | cret := xMainLoopIsRunning(x.GoPointer()) | |
| 489 | + | return cret | |
| 490 | + | } | |
| 491 | + | ||
| 492 | + | var xMainLoopQuit func(uintptr) | |
| 493 | + | ||
| 494 | + | // Stops a #GMainLoop from running. Any calls to g_main_loop_run() | |
| 495 | + | // for the loop will return. | |
| 496 | + | // | |
| 497 | + | // Note that sources that have already been dispatched when | |
| 498 | + | // g_main_loop_quit() is called will still be executed. | |
| 499 | + | func (x *MainLoop) Quit() { | |
| 500 | + | ||
| 501 | + | xMainLoopQuit(x.GoPointer()) | |
| 502 | + | ||
| 503 | + | } | |
| 504 | + | ||
| 505 | + | var xMainLoopRef func(uintptr) *MainLoop | |
| 506 | + | ||
| 507 | + | // Increases the reference count on a #GMainLoop object by one. | |
| 508 | + | func (x *MainLoop) Ref() *MainLoop { | |
| 509 | + | ||
| 510 | + | cret := xMainLoopRef(x.GoPointer()) | |
| 511 | + | return cret | |
| 512 | + | } | |
| 513 | + | ||
| 514 | + | var xMainLoopRun func(uintptr) | |
| 515 | + | ||
| 516 | + | // Runs a main loop until g_main_loop_quit() is called on the loop. | |
| 517 | + | // If this is called for the thread of the loop's #GMainContext, | |
| 518 | + | // it will process events from the loop, otherwise it will | |
| 519 | + | // simply wait. | |
| 520 | + | func (x *MainLoop) Run() { | |
| 521 | + | ||
| 522 | + | xMainLoopRun(x.GoPointer()) | |
| 523 | + | ||
| 524 | + | } | |
| 525 | + | ||
| 526 | + | var xMainLoopUnref func(uintptr) | |
| 527 | + | ||
| 528 | + | // Decreases the reference count on a #GMainLoop object by one. If | |
| 529 | + | // the result is zero, free the loop and free all associated memory. | |
| 530 | + | func (x *MainLoop) Unref() { | |
| 531 | + | ||
| 532 | + | xMainLoopUnref(x.GoPointer()) | |
| 533 | + | ||
| 534 | + | } | |
| 535 | + | ||
| 50 | 536 | // The `GSource` struct is an opaque data type | |
| 51 | 537 | // representing an event source. | |
| 52 | 538 | type Source struct { | |
| @@ -77,11 +563,604 @@ type Source struct { | |||
| 77 | 563 | Priv *SourcePrivate | |
| 78 | 564 | } | |
| 79 | 565 | ||
| 566 | + | func (x *Source) GoPointer() uintptr { | |
| 567 | + | return uintptr(unsafe.Pointer(x)) | |
| 568 | + | } | |
| 569 | + | ||
| 570 | + | var xNewSource func(*SourceFuncs, uint) *Source | |
| 571 | + | ||
| 572 | + | // Creates a new #GSource structure. The size is specified to | |
| 573 | + | // allow creating structures derived from #GSource that contain | |
| 574 | + | // additional data. The size passed in must be at least | |
| 575 | + | // `sizeof (GSource)`. | |
| 576 | + | // | |
| 577 | + | // The source will not initially be associated with any #GMainContext | |
| 578 | + | // and must be added to one with g_source_attach() before it will be | |
| 579 | + | // executed. | |
| 580 | + | func NewSource(SourceFuncsVar *SourceFuncs, StructSizeVar uint) *Source { | |
| 581 | + | ||
| 582 | + | cret := xNewSource(SourceFuncsVar, StructSizeVar) | |
| 583 | + | return cret | |
| 584 | + | } | |
| 585 | + | ||
| 586 | + | var xSourceAddChildSource func(uintptr, *Source) | |
| 587 | + | ||
| 588 | + | // Adds @child_source to @source as a "polled" source; when @source is | |
| 589 | + | // added to a #GMainContext, @child_source will be automatically added | |
| 590 | + | // with the same priority, when @child_source is triggered, it will | |
| 591 | + | // cause @source to dispatch (in addition to calling its own | |
| 592 | + | // callback), and when @source is destroyed, it will destroy | |
| 593 | + | // @child_source as well. (@source will also still be dispatched if | |
| 594 | + | // its own prepare/check functions indicate that it is ready.) | |
| 595 | + | // | |
| 596 | + | // If you don't need @child_source to do anything on its own when it | |
| 597 | + | // triggers, you can call g_source_set_dummy_callback() on it to set a | |
| 598 | + | // callback that does nothing (except return %TRUE if appropriate). | |
| 599 | + | // | |
| 600 | + | // @source will hold a reference on @child_source while @child_source | |
| 601 | + | // is attached to it. | |
| 602 | + | // | |
| 603 | + | // This API is only intended to be used by implementations of #GSource. | |
| 604 | + | // Do not call this API on a #GSource that you did not create. | |
| 605 | + | func (x *Source) AddChildSource(ChildSourceVar *Source) { | |
| 606 | + | ||
| 607 | + | xSourceAddChildSource(x.GoPointer(), ChildSourceVar) | |
| 608 | + | ||
| 609 | + | } | |
| 610 | + | ||
| 611 | + | var xSourceAddPoll func(uintptr, *PollFD) | |
| 612 | + | ||
| 613 | + | // Adds a file descriptor to the set of file descriptors polled for | |
| 614 | + | // this source. This is usually combined with g_source_new() to add an | |
| 615 | + | // event source. The event source's check function will typically test | |
| 616 | + | // the @revents field in the #GPollFD struct and return %TRUE if events need | |
| 617 | + | // to be processed. | |
| 618 | + | // | |
| 619 | + | // This API is only intended to be used by implementations of #GSource. | |
| 620 | + | // Do not call this API on a #GSource that you did not create. | |
| 621 | + | // | |
| 622 | + | // Using this API forces the linear scanning of event sources on each | |
| 623 | + | // main loop iteration. Newly-written event sources should try to use | |
| 624 | + | // g_source_add_unix_fd() instead of this API. | |
| 625 | + | func (x *Source) AddPoll(FdVar *PollFD) { | |
| 626 | + | ||
| 627 | + | xSourceAddPoll(x.GoPointer(), FdVar) | |
| 628 | + | ||
| 629 | + | } | |
| 630 | + | ||
| 631 | + | var xSourceAddUnixFd func(uintptr, int, IOCondition) uintptr | |
| 632 | + | ||
| 633 | + | // Monitors @fd for the IO events in @events. | |
| 634 | + | // | |
| 635 | + | // The tag returned by this function can be used to remove or modify the | |
| 636 | + | // monitoring of the fd using g_source_remove_unix_fd() or | |
| 637 | + | // g_source_modify_unix_fd(). | |
| 638 | + | // | |
| 639 | + | // It is not necessary to remove the fd before destroying the source; it | |
| 640 | + | // will be cleaned up automatically. | |
| 641 | + | // | |
| 642 | + | // This API is only intended to be used by implementations of #GSource. | |
| 643 | + | // Do not call this API on a #GSource that you did not create. | |
| 644 | + | // | |
| 645 | + | // As the name suggests, this function is not available on Windows. | |
| 646 | + | func (x *Source) AddUnixFd(FdVar int, EventsVar IOCondition) uintptr { | |
| 647 | + | ||
| 648 | + | cret := xSourceAddUnixFd(x.GoPointer(), FdVar, EventsVar) | |
| 649 | + | return cret | |
| 650 | + | } | |
| 651 | + | ||
| 652 | + | var xSourceAttach func(uintptr, *MainContext) uint | |
| 653 | + | ||
| 654 | + | // Adds a #GSource to a @context so that it will be executed within | |
| 655 | + | // that context. Remove it by calling g_source_destroy(). | |
| 656 | + | // | |
| 657 | + | // This function is safe to call from any thread, regardless of which thread | |
| 658 | + | // the @context is running in. | |
| 659 | + | func (x *Source) Attach(ContextVar *MainContext) uint { | |
| 660 | + | ||
| 661 | + | cret := xSourceAttach(x.GoPointer(), ContextVar) | |
| 662 | + | return cret | |
| 663 | + | } | |
| 664 | + | ||
| 665 | + | var xSourceDestroy func(uintptr) | |
| 666 | + | ||
| 667 | + | // Removes a source from its #GMainContext, if any, and mark it as | |
| 668 | + | // destroyed. The source cannot be subsequently added to another | |
| 669 | + | // context. It is safe to call this on sources which have already been | |
| 670 | + | // removed from their context. | |
| 671 | + | // | |
| 672 | + | // This does not unref the #GSource: if you still hold a reference, use | |
| 673 | + | // g_source_unref() to drop it. | |
| 674 | + | // | |
| 675 | + | // This function is safe to call from any thread, regardless of which thread | |
| 676 | + | // the #GMainContext is running in. | |
| 677 | + | // | |
| 678 | + | // If the source is currently attached to a #GMainContext, destroying it | |
| 679 | + | // will effectively unset the callback similar to calling g_source_set_callback(). | |
| 680 | + | // This can mean, that the data's #GDestroyNotify gets called right away. | |
| 681 | + | func (x *Source) Destroy() { | |
| 682 | + | ||
| 683 | + | xSourceDestroy(x.GoPointer()) | |
| 684 | + | ||
| 685 | + | } | |
| 686 | + | ||
| 687 | + | var xSourceGetCanRecurse func(uintptr) bool | |
| 688 | + | ||
| 689 | + | // Checks whether a source is allowed to be called recursively. | |
| 690 | + | // see g_source_set_can_recurse(). | |
| 691 | + | func (x *Source) GetCanRecurse() bool { | |
| 692 | + | ||
| 693 | + | cret := xSourceGetCanRecurse(x.GoPointer()) | |
| 694 | + | return cret | |
| 695 | + | } | |
| 696 | + | ||
| 697 | + | var xSourceGetContext func(uintptr) *MainContext | |
| 698 | + | ||
| 699 | + | // Gets the #GMainContext with which the source is associated. | |
| 700 | + | // | |
| 701 | + | // You can call this on a source that has been destroyed, provided | |
| 702 | + | // that the #GMainContext it was attached to still exists (in which | |
| 703 | + | // case it will return that #GMainContext). In particular, you can | |
| 704 | + | // always call this function on the source returned from | |
| 705 | + | // g_main_current_source(). But calling this function on a source | |
| 706 | + | // whose #GMainContext has been destroyed is an error. | |
| 707 | + | func (x *Source) GetContext() *MainContext { | |
| 708 | + | ||
| 709 | + | cret := xSourceGetContext(x.GoPointer()) | |
| 710 | + | return cret | |
| 711 | + | } | |
| 712 | + | ||
| 713 | + | var xSourceGetCurrentTime func(uintptr, *TimeVal) | |
| 714 | + | ||
| 715 | + | // This function ignores @source and is otherwise the same as | |
| 716 | + | // g_get_current_time(). | |
| 717 | + | func (x *Source) GetCurrentTime(TimevalVar *TimeVal) { | |
| 718 | + | ||
| 719 | + | xSourceGetCurrentTime(x.GoPointer(), TimevalVar) | |
| 720 | + | ||
| 721 | + | } | |
| 722 | + | ||
| 723 | + | var xSourceGetId func(uintptr) uint | |
| 724 | + | ||
| 725 | + | // Returns the numeric ID for a particular source. The ID of a source | |
| 726 | + | // is a positive integer which is unique within a particular main loop | |
| 727 | + | // context. The reverse | |
| 728 | + | // mapping from ID to source is done by g_main_context_find_source_by_id(). | |
| 729 | + | // | |
| 730 | + | // You can only call this function while the source is associated to a | |
| 731 | + | // #GMainContext instance; calling this function before g_source_attach() | |
| 732 | + | // or after g_source_destroy() yields undefined behavior. The ID returned | |
| 733 | + | // is unique within the #GMainContext instance passed to g_source_attach(). | |
| 734 | + | func (x *Source) GetId() uint { | |
| 735 | + | ||
| 736 | + | cret := xSourceGetId(x.GoPointer()) | |
| 737 | + | return cret | |
| 738 | + | } | |
| 739 | + | ||
| 740 | + | var xSourceGetName func(uintptr) string | |
| 741 | + | ||
| 742 | + | // Gets a name for the source, used in debugging and profiling. The | |
| 743 | + | // name may be #NULL if it has never been set with g_source_set_name(). | |
| 744 | + | func (x *Source) GetName() string { | |
| 745 | + | ||
| 746 | + | cret := xSourceGetName(x.GoPointer()) | |
| 747 | + | return cret | |
| 748 | + | } | |
| 749 | + | ||
| 750 | + | var xSourceGetPriority func(uintptr) int | |
| 751 | + | ||
| 752 | + | // Gets the priority of a source. | |
| 753 | + | func (x *Source) GetPriority() int { | |
| 754 | + | ||
| 755 | + | cret := xSourceGetPriority(x.GoPointer()) | |
| 756 | + | return cret | |
| 757 | + | } | |
| 758 | + | ||
| 759 | + | var xSourceGetReadyTime func(uintptr) int64 | |
| 760 | + | ||
| 761 | + | // Gets the "ready time" of @source, as set by | |
| 762 | + | // g_source_set_ready_time(). | |
| 763 | + | // | |
| 764 | + | // Any time before the current monotonic time (including 0) is an | |
| 765 | + | // indication that the source will fire immediately. | |
| 766 | + | func (x *Source) GetReadyTime() int64 { | |
| 767 | + | ||
| 768 | + | cret := xSourceGetReadyTime(x.GoPointer()) | |
| 769 | + | return cret | |
| 770 | + | } | |
| 771 | + | ||
| 772 | + | var xSourceGetTime func(uintptr) int64 | |
| 773 | + | ||
| 774 | + | // Gets the time to be used when checking this source. The advantage of | |
| 775 | + | // calling this function over calling g_get_monotonic_time() directly is | |
| 776 | + | // that when checking multiple sources, GLib can cache a single value | |
| 777 | + | // instead of having to repeatedly get the system monotonic time. | |
| 778 | + | // | |
| 779 | + | // The time here is the system monotonic time, if available, or some | |
| 780 | + | // other reasonable alternative otherwise. See g_get_monotonic_time(). | |
| 781 | + | func (x *Source) GetTime() int64 { | |
| 782 | + | ||
| 783 | + | cret := xSourceGetTime(x.GoPointer()) | |
| 784 | + | return cret | |
| 785 | + | } | |
| 786 | + | ||
| 787 | + | var xSourceIsDestroyed func(uintptr) bool | |
| 788 | + | ||
| 789 | + | // Returns whether @source has been destroyed. | |
| 790 | + | // | |
| 791 | + | // This is important when you operate upon your objects | |
| 792 | + | // from within idle handlers, but may have freed the object | |
| 793 | + | // before the dispatch of your idle handler. | |
| 794 | + | // | |
| 795 | + | // |[<!-- language="C" --> | |
| 796 | + | // static gboolean | |
| 797 | + | // idle_callback (gpointer data) | |
| 798 | + | // | |
| 799 | + | // { | |
| 800 | + | // SomeWidget *self = data; | |
| 801 | + | // | |
| 802 | + | // g_mutex_lock (&self->idle_id_mutex); | |
| 803 | + | // // do stuff with self | |
| 804 | + | // self->idle_id = 0; | |
| 805 | + | // g_mutex_unlock (&self->idle_id_mutex); | |
| 806 | + | // | |
| 807 | + | // return G_SOURCE_REMOVE; | |
| 808 | + | // } | |
| 809 | + | // | |
| 810 | + | // static void | |
| 811 | + | // some_widget_do_stuff_later (SomeWidget *self) | |
| 812 | + | // | |
| 813 | + | // { | |
| 814 | + | // g_mutex_lock (&self->idle_id_mutex); | |
| 815 | + | // self->idle_id = g_idle_add (idle_callback, self); | |
| 816 | + | // g_mutex_unlock (&self->idle_id_mutex); | |
| 817 | + | // } | |
| 818 | + | // | |
| 819 | + | // static void | |
| 820 | + | // some_widget_init (SomeWidget *self) | |
| 821 | + | // | |
| 822 | + | // { | |
| 823 | + | // g_mutex_init (&self->idle_id_mutex); | |
| 824 | + | // | |
| 825 | + | // // ... | |
| 826 | + | // } | |
| 827 | + | // | |
| 828 | + | // static void | |
| 829 | + | // some_widget_finalize (GObject *object) | |
| 830 | + | // | |
| 831 | + | // { | |
| 832 | + | // SomeWidget *self = SOME_WIDGET (object); | |
| 833 | + | // | |
| 834 | + | // if (self->idle_id) | |
| 835 | + | // g_source_remove (self->idle_id); | |
| 836 | + | // | |
| 837 | + | // g_mutex_clear (&self->idle_id_mutex); | |
| 838 | + | // | |
| 839 | + | // G_OBJECT_CLASS (parent_class)->finalize (object); | |
| 840 | + | // } | |
| 841 | + | // | |
| 842 | + | // ]| | |
| 843 | + | // | |
| 844 | + | // This will fail in a multi-threaded application if the | |
| 845 | + | // widget is destroyed before the idle handler fires due | |
| 846 | + | // to the use after free in the callback. A solution, to | |
| 847 | + | // this particular problem, is to check to if the source | |
| 848 | + | // has already been destroy within the callback. | |
| 849 | + | // | |
| 850 | + | // |[<!-- language="C" --> | |
| 851 | + | // static gboolean | |
| 852 | + | // idle_callback (gpointer data) | |
| 853 | + | // | |
| 854 | + | // { | |
| 855 | + | // SomeWidget *self = data; | |
| 856 | + | // | |
| 857 | + | // g_mutex_lock (&self->idle_id_mutex); | |
| 858 | + | // if (!g_source_is_destroyed (g_main_current_source ())) | |
| 859 | + | // { | |
| 860 | + | // // do stuff with self | |
| 861 | + | // } | |
| 862 | + | // g_mutex_unlock (&self->idle_id_mutex); | |
| 863 | + | // | |
| 864 | + | // return FALSE; | |
| 865 | + | // } | |
| 866 | + | // | |
| 867 | + | // ]| | |
| 868 | + | // | |
| 869 | + | // Calls to this function from a thread other than the one acquired by the | |
| 870 | + | // #GMainContext the #GSource is attached to are typically redundant, as the | |
| 871 | + | // source could be destroyed immediately after this function returns. However, | |
| 872 | + | // once a source is destroyed it cannot be un-destroyed, so this function can be | |
| 873 | + | // used for opportunistic checks from any thread. | |
| 874 | + | func (x *Source) IsDestroyed() bool { | |
| 875 | + | ||
| 876 | + | cret := xSourceIsDestroyed(x.GoPointer()) | |
| 877 | + | return cret | |
| 878 | + | } | |
| 879 | + | ||
| 880 | + | var xSourceModifyUnixFd func(uintptr, uintptr, IOCondition) | |
| 881 | + | ||
| 882 | + | // Updates the event mask to watch for the fd identified by @tag. | |
| 883 | + | // | |
| 884 | + | // @tag is the tag returned from g_source_add_unix_fd(). | |
| 885 | + | // | |
| 886 | + | // If you want to remove a fd, don't set its event mask to zero. | |
| 887 | + | // Instead, call g_source_remove_unix_fd(). | |
| 888 | + | // | |
| 889 | + | // This API is only intended to be used by implementations of #GSource. | |
| 890 | + | // Do not call this API on a #GSource that you did not create. | |
| 891 | + | // | |
| 892 | + | // As the name suggests, this function is not available on Windows. | |
| 893 | + | func (x *Source) ModifyUnixFd(TagVar uintptr, NewEventsVar IOCondition) { | |
| 894 | + | ||
| 895 | + | xSourceModifyUnixFd(x.GoPointer(), TagVar, NewEventsVar) | |
| 896 | + | ||
| 897 | + | } | |
| 898 | + | ||
| 899 | + | var xSourceQueryUnixFd func(uintptr, uintptr) IOCondition | |
| 900 | + | ||
| 901 | + | // Queries the events reported for the fd corresponding to @tag on | |
| 902 | + | // @source during the last poll. | |
| 903 | + | // | |
| 904 | + | // The return value of this function is only defined when the function | |
| 905 | + | // is called from the check or dispatch functions for @source. | |
| 906 | + | // | |
| 907 | + | // This API is only intended to be used by implementations of #GSource. | |
| 908 | + | // Do not call this API on a #GSource that you did not create. | |
| 909 | + | // | |
| 910 | + | // As the name suggests, this function is not available on Windows. | |
| 911 | + | func (x *Source) QueryUnixFd(TagVar uintptr) IOCondition { | |
| 912 | + | ||
| 913 | + | cret := xSourceQueryUnixFd(x.GoPointer(), TagVar) | |
| 914 | + | return cret | |
| 915 | + | } | |
| 916 | + | ||
| 917 | + | var xSourceRef func(uintptr) *Source | |
| 918 | + | ||
| 919 | + | // Increases the reference count on a source by one. | |
| 920 | + | func (x *Source) Ref() *Source { | |
| 921 | + | ||
| 922 | + | cret := xSourceRef(x.GoPointer()) | |
| 923 | + | return cret | |
| 924 | + | } | |
| 925 | + | ||
| 926 | + | var xSourceRemoveChildSource func(uintptr, *Source) | |
| 927 | + | ||
| 928 | + | // Detaches @child_source from @source and destroys it. | |
| 929 | + | // | |
| 930 | + | // This API is only intended to be used by implementations of #GSource. | |
| 931 | + | // Do not call this API on a #GSource that you did not create. | |
| 932 | + | func (x *Source) RemoveChildSource(ChildSourceVar *Source) { | |
| 933 | + | ||
| 934 | + | xSourceRemoveChildSource(x.GoPointer(), ChildSourceVar) | |
| 935 | + | ||
| 936 | + | } | |
| 937 | + | ||
| 938 | + | var xSourceRemovePoll func(uintptr, *PollFD) | |
| 939 | + | ||
| 940 | + | // Removes a file descriptor from the set of file descriptors polled for | |
| 941 | + | // this source. | |
| 942 | + | // | |
| 943 | + | // This API is only intended to be used by implementations of #GSource. | |
| 944 | + | // Do not call this API on a #GSource that you did not create. | |
| 945 | + | func (x *Source) RemovePoll(FdVar *PollFD) { | |
| 946 | + | ||
| 947 | + | xSourceRemovePoll(x.GoPointer(), FdVar) | |
| 948 | + | ||
| 949 | + | } | |
| 950 | + | ||
| 951 | + | var xSourceRemoveUnixFd func(uintptr, uintptr) | |
| 952 | + | ||
| 953 | + | // Reverses the effect of a previous call to g_source_add_unix_fd(). | |
| 954 | + | // | |
| 955 | + | // You only need to call this if you want to remove an fd from being | |
| 956 | + | // watched while keeping the same source around. In the normal case you | |
| 957 | + | // will just want to destroy the source. | |
| 958 | + | // | |
| 959 | + | // This API is only intended to be used by implementations of #GSource. | |
| 960 | + | // Do not call this API on a #GSource that you did not create. | |
| 961 | + | // | |
| 962 | + | // As the name suggests, this function is not available on Windows. | |
| 963 | + | func (x *Source) RemoveUnixFd(TagVar uintptr) { | |
| 964 | + | ||
| 965 | + | xSourceRemoveUnixFd(x.GoPointer(), TagVar) | |
| 966 | + | ||
| 967 | + | } | |
| 968 | + | ||
| 969 | + | var xSourceSetCallback func(uintptr, uintptr, uintptr, uintptr) | |
| 970 | + | ||
| 971 | + | // Sets the callback function for a source. The callback for a source is | |
| 972 | + | // called from the source's dispatch function. | |
| 973 | + | // | |
| 974 | + | // The exact type of @func depends on the type of source; ie. you | |
| 975 | + | // should not count on @func being called with @data as its first | |
| 976 | + | // parameter. Cast @func with G_SOURCE_FUNC() to avoid warnings about | |
| 977 | + | // incompatible function types. | |
| 978 | + | // | |
| 979 | + | // See [memory management of sources][mainloop-memory-management] for details | |
| 980 | + | // on how to handle memory management of @data. | |
| 981 | + | // | |
| 982 | + | // Typically, you won't use this function. Instead use functions specific | |
| 983 | + | // to the type of source you are using, such as g_idle_add() or g_timeout_add(). | |
| 984 | + | // | |
| 985 | + | // It is safe to call this function multiple times on a source which has already | |
| 986 | + | // been attached to a context. The changes will take effect for the next time | |
| 987 | + | // the source is dispatched after this call returns. | |
| 988 | + | // | |
| 989 | + | // Note that g_source_destroy() for a currently attached source has the effect | |
| 990 | + | // of also unsetting the callback. | |
| 991 | + | func (x *Source) SetCallback(FuncVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) { | |
| 992 | + | ||
| 993 | + | xSourceSetCallback(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 994 | + | ||
| 995 | + | } | |
| 996 | + | ||
| 997 | + | var xSourceSetCallbackIndirect func(uintptr, uintptr, *SourceCallbackFuncs) | |
| 998 | + | ||
| 999 | + | // Sets the callback function storing the data as a refcounted callback | |
| 1000 | + | // "object". This is used internally. Note that calling | |
| 1001 | + | // g_source_set_callback_indirect() assumes | |
| 1002 | + | // an initial reference count on @callback_data, and thus | |
| 1003 | + | // @callback_funcs->unref will eventually be called once more | |
| 1004 | + | // than @callback_funcs->ref. | |
| 1005 | + | // | |
| 1006 | + | // It is safe to call this function multiple times on a source which has already | |
| 1007 | + | // been attached to a context. The changes will take effect for the next time | |
| 1008 | + | // the source is dispatched after this call returns. | |
| 1009 | + | func (x *Source) SetCallbackIndirect(CallbackDataVar uintptr, CallbackFuncsVar *SourceCallbackFuncs) { | |
| 1010 | + | ||
| 1011 | + | xSourceSetCallbackIndirect(x.GoPointer(), CallbackDataVar, CallbackFuncsVar) | |
| 1012 | + | ||
| 1013 | + | } | |
| 1014 | + | ||
| 1015 | + | var xSourceSetCanRecurse func(uintptr, bool) | |
| 1016 | + | ||
| 1017 | + | // Sets whether a source can be called recursively. If @can_recurse is | |
| 1018 | + | // %TRUE, then while the source is being dispatched then this source | |
| 1019 | + | // will be processed normally. Otherwise, all processing of this | |
| 1020 | + | // source is blocked until the dispatch function returns. | |
| 1021 | + | func (x *Source) SetCanRecurse(CanRecurseVar bool) { | |
| 1022 | + | ||
| 1023 | + | xSourceSetCanRecurse(x.GoPointer(), CanRecurseVar) | |
| 1024 | + | ||
| 1025 | + | } | |
| 1026 | + | ||
| 1027 | + | var xSourceSetDisposeFunction func(uintptr, uintptr) | |
| 1028 | + | ||
| 1029 | + | // Set @dispose as dispose function on @source. @dispose will be called once | |
| 1030 | + | // the reference count of @source reaches 0 but before any of the state of the | |
| 1031 | + | // source is freed, especially before the finalize function is called. | |
| 1032 | + | // | |
| 1033 | + | // This means that at this point @source is still a valid #GSource and it is | |
| 1034 | + | // allow for the reference count to increase again until @dispose returns. | |
| 1035 | + | // | |
| 1036 | + | // The dispose function can be used to clear any "weak" references to the | |
| 1037 | + | // @source in other data structures in a thread-safe way where it is possible | |
| 1038 | + | // for another thread to increase the reference count of @source again while | |
| 1039 | + | // it is being freed. | |
| 1040 | + | // | |
| 1041 | + | // The finalize function can not be used for this purpose as at that point | |
| 1042 | + | // @source is already partially freed and not valid anymore. | |
| 1043 | + | // | |
| 1044 | + | // This should only ever be called from #GSource implementations. | |
| 1045 | + | func (x *Source) SetDisposeFunction(DisposeVar SourceDisposeFunc) { | |
| 1046 | + | ||
| 1047 | + | xSourceSetDisposeFunction(x.GoPointer(), purego.NewCallback(DisposeVar)) | |
| 1048 | + | ||
| 1049 | + | } | |
| 1050 | + | ||
| 1051 | + | var xSourceSetFuncs func(uintptr, *SourceFuncs) | |
| 1052 | + | ||
| 1053 | + | // Sets the source functions (can be used to override | |
| 1054 | + | // default implementations) of an unattached source. | |
| 1055 | + | func (x *Source) SetFuncs(FuncsVar *SourceFuncs) { | |
| 1056 | + | ||
| 1057 | + | xSourceSetFuncs(x.GoPointer(), FuncsVar) | |
| 1058 | + | ||
| 1059 | + | } | |
| 1060 | + | ||
| 1061 | + | var xSourceSetName func(uintptr, string) | |
| 1062 | + | ||
| 1063 | + | // Sets a name for the source, used in debugging and profiling. | |
| 1064 | + | // The name defaults to #NULL. | |
| 1065 | + | // | |
| 1066 | + | // The source name should describe in a human-readable way | |
| 1067 | + | // what the source does. For example, "X11 event queue" | |
| 1068 | + | // or "GTK+ repaint idle handler" or whatever it is. | |
| 1069 | + | // | |
| 1070 | + | // It is permitted to call this function multiple times, but is not | |
| 1071 | + | // recommended due to the potential performance impact. For example, | |
| 1072 | + | // one could change the name in the "check" function of a #GSourceFuncs | |
| 1073 | + | // to include details like the event type in the source name. | |
| 1074 | + | // | |
| 1075 | + | // Use caution if changing the name while another thread may be | |
| 1076 | + | // accessing it with g_source_get_name(); that function does not copy | |
| 1077 | + | // the value, and changing the value will free it while the other thread | |
| 1078 | + | // may be attempting to use it. | |
| 1079 | + | // | |
| 1080 | + | // Also see g_source_set_static_name(). | |
| 1081 | + | func (x *Source) SetName(NameVar string) { | |
| 1082 | + | ||
| 1083 | + | xSourceSetName(x.GoPointer(), NameVar) | |
| 1084 | + | ||
| 1085 | + | } | |
| 1086 | + | ||
| 1087 | + | var xSourceSetPriority func(uintptr, int) | |
| 1088 | + | ||
| 1089 | + | // Sets the priority of a source. While the main loop is being run, a | |
| 1090 | + | // source will be dispatched if it is ready to be dispatched and no | |
| 1091 | + | // sources at a higher (numerically smaller) priority are ready to be | |
| 1092 | + | // dispatched. | |
| 1093 | + | // | |
| 1094 | + | // A child source always has the same priority as its parent. It is not | |
| 1095 | + | // permitted to change the priority of a source once it has been added | |
| 1096 | + | // as a child of another source. | |
| 1097 | + | func (x *Source) SetPriority(PriorityVar int) { | |
| 1098 | + | ||
| 1099 | + | xSourceSetPriority(x.GoPointer(), PriorityVar) | |
| 1100 | + | ||
| 1101 | + | } | |
| 1102 | + | ||
| 1103 | + | var xSourceSetReadyTime func(uintptr, int64) | |
| 1104 | + | ||
| 1105 | + | // Sets a #GSource to be dispatched when the given monotonic time is | |
| 1106 | + | // reached (or passed). If the monotonic time is in the past (as it | |
| 1107 | + | // always will be if @ready_time is 0) then the source will be | |
| 1108 | + | // dispatched immediately. | |
| 1109 | + | // | |
| 1110 | + | // If @ready_time is -1 then the source is never woken up on the basis | |
| 1111 | + | // of the passage of time. | |
| 1112 | + | // | |
| 1113 | + | // Dispatching the source does not reset the ready time. You should do | |
| 1114 | + | // so yourself, from the source dispatch function. | |
| 1115 | + | // | |
| 1116 | + | // Note that if you have a pair of sources where the ready time of one | |
| 1117 | + | // suggests that it will be delivered first but the priority for the | |
| 1118 | + | // other suggests that it would be delivered first, and the ready time | |
| 1119 | + | // for both sources is reached during the same main context iteration, | |
| 1120 | + | // then the order of dispatch is undefined. | |
| 1121 | + | // | |
| 1122 | + | // It is a no-op to call this function on a #GSource which has already been | |
| 1123 | + | // destroyed with g_source_destroy(). | |
| 1124 | + | // | |
| 1125 | + | // This API is only intended to be used by implementations of #GSource. | |
| 1126 | + | // Do not call this API on a #GSource that you did not create. | |
| 1127 | + | func (x *Source) SetReadyTime(ReadyTimeVar int64) { | |
| 1128 | + | ||
| 1129 | + | xSourceSetReadyTime(x.GoPointer(), ReadyTimeVar) | |
| 1130 | + | ||
| 1131 | + | } | |
| 1132 | + | ||
| 1133 | + | var xSourceSetStaticName func(uintptr, string) | |
| 1134 | + | ||
| 1135 | + | // A variant of g_source_set_name() that does not | |
| 1136 | + | // duplicate the @name, and can only be used with | |
| 1137 | + | // string literals. | |
| 1138 | + | func (x *Source) SetStaticName(NameVar string) { | |
| 1139 | + | ||
| 1140 | + | xSourceSetStaticName(x.GoPointer(), NameVar) | |
| 1141 | + | ||
| 1142 | + | } | |
| 1143 | + | ||
| 1144 | + | var xSourceUnref func(uintptr) | |
| 1145 | + | ||
| 1146 | + | // Decreases the reference count of a source by one. If the | |
| 1147 | + | // resulting reference count is zero the source and associated | |
| 1148 | + | // memory will be destroyed. | |
| 1149 | + | func (x *Source) Unref() { | |
| 1150 | + | ||
| 1151 | + | xSourceUnref(x.GoPointer()) | |
| 1152 | + | ||
| 1153 | + | } | |
| 1154 | + | ||
| 80 | 1155 | // The `GSourceCallbackFuncs` struct contains | |
| 81 | 1156 | // functions for managing callback objects. | |
| 82 | 1157 | type SourceCallbackFuncs struct { | |
| 83 | 1158 | } | |
| 84 | 1159 | ||
| 1160 | + | func (x *SourceCallbackFuncs) GoPointer() uintptr { | |
| 1161 | + | return uintptr(unsafe.Pointer(x)) | |
| 1162 | + | } | |
| 1163 | + | ||
| 85 | 1164 | // The `GSourceFuncs` struct contains a table of | |
| 86 | 1165 | // functions used to handle event sources in a generic manner. | |
| 87 | 1166 | // | |
| @@ -108,12 +1187,55 @@ type SourceFuncs struct { | |||
| 108 | 1187 | ClosureMarshal SourceDummyMarshal | |
| 109 | 1188 | } | |
| 110 | 1189 | ||
| 1190 | + | func (x *SourceFuncs) GoPointer() uintptr { | |
| 1191 | + | return uintptr(unsafe.Pointer(x)) | |
| 1192 | + | } | |
| 1193 | + | ||
| 111 | 1194 | type SourcePrivate struct { | |
| 112 | 1195 | } | |
| 113 | 1196 | ||
| 1197 | + | func (x *SourcePrivate) GoPointer() uintptr { | |
| 1198 | + | return uintptr(unsafe.Pointer(x)) | |
| 1199 | + | } | |
| 1200 | + | ||
| 114 | 1201 | // Opaque type. See g_main_context_pusher_new() for details. | |
| 115 | 1202 | type MainContextPusher = uintptr | |
| 116 | 1203 | ||
| 1204 | + | const ( | |
| 1205 | + | // Use this for default priority event sources. | |
| 1206 | + | // | |
| 1207 | + | // In GLib this priority is used when adding timeout functions | |
| 1208 | + | // with g_timeout_add(). In GDK this priority is used for events | |
| 1209 | + | // from the X server. | |
| 1210 | + | PRIORITY_DEFAULT int = 0 | |
| 1211 | + | // Use this for default priority idle functions. | |
| 1212 | + | // | |
| 1213 | + | // In GLib this priority is used when adding idle functions with | |
| 1214 | + | // g_idle_add(). | |
| 1215 | + | PRIORITY_DEFAULT_IDLE int = 200 | |
| 1216 | + | // Use this for high priority event sources. | |
| 1217 | + | // | |
| 1218 | + | // It is not used within GLib or GTK+. | |
| 1219 | + | PRIORITY_HIGH int = -100 | |
| 1220 | + | // Use this for high priority idle functions. | |
| 1221 | + | // | |
| 1222 | + | // GTK+ uses %G_PRIORITY_HIGH_IDLE + 10 for resizing operations, | |
| 1223 | + | // and %G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is | |
| 1224 | + | // done to ensure that any pending resizes are processed before any | |
| 1225 | + | // pending redraws, so that widgets are not redrawn twice unnecessarily.) | |
| 1226 | + | PRIORITY_HIGH_IDLE int = 100 | |
| 1227 | + | // Use this for very low priority background tasks. | |
| 1228 | + | // | |
| 1229 | + | // It is not used within GLib or GTK+. | |
| 1230 | + | PRIORITY_LOW int = 300 | |
| 1231 | + | // Use this macro as the return value of a #GSourceFunc to leave | |
| 1232 | + | // the #GSource in the main loop. | |
| 1233 | + | SOURCE_CONTINUE bool = true | |
| 1234 | + | // Use this macro as the return value of a #GSourceFunc to remove | |
| 1235 | + | // the #GSource from the main loop. | |
| 1236 | + | SOURCE_REMOVE bool = false | |
| 1237 | + | ) | |
| 1238 | + | ||
| 117 | 1239 | // Flags to pass to g_main_context_new_with_flags() which affect the behaviour | |
| 118 | 1240 | // of a #GMainContext. | |
| 119 | 1241 | type MainContextFlags int | |
| @@ -823,4 +1945,74 @@ func init() { | |||
| 823 | 1945 | core.PuregoSafeRegister(&xTimeoutSourceNew, lib, "g_timeout_source_new") | |
| 824 | 1946 | core.PuregoSafeRegister(&xTimeoutSourceNewSeconds, lib, "g_timeout_source_new_seconds") | |
| 825 | 1947 | ||
| 1948 | + | core.PuregoSafeRegister(&xNewMainContext, lib, "g_main_context_new") | |
| 1949 | + | core.PuregoSafeRegister(&xNewWithFlagsMainContext, lib, "g_main_context_new_with_flags") | |
| 1950 | + | ||
| 1951 | + | core.PuregoSafeRegister(&xMainContextAcquire, lib, "g_main_context_acquire") | |
| 1952 | + | core.PuregoSafeRegister(&xMainContextAddPoll, lib, "g_main_context_add_poll") | |
| 1953 | + | core.PuregoSafeRegister(&xMainContextCheck, lib, "g_main_context_check") | |
| 1954 | + | core.PuregoSafeRegister(&xMainContextDispatch, lib, "g_main_context_dispatch") | |
| 1955 | + | core.PuregoSafeRegister(&xMainContextFindSourceByFuncsUserData, lib, "g_main_context_find_source_by_funcs_user_data") | |
| 1956 | + | core.PuregoSafeRegister(&xMainContextFindSourceById, lib, "g_main_context_find_source_by_id") | |
| 1957 | + | core.PuregoSafeRegister(&xMainContextFindSourceByUserData, lib, "g_main_context_find_source_by_user_data") | |
| 1958 | + | core.PuregoSafeRegister(&xMainContextGetPollFunc, lib, "g_main_context_get_poll_func") | |
| 1959 | + | core.PuregoSafeRegister(&xMainContextInvoke, lib, "g_main_context_invoke") | |
| 1960 | + | core.PuregoSafeRegister(&xMainContextInvokeFull, lib, "g_main_context_invoke_full") | |
| 1961 | + | core.PuregoSafeRegister(&xMainContextIsOwner, lib, "g_main_context_is_owner") | |
| 1962 | + | core.PuregoSafeRegister(&xMainContextIteration, lib, "g_main_context_iteration") | |
| 1963 | + | core.PuregoSafeRegister(&xMainContextPending, lib, "g_main_context_pending") | |
| 1964 | + | core.PuregoSafeRegister(&xMainContextPopThreadDefault, lib, "g_main_context_pop_thread_default") | |
| 1965 | + | core.PuregoSafeRegister(&xMainContextPrepare, lib, "g_main_context_prepare") | |
| 1966 | + | core.PuregoSafeRegister(&xMainContextPushThreadDefault, lib, "g_main_context_push_thread_default") | |
| 1967 | + | core.PuregoSafeRegister(&xMainContextQuery, lib, "g_main_context_query") | |
| 1968 | + | core.PuregoSafeRegister(&xMainContextRef, lib, "g_main_context_ref") | |
| 1969 | + | core.PuregoSafeRegister(&xMainContextRelease, lib, "g_main_context_release") | |
| 1970 | + | core.PuregoSafeRegister(&xMainContextRemovePoll, lib, "g_main_context_remove_poll") | |
| 1971 | + | core.PuregoSafeRegister(&xMainContextSetPollFunc, lib, "g_main_context_set_poll_func") | |
| 1972 | + | core.PuregoSafeRegister(&xMainContextUnref, lib, "g_main_context_unref") | |
| 1973 | + | core.PuregoSafeRegister(&xMainContextWait, lib, "g_main_context_wait") | |
| 1974 | + | core.PuregoSafeRegister(&xMainContextWakeup, lib, "g_main_context_wakeup") | |
| 1975 | + | ||
| 1976 | + | core.PuregoSafeRegister(&xNewMainLoop, lib, "g_main_loop_new") | |
| 1977 | + | ||
| 1978 | + | core.PuregoSafeRegister(&xMainLoopGetContext, lib, "g_main_loop_get_context") | |
| 1979 | + | core.PuregoSafeRegister(&xMainLoopIsRunning, lib, "g_main_loop_is_running") | |
| 1980 | + | core.PuregoSafeRegister(&xMainLoopQuit, lib, "g_main_loop_quit") | |
| 1981 | + | core.PuregoSafeRegister(&xMainLoopRef, lib, "g_main_loop_ref") | |
| 1982 | + | core.PuregoSafeRegister(&xMainLoopRun, lib, "g_main_loop_run") | |
| 1983 | + | core.PuregoSafeRegister(&xMainLoopUnref, lib, "g_main_loop_unref") | |
| 1984 | + | ||
| 1985 | + | core.PuregoSafeRegister(&xNewSource, lib, "g_source_new") | |
| 1986 | + | ||
| 1987 | + | core.PuregoSafeRegister(&xSourceAddChildSource, lib, "g_source_add_child_source") | |
| 1988 | + | core.PuregoSafeRegister(&xSourceAddPoll, lib, "g_source_add_poll") | |
| 1989 | + | core.PuregoSafeRegister(&xSourceAddUnixFd, lib, "g_source_add_unix_fd") | |
| 1990 | + | core.PuregoSafeRegister(&xSourceAttach, lib, "g_source_attach") | |
| 1991 | + | core.PuregoSafeRegister(&xSourceDestroy, lib, "g_source_destroy") | |
| 1992 | + | core.PuregoSafeRegister(&xSourceGetCanRecurse, lib, "g_source_get_can_recurse") | |
| 1993 | + | core.PuregoSafeRegister(&xSourceGetContext, lib, "g_source_get_context") | |
| 1994 | + | core.PuregoSafeRegister(&xSourceGetCurrentTime, lib, "g_source_get_current_time") | |
| 1995 | + | core.PuregoSafeRegister(&xSourceGetId, lib, "g_source_get_id") | |
| 1996 | + | core.PuregoSafeRegister(&xSourceGetName, lib, "g_source_get_name") | |
| 1997 | + | core.PuregoSafeRegister(&xSourceGetPriority, lib, "g_source_get_priority") | |
| 1998 | + | core.PuregoSafeRegister(&xSourceGetReadyTime, lib, "g_source_get_ready_time") | |
| 1999 | + | core.PuregoSafeRegister(&xSourceGetTime, lib, "g_source_get_time") | |
| 2000 | + | core.PuregoSafeRegister(&xSourceIsDestroyed, lib, "g_source_is_destroyed") | |
| 2001 | + | core.PuregoSafeRegister(&xSourceModifyUnixFd, lib, "g_source_modify_unix_fd") | |
| 2002 | + | core.PuregoSafeRegister(&xSourceQueryUnixFd, lib, "g_source_query_unix_fd") | |
| 2003 | + | core.PuregoSafeRegister(&xSourceRef, lib, "g_source_ref") | |
| 2004 | + | core.PuregoSafeRegister(&xSourceRemoveChildSource, lib, "g_source_remove_child_source") | |
| 2005 | + | core.PuregoSafeRegister(&xSourceRemovePoll, lib, "g_source_remove_poll") | |
| 2006 | + | core.PuregoSafeRegister(&xSourceRemoveUnixFd, lib, "g_source_remove_unix_fd") | |
| 2007 | + | core.PuregoSafeRegister(&xSourceSetCallback, lib, "g_source_set_callback") | |
| 2008 | + | core.PuregoSafeRegister(&xSourceSetCallbackIndirect, lib, "g_source_set_callback_indirect") | |
| 2009 | + | core.PuregoSafeRegister(&xSourceSetCanRecurse, lib, "g_source_set_can_recurse") | |
| 2010 | + | core.PuregoSafeRegister(&xSourceSetDisposeFunction, lib, "g_source_set_dispose_function") | |
| 2011 | + | core.PuregoSafeRegister(&xSourceSetFuncs, lib, "g_source_set_funcs") | |
| 2012 | + | core.PuregoSafeRegister(&xSourceSetName, lib, "g_source_set_name") | |
| 2013 | + | core.PuregoSafeRegister(&xSourceSetPriority, lib, "g_source_set_priority") | |
| 2014 | + | core.PuregoSafeRegister(&xSourceSetReadyTime, lib, "g_source_set_ready_time") | |
| 2015 | + | core.PuregoSafeRegister(&xSourceSetStaticName, lib, "g_source_set_static_name") | |
| 2016 | + | core.PuregoSafeRegister(&xSourceUnref, lib, "g_source_unref") | |
| 2017 | + | ||
| 826 | 2018 | } | |
M v4/glib/gmappedfile.go +150 -0
| @@ -1,8 +1,158 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // The #GMappedFile represents a file mapping created with | |
| 5 | 12 | // g_mapped_file_new(). It has only private members and should | |
| 6 | 13 | // not be accessed directly. | |
| 7 | 14 | type MappedFile struct { | |
| 8 | 15 | } | |
| 16 | + | ||
| 17 | + | func (x *MappedFile) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | var xNewMappedFile func(string, bool, **Error) *MappedFile | |
| 22 | + | ||
| 23 | + | // Maps a file into memory. On UNIX, this is using the mmap() function. | |
| 24 | + | // | |
| 25 | + | // If @writable is %TRUE, the mapped buffer may be modified, otherwise | |
| 26 | + | // it is an error to modify the mapped buffer. Modifications to the buffer | |
| 27 | + | // are not visible to other processes mapping the same file, and are not | |
| 28 | + | // written back to the file. | |
| 29 | + | // | |
| 30 | + | // Note that modifications of the underlying file might affect the contents | |
| 31 | + | // of the #GMappedFile. Therefore, mapping should only be used if the file | |
| 32 | + | // will not be modified, or if all modifications of the file are done | |
| 33 | + | // atomically (e.g. using g_file_set_contents()). | |
| 34 | + | // | |
| 35 | + | // If @filename is the name of an empty, regular file, the function | |
| 36 | + | // will successfully return an empty #GMappedFile. In other cases of | |
| 37 | + | // size 0 (e.g. device files such as /dev/null), @error will be set | |
| 38 | + | // to the #GFileError value %G_FILE_ERROR_INVAL. | |
| 39 | + | func NewMappedFile(FilenameVar string, WritableVar bool) (*MappedFile, error) { | |
| 40 | + | var cerr *Error | |
| 41 | + | ||
| 42 | + | cret := xNewMappedFile(FilenameVar, WritableVar, &cerr) | |
| 43 | + | if cerr == nil { | |
| 44 | + | return cret, nil | |
| 45 | + | } | |
| 46 | + | return cret, cerr | |
| 47 | + | ||
| 48 | + | } | |
| 49 | + | ||
| 50 | + | var xNewFromFdMappedFile func(int, bool, **Error) *MappedFile | |
| 51 | + | ||
| 52 | + | // Maps a file into memory. On UNIX, this is using the mmap() function. | |
| 53 | + | // | |
| 54 | + | // If @writable is %TRUE, the mapped buffer may be modified, otherwise | |
| 55 | + | // it is an error to modify the mapped buffer. Modifications to the buffer | |
| 56 | + | // are not visible to other processes mapping the same file, and are not | |
| 57 | + | // written back to the file. | |
| 58 | + | // | |
| 59 | + | // Note that modifications of the underlying file might affect the contents | |
| 60 | + | // of the #GMappedFile. Therefore, mapping should only be used if the file | |
| 61 | + | // will not be modified, or if all modifications of the file are done | |
| 62 | + | // atomically (e.g. using g_file_set_contents()). | |
| 63 | + | func NewFromFdMappedFile(FdVar int, WritableVar bool) (*MappedFile, error) { | |
| 64 | + | var cerr *Error | |
| 65 | + | ||
| 66 | + | cret := xNewFromFdMappedFile(FdVar, WritableVar, &cerr) | |
| 67 | + | if cerr == nil { | |
| 68 | + | return cret, nil | |
| 69 | + | } | |
| 70 | + | return cret, cerr | |
| 71 | + | ||
| 72 | + | } | |
| 73 | + | ||
| 74 | + | var xMappedFileFree func(uintptr) | |
| 75 | + | ||
| 76 | + | // This call existed before #GMappedFile had refcounting and is currently | |
| 77 | + | // exactly the same as g_mapped_file_unref(). | |
| 78 | + | func (x *MappedFile) Free() { | |
| 79 | + | ||
| 80 | + | xMappedFileFree(x.GoPointer()) | |
| 81 | + | ||
| 82 | + | } | |
| 83 | + | ||
| 84 | + | var xMappedFileGetBytes func(uintptr) *Bytes | |
| 85 | + | ||
| 86 | + | // Creates a new #GBytes which references the data mapped from @file. | |
| 87 | + | // The mapped contents of the file must not be modified after creating this | |
| 88 | + | // bytes object, because a #GBytes should be immutable. | |
| 89 | + | func (x *MappedFile) GetBytes() *Bytes { | |
| 90 | + | ||
| 91 | + | cret := xMappedFileGetBytes(x.GoPointer()) | |
| 92 | + | return cret | |
| 93 | + | } | |
| 94 | + | ||
| 95 | + | var xMappedFileGetContents func(uintptr) string | |
| 96 | + | ||
| 97 | + | // Returns the contents of a #GMappedFile. | |
| 98 | + | // | |
| 99 | + | // Note that the contents may not be zero-terminated, | |
| 100 | + | // even if the #GMappedFile is backed by a text file. | |
| 101 | + | // | |
| 102 | + | // If the file is empty then %NULL is returned. | |
| 103 | + | func (x *MappedFile) GetContents() string { | |
| 104 | + | ||
| 105 | + | cret := xMappedFileGetContents(x.GoPointer()) | |
| 106 | + | return cret | |
| 107 | + | } | |
| 108 | + | ||
| 109 | + | var xMappedFileGetLength func(uintptr) uint | |
| 110 | + | ||
| 111 | + | // Returns the length of the contents of a #GMappedFile. | |
| 112 | + | func (x *MappedFile) GetLength() uint { | |
| 113 | + | ||
| 114 | + | cret := xMappedFileGetLength(x.GoPointer()) | |
| 115 | + | return cret | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xMappedFileRef func(uintptr) *MappedFile | |
| 119 | + | ||
| 120 | + | // Increments the reference count of @file by one. It is safe to call | |
| 121 | + | // this function from any thread. | |
| 122 | + | func (x *MappedFile) Ref() *MappedFile { | |
| 123 | + | ||
| 124 | + | cret := xMappedFileRef(x.GoPointer()) | |
| 125 | + | return cret | |
| 126 | + | } | |
| 127 | + | ||
| 128 | + | var xMappedFileUnref func(uintptr) | |
| 129 | + | ||
| 130 | + | // Decrements the reference count of @file by one. If the reference count | |
| 131 | + | // drops to 0, unmaps the buffer of @file and frees it. | |
| 132 | + | // | |
| 133 | + | // It is safe to call this function from any thread. | |
| 134 | + | // | |
| 135 | + | // Since 2.22 | |
| 136 | + | func (x *MappedFile) Unref() { | |
| 137 | + | ||
| 138 | + | xMappedFileUnref(x.GoPointer()) | |
| 139 | + | ||
| 140 | + | } | |
| 141 | + | ||
| 142 | + | func init() { | |
| 143 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 144 | + | if err != nil { | |
| 145 | + | panic(err) | |
| 146 | + | } | |
| 147 | + | ||
| 148 | + | core.PuregoSafeRegister(&xNewMappedFile, lib, "g_mapped_file_new") | |
| 149 | + | core.PuregoSafeRegister(&xNewFromFdMappedFile, lib, "g_mapped_file_new_from_fd") | |
| 150 | + | ||
| 151 | + | core.PuregoSafeRegister(&xMappedFileFree, lib, "g_mapped_file_free") | |
| 152 | + | core.PuregoSafeRegister(&xMappedFileGetBytes, lib, "g_mapped_file_get_bytes") | |
| 153 | + | core.PuregoSafeRegister(&xMappedFileGetContents, lib, "g_mapped_file_get_contents") | |
| 154 | + | core.PuregoSafeRegister(&xMappedFileGetLength, lib, "g_mapped_file_get_length") | |
| 155 | + | core.PuregoSafeRegister(&xMappedFileRef, lib, "g_mapped_file_ref") | |
| 156 | + | core.PuregoSafeRegister(&xMappedFileUnref, lib, "g_mapped_file_unref") | |
| 157 | + | ||
| 158 | + | } | |
M v4/glib/gmarkup.go +322 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -14,6 +16,308 @@ import ( | |||
| 14 | 16 | type MarkupParseContext struct { | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *MarkupParseContext) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 23 | + | var xNewMarkupParseContext func(*MarkupParser, MarkupParseFlags, uintptr, uintptr) *MarkupParseContext | |
| 24 | + | ||
| 25 | + | // Creates a new parse context. A parse context is used to parse | |
| 26 | + | // marked-up documents. You can feed any number of documents into | |
| 27 | + | // a context, as long as no errors occur; once an error occurs, | |
| 28 | + | // the parse context can't continue to parse text (you have to | |
| 29 | + | // free it and create a new parse context). | |
| 30 | + | func NewMarkupParseContext(ParserVar *MarkupParser, FlagsVar MarkupParseFlags, UserDataVar uintptr, UserDataDnotifyVar DestroyNotify) *MarkupParseContext { | |
| 31 | + | ||
| 32 | + | cret := xNewMarkupParseContext(ParserVar, FlagsVar, UserDataVar, purego.NewCallback(UserDataDnotifyVar)) | |
| 33 | + | return cret | |
| 34 | + | } | |
| 35 | + | ||
| 36 | + | var xMarkupParseContextEndParse func(uintptr) bool | |
| 37 | + | ||
| 38 | + | // Signals to the #GMarkupParseContext that all data has been | |
| 39 | + | // fed into the parse context with g_markup_parse_context_parse(). | |
| 40 | + | // | |
| 41 | + | // This function reports an error if the document isn't complete, | |
| 42 | + | // for example if elements are still open. | |
| 43 | + | func (x *MarkupParseContext) EndParse() (bool, error) { | |
| 44 | + | var cerr *Error | |
| 45 | + | ||
| 46 | + | cret := xMarkupParseContextEndParse(x.GoPointer()) | |
| 47 | + | if cerr == nil { | |
| 48 | + | return cret, nil | |
| 49 | + | } | |
| 50 | + | return cret, cerr | |
| 51 | + | ||
| 52 | + | } | |
| 53 | + | ||
| 54 | + | var xMarkupParseContextFree func(uintptr) | |
| 55 | + | ||
| 56 | + | // Frees a #GMarkupParseContext. | |
| 57 | + | // | |
| 58 | + | // This function can't be called from inside one of the | |
| 59 | + | // #GMarkupParser functions or while a subparser is pushed. | |
| 60 | + | func (x *MarkupParseContext) Free() { | |
| 61 | + | ||
| 62 | + | xMarkupParseContextFree(x.GoPointer()) | |
| 63 | + | ||
| 64 | + | } | |
| 65 | + | ||
| 66 | + | var xMarkupParseContextGetElement func(uintptr) string | |
| 67 | + | ||
| 68 | + | // Retrieves the name of the currently open element. | |
| 69 | + | // | |
| 70 | + | // If called from the start_element or end_element handlers this will | |
| 71 | + | // give the element_name as passed to those functions. For the parent | |
| 72 | + | // elements, see g_markup_parse_context_get_element_stack(). | |
| 73 | + | func (x *MarkupParseContext) GetElement() string { | |
| 74 | + | ||
| 75 | + | cret := xMarkupParseContextGetElement(x.GoPointer()) | |
| 76 | + | return cret | |
| 77 | + | } | |
| 78 | + | ||
| 79 | + | var xMarkupParseContextGetElementStack func(uintptr) *SList | |
| 80 | + | ||
| 81 | + | // Retrieves the element stack from the internal state of the parser. | |
| 82 | + | // | |
| 83 | + | // The returned #GSList is a list of strings where the first item is | |
| 84 | + | // the currently open tag (as would be returned by | |
| 85 | + | // g_markup_parse_context_get_element()) and the next item is its | |
| 86 | + | // immediate parent. | |
| 87 | + | // | |
| 88 | + | // This function is intended to be used in the start_element and | |
| 89 | + | // end_element handlers where g_markup_parse_context_get_element() | |
| 90 | + | // would merely return the name of the element that is being | |
| 91 | + | // processed. | |
| 92 | + | func (x *MarkupParseContext) GetElementStack() *SList { | |
| 93 | + | ||
| 94 | + | cret := xMarkupParseContextGetElementStack(x.GoPointer()) | |
| 95 | + | return cret | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | var xMarkupParseContextGetPosition func(uintptr, int, int) | |
| 99 | + | ||
| 100 | + | // Retrieves the current line number and the number of the character on | |
| 101 | + | // that line. Intended for use in error messages; there are no strict | |
| 102 | + | // semantics for what constitutes the "current" line number other than | |
| 103 | + | // "the best number we could come up with for error messages." | |
| 104 | + | func (x *MarkupParseContext) GetPosition(LineNumberVar int, CharNumberVar int) { | |
| 105 | + | ||
| 106 | + | xMarkupParseContextGetPosition(x.GoPointer(), LineNumberVar, CharNumberVar) | |
| 107 | + | ||
| 108 | + | } | |
| 109 | + | ||
| 110 | + | var xMarkupParseContextGetUserData func(uintptr) uintptr | |
| 111 | + | ||
| 112 | + | // Returns the user_data associated with @context. | |
| 113 | + | // | |
| 114 | + | // This will either be the user_data that was provided to | |
| 115 | + | // g_markup_parse_context_new() or to the most recent call | |
| 116 | + | // of g_markup_parse_context_push(). | |
| 117 | + | func (x *MarkupParseContext) GetUserData() uintptr { | |
| 118 | + | ||
| 119 | + | cret := xMarkupParseContextGetUserData(x.GoPointer()) | |
| 120 | + | return cret | |
| 121 | + | } | |
| 122 | + | ||
| 123 | + | var xMarkupParseContextParse func(uintptr, string, int, **Error) bool | |
| 124 | + | ||
| 125 | + | // Feed some data to the #GMarkupParseContext. | |
| 126 | + | // | |
| 127 | + | // The data need not be valid UTF-8; an error will be signaled if | |
| 128 | + | // it's invalid. The data need not be an entire document; you can | |
| 129 | + | // feed a document into the parser incrementally, via multiple calls | |
| 130 | + | // to this function. Typically, as you receive data from a network | |
| 131 | + | // connection or file, you feed each received chunk of data into this | |
| 132 | + | // function, aborting the process if an error occurs. Once an error | |
| 133 | + | // is reported, no further data may be fed to the #GMarkupParseContext; | |
| 134 | + | // all errors are fatal. | |
| 135 | + | func (x *MarkupParseContext) Parse(TextVar string, TextLenVar int) (bool, error) { | |
| 136 | + | var cerr *Error | |
| 137 | + | ||
| 138 | + | cret := xMarkupParseContextParse(x.GoPointer(), TextVar, TextLenVar, &cerr) | |
| 139 | + | if cerr == nil { | |
| 140 | + | return cret, nil | |
| 141 | + | } | |
| 142 | + | return cret, cerr | |
| 143 | + | ||
| 144 | + | } | |
| 145 | + | ||
| 146 | + | var xMarkupParseContextPop func(uintptr) uintptr | |
| 147 | + | ||
| 148 | + | // Completes the process of a temporary sub-parser redirection. | |
| 149 | + | // | |
| 150 | + | // This function exists to collect the user_data allocated by a | |
| 151 | + | // matching call to g_markup_parse_context_push(). It must be called | |
| 152 | + | // in the end_element handler corresponding to the start_element | |
| 153 | + | // handler during which g_markup_parse_context_push() was called. | |
| 154 | + | // You must not call this function from the error callback -- the | |
| 155 | + | // @user_data is provided directly to the callback in that case. | |
| 156 | + | // | |
| 157 | + | // This function is not intended to be directly called by users | |
| 158 | + | // interested in invoking subparsers. Instead, it is intended to | |
| 159 | + | // be used by the subparsers themselves to implement a higher-level | |
| 160 | + | // interface. | |
| 161 | + | func (x *MarkupParseContext) Pop() uintptr { | |
| 162 | + | ||
| 163 | + | cret := xMarkupParseContextPop(x.GoPointer()) | |
| 164 | + | return cret | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xMarkupParseContextPush func(uintptr, *MarkupParser, uintptr) | |
| 168 | + | ||
| 169 | + | // Temporarily redirects markup data to a sub-parser. | |
| 170 | + | // | |
| 171 | + | // This function may only be called from the start_element handler of | |
| 172 | + | // a #GMarkupParser. It must be matched with a corresponding call to | |
| 173 | + | // g_markup_parse_context_pop() in the matching end_element handler | |
| 174 | + | // (except in the case that the parser aborts due to an error). | |
| 175 | + | // | |
| 176 | + | // All tags, text and other data between the matching tags is | |
| 177 | + | // redirected to the subparser given by @parser. @user_data is used | |
| 178 | + | // as the user_data for that parser. @user_data is also passed to the | |
| 179 | + | // error callback in the event that an error occurs. This includes | |
| 180 | + | // errors that occur in subparsers of the subparser. | |
| 181 | + | // | |
| 182 | + | // The end tag matching the start tag for which this call was made is | |
| 183 | + | // handled by the previous parser (which is given its own user_data) | |
| 184 | + | // which is why g_markup_parse_context_pop() is provided to allow "one | |
| 185 | + | // last access" to the @user_data provided to this function. In the | |
| 186 | + | // case of error, the @user_data provided here is passed directly to | |
| 187 | + | // the error callback of the subparser and g_markup_parse_context_pop() | |
| 188 | + | // should not be called. In either case, if @user_data was allocated | |
| 189 | + | // then it ought to be freed from both of these locations. | |
| 190 | + | // | |
| 191 | + | // This function is not intended to be directly called by users | |
| 192 | + | // interested in invoking subparsers. Instead, it is intended to be | |
| 193 | + | // used by the subparsers themselves to implement a higher-level | |
| 194 | + | // interface. | |
| 195 | + | // | |
| 196 | + | // As an example, see the following implementation of a simple | |
| 197 | + | // parser that counts the number of tags encountered. | |
| 198 | + | // | |
| 199 | + | // |[<!-- language="C" --> | |
| 200 | + | // typedef struct | |
| 201 | + | // | |
| 202 | + | // { | |
| 203 | + | // gint tag_count; | |
| 204 | + | // } CounterData; | |
| 205 | + | // | |
| 206 | + | // static void | |
| 207 | + | // counter_start_element (GMarkupParseContext *context, | |
| 208 | + | // | |
| 209 | + | // const gchar *element_name, | |
| 210 | + | // const gchar **attribute_names, | |
| 211 | + | // const gchar **attribute_values, | |
| 212 | + | // gpointer user_data, | |
| 213 | + | // GError **error) | |
| 214 | + | // | |
| 215 | + | // { | |
| 216 | + | // CounterData *data = user_data; | |
| 217 | + | // | |
| 218 | + | // data->tag_count++; | |
| 219 | + | // } | |
| 220 | + | // | |
| 221 | + | // static void | |
| 222 | + | // counter_error (GMarkupParseContext *context, | |
| 223 | + | // | |
| 224 | + | // GError *error, | |
| 225 | + | // gpointer user_data) | |
| 226 | + | // | |
| 227 | + | // { | |
| 228 | + | // CounterData *data = user_data; | |
| 229 | + | // | |
| 230 | + | // g_slice_free (CounterData, data); | |
| 231 | + | // } | |
| 232 | + | // | |
| 233 | + | // static GMarkupParser counter_subparser = | |
| 234 | + | // | |
| 235 | + | // { | |
| 236 | + | // counter_start_element, | |
| 237 | + | // NULL, | |
| 238 | + | // NULL, | |
| 239 | + | // NULL, | |
| 240 | + | // counter_error | |
| 241 | + | // }; | |
| 242 | + | // | |
| 243 | + | // ]| | |
| 244 | + | // | |
| 245 | + | // In order to allow this parser to be easily used as a subparser, the | |
| 246 | + | // following interface is provided: | |
| 247 | + | // | |
| 248 | + | // |[<!-- language="C" --> | |
| 249 | + | // void | |
| 250 | + | // start_counting (GMarkupParseContext *context) | |
| 251 | + | // | |
| 252 | + | // { | |
| 253 | + | // CounterData *data = g_slice_new (CounterData); | |
| 254 | + | // | |
| 255 | + | // data->tag_count = 0; | |
| 256 | + | // g_markup_parse_context_push (context, &counter_subparser, data); | |
| 257 | + | // } | |
| 258 | + | // | |
| 259 | + | // gint | |
| 260 | + | // end_counting (GMarkupParseContext *context) | |
| 261 | + | // | |
| 262 | + | // { | |
| 263 | + | // CounterData *data = g_markup_parse_context_pop (context); | |
| 264 | + | // int result; | |
| 265 | + | // | |
| 266 | + | // result = data->tag_count; | |
| 267 | + | // g_slice_free (CounterData, data); | |
| 268 | + | // | |
| 269 | + | // return result; | |
| 270 | + | // } | |
| 271 | + | // | |
| 272 | + | // ]| | |
| 273 | + | // | |
| 274 | + | // The subparser would then be used as follows: | |
| 275 | + | // | |
| 276 | + | // |[<!-- language="C" --> | |
| 277 | + | // static void start_element (context, element_name, ...) | |
| 278 | + | // | |
| 279 | + | // { | |
| 280 | + | // if (strcmp (element_name, "count-these") == 0) | |
| 281 | + | // start_counting (context); | |
| 282 | + | // | |
| 283 | + | // // else, handle other tags... | |
| 284 | + | // } | |
| 285 | + | // | |
| 286 | + | // static void end_element (context, element_name, ...) | |
| 287 | + | // | |
| 288 | + | // { | |
| 289 | + | // if (strcmp (element_name, "count-these") == 0) | |
| 290 | + | // g_print ("Counted %d tags\n", end_counting (context)); | |
| 291 | + | // | |
| 292 | + | // // else, handle other tags... | |
| 293 | + | // } | |
| 294 | + | // | |
| 295 | + | // ]| | |
| 296 | + | func (x *MarkupParseContext) Push(ParserVar *MarkupParser, UserDataVar uintptr) { | |
| 297 | + | ||
| 298 | + | xMarkupParseContextPush(x.GoPointer(), ParserVar, UserDataVar) | |
| 299 | + | ||
| 300 | + | } | |
| 301 | + | ||
| 302 | + | var xMarkupParseContextRef func(uintptr) *MarkupParseContext | |
| 303 | + | ||
| 304 | + | // Increases the reference count of @context. | |
| 305 | + | func (x *MarkupParseContext) Ref() *MarkupParseContext { | |
| 306 | + | ||
| 307 | + | cret := xMarkupParseContextRef(x.GoPointer()) | |
| 308 | + | return cret | |
| 309 | + | } | |
| 310 | + | ||
| 311 | + | var xMarkupParseContextUnref func(uintptr) | |
| 312 | + | ||
| 313 | + | // Decreases the reference count of @context. When its reference count | |
| 314 | + | // drops to 0, it is freed. | |
| 315 | + | func (x *MarkupParseContext) Unref() { | |
| 316 | + | ||
| 317 | + | xMarkupParseContextUnref(x.GoPointer()) | |
| 318 | + | ||
| 319 | + | } | |
| 320 | + | ||
| 17 | 321 | // Any of the fields in #GMarkupParser can be %NULL, in which case they | |
| 18 | 322 | // will be ignored. Except for the @error function, any of these callbacks | |
| 19 | 323 | // can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT, | |
| @@ -24,6 +328,10 @@ type MarkupParseContext struct { | |||
| 24 | 328 | type MarkupParser struct { | |
| 25 | 329 | } | |
| 26 | 330 | ||
| 331 | + | func (x *MarkupParser) GoPointer() uintptr { | |
| 332 | + | return uintptr(unsafe.Pointer(x)) | |
| 333 | + | } | |
| 334 | + | ||
| 27 | 335 | // A mixed enumerated type and flags field. You must specify one type | |
| 28 | 336 | // (string, strdup, boolean, tristate). Additionally, you may optionally | |
| 29 | 337 | // bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL. | |
| @@ -225,4 +533,18 @@ func init() { | |||
| 225 | 533 | core.PuregoSafeRegister(&xMarkupPrintfEscaped, lib, "g_markup_printf_escaped") | |
| 226 | 534 | core.PuregoSafeRegister(&xMarkupVprintfEscaped, lib, "g_markup_vprintf_escaped") | |
| 227 | 535 | ||
| 536 | + | core.PuregoSafeRegister(&xNewMarkupParseContext, lib, "g_markup_parse_context_new") | |
| 537 | + | ||
| 538 | + | core.PuregoSafeRegister(&xMarkupParseContextEndParse, lib, "g_markup_parse_context_end_parse") | |
| 539 | + | core.PuregoSafeRegister(&xMarkupParseContextFree, lib, "g_markup_parse_context_free") | |
| 540 | + | core.PuregoSafeRegister(&xMarkupParseContextGetElement, lib, "g_markup_parse_context_get_element") | |
| 541 | + | core.PuregoSafeRegister(&xMarkupParseContextGetElementStack, lib, "g_markup_parse_context_get_element_stack") | |
| 542 | + | core.PuregoSafeRegister(&xMarkupParseContextGetPosition, lib, "g_markup_parse_context_get_position") | |
| 543 | + | core.PuregoSafeRegister(&xMarkupParseContextGetUserData, lib, "g_markup_parse_context_get_user_data") | |
| 544 | + | core.PuregoSafeRegister(&xMarkupParseContextParse, lib, "g_markup_parse_context_parse") | |
| 545 | + | core.PuregoSafeRegister(&xMarkupParseContextPop, lib, "g_markup_parse_context_pop") | |
| 546 | + | core.PuregoSafeRegister(&xMarkupParseContextPush, lib, "g_markup_parse_context_push") | |
| 547 | + | core.PuregoSafeRegister(&xMarkupParseContextRef, lib, "g_markup_parse_context_ref") | |
| 548 | + | core.PuregoSafeRegister(&xMarkupParseContextUnref, lib, "g_markup_parse_context_unref") | |
| 549 | + | ||
| 228 | 550 | } | |
M v4/glib/gmem.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -14,6 +16,10 @@ import ( | |||
| 14 | 16 | type MemVTable struct { | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *MemVTable) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | var xAlignedAlloc func(uint, uint, uint) uintptr | |
| 18 | 24 | ||
| 19 | 25 | // This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) | |
M v4/glib/gmessages.go +41 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -57,6 +59,45 @@ type LogField struct { | |||
| 57 | 59 | Length int | |
| 58 | 60 | } | |
| 59 | 61 | ||
| 62 | + | func (x *LogField) GoPointer() uintptr { | |
| 63 | + | return uintptr(unsafe.Pointer(x)) | |
| 64 | + | } | |
| 65 | + | ||
| 66 | + | const ( | |
| 67 | + | // Defines the log domain. See [Log Domains](#log-domains). | |
| 68 | + | // | |
| 69 | + | // Libraries should define this so that any messages | |
| 70 | + | // which they log can be differentiated from messages from other | |
| 71 | + | // libraries and application code. But be careful not to define | |
| 72 | + | // it in any public header files. | |
| 73 | + | // | |
| 74 | + | // Log domains must be unique, and it is recommended that they are the | |
| 75 | + | // application or library name, optionally followed by a hyphen and a sub-domain | |
| 76 | + | // name. For example, `bloatpad` or `bloatpad-io`. | |
| 77 | + | // | |
| 78 | + | // If undefined, it defaults to the default %NULL (or `""`) log domain; this is | |
| 79 | + | // not advisable, as it cannot be filtered against using the `G_MESSAGES_DEBUG` | |
| 80 | + | // environment variable. | |
| 81 | + | // | |
| 82 | + | // For example, GTK+ uses this in its `Makefile.am`: | |
| 83 | + | // |[ | |
| 84 | + | // AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gtk\" | |
| 85 | + | // ]| | |
| 86 | + | // | |
| 87 | + | // Applications can choose to leave it as the default %NULL (or `""`) | |
| 88 | + | // domain. However, defining the domain offers the same advantages as | |
| 89 | + | // above. | |
| 90 | + | LOG_DOMAIN byte = 0 | |
| 91 | + | // GLib log levels that are considered fatal by default. | |
| 92 | + | // | |
| 93 | + | // This is not used if structured logging is enabled; see | |
| 94 | + | // [Using Structured Logging][using-structured-logging]. | |
| 95 | + | LOG_FATAL_MASK int = 5 | |
| 96 | + | // Log levels below 1<<G_LOG_LEVEL_USER_SHIFT are used by GLib. | |
| 97 | + | // Higher bits can be used for user-defined log levels. | |
| 98 | + | LOG_LEVEL_USER_SHIFT int = 8 | |
| 99 | + | ) | |
| 100 | + | ||
| 60 | 101 | // Flags specifying the level of log messages. | |
| 61 | 102 | // | |
| 62 | 103 | // It is possible to change how GLib treats messages of the various | |
M v4/glib/gnode.go +294 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Specifies the type of function passed to g_node_children_foreach(). | |
| 5 | 12 | // The function is called with each child node, together with the user | |
| 6 | 13 | // data passed to g_node_children_foreach(). | |
| @@ -25,6 +32,259 @@ type Node struct { | |||
| 25 | 32 | Children *Node | |
| 26 | 33 | } | |
| 27 | 34 | ||
| 35 | + | func (x *Node) GoPointer() uintptr { | |
| 36 | + | return uintptr(unsafe.Pointer(x)) | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | var xNodeChildIndex func(uintptr, uintptr) int | |
| 40 | + | ||
| 41 | + | // Gets the position of the first child of a #GNode | |
| 42 | + | // which contains the given data. | |
| 43 | + | func (x *Node) ChildIndex(DataVar uintptr) int { | |
| 44 | + | ||
| 45 | + | cret := xNodeChildIndex(x.GoPointer(), DataVar) | |
| 46 | + | return cret | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | var xNodeChildPosition func(uintptr, *Node) int | |
| 50 | + | ||
| 51 | + | // Gets the position of a #GNode with respect to its siblings. | |
| 52 | + | // @child must be a child of @node. The first child is numbered 0, | |
| 53 | + | // the second 1, and so on. | |
| 54 | + | func (x *Node) ChildPosition(ChildVar *Node) int { | |
| 55 | + | ||
| 56 | + | cret := xNodeChildPosition(x.GoPointer(), ChildVar) | |
| 57 | + | return cret | |
| 58 | + | } | |
| 59 | + | ||
| 60 | + | var xNodeChildrenForeach func(uintptr, TraverseFlags, uintptr, uintptr) | |
| 61 | + | ||
| 62 | + | // Calls a function for each of the children of a #GNode. Note that it | |
| 63 | + | // doesn't descend beneath the child nodes. @func must not do anything | |
| 64 | + | // that would modify the structure of the tree. | |
| 65 | + | func (x *Node) ChildrenForeach(FlagsVar TraverseFlags, FuncVar NodeForeachFunc, DataVar uintptr) { | |
| 66 | + | ||
| 67 | + | xNodeChildrenForeach(x.GoPointer(), FlagsVar, purego.NewCallback(FuncVar), DataVar) | |
| 68 | + | ||
| 69 | + | } | |
| 70 | + | ||
| 71 | + | var xNodeCopy func(uintptr) *Node | |
| 72 | + | ||
| 73 | + | // Recursively copies a #GNode (but does not deep-copy the data inside the | |
| 74 | + | // nodes, see g_node_copy_deep() if you need that). | |
| 75 | + | func (x *Node) Copy() *Node { | |
| 76 | + | ||
| 77 | + | cret := xNodeCopy(x.GoPointer()) | |
| 78 | + | return cret | |
| 79 | + | } | |
| 80 | + | ||
| 81 | + | var xNodeCopyDeep func(uintptr, uintptr, uintptr) *Node | |
| 82 | + | ||
| 83 | + | // Recursively copies a #GNode and its data. | |
| 84 | + | func (x *Node) CopyDeep(CopyFuncVar CopyFunc, DataVar uintptr) *Node { | |
| 85 | + | ||
| 86 | + | cret := xNodeCopyDeep(x.GoPointer(), purego.NewCallback(CopyFuncVar), DataVar) | |
| 87 | + | return cret | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | var xNodeDepth func(uintptr) uint | |
| 91 | + | ||
| 92 | + | // Gets the depth of a #GNode. | |
| 93 | + | // | |
| 94 | + | // If @node is %NULL the depth is 0. The root node has a depth of 1. | |
| 95 | + | // For the children of the root node the depth is 2. And so on. | |
| 96 | + | func (x *Node) Depth() uint { | |
| 97 | + | ||
| 98 | + | cret := xNodeDepth(x.GoPointer()) | |
| 99 | + | return cret | |
| 100 | + | } | |
| 101 | + | ||
| 102 | + | var xNodeDestroy func(uintptr) | |
| 103 | + | ||
| 104 | + | // Removes @root and its children from the tree, freeing any memory | |
| 105 | + | // allocated. | |
| 106 | + | func (x *Node) Destroy() { | |
| 107 | + | ||
| 108 | + | xNodeDestroy(x.GoPointer()) | |
| 109 | + | ||
| 110 | + | } | |
| 111 | + | ||
| 112 | + | var xNodeFind func(uintptr, TraverseType, TraverseFlags, uintptr) *Node | |
| 113 | + | ||
| 114 | + | // Finds a #GNode in a tree. | |
| 115 | + | func (x *Node) Find(OrderVar TraverseType, FlagsVar TraverseFlags, DataVar uintptr) *Node { | |
| 116 | + | ||
| 117 | + | cret := xNodeFind(x.GoPointer(), OrderVar, FlagsVar, DataVar) | |
| 118 | + | return cret | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | var xNodeFindChild func(uintptr, TraverseFlags, uintptr) *Node | |
| 122 | + | ||
| 123 | + | // Finds the first child of a #GNode with the given data. | |
| 124 | + | func (x *Node) FindChild(FlagsVar TraverseFlags, DataVar uintptr) *Node { | |
| 125 | + | ||
| 126 | + | cret := xNodeFindChild(x.GoPointer(), FlagsVar, DataVar) | |
| 127 | + | return cret | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | var xNodeFirstSibling func(uintptr) *Node | |
| 131 | + | ||
| 132 | + | // Gets the first sibling of a #GNode. | |
| 133 | + | // This could possibly be the node itself. | |
| 134 | + | func (x *Node) FirstSibling() *Node { | |
| 135 | + | ||
| 136 | + | cret := xNodeFirstSibling(x.GoPointer()) | |
| 137 | + | return cret | |
| 138 | + | } | |
| 139 | + | ||
| 140 | + | var xNodeGetRoot func(uintptr) *Node | |
| 141 | + | ||
| 142 | + | // Gets the root of a tree. | |
| 143 | + | func (x *Node) GetRoot() *Node { | |
| 144 | + | ||
| 145 | + | cret := xNodeGetRoot(x.GoPointer()) | |
| 146 | + | return cret | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | var xNodeInsert func(uintptr, int, *Node) *Node | |
| 150 | + | ||
| 151 | + | // Inserts a #GNode beneath the parent at the given position. | |
| 152 | + | func (x *Node) Insert(PositionVar int, NodeVar *Node) *Node { | |
| 153 | + | ||
| 154 | + | cret := xNodeInsert(x.GoPointer(), PositionVar, NodeVar) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xNodeInsertAfter func(uintptr, *Node, *Node) *Node | |
| 159 | + | ||
| 160 | + | // Inserts a #GNode beneath the parent after the given sibling. | |
| 161 | + | func (x *Node) InsertAfter(SiblingVar *Node, NodeVar *Node) *Node { | |
| 162 | + | ||
| 163 | + | cret := xNodeInsertAfter(x.GoPointer(), SiblingVar, NodeVar) | |
| 164 | + | return cret | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xNodeInsertBefore func(uintptr, *Node, *Node) *Node | |
| 168 | + | ||
| 169 | + | // Inserts a #GNode beneath the parent before the given sibling. | |
| 170 | + | func (x *Node) InsertBefore(SiblingVar *Node, NodeVar *Node) *Node { | |
| 171 | + | ||
| 172 | + | cret := xNodeInsertBefore(x.GoPointer(), SiblingVar, NodeVar) | |
| 173 | + | return cret | |
| 174 | + | } | |
| 175 | + | ||
| 176 | + | var xNodeIsAncestor func(uintptr, *Node) bool | |
| 177 | + | ||
| 178 | + | // Returns %TRUE if @node is an ancestor of @descendant. | |
| 179 | + | // This is true if node is the parent of @descendant, | |
| 180 | + | // or if node is the grandparent of @descendant etc. | |
| 181 | + | func (x *Node) IsAncestor(DescendantVar *Node) bool { | |
| 182 | + | ||
| 183 | + | cret := xNodeIsAncestor(x.GoPointer(), DescendantVar) | |
| 184 | + | return cret | |
| 185 | + | } | |
| 186 | + | ||
| 187 | + | var xNodeLastChild func(uintptr) *Node | |
| 188 | + | ||
| 189 | + | // Gets the last child of a #GNode. | |
| 190 | + | func (x *Node) LastChild() *Node { | |
| 191 | + | ||
| 192 | + | cret := xNodeLastChild(x.GoPointer()) | |
| 193 | + | return cret | |
| 194 | + | } | |
| 195 | + | ||
| 196 | + | var xNodeLastSibling func(uintptr) *Node | |
| 197 | + | ||
| 198 | + | // Gets the last sibling of a #GNode. | |
| 199 | + | // This could possibly be the node itself. | |
| 200 | + | func (x *Node) LastSibling() *Node { | |
| 201 | + | ||
| 202 | + | cret := xNodeLastSibling(x.GoPointer()) | |
| 203 | + | return cret | |
| 204 | + | } | |
| 205 | + | ||
| 206 | + | var xNodeMaxHeight func(uintptr) uint | |
| 207 | + | ||
| 208 | + | // Gets the maximum height of all branches beneath a #GNode. | |
| 209 | + | // This is the maximum distance from the #GNode to all leaf nodes. | |
| 210 | + | // | |
| 211 | + | // If @root is %NULL, 0 is returned. If @root has no children, | |
| 212 | + | // 1 is returned. If @root has children, 2 is returned. And so on. | |
| 213 | + | func (x *Node) MaxHeight() uint { | |
| 214 | + | ||
| 215 | + | cret := xNodeMaxHeight(x.GoPointer()) | |
| 216 | + | return cret | |
| 217 | + | } | |
| 218 | + | ||
| 219 | + | var xNodeNChildren func(uintptr) uint | |
| 220 | + | ||
| 221 | + | // Gets the number of children of a #GNode. | |
| 222 | + | func (x *Node) NChildren() uint { | |
| 223 | + | ||
| 224 | + | cret := xNodeNChildren(x.GoPointer()) | |
| 225 | + | return cret | |
| 226 | + | } | |
| 227 | + | ||
| 228 | + | var xNodeNNodes func(uintptr, TraverseFlags) uint | |
| 229 | + | ||
| 230 | + | // Gets the number of nodes in a tree. | |
| 231 | + | func (x *Node) NNodes(FlagsVar TraverseFlags) uint { | |
| 232 | + | ||
| 233 | + | cret := xNodeNNodes(x.GoPointer(), FlagsVar) | |
| 234 | + | return cret | |
| 235 | + | } | |
| 236 | + | ||
| 237 | + | var xNodeNthChild func(uintptr, uint) *Node | |
| 238 | + | ||
| 239 | + | // Gets a child of a #GNode, using the given index. | |
| 240 | + | // The first child is at index 0. If the index is | |
| 241 | + | // too big, %NULL is returned. | |
| 242 | + | func (x *Node) NthChild(NVar uint) *Node { | |
| 243 | + | ||
| 244 | + | cret := xNodeNthChild(x.GoPointer(), NVar) | |
| 245 | + | return cret | |
| 246 | + | } | |
| 247 | + | ||
| 248 | + | var xNodePrepend func(uintptr, *Node) *Node | |
| 249 | + | ||
| 250 | + | // Inserts a #GNode as the first child of the given parent. | |
| 251 | + | func (x *Node) Prepend(NodeVar *Node) *Node { | |
| 252 | + | ||
| 253 | + | cret := xNodePrepend(x.GoPointer(), NodeVar) | |
| 254 | + | return cret | |
| 255 | + | } | |
| 256 | + | ||
| 257 | + | var xNodeReverseChildren func(uintptr) | |
| 258 | + | ||
| 259 | + | // Reverses the order of the children of a #GNode. | |
| 260 | + | // (It doesn't change the order of the grandchildren.) | |
| 261 | + | func (x *Node) ReverseChildren() { | |
| 262 | + | ||
| 263 | + | xNodeReverseChildren(x.GoPointer()) | |
| 264 | + | ||
| 265 | + | } | |
| 266 | + | ||
| 267 | + | var xNodeTraverse func(uintptr, TraverseType, TraverseFlags, int, uintptr, uintptr) | |
| 268 | + | ||
| 269 | + | // Traverses a tree starting at the given root #GNode. | |
| 270 | + | // It calls the given function for each node visited. | |
| 271 | + | // The traversal can be halted at any point by returning %TRUE from @func. | |
| 272 | + | // @func must not do anything that would modify the structure of the tree. | |
| 273 | + | func (x *Node) Traverse(OrderVar TraverseType, FlagsVar TraverseFlags, MaxDepthVar int, FuncVar NodeTraverseFunc, DataVar uintptr) { | |
| 274 | + | ||
| 275 | + | xNodeTraverse(x.GoPointer(), OrderVar, FlagsVar, MaxDepthVar, purego.NewCallback(FuncVar), DataVar) | |
| 276 | + | ||
| 277 | + | } | |
| 278 | + | ||
| 279 | + | var xNodeUnlink func(uintptr) | |
| 280 | + | ||
| 281 | + | // Unlinks a #GNode from a tree, resulting in two separate trees. | |
| 282 | + | func (x *Node) Unlink() { | |
| 283 | + | ||
| 284 | + | xNodeUnlink(x.GoPointer()) | |
| 285 | + | ||
| 286 | + | } | |
| 287 | + | ||
| 28 | 288 | // Specifies which nodes are visited during several of the tree | |
| 29 | 289 | // functions, including g_node_traverse() and g_node_find(). | |
| 30 | 290 | type TraverseFlags int | |
| @@ -81,3 +341,37 @@ const ( | |||
| 81 | 341 | // efficient than the other orders. | |
| 82 | 342 | GLevelOrderValue TraverseType = 3 | |
| 83 | 343 | ) | |
| 344 | + | ||
| 345 | + | func init() { | |
| 346 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 347 | + | if err != nil { | |
| 348 | + | panic(err) | |
| 349 | + | } | |
| 350 | + | ||
| 351 | + | core.PuregoSafeRegister(&xNodeChildIndex, lib, "g_node_child_index") | |
| 352 | + | core.PuregoSafeRegister(&xNodeChildPosition, lib, "g_node_child_position") | |
| 353 | + | core.PuregoSafeRegister(&xNodeChildrenForeach, lib, "g_node_children_foreach") | |
| 354 | + | core.PuregoSafeRegister(&xNodeCopy, lib, "g_node_copy") | |
| 355 | + | core.PuregoSafeRegister(&xNodeCopyDeep, lib, "g_node_copy_deep") | |
| 356 | + | core.PuregoSafeRegister(&xNodeDepth, lib, "g_node_depth") | |
| 357 | + | core.PuregoSafeRegister(&xNodeDestroy, lib, "g_node_destroy") | |
| 358 | + | core.PuregoSafeRegister(&xNodeFind, lib, "g_node_find") | |
| 359 | + | core.PuregoSafeRegister(&xNodeFindChild, lib, "g_node_find_child") | |
| 360 | + | core.PuregoSafeRegister(&xNodeFirstSibling, lib, "g_node_first_sibling") | |
| 361 | + | core.PuregoSafeRegister(&xNodeGetRoot, lib, "g_node_get_root") | |
| 362 | + | core.PuregoSafeRegister(&xNodeInsert, lib, "g_node_insert") | |
| 363 | + | core.PuregoSafeRegister(&xNodeInsertAfter, lib, "g_node_insert_after") | |
| 364 | + | core.PuregoSafeRegister(&xNodeInsertBefore, lib, "g_node_insert_before") | |
| 365 | + | core.PuregoSafeRegister(&xNodeIsAncestor, lib, "g_node_is_ancestor") | |
| 366 | + | core.PuregoSafeRegister(&xNodeLastChild, lib, "g_node_last_child") | |
| 367 | + | core.PuregoSafeRegister(&xNodeLastSibling, lib, "g_node_last_sibling") | |
| 368 | + | core.PuregoSafeRegister(&xNodeMaxHeight, lib, "g_node_max_height") | |
| 369 | + | core.PuregoSafeRegister(&xNodeNChildren, lib, "g_node_n_children") | |
| 370 | + | core.PuregoSafeRegister(&xNodeNNodes, lib, "g_node_n_nodes") | |
| 371 | + | core.PuregoSafeRegister(&xNodeNthChild, lib, "g_node_nth_child") | |
| 372 | + | core.PuregoSafeRegister(&xNodePrepend, lib, "g_node_prepend") | |
| 373 | + | core.PuregoSafeRegister(&xNodeReverseChildren, lib, "g_node_reverse_children") | |
| 374 | + | core.PuregoSafeRegister(&xNodeTraverse, lib, "g_node_traverse") | |
| 375 | + | core.PuregoSafeRegister(&xNodeUnlink, lib, "g_node_unlink") | |
| 376 | + | ||
| 377 | + | } | |
M v4/glib/goption.go +470 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK | |
| 5 | 12 | // options. | |
| 6 | 13 | type OptionArgFunc func(string, string, uintptr, **Error) bool | |
| @@ -17,6 +24,307 @@ type OptionParseFunc func(*OptionContext, *OptionGroup, uintptr, **Error) bool | |||
| 17 | 24 | type OptionContext struct { | |
| 18 | 25 | } | |
| 19 | 26 | ||
| 27 | + | func (x *OptionContext) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | var xOptionContextAddGroup func(uintptr, *OptionGroup) | |
| 32 | + | ||
| 33 | + | // Adds a #GOptionGroup to the @context, so that parsing with @context | |
| 34 | + | // will recognize the options in the group. Note that this will take | |
| 35 | + | // ownership of the @group and thus the @group should not be freed. | |
| 36 | + | func (x *OptionContext) AddGroup(GroupVar *OptionGroup) { | |
| 37 | + | ||
| 38 | + | xOptionContextAddGroup(x.GoPointer(), GroupVar) | |
| 39 | + | ||
| 40 | + | } | |
| 41 | + | ||
| 42 | + | var xOptionContextAddMainEntries func(uintptr, uintptr, string) | |
| 43 | + | ||
| 44 | + | // A convenience function which creates a main group if it doesn't | |
| 45 | + | // exist, adds the @entries to it and sets the translation domain. | |
| 46 | + | func (x *OptionContext) AddMainEntries(EntriesVar uintptr, TranslationDomainVar string) { | |
| 47 | + | ||
| 48 | + | xOptionContextAddMainEntries(x.GoPointer(), EntriesVar, TranslationDomainVar) | |
| 49 | + | ||
| 50 | + | } | |
| 51 | + | ||
| 52 | + | var xOptionContextFree func(uintptr) | |
| 53 | + | ||
| 54 | + | // Frees context and all the groups which have been | |
| 55 | + | // added to it. | |
| 56 | + | // | |
| 57 | + | // Please note that parsed arguments need to be freed separately (see | |
| 58 | + | // #GOptionEntry). | |
| 59 | + | func (x *OptionContext) Free() { | |
| 60 | + | ||
| 61 | + | xOptionContextFree(x.GoPointer()) | |
| 62 | + | ||
| 63 | + | } | |
| 64 | + | ||
| 65 | + | var xOptionContextGetDescription func(uintptr) string | |
| 66 | + | ||
| 67 | + | // Returns the description. See g_option_context_set_description(). | |
| 68 | + | func (x *OptionContext) GetDescription() string { | |
| 69 | + | ||
| 70 | + | cret := xOptionContextGetDescription(x.GoPointer()) | |
| 71 | + | return cret | |
| 72 | + | } | |
| 73 | + | ||
| 74 | + | var xOptionContextGetHelp func(uintptr, bool, *OptionGroup) string | |
| 75 | + | ||
| 76 | + | // Returns a formatted, translated help text for the given context. | |
| 77 | + | // To obtain the text produced by `--help`, call | |
| 78 | + | // `g_option_context_get_help (context, TRUE, NULL)`. | |
| 79 | + | // To obtain the text produced by `--help-all`, call | |
| 80 | + | // `g_option_context_get_help (context, FALSE, NULL)`. | |
| 81 | + | // To obtain the help text for an option group, call | |
| 82 | + | // `g_option_context_get_help (context, FALSE, group)`. | |
| 83 | + | func (x *OptionContext) GetHelp(MainHelpVar bool, GroupVar *OptionGroup) string { | |
| 84 | + | ||
| 85 | + | cret := xOptionContextGetHelp(x.GoPointer(), MainHelpVar, GroupVar) | |
| 86 | + | return cret | |
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xOptionContextGetHelpEnabled func(uintptr) bool | |
| 90 | + | ||
| 91 | + | // Returns whether automatic `--help` generation | |
| 92 | + | // is turned on for @context. See g_option_context_set_help_enabled(). | |
| 93 | + | func (x *OptionContext) GetHelpEnabled() bool { | |
| 94 | + | ||
| 95 | + | cret := xOptionContextGetHelpEnabled(x.GoPointer()) | |
| 96 | + | return cret | |
| 97 | + | } | |
| 98 | + | ||
| 99 | + | var xOptionContextGetIgnoreUnknownOptions func(uintptr) bool | |
| 100 | + | ||
| 101 | + | // Returns whether unknown options are ignored or not. See | |
| 102 | + | // g_option_context_set_ignore_unknown_options(). | |
| 103 | + | func (x *OptionContext) GetIgnoreUnknownOptions() bool { | |
| 104 | + | ||
| 105 | + | cret := xOptionContextGetIgnoreUnknownOptions(x.GoPointer()) | |
| 106 | + | return cret | |
| 107 | + | } | |
| 108 | + | ||
| 109 | + | var xOptionContextGetMainGroup func(uintptr) *OptionGroup | |
| 110 | + | ||
| 111 | + | // Returns a pointer to the main group of @context. | |
| 112 | + | func (x *OptionContext) GetMainGroup() *OptionGroup { | |
| 113 | + | ||
| 114 | + | cret := xOptionContextGetMainGroup(x.GoPointer()) | |
| 115 | + | return cret | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xOptionContextGetStrictPosix func(uintptr) bool | |
| 119 | + | ||
| 120 | + | // Returns whether strict POSIX code is enabled. | |
| 121 | + | // | |
| 122 | + | // See g_option_context_set_strict_posix() for more information. | |
| 123 | + | func (x *OptionContext) GetStrictPosix() bool { | |
| 124 | + | ||
| 125 | + | cret := xOptionContextGetStrictPosix(x.GoPointer()) | |
| 126 | + | return cret | |
| 127 | + | } | |
| 128 | + | ||
| 129 | + | var xOptionContextGetSummary func(uintptr) string | |
| 130 | + | ||
| 131 | + | // Returns the summary. See g_option_context_set_summary(). | |
| 132 | + | func (x *OptionContext) GetSummary() string { | |
| 133 | + | ||
| 134 | + | cret := xOptionContextGetSummary(x.GoPointer()) | |
| 135 | + | return cret | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xOptionContextParse func(uintptr, int, uintptr, **Error) bool | |
| 139 | + | ||
| 140 | + | // Parses the command line arguments, recognizing options | |
| 141 | + | // which have been added to @context. A side-effect of | |
| 142 | + | // calling this function is that g_set_prgname() will be | |
| 143 | + | // called. | |
| 144 | + | // | |
| 145 | + | // If the parsing is successful, any parsed arguments are | |
| 146 | + | // removed from the array and @argc and @argv are updated | |
| 147 | + | // accordingly. A '--' option is stripped from @argv | |
| 148 | + | // unless there are unparsed options before and after it, | |
| 149 | + | // or some of the options after it start with '-'. In case | |
| 150 | + | // of an error, @argc and @argv are left unmodified. | |
| 151 | + | // | |
| 152 | + | // If automatic `--help` support is enabled | |
| 153 | + | // (see g_option_context_set_help_enabled()), and the | |
| 154 | + | // @argv array contains one of the recognized help options, | |
| 155 | + | // this function will produce help output to stdout and | |
| 156 | + | // call `exit (0)`. | |
| 157 | + | // | |
| 158 | + | // Note that function depends on the [current locale][setlocale] for | |
| 159 | + | // automatic character set conversion of string and filename | |
| 160 | + | // arguments. | |
| 161 | + | func (x *OptionContext) Parse(ArgcVar int, ArgvVar uintptr) (bool, error) { | |
| 162 | + | var cerr *Error | |
| 163 | + | ||
| 164 | + | cret := xOptionContextParse(x.GoPointer(), ArgcVar, ArgvVar, &cerr) | |
| 165 | + | if cerr == nil { | |
| 166 | + | return cret, nil | |
| 167 | + | } | |
| 168 | + | return cret, cerr | |
| 169 | + | ||
| 170 | + | } | |
| 171 | + | ||
| 172 | + | var xOptionContextParseStrv func(uintptr, uintptr, **Error) bool | |
| 173 | + | ||
| 174 | + | // Parses the command line arguments. | |
| 175 | + | // | |
| 176 | + | // This function is similar to g_option_context_parse() except that it | |
| 177 | + | // respects the normal memory rules when dealing with a strv instead of | |
| 178 | + | // assuming that the passed-in array is the argv of the main function. | |
| 179 | + | // | |
| 180 | + | // In particular, strings that are removed from the arguments list will | |
| 181 | + | // be freed using g_free(). | |
| 182 | + | // | |
| 183 | + | // On Windows, the strings are expected to be in UTF-8. This is in | |
| 184 | + | // contrast to g_option_context_parse() which expects them to be in the | |
| 185 | + | // system codepage, which is how they are passed as @argv to main(). | |
| 186 | + | // See g_win32_get_command_line() for a solution. | |
| 187 | + | // | |
| 188 | + | // This function is useful if you are trying to use #GOptionContext with | |
| 189 | + | // #GApplication. | |
| 190 | + | func (x *OptionContext) ParseStrv(ArgumentsVar uintptr) (bool, error) { | |
| 191 | + | var cerr *Error | |
| 192 | + | ||
| 193 | + | cret := xOptionContextParseStrv(x.GoPointer(), ArgumentsVar, &cerr) | |
| 194 | + | if cerr == nil { | |
| 195 | + | return cret, nil | |
| 196 | + | } | |
| 197 | + | return cret, cerr | |
| 198 | + | ||
| 199 | + | } | |
| 200 | + | ||
| 201 | + | var xOptionContextSetDescription func(uintptr, string) | |
| 202 | + | ||
| 203 | + | // Adds a string to be displayed in `--help` output after the list | |
| 204 | + | // of options. This text often includes a bug reporting address. | |
| 205 | + | // | |
| 206 | + | // Note that the summary is translated (see | |
| 207 | + | // g_option_context_set_translate_func()). | |
| 208 | + | func (x *OptionContext) SetDescription(DescriptionVar string) { | |
| 209 | + | ||
| 210 | + | xOptionContextSetDescription(x.GoPointer(), DescriptionVar) | |
| 211 | + | ||
| 212 | + | } | |
| 213 | + | ||
| 214 | + | var xOptionContextSetHelpEnabled func(uintptr, bool) | |
| 215 | + | ||
| 216 | + | // Enables or disables automatic generation of `--help` output. | |
| 217 | + | // By default, g_option_context_parse() recognizes `--help`, `-h`, | |
| 218 | + | // `-?`, `--help-all` and `--help-groupname` and creates suitable | |
| 219 | + | // output to stdout. | |
| 220 | + | func (x *OptionContext) SetHelpEnabled(HelpEnabledVar bool) { | |
| 221 | + | ||
| 222 | + | xOptionContextSetHelpEnabled(x.GoPointer(), HelpEnabledVar) | |
| 223 | + | ||
| 224 | + | } | |
| 225 | + | ||
| 226 | + | var xOptionContextSetIgnoreUnknownOptions func(uintptr, bool) | |
| 227 | + | ||
| 228 | + | // Sets whether to ignore unknown options or not. If an argument is | |
| 229 | + | // ignored, it is left in the @argv array after parsing. By default, | |
| 230 | + | // g_option_context_parse() treats unknown options as error. | |
| 231 | + | // | |
| 232 | + | // This setting does not affect non-option arguments (i.e. arguments | |
| 233 | + | // which don't start with a dash). But note that GOption cannot reliably | |
| 234 | + | // determine whether a non-option belongs to a preceding unknown option. | |
| 235 | + | func (x *OptionContext) SetIgnoreUnknownOptions(IgnoreUnknownVar bool) { | |
| 236 | + | ||
| 237 | + | xOptionContextSetIgnoreUnknownOptions(x.GoPointer(), IgnoreUnknownVar) | |
| 238 | + | ||
| 239 | + | } | |
| 240 | + | ||
| 241 | + | var xOptionContextSetMainGroup func(uintptr, *OptionGroup) | |
| 242 | + | ||
| 243 | + | // Sets a #GOptionGroup as main group of the @context. | |
| 244 | + | // This has the same effect as calling g_option_context_add_group(), | |
| 245 | + | // the only difference is that the options in the main group are | |
| 246 | + | // treated differently when generating `--help` output. | |
| 247 | + | func (x *OptionContext) SetMainGroup(GroupVar *OptionGroup) { | |
| 248 | + | ||
| 249 | + | xOptionContextSetMainGroup(x.GoPointer(), GroupVar) | |
| 250 | + | ||
| 251 | + | } | |
| 252 | + | ||
| 253 | + | var xOptionContextSetStrictPosix func(uintptr, bool) | |
| 254 | + | ||
| 255 | + | // Sets strict POSIX mode. | |
| 256 | + | // | |
| 257 | + | // By default, this mode is disabled. | |
| 258 | + | // | |
| 259 | + | // In strict POSIX mode, the first non-argument parameter encountered | |
| 260 | + | // (eg: filename) terminates argument processing. Remaining arguments | |
| 261 | + | // are treated as non-options and are not attempted to be parsed. | |
| 262 | + | // | |
| 263 | + | // If strict POSIX mode is disabled then parsing is done in the GNU way | |
| 264 | + | // where option arguments can be freely mixed with non-options. | |
| 265 | + | // | |
| 266 | + | // As an example, consider "ls foo -l". With GNU style parsing, this | |
| 267 | + | // will list "foo" in long mode. In strict POSIX style, this will list | |
| 268 | + | // the files named "foo" and "-l". | |
| 269 | + | // | |
| 270 | + | // It may be useful to force strict POSIX mode when creating "verb | |
| 271 | + | // style" command line tools. For example, the "gsettings" command line | |
| 272 | + | // tool supports the global option "--schemadir" as well as many | |
| 273 | + | // subcommands ("get", "set", etc.) which each have their own set of | |
| 274 | + | // arguments. Using strict POSIX mode will allow parsing the global | |
| 275 | + | // options up to the verb name while leaving the remaining options to be | |
| 276 | + | // parsed by the relevant subcommand (which can be determined by | |
| 277 | + | // examining the verb name, which should be present in argv[1] after | |
| 278 | + | // parsing). | |
| 279 | + | func (x *OptionContext) SetStrictPosix(StrictPosixVar bool) { | |
| 280 | + | ||
| 281 | + | xOptionContextSetStrictPosix(x.GoPointer(), StrictPosixVar) | |
| 282 | + | ||
| 283 | + | } | |
| 284 | + | ||
| 285 | + | var xOptionContextSetSummary func(uintptr, string) | |
| 286 | + | ||
| 287 | + | // Adds a string to be displayed in `--help` output before the list | |
| 288 | + | // of options. This is typically a summary of the program functionality. | |
| 289 | + | // | |
| 290 | + | // Note that the summary is translated (see | |
| 291 | + | // g_option_context_set_translate_func() and | |
| 292 | + | // g_option_context_set_translation_domain()). | |
| 293 | + | func (x *OptionContext) SetSummary(SummaryVar string) { | |
| 294 | + | ||
| 295 | + | xOptionContextSetSummary(x.GoPointer(), SummaryVar) | |
| 296 | + | ||
| 297 | + | } | |
| 298 | + | ||
| 299 | + | var xOptionContextSetTranslateFunc func(uintptr, uintptr, uintptr, uintptr) | |
| 300 | + | ||
| 301 | + | // Sets the function which is used to translate the contexts | |
| 302 | + | // user-visible strings, for `--help` output. If @func is %NULL, | |
| 303 | + | // strings are not translated. | |
| 304 | + | // | |
| 305 | + | // Note that option groups have their own translation functions, | |
| 306 | + | // this function only affects the @parameter_string (see g_option_context_new()), | |
| 307 | + | // the summary (see g_option_context_set_summary()) and the description | |
| 308 | + | // (see g_option_context_set_description()). | |
| 309 | + | // | |
| 310 | + | // If you are using gettext(), you only need to set the translation | |
| 311 | + | // domain, see g_option_context_set_translation_domain(). | |
| 312 | + | func (x *OptionContext) SetTranslateFunc(FuncVar TranslateFunc, DataVar uintptr, DestroyNotifyVar DestroyNotify) { | |
| 313 | + | ||
| 314 | + | xOptionContextSetTranslateFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 315 | + | ||
| 316 | + | } | |
| 317 | + | ||
| 318 | + | var xOptionContextSetTranslationDomain func(uintptr, string) | |
| 319 | + | ||
| 320 | + | // A convenience function to use gettext() for translating | |
| 321 | + | // user-visible strings. | |
| 322 | + | func (x *OptionContext) SetTranslationDomain(DomainVar string) { | |
| 323 | + | ||
| 324 | + | xOptionContextSetTranslationDomain(x.GoPointer(), DomainVar) | |
| 325 | + | ||
| 326 | + | } | |
| 327 | + | ||
| 20 | 328 | // A GOptionEntry struct defines a single option. To have an effect, they | |
| 21 | 329 | // must be added to a #GOptionGroup with g_option_context_add_main_entries() | |
| 22 | 330 | // or g_option_group_add_entries(). | |
| @@ -36,6 +344,10 @@ type OptionEntry struct { | |||
| 36 | 344 | ArgDescription uintptr | |
| 37 | 345 | } | |
| 38 | 346 | ||
| 347 | + | func (x *OptionEntry) GoPointer() uintptr { | |
| 348 | + | return uintptr(unsafe.Pointer(x)) | |
| 349 | + | } | |
| 350 | + | ||
| 39 | 351 | // A `GOptionGroup` struct defines the options in a single | |
| 40 | 352 | // group. The struct has only private fields and should not be directly accessed. | |
| 41 | 353 | // | |
| @@ -46,6 +358,124 @@ type OptionEntry struct { | |||
| 46 | 358 | type OptionGroup struct { | |
| 47 | 359 | } | |
| 48 | 360 | ||
| 361 | + | func (x *OptionGroup) GoPointer() uintptr { | |
| 362 | + | return uintptr(unsafe.Pointer(x)) | |
| 363 | + | } | |
| 364 | + | ||
| 365 | + | var xNewOptionGroup func(string, string, string, uintptr, uintptr) *OptionGroup | |
| 366 | + | ||
| 367 | + | // Creates a new #GOptionGroup. | |
| 368 | + | func NewOptionGroup(NameVar string, DescriptionVar string, HelpDescriptionVar string, UserDataVar uintptr, DestroyVar DestroyNotify) *OptionGroup { | |
| 369 | + | ||
| 370 | + | cret := xNewOptionGroup(NameVar, DescriptionVar, HelpDescriptionVar, UserDataVar, purego.NewCallback(DestroyVar)) | |
| 371 | + | return cret | |
| 372 | + | } | |
| 373 | + | ||
| 374 | + | var xOptionGroupAddEntries func(uintptr, uintptr) | |
| 375 | + | ||
| 376 | + | // Adds the options specified in @entries to @group. | |
| 377 | + | func (x *OptionGroup) AddEntries(EntriesVar uintptr) { | |
| 378 | + | ||
| 379 | + | xOptionGroupAddEntries(x.GoPointer(), EntriesVar) | |
| 380 | + | ||
| 381 | + | } | |
| 382 | + | ||
| 383 | + | var xOptionGroupFree func(uintptr) | |
| 384 | + | ||
| 385 | + | // Frees a #GOptionGroup. Note that you must not free groups | |
| 386 | + | // which have been added to a #GOptionContext. | |
| 387 | + | func (x *OptionGroup) Free() { | |
| 388 | + | ||
| 389 | + | xOptionGroupFree(x.GoPointer()) | |
| 390 | + | ||
| 391 | + | } | |
| 392 | + | ||
| 393 | + | var xOptionGroupRef func(uintptr) *OptionGroup | |
| 394 | + | ||
| 395 | + | // Increments the reference count of @group by one. | |
| 396 | + | func (x *OptionGroup) Ref() *OptionGroup { | |
| 397 | + | ||
| 398 | + | cret := xOptionGroupRef(x.GoPointer()) | |
| 399 | + | return cret | |
| 400 | + | } | |
| 401 | + | ||
| 402 | + | var xOptionGroupSetErrorHook func(uintptr, uintptr) | |
| 403 | + | ||
| 404 | + | // Associates a function with @group which will be called | |
| 405 | + | // from g_option_context_parse() when an error occurs. | |
| 406 | + | // | |
| 407 | + | // Note that the user data to be passed to @error_func can be | |
| 408 | + | // specified when constructing the group with g_option_group_new(). | |
| 409 | + | func (x *OptionGroup) SetErrorHook(ErrorFuncVar OptionErrorFunc) { | |
| 410 | + | ||
| 411 | + | xOptionGroupSetErrorHook(x.GoPointer(), purego.NewCallback(ErrorFuncVar)) | |
| 412 | + | ||
| 413 | + | } | |
| 414 | + | ||
| 415 | + | var xOptionGroupSetParseHooks func(uintptr, uintptr, uintptr) | |
| 416 | + | ||
| 417 | + | // Associates two functions with @group which will be called | |
| 418 | + | // from g_option_context_parse() before the first option is parsed | |
| 419 | + | // and after the last option has been parsed, respectively. | |
| 420 | + | // | |
| 421 | + | // Note that the user data to be passed to @pre_parse_func and | |
| 422 | + | // @post_parse_func can be specified when constructing the group | |
| 423 | + | // with g_option_group_new(). | |
| 424 | + | func (x *OptionGroup) SetParseHooks(PreParseFuncVar OptionParseFunc, PostParseFuncVar OptionParseFunc) { | |
| 425 | + | ||
| 426 | + | xOptionGroupSetParseHooks(x.GoPointer(), purego.NewCallback(PreParseFuncVar), purego.NewCallback(PostParseFuncVar)) | |
| 427 | + | ||
| 428 | + | } | |
| 429 | + | ||
| 430 | + | var xOptionGroupSetTranslateFunc func(uintptr, uintptr, uintptr, uintptr) | |
| 431 | + | ||
| 432 | + | // Sets the function which is used to translate user-visible strings, | |
| 433 | + | // for `--help` output. Different groups can use different | |
| 434 | + | // #GTranslateFuncs. If @func is %NULL, strings are not translated. | |
| 435 | + | // | |
| 436 | + | // If you are using gettext(), you only need to set the translation | |
| 437 | + | // domain, see g_option_group_set_translation_domain(). | |
| 438 | + | func (x *OptionGroup) SetTranslateFunc(FuncVar TranslateFunc, DataVar uintptr, DestroyNotifyVar DestroyNotify) { | |
| 439 | + | ||
| 440 | + | xOptionGroupSetTranslateFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 441 | + | ||
| 442 | + | } | |
| 443 | + | ||
| 444 | + | var xOptionGroupSetTranslationDomain func(uintptr, string) | |
| 445 | + | ||
| 446 | + | // A convenience function to use gettext() for translating | |
| 447 | + | // user-visible strings. | |
| 448 | + | func (x *OptionGroup) SetTranslationDomain(DomainVar string) { | |
| 449 | + | ||
| 450 | + | xOptionGroupSetTranslationDomain(x.GoPointer(), DomainVar) | |
| 451 | + | ||
| 452 | + | } | |
| 453 | + | ||
| 454 | + | var xOptionGroupUnref func(uintptr) | |
| 455 | + | ||
| 456 | + | // Decrements the reference count of @group by one. | |
| 457 | + | // If the reference count drops to 0, the @group will be freed. | |
| 458 | + | // and all memory allocated by the @group is released. | |
| 459 | + | func (x *OptionGroup) Unref() { | |
| 460 | + | ||
| 461 | + | xOptionGroupUnref(x.GoPointer()) | |
| 462 | + | ||
| 463 | + | } | |
| 464 | + | ||
| 465 | + | const ( | |
| 466 | + | // If a long option in the main group has this name, it is not treated as a | |
| 467 | + | // regular option. Instead it collects all non-option arguments which would | |
| 468 | + | // otherwise be left in `argv`. The option must be of type | |
| 469 | + | // %G_OPTION_ARG_CALLBACK, %G_OPTION_ARG_STRING_ARRAY | |
| 470 | + | // or %G_OPTION_ARG_FILENAME_ARRAY. | |
| 471 | + | // | |
| 472 | + | // | |
| 473 | + | // Using %G_OPTION_REMAINING instead of simply scanning `argv` | |
| 474 | + | // for leftover arguments has the advantage that GOption takes care of | |
| 475 | + | // necessary encoding conversions for strings or filenames. | |
| 476 | + | OPTION_REMAINING string = "" | |
| 477 | + | ) | |
| 478 | + | ||
| 49 | 479 | // Flags which modify individual options. | |
| 50 | 480 | type OptionFlags int | |
| 51 | 481 | ||
| @@ -134,3 +564,43 @@ const ( | |||
| 134 | 564 | // A #GOptionArgFunc callback failed. | |
| 135 | 565 | GOptionErrorFailedValue OptionError = 2 | |
| 136 | 566 | ) | |
| 567 | + | ||
| 568 | + | func init() { | |
| 569 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 570 | + | if err != nil { | |
| 571 | + | panic(err) | |
| 572 | + | } | |
| 573 | + | ||
| 574 | + | core.PuregoSafeRegister(&xOptionContextAddGroup, lib, "g_option_context_add_group") | |
| 575 | + | core.PuregoSafeRegister(&xOptionContextAddMainEntries, lib, "g_option_context_add_main_entries") | |
| 576 | + | core.PuregoSafeRegister(&xOptionContextFree, lib, "g_option_context_free") | |
| 577 | + | core.PuregoSafeRegister(&xOptionContextGetDescription, lib, "g_option_context_get_description") | |
| 578 | + | core.PuregoSafeRegister(&xOptionContextGetHelp, lib, "g_option_context_get_help") | |
| 579 | + | core.PuregoSafeRegister(&xOptionContextGetHelpEnabled, lib, "g_option_context_get_help_enabled") | |
| 580 | + | core.PuregoSafeRegister(&xOptionContextGetIgnoreUnknownOptions, lib, "g_option_context_get_ignore_unknown_options") | |
| 581 | + | core.PuregoSafeRegister(&xOptionContextGetMainGroup, lib, "g_option_context_get_main_group") | |
| 582 | + | core.PuregoSafeRegister(&xOptionContextGetStrictPosix, lib, "g_option_context_get_strict_posix") | |
| 583 | + | core.PuregoSafeRegister(&xOptionContextGetSummary, lib, "g_option_context_get_summary") | |
| 584 | + | core.PuregoSafeRegister(&xOptionContextParse, lib, "g_option_context_parse") | |
| 585 | + | core.PuregoSafeRegister(&xOptionContextParseStrv, lib, "g_option_context_parse_strv") | |
| 586 | + | core.PuregoSafeRegister(&xOptionContextSetDescription, lib, "g_option_context_set_description") | |
| 587 | + | core.PuregoSafeRegister(&xOptionContextSetHelpEnabled, lib, "g_option_context_set_help_enabled") | |
| 588 | + | core.PuregoSafeRegister(&xOptionContextSetIgnoreUnknownOptions, lib, "g_option_context_set_ignore_unknown_options") | |
| 589 | + | core.PuregoSafeRegister(&xOptionContextSetMainGroup, lib, "g_option_context_set_main_group") | |
| 590 | + | core.PuregoSafeRegister(&xOptionContextSetStrictPosix, lib, "g_option_context_set_strict_posix") | |
| 591 | + | core.PuregoSafeRegister(&xOptionContextSetSummary, lib, "g_option_context_set_summary") | |
| 592 | + | core.PuregoSafeRegister(&xOptionContextSetTranslateFunc, lib, "g_option_context_set_translate_func") | |
| 593 | + | core.PuregoSafeRegister(&xOptionContextSetTranslationDomain, lib, "g_option_context_set_translation_domain") | |
| 594 | + | ||
| 595 | + | core.PuregoSafeRegister(&xNewOptionGroup, lib, "g_option_group_new") | |
| 596 | + | ||
| 597 | + | core.PuregoSafeRegister(&xOptionGroupAddEntries, lib, "g_option_group_add_entries") | |
| 598 | + | core.PuregoSafeRegister(&xOptionGroupFree, lib, "g_option_group_free") | |
| 599 | + | core.PuregoSafeRegister(&xOptionGroupRef, lib, "g_option_group_ref") | |
| 600 | + | core.PuregoSafeRegister(&xOptionGroupSetErrorHook, lib, "g_option_group_set_error_hook") | |
| 601 | + | core.PuregoSafeRegister(&xOptionGroupSetParseHooks, lib, "g_option_group_set_parse_hooks") | |
| 602 | + | core.PuregoSafeRegister(&xOptionGroupSetTranslateFunc, lib, "g_option_group_set_translate_func") | |
| 603 | + | core.PuregoSafeRegister(&xOptionGroupSetTranslationDomain, lib, "g_option_group_set_translation_domain") | |
| 604 | + | core.PuregoSafeRegister(&xOptionGroupUnref, lib, "g_option_group_unref") | |
| 605 | + | ||
| 606 | + | } | |
M v4/glib/gpattern.go +87 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,83 @@ import ( | |||
| 11 | 13 | type PatternSpec struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *PatternSpec) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xNewPatternSpec func(string) *PatternSpec | |
| 21 | + | ||
| 22 | + | // Compiles a pattern to a #GPatternSpec. | |
| 23 | + | func NewPatternSpec(PatternVar string) *PatternSpec { | |
| 24 | + | ||
| 25 | + | cret := xNewPatternSpec(PatternVar) | |
| 26 | + | return cret | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | var xPatternSpecCopy func(uintptr) *PatternSpec | |
| 30 | + | ||
| 31 | + | // Copies @pspec in a new #GPatternSpec. | |
| 32 | + | func (x *PatternSpec) Copy() *PatternSpec { | |
| 33 | + | ||
| 34 | + | cret := xPatternSpecCopy(x.GoPointer()) | |
| 35 | + | return cret | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | var xPatternSpecEqual func(uintptr, *PatternSpec) bool | |
| 39 | + | ||
| 40 | + | // Compares two compiled pattern specs and returns whether they will | |
| 41 | + | // match the same set of strings. | |
| 42 | + | func (x *PatternSpec) Equal(Pspec2Var *PatternSpec) bool { | |
| 43 | + | ||
| 44 | + | cret := xPatternSpecEqual(x.GoPointer(), Pspec2Var) | |
| 45 | + | return cret | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | var xPatternSpecFree func(uintptr) | |
| 49 | + | ||
| 50 | + | // Frees the memory allocated for the #GPatternSpec. | |
| 51 | + | func (x *PatternSpec) Free() { | |
| 52 | + | ||
| 53 | + | xPatternSpecFree(x.GoPointer()) | |
| 54 | + | ||
| 55 | + | } | |
| 56 | + | ||
| 57 | + | var xPatternSpecMatch func(uintptr, uint, string, string) bool | |
| 58 | + | ||
| 59 | + | // Matches a string against a compiled pattern. Passing the correct | |
| 60 | + | // length of the string given is mandatory. The reversed string can be | |
| 61 | + | // omitted by passing %NULL, this is more efficient if the reversed | |
| 62 | + | // version of the string to be matched is not at hand, as | |
| 63 | + | // g_pattern_match() will only construct it if the compiled pattern | |
| 64 | + | // requires reverse matches. | |
| 65 | + | // | |
| 66 | + | // Note that, if the user code will (possibly) match a string against a | |
| 67 | + | // multitude of patterns containing wildcards, chances are high that | |
| 68 | + | // some patterns will require a reversed string. In this case, it's | |
| 69 | + | // more efficient to provide the reversed string to avoid multiple | |
| 70 | + | // constructions thereof in the various calls to g_pattern_match(). | |
| 71 | + | // | |
| 72 | + | // Note also that the reverse of a UTF-8 encoded string can in general | |
| 73 | + | // not be obtained by g_strreverse(). This works only if the string | |
| 74 | + | // does not contain any multibyte characters. GLib offers the | |
| 75 | + | // g_utf8_strreverse() function to reverse UTF-8 encoded strings. | |
| 76 | + | func (x *PatternSpec) Match(StringLengthVar uint, StringVar string, StringReversedVar string) bool { | |
| 77 | + | ||
| 78 | + | cret := xPatternSpecMatch(x.GoPointer(), StringLengthVar, StringVar, StringReversedVar) | |
| 79 | + | return cret | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | var xPatternSpecMatchString func(uintptr, string) bool | |
| 83 | + | ||
| 84 | + | // Matches a string against a compiled pattern. If the string is to be | |
| 85 | + | // matched against more than one pattern, consider using | |
| 86 | + | // g_pattern_match() instead while supplying the reversed string. | |
| 87 | + | func (x *PatternSpec) MatchString(StringVar string) bool { | |
| 88 | + | ||
| 89 | + | cret := xPatternSpecMatchString(x.GoPointer(), StringVar) | |
| 90 | + | return cret | |
| 91 | + | } | |
| 92 | + | ||
| 14 | 93 | var xPatternMatch func(*PatternSpec, uint, string, string) bool | |
| 15 | 94 | ||
| 16 | 95 | // Matches a string against a compiled pattern. Passing the correct | |
| @@ -68,4 +147,12 @@ func init() { | |||
| 68 | 147 | core.PuregoSafeRegister(&xPatternMatchSimple, lib, "g_pattern_match_simple") | |
| 69 | 148 | core.PuregoSafeRegister(&xPatternMatchString, lib, "g_pattern_match_string") | |
| 70 | 149 | ||
| 150 | + | core.PuregoSafeRegister(&xNewPatternSpec, lib, "g_pattern_spec_new") | |
| 151 | + | ||
| 152 | + | core.PuregoSafeRegister(&xPatternSpecCopy, lib, "g_pattern_spec_copy") | |
| 153 | + | core.PuregoSafeRegister(&xPatternSpecEqual, lib, "g_pattern_spec_equal") | |
| 154 | + | core.PuregoSafeRegister(&xPatternSpecFree, lib, "g_pattern_spec_free") | |
| 155 | + | core.PuregoSafeRegister(&xPatternSpecMatch, lib, "g_pattern_spec_match") | |
| 156 | + | core.PuregoSafeRegister(&xPatternSpecMatchString, lib, "g_pattern_spec_match_string") | |
| 157 | + | ||
| 71 | 158 | } | |
M v4/glib/gpoll.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -20,6 +22,10 @@ type PollFD struct { | |||
| 20 | 22 | Revents uint16 | |
| 21 | 23 | } | |
| 22 | 24 | ||
| 25 | + | func (x *PollFD) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 23 | 29 | var xPoll func(*PollFD, uint, int) int | |
| 24 | 30 | ||
| 25 | 31 | // Polls @fds, as with the poll() system call, but portably. (On | |
M v4/glib/gqueue.go +479 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Contains the public fields of a | |
| 5 | 12 | // [Queue][glib-Double-ended-Queues]. | |
| 6 | 13 | type Queue struct { | |
| @@ -10,3 +17,475 @@ type Queue struct { | |||
| 10 | 17 | ||
| 11 | 18 | Length uint | |
| 12 | 19 | } | |
| 20 | + | ||
| 21 | + | func (x *Queue) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | var xQueueClear func(uintptr) | |
| 26 | + | ||
| 27 | + | // Removes all the elements in @queue. If queue elements contain | |
| 28 | + | // dynamically-allocated memory, they should be freed first. | |
| 29 | + | func (x *Queue) Clear() { | |
| 30 | + | ||
| 31 | + | xQueueClear(x.GoPointer()) | |
| 32 | + | ||
| 33 | + | } | |
| 34 | + | ||
| 35 | + | var xQueueClearFull func(uintptr, uintptr) | |
| 36 | + | ||
| 37 | + | // Convenience method, which frees all the memory used by a #GQueue, | |
| 38 | + | // and calls the provided @free_func on each item in the #GQueue. | |
| 39 | + | func (x *Queue) ClearFull(FreeFuncVar DestroyNotify) { | |
| 40 | + | ||
| 41 | + | xQueueClearFull(x.GoPointer(), purego.NewCallback(FreeFuncVar)) | |
| 42 | + | ||
| 43 | + | } | |
| 44 | + | ||
| 45 | + | var xQueueCopy func(uintptr) *Queue | |
| 46 | + | ||
| 47 | + | // Copies a @queue. Note that is a shallow copy. If the elements in the | |
| 48 | + | // queue consist of pointers to data, the pointers are copied, but the | |
| 49 | + | // actual data is not. | |
| 50 | + | func (x *Queue) Copy() *Queue { | |
| 51 | + | ||
| 52 | + | cret := xQueueCopy(x.GoPointer()) | |
| 53 | + | return cret | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | var xQueueDeleteLink func(uintptr, *List) | |
| 57 | + | ||
| 58 | + | // Removes @link_ from @queue and frees it. | |
| 59 | + | // | |
| 60 | + | // @link_ must be part of @queue. | |
| 61 | + | func (x *Queue) DeleteLink(LinkVar *List) { | |
| 62 | + | ||
| 63 | + | xQueueDeleteLink(x.GoPointer(), LinkVar) | |
| 64 | + | ||
| 65 | + | } | |
| 66 | + | ||
| 67 | + | var xQueueFind func(uintptr, uintptr) *List | |
| 68 | + | ||
| 69 | + | // Finds the first link in @queue which contains @data. | |
| 70 | + | func (x *Queue) Find(DataVar uintptr) *List { | |
| 71 | + | ||
| 72 | + | cret := xQueueFind(x.GoPointer(), DataVar) | |
| 73 | + | return cret | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | var xQueueFindCustom func(uintptr, uintptr, uintptr) *List | |
| 77 | + | ||
| 78 | + | // Finds an element in a #GQueue, using a supplied function to find the | |
| 79 | + | // desired element. It iterates over the queue, calling the given function | |
| 80 | + | // which should return 0 when the desired element is found. The function | |
| 81 | + | // takes two gconstpointer arguments, the #GQueue element's data as the | |
| 82 | + | // first argument and the given user data as the second argument. | |
| 83 | + | func (x *Queue) FindCustom(DataVar uintptr, FuncVar CompareFunc) *List { | |
| 84 | + | ||
| 85 | + | cret := xQueueFindCustom(x.GoPointer(), DataVar, purego.NewCallback(FuncVar)) | |
| 86 | + | return cret | |
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xQueueForeach func(uintptr, uintptr, uintptr) | |
| 90 | + | ||
| 91 | + | // Calls @func for each element in the queue passing @user_data to the | |
| 92 | + | // function. | |
| 93 | + | // | |
| 94 | + | // It is safe for @func to remove the element from @queue, but it must | |
| 95 | + | // not modify any part of the queue after that element. | |
| 96 | + | func (x *Queue) Foreach(FuncVar Func, UserDataVar uintptr) { | |
| 97 | + | ||
| 98 | + | xQueueForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 99 | + | ||
| 100 | + | } | |
| 101 | + | ||
| 102 | + | var xQueueFree func(uintptr) | |
| 103 | + | ||
| 104 | + | // Frees the memory allocated for the #GQueue. Only call this function | |
| 105 | + | // if @queue was created with g_queue_new(). If queue elements contain | |
| 106 | + | // dynamically-allocated memory, they should be freed first. | |
| 107 | + | // | |
| 108 | + | // If queue elements contain dynamically-allocated memory, you should | |
| 109 | + | // either use g_queue_free_full() or free them manually first. | |
| 110 | + | func (x *Queue) Free() { | |
| 111 | + | ||
| 112 | + | xQueueFree(x.GoPointer()) | |
| 113 | + | ||
| 114 | + | } | |
| 115 | + | ||
| 116 | + | var xQueueFreeFull func(uintptr, uintptr) | |
| 117 | + | ||
| 118 | + | // Convenience method, which frees all the memory used by a #GQueue, | |
| 119 | + | // and calls the specified destroy function on every element's data. | |
| 120 | + | // | |
| 121 | + | // @free_func should not modify the queue (eg, by removing the freed | |
| 122 | + | // element from it). | |
| 123 | + | func (x *Queue) FreeFull(FreeFuncVar DestroyNotify) { | |
| 124 | + | ||
| 125 | + | xQueueFreeFull(x.GoPointer(), purego.NewCallback(FreeFuncVar)) | |
| 126 | + | ||
| 127 | + | } | |
| 128 | + | ||
| 129 | + | var xQueueGetLength func(uintptr) uint | |
| 130 | + | ||
| 131 | + | // Returns the number of items in @queue. | |
| 132 | + | func (x *Queue) GetLength() uint { | |
| 133 | + | ||
| 134 | + | cret := xQueueGetLength(x.GoPointer()) | |
| 135 | + | return cret | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xQueueIndex func(uintptr, uintptr) int | |
| 139 | + | ||
| 140 | + | // Returns the position of the first element in @queue which contains @data. | |
| 141 | + | func (x *Queue) Index(DataVar uintptr) int { | |
| 142 | + | ||
| 143 | + | cret := xQueueIndex(x.GoPointer(), DataVar) | |
| 144 | + | return cret | |
| 145 | + | } | |
| 146 | + | ||
| 147 | + | var xQueueInit func(uintptr) | |
| 148 | + | ||
| 149 | + | // A statically-allocated #GQueue must be initialized with this function | |
| 150 | + | // before it can be used. Alternatively you can initialize it with | |
| 151 | + | // %G_QUEUE_INIT. It is not necessary to initialize queues created with | |
| 152 | + | // g_queue_new(). | |
| 153 | + | func (x *Queue) Init() { | |
| 154 | + | ||
| 155 | + | xQueueInit(x.GoPointer()) | |
| 156 | + | ||
| 157 | + | } | |
| 158 | + | ||
| 159 | + | var xQueueInsertAfter func(uintptr, *List, uintptr) | |
| 160 | + | ||
| 161 | + | // Inserts @data into @queue after @sibling. | |
| 162 | + | // | |
| 163 | + | // @sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the | |
| 164 | + | // data at the head of the queue. | |
| 165 | + | func (x *Queue) InsertAfter(SiblingVar *List, DataVar uintptr) { | |
| 166 | + | ||
| 167 | + | xQueueInsertAfter(x.GoPointer(), SiblingVar, DataVar) | |
| 168 | + | ||
| 169 | + | } | |
| 170 | + | ||
| 171 | + | var xQueueInsertAfterLink func(uintptr, *List, *List) | |
| 172 | + | ||
| 173 | + | // Inserts @link_ into @queue after @sibling. | |
| 174 | + | // | |
| 175 | + | // @sibling must be part of @queue. | |
| 176 | + | func (x *Queue) InsertAfterLink(SiblingVar *List, LinkVar *List) { | |
| 177 | + | ||
| 178 | + | xQueueInsertAfterLink(x.GoPointer(), SiblingVar, LinkVar) | |
| 179 | + | ||
| 180 | + | } | |
| 181 | + | ||
| 182 | + | var xQueueInsertBefore func(uintptr, *List, uintptr) | |
| 183 | + | ||
| 184 | + | // Inserts @data into @queue before @sibling. | |
| 185 | + | // | |
| 186 | + | // @sibling must be part of @queue. Since GLib 2.44 a %NULL sibling pushes the | |
| 187 | + | // data at the tail of the queue. | |
| 188 | + | func (x *Queue) InsertBefore(SiblingVar *List, DataVar uintptr) { | |
| 189 | + | ||
| 190 | + | xQueueInsertBefore(x.GoPointer(), SiblingVar, DataVar) | |
| 191 | + | ||
| 192 | + | } | |
| 193 | + | ||
| 194 | + | var xQueueInsertBeforeLink func(uintptr, *List, *List) | |
| 195 | + | ||
| 196 | + | // Inserts @link_ into @queue before @sibling. | |
| 197 | + | // | |
| 198 | + | // @sibling must be part of @queue. | |
| 199 | + | func (x *Queue) InsertBeforeLink(SiblingVar *List, LinkVar *List) { | |
| 200 | + | ||
| 201 | + | xQueueInsertBeforeLink(x.GoPointer(), SiblingVar, LinkVar) | |
| 202 | + | ||
| 203 | + | } | |
| 204 | + | ||
| 205 | + | var xQueueInsertSorted func(uintptr, uintptr, uintptr, uintptr) | |
| 206 | + | ||
| 207 | + | // Inserts @data into @queue using @func to determine the new position. | |
| 208 | + | func (x *Queue) InsertSorted(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 209 | + | ||
| 210 | + | xQueueInsertSorted(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 211 | + | ||
| 212 | + | } | |
| 213 | + | ||
| 214 | + | var xQueueIsEmpty func(uintptr) bool | |
| 215 | + | ||
| 216 | + | // Returns %TRUE if the queue is empty. | |
| 217 | + | func (x *Queue) IsEmpty() bool { | |
| 218 | + | ||
| 219 | + | cret := xQueueIsEmpty(x.GoPointer()) | |
| 220 | + | return cret | |
| 221 | + | } | |
| 222 | + | ||
| 223 | + | var xQueueLinkIndex func(uintptr, *List) int | |
| 224 | + | ||
| 225 | + | // Returns the position of @link_ in @queue. | |
| 226 | + | func (x *Queue) LinkIndex(LinkVar *List) int { | |
| 227 | + | ||
| 228 | + | cret := xQueueLinkIndex(x.GoPointer(), LinkVar) | |
| 229 | + | return cret | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | var xQueuePeekHead func(uintptr) uintptr | |
| 233 | + | ||
| 234 | + | // Returns the first element of the queue. | |
| 235 | + | func (x *Queue) PeekHead() uintptr { | |
| 236 | + | ||
| 237 | + | cret := xQueuePeekHead(x.GoPointer()) | |
| 238 | + | return cret | |
| 239 | + | } | |
| 240 | + | ||
| 241 | + | var xQueuePeekHeadLink func(uintptr) *List | |
| 242 | + | ||
| 243 | + | // Returns the first link in @queue. | |
| 244 | + | func (x *Queue) PeekHeadLink() *List { | |
| 245 | + | ||
| 246 | + | cret := xQueuePeekHeadLink(x.GoPointer()) | |
| 247 | + | return cret | |
| 248 | + | } | |
| 249 | + | ||
| 250 | + | var xQueuePeekNth func(uintptr, uint) uintptr | |
| 251 | + | ||
| 252 | + | // Returns the @n'th element of @queue. | |
| 253 | + | func (x *Queue) PeekNth(NVar uint) uintptr { | |
| 254 | + | ||
| 255 | + | cret := xQueuePeekNth(x.GoPointer(), NVar) | |
| 256 | + | return cret | |
| 257 | + | } | |
| 258 | + | ||
| 259 | + | var xQueuePeekNthLink func(uintptr, uint) *List | |
| 260 | + | ||
| 261 | + | // Returns the link at the given position | |
| 262 | + | func (x *Queue) PeekNthLink(NVar uint) *List { | |
| 263 | + | ||
| 264 | + | cret := xQueuePeekNthLink(x.GoPointer(), NVar) | |
| 265 | + | return cret | |
| 266 | + | } | |
| 267 | + | ||
| 268 | + | var xQueuePeekTail func(uintptr) uintptr | |
| 269 | + | ||
| 270 | + | // Returns the last element of the queue. | |
| 271 | + | func (x *Queue) PeekTail() uintptr { | |
| 272 | + | ||
| 273 | + | cret := xQueuePeekTail(x.GoPointer()) | |
| 274 | + | return cret | |
| 275 | + | } | |
| 276 | + | ||
| 277 | + | var xQueuePeekTailLink func(uintptr) *List | |
| 278 | + | ||
| 279 | + | // Returns the last link in @queue. | |
| 280 | + | func (x *Queue) PeekTailLink() *List { | |
| 281 | + | ||
| 282 | + | cret := xQueuePeekTailLink(x.GoPointer()) | |
| 283 | + | return cret | |
| 284 | + | } | |
| 285 | + | ||
| 286 | + | var xQueuePopHead func(uintptr) uintptr | |
| 287 | + | ||
| 288 | + | // Removes the first element of the queue and returns its data. | |
| 289 | + | func (x *Queue) PopHead() uintptr { | |
| 290 | + | ||
| 291 | + | cret := xQueuePopHead(x.GoPointer()) | |
| 292 | + | return cret | |
| 293 | + | } | |
| 294 | + | ||
| 295 | + | var xQueuePopHeadLink func(uintptr) *List | |
| 296 | + | ||
| 297 | + | // Removes and returns the first element of the queue. | |
| 298 | + | func (x *Queue) PopHeadLink() *List { | |
| 299 | + | ||
| 300 | + | cret := xQueuePopHeadLink(x.GoPointer()) | |
| 301 | + | return cret | |
| 302 | + | } | |
| 303 | + | ||
| 304 | + | var xQueuePopNth func(uintptr, uint) uintptr | |
| 305 | + | ||
| 306 | + | // Removes the @n'th element of @queue and returns its data. | |
| 307 | + | func (x *Queue) PopNth(NVar uint) uintptr { | |
| 308 | + | ||
| 309 | + | cret := xQueuePopNth(x.GoPointer(), NVar) | |
| 310 | + | return cret | |
| 311 | + | } | |
| 312 | + | ||
| 313 | + | var xQueuePopNthLink func(uintptr, uint) *List | |
| 314 | + | ||
| 315 | + | // Removes and returns the link at the given position. | |
| 316 | + | func (x *Queue) PopNthLink(NVar uint) *List { | |
| 317 | + | ||
| 318 | + | cret := xQueuePopNthLink(x.GoPointer(), NVar) | |
| 319 | + | return cret | |
| 320 | + | } | |
| 321 | + | ||
| 322 | + | var xQueuePopTail func(uintptr) uintptr | |
| 323 | + | ||
| 324 | + | // Removes the last element of the queue and returns its data. | |
| 325 | + | func (x *Queue) PopTail() uintptr { | |
| 326 | + | ||
| 327 | + | cret := xQueuePopTail(x.GoPointer()) | |
| 328 | + | return cret | |
| 329 | + | } | |
| 330 | + | ||
| 331 | + | var xQueuePopTailLink func(uintptr) *List | |
| 332 | + | ||
| 333 | + | // Removes and returns the last element of the queue. | |
| 334 | + | func (x *Queue) PopTailLink() *List { | |
| 335 | + | ||
| 336 | + | cret := xQueuePopTailLink(x.GoPointer()) | |
| 337 | + | return cret | |
| 338 | + | } | |
| 339 | + | ||
| 340 | + | var xQueuePushHead func(uintptr, uintptr) | |
| 341 | + | ||
| 342 | + | // Adds a new element at the head of the queue. | |
| 343 | + | func (x *Queue) PushHead(DataVar uintptr) { | |
| 344 | + | ||
| 345 | + | xQueuePushHead(x.GoPointer(), DataVar) | |
| 346 | + | ||
| 347 | + | } | |
| 348 | + | ||
| 349 | + | var xQueuePushHeadLink func(uintptr, *List) | |
| 350 | + | ||
| 351 | + | // Adds a new element at the head of the queue. | |
| 352 | + | func (x *Queue) PushHeadLink(LinkVar *List) { | |
| 353 | + | ||
| 354 | + | xQueuePushHeadLink(x.GoPointer(), LinkVar) | |
| 355 | + | ||
| 356 | + | } | |
| 357 | + | ||
| 358 | + | var xQueuePushNth func(uintptr, uintptr, int) | |
| 359 | + | ||
| 360 | + | // Inserts a new element into @queue at the given position. | |
| 361 | + | func (x *Queue) PushNth(DataVar uintptr, NVar int) { | |
| 362 | + | ||
| 363 | + | xQueuePushNth(x.GoPointer(), DataVar, NVar) | |
| 364 | + | ||
| 365 | + | } | |
| 366 | + | ||
| 367 | + | var xQueuePushNthLink func(uintptr, int, *List) | |
| 368 | + | ||
| 369 | + | // Inserts @link into @queue at the given position. | |
| 370 | + | func (x *Queue) PushNthLink(NVar int, LinkVar *List) { | |
| 371 | + | ||
| 372 | + | xQueuePushNthLink(x.GoPointer(), NVar, LinkVar) | |
| 373 | + | ||
| 374 | + | } | |
| 375 | + | ||
| 376 | + | var xQueuePushTail func(uintptr, uintptr) | |
| 377 | + | ||
| 378 | + | // Adds a new element at the tail of the queue. | |
| 379 | + | func (x *Queue) PushTail(DataVar uintptr) { | |
| 380 | + | ||
| 381 | + | xQueuePushTail(x.GoPointer(), DataVar) | |
| 382 | + | ||
| 383 | + | } | |
| 384 | + | ||
| 385 | + | var xQueuePushTailLink func(uintptr, *List) | |
| 386 | + | ||
| 387 | + | // Adds a new element at the tail of the queue. | |
| 388 | + | func (x *Queue) PushTailLink(LinkVar *List) { | |
| 389 | + | ||
| 390 | + | xQueuePushTailLink(x.GoPointer(), LinkVar) | |
| 391 | + | ||
| 392 | + | } | |
| 393 | + | ||
| 394 | + | var xQueueRemove func(uintptr, uintptr) bool | |
| 395 | + | ||
| 396 | + | // Removes the first element in @queue that contains @data. | |
| 397 | + | func (x *Queue) Remove(DataVar uintptr) bool { | |
| 398 | + | ||
| 399 | + | cret := xQueueRemove(x.GoPointer(), DataVar) | |
| 400 | + | return cret | |
| 401 | + | } | |
| 402 | + | ||
| 403 | + | var xQueueRemoveAll func(uintptr, uintptr) uint | |
| 404 | + | ||
| 405 | + | // Remove all elements whose data equals @data from @queue. | |
| 406 | + | func (x *Queue) RemoveAll(DataVar uintptr) uint { | |
| 407 | + | ||
| 408 | + | cret := xQueueRemoveAll(x.GoPointer(), DataVar) | |
| 409 | + | return cret | |
| 410 | + | } | |
| 411 | + | ||
| 412 | + | var xQueueReverse func(uintptr) | |
| 413 | + | ||
| 414 | + | // Reverses the order of the items in @queue. | |
| 415 | + | func (x *Queue) Reverse() { | |
| 416 | + | ||
| 417 | + | xQueueReverse(x.GoPointer()) | |
| 418 | + | ||
| 419 | + | } | |
| 420 | + | ||
| 421 | + | var xQueueSort func(uintptr, uintptr, uintptr) | |
| 422 | + | ||
| 423 | + | // Sorts @queue using @compare_func. | |
| 424 | + | func (x *Queue) Sort(CompareFuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 425 | + | ||
| 426 | + | xQueueSort(x.GoPointer(), purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 427 | + | ||
| 428 | + | } | |
| 429 | + | ||
| 430 | + | var xQueueUnlink func(uintptr, *List) | |
| 431 | + | ||
| 432 | + | // Unlinks @link_ so that it will no longer be part of @queue. | |
| 433 | + | // The link is not freed. | |
| 434 | + | // | |
| 435 | + | // @link_ must be part of @queue. | |
| 436 | + | func (x *Queue) Unlink(LinkVar *List) { | |
| 437 | + | ||
| 438 | + | xQueueUnlink(x.GoPointer(), LinkVar) | |
| 439 | + | ||
| 440 | + | } | |
| 441 | + | ||
| 442 | + | func init() { | |
| 443 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 444 | + | if err != nil { | |
| 445 | + | panic(err) | |
| 446 | + | } | |
| 447 | + | ||
| 448 | + | core.PuregoSafeRegister(&xQueueClear, lib, "g_queue_clear") | |
| 449 | + | core.PuregoSafeRegister(&xQueueClearFull, lib, "g_queue_clear_full") | |
| 450 | + | core.PuregoSafeRegister(&xQueueCopy, lib, "g_queue_copy") | |
| 451 | + | core.PuregoSafeRegister(&xQueueDeleteLink, lib, "g_queue_delete_link") | |
| 452 | + | core.PuregoSafeRegister(&xQueueFind, lib, "g_queue_find") | |
| 453 | + | core.PuregoSafeRegister(&xQueueFindCustom, lib, "g_queue_find_custom") | |
| 454 | + | core.PuregoSafeRegister(&xQueueForeach, lib, "g_queue_foreach") | |
| 455 | + | core.PuregoSafeRegister(&xQueueFree, lib, "g_queue_free") | |
| 456 | + | core.PuregoSafeRegister(&xQueueFreeFull, lib, "g_queue_free_full") | |
| 457 | + | core.PuregoSafeRegister(&xQueueGetLength, lib, "g_queue_get_length") | |
| 458 | + | core.PuregoSafeRegister(&xQueueIndex, lib, "g_queue_index") | |
| 459 | + | core.PuregoSafeRegister(&xQueueInit, lib, "g_queue_init") | |
| 460 | + | core.PuregoSafeRegister(&xQueueInsertAfter, lib, "g_queue_insert_after") | |
| 461 | + | core.PuregoSafeRegister(&xQueueInsertAfterLink, lib, "g_queue_insert_after_link") | |
| 462 | + | core.PuregoSafeRegister(&xQueueInsertBefore, lib, "g_queue_insert_before") | |
| 463 | + | core.PuregoSafeRegister(&xQueueInsertBeforeLink, lib, "g_queue_insert_before_link") | |
| 464 | + | core.PuregoSafeRegister(&xQueueInsertSorted, lib, "g_queue_insert_sorted") | |
| 465 | + | core.PuregoSafeRegister(&xQueueIsEmpty, lib, "g_queue_is_empty") | |
| 466 | + | core.PuregoSafeRegister(&xQueueLinkIndex, lib, "g_queue_link_index") | |
| 467 | + | core.PuregoSafeRegister(&xQueuePeekHead, lib, "g_queue_peek_head") | |
| 468 | + | core.PuregoSafeRegister(&xQueuePeekHeadLink, lib, "g_queue_peek_head_link") | |
| 469 | + | core.PuregoSafeRegister(&xQueuePeekNth, lib, "g_queue_peek_nth") | |
| 470 | + | core.PuregoSafeRegister(&xQueuePeekNthLink, lib, "g_queue_peek_nth_link") | |
| 471 | + | core.PuregoSafeRegister(&xQueuePeekTail, lib, "g_queue_peek_tail") | |
| 472 | + | core.PuregoSafeRegister(&xQueuePeekTailLink, lib, "g_queue_peek_tail_link") | |
| 473 | + | core.PuregoSafeRegister(&xQueuePopHead, lib, "g_queue_pop_head") | |
| 474 | + | core.PuregoSafeRegister(&xQueuePopHeadLink, lib, "g_queue_pop_head_link") | |
| 475 | + | core.PuregoSafeRegister(&xQueuePopNth, lib, "g_queue_pop_nth") | |
| 476 | + | core.PuregoSafeRegister(&xQueuePopNthLink, lib, "g_queue_pop_nth_link") | |
| 477 | + | core.PuregoSafeRegister(&xQueuePopTail, lib, "g_queue_pop_tail") | |
| 478 | + | core.PuregoSafeRegister(&xQueuePopTailLink, lib, "g_queue_pop_tail_link") | |
| 479 | + | core.PuregoSafeRegister(&xQueuePushHead, lib, "g_queue_push_head") | |
| 480 | + | core.PuregoSafeRegister(&xQueuePushHeadLink, lib, "g_queue_push_head_link") | |
| 481 | + | core.PuregoSafeRegister(&xQueuePushNth, lib, "g_queue_push_nth") | |
| 482 | + | core.PuregoSafeRegister(&xQueuePushNthLink, lib, "g_queue_push_nth_link") | |
| 483 | + | core.PuregoSafeRegister(&xQueuePushTail, lib, "g_queue_push_tail") | |
| 484 | + | core.PuregoSafeRegister(&xQueuePushTailLink, lib, "g_queue_push_tail_link") | |
| 485 | + | core.PuregoSafeRegister(&xQueueRemove, lib, "g_queue_remove") | |
| 486 | + | core.PuregoSafeRegister(&xQueueRemoveAll, lib, "g_queue_remove_all") | |
| 487 | + | core.PuregoSafeRegister(&xQueueReverse, lib, "g_queue_reverse") | |
| 488 | + | core.PuregoSafeRegister(&xQueueSort, lib, "g_queue_sort") | |
| 489 | + | core.PuregoSafeRegister(&xQueueUnlink, lib, "g_queue_unlink") | |
| 490 | + | ||
| 491 | + | } | |
M v4/glib/grand.go +97 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -11,6 +13,92 @@ import ( | |||
| 11 | 13 | type Rand struct { | |
| 12 | 14 | } | |
| 13 | 15 | ||
| 16 | + | func (x *Rand) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xRandCopy func(uintptr) *Rand | |
| 21 | + | ||
| 22 | + | // Copies a #GRand into a new one with the same exact state as before. | |
| 23 | + | // This way you can take a snapshot of the random number generator for | |
| 24 | + | // replaying later. | |
| 25 | + | func (x *Rand) Copy() *Rand { | |
| 26 | + | ||
| 27 | + | cret := xRandCopy(x.GoPointer()) | |
| 28 | + | return cret | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | var xRandDouble func(uintptr) float64 | |
| 32 | + | ||
| 33 | + | // Returns the next random #gdouble from @rand_ equally distributed over | |
| 34 | + | // the range [0..1). | |
| 35 | + | func (x *Rand) Double() float64 { | |
| 36 | + | ||
| 37 | + | cret := xRandDouble(x.GoPointer()) | |
| 38 | + | return cret | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | var xRandDoubleRange func(uintptr, float64, float64) float64 | |
| 42 | + | ||
| 43 | + | // Returns the next random #gdouble from @rand_ equally distributed over | |
| 44 | + | // the range [@begin..@end). | |
| 45 | + | func (x *Rand) DoubleRange(BeginVar float64, EndVar float64) float64 { | |
| 46 | + | ||
| 47 | + | cret := xRandDoubleRange(x.GoPointer(), BeginVar, EndVar) | |
| 48 | + | return cret | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | var xRandFree func(uintptr) | |
| 52 | + | ||
| 53 | + | // Frees the memory allocated for the #GRand. | |
| 54 | + | func (x *Rand) Free() { | |
| 55 | + | ||
| 56 | + | xRandFree(x.GoPointer()) | |
| 57 | + | ||
| 58 | + | } | |
| 59 | + | ||
| 60 | + | var xRandInt func(uintptr) uint32 | |
| 61 | + | ||
| 62 | + | // Returns the next random #guint32 from @rand_ equally distributed over | |
| 63 | + | // the range [0..2^32-1]. | |
| 64 | + | func (x *Rand) Int() uint32 { | |
| 65 | + | ||
| 66 | + | cret := xRandInt(x.GoPointer()) | |
| 67 | + | return cret | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | var xRandIntRange func(uintptr, int32, int32) int32 | |
| 71 | + | ||
| 72 | + | // Returns the next random #gint32 from @rand_ equally distributed over | |
| 73 | + | // the range [@begin..@end-1]. | |
| 74 | + | func (x *Rand) IntRange(BeginVar int32, EndVar int32) int32 { | |
| 75 | + | ||
| 76 | + | cret := xRandIntRange(x.GoPointer(), BeginVar, EndVar) | |
| 77 | + | return cret | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | var xRandSetSeed func(uintptr, uint32) | |
| 81 | + | ||
| 82 | + | // Sets the seed for the random number generator #GRand to @seed. | |
| 83 | + | func (x *Rand) SetSeed(SeedVar uint32) { | |
| 84 | + | ||
| 85 | + | xRandSetSeed(x.GoPointer(), SeedVar) | |
| 86 | + | ||
| 87 | + | } | |
| 88 | + | ||
| 89 | + | var xRandSetSeedArray func(uintptr, uint32, uint) | |
| 90 | + | ||
| 91 | + | // Initializes the random number generator by an array of longs. | |
| 92 | + | // Array can be of arbitrary size, though only the first 624 values | |
| 93 | + | // are taken. This function is useful if you have many low entropy | |
| 94 | + | // seeds, or if you require more then 32 bits of actual entropy for | |
| 95 | + | // your application. | |
| 96 | + | func (x *Rand) SetSeedArray(SeedVar uint32, SeedLengthVar uint) { | |
| 97 | + | ||
| 98 | + | xRandSetSeedArray(x.GoPointer(), SeedVar, SeedLengthVar) | |
| 99 | + | ||
| 100 | + | } | |
| 101 | + | ||
| 14 | 102 | var xRandomDouble func() float64 | |
| 15 | 103 | ||
| 16 | 104 | // Returns a random #gdouble equally distributed over the range [0..1). | |
| @@ -71,4 +159,13 @@ func init() { | |||
| 71 | 159 | core.PuregoSafeRegister(&xRandomIntRange, lib, "g_random_int_range") | |
| 72 | 160 | core.PuregoSafeRegister(&xRandomSetSeed, lib, "g_random_set_seed") | |
| 73 | 161 | ||
| 162 | + | core.PuregoSafeRegister(&xRandCopy, lib, "g_rand_copy") | |
| 163 | + | core.PuregoSafeRegister(&xRandDouble, lib, "g_rand_double") | |
| 164 | + | core.PuregoSafeRegister(&xRandDoubleRange, lib, "g_rand_double_range") | |
| 165 | + | core.PuregoSafeRegister(&xRandFree, lib, "g_rand_free") | |
| 166 | + | core.PuregoSafeRegister(&xRandInt, lib, "g_rand_int") | |
| 167 | + | core.PuregoSafeRegister(&xRandIntRange, lib, "g_rand_int_range") | |
| 168 | + | core.PuregoSafeRegister(&xRandSetSeed, lib, "g_rand_set_seed") | |
| 169 | + | core.PuregoSafeRegister(&xRandSetSeedArray, lib, "g_rand_set_seed_array") | |
| 170 | + | ||
| 74 | 171 | } | |
M v4/glib/gregex.go +795 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -17,6 +19,274 @@ type RegexEvalCallback func(*MatchInfo, *String, uintptr) bool | |||
| 17 | 19 | type MatchInfo struct { | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *MatchInfo) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | var xMatchInfoExpandReferences func(uintptr, string, **Error) string | |
| 27 | + | ||
| 28 | + | // Returns a new string containing the text in @string_to_expand with | |
| 29 | + | // references and escape sequences expanded. References refer to the last | |
| 30 | + | // match done with @string against @regex and have the same syntax used by | |
| 31 | + | // g_regex_replace(). | |
| 32 | + | // | |
| 33 | + | // The @string_to_expand must be UTF-8 encoded even if %G_REGEX_RAW was | |
| 34 | + | // passed to g_regex_new(). | |
| 35 | + | // | |
| 36 | + | // The backreferences are extracted from the string passed to the match | |
| 37 | + | // function, so you cannot call this function after freeing the string. | |
| 38 | + | // | |
| 39 | + | // @match_info may be %NULL in which case @string_to_expand must not | |
| 40 | + | // contain references. For instance "foo\n" does not refer to an actual | |
| 41 | + | // pattern and '\n' merely will be replaced with \n character, | |
| 42 | + | // while to expand "\0" (whole match) one needs the result of a match. | |
| 43 | + | // Use g_regex_check_replacement() to find out whether @string_to_expand | |
| 44 | + | // contains references. | |
| 45 | + | func (x *MatchInfo) ExpandReferences(StringToExpandVar string) (string, error) { | |
| 46 | + | var cerr *Error | |
| 47 | + | ||
| 48 | + | cret := xMatchInfoExpandReferences(x.GoPointer(), StringToExpandVar, &cerr) | |
| 49 | + | if cerr == nil { | |
| 50 | + | return cret, nil | |
| 51 | + | } | |
| 52 | + | return cret, cerr | |
| 53 | + | ||
| 54 | + | } | |
| 55 | + | ||
| 56 | + | var xMatchInfoFetch func(uintptr, int) string | |
| 57 | + | ||
| 58 | + | // Retrieves the text matching the @match_num'th capturing | |
| 59 | + | // parentheses. 0 is the full text of the match, 1 is the first paren | |
| 60 | + | // set, 2 the second, and so on. | |
| 61 | + | // | |
| 62 | + | // If @match_num is a valid sub pattern but it didn't match anything | |
| 63 | + | // (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty | |
| 64 | + | // string is returned. | |
| 65 | + | // | |
| 66 | + | // If the match was obtained using the DFA algorithm, that is using | |
| 67 | + | // g_regex_match_all() or g_regex_match_all_full(), the retrieved | |
| 68 | + | // string is not that of a set of parentheses but that of a matched | |
| 69 | + | // substring. Substrings are matched in reverse order of length, so | |
| 70 | + | // 0 is the longest match. | |
| 71 | + | // | |
| 72 | + | // The string is fetched from the string passed to the match function, | |
| 73 | + | // so you cannot call this function after freeing the string. | |
| 74 | + | func (x *MatchInfo) Fetch(MatchNumVar int) string { | |
| 75 | + | ||
| 76 | + | cret := xMatchInfoFetch(x.GoPointer(), MatchNumVar) | |
| 77 | + | return cret | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | var xMatchInfoFetchAll func(uintptr) uintptr | |
| 81 | + | ||
| 82 | + | // Bundles up pointers to each of the matching substrings from a match | |
| 83 | + | // and stores them in an array of gchar pointers. The first element in | |
| 84 | + | // the returned array is the match number 0, i.e. the entire matched | |
| 85 | + | // text. | |
| 86 | + | // | |
| 87 | + | // If a sub pattern didn't match anything (e.g. sub pattern 1, matching | |
| 88 | + | // "b" against "(a)?b") then an empty string is inserted. | |
| 89 | + | // | |
| 90 | + | // If the last match was obtained using the DFA algorithm, that is using | |
| 91 | + | // g_regex_match_all() or g_regex_match_all_full(), the retrieved | |
| 92 | + | // strings are not that matched by sets of parentheses but that of the | |
| 93 | + | // matched substring. Substrings are matched in reverse order of length, | |
| 94 | + | // so the first one is the longest match. | |
| 95 | + | // | |
| 96 | + | // The strings are fetched from the string passed to the match function, | |
| 97 | + | // so you cannot call this function after freeing the string. | |
| 98 | + | func (x *MatchInfo) FetchAll() uintptr { | |
| 99 | + | ||
| 100 | + | cret := xMatchInfoFetchAll(x.GoPointer()) | |
| 101 | + | return cret | |
| 102 | + | } | |
| 103 | + | ||
| 104 | + | var xMatchInfoFetchNamed func(uintptr, string) string | |
| 105 | + | ||
| 106 | + | // Retrieves the text matching the capturing parentheses named @name. | |
| 107 | + | // | |
| 108 | + | // If @name is a valid sub pattern name but it didn't match anything | |
| 109 | + | // (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b") | |
| 110 | + | // then an empty string is returned. | |
| 111 | + | // | |
| 112 | + | // The string is fetched from the string passed to the match function, | |
| 113 | + | // so you cannot call this function after freeing the string. | |
| 114 | + | func (x *MatchInfo) FetchNamed(NameVar string) string { | |
| 115 | + | ||
| 116 | + | cret := xMatchInfoFetchNamed(x.GoPointer(), NameVar) | |
| 117 | + | return cret | |
| 118 | + | } | |
| 119 | + | ||
| 120 | + | var xMatchInfoFetchNamedPos func(uintptr, string, int, int) bool | |
| 121 | + | ||
| 122 | + | // Retrieves the position in bytes of the capturing parentheses named @name. | |
| 123 | + | // | |
| 124 | + | // If @name is a valid sub pattern name but it didn't match anything | |
| 125 | + | // (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b") | |
| 126 | + | // then @start_pos and @end_pos are set to -1 and %TRUE is returned. | |
| 127 | + | func (x *MatchInfo) FetchNamedPos(NameVar string, StartPosVar int, EndPosVar int) bool { | |
| 128 | + | ||
| 129 | + | cret := xMatchInfoFetchNamedPos(x.GoPointer(), NameVar, StartPosVar, EndPosVar) | |
| 130 | + | return cret | |
| 131 | + | } | |
| 132 | + | ||
| 133 | + | var xMatchInfoFetchPos func(uintptr, int, int, int) bool | |
| 134 | + | ||
| 135 | + | // Retrieves the position in bytes of the @match_num'th capturing | |
| 136 | + | // parentheses. 0 is the full text of the match, 1 is the first | |
| 137 | + | // paren set, 2 the second, and so on. | |
| 138 | + | // | |
| 139 | + | // If @match_num is a valid sub pattern but it didn't match anything | |
| 140 | + | // (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos | |
| 141 | + | // and @end_pos are set to -1 and %TRUE is returned. | |
| 142 | + | // | |
| 143 | + | // If the match was obtained using the DFA algorithm, that is using | |
| 144 | + | // g_regex_match_all() or g_regex_match_all_full(), the retrieved | |
| 145 | + | // position is not that of a set of parentheses but that of a matched | |
| 146 | + | // substring. Substrings are matched in reverse order of length, so | |
| 147 | + | // 0 is the longest match. | |
| 148 | + | func (x *MatchInfo) FetchPos(MatchNumVar int, StartPosVar int, EndPosVar int) bool { | |
| 149 | + | ||
| 150 | + | cret := xMatchInfoFetchPos(x.GoPointer(), MatchNumVar, StartPosVar, EndPosVar) | |
| 151 | + | return cret | |
| 152 | + | } | |
| 153 | + | ||
| 154 | + | var xMatchInfoFree func(uintptr) | |
| 155 | + | ||
| 156 | + | // If @match_info is not %NULL, calls g_match_info_unref(); otherwise does | |
| 157 | + | // nothing. | |
| 158 | + | func (x *MatchInfo) Free() { | |
| 159 | + | ||
| 160 | + | xMatchInfoFree(x.GoPointer()) | |
| 161 | + | ||
| 162 | + | } | |
| 163 | + | ||
| 164 | + | var xMatchInfoGetMatchCount func(uintptr) int | |
| 165 | + | ||
| 166 | + | // Retrieves the number of matched substrings (including substring 0, | |
| 167 | + | // that is the whole matched text), so 1 is returned if the pattern | |
| 168 | + | // has no substrings in it and 0 is returned if the match failed. | |
| 169 | + | // | |
| 170 | + | // If the last match was obtained using the DFA algorithm, that is | |
| 171 | + | // using g_regex_match_all() or g_regex_match_all_full(), the retrieved | |
| 172 | + | // count is not that of the number of capturing parentheses but that of | |
| 173 | + | // the number of matched substrings. | |
| 174 | + | func (x *MatchInfo) GetMatchCount() int { | |
| 175 | + | ||
| 176 | + | cret := xMatchInfoGetMatchCount(x.GoPointer()) | |
| 177 | + | return cret | |
| 178 | + | } | |
| 179 | + | ||
| 180 | + | var xMatchInfoGetRegex func(uintptr) *Regex | |
| 181 | + | ||
| 182 | + | // Returns #GRegex object used in @match_info. It belongs to Glib | |
| 183 | + | // and must not be freed. Use g_regex_ref() if you need to keep it | |
| 184 | + | // after you free @match_info object. | |
| 185 | + | func (x *MatchInfo) GetRegex() *Regex { | |
| 186 | + | ||
| 187 | + | cret := xMatchInfoGetRegex(x.GoPointer()) | |
| 188 | + | return cret | |
| 189 | + | } | |
| 190 | + | ||
| 191 | + | var xMatchInfoGetString func(uintptr) string | |
| 192 | + | ||
| 193 | + | // Returns the string searched with @match_info. This is the | |
| 194 | + | // string passed to g_regex_match() or g_regex_replace() so | |
| 195 | + | // you may not free it before calling this function. | |
| 196 | + | func (x *MatchInfo) GetString() string { | |
| 197 | + | ||
| 198 | + | cret := xMatchInfoGetString(x.GoPointer()) | |
| 199 | + | return cret | |
| 200 | + | } | |
| 201 | + | ||
| 202 | + | var xMatchInfoIsPartialMatch func(uintptr) bool | |
| 203 | + | ||
| 204 | + | // Usually if the string passed to g_regex_match*() matches as far as | |
| 205 | + | // it goes, but is too short to match the entire pattern, %FALSE is | |
| 206 | + | // returned. There are circumstances where it might be helpful to | |
| 207 | + | // distinguish this case from other cases in which there is no match. | |
| 208 | + | // | |
| 209 | + | // Consider, for example, an application where a human is required to | |
| 210 | + | // type in data for a field with specific formatting requirements. An | |
| 211 | + | // example might be a date in the form ddmmmyy, defined by the pattern | |
| 212 | + | // "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$". | |
| 213 | + | // If the application sees the user’s keystrokes one by one, and can | |
| 214 | + | // check that what has been typed so far is potentially valid, it is | |
| 215 | + | // able to raise an error as soon as a mistake is made. | |
| 216 | + | // | |
| 217 | + | // GRegex supports the concept of partial matching by means of the | |
| 218 | + | // %G_REGEX_MATCH_PARTIAL_SOFT and %G_REGEX_MATCH_PARTIAL_HARD flags. | |
| 219 | + | // When they are used, the return code for | |
| 220 | + | // g_regex_match() or g_regex_match_full() is, as usual, %TRUE | |
| 221 | + | // for a complete match, %FALSE otherwise. But, when these functions | |
| 222 | + | // return %FALSE, you can check if the match was partial calling | |
| 223 | + | // g_match_info_is_partial_match(). | |
| 224 | + | // | |
| 225 | + | // The difference between %G_REGEX_MATCH_PARTIAL_SOFT and | |
| 226 | + | // %G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered | |
| 227 | + | // with %G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a | |
| 228 | + | // possible complete match, while with %G_REGEX_MATCH_PARTIAL_HARD matching | |
| 229 | + | // stops at the partial match. | |
| 230 | + | // When both %G_REGEX_MATCH_PARTIAL_SOFT and %G_REGEX_MATCH_PARTIAL_HARD | |
| 231 | + | // are set, the latter takes precedence. | |
| 232 | + | // | |
| 233 | + | // There were formerly some restrictions on the pattern for partial matching. | |
| 234 | + | // The restrictions no longer apply. | |
| 235 | + | // | |
| 236 | + | // See pcrepartial(3) for more information on partial matching. | |
| 237 | + | func (x *MatchInfo) IsPartialMatch() bool { | |
| 238 | + | ||
| 239 | + | cret := xMatchInfoIsPartialMatch(x.GoPointer()) | |
| 240 | + | return cret | |
| 241 | + | } | |
| 242 | + | ||
| 243 | + | var xMatchInfoMatches func(uintptr) bool | |
| 244 | + | ||
| 245 | + | // Returns whether the previous match operation succeeded. | |
| 246 | + | func (x *MatchInfo) Matches() bool { | |
| 247 | + | ||
| 248 | + | cret := xMatchInfoMatches(x.GoPointer()) | |
| 249 | + | return cret | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | var xMatchInfoNext func(uintptr) bool | |
| 253 | + | ||
| 254 | + | // Scans for the next match using the same parameters of the previous | |
| 255 | + | // call to g_regex_match_full() or g_regex_match() that returned | |
| 256 | + | // @match_info. | |
| 257 | + | // | |
| 258 | + | // The match is done on the string passed to the match function, so you | |
| 259 | + | // cannot free it before calling this function. | |
| 260 | + | func (x *MatchInfo) Next() (bool, error) { | |
| 261 | + | var cerr *Error | |
| 262 | + | ||
| 263 | + | cret := xMatchInfoNext(x.GoPointer()) | |
| 264 | + | if cerr == nil { | |
| 265 | + | return cret, nil | |
| 266 | + | } | |
| 267 | + | return cret, cerr | |
| 268 | + | ||
| 269 | + | } | |
| 270 | + | ||
| 271 | + | var xMatchInfoRef func(uintptr) *MatchInfo | |
| 272 | + | ||
| 273 | + | // Increases reference count of @match_info by 1. | |
| 274 | + | func (x *MatchInfo) Ref() *MatchInfo { | |
| 275 | + | ||
| 276 | + | cret := xMatchInfoRef(x.GoPointer()) | |
| 277 | + | return cret | |
| 278 | + | } | |
| 279 | + | ||
| 280 | + | var xMatchInfoUnref func(uintptr) | |
| 281 | + | ||
| 282 | + | // Decreases reference count of @match_info by 1. When reference count drops | |
| 283 | + | // to zero, it frees all the memory associated with the match_info structure. | |
| 284 | + | func (x *MatchInfo) Unref() { | |
| 285 | + | ||
| 286 | + | xMatchInfoUnref(x.GoPointer()) | |
| 287 | + | ||
| 288 | + | } | |
| 289 | + | ||
| 20 | 290 | // The g_regex_*() functions implement regular | |
| 21 | 291 | // expression pattern matching using syntax and semantics similar to | |
| 22 | 292 | // Perl regular expression. | |
| @@ -85,6 +355,493 @@ type MatchInfo struct { | |||
| 85 | 355 | type Regex struct { | |
| 86 | 356 | } | |
| 87 | 357 | ||
| 358 | + | func (x *Regex) GoPointer() uintptr { | |
| 359 | + | return uintptr(unsafe.Pointer(x)) | |
| 360 | + | } | |
| 361 | + | ||
| 362 | + | var xNewRegex func(string, RegexCompileFlags, RegexMatchFlags, **Error) *Regex | |
| 363 | + | ||
| 364 | + | // Compiles the regular expression to an internal form, and does | |
| 365 | + | // the initial setup of the #GRegex structure. | |
| 366 | + | func NewRegex(PatternVar string, CompileOptionsVar RegexCompileFlags, MatchOptionsVar RegexMatchFlags) (*Regex, error) { | |
| 367 | + | var cerr *Error | |
| 368 | + | ||
| 369 | + | cret := xNewRegex(PatternVar, CompileOptionsVar, MatchOptionsVar, &cerr) | |
| 370 | + | if cerr == nil { | |
| 371 | + | return cret, nil | |
| 372 | + | } | |
| 373 | + | return cret, cerr | |
| 374 | + | ||
| 375 | + | } | |
| 376 | + | ||
| 377 | + | var xRegexGetCaptureCount func(uintptr) int | |
| 378 | + | ||
| 379 | + | // Returns the number of capturing subpatterns in the pattern. | |
| 380 | + | func (x *Regex) GetCaptureCount() int { | |
| 381 | + | ||
| 382 | + | cret := xRegexGetCaptureCount(x.GoPointer()) | |
| 383 | + | return cret | |
| 384 | + | } | |
| 385 | + | ||
| 386 | + | var xRegexGetCompileFlags func(uintptr) RegexCompileFlags | |
| 387 | + | ||
| 388 | + | // Returns the compile options that @regex was created with. | |
| 389 | + | // | |
| 390 | + | // Depending on the version of PCRE that is used, this may or may not | |
| 391 | + | // include flags set by option expressions such as `(?i)` found at the | |
| 392 | + | // top-level within the compiled pattern. | |
| 393 | + | func (x *Regex) GetCompileFlags() RegexCompileFlags { | |
| 394 | + | ||
| 395 | + | cret := xRegexGetCompileFlags(x.GoPointer()) | |
| 396 | + | return cret | |
| 397 | + | } | |
| 398 | + | ||
| 399 | + | var xRegexGetHasCrOrLf func(uintptr) bool | |
| 400 | + | ||
| 401 | + | // Checks whether the pattern contains explicit CR or LF references. | |
| 402 | + | func (x *Regex) GetHasCrOrLf() bool { | |
| 403 | + | ||
| 404 | + | cret := xRegexGetHasCrOrLf(x.GoPointer()) | |
| 405 | + | return cret | |
| 406 | + | } | |
| 407 | + | ||
| 408 | + | var xRegexGetMatchFlags func(uintptr) RegexMatchFlags | |
| 409 | + | ||
| 410 | + | // Returns the match options that @regex was created with. | |
| 411 | + | func (x *Regex) GetMatchFlags() RegexMatchFlags { | |
| 412 | + | ||
| 413 | + | cret := xRegexGetMatchFlags(x.GoPointer()) | |
| 414 | + | return cret | |
| 415 | + | } | |
| 416 | + | ||
| 417 | + | var xRegexGetMaxBackref func(uintptr) int | |
| 418 | + | ||
| 419 | + | // Returns the number of the highest back reference | |
| 420 | + | // in the pattern, or 0 if the pattern does not contain | |
| 421 | + | // back references. | |
| 422 | + | func (x *Regex) GetMaxBackref() int { | |
| 423 | + | ||
| 424 | + | cret := xRegexGetMaxBackref(x.GoPointer()) | |
| 425 | + | return cret | |
| 426 | + | } | |
| 427 | + | ||
| 428 | + | var xRegexGetMaxLookbehind func(uintptr) int | |
| 429 | + | ||
| 430 | + | // Gets the number of characters in the longest lookbehind assertion in the | |
| 431 | + | // pattern. This information is useful when doing multi-segment matching using | |
| 432 | + | // the partial matching facilities. | |
| 433 | + | func (x *Regex) GetMaxLookbehind() int { | |
| 434 | + | ||
| 435 | + | cret := xRegexGetMaxLookbehind(x.GoPointer()) | |
| 436 | + | return cret | |
| 437 | + | } | |
| 438 | + | ||
| 439 | + | var xRegexGetPattern func(uintptr) string | |
| 440 | + | ||
| 441 | + | // Gets the pattern string associated with @regex, i.e. a copy of | |
| 442 | + | // the string passed to g_regex_new(). | |
| 443 | + | func (x *Regex) GetPattern() string { | |
| 444 | + | ||
| 445 | + | cret := xRegexGetPattern(x.GoPointer()) | |
| 446 | + | return cret | |
| 447 | + | } | |
| 448 | + | ||
| 449 | + | var xRegexGetStringNumber func(uintptr, string) int | |
| 450 | + | ||
| 451 | + | // Retrieves the number of the subexpression named @name. | |
| 452 | + | func (x *Regex) GetStringNumber(NameVar string) int { | |
| 453 | + | ||
| 454 | + | cret := xRegexGetStringNumber(x.GoPointer(), NameVar) | |
| 455 | + | return cret | |
| 456 | + | } | |
| 457 | + | ||
| 458 | + | var xRegexMatch func(uintptr, string, RegexMatchFlags, **MatchInfo) bool | |
| 459 | + | ||
| 460 | + | // Scans for a match in @string for the pattern in @regex. | |
| 461 | + | // The @match_options are combined with the match options specified | |
| 462 | + | // when the @regex structure was created, letting you have more | |
| 463 | + | // flexibility in reusing #GRegex structures. | |
| 464 | + | // | |
| 465 | + | // Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8. | |
| 466 | + | // | |
| 467 | + | // A #GMatchInfo structure, used to get information on the match, | |
| 468 | + | // is stored in @match_info if not %NULL. Note that if @match_info | |
| 469 | + | // is not %NULL then it is created even if the function returns %FALSE, | |
| 470 | + | // i.e. you must free it regardless if regular expression actually matched. | |
| 471 | + | // | |
| 472 | + | // To retrieve all the non-overlapping matches of the pattern in | |
| 473 | + | // string you can use g_match_info_next(). | |
| 474 | + | // | |
| 475 | + | // |[<!-- language="C" --> | |
| 476 | + | // static void | |
| 477 | + | // print_uppercase_words (const gchar *string) | |
| 478 | + | // | |
| 479 | + | // { | |
| 480 | + | // // Print all uppercase-only words. | |
| 481 | + | // GRegex *regex; | |
| 482 | + | // GMatchInfo *match_info; | |
| 483 | + | // | |
| 484 | + | // regex = g_regex_new ("[A-Z]+", 0, 0, NULL); | |
| 485 | + | // g_regex_match (regex, string, 0, &match_info); | |
| 486 | + | // while (g_match_info_matches (match_info)) | |
| 487 | + | // { | |
| 488 | + | // gchar *word = g_match_info_fetch (match_info, 0); | |
| 489 | + | // g_print ("Found: %s\n", word); | |
| 490 | + | // g_free (word); | |
| 491 | + | // g_match_info_next (match_info, NULL); | |
| 492 | + | // } | |
| 493 | + | // g_match_info_free (match_info); | |
| 494 | + | // g_regex_unref (regex); | |
| 495 | + | // } | |
| 496 | + | // | |
| 497 | + | // ]| | |
| 498 | + | // | |
| 499 | + | // @string is not copied and is used in #GMatchInfo internally. If | |
| 500 | + | // you use any #GMatchInfo method (except g_match_info_free()) after | |
| 501 | + | // freeing or modifying @string then the behaviour is undefined. | |
| 502 | + | func (x *Regex) Match(StringVar string, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) bool { | |
| 503 | + | ||
| 504 | + | cret := xRegexMatch(x.GoPointer(), StringVar, MatchOptionsVar, MatchInfoVar) | |
| 505 | + | return cret | |
| 506 | + | } | |
| 507 | + | ||
| 508 | + | var xRegexMatchAll func(uintptr, string, RegexMatchFlags, **MatchInfo) bool | |
| 509 | + | ||
| 510 | + | // Using the standard algorithm for regular expression matching only | |
| 511 | + | // the longest match in the string is retrieved. This function uses | |
| 512 | + | // a different algorithm so it can retrieve all the possible matches. | |
| 513 | + | // For more documentation see g_regex_match_all_full(). | |
| 514 | + | // | |
| 515 | + | // A #GMatchInfo structure, used to get information on the match, is | |
| 516 | + | // stored in @match_info if not %NULL. Note that if @match_info is | |
| 517 | + | // not %NULL then it is created even if the function returns %FALSE, | |
| 518 | + | // i.e. you must free it regardless if regular expression actually | |
| 519 | + | // matched. | |
| 520 | + | // | |
| 521 | + | // @string is not copied and is used in #GMatchInfo internally. If | |
| 522 | + | // you use any #GMatchInfo method (except g_match_info_free()) after | |
| 523 | + | // freeing or modifying @string then the behaviour is undefined. | |
| 524 | + | func (x *Regex) MatchAll(StringVar string, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) bool { | |
| 525 | + | ||
| 526 | + | cret := xRegexMatchAll(x.GoPointer(), StringVar, MatchOptionsVar, MatchInfoVar) | |
| 527 | + | return cret | |
| 528 | + | } | |
| 529 | + | ||
| 530 | + | var xRegexMatchAllFull func(uintptr, uintptr, int, int, RegexMatchFlags, **MatchInfo, **Error) bool | |
| 531 | + | ||
| 532 | + | // Using the standard algorithm for regular expression matching only | |
| 533 | + | // the longest match in the @string is retrieved, it is not possible | |
| 534 | + | // to obtain all the available matches. For instance matching | |
| 535 | + | // "<a> <b> <c>" against the pattern "<.*>" | |
| 536 | + | // you get "<a> <b> <c>". | |
| 537 | + | // | |
| 538 | + | // This function uses a different algorithm (called DFA, i.e. deterministic | |
| 539 | + | // finite automaton), so it can retrieve all the possible matches, all | |
| 540 | + | // starting at the same point in the string. For instance matching | |
| 541 | + | // "<a> <b> <c>" against the pattern "<.*>;" | |
| 542 | + | // you would obtain three matches: "<a> <b> <c>", | |
| 543 | + | // "<a> <b>" and "<a>". | |
| 544 | + | // | |
| 545 | + | // The number of matched strings is retrieved using | |
| 546 | + | // g_match_info_get_match_count(). To obtain the matched strings and | |
| 547 | + | // their position you can use, respectively, g_match_info_fetch() and | |
| 548 | + | // g_match_info_fetch_pos(). Note that the strings are returned in | |
| 549 | + | // reverse order of length; that is, the longest matching string is | |
| 550 | + | // given first. | |
| 551 | + | // | |
| 552 | + | // Note that the DFA algorithm is slower than the standard one and it | |
| 553 | + | // is not able to capture substrings, so backreferences do not work. | |
| 554 | + | // | |
| 555 | + | // Setting @start_position differs from just passing over a shortened | |
| 556 | + | // string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern | |
| 557 | + | // that begins with any kind of lookbehind assertion, such as "\b". | |
| 558 | + | // | |
| 559 | + | // Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8. | |
| 560 | + | // | |
| 561 | + | // A #GMatchInfo structure, used to get information on the match, is | |
| 562 | + | // stored in @match_info if not %NULL. Note that if @match_info is | |
| 563 | + | // not %NULL then it is created even if the function returns %FALSE, | |
| 564 | + | // i.e. you must free it regardless if regular expression actually | |
| 565 | + | // matched. | |
| 566 | + | // | |
| 567 | + | // @string is not copied and is used in #GMatchInfo internally. If | |
| 568 | + | // you use any #GMatchInfo method (except g_match_info_free()) after | |
| 569 | + | // freeing or modifying @string then the behaviour is undefined. | |
| 570 | + | func (x *Regex) MatchAllFull(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) (bool, error) { | |
| 571 | + | var cerr *Error | |
| 572 | + | ||
| 573 | + | cret := xRegexMatchAllFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MatchInfoVar, &cerr) | |
| 574 | + | if cerr == nil { | |
| 575 | + | return cret, nil | |
| 576 | + | } | |
| 577 | + | return cret, cerr | |
| 578 | + | ||
| 579 | + | } | |
| 580 | + | ||
| 581 | + | var xRegexMatchFull func(uintptr, uintptr, int, int, RegexMatchFlags, **MatchInfo, **Error) bool | |
| 582 | + | ||
| 583 | + | // Scans for a match in @string for the pattern in @regex. | |
| 584 | + | // The @match_options are combined with the match options specified | |
| 585 | + | // when the @regex structure was created, letting you have more | |
| 586 | + | // flexibility in reusing #GRegex structures. | |
| 587 | + | // | |
| 588 | + | // Setting @start_position differs from just passing over a shortened | |
| 589 | + | // string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern | |
| 590 | + | // that begins with any kind of lookbehind assertion, such as "\b". | |
| 591 | + | // | |
| 592 | + | // Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8. | |
| 593 | + | // | |
| 594 | + | // A #GMatchInfo structure, used to get information on the match, is | |
| 595 | + | // stored in @match_info if not %NULL. Note that if @match_info is | |
| 596 | + | // not %NULL then it is created even if the function returns %FALSE, | |
| 597 | + | // i.e. you must free it regardless if regular expression actually | |
| 598 | + | // matched. | |
| 599 | + | // | |
| 600 | + | // @string is not copied and is used in #GMatchInfo internally. If | |
| 601 | + | // you use any #GMatchInfo method (except g_match_info_free()) after | |
| 602 | + | // freeing or modifying @string then the behaviour is undefined. | |
| 603 | + | // | |
| 604 | + | // To retrieve all the non-overlapping matches of the pattern in | |
| 605 | + | // string you can use g_match_info_next(). | |
| 606 | + | // | |
| 607 | + | // |[<!-- language="C" --> | |
| 608 | + | // static void | |
| 609 | + | // print_uppercase_words (const gchar *string) | |
| 610 | + | // | |
| 611 | + | // { | |
| 612 | + | // // Print all uppercase-only words. | |
| 613 | + | // GRegex *regex; | |
| 614 | + | // GMatchInfo *match_info; | |
| 615 | + | // GError *error = NULL; | |
| 616 | + | // | |
| 617 | + | // regex = g_regex_new ("[A-Z]+", 0, 0, NULL); | |
| 618 | + | // g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error); | |
| 619 | + | // while (g_match_info_matches (match_info)) | |
| 620 | + | // { | |
| 621 | + | // gchar *word = g_match_info_fetch (match_info, 0); | |
| 622 | + | // g_print ("Found: %s\n", word); | |
| 623 | + | // g_free (word); | |
| 624 | + | // g_match_info_next (match_info, &error); | |
| 625 | + | // } | |
| 626 | + | // g_match_info_free (match_info); | |
| 627 | + | // g_regex_unref (regex); | |
| 628 | + | // if (error != NULL) | |
| 629 | + | // { | |
| 630 | + | // g_printerr ("Error while matching: %s\n", error->message); | |
| 631 | + | // g_error_free (error); | |
| 632 | + | // } | |
| 633 | + | // } | |
| 634 | + | // | |
| 635 | + | // ]| | |
| 636 | + | func (x *Regex) MatchFull(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) (bool, error) { | |
| 637 | + | var cerr *Error | |
| 638 | + | ||
| 639 | + | cret := xRegexMatchFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MatchInfoVar, &cerr) | |
| 640 | + | if cerr == nil { | |
| 641 | + | return cret, nil | |
| 642 | + | } | |
| 643 | + | return cret, cerr | |
| 644 | + | ||
| 645 | + | } | |
| 646 | + | ||
| 647 | + | var xRegexRef func(uintptr) *Regex | |
| 648 | + | ||
| 649 | + | // Increases reference count of @regex by 1. | |
| 650 | + | func (x *Regex) Ref() *Regex { | |
| 651 | + | ||
| 652 | + | cret := xRegexRef(x.GoPointer()) | |
| 653 | + | return cret | |
| 654 | + | } | |
| 655 | + | ||
| 656 | + | var xRegexReplace func(uintptr, uintptr, int, int, string, RegexMatchFlags, **Error) string | |
| 657 | + | ||
| 658 | + | // Replaces all occurrences of the pattern in @regex with the | |
| 659 | + | // replacement text. Backreferences of the form '\number' or | |
| 660 | + | // '\g<number>' in the replacement text are interpolated by the | |
| 661 | + | // number-th captured subexpression of the match, '\g<name>' refers | |
| 662 | + | // to the captured subexpression with the given name. '\0' refers | |
| 663 | + | // to the complete match, but '\0' followed by a number is the octal | |
| 664 | + | // representation of a character. To include a literal '\' in the | |
| 665 | + | // replacement, write '\\\\'. | |
| 666 | + | // | |
| 667 | + | // There are also escapes that changes the case of the following text: | |
| 668 | + | // | |
| 669 | + | // - \l: Convert to lower case the next character | |
| 670 | + | // - \u: Convert to upper case the next character | |
| 671 | + | // - \L: Convert to lower case till \E | |
| 672 | + | // - \U: Convert to upper case till \E | |
| 673 | + | // - \E: End case modification | |
| 674 | + | // | |
| 675 | + | // If you do not need to use backreferences use g_regex_replace_literal(). | |
| 676 | + | // | |
| 677 | + | // The @replacement string must be UTF-8 encoded even if %G_REGEX_RAW was | |
| 678 | + | // passed to g_regex_new(). If you want to use not UTF-8 encoded strings | |
| 679 | + | // you can use g_regex_replace_literal(). | |
| 680 | + | // | |
| 681 | + | // Setting @start_position differs from just passing over a shortened | |
| 682 | + | // string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern that | |
| 683 | + | // begins with any kind of lookbehind assertion, such as "\b". | |
| 684 | + | func (x *Regex) Replace(StringVar uintptr, StringLenVar int, StartPositionVar int, ReplacementVar string, MatchOptionsVar RegexMatchFlags) (string, error) { | |
| 685 | + | var cerr *Error | |
| 686 | + | ||
| 687 | + | cret := xRegexReplace(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, ReplacementVar, MatchOptionsVar, &cerr) | |
| 688 | + | if cerr == nil { | |
| 689 | + | return cret, nil | |
| 690 | + | } | |
| 691 | + | return cret, cerr | |
| 692 | + | ||
| 693 | + | } | |
| 694 | + | ||
| 695 | + | var xRegexReplaceEval func(uintptr, uintptr, int, int, RegexMatchFlags, uintptr, uintptr, **Error) string | |
| 696 | + | ||
| 697 | + | // Replaces occurrences of the pattern in regex with the output of | |
| 698 | + | // @eval for that occurrence. | |
| 699 | + | // | |
| 700 | + | // Setting @start_position differs from just passing over a shortened | |
| 701 | + | // string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern | |
| 702 | + | // that begins with any kind of lookbehind assertion, such as "\b". | |
| 703 | + | // | |
| 704 | + | // The following example uses g_regex_replace_eval() to replace multiple | |
| 705 | + | // strings at once: | |
| 706 | + | // |[<!-- language="C" --> | |
| 707 | + | // static gboolean | |
| 708 | + | // eval_cb (const GMatchInfo *info, | |
| 709 | + | // | |
| 710 | + | // GString *res, | |
| 711 | + | // gpointer data) | |
| 712 | + | // | |
| 713 | + | // { | |
| 714 | + | // gchar *match; | |
| 715 | + | // gchar *r; | |
| 716 | + | // | |
| 717 | + | // match = g_match_info_fetch (info, 0); | |
| 718 | + | // r = g_hash_table_lookup ((GHashTable *)data, match); | |
| 719 | + | // g_string_append (res, r); | |
| 720 | + | // g_free (match); | |
| 721 | + | // | |
| 722 | + | // return FALSE; | |
| 723 | + | // } | |
| 724 | + | // | |
| 725 | + | // ... | |
| 726 | + | // | |
| 727 | + | // GRegex *reg; | |
| 728 | + | // GHashTable *h; | |
| 729 | + | // gchar *res; | |
| 730 | + | // | |
| 731 | + | // h = g_hash_table_new (g_str_hash, g_str_equal); | |
| 732 | + | // | |
| 733 | + | // g_hash_table_insert (h, "1", "ONE"); | |
| 734 | + | // g_hash_table_insert (h, "2", "TWO"); | |
| 735 | + | // g_hash_table_insert (h, "3", "THREE"); | |
| 736 | + | // g_hash_table_insert (h, "4", "FOUR"); | |
| 737 | + | // | |
| 738 | + | // reg = g_regex_new ("1|2|3|4", 0, 0, NULL); | |
| 739 | + | // res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL); | |
| 740 | + | // g_hash_table_destroy (h); | |
| 741 | + | // | |
| 742 | + | // ... | |
| 743 | + | // ]| | |
| 744 | + | func (x *Regex) ReplaceEval(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, EvalVar RegexEvalCallback, UserDataVar uintptr) (string, error) { | |
| 745 | + | var cerr *Error | |
| 746 | + | ||
| 747 | + | cret := xRegexReplaceEval(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, purego.NewCallback(EvalVar), UserDataVar, &cerr) | |
| 748 | + | if cerr == nil { | |
| 749 | + | return cret, nil | |
| 750 | + | } | |
| 751 | + | return cret, cerr | |
| 752 | + | ||
| 753 | + | } | |
| 754 | + | ||
| 755 | + | var xRegexReplaceLiteral func(uintptr, uintptr, int, int, string, RegexMatchFlags, **Error) string | |
| 756 | + | ||
| 757 | + | // Replaces all occurrences of the pattern in @regex with the | |
| 758 | + | // replacement text. @replacement is replaced literally, to | |
| 759 | + | // include backreferences use g_regex_replace(). | |
| 760 | + | // | |
| 761 | + | // Setting @start_position differs from just passing over a | |
| 762 | + | // shortened string and setting %G_REGEX_MATCH_NOTBOL in the | |
| 763 | + | // case of a pattern that begins with any kind of lookbehind | |
| 764 | + | // assertion, such as "\b". | |
| 765 | + | func (x *Regex) ReplaceLiteral(StringVar uintptr, StringLenVar int, StartPositionVar int, ReplacementVar string, MatchOptionsVar RegexMatchFlags) (string, error) { | |
| 766 | + | var cerr *Error | |
| 767 | + | ||
| 768 | + | cret := xRegexReplaceLiteral(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, ReplacementVar, MatchOptionsVar, &cerr) | |
| 769 | + | if cerr == nil { | |
| 770 | + | return cret, nil | |
| 771 | + | } | |
| 772 | + | return cret, cerr | |
| 773 | + | ||
| 774 | + | } | |
| 775 | + | ||
| 776 | + | var xRegexSplit func(uintptr, string, RegexMatchFlags) uintptr | |
| 777 | + | ||
| 778 | + | // Breaks the string on the pattern, and returns an array of the tokens. | |
| 779 | + | // If the pattern contains capturing parentheses, then the text for each | |
| 780 | + | // of the substrings will also be returned. If the pattern does not match | |
| 781 | + | // anywhere in the string, then the whole string is returned as the first | |
| 782 | + | // token. | |
| 783 | + | // | |
| 784 | + | // As a special case, the result of splitting the empty string "" is an | |
| 785 | + | // empty vector, not a vector containing a single string. The reason for | |
| 786 | + | // this special case is that being able to represent an empty vector is | |
| 787 | + | // typically more useful than consistent handling of empty elements. If | |
| 788 | + | // you do need to represent empty elements, you'll need to check for the | |
| 789 | + | // empty string before calling this function. | |
| 790 | + | // | |
| 791 | + | // A pattern that can match empty strings splits @string into separate | |
| 792 | + | // characters wherever it matches the empty string between characters. | |
| 793 | + | // For example splitting "ab c" using as a separator "\s*", you will get | |
| 794 | + | // "a", "b" and "c". | |
| 795 | + | func (x *Regex) Split(StringVar string, MatchOptionsVar RegexMatchFlags) uintptr { | |
| 796 | + | ||
| 797 | + | cret := xRegexSplit(x.GoPointer(), StringVar, MatchOptionsVar) | |
| 798 | + | return cret | |
| 799 | + | } | |
| 800 | + | ||
| 801 | + | var xRegexSplitFull func(uintptr, uintptr, int, int, RegexMatchFlags, int, **Error) uintptr | |
| 802 | + | ||
| 803 | + | // Breaks the string on the pattern, and returns an array of the tokens. | |
| 804 | + | // If the pattern contains capturing parentheses, then the text for each | |
| 805 | + | // of the substrings will also be returned. If the pattern does not match | |
| 806 | + | // anywhere in the string, then the whole string is returned as the first | |
| 807 | + | // token. | |
| 808 | + | // | |
| 809 | + | // As a special case, the result of splitting the empty string "" is an | |
| 810 | + | // empty vector, not a vector containing a single string. The reason for | |
| 811 | + | // this special case is that being able to represent an empty vector is | |
| 812 | + | // typically more useful than consistent handling of empty elements. If | |
| 813 | + | // you do need to represent empty elements, you'll need to check for the | |
| 814 | + | // empty string before calling this function. | |
| 815 | + | // | |
| 816 | + | // A pattern that can match empty strings splits @string into separate | |
| 817 | + | // characters wherever it matches the empty string between characters. | |
| 818 | + | // For example splitting "ab c" using as a separator "\s*", you will get | |
| 819 | + | // "a", "b" and "c". | |
| 820 | + | // | |
| 821 | + | // Setting @start_position differs from just passing over a shortened | |
| 822 | + | // string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern | |
| 823 | + | // that begins with any kind of lookbehind assertion, such as "\b". | |
| 824 | + | func (x *Regex) SplitFull(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MaxTokensVar int) (uintptr, error) { | |
| 825 | + | var cerr *Error | |
| 826 | + | ||
| 827 | + | cret := xRegexSplitFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MaxTokensVar, &cerr) | |
| 828 | + | if cerr == nil { | |
| 829 | + | return cret, nil | |
| 830 | + | } | |
| 831 | + | return cret, cerr | |
| 832 | + | ||
| 833 | + | } | |
| 834 | + | ||
| 835 | + | var xRegexUnref func(uintptr) | |
| 836 | + | ||
| 837 | + | // Decreases reference count of @regex by 1. When reference count drops | |
| 838 | + | // to zero, it frees all the memory associated with the regex structure. | |
| 839 | + | func (x *Regex) Unref() { | |
| 840 | + | ||
| 841 | + | xRegexUnref(x.GoPointer()) | |
| 842 | + | ||
| 843 | + | } | |
| 844 | + | ||
| 88 | 845 | // Flags specifying compile-time options. | |
| 89 | 846 | type RegexCompileFlags int | |
| 90 | 847 | ||
| @@ -538,4 +1295,42 @@ func init() { | |||
| 538 | 1295 | core.PuregoSafeRegister(&xRegexMatchSimple, lib, "g_regex_match_simple") | |
| 539 | 1296 | core.PuregoSafeRegister(&xRegexSplitSimple, lib, "g_regex_split_simple") | |
| 540 | 1297 | ||
| 1298 | + | core.PuregoSafeRegister(&xMatchInfoExpandReferences, lib, "g_match_info_expand_references") | |
| 1299 | + | core.PuregoSafeRegister(&xMatchInfoFetch, lib, "g_match_info_fetch") | |
| 1300 | + | core.PuregoSafeRegister(&xMatchInfoFetchAll, lib, "g_match_info_fetch_all") | |
| 1301 | + | core.PuregoSafeRegister(&xMatchInfoFetchNamed, lib, "g_match_info_fetch_named") | |
| 1302 | + | core.PuregoSafeRegister(&xMatchInfoFetchNamedPos, lib, "g_match_info_fetch_named_pos") | |
| 1303 | + | core.PuregoSafeRegister(&xMatchInfoFetchPos, lib, "g_match_info_fetch_pos") | |
| 1304 | + | core.PuregoSafeRegister(&xMatchInfoFree, lib, "g_match_info_free") | |
| 1305 | + | core.PuregoSafeRegister(&xMatchInfoGetMatchCount, lib, "g_match_info_get_match_count") | |
| 1306 | + | core.PuregoSafeRegister(&xMatchInfoGetRegex, lib, "g_match_info_get_regex") | |
| 1307 | + | core.PuregoSafeRegister(&xMatchInfoGetString, lib, "g_match_info_get_string") | |
| 1308 | + | core.PuregoSafeRegister(&xMatchInfoIsPartialMatch, lib, "g_match_info_is_partial_match") | |
| 1309 | + | core.PuregoSafeRegister(&xMatchInfoMatches, lib, "g_match_info_matches") | |
| 1310 | + | core.PuregoSafeRegister(&xMatchInfoNext, lib, "g_match_info_next") | |
| 1311 | + | core.PuregoSafeRegister(&xMatchInfoRef, lib, "g_match_info_ref") | |
| 1312 | + | core.PuregoSafeRegister(&xMatchInfoUnref, lib, "g_match_info_unref") | |
| 1313 | + | ||
| 1314 | + | core.PuregoSafeRegister(&xNewRegex, lib, "g_regex_new") | |
| 1315 | + | ||
| 1316 | + | core.PuregoSafeRegister(&xRegexGetCaptureCount, lib, "g_regex_get_capture_count") | |
| 1317 | + | core.PuregoSafeRegister(&xRegexGetCompileFlags, lib, "g_regex_get_compile_flags") | |
| 1318 | + | core.PuregoSafeRegister(&xRegexGetHasCrOrLf, lib, "g_regex_get_has_cr_or_lf") | |
| 1319 | + | core.PuregoSafeRegister(&xRegexGetMatchFlags, lib, "g_regex_get_match_flags") | |
| 1320 | + | core.PuregoSafeRegister(&xRegexGetMaxBackref, lib, "g_regex_get_max_backref") | |
| 1321 | + | core.PuregoSafeRegister(&xRegexGetMaxLookbehind, lib, "g_regex_get_max_lookbehind") | |
| 1322 | + | core.PuregoSafeRegister(&xRegexGetPattern, lib, "g_regex_get_pattern") | |
| 1323 | + | core.PuregoSafeRegister(&xRegexGetStringNumber, lib, "g_regex_get_string_number") | |
| 1324 | + | core.PuregoSafeRegister(&xRegexMatch, lib, "g_regex_match") | |
| 1325 | + | core.PuregoSafeRegister(&xRegexMatchAll, lib, "g_regex_match_all") | |
| 1326 | + | core.PuregoSafeRegister(&xRegexMatchAllFull, lib, "g_regex_match_all_full") | |
| 1327 | + | core.PuregoSafeRegister(&xRegexMatchFull, lib, "g_regex_match_full") | |
| 1328 | + | core.PuregoSafeRegister(&xRegexRef, lib, "g_regex_ref") | |
| 1329 | + | core.PuregoSafeRegister(&xRegexReplace, lib, "g_regex_replace") | |
| 1330 | + | core.PuregoSafeRegister(&xRegexReplaceEval, lib, "g_regex_replace_eval") | |
| 1331 | + | core.PuregoSafeRegister(&xRegexReplaceLiteral, lib, "g_regex_replace_literal") | |
| 1332 | + | core.PuregoSafeRegister(&xRegexSplit, lib, "g_regex_split") | |
| 1333 | + | core.PuregoSafeRegister(&xRegexSplitFull, lib, "g_regex_split_full") | |
| 1334 | + | core.PuregoSafeRegister(&xRegexUnref, lib, "g_regex_unref") | |
| 1335 | + | ||
| 541 | 1336 | } | |
M v4/glib/gscanner.go +274 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Specifies the type of the message handler function. | |
| 5 | 12 | type ScannerMsgFunc func(*Scanner, string, bool) | |
| 6 | 13 | ||
| @@ -62,6 +69,225 @@ type Scanner struct { | |||
| 62 | 69 | MsgHandler ScannerMsgFunc | |
| 63 | 70 | } | |
| 64 | 71 | ||
| 72 | + | func (x *Scanner) GoPointer() uintptr { | |
| 73 | + | return uintptr(unsafe.Pointer(x)) | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | var xScannerCurLine func(uintptr) uint | |
| 77 | + | ||
| 78 | + | // Returns the current line in the input stream (counting | |
| 79 | + | // from 1). This is the line of the last token parsed via | |
| 80 | + | // g_scanner_get_next_token(). | |
| 81 | + | func (x *Scanner) CurLine() uint { | |
| 82 | + | ||
| 83 | + | cret := xScannerCurLine(x.GoPointer()) | |
| 84 | + | return cret | |
| 85 | + | } | |
| 86 | + | ||
| 87 | + | var xScannerCurPosition func(uintptr) uint | |
| 88 | + | ||
| 89 | + | // Returns the current position in the current line (counting | |
| 90 | + | // from 0). This is the position of the last token parsed via | |
| 91 | + | // g_scanner_get_next_token(). | |
| 92 | + | func (x *Scanner) CurPosition() uint { | |
| 93 | + | ||
| 94 | + | cret := xScannerCurPosition(x.GoPointer()) | |
| 95 | + | return cret | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | var xScannerCurToken func(uintptr) TokenType | |
| 99 | + | ||
| 100 | + | // Gets the current token type. This is simply the @token | |
| 101 | + | // field in the #GScanner structure. | |
| 102 | + | func (x *Scanner) CurToken() TokenType { | |
| 103 | + | ||
| 104 | + | cret := xScannerCurToken(x.GoPointer()) | |
| 105 | + | return cret | |
| 106 | + | } | |
| 107 | + | ||
| 108 | + | var xScannerCurValue func(uintptr) TokenValue | |
| 109 | + | ||
| 110 | + | // Gets the current token value. This is simply the @value | |
| 111 | + | // field in the #GScanner structure. | |
| 112 | + | func (x *Scanner) CurValue() TokenValue { | |
| 113 | + | ||
| 114 | + | cret := xScannerCurValue(x.GoPointer()) | |
| 115 | + | return cret | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xScannerDestroy func(uintptr) | |
| 119 | + | ||
| 120 | + | // Frees all memory used by the #GScanner. | |
| 121 | + | func (x *Scanner) Destroy() { | |
| 122 | + | ||
| 123 | + | xScannerDestroy(x.GoPointer()) | |
| 124 | + | ||
| 125 | + | } | |
| 126 | + | ||
| 127 | + | var xScannerEof func(uintptr) bool | |
| 128 | + | ||
| 129 | + | // Returns %TRUE if the scanner has reached the end of | |
| 130 | + | // the file or text buffer. | |
| 131 | + | func (x *Scanner) Eof() bool { | |
| 132 | + | ||
| 133 | + | cret := xScannerEof(x.GoPointer()) | |
| 134 | + | return cret | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | var xScannerError func(uintptr, string, ...interface{}) | |
| 138 | + | ||
| 139 | + | // Outputs an error message, via the #GScanner message handler. | |
| 140 | + | func (x *Scanner) Error(FormatVar string, varArgs ...interface{}) { | |
| 141 | + | ||
| 142 | + | xScannerError(x.GoPointer(), FormatVar, varArgs...) | |
| 143 | + | ||
| 144 | + | } | |
| 145 | + | ||
| 146 | + | var xScannerGetNextToken func(uintptr) TokenType | |
| 147 | + | ||
| 148 | + | // Parses the next token just like g_scanner_peek_next_token() | |
| 149 | + | // and also removes it from the input stream. The token data is | |
| 150 | + | // placed in the @token, @value, @line, and @position fields of | |
| 151 | + | // the #GScanner structure. | |
| 152 | + | func (x *Scanner) GetNextToken() TokenType { | |
| 153 | + | ||
| 154 | + | cret := xScannerGetNextToken(x.GoPointer()) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xScannerInputFile func(uintptr, int) | |
| 159 | + | ||
| 160 | + | // Prepares to scan a file. | |
| 161 | + | func (x *Scanner) InputFile(InputFdVar int) { | |
| 162 | + | ||
| 163 | + | xScannerInputFile(x.GoPointer(), InputFdVar) | |
| 164 | + | ||
| 165 | + | } | |
| 166 | + | ||
| 167 | + | var xScannerInputText func(uintptr, string, uint) | |
| 168 | + | ||
| 169 | + | // Prepares to scan a text buffer. | |
| 170 | + | func (x *Scanner) InputText(TextVar string, TextLenVar uint) { | |
| 171 | + | ||
| 172 | + | xScannerInputText(x.GoPointer(), TextVar, TextLenVar) | |
| 173 | + | ||
| 174 | + | } | |
| 175 | + | ||
| 176 | + | var xScannerLookupSymbol func(uintptr, string) uintptr | |
| 177 | + | ||
| 178 | + | // Looks up a symbol in the current scope and return its value. | |
| 179 | + | // If the symbol is not bound in the current scope, %NULL is | |
| 180 | + | // returned. | |
| 181 | + | func (x *Scanner) LookupSymbol(SymbolVar string) uintptr { | |
| 182 | + | ||
| 183 | + | cret := xScannerLookupSymbol(x.GoPointer(), SymbolVar) | |
| 184 | + | return cret | |
| 185 | + | } | |
| 186 | + | ||
| 187 | + | var xScannerPeekNextToken func(uintptr) TokenType | |
| 188 | + | ||
| 189 | + | // Parses the next token, without removing it from the input stream. | |
| 190 | + | // The token data is placed in the @next_token, @next_value, @next_line, | |
| 191 | + | // and @next_position fields of the #GScanner structure. | |
| 192 | + | // | |
| 193 | + | // Note that, while the token is not removed from the input stream | |
| 194 | + | // (i.e. the next call to g_scanner_get_next_token() will return the | |
| 195 | + | // same token), it will not be reevaluated. This can lead to surprising | |
| 196 | + | // results when changing scope or the scanner configuration after peeking | |
| 197 | + | // the next token. Getting the next token after switching the scope or | |
| 198 | + | // configuration will return whatever was peeked before, regardless of | |
| 199 | + | // any symbols that may have been added or removed in the new scope. | |
| 200 | + | func (x *Scanner) PeekNextToken() TokenType { | |
| 201 | + | ||
| 202 | + | cret := xScannerPeekNextToken(x.GoPointer()) | |
| 203 | + | return cret | |
| 204 | + | } | |
| 205 | + | ||
| 206 | + | var xScannerScopeAddSymbol func(uintptr, uint, string, uintptr) | |
| 207 | + | ||
| 208 | + | // Adds a symbol to the given scope. | |
| 209 | + | func (x *Scanner) ScopeAddSymbol(ScopeIdVar uint, SymbolVar string, ValueVar uintptr) { | |
| 210 | + | ||
| 211 | + | xScannerScopeAddSymbol(x.GoPointer(), ScopeIdVar, SymbolVar, ValueVar) | |
| 212 | + | ||
| 213 | + | } | |
| 214 | + | ||
| 215 | + | var xScannerScopeForeachSymbol func(uintptr, uint, uintptr, uintptr) | |
| 216 | + | ||
| 217 | + | // Calls the given function for each of the symbol/value pairs | |
| 218 | + | // in the given scope of the #GScanner. The function is passed | |
| 219 | + | // the symbol and value of each pair, and the given @user_data | |
| 220 | + | // parameter. | |
| 221 | + | func (x *Scanner) ScopeForeachSymbol(ScopeIdVar uint, FuncVar HFunc, UserDataVar uintptr) { | |
| 222 | + | ||
| 223 | + | xScannerScopeForeachSymbol(x.GoPointer(), ScopeIdVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 224 | + | ||
| 225 | + | } | |
| 226 | + | ||
| 227 | + | var xScannerScopeLookupSymbol func(uintptr, uint, string) uintptr | |
| 228 | + | ||
| 229 | + | // Looks up a symbol in a scope and return its value. If the | |
| 230 | + | // symbol is not bound in the scope, %NULL is returned. | |
| 231 | + | func (x *Scanner) ScopeLookupSymbol(ScopeIdVar uint, SymbolVar string) uintptr { | |
| 232 | + | ||
| 233 | + | cret := xScannerScopeLookupSymbol(x.GoPointer(), ScopeIdVar, SymbolVar) | |
| 234 | + | return cret | |
| 235 | + | } | |
| 236 | + | ||
| 237 | + | var xScannerScopeRemoveSymbol func(uintptr, uint, string) | |
| 238 | + | ||
| 239 | + | // Removes a symbol from a scope. | |
| 240 | + | func (x *Scanner) ScopeRemoveSymbol(ScopeIdVar uint, SymbolVar string) { | |
| 241 | + | ||
| 242 | + | xScannerScopeRemoveSymbol(x.GoPointer(), ScopeIdVar, SymbolVar) | |
| 243 | + | ||
| 244 | + | } | |
| 245 | + | ||
| 246 | + | var xScannerSetScope func(uintptr, uint) uint | |
| 247 | + | ||
| 248 | + | // Sets the current scope. | |
| 249 | + | func (x *Scanner) SetScope(ScopeIdVar uint) uint { | |
| 250 | + | ||
| 251 | + | cret := xScannerSetScope(x.GoPointer(), ScopeIdVar) | |
| 252 | + | return cret | |
| 253 | + | } | |
| 254 | + | ||
| 255 | + | var xScannerSyncFileOffset func(uintptr) | |
| 256 | + | ||
| 257 | + | // Rewinds the filedescriptor to the current buffer position | |
| 258 | + | // and blows the file read ahead buffer. This is useful for | |
| 259 | + | // third party uses of the scanners filedescriptor, which hooks | |
| 260 | + | // onto the current scanning position. | |
| 261 | + | func (x *Scanner) SyncFileOffset() { | |
| 262 | + | ||
| 263 | + | xScannerSyncFileOffset(x.GoPointer()) | |
| 264 | + | ||
| 265 | + | } | |
| 266 | + | ||
| 267 | + | var xScannerUnexpToken func(uintptr, TokenType, string, string, string, string, int) | |
| 268 | + | ||
| 269 | + | // Outputs a message through the scanner's msg_handler, | |
| 270 | + | // resulting from an unexpected token in the input stream. | |
| 271 | + | // Note that you should not call g_scanner_peek_next_token() | |
| 272 | + | // followed by g_scanner_unexp_token() without an intermediate | |
| 273 | + | // call to g_scanner_get_next_token(), as g_scanner_unexp_token() | |
| 274 | + | // evaluates the scanner's current token (not the peeked token) | |
| 275 | + | // to construct part of the message. | |
| 276 | + | func (x *Scanner) UnexpToken(ExpectedTokenVar TokenType, IdentifierSpecVar string, SymbolSpecVar string, SymbolNameVar string, MessageVar string, IsErrorVar int) { | |
| 277 | + | ||
| 278 | + | xScannerUnexpToken(x.GoPointer(), ExpectedTokenVar, IdentifierSpecVar, SymbolSpecVar, SymbolNameVar, MessageVar, IsErrorVar) | |
| 279 | + | ||
| 280 | + | } | |
| 281 | + | ||
| 282 | + | var xScannerWarn func(uintptr, string, ...interface{}) | |
| 283 | + | ||
| 284 | + | // Outputs a warning message, via the #GScanner message handler. | |
| 285 | + | func (x *Scanner) Warn(FormatVar string, varArgs ...interface{}) { | |
| 286 | + | ||
| 287 | + | xScannerWarn(x.GoPointer(), FormatVar, varArgs...) | |
| 288 | + | ||
| 289 | + | } | |
| 290 | + | ||
| 65 | 291 | // Specifies the #GScanner parser configuration. Most settings can | |
| 66 | 292 | // be changed during the parsing phase and will affect the lexical | |
| 67 | 293 | // parsing of the next unpeeked token. | |
| @@ -121,9 +347,28 @@ type ScannerConfig struct { | |||
| 121 | 347 | PaddingDummy uint | |
| 122 | 348 | } | |
| 123 | 349 | ||
| 350 | + | func (x *ScannerConfig) GoPointer() uintptr { | |
| 351 | + | return uintptr(unsafe.Pointer(x)) | |
| 352 | + | } | |
| 353 | + | ||
| 124 | 354 | // A union holding the value of the token. | |
| 125 | 355 | type TokenValue = uintptr | |
| 126 | 356 | ||
| 357 | + | const ( | |
| 358 | + | // The set of uppercase ASCII alphabet characters. | |
| 359 | + | // Used for specifying valid identifier characters | |
| 360 | + | // in #GScannerConfig. | |
| 361 | + | CSET_A_2_Z string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| 362 | + | // The set of ASCII digits. | |
| 363 | + | // Used for specifying valid identifier characters | |
| 364 | + | // in #GScannerConfig. | |
| 365 | + | CSET_DIGITS string = "0123456789" | |
| 366 | + | // The set of lowercase ASCII alphabet characters. | |
| 367 | + | // Used for specifying valid identifier characters | |
| 368 | + | // in #GScannerConfig. | |
| 369 | + | CSET_a_2_z string = "abcdefghijklmnopqrstuvwxyz" | |
| 370 | + | ) | |
| 371 | + | ||
| 127 | 372 | // The possible errors, used in the @v_error field | |
| 128 | 373 | // of #GTokenValue, when the token is a %G_TOKEN_ERROR. | |
| 129 | 374 | type ErrorType int | |
| @@ -201,3 +446,32 @@ const ( | |||
| 201 | 446 | // multi line comment | |
| 202 | 447 | GTokenCommentMultiValue TokenType = 269 | |
| 203 | 448 | ) | |
| 449 | + | ||
| 450 | + | func init() { | |
| 451 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 452 | + | if err != nil { | |
| 453 | + | panic(err) | |
| 454 | + | } | |
| 455 | + | ||
| 456 | + | core.PuregoSafeRegister(&xScannerCurLine, lib, "g_scanner_cur_line") | |
| 457 | + | core.PuregoSafeRegister(&xScannerCurPosition, lib, "g_scanner_cur_position") | |
| 458 | + | core.PuregoSafeRegister(&xScannerCurToken, lib, "g_scanner_cur_token") | |
| 459 | + | core.PuregoSafeRegister(&xScannerCurValue, lib, "g_scanner_cur_value") | |
| 460 | + | core.PuregoSafeRegister(&xScannerDestroy, lib, "g_scanner_destroy") | |
| 461 | + | core.PuregoSafeRegister(&xScannerEof, lib, "g_scanner_eof") | |
| 462 | + | core.PuregoSafeRegister(&xScannerError, lib, "g_scanner_error") | |
| 463 | + | core.PuregoSafeRegister(&xScannerGetNextToken, lib, "g_scanner_get_next_token") | |
| 464 | + | core.PuregoSafeRegister(&xScannerInputFile, lib, "g_scanner_input_file") | |
| 465 | + | core.PuregoSafeRegister(&xScannerInputText, lib, "g_scanner_input_text") | |
| 466 | + | core.PuregoSafeRegister(&xScannerLookupSymbol, lib, "g_scanner_lookup_symbol") | |
| 467 | + | core.PuregoSafeRegister(&xScannerPeekNextToken, lib, "g_scanner_peek_next_token") | |
| 468 | + | core.PuregoSafeRegister(&xScannerScopeAddSymbol, lib, "g_scanner_scope_add_symbol") | |
| 469 | + | core.PuregoSafeRegister(&xScannerScopeForeachSymbol, lib, "g_scanner_scope_foreach_symbol") | |
| 470 | + | core.PuregoSafeRegister(&xScannerScopeLookupSymbol, lib, "g_scanner_scope_lookup_symbol") | |
| 471 | + | core.PuregoSafeRegister(&xScannerScopeRemoveSymbol, lib, "g_scanner_scope_remove_symbol") | |
| 472 | + | core.PuregoSafeRegister(&xScannerSetScope, lib, "g_scanner_set_scope") | |
| 473 | + | core.PuregoSafeRegister(&xScannerSyncFileOffset, lib, "g_scanner_sync_file_offset") | |
| 474 | + | core.PuregoSafeRegister(&xScannerUnexpToken, lib, "g_scanner_unexp_token") | |
| 475 | + | core.PuregoSafeRegister(&xScannerWarn, lib, "g_scanner_warn") | |
| 476 | + | ||
| 477 | + | } | |
M v4/glib/gsequence.go +358 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -16,11 +18,340 @@ type SequenceIterCompareFunc func(*SequenceIter, *SequenceIter, uintptr) int | |||
| 16 | 18 | type Sequence struct { | |
| 17 | 19 | } | |
| 18 | 20 | ||
| 21 | + | func (x *Sequence) GoPointer() uintptr { | |
| 22 | + | return uintptr(unsafe.Pointer(x)) | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | var xSequenceAppend func(uintptr, uintptr) *SequenceIter | |
| 26 | + | ||
| 27 | + | // Adds a new item to the end of @seq. | |
| 28 | + | func (x *Sequence) Append(DataVar uintptr) *SequenceIter { | |
| 29 | + | ||
| 30 | + | cret := xSequenceAppend(x.GoPointer(), DataVar) | |
| 31 | + | return cret | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | var xSequenceForeach func(uintptr, uintptr, uintptr) | |
| 35 | + | ||
| 36 | + | // Calls @func for each item in the sequence passing @user_data | |
| 37 | + | // to the function. @func must not modify the sequence itself. | |
| 38 | + | func (x *Sequence) Foreach(FuncVar Func, UserDataVar uintptr) { | |
| 39 | + | ||
| 40 | + | xSequenceForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 41 | + | ||
| 42 | + | } | |
| 43 | + | ||
| 44 | + | var xSequenceFree func(uintptr) | |
| 45 | + | ||
| 46 | + | // Frees the memory allocated for @seq. If @seq has a data destroy | |
| 47 | + | // function associated with it, that function is called on all items | |
| 48 | + | // in @seq. | |
| 49 | + | func (x *Sequence) Free() { | |
| 50 | + | ||
| 51 | + | xSequenceFree(x.GoPointer()) | |
| 52 | + | ||
| 53 | + | } | |
| 54 | + | ||
| 55 | + | var xSequenceGetBeginIter func(uintptr) *SequenceIter | |
| 56 | + | ||
| 57 | + | // Returns the begin iterator for @seq. | |
| 58 | + | func (x *Sequence) GetBeginIter() *SequenceIter { | |
| 59 | + | ||
| 60 | + | cret := xSequenceGetBeginIter(x.GoPointer()) | |
| 61 | + | return cret | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xSequenceGetEndIter func(uintptr) *SequenceIter | |
| 65 | + | ||
| 66 | + | // Returns the end iterator for @seg | |
| 67 | + | func (x *Sequence) GetEndIter() *SequenceIter { | |
| 68 | + | ||
| 69 | + | cret := xSequenceGetEndIter(x.GoPointer()) | |
| 70 | + | return cret | |
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xSequenceGetIterAtPos func(uintptr, int) *SequenceIter | |
| 74 | + | ||
| 75 | + | // Returns the iterator at position @pos. If @pos is negative or larger | |
| 76 | + | // than the number of items in @seq, the end iterator is returned. | |
| 77 | + | func (x *Sequence) GetIterAtPos(PosVar int) *SequenceIter { | |
| 78 | + | ||
| 79 | + | cret := xSequenceGetIterAtPos(x.GoPointer(), PosVar) | |
| 80 | + | return cret | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | var xSequenceGetLength func(uintptr) int | |
| 84 | + | ||
| 85 | + | // Returns the positive length (>= 0) of @seq. Note that this method is | |
| 86 | + | // O(h) where `h' is the height of the tree. It is thus more efficient | |
| 87 | + | // to use g_sequence_is_empty() when comparing the length to zero. | |
| 88 | + | func (x *Sequence) GetLength() int { | |
| 89 | + | ||
| 90 | + | cret := xSequenceGetLength(x.GoPointer()) | |
| 91 | + | return cret | |
| 92 | + | } | |
| 93 | + | ||
| 94 | + | var xSequenceInsertSorted func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 95 | + | ||
| 96 | + | // Inserts @data into @seq using @cmp_func to determine the new | |
| 97 | + | // position. The sequence must already be sorted according to @cmp_func; | |
| 98 | + | // otherwise the new position of @data is undefined. | |
| 99 | + | // | |
| 100 | + | // @cmp_func is called with two items of the @seq, and @cmp_data. | |
| 101 | + | // It should return 0 if the items are equal, a negative value | |
| 102 | + | // if the first item comes before the second, and a positive value | |
| 103 | + | // if the second item comes before the first. | |
| 104 | + | // | |
| 105 | + | // Note that when adding a large amount of data to a #GSequence, | |
| 106 | + | // it is more efficient to do unsorted insertions and then call | |
| 107 | + | // g_sequence_sort() or g_sequence_sort_iter(). | |
| 108 | + | func (x *Sequence) InsertSorted(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 109 | + | ||
| 110 | + | cret := xSequenceInsertSorted(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 111 | + | return cret | |
| 112 | + | } | |
| 113 | + | ||
| 114 | + | var xSequenceInsertSortedIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 115 | + | ||
| 116 | + | // Like g_sequence_insert_sorted(), but uses | |
| 117 | + | // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as | |
| 118 | + | // the compare function. | |
| 119 | + | // | |
| 120 | + | // @iter_cmp is called with two iterators pointing into @seq. | |
| 121 | + | // It should return 0 if the iterators are equal, a negative | |
| 122 | + | // value if the first iterator comes before the second, and a | |
| 123 | + | // positive value if the second iterator comes before the first. | |
| 124 | + | // | |
| 125 | + | // Note that when adding a large amount of data to a #GSequence, | |
| 126 | + | // it is more efficient to do unsorted insertions and then call | |
| 127 | + | // g_sequence_sort() or g_sequence_sort_iter(). | |
| 128 | + | func (x *Sequence) InsertSortedIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 129 | + | ||
| 130 | + | cret := xSequenceInsertSortedIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 131 | + | return cret | |
| 132 | + | } | |
| 133 | + | ||
| 134 | + | var xSequenceIsEmpty func(uintptr) bool | |
| 135 | + | ||
| 136 | + | // Returns %TRUE if the sequence contains zero items. | |
| 137 | + | // | |
| 138 | + | // This function is functionally identical to checking the result of | |
| 139 | + | // g_sequence_get_length() being equal to zero. However this function is | |
| 140 | + | // implemented in O(1) running time. | |
| 141 | + | func (x *Sequence) IsEmpty() bool { | |
| 142 | + | ||
| 143 | + | cret := xSequenceIsEmpty(x.GoPointer()) | |
| 144 | + | return cret | |
| 145 | + | } | |
| 146 | + | ||
| 147 | + | var xSequenceLookup func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 148 | + | ||
| 149 | + | // Returns an iterator pointing to the position of the first item found | |
| 150 | + | // equal to @data according to @cmp_func and @cmp_data. If more than one | |
| 151 | + | // item is equal, it is not guaranteed that it is the first which is | |
| 152 | + | // returned. In that case, you can use g_sequence_iter_next() and | |
| 153 | + | // g_sequence_iter_prev() to get others. | |
| 154 | + | // | |
| 155 | + | // @cmp_func is called with two items of the @seq, and @cmp_data. | |
| 156 | + | // It should return 0 if the items are equal, a negative value if | |
| 157 | + | // the first item comes before the second, and a positive value if | |
| 158 | + | // the second item comes before the first. | |
| 159 | + | // | |
| 160 | + | // This function will fail if the data contained in the sequence is | |
| 161 | + | // unsorted. | |
| 162 | + | func (x *Sequence) Lookup(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 163 | + | ||
| 164 | + | cret := xSequenceLookup(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 165 | + | return cret | |
| 166 | + | } | |
| 167 | + | ||
| 168 | + | var xSequenceLookupIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 169 | + | ||
| 170 | + | // Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc | |
| 171 | + | // instead of a #GCompareDataFunc as the compare function. | |
| 172 | + | // | |
| 173 | + | // @iter_cmp is called with two iterators pointing into @seq. | |
| 174 | + | // It should return 0 if the iterators are equal, a negative value | |
| 175 | + | // if the first iterator comes before the second, and a positive | |
| 176 | + | // value if the second iterator comes before the first. | |
| 177 | + | // | |
| 178 | + | // This function will fail if the data contained in the sequence is | |
| 179 | + | // unsorted. | |
| 180 | + | func (x *Sequence) LookupIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 181 | + | ||
| 182 | + | cret := xSequenceLookupIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 183 | + | return cret | |
| 184 | + | } | |
| 185 | + | ||
| 186 | + | var xSequencePrepend func(uintptr, uintptr) *SequenceIter | |
| 187 | + | ||
| 188 | + | // Adds a new item to the front of @seq | |
| 189 | + | func (x *Sequence) Prepend(DataVar uintptr) *SequenceIter { | |
| 190 | + | ||
| 191 | + | cret := xSequencePrepend(x.GoPointer(), DataVar) | |
| 192 | + | return cret | |
| 193 | + | } | |
| 194 | + | ||
| 195 | + | var xSequenceSearch func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 196 | + | ||
| 197 | + | // Returns an iterator pointing to the position where @data would | |
| 198 | + | // be inserted according to @cmp_func and @cmp_data. | |
| 199 | + | // | |
| 200 | + | // @cmp_func is called with two items of the @seq, and @cmp_data. | |
| 201 | + | // It should return 0 if the items are equal, a negative value if | |
| 202 | + | // the first item comes before the second, and a positive value if | |
| 203 | + | // the second item comes before the first. | |
| 204 | + | // | |
| 205 | + | // If you are simply searching for an existing element of the sequence, | |
| 206 | + | // consider using g_sequence_lookup(). | |
| 207 | + | // | |
| 208 | + | // This function will fail if the data contained in the sequence is | |
| 209 | + | // unsorted. | |
| 210 | + | func (x *Sequence) Search(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 211 | + | ||
| 212 | + | cret := xSequenceSearch(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 213 | + | return cret | |
| 214 | + | } | |
| 215 | + | ||
| 216 | + | var xSequenceSearchIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |
| 217 | + | ||
| 218 | + | // Like g_sequence_search(), but uses a #GSequenceIterCompareFunc | |
| 219 | + | // instead of a #GCompareDataFunc as the compare function. | |
| 220 | + | // | |
| 221 | + | // @iter_cmp is called with two iterators pointing into @seq. | |
| 222 | + | // It should return 0 if the iterators are equal, a negative value | |
| 223 | + | // if the first iterator comes before the second, and a positive | |
| 224 | + | // value if the second iterator comes before the first. | |
| 225 | + | // | |
| 226 | + | // If you are simply searching for an existing element of the sequence, | |
| 227 | + | // consider using g_sequence_lookup_iter(). | |
| 228 | + | // | |
| 229 | + | // This function will fail if the data contained in the sequence is | |
| 230 | + | // unsorted. | |
| 231 | + | func (x *Sequence) SearchIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 232 | + | ||
| 233 | + | cret := xSequenceSearchIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 234 | + | return cret | |
| 235 | + | } | |
| 236 | + | ||
| 237 | + | var xSequenceSort func(uintptr, uintptr, uintptr) | |
| 238 | + | ||
| 239 | + | // Sorts @seq using @cmp_func. | |
| 240 | + | // | |
| 241 | + | // @cmp_func is passed two items of @seq and should | |
| 242 | + | // return 0 if they are equal, a negative value if the | |
| 243 | + | // first comes before the second, and a positive value | |
| 244 | + | // if the second comes before the first. | |
| 245 | + | func (x *Sequence) Sort(CmpFuncVar CompareDataFunc, CmpDataVar uintptr) { | |
| 246 | + | ||
| 247 | + | xSequenceSort(x.GoPointer(), purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 248 | + | ||
| 249 | + | } | |
| 250 | + | ||
| 251 | + | var xSequenceSortIter func(uintptr, uintptr, uintptr) | |
| 252 | + | ||
| 253 | + | // Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead | |
| 254 | + | // of a #GCompareDataFunc as the compare function | |
| 255 | + | // | |
| 256 | + | // @cmp_func is called with two iterators pointing into @seq. It should | |
| 257 | + | // return 0 if the iterators are equal, a negative value if the first | |
| 258 | + | // iterator comes before the second, and a positive value if the second | |
| 259 | + | // iterator comes before the first. | |
| 260 | + | func (x *Sequence) SortIter(CmpFuncVar SequenceIterCompareFunc, CmpDataVar uintptr) { | |
| 261 | + | ||
| 262 | + | xSequenceSortIter(x.GoPointer(), purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 263 | + | ||
| 264 | + | } | |
| 265 | + | ||
| 19 | 266 | // The #GSequenceIter struct is an opaque data type representing an | |
| 20 | 267 | // iterator pointing into a #GSequence. | |
| 21 | 268 | type SequenceIter struct { | |
| 22 | 269 | } | |
| 23 | 270 | ||
| 271 | + | func (x *SequenceIter) GoPointer() uintptr { | |
| 272 | + | return uintptr(unsafe.Pointer(x)) | |
| 273 | + | } | |
| 274 | + | ||
| 275 | + | var xSequenceIterCompare func(uintptr, *SequenceIter) int | |
| 276 | + | ||
| 277 | + | // Returns a negative number if @a comes before @b, 0 if they are equal, | |
| 278 | + | // and a positive number if @a comes after @b. | |
| 279 | + | // | |
| 280 | + | // The @a and @b iterators must point into the same sequence. | |
| 281 | + | func (x *SequenceIter) Compare(BVar *SequenceIter) int { | |
| 282 | + | ||
| 283 | + | cret := xSequenceIterCompare(x.GoPointer(), BVar) | |
| 284 | + | return cret | |
| 285 | + | } | |
| 286 | + | ||
| 287 | + | var xSequenceIterGetPosition func(uintptr) int | |
| 288 | + | ||
| 289 | + | // Returns the position of @iter | |
| 290 | + | func (x *SequenceIter) GetPosition() int { | |
| 291 | + | ||
| 292 | + | cret := xSequenceIterGetPosition(x.GoPointer()) | |
| 293 | + | return cret | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | var xSequenceIterGetSequence func(uintptr) *Sequence | |
| 297 | + | ||
| 298 | + | // Returns the #GSequence that @iter points into. | |
| 299 | + | func (x *SequenceIter) GetSequence() *Sequence { | |
| 300 | + | ||
| 301 | + | cret := xSequenceIterGetSequence(x.GoPointer()) | |
| 302 | + | return cret | |
| 303 | + | } | |
| 304 | + | ||
| 305 | + | var xSequenceIterIsBegin func(uintptr) bool | |
| 306 | + | ||
| 307 | + | // Returns whether @iter is the begin iterator | |
| 308 | + | func (x *SequenceIter) IsBegin() bool { | |
| 309 | + | ||
| 310 | + | cret := xSequenceIterIsBegin(x.GoPointer()) | |
| 311 | + | return cret | |
| 312 | + | } | |
| 313 | + | ||
| 314 | + | var xSequenceIterIsEnd func(uintptr) bool | |
| 315 | + | ||
| 316 | + | // Returns whether @iter is the end iterator | |
| 317 | + | func (x *SequenceIter) IsEnd() bool { | |
| 318 | + | ||
| 319 | + | cret := xSequenceIterIsEnd(x.GoPointer()) | |
| 320 | + | return cret | |
| 321 | + | } | |
| 322 | + | ||
| 323 | + | var xSequenceIterMove func(uintptr, int) *SequenceIter | |
| 324 | + | ||
| 325 | + | // Returns the #GSequenceIter which is @delta positions away from @iter. | |
| 326 | + | // If @iter is closer than -@delta positions to the beginning of the sequence, | |
| 327 | + | // the begin iterator is returned. If @iter is closer than @delta positions | |
| 328 | + | // to the end of the sequence, the end iterator is returned. | |
| 329 | + | func (x *SequenceIter) Move(DeltaVar int) *SequenceIter { | |
| 330 | + | ||
| 331 | + | cret := xSequenceIterMove(x.GoPointer(), DeltaVar) | |
| 332 | + | return cret | |
| 333 | + | } | |
| 334 | + | ||
| 335 | + | var xSequenceIterNext func(uintptr) *SequenceIter | |
| 336 | + | ||
| 337 | + | // Returns an iterator pointing to the next position after @iter. | |
| 338 | + | // If @iter is the end iterator, the end iterator is returned. | |
| 339 | + | func (x *SequenceIter) Next() *SequenceIter { | |
| 340 | + | ||
| 341 | + | cret := xSequenceIterNext(x.GoPointer()) | |
| 342 | + | return cret | |
| 343 | + | } | |
| 344 | + | ||
| 345 | + | var xSequenceIterPrev func(uintptr) *SequenceIter | |
| 346 | + | ||
| 347 | + | // Returns an iterator pointing to the previous position before @iter. | |
| 348 | + | // If @iter is the begin iterator, the begin iterator is returned. | |
| 349 | + | func (x *SequenceIter) Prev() *SequenceIter { | |
| 350 | + | ||
| 351 | + | cret := xSequenceIterPrev(x.GoPointer()) | |
| 352 | + | return cret | |
| 353 | + | } | |
| 354 | + | ||
| 24 | 355 | var xSequenceGet func(*SequenceIter) uintptr | |
| 25 | 356 | ||
| 26 | 357 | // Returns the data that @iter points to. | |
| @@ -142,4 +473,31 @@ func init() { | |||
| 142 | 473 | core.PuregoSafeRegister(&xSequenceSet, lib, "g_sequence_set") | |
| 143 | 474 | core.PuregoSafeRegister(&xSequenceSwap, lib, "g_sequence_swap") | |
| 144 | 475 | ||
| 476 | + | core.PuregoSafeRegister(&xSequenceAppend, lib, "g_sequence_append") | |
| 477 | + | core.PuregoSafeRegister(&xSequenceForeach, lib, "g_sequence_foreach") | |
| 478 | + | core.PuregoSafeRegister(&xSequenceFree, lib, "g_sequence_free") | |
| 479 | + | core.PuregoSafeRegister(&xSequenceGetBeginIter, lib, "g_sequence_get_begin_iter") | |
| 480 | + | core.PuregoSafeRegister(&xSequenceGetEndIter, lib, "g_sequence_get_end_iter") | |
| 481 | + | core.PuregoSafeRegister(&xSequenceGetIterAtPos, lib, "g_sequence_get_iter_at_pos") | |
| 482 | + | core.PuregoSafeRegister(&xSequenceGetLength, lib, "g_sequence_get_length") | |
| 483 | + | core.PuregoSafeRegister(&xSequenceInsertSorted, lib, "g_sequence_insert_sorted") | |
| 484 | + | core.PuregoSafeRegister(&xSequenceInsertSortedIter, lib, "g_sequence_insert_sorted_iter") | |
| 485 | + | core.PuregoSafeRegister(&xSequenceIsEmpty, lib, "g_sequence_is_empty") | |
| 486 | + | core.PuregoSafeRegister(&xSequenceLookup, lib, "g_sequence_lookup") | |
| 487 | + | core.PuregoSafeRegister(&xSequenceLookupIter, lib, "g_sequence_lookup_iter") | |
| 488 | + | core.PuregoSafeRegister(&xSequencePrepend, lib, "g_sequence_prepend") | |
| 489 | + | core.PuregoSafeRegister(&xSequenceSearch, lib, "g_sequence_search") | |
| 490 | + | core.PuregoSafeRegister(&xSequenceSearchIter, lib, "g_sequence_search_iter") | |
| 491 | + | core.PuregoSafeRegister(&xSequenceSort, lib, "g_sequence_sort") | |
| 492 | + | core.PuregoSafeRegister(&xSequenceSortIter, lib, "g_sequence_sort_iter") | |
| 493 | + | ||
| 494 | + | core.PuregoSafeRegister(&xSequenceIterCompare, lib, "g_sequence_iter_compare") | |
| 495 | + | core.PuregoSafeRegister(&xSequenceIterGetPosition, lib, "g_sequence_iter_get_position") | |
| 496 | + | core.PuregoSafeRegister(&xSequenceIterGetSequence, lib, "g_sequence_iter_get_sequence") | |
| 497 | + | core.PuregoSafeRegister(&xSequenceIterIsBegin, lib, "g_sequence_iter_is_begin") | |
| 498 | + | core.PuregoSafeRegister(&xSequenceIterIsEnd, lib, "g_sequence_iter_is_end") | |
| 499 | + | core.PuregoSafeRegister(&xSequenceIterMove, lib, "g_sequence_iter_move") | |
| 500 | + | core.PuregoSafeRegister(&xSequenceIterNext, lib, "g_sequence_iter_next") | |
| 501 | + | core.PuregoSafeRegister(&xSequenceIterPrev, lib, "g_sequence_iter_prev") | |
| 502 | + | ||
| 145 | 503 | } | |
M v4/glib/gslist.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -14,6 +16,10 @@ type SList struct { | |||
| 14 | 16 | Next *SList | |
| 15 | 17 | } | |
| 16 | 18 | ||
| 19 | + | func (x *SList) GoPointer() uintptr { | |
| 20 | + | return uintptr(unsafe.Pointer(x)) | |
| 21 | + | } | |
| 22 | + | ||
| 17 | 23 | var xClearSlist func(**SList, uintptr) | |
| 18 | 24 | ||
| 19 | 25 | // Clears a pointer to a #GSList, freeing it and, optionally, freeing its elements using @destroy. | |
M v4/glib/gstdio.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -13,6 +15,10 @@ import ( | |||
| 13 | 15 | type StatBuf struct { | |
| 14 | 16 | } | |
| 15 | 17 | ||
| 18 | + | func (x *StatBuf) GoPointer() uintptr { | |
| 19 | + | return uintptr(unsafe.Pointer(x)) | |
| 20 | + | } | |
| 21 | + | ||
| 16 | 22 | var xAccess func(string, int) int | |
| 17 | 23 | ||
| 18 | 24 | // A wrapper for the POSIX access() function. This function is used to | |
M v4/glib/gstrfuncs.go +16 -0
| @@ -10,6 +10,22 @@ import ( | |||
| 10 | 10 | // g_auto(). | |
| 11 | 11 | type Strv = string | |
| 12 | 12 | ||
| 13 | + | const ( | |
| 14 | + | // A good size for a buffer to be passed into g_ascii_dtostr(). | |
| 15 | + | // It is guaranteed to be enough for all output of that function | |
| 16 | + | // on systems with 64bit IEEE-compatible doubles. | |
| 17 | + | // | |
| 18 | + | // The typical usage would be something like: | |
| 19 | + | // |[<!-- language="C" --> | |
| 20 | + | // char buf[G_ASCII_DTOSTR_BUF_SIZE]; | |
| 21 | + | // | |
| 22 | + | // fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value)); | |
| 23 | + | // ]| | |
| 24 | + | ASCII_DTOSTR_BUF_SIZE int = 39 | |
| 25 | + | // The standard delimiters, used in g_strdelimit(). | |
| 26 | + | STR_DELIMITERS string = "_-|> <." | |
| 27 | + | ) | |
| 28 | + | ||
| 13 | 29 | type AsciiType int | |
| 14 | 30 | ||
| 15 | 31 | const ( | |
M v4/glib/gstring.go +453 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // The GString struct contains the public fields of a GString. | |
| 5 | 12 | type String struct { | |
| 6 | 13 | Str uintptr | |
| @@ -9,3 +16,449 @@ type String struct { | |||
| 9 | 16 | ||
| 10 | 17 | AllocatedLen uint | |
| 11 | 18 | } | |
| 19 | + | ||
| 20 | + | func (x *String) GoPointer() uintptr { | |
| 21 | + | return uintptr(unsafe.Pointer(x)) | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | var xNewString func(string) *String | |
| 25 | + | ||
| 26 | + | // Creates a new #GString, initialized with the given string. | |
| 27 | + | func NewString(InitVar string) *String { | |
| 28 | + | ||
| 29 | + | cret := xNewString(InitVar) | |
| 30 | + | return cret | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | var xNewLenString func(string, int) *String | |
| 34 | + | ||
| 35 | + | // Creates a new #GString with @len bytes of the @init buffer. | |
| 36 | + | // Because a length is provided, @init need not be nul-terminated, | |
| 37 | + | // and can contain embedded nul bytes. | |
| 38 | + | // | |
| 39 | + | // Since this function does not stop at nul bytes, it is the caller's | |
| 40 | + | // responsibility to ensure that @init has at least @len addressable | |
| 41 | + | // bytes. | |
| 42 | + | func NewLenString(InitVar string, LenVar int) *String { | |
| 43 | + | ||
| 44 | + | cret := xNewLenString(InitVar, LenVar) | |
| 45 | + | return cret | |
| 46 | + | } | |
| 47 | + | ||
| 48 | + | var xSizedNewString func(uint) *String | |
| 49 | + | ||
| 50 | + | // Creates a new #GString, with enough space for @dfl_size | |
| 51 | + | // bytes. This is useful if you are going to add a lot of | |
| 52 | + | // text to the string and don't want it to be reallocated | |
| 53 | + | // too often. | |
| 54 | + | func SizedNewString(DflSizeVar uint) *String { | |
| 55 | + | ||
| 56 | + | cret := xSizedNewString(DflSizeVar) | |
| 57 | + | return cret | |
| 58 | + | } | |
| 59 | + | ||
| 60 | + | var xStringAppend func(uintptr, string) *String | |
| 61 | + | ||
| 62 | + | // Adds a string onto the end of a #GString, expanding | |
| 63 | + | // it if necessary. | |
| 64 | + | func (x *String) Append(ValVar string) *String { | |
| 65 | + | ||
| 66 | + | cret := xStringAppend(x.GoPointer(), ValVar) | |
| 67 | + | return cret | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | var xStringAppendC func(uintptr, byte) *String | |
| 71 | + | ||
| 72 | + | // Adds a byte onto the end of a #GString, expanding | |
| 73 | + | // it if necessary. | |
| 74 | + | func (x *String) AppendC(CVar byte) *String { | |
| 75 | + | ||
| 76 | + | cret := xStringAppendC(x.GoPointer(), CVar) | |
| 77 | + | return cret | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | var xStringAppendLen func(uintptr, string, int) *String | |
| 81 | + | ||
| 82 | + | // Appends @len bytes of @val to @string. | |
| 83 | + | // | |
| 84 | + | // If @len is positive, @val may contain embedded nuls and need | |
| 85 | + | // not be nul-terminated. It is the caller's responsibility to | |
| 86 | + | // ensure that @val has at least @len addressable bytes. | |
| 87 | + | // | |
| 88 | + | // If @len is negative, @val must be nul-terminated and @len | |
| 89 | + | // is considered to request the entire string length. This | |
| 90 | + | // makes g_string_append_len() equivalent to g_string_append(). | |
| 91 | + | func (x *String) AppendLen(ValVar string, LenVar int) *String { | |
| 92 | + | ||
| 93 | + | cret := xStringAppendLen(x.GoPointer(), ValVar, LenVar) | |
| 94 | + | return cret | |
| 95 | + | } | |
| 96 | + | ||
| 97 | + | var xStringAppendPrintf func(uintptr, string, ...interface{}) | |
| 98 | + | ||
| 99 | + | // Appends a formatted string onto the end of a #GString. | |
| 100 | + | // This function is similar to g_string_printf() except | |
| 101 | + | // that the text is appended to the #GString. | |
| 102 | + | func (x *String) AppendPrintf(FormatVar string, varArgs ...interface{}) { | |
| 103 | + | ||
| 104 | + | xStringAppendPrintf(x.GoPointer(), FormatVar, varArgs...) | |
| 105 | + | ||
| 106 | + | } | |
| 107 | + | ||
| 108 | + | var xStringAppendUnichar func(uintptr, uint32) *String | |
| 109 | + | ||
| 110 | + | // Converts a Unicode character into UTF-8, and appends it | |
| 111 | + | // to the string. | |
| 112 | + | func (x *String) AppendUnichar(WcVar uint32) *String { | |
| 113 | + | ||
| 114 | + | cret := xStringAppendUnichar(x.GoPointer(), WcVar) | |
| 115 | + | return cret | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xStringAppendUriEscaped func(uintptr, string, string, bool) *String | |
| 119 | + | ||
| 120 | + | // Appends @unescaped to @string, escaping any characters that | |
| 121 | + | // are reserved in URIs using URI-style escape sequences. | |
| 122 | + | func (x *String) AppendUriEscaped(UnescapedVar string, ReservedCharsAllowedVar string, AllowUtf8Var bool) *String { | |
| 123 | + | ||
| 124 | + | cret := xStringAppendUriEscaped(x.GoPointer(), UnescapedVar, ReservedCharsAllowedVar, AllowUtf8Var) | |
| 125 | + | return cret | |
| 126 | + | } | |
| 127 | + | ||
| 128 | + | var xStringAppendVprintf func(uintptr, string, []interface{}) | |
| 129 | + | ||
| 130 | + | // Appends a formatted string onto the end of a #GString. | |
| 131 | + | // This function is similar to g_string_append_printf() | |
| 132 | + | // except that the arguments to the format string are passed | |
| 133 | + | // as a va_list. | |
| 134 | + | func (x *String) AppendVprintf(FormatVar string, ArgsVar []interface{}) { | |
| 135 | + | ||
| 136 | + | xStringAppendVprintf(x.GoPointer(), FormatVar, ArgsVar) | |
| 137 | + | ||
| 138 | + | } | |
| 139 | + | ||
| 140 | + | var xStringAsciiDown func(uintptr) *String | |
| 141 | + | ||
| 142 | + | // Converts all uppercase ASCII letters to lowercase ASCII letters. | |
| 143 | + | func (x *String) AsciiDown() *String { | |
| 144 | + | ||
| 145 | + | cret := xStringAsciiDown(x.GoPointer()) | |
| 146 | + | return cret | |
| 147 | + | } | |
| 148 | + | ||
| 149 | + | var xStringAsciiUp func(uintptr) *String | |
| 150 | + | ||
| 151 | + | // Converts all lowercase ASCII letters to uppercase ASCII letters. | |
| 152 | + | func (x *String) AsciiUp() *String { | |
| 153 | + | ||
| 154 | + | cret := xStringAsciiUp(x.GoPointer()) | |
| 155 | + | return cret | |
| 156 | + | } | |
| 157 | + | ||
| 158 | + | var xStringAssign func(uintptr, string) *String | |
| 159 | + | ||
| 160 | + | // Copies the bytes from a string into a #GString, | |
| 161 | + | // destroying any previous contents. It is rather like | |
| 162 | + | // the standard strcpy() function, except that you do not | |
| 163 | + | // have to worry about having enough space to copy the string. | |
| 164 | + | func (x *String) Assign(RvalVar string) *String { | |
| 165 | + | ||
| 166 | + | cret := xStringAssign(x.GoPointer(), RvalVar) | |
| 167 | + | return cret | |
| 168 | + | } | |
| 169 | + | ||
| 170 | + | var xStringDown func(uintptr) *String | |
| 171 | + | ||
| 172 | + | // Converts a #GString to lowercase. | |
| 173 | + | func (x *String) Down() *String { | |
| 174 | + | ||
| 175 | + | cret := xStringDown(x.GoPointer()) | |
| 176 | + | return cret | |
| 177 | + | } | |
| 178 | + | ||
| 179 | + | var xStringEqual func(uintptr, *String) bool | |
| 180 | + | ||
| 181 | + | // Compares two strings for equality, returning %TRUE if they are equal. | |
| 182 | + | // For use with #GHashTable. | |
| 183 | + | func (x *String) Equal(V2Var *String) bool { | |
| 184 | + | ||
| 185 | + | cret := xStringEqual(x.GoPointer(), V2Var) | |
| 186 | + | return cret | |
| 187 | + | } | |
| 188 | + | ||
| 189 | + | var xStringErase func(uintptr, int, int) *String | |
| 190 | + | ||
| 191 | + | // Removes @len bytes from a #GString, starting at position @pos. | |
| 192 | + | // The rest of the #GString is shifted down to fill the gap. | |
| 193 | + | func (x *String) Erase(PosVar int, LenVar int) *String { | |
| 194 | + | ||
| 195 | + | cret := xStringErase(x.GoPointer(), PosVar, LenVar) | |
| 196 | + | return cret | |
| 197 | + | } | |
| 198 | + | ||
| 199 | + | var xStringFree func(uintptr, bool) string | |
| 200 | + | ||
| 201 | + | // Frees the memory allocated for the #GString. | |
| 202 | + | // If @free_segment is %TRUE it also frees the character data. If | |
| 203 | + | // it's %FALSE, the caller gains ownership of the buffer and must | |
| 204 | + | // free it after use with g_free(). | |
| 205 | + | func (x *String) Free(FreeSegmentVar bool) string { | |
| 206 | + | ||
| 207 | + | cret := xStringFree(x.GoPointer(), FreeSegmentVar) | |
| 208 | + | return cret | |
| 209 | + | } | |
| 210 | + | ||
| 211 | + | var xStringFreeToBytes func(uintptr) *Bytes | |
| 212 | + | ||
| 213 | + | // Transfers ownership of the contents of @string to a newly allocated | |
| 214 | + | // #GBytes. The #GString structure itself is deallocated, and it is | |
| 215 | + | // therefore invalid to use @string after invoking this function. | |
| 216 | + | // | |
| 217 | + | // Note that while #GString ensures that its buffer always has a | |
| 218 | + | // trailing nul character (not reflected in its "len"), the returned | |
| 219 | + | // #GBytes does not include this extra nul; i.e. it has length exactly | |
| 220 | + | // equal to the "len" member. | |
| 221 | + | func (x *String) FreeToBytes() *Bytes { | |
| 222 | + | ||
| 223 | + | cret := xStringFreeToBytes(x.GoPointer()) | |
| 224 | + | return cret | |
| 225 | + | } | |
| 226 | + | ||
| 227 | + | var xStringHash func(uintptr) uint | |
| 228 | + | ||
| 229 | + | // Creates a hash code for @str; for use with #GHashTable. | |
| 230 | + | func (x *String) Hash() uint { | |
| 231 | + | ||
| 232 | + | cret := xStringHash(x.GoPointer()) | |
| 233 | + | return cret | |
| 234 | + | } | |
| 235 | + | ||
| 236 | + | var xStringInsert func(uintptr, int, string) *String | |
| 237 | + | ||
| 238 | + | // Inserts a copy of a string into a #GString, | |
| 239 | + | // expanding it if necessary. | |
| 240 | + | func (x *String) Insert(PosVar int, ValVar string) *String { | |
| 241 | + | ||
| 242 | + | cret := xStringInsert(x.GoPointer(), PosVar, ValVar) | |
| 243 | + | return cret | |
| 244 | + | } | |
| 245 | + | ||
| 246 | + | var xStringInsertC func(uintptr, int, byte) *String | |
| 247 | + | ||
| 248 | + | // Inserts a byte into a #GString, expanding it if necessary. | |
| 249 | + | func (x *String) InsertC(PosVar int, CVar byte) *String { | |
| 250 | + | ||
| 251 | + | cret := xStringInsertC(x.GoPointer(), PosVar, CVar) | |
| 252 | + | return cret | |
| 253 | + | } | |
| 254 | + | ||
| 255 | + | var xStringInsertLen func(uintptr, int, string, int) *String | |
| 256 | + | ||
| 257 | + | // Inserts @len bytes of @val into @string at @pos. | |
| 258 | + | // | |
| 259 | + | // If @len is positive, @val may contain embedded nuls and need | |
| 260 | + | // not be nul-terminated. It is the caller's responsibility to | |
| 261 | + | // ensure that @val has at least @len addressable bytes. | |
| 262 | + | // | |
| 263 | + | // If @len is negative, @val must be nul-terminated and @len | |
| 264 | + | // is considered to request the entire string length. | |
| 265 | + | // | |
| 266 | + | // If @pos is -1, bytes are inserted at the end of the string. | |
| 267 | + | func (x *String) InsertLen(PosVar int, ValVar string, LenVar int) *String { | |
| 268 | + | ||
| 269 | + | cret := xStringInsertLen(x.GoPointer(), PosVar, ValVar, LenVar) | |
| 270 | + | return cret | |
| 271 | + | } | |
| 272 | + | ||
| 273 | + | var xStringInsertUnichar func(uintptr, int, uint32) *String | |
| 274 | + | ||
| 275 | + | // Converts a Unicode character into UTF-8, and insert it | |
| 276 | + | // into the string at the given position. | |
| 277 | + | func (x *String) InsertUnichar(PosVar int, WcVar uint32) *String { | |
| 278 | + | ||
| 279 | + | cret := xStringInsertUnichar(x.GoPointer(), PosVar, WcVar) | |
| 280 | + | return cret | |
| 281 | + | } | |
| 282 | + | ||
| 283 | + | var xStringOverwrite func(uintptr, uint, string) *String | |
| 284 | + | ||
| 285 | + | // Overwrites part of a string, lengthening it if necessary. | |
| 286 | + | func (x *String) Overwrite(PosVar uint, ValVar string) *String { | |
| 287 | + | ||
| 288 | + | cret := xStringOverwrite(x.GoPointer(), PosVar, ValVar) | |
| 289 | + | return cret | |
| 290 | + | } | |
| 291 | + | ||
| 292 | + | var xStringOverwriteLen func(uintptr, uint, string, int) *String | |
| 293 | + | ||
| 294 | + | // Overwrites part of a string, lengthening it if necessary. | |
| 295 | + | // This function will work with embedded nuls. | |
| 296 | + | func (x *String) OverwriteLen(PosVar uint, ValVar string, LenVar int) *String { | |
| 297 | + | ||
| 298 | + | cret := xStringOverwriteLen(x.GoPointer(), PosVar, ValVar, LenVar) | |
| 299 | + | return cret | |
| 300 | + | } | |
| 301 | + | ||
| 302 | + | var xStringPrepend func(uintptr, string) *String | |
| 303 | + | ||
| 304 | + | // Adds a string on to the start of a #GString, | |
| 305 | + | // expanding it if necessary. | |
| 306 | + | func (x *String) Prepend(ValVar string) *String { | |
| 307 | + | ||
| 308 | + | cret := xStringPrepend(x.GoPointer(), ValVar) | |
| 309 | + | return cret | |
| 310 | + | } | |
| 311 | + | ||
| 312 | + | var xStringPrependC func(uintptr, byte) *String | |
| 313 | + | ||
| 314 | + | // Adds a byte onto the start of a #GString, | |
| 315 | + | // expanding it if necessary. | |
| 316 | + | func (x *String) PrependC(CVar byte) *String { | |
| 317 | + | ||
| 318 | + | cret := xStringPrependC(x.GoPointer(), CVar) | |
| 319 | + | return cret | |
| 320 | + | } | |
| 321 | + | ||
| 322 | + | var xStringPrependLen func(uintptr, string, int) *String | |
| 323 | + | ||
| 324 | + | // Prepends @len bytes of @val to @string. | |
| 325 | + | // | |
| 326 | + | // If @len is positive, @val may contain embedded nuls and need | |
| 327 | + | // not be nul-terminated. It is the caller's responsibility to | |
| 328 | + | // ensure that @val has at least @len addressable bytes. | |
| 329 | + | // | |
| 330 | + | // If @len is negative, @val must be nul-terminated and @len | |
| 331 | + | // is considered to request the entire string length. This | |
| 332 | + | // makes g_string_prepend_len() equivalent to g_string_prepend(). | |
| 333 | + | func (x *String) PrependLen(ValVar string, LenVar int) *String { | |
| 334 | + | ||
| 335 | + | cret := xStringPrependLen(x.GoPointer(), ValVar, LenVar) | |
| 336 | + | return cret | |
| 337 | + | } | |
| 338 | + | ||
| 339 | + | var xStringPrependUnichar func(uintptr, uint32) *String | |
| 340 | + | ||
| 341 | + | // Converts a Unicode character into UTF-8, and prepends it | |
| 342 | + | // to the string. | |
| 343 | + | func (x *String) PrependUnichar(WcVar uint32) *String { | |
| 344 | + | ||
| 345 | + | cret := xStringPrependUnichar(x.GoPointer(), WcVar) | |
| 346 | + | return cret | |
| 347 | + | } | |
| 348 | + | ||
| 349 | + | var xStringPrintf func(uintptr, string, ...interface{}) | |
| 350 | + | ||
| 351 | + | // Writes a formatted string into a #GString. | |
| 352 | + | // This is similar to the standard sprintf() function, | |
| 353 | + | // except that the #GString buffer automatically expands | |
| 354 | + | // to contain the results. The previous contents of the | |
| 355 | + | // #GString are destroyed. | |
| 356 | + | func (x *String) Printf(FormatVar string, varArgs ...interface{}) { | |
| 357 | + | ||
| 358 | + | xStringPrintf(x.GoPointer(), FormatVar, varArgs...) | |
| 359 | + | ||
| 360 | + | } | |
| 361 | + | ||
| 362 | + | var xStringReplace func(uintptr, string, string, uint) uint | |
| 363 | + | ||
| 364 | + | // Replaces the string @find with the string @replace in a #GString up to | |
| 365 | + | // @limit times. If the number of instances of @find in the #GString is | |
| 366 | + | // less than @limit, all instances are replaced. If @limit is `0`, | |
| 367 | + | // all instances of @find are replaced. | |
| 368 | + | // | |
| 369 | + | // If @find is the empty string, since versions 2.69.1 and 2.68.4 the | |
| 370 | + | // replacement will be inserted no more than once per possible position | |
| 371 | + | // (beginning of string, end of string and between characters). This did | |
| 372 | + | // not work correctly in earlier versions. | |
| 373 | + | func (x *String) Replace(FindVar string, ReplaceVar string, LimitVar uint) uint { | |
| 374 | + | ||
| 375 | + | cret := xStringReplace(x.GoPointer(), FindVar, ReplaceVar, LimitVar) | |
| 376 | + | return cret | |
| 377 | + | } | |
| 378 | + | ||
| 379 | + | var xStringSetSize func(uintptr, uint) *String | |
| 380 | + | ||
| 381 | + | // Sets the length of a #GString. If the length is less than | |
| 382 | + | // the current length, the string will be truncated. If the | |
| 383 | + | // length is greater than the current length, the contents | |
| 384 | + | // of the newly added area are undefined. (However, as | |
| 385 | + | // always, string->str[string->len] will be a nul byte.) | |
| 386 | + | func (x *String) SetSize(LenVar uint) *String { | |
| 387 | + | ||
| 388 | + | cret := xStringSetSize(x.GoPointer(), LenVar) | |
| 389 | + | return cret | |
| 390 | + | } | |
| 391 | + | ||
| 392 | + | var xStringTruncate func(uintptr, uint) *String | |
| 393 | + | ||
| 394 | + | // Cuts off the end of the GString, leaving the first @len bytes. | |
| 395 | + | func (x *String) Truncate(LenVar uint) *String { | |
| 396 | + | ||
| 397 | + | cret := xStringTruncate(x.GoPointer(), LenVar) | |
| 398 | + | return cret | |
| 399 | + | } | |
| 400 | + | ||
| 401 | + | var xStringUp func(uintptr) *String | |
| 402 | + | ||
| 403 | + | // Converts a #GString to uppercase. | |
| 404 | + | func (x *String) Up() *String { | |
| 405 | + | ||
| 406 | + | cret := xStringUp(x.GoPointer()) | |
| 407 | + | return cret | |
| 408 | + | } | |
| 409 | + | ||
| 410 | + | var xStringVprintf func(uintptr, string, []interface{}) | |
| 411 | + | ||
| 412 | + | // Writes a formatted string into a #GString. | |
| 413 | + | // This function is similar to g_string_printf() except that | |
| 414 | + | // the arguments to the format string are passed as a va_list. | |
| 415 | + | func (x *String) Vprintf(FormatVar string, ArgsVar []interface{}) { | |
| 416 | + | ||
| 417 | + | xStringVprintf(x.GoPointer(), FormatVar, ArgsVar) | |
| 418 | + | ||
| 419 | + | } | |
| 420 | + | ||
| 421 | + | func init() { | |
| 422 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 423 | + | if err != nil { | |
| 424 | + | panic(err) | |
| 425 | + | } | |
| 426 | + | ||
| 427 | + | core.PuregoSafeRegister(&xNewString, lib, "g_string_new") | |
| 428 | + | core.PuregoSafeRegister(&xNewLenString, lib, "g_string_new_len") | |
| 429 | + | core.PuregoSafeRegister(&xSizedNewString, lib, "g_string_sized_new") | |
| 430 | + | ||
| 431 | + | core.PuregoSafeRegister(&xStringAppend, lib, "g_string_append") | |
| 432 | + | core.PuregoSafeRegister(&xStringAppendC, lib, "g_string_append_c") | |
| 433 | + | core.PuregoSafeRegister(&xStringAppendLen, lib, "g_string_append_len") | |
| 434 | + | core.PuregoSafeRegister(&xStringAppendPrintf, lib, "g_string_append_printf") | |
| 435 | + | core.PuregoSafeRegister(&xStringAppendUnichar, lib, "g_string_append_unichar") | |
| 436 | + | core.PuregoSafeRegister(&xStringAppendUriEscaped, lib, "g_string_append_uri_escaped") | |
| 437 | + | core.PuregoSafeRegister(&xStringAppendVprintf, lib, "g_string_append_vprintf") | |
| 438 | + | core.PuregoSafeRegister(&xStringAsciiDown, lib, "g_string_ascii_down") | |
| 439 | + | core.PuregoSafeRegister(&xStringAsciiUp, lib, "g_string_ascii_up") | |
| 440 | + | core.PuregoSafeRegister(&xStringAssign, lib, "g_string_assign") | |
| 441 | + | core.PuregoSafeRegister(&xStringDown, lib, "g_string_down") | |
| 442 | + | core.PuregoSafeRegister(&xStringEqual, lib, "g_string_equal") | |
| 443 | + | core.PuregoSafeRegister(&xStringErase, lib, "g_string_erase") | |
| 444 | + | core.PuregoSafeRegister(&xStringFree, lib, "g_string_free") | |
| 445 | + | core.PuregoSafeRegister(&xStringFreeToBytes, lib, "g_string_free_to_bytes") | |
| 446 | + | core.PuregoSafeRegister(&xStringHash, lib, "g_string_hash") | |
| 447 | + | core.PuregoSafeRegister(&xStringInsert, lib, "g_string_insert") | |
| 448 | + | core.PuregoSafeRegister(&xStringInsertC, lib, "g_string_insert_c") | |
| 449 | + | core.PuregoSafeRegister(&xStringInsertLen, lib, "g_string_insert_len") | |
| 450 | + | core.PuregoSafeRegister(&xStringInsertUnichar, lib, "g_string_insert_unichar") | |
| 451 | + | core.PuregoSafeRegister(&xStringOverwrite, lib, "g_string_overwrite") | |
| 452 | + | core.PuregoSafeRegister(&xStringOverwriteLen, lib, "g_string_overwrite_len") | |
| 453 | + | core.PuregoSafeRegister(&xStringPrepend, lib, "g_string_prepend") | |
| 454 | + | core.PuregoSafeRegister(&xStringPrependC, lib, "g_string_prepend_c") | |
| 455 | + | core.PuregoSafeRegister(&xStringPrependLen, lib, "g_string_prepend_len") | |
| 456 | + | core.PuregoSafeRegister(&xStringPrependUnichar, lib, "g_string_prepend_unichar") | |
| 457 | + | core.PuregoSafeRegister(&xStringPrintf, lib, "g_string_printf") | |
| 458 | + | core.PuregoSafeRegister(&xStringReplace, lib, "g_string_replace") | |
| 459 | + | core.PuregoSafeRegister(&xStringSetSize, lib, "g_string_set_size") | |
| 460 | + | core.PuregoSafeRegister(&xStringTruncate, lib, "g_string_truncate") | |
| 461 | + | core.PuregoSafeRegister(&xStringUp, lib, "g_string_up") | |
| 462 | + | core.PuregoSafeRegister(&xStringVprintf, lib, "g_string_vprintf") | |
| 463 | + | ||
| 464 | + | } | |
M v4/glib/gstringchunk.go +104 -0
| @@ -1,7 +1,111 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // An opaque data structure representing String Chunks. | |
| 5 | 12 | // It should only be accessed by using the following functions. | |
| 6 | 13 | type StringChunk struct { | |
| 7 | 14 | } | |
| 15 | + | ||
| 16 | + | func (x *StringChunk) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xStringChunkClear func(uintptr) | |
| 21 | + | ||
| 22 | + | // Frees all strings contained within the #GStringChunk. | |
| 23 | + | // After calling g_string_chunk_clear() it is not safe to | |
| 24 | + | // access any of the strings which were contained within it. | |
| 25 | + | func (x *StringChunk) Clear() { | |
| 26 | + | ||
| 27 | + | xStringChunkClear(x.GoPointer()) | |
| 28 | + | ||
| 29 | + | } | |
| 30 | + | ||
| 31 | + | var xStringChunkFree func(uintptr) | |
| 32 | + | ||
| 33 | + | // Frees all memory allocated by the #GStringChunk. | |
| 34 | + | // After calling g_string_chunk_free() it is not safe to | |
| 35 | + | // access any of the strings which were contained within it. | |
| 36 | + | func (x *StringChunk) Free() { | |
| 37 | + | ||
| 38 | + | xStringChunkFree(x.GoPointer()) | |
| 39 | + | ||
| 40 | + | } | |
| 41 | + | ||
| 42 | + | var xStringChunkInsert func(uintptr, string) string | |
| 43 | + | ||
| 44 | + | // Adds a copy of @string to the #GStringChunk. | |
| 45 | + | // It returns a pointer to the new copy of the string | |
| 46 | + | // in the #GStringChunk. The characters in the string | |
| 47 | + | // can be changed, if necessary, though you should not | |
| 48 | + | // change anything after the end of the string. | |
| 49 | + | // | |
| 50 | + | // Unlike g_string_chunk_insert_const(), this function | |
| 51 | + | // does not check for duplicates. Also strings added | |
| 52 | + | // with g_string_chunk_insert() will not be searched | |
| 53 | + | // by g_string_chunk_insert_const() when looking for | |
| 54 | + | // duplicates. | |
| 55 | + | func (x *StringChunk) Insert(StringVar string) string { | |
| 56 | + | ||
| 57 | + | cret := xStringChunkInsert(x.GoPointer(), StringVar) | |
| 58 | + | return cret | |
| 59 | + | } | |
| 60 | + | ||
| 61 | + | var xStringChunkInsertConst func(uintptr, string) string | |
| 62 | + | ||
| 63 | + | // Adds a copy of @string to the #GStringChunk, unless the same | |
| 64 | + | // string has already been added to the #GStringChunk with | |
| 65 | + | // g_string_chunk_insert_const(). | |
| 66 | + | // | |
| 67 | + | // This function is useful if you need to copy a large number | |
| 68 | + | // of strings but do not want to waste space storing duplicates. | |
| 69 | + | // But you must remember that there may be several pointers to | |
| 70 | + | // the same string, and so any changes made to the strings | |
| 71 | + | // should be done very carefully. | |
| 72 | + | // | |
| 73 | + | // Note that g_string_chunk_insert_const() will not return a | |
| 74 | + | // pointer to a string added with g_string_chunk_insert(), even | |
| 75 | + | // if they do match. | |
| 76 | + | func (x *StringChunk) InsertConst(StringVar string) string { | |
| 77 | + | ||
| 78 | + | cret := xStringChunkInsertConst(x.GoPointer(), StringVar) | |
| 79 | + | return cret | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | var xStringChunkInsertLen func(uintptr, string, int) string | |
| 83 | + | ||
| 84 | + | // Adds a copy of the first @len bytes of @string to the #GStringChunk. | |
| 85 | + | // The copy is nul-terminated. | |
| 86 | + | // | |
| 87 | + | // Since this function does not stop at nul bytes, it is the caller's | |
| 88 | + | // responsibility to ensure that @string has at least @len addressable | |
| 89 | + | // bytes. | |
| 90 | + | // | |
| 91 | + | // The characters in the returned string can be changed, if necessary, | |
| 92 | + | // though you should not change anything after the end of the string. | |
| 93 | + | func (x *StringChunk) InsertLen(StringVar string, LenVar int) string { | |
| 94 | + | ||
| 95 | + | cret := xStringChunkInsertLen(x.GoPointer(), StringVar, LenVar) | |
| 96 | + | return cret | |
| 97 | + | } | |
| 98 | + | ||
| 99 | + | func init() { | |
| 100 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 101 | + | if err != nil { | |
| 102 | + | panic(err) | |
| 103 | + | } | |
| 104 | + | ||
| 105 | + | core.PuregoSafeRegister(&xStringChunkClear, lib, "g_string_chunk_clear") | |
| 106 | + | core.PuregoSafeRegister(&xStringChunkFree, lib, "g_string_chunk_free") | |
| 107 | + | core.PuregoSafeRegister(&xStringChunkInsert, lib, "g_string_chunk_insert") | |
| 108 | + | core.PuregoSafeRegister(&xStringChunkInsertConst, lib, "g_string_chunk_insert_const") | |
| 109 | + | core.PuregoSafeRegister(&xStringChunkInsertLen, lib, "g_string_chunk_insert_len") | |
| 110 | + | ||
| 111 | + | } | |
M v4/glib/gstrvbuilder.go +92 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // #GStrvBuilder is a method of easily building dynamically sized | |
| 5 | 12 | // NULL-terminated string arrays. | |
| 6 | 13 | // | |
| @@ -16,3 +23,88 @@ package glib | |||
| 16 | 23 | // ]| | |
| 17 | 24 | type StrvBuilder struct { | |
| 18 | 25 | } | |
| 26 | + | ||
| 27 | + | func (x *StrvBuilder) GoPointer() uintptr { | |
| 28 | + | return uintptr(unsafe.Pointer(x)) | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | var xStrvBuilderAdd func(uintptr, string) | |
| 32 | + | ||
| 33 | + | // Add a string to the end of the array. | |
| 34 | + | // | |
| 35 | + | // Since 2.68 | |
| 36 | + | func (x *StrvBuilder) Add(ValueVar string) { | |
| 37 | + | ||
| 38 | + | xStrvBuilderAdd(x.GoPointer(), ValueVar) | |
| 39 | + | ||
| 40 | + | } | |
| 41 | + | ||
| 42 | + | var xStrvBuilderAddMany func(uintptr, ...interface{}) | |
| 43 | + | ||
| 44 | + | // Appends all the given strings to the builder. | |
| 45 | + | // | |
| 46 | + | // Since 2.70 | |
| 47 | + | func (x *StrvBuilder) AddMany(varArgs ...interface{}) { | |
| 48 | + | ||
| 49 | + | xStrvBuilderAddMany(x.GoPointer(), varArgs...) | |
| 50 | + | ||
| 51 | + | } | |
| 52 | + | ||
| 53 | + | var xStrvBuilderAddv func(uintptr, []string) | |
| 54 | + | ||
| 55 | + | // Appends all the strings in the given vector to the builder. | |
| 56 | + | // | |
| 57 | + | // Since 2.70 | |
| 58 | + | func (x *StrvBuilder) Addv(ValueVar []string) { | |
| 59 | + | ||
| 60 | + | xStrvBuilderAddv(x.GoPointer(), ValueVar) | |
| 61 | + | ||
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xStrvBuilderEnd func(uintptr) uintptr | |
| 65 | + | ||
| 66 | + | // Ends the builder process and returns the constructed NULL-terminated string | |
| 67 | + | // array. The returned value should be freed with g_strfreev() when no longer | |
| 68 | + | // needed. | |
| 69 | + | func (x *StrvBuilder) End() uintptr { | |
| 70 | + | ||
| 71 | + | cret := xStrvBuilderEnd(x.GoPointer()) | |
| 72 | + | return cret | |
| 73 | + | } | |
| 74 | + | ||
| 75 | + | var xStrvBuilderRef func(uintptr) *StrvBuilder | |
| 76 | + | ||
| 77 | + | // Atomically increments the reference count of @builder by one. | |
| 78 | + | // This function is thread-safe and may be called from any thread. | |
| 79 | + | func (x *StrvBuilder) Ref() *StrvBuilder { | |
| 80 | + | ||
| 81 | + | cret := xStrvBuilderRef(x.GoPointer()) | |
| 82 | + | return cret | |
| 83 | + | } | |
| 84 | + | ||
| 85 | + | var xStrvBuilderUnref func(uintptr) | |
| 86 | + | ||
| 87 | + | // Decreases the reference count on @builder. | |
| 88 | + | // | |
| 89 | + | // In the event that there are no more references, releases all memory | |
| 90 | + | // associated with the #GStrvBuilder. | |
| 91 | + | func (x *StrvBuilder) Unref() { | |
| 92 | + | ||
| 93 | + | xStrvBuilderUnref(x.GoPointer()) | |
| 94 | + | ||
| 95 | + | } | |
| 96 | + | ||
| 97 | + | func init() { | |
| 98 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 99 | + | if err != nil { | |
| 100 | + | panic(err) | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | core.PuregoSafeRegister(&xStrvBuilderAdd, lib, "g_strv_builder_add") | |
| 104 | + | core.PuregoSafeRegister(&xStrvBuilderAddMany, lib, "g_strv_builder_add_many") | |
| 105 | + | core.PuregoSafeRegister(&xStrvBuilderAddv, lib, "g_strv_builder_addv") | |
| 106 | + | core.PuregoSafeRegister(&xStrvBuilderEnd, lib, "g_strv_builder_end") | |
| 107 | + | core.PuregoSafeRegister(&xStrvBuilderRef, lib, "g_strv_builder_ref") | |
| 108 | + | core.PuregoSafeRegister(&xStrvBuilderUnref, lib, "g_strv_builder_unref") | |
| 109 | + | ||
| 110 | + | } | |
M v4/glib/gtestutils.go +133 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -32,6 +34,19 @@ type TestLogFatalFunc func(string, LogLevelFlags, string, uintptr) bool | |||
| 32 | 34 | type TestCase struct { | |
| 33 | 35 | } | |
| 34 | 36 | ||
| 37 | + | func (x *TestCase) GoPointer() uintptr { | |
| 38 | + | return uintptr(unsafe.Pointer(x)) | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | var xTestCaseFree func(uintptr) | |
| 42 | + | ||
| 43 | + | // Free the @test_case. | |
| 44 | + | func (x *TestCase) Free() { | |
| 45 | + | ||
| 46 | + | xTestCaseFree(x.GoPointer()) | |
| 47 | + | ||
| 48 | + | } | |
| 49 | + | ||
| 35 | 50 | type TestConfig struct { | |
| 36 | 51 | TestInitialized bool | |
| 37 | 52 | ||
| @@ -46,12 +61,47 @@ type TestConfig struct { | |||
| 46 | 61 | TestUndefined bool | |
| 47 | 62 | } | |
| 48 | 63 | ||
| 64 | + | func (x *TestConfig) GoPointer() uintptr { | |
| 65 | + | return uintptr(unsafe.Pointer(x)) | |
| 66 | + | } | |
| 67 | + | ||
| 49 | 68 | type TestLogBuffer struct { | |
| 50 | 69 | Data *String | |
| 51 | 70 | ||
| 52 | 71 | Msgs *SList | |
| 53 | 72 | } | |
| 54 | 73 | ||
| 74 | + | func (x *TestLogBuffer) GoPointer() uintptr { | |
| 75 | + | return uintptr(unsafe.Pointer(x)) | |
| 76 | + | } | |
| 77 | + | ||
| 78 | + | var xTestLogBufferFree func(uintptr) | |
| 79 | + | ||
| 80 | + | // Internal function for gtester to free test log messages, no ABI guarantees provided. | |
| 81 | + | func (x *TestLogBuffer) Free() { | |
| 82 | + | ||
| 83 | + | xTestLogBufferFree(x.GoPointer()) | |
| 84 | + | ||
| 85 | + | } | |
| 86 | + | ||
| 87 | + | var xTestLogBufferPop func(uintptr) *TestLogMsg | |
| 88 | + | ||
| 89 | + | // Internal function for gtester to retrieve test log messages, no ABI guarantees provided. | |
| 90 | + | func (x *TestLogBuffer) Pop() *TestLogMsg { | |
| 91 | + | ||
| 92 | + | cret := xTestLogBufferPop(x.GoPointer()) | |
| 93 | + | return cret | |
| 94 | + | } | |
| 95 | + | ||
| 96 | + | var xTestLogBufferPush func(uintptr, uint, byte) | |
| 97 | + | ||
| 98 | + | // Internal function for gtester to decode test log messages, no ABI guarantees provided. | |
| 99 | + | func (x *TestLogBuffer) Push(NBytesVar uint, BytesVar byte) { | |
| 100 | + | ||
| 101 | + | xTestLogBufferPush(x.GoPointer(), NBytesVar, BytesVar) | |
| 102 | + | ||
| 103 | + | } | |
| 104 | + | ||
| 55 | 105 | type TestLogMsg struct { | |
| 56 | 106 | LogType TestLogType | |
| 57 | 107 | ||
| @@ -64,10 +114,81 @@ type TestLogMsg struct { | |||
| 64 | 114 | Nums float64 | |
| 65 | 115 | } | |
| 66 | 116 | ||
| 117 | + | func (x *TestLogMsg) GoPointer() uintptr { | |
| 118 | + | return uintptr(unsafe.Pointer(x)) | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | var xTestLogMsgFree func(uintptr) | |
| 122 | + | ||
| 123 | + | // Internal function for gtester to free test log messages, no ABI guarantees provided. | |
| 124 | + | func (x *TestLogMsg) Free() { | |
| 125 | + | ||
| 126 | + | xTestLogMsgFree(x.GoPointer()) | |
| 127 | + | ||
| 128 | + | } | |
| 129 | + | ||
| 67 | 130 | // An opaque structure representing a test suite. | |
| 68 | 131 | type TestSuite struct { | |
| 69 | 132 | } | |
| 70 | 133 | ||
| 134 | + | func (x *TestSuite) GoPointer() uintptr { | |
| 135 | + | return uintptr(unsafe.Pointer(x)) | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xTestSuiteAdd func(uintptr, *TestCase) | |
| 139 | + | ||
| 140 | + | // Adds @test_case to @suite. | |
| 141 | + | func (x *TestSuite) Add(TestCaseVar *TestCase) { | |
| 142 | + | ||
| 143 | + | xTestSuiteAdd(x.GoPointer(), TestCaseVar) | |
| 144 | + | ||
| 145 | + | } | |
| 146 | + | ||
| 147 | + | var xTestSuiteAddSuite func(uintptr, *TestSuite) | |
| 148 | + | ||
| 149 | + | // Adds @nestedsuite to @suite. | |
| 150 | + | func (x *TestSuite) AddSuite(NestedsuiteVar *TestSuite) { | |
| 151 | + | ||
| 152 | + | xTestSuiteAddSuite(x.GoPointer(), NestedsuiteVar) | |
| 153 | + | ||
| 154 | + | } | |
| 155 | + | ||
| 156 | + | var xTestSuiteFree func(uintptr) | |
| 157 | + | ||
| 158 | + | // Free the @suite and all nested #GTestSuites. | |
| 159 | + | func (x *TestSuite) Free() { | |
| 160 | + | ||
| 161 | + | xTestSuiteFree(x.GoPointer()) | |
| 162 | + | ||
| 163 | + | } | |
| 164 | + | ||
| 165 | + | const ( | |
| 166 | + | // Creates a unique temporary directory for each unit test and uses | |
| 167 | + | // g_set_user_dirs() to set XDG directories to point into subdirectories of it | |
| 168 | + | // for the duration of the unit test. The directory tree is cleaned up after the | |
| 169 | + | // test finishes successfully. Note that this doesn’t take effect until | |
| 170 | + | // g_test_run() is called, so calls to (for example) g_get_user_home_dir() will | |
| 171 | + | // return the system-wide value when made in a test program’s main() function. | |
| 172 | + | // | |
| 173 | + | // The following functions will return subdirectories of the temporary directory | |
| 174 | + | // when this option is used. The specific subdirectory paths in use are not | |
| 175 | + | // guaranteed to be stable API — always use a getter function to retrieve them. | |
| 176 | + | // | |
| 177 | + | // - g_get_home_dir() | |
| 178 | + | // - g_get_user_cache_dir() | |
| 179 | + | // - g_get_system_config_dirs() | |
| 180 | + | // - g_get_user_config_dir() | |
| 181 | + | // - g_get_system_data_dirs() | |
| 182 | + | // - g_get_user_data_dir() | |
| 183 | + | // - g_get_user_state_dir() | |
| 184 | + | // - g_get_user_runtime_dir() | |
| 185 | + | // | |
| 186 | + | // The subdirectories may not be created by the test harness; as with normal | |
| 187 | + | // calls to functions like g_get_user_cache_dir(), the caller must be prepared | |
| 188 | + | // to create the directory if it doesn’t exist. | |
| 189 | + | TEST_OPTION_ISOLATE_DIRS string = "isolate_dirs" | |
| 190 | + | ) | |
| 191 | + | ||
| 71 | 192 | // Flags to pass to g_test_trap_subprocess() to control input and output. | |
| 72 | 193 | // | |
| 73 | 194 | // Note that in contrast with g_test_trap_fork(), the default is to | |
| @@ -1161,4 +1282,16 @@ func init() { | |||
| 1161 | 1282 | core.PuregoSafeRegister(&xTestTrapReachedTimeout, lib, "g_test_trap_reached_timeout") | |
| 1162 | 1283 | core.PuregoSafeRegister(&xTestTrapSubprocess, lib, "g_test_trap_subprocess") | |
| 1163 | 1284 | ||
| 1285 | + | core.PuregoSafeRegister(&xTestCaseFree, lib, "g_test_case_free") | |
| 1286 | + | ||
| 1287 | + | core.PuregoSafeRegister(&xTestLogBufferFree, lib, "g_test_log_buffer_free") | |
| 1288 | + | core.PuregoSafeRegister(&xTestLogBufferPop, lib, "g_test_log_buffer_pop") | |
| 1289 | + | core.PuregoSafeRegister(&xTestLogBufferPush, lib, "g_test_log_buffer_push") | |
| 1290 | + | ||
| 1291 | + | core.PuregoSafeRegister(&xTestLogMsgFree, lib, "g_test_log_msg_free") | |
| 1292 | + | ||
| 1293 | + | core.PuregoSafeRegister(&xTestSuiteAdd, lib, "g_test_suite_add") | |
| 1294 | + | core.PuregoSafeRegister(&xTestSuiteAddSuite, lib, "g_test_suite_add_suite") | |
| 1295 | + | core.PuregoSafeRegister(&xTestSuiteFree, lib, "g_test_suite_free") | |
| 1296 | + | ||
| 1164 | 1297 | } | |
M v4/glib/gthread.go +573 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -83,6 +85,148 @@ type Cond struct { | |||
| 83 | 85 | I uintptr | |
| 84 | 86 | } | |
| 85 | 87 | ||
| 88 | + | func (x *Cond) GoPointer() uintptr { | |
| 89 | + | return uintptr(unsafe.Pointer(x)) | |
| 90 | + | } | |
| 91 | + | ||
| 92 | + | var xCondBroadcast func(uintptr) | |
| 93 | + | ||
| 94 | + | // If threads are waiting for @cond, all of them are unblocked. | |
| 95 | + | // If no threads are waiting for @cond, this function has no effect. | |
| 96 | + | // It is good practice to lock the same mutex as the waiting threads | |
| 97 | + | // while calling this function, though not required. | |
| 98 | + | func (x *Cond) Broadcast() { | |
| 99 | + | ||
| 100 | + | xCondBroadcast(x.GoPointer()) | |
| 101 | + | ||
| 102 | + | } | |
| 103 | + | ||
| 104 | + | var xCondClear func(uintptr) | |
| 105 | + | ||
| 106 | + | // Frees the resources allocated to a #GCond with g_cond_init(). | |
| 107 | + | // | |
| 108 | + | // This function should not be used with a #GCond that has been | |
| 109 | + | // statically allocated. | |
| 110 | + | // | |
| 111 | + | // Calling g_cond_clear() for a #GCond on which threads are | |
| 112 | + | // blocking leads to undefined behaviour. | |
| 113 | + | func (x *Cond) Clear() { | |
| 114 | + | ||
| 115 | + | xCondClear(x.GoPointer()) | |
| 116 | + | ||
| 117 | + | } | |
| 118 | + | ||
| 119 | + | var xCondInit func(uintptr) | |
| 120 | + | ||
| 121 | + | // Initialises a #GCond so that it can be used. | |
| 122 | + | // | |
| 123 | + | // This function is useful to initialise a #GCond that has been | |
| 124 | + | // allocated as part of a larger structure. It is not necessary to | |
| 125 | + | // initialise a #GCond that has been statically allocated. | |
| 126 | + | // | |
| 127 | + | // To undo the effect of g_cond_init() when a #GCond is no longer | |
| 128 | + | // needed, use g_cond_clear(). | |
| 129 | + | // | |
| 130 | + | // Calling g_cond_init() on an already-initialised #GCond leads | |
| 131 | + | // to undefined behaviour. | |
| 132 | + | func (x *Cond) Init() { | |
| 133 | + | ||
| 134 | + | xCondInit(x.GoPointer()) | |
| 135 | + | ||
| 136 | + | } | |
| 137 | + | ||
| 138 | + | var xCondSignal func(uintptr) | |
| 139 | + | ||
| 140 | + | // If threads are waiting for @cond, at least one of them is unblocked. | |
| 141 | + | // If no threads are waiting for @cond, this function has no effect. | |
| 142 | + | // It is good practice to hold the same lock as the waiting thread | |
| 143 | + | // while calling this function, though not required. | |
| 144 | + | func (x *Cond) Signal() { | |
| 145 | + | ||
| 146 | + | xCondSignal(x.GoPointer()) | |
| 147 | + | ||
| 148 | + | } | |
| 149 | + | ||
| 150 | + | var xCondWait func(uintptr, *Mutex) | |
| 151 | + | ||
| 152 | + | // Atomically releases @mutex and waits until @cond is signalled. | |
| 153 | + | // When this function returns, @mutex is locked again and owned by the | |
| 154 | + | // calling thread. | |
| 155 | + | // | |
| 156 | + | // When using condition variables, it is possible that a spurious wakeup | |
| 157 | + | // may occur (ie: g_cond_wait() returns even though g_cond_signal() was | |
| 158 | + | // not called). It's also possible that a stolen wakeup may occur. | |
| 159 | + | // This is when g_cond_signal() is called, but another thread acquires | |
| 160 | + | // @mutex before this thread and modifies the state of the program in | |
| 161 | + | // such a way that when g_cond_wait() is able to return, the expected | |
| 162 | + | // condition is no longer met. | |
| 163 | + | // | |
| 164 | + | // For this reason, g_cond_wait() must always be used in a loop. See | |
| 165 | + | // the documentation for #GCond for a complete example. | |
| 166 | + | func (x *Cond) Wait(MutexVar *Mutex) { | |
| 167 | + | ||
| 168 | + | xCondWait(x.GoPointer(), MutexVar) | |
| 169 | + | ||
| 170 | + | } | |
| 171 | + | ||
| 172 | + | var xCondWaitUntil func(uintptr, *Mutex, int64) bool | |
| 173 | + | ||
| 174 | + | // Waits until either @cond is signalled or @end_time has passed. | |
| 175 | + | // | |
| 176 | + | // As with g_cond_wait() it is possible that a spurious or stolen wakeup | |
| 177 | + | // could occur. For that reason, waiting on a condition variable should | |
| 178 | + | // always be in a loop, based on an explicitly-checked predicate. | |
| 179 | + | // | |
| 180 | + | // %TRUE is returned if the condition variable was signalled (or in the | |
| 181 | + | // case of a spurious wakeup). %FALSE is returned if @end_time has | |
| 182 | + | // passed. | |
| 183 | + | // | |
| 184 | + | // The following code shows how to correctly perform a timed wait on a | |
| 185 | + | // condition variable (extending the example presented in the | |
| 186 | + | // documentation for #GCond): | |
| 187 | + | // | |
| 188 | + | // |[<!-- language="C" --> | |
| 189 | + | // gpointer | |
| 190 | + | // pop_data_timed (void) | |
| 191 | + | // | |
| 192 | + | // { | |
| 193 | + | // gint64 end_time; | |
| 194 | + | // gpointer data; | |
| 195 | + | // | |
| 196 | + | // g_mutex_lock (&data_mutex); | |
| 197 | + | // | |
| 198 | + | // end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND; | |
| 199 | + | // while (!current_data) | |
| 200 | + | // if (!g_cond_wait_until (&data_cond, &data_mutex, end_time)) | |
| 201 | + | // { | |
| 202 | + | // // timeout has passed. | |
| 203 | + | // g_mutex_unlock (&data_mutex); | |
| 204 | + | // return NULL; | |
| 205 | + | // } | |
| 206 | + | // | |
| 207 | + | // // there is data for us | |
| 208 | + | // data = current_data; | |
| 209 | + | // current_data = NULL; | |
| 210 | + | // | |
| 211 | + | // g_mutex_unlock (&data_mutex); | |
| 212 | + | // | |
| 213 | + | // return data; | |
| 214 | + | // } | |
| 215 | + | // | |
| 216 | + | // ]| | |
| 217 | + | // | |
| 218 | + | // Notice that the end time is calculated once, before entering the | |
| 219 | + | // loop and reused. This is the motivation behind the use of absolute | |
| 220 | + | // time on this API -- if a relative time of 5 seconds were passed | |
| 221 | + | // directly to the call and a spurious wakeup occurred, the program would | |
| 222 | + | // have to start over waiting again (which would lead to a total wait | |
| 223 | + | // time of more than 5 seconds). | |
| 224 | + | func (x *Cond) WaitUntil(MutexVar *Mutex, EndTimeVar int64) bool { | |
| 225 | + | ||
| 226 | + | cret := xCondWaitUntil(x.GoPointer(), MutexVar, EndTimeVar) | |
| 227 | + | return cret | |
| 228 | + | } | |
| 229 | + | ||
| 86 | 230 | // A #GOnce struct controls a one-time initialization function. Any | |
| 87 | 231 | // one-time initialization function must have its own unique #GOnce | |
| 88 | 232 | // struct. | |
| @@ -92,6 +236,18 @@ type Once struct { | |||
| 92 | 236 | Retval uintptr | |
| 93 | 237 | } | |
| 94 | 238 | ||
| 239 | + | func (x *Once) GoPointer() uintptr { | |
| 240 | + | return uintptr(unsafe.Pointer(x)) | |
| 241 | + | } | |
| 242 | + | ||
| 243 | + | var xOnceImpl func(uintptr, uintptr, uintptr) uintptr | |
| 244 | + | ||
| 245 | + | func (x *Once) Impl(FuncVar ThreadFunc, ArgVar uintptr) uintptr { | |
| 246 | + | ||
| 247 | + | cret := xOnceImpl(x.GoPointer(), purego.NewCallback(FuncVar), ArgVar) | |
| 248 | + | return cret | |
| 249 | + | } | |
| 250 | + | ||
| 95 | 251 | // The #GPrivate struct is an opaque data structure to represent a | |
| 96 | 252 | // thread-local data key. It is approximately equivalent to the | |
| 97 | 253 | // pthread_setspecific()/pthread_getspecific() APIs on POSIX and to | |
| @@ -117,6 +273,50 @@ type Private struct { | |||
| 117 | 273 | Future uintptr | |
| 118 | 274 | } | |
| 119 | 275 | ||
| 276 | + | func (x *Private) GoPointer() uintptr { | |
| 277 | + | return uintptr(unsafe.Pointer(x)) | |
| 278 | + | } | |
| 279 | + | ||
| 280 | + | var xPrivateGet func(uintptr) uintptr | |
| 281 | + | ||
| 282 | + | // Returns the current value of the thread local variable @key. | |
| 283 | + | // | |
| 284 | + | // If the value has not yet been set in this thread, %NULL is returned. | |
| 285 | + | // Values are never copied between threads (when a new thread is | |
| 286 | + | // created, for example). | |
| 287 | + | func (x *Private) Get() uintptr { | |
| 288 | + | ||
| 289 | + | cret := xPrivateGet(x.GoPointer()) | |
| 290 | + | return cret | |
| 291 | + | } | |
| 292 | + | ||
| 293 | + | var xPrivateReplace func(uintptr, uintptr) | |
| 294 | + | ||
| 295 | + | // Sets the thread local variable @key to have the value @value in the | |
| 296 | + | // current thread. | |
| 297 | + | // | |
| 298 | + | // This function differs from g_private_set() in the following way: if | |
| 299 | + | // the previous value was non-%NULL then the #GDestroyNotify handler for | |
| 300 | + | // @key is run on it. | |
| 301 | + | func (x *Private) Replace(ValueVar uintptr) { | |
| 302 | + | ||
| 303 | + | xPrivateReplace(x.GoPointer(), ValueVar) | |
| 304 | + | ||
| 305 | + | } | |
| 306 | + | ||
| 307 | + | var xPrivateSet func(uintptr, uintptr) | |
| 308 | + | ||
| 309 | + | // Sets the thread local variable @key to have the value @value in the | |
| 310 | + | // current thread. | |
| 311 | + | // | |
| 312 | + | // This function differs from g_private_replace() in the following way: | |
| 313 | + | // the #GDestroyNotify for @key is not called on the old value. | |
| 314 | + | func (x *Private) Set(ValueVar uintptr) { | |
| 315 | + | ||
| 316 | + | xPrivateSet(x.GoPointer(), ValueVar) | |
| 317 | + | ||
| 318 | + | } | |
| 319 | + | ||
| 120 | 320 | // The GRWLock struct is an opaque data structure to represent a | |
| 121 | 321 | // reader-writer lock. It is similar to a #GMutex in that it allows | |
| 122 | 322 | // multiple threads to coordinate access to a shared resource. | |
| @@ -188,6 +388,144 @@ type RWLock struct { | |||
| 188 | 388 | I uintptr | |
| 189 | 389 | } | |
| 190 | 390 | ||
| 391 | + | func (x *RWLock) GoPointer() uintptr { | |
| 392 | + | return uintptr(unsafe.Pointer(x)) | |
| 393 | + | } | |
| 394 | + | ||
| 395 | + | var xRWLockClear func(uintptr) | |
| 396 | + | ||
| 397 | + | // Frees the resources allocated to a lock with g_rw_lock_init(). | |
| 398 | + | // | |
| 399 | + | // This function should not be used with a #GRWLock that has been | |
| 400 | + | // statically allocated. | |
| 401 | + | // | |
| 402 | + | // Calling g_rw_lock_clear() when any thread holds the lock | |
| 403 | + | // leads to undefined behaviour. | |
| 404 | + | // | |
| 405 | + | // Sine: 2.32 | |
| 406 | + | func (x *RWLock) Clear() { | |
| 407 | + | ||
| 408 | + | xRWLockClear(x.GoPointer()) | |
| 409 | + | ||
| 410 | + | } | |
| 411 | + | ||
| 412 | + | var xRWLockInit func(uintptr) | |
| 413 | + | ||
| 414 | + | // Initializes a #GRWLock so that it can be used. | |
| 415 | + | // | |
| 416 | + | // This function is useful to initialize a lock that has been | |
| 417 | + | // allocated on the stack, or as part of a larger structure. It is not | |
| 418 | + | // necessary to initialise a reader-writer lock that has been statically | |
| 419 | + | // allocated. | |
| 420 | + | // | |
| 421 | + | // |[<!-- language="C" --> | |
| 422 | + | // | |
| 423 | + | // typedef struct { | |
| 424 | + | // GRWLock l; | |
| 425 | + | // ... | |
| 426 | + | // } Blob; | |
| 427 | + | // | |
| 428 | + | // Blob *b; | |
| 429 | + | // | |
| 430 | + | // b = g_new (Blob, 1); | |
| 431 | + | // g_rw_lock_init (&b->l); | |
| 432 | + | // ]| | |
| 433 | + | // | |
| 434 | + | // To undo the effect of g_rw_lock_init() when a lock is no longer | |
| 435 | + | // needed, use g_rw_lock_clear(). | |
| 436 | + | // | |
| 437 | + | // Calling g_rw_lock_init() on an already initialized #GRWLock leads | |
| 438 | + | // to undefined behaviour. | |
| 439 | + | func (x *RWLock) Init() { | |
| 440 | + | ||
| 441 | + | xRWLockInit(x.GoPointer()) | |
| 442 | + | ||
| 443 | + | } | |
| 444 | + | ||
| 445 | + | var xRWLockReaderLock func(uintptr) | |
| 446 | + | ||
| 447 | + | // Obtain a read lock on @rw_lock. If another thread currently holds | |
| 448 | + | // the write lock on @rw_lock, the current thread will block until the | |
| 449 | + | // write lock was (held and) released. If another thread does not hold | |
| 450 | + | // the write lock, but is waiting for it, it is implementation defined | |
| 451 | + | // whether the reader or writer will block. Read locks can be taken | |
| 452 | + | // recursively. | |
| 453 | + | // | |
| 454 | + | // Calling g_rw_lock_reader_lock() while the current thread already | |
| 455 | + | // owns a write lock leads to undefined behaviour. Read locks however | |
| 456 | + | // can be taken recursively, in which case you need to make sure to | |
| 457 | + | // call g_rw_lock_reader_unlock() the same amount of times. | |
| 458 | + | // | |
| 459 | + | // It is implementation-defined how many read locks are allowed to be | |
| 460 | + | // held on the same lock simultaneously. If the limit is hit, | |
| 461 | + | // or if a deadlock is detected, a critical warning will be emitted. | |
| 462 | + | func (x *RWLock) ReaderLock() { | |
| 463 | + | ||
| 464 | + | xRWLockReaderLock(x.GoPointer()) | |
| 465 | + | ||
| 466 | + | } | |
| 467 | + | ||
| 468 | + | var xRWLockReaderTrylock func(uintptr) bool | |
| 469 | + | ||
| 470 | + | // Tries to obtain a read lock on @rw_lock and returns %TRUE if | |
| 471 | + | // the read lock was successfully obtained. Otherwise it | |
| 472 | + | // returns %FALSE. | |
| 473 | + | func (x *RWLock) ReaderTrylock() bool { | |
| 474 | + | ||
| 475 | + | cret := xRWLockReaderTrylock(x.GoPointer()) | |
| 476 | + | return cret | |
| 477 | + | } | |
| 478 | + | ||
| 479 | + | var xRWLockReaderUnlock func(uintptr) | |
| 480 | + | ||
| 481 | + | // Release a read lock on @rw_lock. | |
| 482 | + | // | |
| 483 | + | // Calling g_rw_lock_reader_unlock() on a lock that is not held | |
| 484 | + | // by the current thread leads to undefined behaviour. | |
| 485 | + | func (x *RWLock) ReaderUnlock() { | |
| 486 | + | ||
| 487 | + | xRWLockReaderUnlock(x.GoPointer()) | |
| 488 | + | ||
| 489 | + | } | |
| 490 | + | ||
| 491 | + | var xRWLockWriterLock func(uintptr) | |
| 492 | + | ||
| 493 | + | // Obtain a write lock on @rw_lock. If another thread currently holds | |
| 494 | + | // a read or write lock on @rw_lock, the current thread will block | |
| 495 | + | // until all other threads have dropped their locks on @rw_lock. | |
| 496 | + | // | |
| 497 | + | // Calling g_rw_lock_writer_lock() while the current thread already | |
| 498 | + | // owns a read or write lock on @rw_lock leads to undefined behaviour. | |
| 499 | + | func (x *RWLock) WriterLock() { | |
| 500 | + | ||
| 501 | + | xRWLockWriterLock(x.GoPointer()) | |
| 502 | + | ||
| 503 | + | } | |
| 504 | + | ||
| 505 | + | var xRWLockWriterTrylock func(uintptr) bool | |
| 506 | + | ||
| 507 | + | // Tries to obtain a write lock on @rw_lock. If another thread | |
| 508 | + | // currently holds a read or write lock on @rw_lock, it immediately | |
| 509 | + | // returns %FALSE. | |
| 510 | + | // Otherwise it locks @rw_lock and returns %TRUE. | |
| 511 | + | func (x *RWLock) WriterTrylock() bool { | |
| 512 | + | ||
| 513 | + | cret := xRWLockWriterTrylock(x.GoPointer()) | |
| 514 | + | return cret | |
| 515 | + | } | |
| 516 | + | ||
| 517 | + | var xRWLockWriterUnlock func(uintptr) | |
| 518 | + | ||
| 519 | + | // Release a write lock on @rw_lock. | |
| 520 | + | // | |
| 521 | + | // Calling g_rw_lock_writer_unlock() on a lock that is not held | |
| 522 | + | // by the current thread leads to undefined behaviour. | |
| 523 | + | func (x *RWLock) WriterUnlock() { | |
| 524 | + | ||
| 525 | + | xRWLockWriterUnlock(x.GoPointer()) | |
| 526 | + | ||
| 527 | + | } | |
| 528 | + | ||
| 191 | 529 | // The GRecMutex struct is an opaque data structure to represent a | |
| 192 | 530 | // recursive mutex. It is similar to a #GMutex with the difference | |
| 193 | 531 | // that it is possible to lock a GRecMutex multiple times in the same | |
| @@ -206,6 +544,102 @@ type RecMutex struct { | |||
| 206 | 544 | I uintptr | |
| 207 | 545 | } | |
| 208 | 546 | ||
| 547 | + | func (x *RecMutex) GoPointer() uintptr { | |
| 548 | + | return uintptr(unsafe.Pointer(x)) | |
| 549 | + | } | |
| 550 | + | ||
| 551 | + | var xRecMutexClear func(uintptr) | |
| 552 | + | ||
| 553 | + | // Frees the resources allocated to a recursive mutex with | |
| 554 | + | // g_rec_mutex_init(). | |
| 555 | + | // | |
| 556 | + | // This function should not be used with a #GRecMutex that has been | |
| 557 | + | // statically allocated. | |
| 558 | + | // | |
| 559 | + | // Calling g_rec_mutex_clear() on a locked recursive mutex leads | |
| 560 | + | // to undefined behaviour. | |
| 561 | + | // | |
| 562 | + | // Sine: 2.32 | |
| 563 | + | func (x *RecMutex) Clear() { | |
| 564 | + | ||
| 565 | + | xRecMutexClear(x.GoPointer()) | |
| 566 | + | ||
| 567 | + | } | |
| 568 | + | ||
| 569 | + | var xRecMutexInit func(uintptr) | |
| 570 | + | ||
| 571 | + | // Initializes a #GRecMutex so that it can be used. | |
| 572 | + | // | |
| 573 | + | // This function is useful to initialize a recursive mutex | |
| 574 | + | // that has been allocated on the stack, or as part of a larger | |
| 575 | + | // structure. | |
| 576 | + | // | |
| 577 | + | // It is not necessary to initialise a recursive mutex that has been | |
| 578 | + | // statically allocated. | |
| 579 | + | // | |
| 580 | + | // |[<!-- language="C" --> | |
| 581 | + | // | |
| 582 | + | // typedef struct { | |
| 583 | + | // GRecMutex m; | |
| 584 | + | // ... | |
| 585 | + | // } Blob; | |
| 586 | + | // | |
| 587 | + | // Blob *b; | |
| 588 | + | // | |
| 589 | + | // b = g_new (Blob, 1); | |
| 590 | + | // g_rec_mutex_init (&b->m); | |
| 591 | + | // ]| | |
| 592 | + | // | |
| 593 | + | // Calling g_rec_mutex_init() on an already initialized #GRecMutex | |
| 594 | + | // leads to undefined behaviour. | |
| 595 | + | // | |
| 596 | + | // To undo the effect of g_rec_mutex_init() when a recursive mutex | |
| 597 | + | // is no longer needed, use g_rec_mutex_clear(). | |
| 598 | + | func (x *RecMutex) Init() { | |
| 599 | + | ||
| 600 | + | xRecMutexInit(x.GoPointer()) | |
| 601 | + | ||
| 602 | + | } | |
| 603 | + | ||
| 604 | + | var xRecMutexLock func(uintptr) | |
| 605 | + | ||
| 606 | + | // Locks @rec_mutex. If @rec_mutex is already locked by another | |
| 607 | + | // thread, the current thread will block until @rec_mutex is | |
| 608 | + | // unlocked by the other thread. If @rec_mutex is already locked | |
| 609 | + | // by the current thread, the 'lock count' of @rec_mutex is increased. | |
| 610 | + | // The mutex will only become available again when it is unlocked | |
| 611 | + | // as many times as it has been locked. | |
| 612 | + | func (x *RecMutex) Lock() { | |
| 613 | + | ||
| 614 | + | xRecMutexLock(x.GoPointer()) | |
| 615 | + | ||
| 616 | + | } | |
| 617 | + | ||
| 618 | + | var xRecMutexTrylock func(uintptr) bool | |
| 619 | + | ||
| 620 | + | // Tries to lock @rec_mutex. If @rec_mutex is already locked | |
| 621 | + | // by another thread, it immediately returns %FALSE. Otherwise | |
| 622 | + | // it locks @rec_mutex and returns %TRUE. | |
| 623 | + | func (x *RecMutex) Trylock() bool { | |
| 624 | + | ||
| 625 | + | cret := xRecMutexTrylock(x.GoPointer()) | |
| 626 | + | return cret | |
| 627 | + | } | |
| 628 | + | ||
| 629 | + | var xRecMutexUnlock func(uintptr) | |
| 630 | + | ||
| 631 | + | // Unlocks @rec_mutex. If another thread is blocked in a | |
| 632 | + | // g_rec_mutex_lock() call for @rec_mutex, it will become unblocked | |
| 633 | + | // and can lock @rec_mutex itself. | |
| 634 | + | // | |
| 635 | + | // Calling g_rec_mutex_unlock() on a recursive mutex that is not | |
| 636 | + | // locked by the current thread leads to undefined behaviour. | |
| 637 | + | func (x *RecMutex) Unlock() { | |
| 638 | + | ||
| 639 | + | xRecMutexUnlock(x.GoPointer()) | |
| 640 | + | ||
| 641 | + | } | |
| 642 | + | ||
| 209 | 643 | // The #GThread struct represents a running thread. This struct | |
| 210 | 644 | // is returned by g_thread_new() or g_thread_try_new(). You can | |
| 211 | 645 | // obtain the #GThread struct representing the current thread by | |
| @@ -222,6 +656,110 @@ type RecMutex struct { | |||
| 222 | 656 | type Thread struct { | |
| 223 | 657 | } | |
| 224 | 658 | ||
| 659 | + | func (x *Thread) GoPointer() uintptr { | |
| 660 | + | return uintptr(unsafe.Pointer(x)) | |
| 661 | + | } | |
| 662 | + | ||
| 663 | + | var xNewThread func(string, uintptr, uintptr) *Thread | |
| 664 | + | ||
| 665 | + | // This function creates a new thread. The new thread starts by invoking | |
| 666 | + | // @func with the argument data. The thread will run until @func returns | |
| 667 | + | // or until g_thread_exit() is called from the new thread. The return value | |
| 668 | + | // of @func becomes the return value of the thread, which can be obtained | |
| 669 | + | // with g_thread_join(). | |
| 670 | + | // | |
| 671 | + | // The @name can be useful for discriminating threads in a debugger. | |
| 672 | + | // It is not used for other purposes and does not have to be unique. | |
| 673 | + | // Some systems restrict the length of @name to 16 bytes. | |
| 674 | + | // | |
| 675 | + | // If the thread can not be created the program aborts. See | |
| 676 | + | // g_thread_try_new() if you want to attempt to deal with failures. | |
| 677 | + | // | |
| 678 | + | // If you are using threads to offload (potentially many) short-lived tasks, | |
| 679 | + | // #GThreadPool may be more appropriate than manually spawning and tracking | |
| 680 | + | // multiple #GThreads. | |
| 681 | + | // | |
| 682 | + | // To free the struct returned by this function, use g_thread_unref(). | |
| 683 | + | // Note that g_thread_join() implicitly unrefs the #GThread as well. | |
| 684 | + | // | |
| 685 | + | // New threads by default inherit their scheduler policy (POSIX) or thread | |
| 686 | + | // priority (Windows) of the thread creating the new thread. | |
| 687 | + | // | |
| 688 | + | // This behaviour changed in GLib 2.64: before threads on Windows were not | |
| 689 | + | // inheriting the thread priority but were spawned with the default priority. | |
| 690 | + | // Starting with GLib 2.64 the behaviour is now consistent between Windows and | |
| 691 | + | // POSIX and all threads inherit their parent thread's priority. | |
| 692 | + | func NewThread(NameVar string, FuncVar ThreadFunc, DataVar uintptr) *Thread { | |
| 693 | + | ||
| 694 | + | cret := xNewThread(NameVar, purego.NewCallback(FuncVar), DataVar) | |
| 695 | + | return cret | |
| 696 | + | } | |
| 697 | + | ||
| 698 | + | var xTryNewThread func(string, uintptr, uintptr, **Error) *Thread | |
| 699 | + | ||
| 700 | + | // This function is the same as g_thread_new() except that | |
| 701 | + | // it allows for the possibility of failure. | |
| 702 | + | // | |
| 703 | + | // If a thread can not be created (due to resource limits), | |
| 704 | + | // @error is set and %NULL is returned. | |
| 705 | + | func TryNewThread(NameVar string, FuncVar ThreadFunc, DataVar uintptr) (*Thread, error) { | |
| 706 | + | var cerr *Error | |
| 707 | + | ||
| 708 | + | cret := xTryNewThread(NameVar, purego.NewCallback(FuncVar), DataVar, &cerr) | |
| 709 | + | if cerr == nil { | |
| 710 | + | return cret, nil | |
| 711 | + | } | |
| 712 | + | return cret, cerr | |
| 713 | + | ||
| 714 | + | } | |
| 715 | + | ||
| 716 | + | var xThreadJoin func(uintptr) uintptr | |
| 717 | + | ||
| 718 | + | // Waits until @thread finishes, i.e. the function @func, as | |
| 719 | + | // given to g_thread_new(), returns or g_thread_exit() is called. | |
| 720 | + | // If @thread has already terminated, then g_thread_join() | |
| 721 | + | // returns immediately. | |
| 722 | + | // | |
| 723 | + | // Any thread can wait for any other thread by calling g_thread_join(), | |
| 724 | + | // not just its 'creator'. Calling g_thread_join() from multiple threads | |
| 725 | + | // for the same @thread leads to undefined behaviour. | |
| 726 | + | // | |
| 727 | + | // The value returned by @func or given to g_thread_exit() is | |
| 728 | + | // returned by this function. | |
| 729 | + | // | |
| 730 | + | // g_thread_join() consumes the reference to the passed-in @thread. | |
| 731 | + | // This will usually cause the #GThread struct and associated resources | |
| 732 | + | // to be freed. Use g_thread_ref() to obtain an extra reference if you | |
| 733 | + | // want to keep the GThread alive beyond the g_thread_join() call. | |
| 734 | + | func (x *Thread) Join() uintptr { | |
| 735 | + | ||
| 736 | + | cret := xThreadJoin(x.GoPointer()) | |
| 737 | + | return cret | |
| 738 | + | } | |
| 739 | + | ||
| 740 | + | var xThreadRef func(uintptr) *Thread | |
| 741 | + | ||
| 742 | + | // Increase the reference count on @thread. | |
| 743 | + | func (x *Thread) Ref() *Thread { | |
| 744 | + | ||
| 745 | + | cret := xThreadRef(x.GoPointer()) | |
| 746 | + | return cret | |
| 747 | + | } | |
| 748 | + | ||
| 749 | + | var xThreadUnref func(uintptr) | |
| 750 | + | ||
| 751 | + | // Decrease the reference count on @thread, possibly freeing all | |
| 752 | + | // resources associated with it. | |
| 753 | + | // | |
| 754 | + | // Note that each thread holds a reference to its #GThread while | |
| 755 | + | // it is running, so it is safe to drop your own reference to it | |
| 756 | + | // if you don't need it anymore. | |
| 757 | + | func (x *Thread) Unref() { | |
| 758 | + | ||
| 759 | + | xThreadUnref(x.GoPointer()) | |
| 760 | + | ||
| 761 | + | } | |
| 762 | + | ||
| 225 | 763 | // The #GMutex struct is an opaque data structure to represent a mutex | |
| 226 | 764 | // (mutual exclusion). It can be used to protect data against shared | |
| 227 | 765 | // access. | |
| @@ -433,4 +971,39 @@ func init() { | |||
| 433 | 971 | core.PuregoSafeRegister(&xThreadSelf, lib, "g_thread_self") | |
| 434 | 972 | core.PuregoSafeRegister(&xThreadYield, lib, "g_thread_yield") | |
| 435 | 973 | ||
| 974 | + | core.PuregoSafeRegister(&xCondBroadcast, lib, "g_cond_broadcast") | |
| 975 | + | core.PuregoSafeRegister(&xCondClear, lib, "g_cond_clear") | |
| 976 | + | core.PuregoSafeRegister(&xCondInit, lib, "g_cond_init") | |
| 977 | + | core.PuregoSafeRegister(&xCondSignal, lib, "g_cond_signal") | |
| 978 | + | core.PuregoSafeRegister(&xCondWait, lib, "g_cond_wait") | |
| 979 | + | core.PuregoSafeRegister(&xCondWaitUntil, lib, "g_cond_wait_until") | |
| 980 | + | ||
| 981 | + | core.PuregoSafeRegister(&xOnceImpl, lib, "g_once_impl") | |
| 982 | + | ||
| 983 | + | core.PuregoSafeRegister(&xPrivateGet, lib, "g_private_get") | |
| 984 | + | core.PuregoSafeRegister(&xPrivateReplace, lib, "g_private_replace") | |
| 985 | + | core.PuregoSafeRegister(&xPrivateSet, lib, "g_private_set") | |
| 986 | + | ||
| 987 | + | core.PuregoSafeRegister(&xRWLockClear, lib, "g_rw_lock_clear") | |
| 988 | + | core.PuregoSafeRegister(&xRWLockInit, lib, "g_rw_lock_init") | |
| 989 | + | core.PuregoSafeRegister(&xRWLockReaderLock, lib, "g_rw_lock_reader_lock") | |
| 990 | + | core.PuregoSafeRegister(&xRWLockReaderTrylock, lib, "g_rw_lock_reader_trylock") | |
| 991 | + | core.PuregoSafeRegister(&xRWLockReaderUnlock, lib, "g_rw_lock_reader_unlock") | |
| 992 | + | core.PuregoSafeRegister(&xRWLockWriterLock, lib, "g_rw_lock_writer_lock") | |
| 993 | + | core.PuregoSafeRegister(&xRWLockWriterTrylock, lib, "g_rw_lock_writer_trylock") | |
| 994 | + | core.PuregoSafeRegister(&xRWLockWriterUnlock, lib, "g_rw_lock_writer_unlock") | |
| 995 | + | ||
| 996 | + | core.PuregoSafeRegister(&xRecMutexClear, lib, "g_rec_mutex_clear") | |
| 997 | + | core.PuregoSafeRegister(&xRecMutexInit, lib, "g_rec_mutex_init") | |
| 998 | + | core.PuregoSafeRegister(&xRecMutexLock, lib, "g_rec_mutex_lock") | |
| 999 | + | core.PuregoSafeRegister(&xRecMutexTrylock, lib, "g_rec_mutex_trylock") | |
| 1000 | + | core.PuregoSafeRegister(&xRecMutexUnlock, lib, "g_rec_mutex_unlock") | |
| 1001 | + | ||
| 1002 | + | core.PuregoSafeRegister(&xNewThread, lib, "g_thread_new") | |
| 1003 | + | core.PuregoSafeRegister(&xTryNewThread, lib, "g_thread_try_new") | |
| 1004 | + | ||
| 1005 | + | core.PuregoSafeRegister(&xThreadJoin, lib, "g_thread_join") | |
| 1006 | + | core.PuregoSafeRegister(&xThreadRef, lib, "g_thread_ref") | |
| 1007 | + | core.PuregoSafeRegister(&xThreadUnref, lib, "g_thread_unref") | |
| 1008 | + | ||
| 436 | 1009 | } | |
M v4/glib/gthreadpool.go +151 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -17,6 +19,146 @@ type ThreadPool struct { | |||
| 17 | 19 | Exclusive bool | |
| 18 | 20 | } | |
| 19 | 21 | ||
| 22 | + | func (x *ThreadPool) GoPointer() uintptr { | |
| 23 | + | return uintptr(unsafe.Pointer(x)) | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | var xThreadPoolFree func(uintptr, bool, bool) | |
| 27 | + | ||
| 28 | + | // Frees all resources allocated for @pool. | |
| 29 | + | // | |
| 30 | + | // If @immediate is %TRUE, no new task is processed for @pool. | |
| 31 | + | // Otherwise @pool is not freed before the last task is processed. | |
| 32 | + | // Note however, that no thread of this pool is interrupted while | |
| 33 | + | // processing a task. Instead at least all still running threads | |
| 34 | + | // can finish their tasks before the @pool is freed. | |
| 35 | + | // | |
| 36 | + | // If @wait_ is %TRUE, this function does not return before all | |
| 37 | + | // tasks to be processed (dependent on @immediate, whether all | |
| 38 | + | // or only the currently running) are ready. | |
| 39 | + | // Otherwise this function returns immediately. | |
| 40 | + | // | |
| 41 | + | // After calling this function @pool must not be used anymore. | |
| 42 | + | func (x *ThreadPool) Free(ImmediateVar bool, WaitVar bool) { | |
| 43 | + | ||
| 44 | + | xThreadPoolFree(x.GoPointer(), ImmediateVar, WaitVar) | |
| 45 | + | ||
| 46 | + | } | |
| 47 | + | ||
| 48 | + | var xThreadPoolGetMaxThreads func(uintptr) int | |
| 49 | + | ||
| 50 | + | // Returns the maximal number of threads for @pool. | |
| 51 | + | func (x *ThreadPool) GetMaxThreads() int { | |
| 52 | + | ||
| 53 | + | cret := xThreadPoolGetMaxThreads(x.GoPointer()) | |
| 54 | + | return cret | |
| 55 | + | } | |
| 56 | + | ||
| 57 | + | var xThreadPoolGetNumThreads func(uintptr) uint | |
| 58 | + | ||
| 59 | + | // Returns the number of threads currently running in @pool. | |
| 60 | + | func (x *ThreadPool) GetNumThreads() uint { | |
| 61 | + | ||
| 62 | + | cret := xThreadPoolGetNumThreads(x.GoPointer()) | |
| 63 | + | return cret | |
| 64 | + | } | |
| 65 | + | ||
| 66 | + | var xThreadPoolMoveToFront func(uintptr, uintptr) bool | |
| 67 | + | ||
| 68 | + | // Moves the item to the front of the queue of unprocessed | |
| 69 | + | // items, so that it will be processed next. | |
| 70 | + | func (x *ThreadPool) MoveToFront(DataVar uintptr) bool { | |
| 71 | + | ||
| 72 | + | cret := xThreadPoolMoveToFront(x.GoPointer(), DataVar) | |
| 73 | + | return cret | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | var xThreadPoolPush func(uintptr, uintptr, **Error) bool | |
| 77 | + | ||
| 78 | + | // Inserts @data into the list of tasks to be executed by @pool. | |
| 79 | + | // | |
| 80 | + | // When the number of currently running threads is lower than the | |
| 81 | + | // maximal allowed number of threads, a new thread is started (or | |
| 82 | + | // reused) with the properties given to g_thread_pool_new(). | |
| 83 | + | // Otherwise, @data stays in the queue until a thread in this pool | |
| 84 | + | // finishes its previous task and processes @data. | |
| 85 | + | // | |
| 86 | + | // @error can be %NULL to ignore errors, or non-%NULL to report | |
| 87 | + | // errors. An error can only occur when a new thread couldn't be | |
| 88 | + | // created. In that case @data is simply appended to the queue of | |
| 89 | + | // work to do. | |
| 90 | + | // | |
| 91 | + | // Before version 2.32, this function did not return a success status. | |
| 92 | + | func (x *ThreadPool) Push(DataVar uintptr) (bool, error) { | |
| 93 | + | var cerr *Error | |
| 94 | + | ||
| 95 | + | cret := xThreadPoolPush(x.GoPointer(), DataVar, &cerr) | |
| 96 | + | if cerr == nil { | |
| 97 | + | return cret, nil | |
| 98 | + | } | |
| 99 | + | return cret, cerr | |
| 100 | + | ||
| 101 | + | } | |
| 102 | + | ||
| 103 | + | var xThreadPoolSetMaxThreads func(uintptr, int, **Error) bool | |
| 104 | + | ||
| 105 | + | // Sets the maximal allowed number of threads for @pool. | |
| 106 | + | // A value of -1 means that the maximal number of threads | |
| 107 | + | // is unlimited. If @pool is an exclusive thread pool, setting | |
| 108 | + | // the maximal number of threads to -1 is not allowed. | |
| 109 | + | // | |
| 110 | + | // Setting @max_threads to 0 means stopping all work for @pool. | |
| 111 | + | // It is effectively frozen until @max_threads is set to a non-zero | |
| 112 | + | // value again. | |
| 113 | + | // | |
| 114 | + | // A thread is never terminated while calling @func, as supplied by | |
| 115 | + | // g_thread_pool_new(). Instead the maximal number of threads only | |
| 116 | + | // has effect for the allocation of new threads in g_thread_pool_push(). | |
| 117 | + | // A new thread is allocated, whenever the number of currently | |
| 118 | + | // running threads in @pool is smaller than the maximal number. | |
| 119 | + | // | |
| 120 | + | // @error can be %NULL to ignore errors, or non-%NULL to report | |
| 121 | + | // errors. An error can only occur when a new thread couldn't be | |
| 122 | + | // created. | |
| 123 | + | // | |
| 124 | + | // Before version 2.32, this function did not return a success status. | |
| 125 | + | func (x *ThreadPool) SetMaxThreads(MaxThreadsVar int) (bool, error) { | |
| 126 | + | var cerr *Error | |
| 127 | + | ||
| 128 | + | cret := xThreadPoolSetMaxThreads(x.GoPointer(), MaxThreadsVar, &cerr) | |
| 129 | + | if cerr == nil { | |
| 130 | + | return cret, nil | |
| 131 | + | } | |
| 132 | + | return cret, cerr | |
| 133 | + | ||
| 134 | + | } | |
| 135 | + | ||
| 136 | + | var xThreadPoolSetSortFunction func(uintptr, uintptr, uintptr) | |
| 137 | + | ||
| 138 | + | // Sets the function used to sort the list of tasks. This allows the | |
| 139 | + | // tasks to be processed by a priority determined by @func, and not | |
| 140 | + | // just in the order in which they were added to the pool. | |
| 141 | + | // | |
| 142 | + | // Note, if the maximum number of threads is more than 1, the order | |
| 143 | + | // that threads are executed cannot be guaranteed 100%. Threads are | |
| 144 | + | // scheduled by the operating system and are executed at random. It | |
| 145 | + | // cannot be assumed that threads are executed in the order they are | |
| 146 | + | // created. | |
| 147 | + | func (x *ThreadPool) SetSortFunction(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 148 | + | ||
| 149 | + | xThreadPoolSetSortFunction(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 150 | + | ||
| 151 | + | } | |
| 152 | + | ||
| 153 | + | var xThreadPoolUnprocessed func(uintptr) uint | |
| 154 | + | ||
| 155 | + | // Returns the number of tasks still unprocessed in @pool. | |
| 156 | + | func (x *ThreadPool) Unprocessed() uint { | |
| 157 | + | ||
| 158 | + | cret := xThreadPoolUnprocessed(x.GoPointer()) | |
| 159 | + | return cret | |
| 160 | + | } | |
| 161 | + | ||
| 20 | 162 | var xThreadPoolGetMaxIdleTime func() uint | |
| 21 | 163 | ||
| 22 | 164 | // This function will return the maximum @interval that a | |
| @@ -102,4 +244,13 @@ func init() { | |||
| 102 | 244 | core.PuregoSafeRegister(&xThreadPoolSetMaxUnusedThreads, lib, "g_thread_pool_set_max_unused_threads") | |
| 103 | 245 | core.PuregoSafeRegister(&xThreadPoolStopUnusedThreads, lib, "g_thread_pool_stop_unused_threads") | |
| 104 | 246 | ||
| 247 | + | core.PuregoSafeRegister(&xThreadPoolFree, lib, "g_thread_pool_free") | |
| 248 | + | core.PuregoSafeRegister(&xThreadPoolGetMaxThreads, lib, "g_thread_pool_get_max_threads") | |
| 249 | + | core.PuregoSafeRegister(&xThreadPoolGetNumThreads, lib, "g_thread_pool_get_num_threads") | |
| 250 | + | core.PuregoSafeRegister(&xThreadPoolMoveToFront, lib, "g_thread_pool_move_to_front") | |
| 251 | + | core.PuregoSafeRegister(&xThreadPoolPush, lib, "g_thread_pool_push") | |
| 252 | + | core.PuregoSafeRegister(&xThreadPoolSetMaxThreads, lib, "g_thread_pool_set_max_threads") | |
| 253 | + | core.PuregoSafeRegister(&xThreadPoolSetSortFunction, lib, "g_thread_pool_set_sort_function") | |
| 254 | + | core.PuregoSafeRegister(&xThreadPoolUnprocessed, lib, "g_thread_pool_unprocessed") | |
| 255 | + | ||
| 105 | 256 | } | |
M v4/glib/gtimer.go +96 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -10,6 +12,92 @@ import ( | |||
| 10 | 12 | type Timer struct { | |
| 11 | 13 | } | |
| 12 | 14 | ||
| 15 | + | func (x *Timer) GoPointer() uintptr { | |
| 16 | + | return uintptr(unsafe.Pointer(x)) | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | var xTimerContinue func(uintptr) | |
| 20 | + | ||
| 21 | + | // Resumes a timer that has previously been stopped with | |
| 22 | + | // g_timer_stop(). g_timer_stop() must be called before using this | |
| 23 | + | // function. | |
| 24 | + | func (x *Timer) Continue() { | |
| 25 | + | ||
| 26 | + | xTimerContinue(x.GoPointer()) | |
| 27 | + | ||
| 28 | + | } | |
| 29 | + | ||
| 30 | + | var xTimerDestroy func(uintptr) | |
| 31 | + | ||
| 32 | + | // Destroys a timer, freeing associated resources. | |
| 33 | + | func (x *Timer) Destroy() { | |
| 34 | + | ||
| 35 | + | xTimerDestroy(x.GoPointer()) | |
| 36 | + | ||
| 37 | + | } | |
| 38 | + | ||
| 39 | + | var xTimerElapsed func(uintptr, uint32) float64 | |
| 40 | + | ||
| 41 | + | // If @timer has been started but not stopped, obtains the time since | |
| 42 | + | // the timer was started. If @timer has been stopped, obtains the | |
| 43 | + | // elapsed time between the time it was started and the time it was | |
| 44 | + | // stopped. The return value is the number of seconds elapsed, | |
| 45 | + | // including any fractional part. The @microseconds out parameter is | |
| 46 | + | // essentially useless. | |
| 47 | + | func (x *Timer) Elapsed(MicrosecondsVar uint32) float64 { | |
| 48 | + | ||
| 49 | + | cret := xTimerElapsed(x.GoPointer(), MicrosecondsVar) | |
| 50 | + | return cret | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | var xTimerIsActive func(uintptr) bool | |
| 54 | + | ||
| 55 | + | // Exposes whether the timer is currently active. | |
| 56 | + | func (x *Timer) IsActive() bool { | |
| 57 | + | ||
| 58 | + | cret := xTimerIsActive(x.GoPointer()) | |
| 59 | + | return cret | |
| 60 | + | } | |
| 61 | + | ||
| 62 | + | var xTimerReset func(uintptr) | |
| 63 | + | ||
| 64 | + | // This function is useless; it's fine to call g_timer_start() on an | |
| 65 | + | // already-started timer to reset the start time, so g_timer_reset() | |
| 66 | + | // serves no purpose. | |
| 67 | + | func (x *Timer) Reset() { | |
| 68 | + | ||
| 69 | + | xTimerReset(x.GoPointer()) | |
| 70 | + | ||
| 71 | + | } | |
| 72 | + | ||
| 73 | + | var xTimerStart func(uintptr) | |
| 74 | + | ||
| 75 | + | // Marks a start time, so that future calls to g_timer_elapsed() will | |
| 76 | + | // report the time since g_timer_start() was called. g_timer_new() | |
| 77 | + | // automatically marks the start time, so no need to call | |
| 78 | + | // g_timer_start() immediately after creating the timer. | |
| 79 | + | func (x *Timer) Start() { | |
| 80 | + | ||
| 81 | + | xTimerStart(x.GoPointer()) | |
| 82 | + | ||
| 83 | + | } | |
| 84 | + | ||
| 85 | + | var xTimerStop func(uintptr) | |
| 86 | + | ||
| 87 | + | // Marks an end time, so calls to g_timer_elapsed() will return the | |
| 88 | + | // difference between this end time and the start time. | |
| 89 | + | func (x *Timer) Stop() { | |
| 90 | + | ||
| 91 | + | xTimerStop(x.GoPointer()) | |
| 92 | + | ||
| 93 | + | } | |
| 94 | + | ||
| 95 | + | const ( | |
| 96 | + | // Number of microseconds in one second (1 million). | |
| 97 | + | // This macro is provided for code readability. | |
| 98 | + | USEC_PER_SEC int = 1000000 | |
| 99 | + | ) | |
| 100 | + | ||
| 13 | 101 | var xTimeValFromIso8601 func(string, *TimeVal) bool | |
| 14 | 102 | ||
| 15 | 103 | // Converts a string containing an ISO 8601 encoded date and time | |
| @@ -57,4 +145,12 @@ func init() { | |||
| 57 | 145 | core.PuregoSafeRegister(&xTimeValFromIso8601, lib, "g_time_val_from_iso8601") | |
| 58 | 146 | core.PuregoSafeRegister(&xUsleep, lib, "g_usleep") | |
| 59 | 147 | ||
| 148 | + | core.PuregoSafeRegister(&xTimerContinue, lib, "g_timer_continue") | |
| 149 | + | core.PuregoSafeRegister(&xTimerDestroy, lib, "g_timer_destroy") | |
| 150 | + | core.PuregoSafeRegister(&xTimerElapsed, lib, "g_timer_elapsed") | |
| 151 | + | core.PuregoSafeRegister(&xTimerIsActive, lib, "g_timer_is_active") | |
| 152 | + | core.PuregoSafeRegister(&xTimerReset, lib, "g_timer_reset") | |
| 153 | + | core.PuregoSafeRegister(&xTimerStart, lib, "g_timer_start") | |
| 154 | + | core.PuregoSafeRegister(&xTimerStop, lib, "g_timer_stop") | |
| 155 | + | ||
| 60 | 156 | } | |
M v4/glib/gtimezone.go +287 -0
| @@ -1,11 +1,275 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // #GTimeZone is an opaque structure whose members cannot be accessed | |
| 5 | 12 | // directly. | |
| 6 | 13 | type TimeZone struct { | |
| 7 | 14 | } | |
| 8 | 15 | ||
| 16 | + | func (x *TimeZone) GoPointer() uintptr { | |
| 17 | + | return uintptr(unsafe.Pointer(x)) | |
| 18 | + | } | |
| 19 | + | ||
| 20 | + | var xNewTimeZone func(string) *TimeZone | |
| 21 | + | ||
| 22 | + | // A version of g_time_zone_new_identifier() which returns the UTC time zone | |
| 23 | + | // if @identifier could not be parsed or loaded. | |
| 24 | + | // | |
| 25 | + | // If you need to check whether @identifier was loaded successfully, use | |
| 26 | + | // g_time_zone_new_identifier(). | |
| 27 | + | func NewTimeZone(IdentifierVar string) *TimeZone { | |
| 28 | + | ||
| 29 | + | cret := xNewTimeZone(IdentifierVar) | |
| 30 | + | return cret | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | var xNewIdentifierTimeZone func(string) *TimeZone | |
| 34 | + | ||
| 35 | + | // Creates a #GTimeZone corresponding to @identifier. If @identifier cannot be | |
| 36 | + | // parsed or loaded, %NULL is returned. | |
| 37 | + | // | |
| 38 | + | // @identifier can either be an RFC3339/ISO 8601 time offset or | |
| 39 | + | // something that would pass as a valid value for the `TZ` environment | |
| 40 | + | // variable (including %NULL). | |
| 41 | + | // | |
| 42 | + | // In Windows, @identifier can also be the unlocalized name of a time | |
| 43 | + | // zone for standard time, for example "Pacific Standard Time". | |
| 44 | + | // | |
| 45 | + | // Valid RFC3339 time offsets are `"Z"` (for UTC) or | |
| 46 | + | // `"±hh:mm"`. ISO 8601 additionally specifies | |
| 47 | + | // `"±hhmm"` and `"±hh"`. Offsets are | |
| 48 | + | // time values to be added to Coordinated Universal Time (UTC) to get | |
| 49 | + | // the local time. | |
| 50 | + | // | |
| 51 | + | // In UNIX, the `TZ` environment variable typically corresponds | |
| 52 | + | // to the name of a file in the zoneinfo database, an absolute path to a file | |
| 53 | + | // somewhere else, or a string in | |
| 54 | + | // "std offset [dst [offset],start[/time],end[/time]]" (POSIX) format. | |
| 55 | + | // There are no spaces in the specification. The name of standard | |
| 56 | + | // and daylight savings time zone must be three or more alphabetic | |
| 57 | + | // characters. Offsets are time values to be added to local time to | |
| 58 | + | // get Coordinated Universal Time (UTC) and should be | |
| 59 | + | // `"[±]hh[[:]mm[:ss]]"`. Dates are either | |
| 60 | + | // `"Jn"` (Julian day with n between 1 and 365, leap | |
| 61 | + | // years not counted), `"n"` (zero-based Julian day | |
| 62 | + | // with n between 0 and 365) or `"Mm.w.d"` (day d | |
| 63 | + | // (0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day | |
| 64 | + | // 0 is a Sunday). Times are in local wall clock time, the default is | |
| 65 | + | // 02:00:00. | |
| 66 | + | // | |
| 67 | + | // In Windows, the "tzn[+|–]hh[:mm[:ss]][dzn]" format is used, but also | |
| 68 | + | // accepts POSIX format. The Windows format uses US rules for all time | |
| 69 | + | // zones; daylight savings time is 60 minutes behind the standard time | |
| 70 | + | // with date and time of change taken from Pacific Standard Time. | |
| 71 | + | // Offsets are time values to be added to the local time to get | |
| 72 | + | // Coordinated Universal Time (UTC). | |
| 73 | + | // | |
| 74 | + | // g_time_zone_new_local() calls this function with the value of the | |
| 75 | + | // `TZ` environment variable. This function itself is independent of | |
| 76 | + | // the value of `TZ`, but if @identifier is %NULL then `/etc/localtime` | |
| 77 | + | // will be consulted to discover the correct time zone on UNIX and the | |
| 78 | + | // registry will be consulted or GetTimeZoneInformation() will be used | |
| 79 | + | // to get the local time zone on Windows. | |
| 80 | + | // | |
| 81 | + | // If intervals are not available, only time zone rules from `TZ` | |
| 82 | + | // environment variable or other means, then they will be computed | |
| 83 | + | // from year 1900 to 2037. If the maximum year for the rules is | |
| 84 | + | // available and it is greater than 2037, then it will followed | |
| 85 | + | // instead. | |
| 86 | + | // | |
| 87 | + | // See | |
| 88 | + | // [RFC3339 §5.6](http://tools.ietf.org/html/rfc3339#section-5.6) | |
| 89 | + | // for a precise definition of valid RFC3339 time offsets | |
| 90 | + | // (the `time-offset` expansion) and ISO 8601 for the | |
| 91 | + | // full list of valid time offsets. See | |
| 92 | + | // [The GNU C Library manual](http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html) | |
| 93 | + | // for an explanation of the possible | |
| 94 | + | // values of the `TZ` environment variable. See | |
| 95 | + | // [Microsoft Time Zone Index Values](http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx) | |
| 96 | + | // for the list of time zones on Windows. | |
| 97 | + | // | |
| 98 | + | // You should release the return value by calling g_time_zone_unref() | |
| 99 | + | // when you are done with it. | |
| 100 | + | func NewIdentifierTimeZone(IdentifierVar string) *TimeZone { | |
| 101 | + | ||
| 102 | + | cret := xNewIdentifierTimeZone(IdentifierVar) | |
| 103 | + | return cret | |
| 104 | + | } | |
| 105 | + | ||
| 106 | + | var xNewLocalTimeZone func() *TimeZone | |
| 107 | + | ||
| 108 | + | // Creates a #GTimeZone corresponding to local time. The local time | |
| 109 | + | // zone may change between invocations to this function; for example, | |
| 110 | + | // if the system administrator changes it. | |
| 111 | + | // | |
| 112 | + | // This is equivalent to calling g_time_zone_new() with the value of | |
| 113 | + | // the `TZ` environment variable (including the possibility of %NULL). | |
| 114 | + | // | |
| 115 | + | // You should release the return value by calling g_time_zone_unref() | |
| 116 | + | // when you are done with it. | |
| 117 | + | func NewLocalTimeZone() *TimeZone { | |
| 118 | + | ||
| 119 | + | cret := xNewLocalTimeZone() | |
| 120 | + | return cret | |
| 121 | + | } | |
| 122 | + | ||
| 123 | + | var xNewOffsetTimeZone func(int32) *TimeZone | |
| 124 | + | ||
| 125 | + | // Creates a #GTimeZone corresponding to the given constant offset from UTC, | |
| 126 | + | // in seconds. | |
| 127 | + | // | |
| 128 | + | // This is equivalent to calling g_time_zone_new() with a string in the form | |
| 129 | + | // `[+|-]hh[:mm[:ss]]`. | |
| 130 | + | func NewOffsetTimeZone(SecondsVar int32) *TimeZone { | |
| 131 | + | ||
| 132 | + | cret := xNewOffsetTimeZone(SecondsVar) | |
| 133 | + | return cret | |
| 134 | + | } | |
| 135 | + | ||
| 136 | + | var xNewUtcTimeZone func() *TimeZone | |
| 137 | + | ||
| 138 | + | // Creates a #GTimeZone corresponding to UTC. | |
| 139 | + | // | |
| 140 | + | // This is equivalent to calling g_time_zone_new() with a value like | |
| 141 | + | // "Z", "UTC", "+00", etc. | |
| 142 | + | // | |
| 143 | + | // You should release the return value by calling g_time_zone_unref() | |
| 144 | + | // when you are done with it. | |
| 145 | + | func NewUtcTimeZone() *TimeZone { | |
| 146 | + | ||
| 147 | + | cret := xNewUtcTimeZone() | |
| 148 | + | return cret | |
| 149 | + | } | |
| 150 | + | ||
| 151 | + | var xTimeZoneAdjustTime func(uintptr, TimeType, int64) int | |
| 152 | + | ||
| 153 | + | // Finds an interval within @tz that corresponds to the given @time_, | |
| 154 | + | // possibly adjusting @time_ if required to fit into an interval. | |
| 155 | + | // The meaning of @time_ depends on @type. | |
| 156 | + | // | |
| 157 | + | // This function is similar to g_time_zone_find_interval(), with the | |
| 158 | + | // difference that it always succeeds (by making the adjustments | |
| 159 | + | // described below). | |
| 160 | + | // | |
| 161 | + | // In any of the cases where g_time_zone_find_interval() succeeds then | |
| 162 | + | // this function returns the same value, without modifying @time_. | |
| 163 | + | // | |
| 164 | + | // This function may, however, modify @time_ in order to deal with | |
| 165 | + | // non-existent times. If the non-existent local @time_ of 02:30 were | |
| 166 | + | // requested on March 14th 2010 in Toronto then this function would | |
| 167 | + | // adjust @time_ to be 03:00 and return the interval containing the | |
| 168 | + | // adjusted time. | |
| 169 | + | func (x *TimeZone) AdjustTime(TypeVar TimeType, TimeVar int64) int { | |
| 170 | + | ||
| 171 | + | cret := xTimeZoneAdjustTime(x.GoPointer(), TypeVar, TimeVar) | |
| 172 | + | return cret | |
| 173 | + | } | |
| 174 | + | ||
| 175 | + | var xTimeZoneFindInterval func(uintptr, TimeType, int64) int | |
| 176 | + | ||
| 177 | + | // Finds an interval within @tz that corresponds to the given @time_. | |
| 178 | + | // The meaning of @time_ depends on @type. | |
| 179 | + | // | |
| 180 | + | // If @type is %G_TIME_TYPE_UNIVERSAL then this function will always | |
| 181 | + | // succeed (since universal time is monotonic and continuous). | |
| 182 | + | // | |
| 183 | + | // Otherwise @time_ is treated as local time. The distinction between | |
| 184 | + | // %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in | |
| 185 | + | // the case that the given @time_ is ambiguous. In Toronto, for example, | |
| 186 | + | // 01:30 on November 7th 2010 occurred twice (once inside of daylight | |
| 187 | + | // savings time and the next, an hour later, outside of daylight savings | |
| 188 | + | // time). In this case, the different value of @type would result in a | |
| 189 | + | // different interval being returned. | |
| 190 | + | // | |
| 191 | + | // It is still possible for this function to fail. In Toronto, for | |
| 192 | + | // example, 02:00 on March 14th 2010 does not exist (due to the leap | |
| 193 | + | // forward to begin daylight savings time). -1 is returned in that | |
| 194 | + | // case. | |
| 195 | + | func (x *TimeZone) FindInterval(TypeVar TimeType, TimeVar int64) int { | |
| 196 | + | ||
| 197 | + | cret := xTimeZoneFindInterval(x.GoPointer(), TypeVar, TimeVar) | |
| 198 | + | return cret | |
| 199 | + | } | |
| 200 | + | ||
| 201 | + | var xTimeZoneGetAbbreviation func(uintptr, int) string | |
| 202 | + | ||
| 203 | + | // Determines the time zone abbreviation to be used during a particular | |
| 204 | + | // @interval of time in the time zone @tz. | |
| 205 | + | // | |
| 206 | + | // For example, in Toronto this is currently "EST" during the winter | |
| 207 | + | // months and "EDT" during the summer months when daylight savings time | |
| 208 | + | // is in effect. | |
| 209 | + | func (x *TimeZone) GetAbbreviation(IntervalVar int) string { | |
| 210 | + | ||
| 211 | + | cret := xTimeZoneGetAbbreviation(x.GoPointer(), IntervalVar) | |
| 212 | + | return cret | |
| 213 | + | } | |
| 214 | + | ||
| 215 | + | var xTimeZoneGetIdentifier func(uintptr) string | |
| 216 | + | ||
| 217 | + | // Get the identifier of this #GTimeZone, as passed to g_time_zone_new(). | |
| 218 | + | // If the identifier passed at construction time was not recognised, `UTC` will | |
| 219 | + | // be returned. If it was %NULL, the identifier of the local timezone at | |
| 220 | + | // construction time will be returned. | |
| 221 | + | // | |
| 222 | + | // The identifier will be returned in the same format as provided at | |
| 223 | + | // construction time: if provided as a time offset, that will be returned by | |
| 224 | + | // this function. | |
| 225 | + | func (x *TimeZone) GetIdentifier() string { | |
| 226 | + | ||
| 227 | + | cret := xTimeZoneGetIdentifier(x.GoPointer()) | |
| 228 | + | return cret | |
| 229 | + | } | |
| 230 | + | ||
| 231 | + | var xTimeZoneGetOffset func(uintptr, int) int32 | |
| 232 | + | ||
| 233 | + | // Determines the offset to UTC in effect during a particular @interval | |
| 234 | + | // of time in the time zone @tz. | |
| 235 | + | // | |
| 236 | + | // The offset is the number of seconds that you add to UTC time to | |
| 237 | + | // arrive at local time for @tz (ie: negative numbers for time zones | |
| 238 | + | // west of GMT, positive numbers for east). | |
| 239 | + | func (x *TimeZone) GetOffset(IntervalVar int) int32 { | |
| 240 | + | ||
| 241 | + | cret := xTimeZoneGetOffset(x.GoPointer(), IntervalVar) | |
| 242 | + | return cret | |
| 243 | + | } | |
| 244 | + | ||
| 245 | + | var xTimeZoneIsDst func(uintptr, int) bool | |
| 246 | + | ||
| 247 | + | // Determines if daylight savings time is in effect during a particular | |
| 248 | + | // @interval of time in the time zone @tz. | |
| 249 | + | func (x *TimeZone) IsDst(IntervalVar int) bool { | |
| 250 | + | ||
| 251 | + | cret := xTimeZoneIsDst(x.GoPointer(), IntervalVar) | |
| 252 | + | return cret | |
| 253 | + | } | |
| 254 | + | ||
| 255 | + | var xTimeZoneRef func(uintptr) *TimeZone | |
| 256 | + | ||
| 257 | + | // Increases the reference count on @tz. | |
| 258 | + | func (x *TimeZone) Ref() *TimeZone { | |
| 259 | + | ||
| 260 | + | cret := xTimeZoneRef(x.GoPointer()) | |
| 261 | + | return cret | |
| 262 | + | } | |
| 263 | + | ||
| 264 | + | var xTimeZoneUnref func(uintptr) | |
| 265 | + | ||
| 266 | + | // Decreases the reference count on @tz. | |
| 267 | + | func (x *TimeZone) Unref() { | |
| 268 | + | ||
| 269 | + | xTimeZoneUnref(x.GoPointer()) | |
| 270 | + | ||
| 271 | + | } | |
| 272 | + | ||
| 9 | 273 | // Disambiguates a given time in two ways. | |
| 10 | 274 | // | |
| 11 | 275 | // First, specifies if the given time is in universal or local time. | |
| @@ -25,3 +289,26 @@ const ( | |||
| 25 | 289 | // the time is in UTC | |
| 26 | 290 | GTimeTypeUniversalValue TimeType = 2 | |
| 27 | 291 | ) | |
| 292 | + | ||
| 293 | + | func init() { | |
| 294 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 295 | + | if err != nil { | |
| 296 | + | panic(err) | |
| 297 | + | } | |
| 298 | + | ||
| 299 | + | core.PuregoSafeRegister(&xNewTimeZone, lib, "g_time_zone_new") | |
| 300 | + | core.PuregoSafeRegister(&xNewIdentifierTimeZone, lib, "g_time_zone_new_identifier") | |
| 301 | + | core.PuregoSafeRegister(&xNewLocalTimeZone, lib, "g_time_zone_new_local") | |
| 302 | + | core.PuregoSafeRegister(&xNewOffsetTimeZone, lib, "g_time_zone_new_offset") | |
| 303 | + | core.PuregoSafeRegister(&xNewUtcTimeZone, lib, "g_time_zone_new_utc") | |
| 304 | + | ||
| 305 | + | core.PuregoSafeRegister(&xTimeZoneAdjustTime, lib, "g_time_zone_adjust_time") | |
| 306 | + | core.PuregoSafeRegister(&xTimeZoneFindInterval, lib, "g_time_zone_find_interval") | |
| 307 | + | core.PuregoSafeRegister(&xTimeZoneGetAbbreviation, lib, "g_time_zone_get_abbreviation") | |
| 308 | + | core.PuregoSafeRegister(&xTimeZoneGetIdentifier, lib, "g_time_zone_get_identifier") | |
| 309 | + | core.PuregoSafeRegister(&xTimeZoneGetOffset, lib, "g_time_zone_get_offset") | |
| 310 | + | core.PuregoSafeRegister(&xTimeZoneIsDst, lib, "g_time_zone_is_dst") | |
| 311 | + | core.PuregoSafeRegister(&xTimeZoneRef, lib, "g_time_zone_ref") | |
| 312 | + | core.PuregoSafeRegister(&xTimeZoneUnref, lib, "g_time_zone_unref") | |
| 313 | + | ||
| 314 | + | } | |
M v4/glib/gtrashstack.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -12,6 +14,10 @@ type TrashStack struct { | |||
| 12 | 14 | Next *TrashStack | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *TrashStack) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | var xTrashStackHeight func(**TrashStack) uint | |
| 16 | 22 | ||
| 17 | 23 | // Returns the height of a #GTrashStack. | |
M v4/glib/gtree.go +443 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Specifies the type of function passed to g_tree_traverse(). It is | |
| 5 | 12 | // passed the key and value of each node, together with the @user_data | |
| 6 | 13 | // parameter passed to g_tree_traverse(). If the function returns | |
| @@ -19,6 +26,442 @@ type TraverseNodeFunc func(*TreeNode, uintptr) bool | |||
| 19 | 26 | type Tree struct { | |
| 20 | 27 | } | |
| 21 | 28 | ||
| 29 | + | func (x *Tree) GoPointer() uintptr { | |
| 30 | + | return uintptr(unsafe.Pointer(x)) | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | var xNewTree func(uintptr) *Tree | |
| 34 | + | ||
| 35 | + | // Creates a new #GTree. | |
| 36 | + | func NewTree(KeyCompareFuncVar CompareFunc) *Tree { | |
| 37 | + | ||
| 38 | + | cret := xNewTree(purego.NewCallback(KeyCompareFuncVar)) | |
| 39 | + | return cret | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | var xNewFullTree func(uintptr, uintptr, uintptr, uintptr) *Tree | |
| 43 | + | ||
| 44 | + | // Creates a new #GTree like g_tree_new() and allows to specify functions | |
| 45 | + | // to free the memory allocated for the key and value that get called when | |
| 46 | + | // removing the entry from the #GTree. | |
| 47 | + | func NewFullTree(KeyCompareFuncVar CompareDataFunc, KeyCompareDataVar uintptr, KeyDestroyFuncVar DestroyNotify, ValueDestroyFuncVar DestroyNotify) *Tree { | |
| 48 | + | ||
| 49 | + | cret := xNewFullTree(purego.NewCallback(KeyCompareFuncVar), KeyCompareDataVar, purego.NewCallback(KeyDestroyFuncVar), purego.NewCallback(ValueDestroyFuncVar)) | |
| 50 | + | return cret | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | var xNewWithDataTree func(uintptr, uintptr) *Tree | |
| 54 | + | ||
| 55 | + | // Creates a new #GTree with a comparison function that accepts user data. | |
| 56 | + | // See g_tree_new() for more details. | |
| 57 | + | func NewWithDataTree(KeyCompareFuncVar CompareDataFunc, KeyCompareDataVar uintptr) *Tree { | |
| 58 | + | ||
| 59 | + | cret := xNewWithDataTree(purego.NewCallback(KeyCompareFuncVar), KeyCompareDataVar) | |
| 60 | + | return cret | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | var xTreeDestroy func(uintptr) | |
| 64 | + | ||
| 65 | + | // Removes all keys and values from the #GTree and decreases its | |
| 66 | + | // reference count by one. If keys and/or values are dynamically | |
| 67 | + | // allocated, you should either free them first or create the #GTree | |
| 68 | + | // using g_tree_new_full(). In the latter case the destroy functions | |
| 69 | + | // you supplied will be called on all keys and values before destroying | |
| 70 | + | // the #GTree. | |
| 71 | + | func (x *Tree) Destroy() { | |
| 72 | + | ||
| 73 | + | xTreeDestroy(x.GoPointer()) | |
| 74 | + | ||
| 75 | + | } | |
| 76 | + | ||
| 77 | + | var xTreeForeach func(uintptr, uintptr, uintptr) | |
| 78 | + | ||
| 79 | + | // Calls the given function for each of the key/value pairs in the #GTree. | |
| 80 | + | // The function is passed the key and value of each pair, and the given | |
| 81 | + | // @data parameter. The tree is traversed in sorted order. | |
| 82 | + | // | |
| 83 | + | // The tree may not be modified while iterating over it (you can't | |
| 84 | + | // add/remove items). To remove all items matching a predicate, you need | |
| 85 | + | // to add each item to a list in your #GTraverseFunc as you walk over | |
| 86 | + | // the tree, then walk the list and remove each item. | |
| 87 | + | func (x *Tree) Foreach(FuncVar TraverseFunc, UserDataVar uintptr) { | |
| 88 | + | ||
| 89 | + | xTreeForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 90 | + | ||
| 91 | + | } | |
| 92 | + | ||
| 93 | + | var xTreeForeachNode func(uintptr, uintptr, uintptr) | |
| 94 | + | ||
| 95 | + | // Calls the given function for each of the nodes in the #GTree. | |
| 96 | + | // The function is passed the pointer to the particular node, and the given | |
| 97 | + | // @data parameter. The tree traversal happens in-order. | |
| 98 | + | // | |
| 99 | + | // The tree may not be modified while iterating over it (you can't | |
| 100 | + | // add/remove items). To remove all items matching a predicate, you need | |
| 101 | + | // to add each item to a list in your #GTraverseFunc as you walk over | |
| 102 | + | // the tree, then walk the list and remove each item. | |
| 103 | + | func (x *Tree) ForeachNode(FuncVar TraverseNodeFunc, UserDataVar uintptr) { | |
| 104 | + | ||
| 105 | + | xTreeForeachNode(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 106 | + | ||
| 107 | + | } | |
| 108 | + | ||
| 109 | + | var xTreeHeight func(uintptr) int | |
| 110 | + | ||
| 111 | + | // Gets the height of a #GTree. | |
| 112 | + | // | |
| 113 | + | // If the #GTree contains no nodes, the height is 0. | |
| 114 | + | // If the #GTree contains only one root node the height is 1. | |
| 115 | + | // If the root node has children the height is 2, etc. | |
| 116 | + | func (x *Tree) Height() int { | |
| 117 | + | ||
| 118 | + | cret := xTreeHeight(x.GoPointer()) | |
| 119 | + | return cret | |
| 120 | + | } | |
| 121 | + | ||
| 122 | + | var xTreeInsert func(uintptr, uintptr, uintptr) | |
| 123 | + | ||
| 124 | + | // Inserts a key/value pair into a #GTree. | |
| 125 | + | // | |
| 126 | + | // Inserts a new key and value into a #GTree as g_tree_insert_node() does, | |
| 127 | + | // only this function does not return the inserted or set node. | |
| 128 | + | func (x *Tree) Insert(KeyVar uintptr, ValueVar uintptr) { | |
| 129 | + | ||
| 130 | + | xTreeInsert(x.GoPointer(), KeyVar, ValueVar) | |
| 131 | + | ||
| 132 | + | } | |
| 133 | + | ||
| 134 | + | var xTreeInsertNode func(uintptr, uintptr, uintptr) *TreeNode | |
| 135 | + | ||
| 136 | + | // Inserts a key/value pair into a #GTree. | |
| 137 | + | // | |
| 138 | + | // If the given key already exists in the #GTree its corresponding value | |
| 139 | + | // is set to the new value. If you supplied a @value_destroy_func when | |
| 140 | + | // creating the #GTree, the old value is freed using that function. If | |
| 141 | + | // you supplied a @key_destroy_func when creating the #GTree, the passed | |
| 142 | + | // key is freed using that function. | |
| 143 | + | // | |
| 144 | + | // The tree is automatically 'balanced' as new key/value pairs are added, | |
| 145 | + | // so that the distance from the root to every leaf is as small as possible. | |
| 146 | + | // The cost of maintaining a balanced tree while inserting new key/value | |
| 147 | + | // result in a O(n log(n)) operation where most of the other operations | |
| 148 | + | // are O(log(n)). | |
| 149 | + | func (x *Tree) InsertNode(KeyVar uintptr, ValueVar uintptr) *TreeNode { | |
| 150 | + | ||
| 151 | + | cret := xTreeInsertNode(x.GoPointer(), KeyVar, ValueVar) | |
| 152 | + | return cret | |
| 153 | + | } | |
| 154 | + | ||
| 155 | + | var xTreeLookup func(uintptr, uintptr) uintptr | |
| 156 | + | ||
| 157 | + | // Gets the value corresponding to the given key. Since a #GTree is | |
| 158 | + | // automatically balanced as key/value pairs are added, key lookup | |
| 159 | + | // is O(log n) (where n is the number of key/value pairs in the tree). | |
| 160 | + | func (x *Tree) Lookup(KeyVar uintptr) uintptr { | |
| 161 | + | ||
| 162 | + | cret := xTreeLookup(x.GoPointer(), KeyVar) | |
| 163 | + | return cret | |
| 164 | + | } | |
| 165 | + | ||
| 166 | + | var xTreeLookupExtended func(uintptr, uintptr, uintptr, uintptr) bool | |
| 167 | + | ||
| 168 | + | // Looks up a key in the #GTree, returning the original key and the | |
| 169 | + | // associated value. This is useful if you need to free the memory | |
| 170 | + | // allocated for the original key, for example before calling | |
| 171 | + | // g_tree_remove(). | |
| 172 | + | func (x *Tree) LookupExtended(LookupKeyVar uintptr, OrigKeyVar uintptr, ValueVar uintptr) bool { | |
| 173 | + | ||
| 174 | + | cret := xTreeLookupExtended(x.GoPointer(), LookupKeyVar, OrigKeyVar, ValueVar) | |
| 175 | + | return cret | |
| 176 | + | } | |
| 177 | + | ||
| 178 | + | var xTreeLookupNode func(uintptr, uintptr) *TreeNode | |
| 179 | + | ||
| 180 | + | // Gets the tree node corresponding to the given key. Since a #GTree is | |
| 181 | + | // automatically balanced as key/value pairs are added, key lookup | |
| 182 | + | // is O(log n) (where n is the number of key/value pairs in the tree). | |
| 183 | + | func (x *Tree) LookupNode(KeyVar uintptr) *TreeNode { | |
| 184 | + | ||
| 185 | + | cret := xTreeLookupNode(x.GoPointer(), KeyVar) | |
| 186 | + | return cret | |
| 187 | + | } | |
| 188 | + | ||
| 189 | + | var xTreeLowerBound func(uintptr, uintptr) *TreeNode | |
| 190 | + | ||
| 191 | + | // Gets the lower bound node corresponding to the given key, | |
| 192 | + | // or %NULL if the tree is empty or all the nodes in the tree | |
| 193 | + | // have keys that are strictly lower than the searched key. | |
| 194 | + | // | |
| 195 | + | // The lower bound is the first node that has its key greater | |
| 196 | + | // than or equal to the searched key. | |
| 197 | + | func (x *Tree) LowerBound(KeyVar uintptr) *TreeNode { | |
| 198 | + | ||
| 199 | + | cret := xTreeLowerBound(x.GoPointer(), KeyVar) | |
| 200 | + | return cret | |
| 201 | + | } | |
| 202 | + | ||
| 203 | + | var xTreeNnodes func(uintptr) int | |
| 204 | + | ||
| 205 | + | // Gets the number of nodes in a #GTree. | |
| 206 | + | func (x *Tree) Nnodes() int { | |
| 207 | + | ||
| 208 | + | cret := xTreeNnodes(x.GoPointer()) | |
| 209 | + | return cret | |
| 210 | + | } | |
| 211 | + | ||
| 212 | + | var xTreeNodeFirst func(uintptr) *TreeNode | |
| 213 | + | ||
| 214 | + | // Returns the first in-order node of the tree, or %NULL | |
| 215 | + | // for an empty tree. | |
| 216 | + | func (x *Tree) NodeFirst() *TreeNode { | |
| 217 | + | ||
| 218 | + | cret := xTreeNodeFirst(x.GoPointer()) | |
| 219 | + | return cret | |
| 220 | + | } | |
| 221 | + | ||
| 222 | + | var xTreeNodeLast func(uintptr) *TreeNode | |
| 223 | + | ||
| 224 | + | // Returns the last in-order node of the tree, or %NULL | |
| 225 | + | // for an empty tree. | |
| 226 | + | func (x *Tree) NodeLast() *TreeNode { | |
| 227 | + | ||
| 228 | + | cret := xTreeNodeLast(x.GoPointer()) | |
| 229 | + | return cret | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | var xTreeRef func(uintptr) *Tree | |
| 233 | + | ||
| 234 | + | // Increments the reference count of @tree by one. | |
| 235 | + | // | |
| 236 | + | // It is safe to call this function from any thread. | |
| 237 | + | func (x *Tree) Ref() *Tree { | |
| 238 | + | ||
| 239 | + | cret := xTreeRef(x.GoPointer()) | |
| 240 | + | return cret | |
| 241 | + | } | |
| 242 | + | ||
| 243 | + | var xTreeRemove func(uintptr, uintptr) bool | |
| 244 | + | ||
| 245 | + | // Removes a key/value pair from a #GTree. | |
| 246 | + | // | |
| 247 | + | // If the #GTree was created using g_tree_new_full(), the key and value | |
| 248 | + | // are freed using the supplied destroy functions, otherwise you have to | |
| 249 | + | // make sure that any dynamically allocated values are freed yourself. | |
| 250 | + | // If the key does not exist in the #GTree, the function does nothing. | |
| 251 | + | // | |
| 252 | + | // The cost of maintaining a balanced tree while removing a key/value | |
| 253 | + | // result in a O(n log(n)) operation where most of the other operations | |
| 254 | + | // are O(log(n)). | |
| 255 | + | func (x *Tree) Remove(KeyVar uintptr) bool { | |
| 256 | + | ||
| 257 | + | cret := xTreeRemove(x.GoPointer(), KeyVar) | |
| 258 | + | return cret | |
| 259 | + | } | |
| 260 | + | ||
| 261 | + | var xTreeRemoveAll func(uintptr) | |
| 262 | + | ||
| 263 | + | // Removes all nodes from a #GTree and destroys their keys and values, | |
| 264 | + | // then resets the #GTree’s root to %NULL. | |
| 265 | + | func (x *Tree) RemoveAll() { | |
| 266 | + | ||
| 267 | + | xTreeRemoveAll(x.GoPointer()) | |
| 268 | + | ||
| 269 | + | } | |
| 270 | + | ||
| 271 | + | var xTreeReplace func(uintptr, uintptr, uintptr) | |
| 272 | + | ||
| 273 | + | // Inserts a new key and value into a #GTree as g_tree_replace_node() does, | |
| 274 | + | // only this function does not return the inserted or set node. | |
| 275 | + | func (x *Tree) Replace(KeyVar uintptr, ValueVar uintptr) { | |
| 276 | + | ||
| 277 | + | xTreeReplace(x.GoPointer(), KeyVar, ValueVar) | |
| 278 | + | ||
| 279 | + | } | |
| 280 | + | ||
| 281 | + | var xTreeReplaceNode func(uintptr, uintptr, uintptr) *TreeNode | |
| 282 | + | ||
| 283 | + | // Inserts a new key and value into a #GTree similar to g_tree_insert_node(). | |
| 284 | + | // The difference is that if the key already exists in the #GTree, it gets | |
| 285 | + | // replaced by the new key. If you supplied a @value_destroy_func when | |
| 286 | + | // creating the #GTree, the old value is freed using that function. If you | |
| 287 | + | // supplied a @key_destroy_func when creating the #GTree, the old key is | |
| 288 | + | // freed using that function. | |
| 289 | + | // | |
| 290 | + | // The tree is automatically 'balanced' as new key/value pairs are added, | |
| 291 | + | // so that the distance from the root to every leaf is as small as possible. | |
| 292 | + | func (x *Tree) ReplaceNode(KeyVar uintptr, ValueVar uintptr) *TreeNode { | |
| 293 | + | ||
| 294 | + | cret := xTreeReplaceNode(x.GoPointer(), KeyVar, ValueVar) | |
| 295 | + | return cret | |
| 296 | + | } | |
| 297 | + | ||
| 298 | + | var xTreeSearch func(uintptr, uintptr, uintptr) uintptr | |
| 299 | + | ||
| 300 | + | // Searches a #GTree using @search_func. | |
| 301 | + | // | |
| 302 | + | // The @search_func is called with a pointer to the key of a key/value | |
| 303 | + | // pair in the tree, and the passed in @user_data. If @search_func returns | |
| 304 | + | // 0 for a key/value pair, then the corresponding value is returned as | |
| 305 | + | // the result of g_tree_search(). If @search_func returns -1, searching | |
| 306 | + | // will proceed among the key/value pairs that have a smaller key; if | |
| 307 | + | // @search_func returns 1, searching will proceed among the key/value | |
| 308 | + | // pairs that have a larger key. | |
| 309 | + | func (x *Tree) Search(SearchFuncVar CompareFunc, UserDataVar uintptr) uintptr { | |
| 310 | + | ||
| 311 | + | cret := xTreeSearch(x.GoPointer(), purego.NewCallback(SearchFuncVar), UserDataVar) | |
| 312 | + | return cret | |
| 313 | + | } | |
| 314 | + | ||
| 315 | + | var xTreeSearchNode func(uintptr, uintptr, uintptr) *TreeNode | |
| 316 | + | ||
| 317 | + | // Searches a #GTree using @search_func. | |
| 318 | + | // | |
| 319 | + | // The @search_func is called with a pointer to the key of a key/value | |
| 320 | + | // pair in the tree, and the passed in @user_data. If @search_func returns | |
| 321 | + | // 0 for a key/value pair, then the corresponding node is returned as | |
| 322 | + | // the result of g_tree_search(). If @search_func returns -1, searching | |
| 323 | + | // will proceed among the key/value pairs that have a smaller key; if | |
| 324 | + | // @search_func returns 1, searching will proceed among the key/value | |
| 325 | + | // pairs that have a larger key. | |
| 326 | + | func (x *Tree) SearchNode(SearchFuncVar CompareFunc, UserDataVar uintptr) *TreeNode { | |
| 327 | + | ||
| 328 | + | cret := xTreeSearchNode(x.GoPointer(), purego.NewCallback(SearchFuncVar), UserDataVar) | |
| 329 | + | return cret | |
| 330 | + | } | |
| 331 | + | ||
| 332 | + | var xTreeSteal func(uintptr, uintptr) bool | |
| 333 | + | ||
| 334 | + | // Removes a key and its associated value from a #GTree without calling | |
| 335 | + | // the key and value destroy functions. | |
| 336 | + | // | |
| 337 | + | // If the key does not exist in the #GTree, the function does nothing. | |
| 338 | + | func (x *Tree) Steal(KeyVar uintptr) bool { | |
| 339 | + | ||
| 340 | + | cret := xTreeSteal(x.GoPointer(), KeyVar) | |
| 341 | + | return cret | |
| 342 | + | } | |
| 343 | + | ||
| 344 | + | var xTreeTraverse func(uintptr, uintptr, TraverseType, uintptr) | |
| 345 | + | ||
| 346 | + | // Calls the given function for each node in the #GTree. | |
| 347 | + | func (x *Tree) Traverse(TraverseFuncVar TraverseFunc, TraverseTypeVar TraverseType, UserDataVar uintptr) { | |
| 348 | + | ||
| 349 | + | xTreeTraverse(x.GoPointer(), purego.NewCallback(TraverseFuncVar), TraverseTypeVar, UserDataVar) | |
| 350 | + | ||
| 351 | + | } | |
| 352 | + | ||
| 353 | + | var xTreeUnref func(uintptr) | |
| 354 | + | ||
| 355 | + | // Decrements the reference count of @tree by one. | |
| 356 | + | // If the reference count drops to 0, all keys and values will | |
| 357 | + | // be destroyed (if destroy functions were specified) and all | |
| 358 | + | // memory allocated by @tree will be released. | |
| 359 | + | // | |
| 360 | + | // It is safe to call this function from any thread. | |
| 361 | + | func (x *Tree) Unref() { | |
| 362 | + | ||
| 363 | + | xTreeUnref(x.GoPointer()) | |
| 364 | + | ||
| 365 | + | } | |
| 366 | + | ||
| 367 | + | var xTreeUpperBound func(uintptr, uintptr) *TreeNode | |
| 368 | + | ||
| 369 | + | // Gets the upper bound node corresponding to the given key, | |
| 370 | + | // or %NULL if the tree is empty or all the nodes in the tree | |
| 371 | + | // have keys that are lower than or equal to the searched key. | |
| 372 | + | // | |
| 373 | + | // The upper bound is the first node that has its key strictly greater | |
| 374 | + | // than the searched key. | |
| 375 | + | func (x *Tree) UpperBound(KeyVar uintptr) *TreeNode { | |
| 376 | + | ||
| 377 | + | cret := xTreeUpperBound(x.GoPointer(), KeyVar) | |
| 378 | + | return cret | |
| 379 | + | } | |
| 380 | + | ||
| 22 | 381 | // An opaque type which identifies a specific node in a #GTree. | |
| 23 | 382 | type TreeNode struct { | |
| 24 | 383 | } | |
| 384 | + | ||
| 385 | + | func (x *TreeNode) GoPointer() uintptr { | |
| 386 | + | return uintptr(unsafe.Pointer(x)) | |
| 387 | + | } | |
| 388 | + | ||
| 389 | + | var xTreeNodeKey func(uintptr) uintptr | |
| 390 | + | ||
| 391 | + | // Gets the key stored at a particular tree node. | |
| 392 | + | func (x *TreeNode) Key() uintptr { | |
| 393 | + | ||
| 394 | + | cret := xTreeNodeKey(x.GoPointer()) | |
| 395 | + | return cret | |
| 396 | + | } | |
| 397 | + | ||
| 398 | + | var xTreeNodeNext func(uintptr) *TreeNode | |
| 399 | + | ||
| 400 | + | // Returns the next in-order node of the tree, or %NULL | |
| 401 | + | // if the passed node was already the last one. | |
| 402 | + | func (x *TreeNode) Next() *TreeNode { | |
| 403 | + | ||
| 404 | + | cret := xTreeNodeNext(x.GoPointer()) | |
| 405 | + | return cret | |
| 406 | + | } | |
| 407 | + | ||
| 408 | + | var xTreeNodePrevious func(uintptr) *TreeNode | |
| 409 | + | ||
| 410 | + | // Returns the previous in-order node of the tree, or %NULL | |
| 411 | + | // if the passed node was already the first one. | |
| 412 | + | func (x *TreeNode) Previous() *TreeNode { | |
| 413 | + | ||
| 414 | + | cret := xTreeNodePrevious(x.GoPointer()) | |
| 415 | + | return cret | |
| 416 | + | } | |
| 417 | + | ||
| 418 | + | var xTreeNodeValue func(uintptr) uintptr | |
| 419 | + | ||
| 420 | + | // Gets the value stored at a particular tree node. | |
| 421 | + | func (x *TreeNode) Value() uintptr { | |
| 422 | + | ||
| 423 | + | cret := xTreeNodeValue(x.GoPointer()) | |
| 424 | + | return cret | |
| 425 | + | } | |
| 426 | + | ||
| 427 | + | func init() { | |
| 428 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 429 | + | if err != nil { | |
| 430 | + | panic(err) | |
| 431 | + | } | |
| 432 | + | ||
| 433 | + | core.PuregoSafeRegister(&xNewTree, lib, "g_tree_new") | |
| 434 | + | core.PuregoSafeRegister(&xNewFullTree, lib, "g_tree_new_full") | |
| 435 | + | core.PuregoSafeRegister(&xNewWithDataTree, lib, "g_tree_new_with_data") | |
| 436 | + | ||
| 437 | + | core.PuregoSafeRegister(&xTreeDestroy, lib, "g_tree_destroy") | |
| 438 | + | core.PuregoSafeRegister(&xTreeForeach, lib, "g_tree_foreach") | |
| 439 | + | core.PuregoSafeRegister(&xTreeForeachNode, lib, "g_tree_foreach_node") | |
| 440 | + | core.PuregoSafeRegister(&xTreeHeight, lib, "g_tree_height") | |
| 441 | + | core.PuregoSafeRegister(&xTreeInsert, lib, "g_tree_insert") | |
| 442 | + | core.PuregoSafeRegister(&xTreeInsertNode, lib, "g_tree_insert_node") | |
| 443 | + | core.PuregoSafeRegister(&xTreeLookup, lib, "g_tree_lookup") | |
| 444 | + | core.PuregoSafeRegister(&xTreeLookupExtended, lib, "g_tree_lookup_extended") | |
| 445 | + | core.PuregoSafeRegister(&xTreeLookupNode, lib, "g_tree_lookup_node") | |
| 446 | + | core.PuregoSafeRegister(&xTreeLowerBound, lib, "g_tree_lower_bound") | |
| 447 | + | core.PuregoSafeRegister(&xTreeNnodes, lib, "g_tree_nnodes") | |
| 448 | + | core.PuregoSafeRegister(&xTreeNodeFirst, lib, "g_tree_node_first") | |
| 449 | + | core.PuregoSafeRegister(&xTreeNodeLast, lib, "g_tree_node_last") | |
| 450 | + | core.PuregoSafeRegister(&xTreeRef, lib, "g_tree_ref") | |
| 451 | + | core.PuregoSafeRegister(&xTreeRemove, lib, "g_tree_remove") | |
| 452 | + | core.PuregoSafeRegister(&xTreeRemoveAll, lib, "g_tree_remove_all") | |
| 453 | + | core.PuregoSafeRegister(&xTreeReplace, lib, "g_tree_replace") | |
| 454 | + | core.PuregoSafeRegister(&xTreeReplaceNode, lib, "g_tree_replace_node") | |
| 455 | + | core.PuregoSafeRegister(&xTreeSearch, lib, "g_tree_search") | |
| 456 | + | core.PuregoSafeRegister(&xTreeSearchNode, lib, "g_tree_search_node") | |
| 457 | + | core.PuregoSafeRegister(&xTreeSteal, lib, "g_tree_steal") | |
| 458 | + | core.PuregoSafeRegister(&xTreeTraverse, lib, "g_tree_traverse") | |
| 459 | + | core.PuregoSafeRegister(&xTreeUnref, lib, "g_tree_unref") | |
| 460 | + | core.PuregoSafeRegister(&xTreeUpperBound, lib, "g_tree_upper_bound") | |
| 461 | + | ||
| 462 | + | core.PuregoSafeRegister(&xTreeNodeKey, lib, "g_tree_node_key") | |
| 463 | + | core.PuregoSafeRegister(&xTreeNodeNext, lib, "g_tree_node_next") | |
| 464 | + | core.PuregoSafeRegister(&xTreeNodePrevious, lib, "g_tree_node_previous") | |
| 465 | + | core.PuregoSafeRegister(&xTreeNodeValue, lib, "g_tree_node_value") | |
| 466 | + | ||
| 467 | + | } | |
M v4/glib/gtypes.go +130 -0
| @@ -1,6 +1,13 @@ | |||
| 1 | 1 | // Package glib was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | + | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | ) | |
| 10 | + | ||
| 4 | 11 | // Specifies the type of a comparison function used to compare two | |
| 5 | 12 | // values. The function should return a negative integer if the first | |
| 6 | 13 | // value comes before the second, 0 if they are equal, or a positive | |
| @@ -93,6 +100,62 @@ type TimeVal struct { | |||
| 93 | 100 | TvUsec int32 | |
| 94 | 101 | } | |
| 95 | 102 | ||
| 103 | + | func (x *TimeVal) GoPointer() uintptr { | |
| 104 | + | return uintptr(unsafe.Pointer(x)) | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | var xTimeValAdd func(uintptr, int32) | |
| 108 | + | ||
| 109 | + | // Adds the given number of microseconds to @time_. @microseconds can | |
| 110 | + | // also be negative to decrease the value of @time_. | |
| 111 | + | func (x *TimeVal) Add(MicrosecondsVar int32) { | |
| 112 | + | ||
| 113 | + | xTimeValAdd(x.GoPointer(), MicrosecondsVar) | |
| 114 | + | ||
| 115 | + | } | |
| 116 | + | ||
| 117 | + | var xTimeValToIso8601 func(uintptr) string | |
| 118 | + | ||
| 119 | + | // Converts @time_ into an RFC 3339 encoded string, relative to the | |
| 120 | + | // Coordinated Universal Time (UTC). This is one of the many formats | |
| 121 | + | // allowed by ISO 8601. | |
| 122 | + | // | |
| 123 | + | // ISO 8601 allows a large number of date/time formats, with or without | |
| 124 | + | // punctuation and optional elements. The format returned by this function | |
| 125 | + | // is a complete date and time, with optional punctuation included, the | |
| 126 | + | // UTC time zone represented as "Z", and the @tv_usec part included if | |
| 127 | + | // and only if it is nonzero, i.e. either | |
| 128 | + | // "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ". | |
| 129 | + | // | |
| 130 | + | // This corresponds to the Internet date/time format defined by | |
| 131 | + | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt), | |
| 132 | + | // and to either of the two most-precise formats defined by | |
| 133 | + | // the W3C Note | |
| 134 | + | // [Date and Time Formats](http://www.w3.org/TR/NOTE-datetime-19980827). | |
| 135 | + | // Both of these documents are profiles of ISO 8601. | |
| 136 | + | // | |
| 137 | + | // Use g_date_time_format() or g_strdup_printf() if a different | |
| 138 | + | // variation of ISO 8601 format is required. | |
| 139 | + | // | |
| 140 | + | // If @time_ represents a date which is too large to fit into a `struct tm`, | |
| 141 | + | // %NULL will be returned. This is platform dependent. Note also that since | |
| 142 | + | // `GTimeVal` stores the number of seconds as a `glong`, on 32-bit systems it | |
| 143 | + | // is subject to the year 2038 problem. Accordingly, since GLib 2.62, this | |
| 144 | + | // function has been deprecated. Equivalent functionality is available using: | |
| 145 | + | // |[ | |
| 146 | + | // GDateTime *dt = g_date_time_new_from_unix_utc (time_val); | |
| 147 | + | // iso8601_string = g_date_time_format_iso8601 (dt); | |
| 148 | + | // g_date_time_unref (dt); | |
| 149 | + | // ]| | |
| 150 | + | // | |
| 151 | + | // The return value of g_time_val_to_iso8601() has been nullable since GLib | |
| 152 | + | // 2.54; before then, GLib would crash under the same conditions. | |
| 153 | + | func (x *TimeVal) ToIso8601() string { | |
| 154 | + | ||
| 155 | + | cret := xTimeValToIso8601(x.GoPointer()) | |
| 156 | + | return cret | |
| 157 | + | } | |
| 158 | + | ||
| 96 | 159 | // The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign, | |
| 97 | 160 | // mantissa and exponent of IEEE floats and doubles. These unions are defined | |
| 98 | 161 | // as appropriate for a given platform. IEEE floats and doubles are supported | |
| @@ -104,3 +167,70 @@ type DoubleIEEE754 = uintptr | |||
| 104 | 167 | // as appropriate for a given platform. IEEE floats and doubles are supported | |
| 105 | 168 | // (used for storage) by at least Intel, PPC and Sparc. | |
| 106 | 169 | type FloatIEEE754 = uintptr | |
| 170 | + | ||
| 171 | + | const ( | |
| 172 | + | // Specifies one of the possible types of byte order. | |
| 173 | + | // See %G_BYTE_ORDER. | |
| 174 | + | BIG_ENDIAN int = 4321 | |
| 175 | + | // The base of natural logarithms. | |
| 176 | + | E float64 = 2.718282 | |
| 177 | + | // The bias by which exponents in double-precision floats are offset. | |
| 178 | + | IEEE754_DOUBLE_BIAS int = 1023 | |
| 179 | + | // The bias by which exponents in single-precision floats are offset. | |
| 180 | + | IEEE754_FLOAT_BIAS int = 127 | |
| 181 | + | // Specifies one of the possible types of byte order. | |
| 182 | + | // See %G_BYTE_ORDER. | |
| 183 | + | LITTLE_ENDIAN int = 1234 | |
| 184 | + | // The natural logarithm of 10. | |
| 185 | + | LN10 float64 = 2.302585 | |
| 186 | + | // The natural logarithm of 2. | |
| 187 | + | LN2 float64 = 0.693147 | |
| 188 | + | // Multiplying the base 2 exponent by this number yields the base 10 exponent. | |
| 189 | + | LOG_2_BASE_10 float64 = 0.301030 | |
| 190 | + | // The maximum value which can be held in a #gint16. | |
| 191 | + | MAXINT16 int16 = 32767 | |
| 192 | + | // The maximum value which can be held in a #gint32. | |
| 193 | + | MAXINT32 int32 = 2147483647 | |
| 194 | + | // The maximum value which can be held in a #gint64. | |
| 195 | + | MAXINT64 int64 = 9223372036854775807 | |
| 196 | + | // The maximum value which can be held in a #gint8. | |
| 197 | + | MAXINT8 int8 = 127 | |
| 198 | + | // The maximum value which can be held in a #guint16. | |
| 199 | + | MAXUINT16 uint16 = 65535 | |
| 200 | + | // The maximum value which can be held in a #guint32. | |
| 201 | + | MAXUINT32 uint32 = 4294967295 | |
| 202 | + | // The maximum value which can be held in a #guint64. | |
| 203 | + | MAXUINT64 uint64 = 18446744073709551615 | |
| 204 | + | // The maximum value which can be held in a #guint8. | |
| 205 | + | MAXUINT8 byte = 255 | |
| 206 | + | // The minimum value which can be held in a #gint16. | |
| 207 | + | MININT16 int16 = -32768 | |
| 208 | + | // The minimum value which can be held in a #gint32. | |
| 209 | + | MININT32 int32 = -2147483648 | |
| 210 | + | // The minimum value which can be held in a #gint64. | |
| 211 | + | MININT64 int64 = -9223372036854775808 | |
| 212 | + | // The minimum value which can be held in a #gint8. | |
| 213 | + | MININT8 int8 = -128 | |
| 214 | + | // Specifies one of the possible types of byte order | |
| 215 | + | // (currently unused). See %G_BYTE_ORDER. | |
| 216 | + | PDP_ENDIAN int = 3412 | |
| 217 | + | // The value of pi (ratio of circle's circumference to its diameter). | |
| 218 | + | PI float64 = 3.141593 | |
| 219 | + | // Pi divided by 2. | |
| 220 | + | PI_2 float64 = 1.570796 | |
| 221 | + | // Pi divided by 4. | |
| 222 | + | PI_4 float64 = 0.785398 | |
| 223 | + | // The square root of two. | |
| 224 | + | SQRT2 float64 = 1.414214 | |
| 225 | + | ) | |
| 226 | + | ||
| 227 | + | func init() { | |
| 228 | + | lib, err := purego.Dlopen(core.GetPath("GLIB"), purego.RTLD_NOW|purego.RTLD_GLOBAL) | |
| 229 | + | if err != nil { | |
| 230 | + | panic(err) | |
| 231 | + | } | |
| 232 | + | ||
| 233 | + | core.PuregoSafeRegister(&xTimeValAdd, lib, "g_time_val_add") | |
| 234 | + | core.PuregoSafeRegister(&xTimeValToIso8601, lib, "g_time_val_to_iso8601") | |
| 235 | + | ||
| 236 | + | } | |
M v4/glib/gunicode.go +8 -0
| @@ -6,6 +6,14 @@ import ( | |||
| 6 | 6 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 7 | ) | |
| 8 | 8 | ||
| 9 | + | const ( | |
| 10 | + | // The maximum length (in codepoints) of a compatibility or canonical | |
| 11 | + | // decomposition of a single Unicode character. | |
| 12 | + | // | |
| 13 | + | // This is as defined by Unicode 6.1. | |
| 14 | + | UNICHAR_MAX_DECOMPOSITION_LENGTH int = 18 | |
| 15 | + | ) | |
| 16 | + | ||
| 9 | 17 | // Defines how a Unicode string is transformed in a canonical | |
| 10 | 18 | // form, standardizing such issues as whether a character with | |
| 11 | 19 | // an accent is represented as a base character and combining | |
M v4/glib/guri.go +300 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -117,6 +119,204 @@ import ( | |||
| 117 | 119 | type Uri struct { | |
| 118 | 120 | } | |
| 119 | 121 | ||
| 122 | + | func (x *Uri) GoPointer() uintptr { | |
| 123 | + | return uintptr(unsafe.Pointer(x)) | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | var xUriGetAuthParams func(uintptr) string | |
| 127 | + | ||
| 128 | + | // Gets @uri's authentication parameters, which may contain | |
| 129 | + | // `%`-encoding, depending on the flags with which @uri was created. | |
| 130 | + | // (If @uri was not created with %G_URI_FLAGS_HAS_AUTH_PARAMS then this will | |
| 131 | + | // be %NULL.) | |
| 132 | + | // | |
| 133 | + | // Depending on the URI scheme, g_uri_parse_params() may be useful for | |
| 134 | + | // further parsing this information. | |
| 135 | + | func (x *Uri) GetAuthParams() string { | |
| 136 | + | ||
| 137 | + | cret := xUriGetAuthParams(x.GoPointer()) | |
| 138 | + | return cret | |
| 139 | + | } | |
| 140 | + | ||
| 141 | + | var xUriGetFlags func(uintptr) UriFlags | |
| 142 | + | ||
| 143 | + | // Gets @uri's flags set upon construction. | |
| 144 | + | func (x *Uri) GetFlags() UriFlags { | |
| 145 | + | ||
| 146 | + | cret := xUriGetFlags(x.GoPointer()) | |
| 147 | + | return cret | |
| 148 | + | } | |
| 149 | + | ||
| 150 | + | var xUriGetFragment func(uintptr) string | |
| 151 | + | ||
| 152 | + | // Gets @uri's fragment, which may contain `%`-encoding, depending on | |
| 153 | + | // the flags with which @uri was created. | |
| 154 | + | func (x *Uri) GetFragment() string { | |
| 155 | + | ||
| 156 | + | cret := xUriGetFragment(x.GoPointer()) | |
| 157 | + | return cret | |
| 158 | + | } | |
| 159 | + | ||
| 160 | + | var xUriGetHost func(uintptr) string | |
| 161 | + | ||
| 162 | + | // Gets @uri's host. This will never have `%`-encoded characters, | |
| 163 | + | // unless it is non-UTF-8 (which can only be the case if @uri was | |
| 164 | + | // created with %G_URI_FLAGS_NON_DNS). | |
| 165 | + | // | |
| 166 | + | // If @uri contained an IPv6 address literal, this value will be just | |
| 167 | + | // that address, without the brackets around it that are necessary in | |
| 168 | + | // the string form of the URI. Note that in this case there may also | |
| 169 | + | // be a scope ID attached to the address. Eg, `fe80::1234%“em1` (or | |
| 170 | + | // `fe80::1234%“25em1` if the string is still encoded). | |
| 171 | + | func (x *Uri) GetHost() string { | |
| 172 | + | ||
| 173 | + | cret := xUriGetHost(x.GoPointer()) | |
| 174 | + | return cret | |
| 175 | + | } | |
| 176 | + | ||
| 177 | + | var xUriGetPassword func(uintptr) string | |
| 178 | + | ||
| 179 | + | // Gets @uri's password, which may contain `%`-encoding, depending on | |
| 180 | + | // the flags with which @uri was created. (If @uri was not created | |
| 181 | + | // with %G_URI_FLAGS_HAS_PASSWORD then this will be %NULL.) | |
| 182 | + | func (x *Uri) GetPassword() string { | |
| 183 | + | ||
| 184 | + | cret := xUriGetPassword(x.GoPointer()) | |
| 185 | + | return cret | |
| 186 | + | } | |
| 187 | + | ||
| 188 | + | var xUriGetPath func(uintptr) string | |
| 189 | + | ||
| 190 | + | // Gets @uri's path, which may contain `%`-encoding, depending on the | |
| 191 | + | // flags with which @uri was created. | |
| 192 | + | func (x *Uri) GetPath() string { | |
| 193 | + | ||
| 194 | + | cret := xUriGetPath(x.GoPointer()) | |
| 195 | + | return cret | |
| 196 | + | } | |
| 197 | + | ||
| 198 | + | var xUriGetPort func(uintptr) int | |
| 199 | + | ||
| 200 | + | // Gets @uri's port. | |
| 201 | + | func (x *Uri) GetPort() int { | |
| 202 | + | ||
| 203 | + | cret := xUriGetPort(x.GoPointer()) | |
| 204 | + | return cret | |
| 205 | + | } | |
| 206 | + | ||
| 207 | + | var xUriGetQuery func(uintptr) string | |
| 208 | + | ||
| 209 | + | // Gets @uri's query, which may contain `%`-encoding, depending on the | |
| 210 | + | // flags with which @uri was created. | |
| 211 | + | // | |
| 212 | + | // For queries consisting of a series of `name=value` parameters, | |
| 213 | + | // #GUriParamsIter or g_uri_parse_params() may be useful. | |
| 214 | + | func (x *Uri) GetQuery() string { | |
| 215 | + | ||
| 216 | + | cret := xUriGetQuery(x.GoPointer()) | |
| 217 | + | return cret | |
| 218 | + | } | |
| 219 | + | ||
| 220 | + | var xUriGetScheme func(uintptr) string | |
| 221 | + | ||
| 222 | + | // Gets @uri's scheme. Note that this will always be all-lowercase, | |
| 223 | + | // regardless of the string or strings that @uri was created from. | |
| 224 | + | func (x *Uri) GetScheme() string { | |
| 225 | + | ||
| 226 | + | cret := xUriGetScheme(x.GoPointer()) | |
| 227 | + | return cret | |
| 228 | + | } | |
| 229 | + | ||
| 230 | + | var xUriGetUser func(uintptr) string | |
| 231 | + | ||
| 232 | + | // Gets the ‘username’ component of @uri's userinfo, which may contain | |
| 233 | + | // `%`-encoding, depending on the flags with which @uri was created. | |
| 234 | + | // If @uri was not created with %G_URI_FLAGS_HAS_PASSWORD or | |
| 235 | + | // %G_URI_FLAGS_HAS_AUTH_PARAMS, this is the same as g_uri_get_userinfo(). | |
| 236 | + | func (x *Uri) GetUser() string { | |
| 237 | + | ||
| 238 | + | cret := xUriGetUser(x.GoPointer()) | |
| 239 | + | return cret | |
| 240 | + | } | |
| 241 | + | ||
| 242 | + | var xUriGetUserinfo func(uintptr) string | |
| 243 | + | ||
| 244 | + | // Gets @uri's userinfo, which may contain `%`-encoding, depending on | |
| 245 | + | // the flags with which @uri was created. | |
| 246 | + | func (x *Uri) GetUserinfo() string { | |
| 247 | + | ||
| 248 | + | cret := xUriGetUserinfo(x.GoPointer()) | |
| 249 | + | return cret | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | var xUriParseRelative func(uintptr, string, UriFlags, **Error) *Uri | |
| 253 | + | ||
| 254 | + | // Parses @uri_ref according to @flags and, if it is a | |
| 255 | + | // [relative URI][relative-absolute-uris], resolves it relative to @base_uri. | |
| 256 | + | // If the result is not a valid absolute URI, it will be discarded, and an error | |
| 257 | + | // returned. | |
| 258 | + | func (x *Uri) ParseRelative(UriRefVar string, FlagsVar UriFlags) (*Uri, error) { | |
| 259 | + | var cerr *Error | |
| 260 | + | ||
| 261 | + | cret := xUriParseRelative(x.GoPointer(), UriRefVar, FlagsVar, &cerr) | |
| 262 | + | if cerr == nil { | |
| 263 | + | return cret, nil | |
| 264 | + | } | |
| 265 | + | return cret, cerr | |
| 266 | + | ||
| 267 | + | } | |
| 268 | + | ||
| 269 | + | var xUriRef func(uintptr) *Uri | |
| 270 | + | ||
| 271 | + | // Increments the reference count of @uri by one. | |
| 272 | + | func (x *Uri) Ref() *Uri { | |
| 273 | + | ||
| 274 | + | cret := xUriRef(x.GoPointer()) | |
| 275 | + | return cret | |
| 276 | + | } | |
| 277 | + | ||
| 278 | + | var xUriToString func(uintptr) string | |
| 279 | + | ||
| 280 | + | // Returns a string representing @uri. | |
| 281 | + | // | |
| 282 | + | // This is not guaranteed to return a string which is identical to the | |
| 283 | + | // string that @uri was parsed from. However, if the source URI was | |
| 284 | + | // syntactically correct (according to RFC 3986), and it was parsed | |
| 285 | + | // with %G_URI_FLAGS_ENCODED, then g_uri_to_string() is guaranteed to return | |
| 286 | + | // a string which is at least semantically equivalent to the source | |
| 287 | + | // URI (according to RFC 3986). | |
| 288 | + | // | |
| 289 | + | // If @uri might contain sensitive details, such as authentication parameters, | |
| 290 | + | // or private data in its query string, and the returned string is going to be | |
| 291 | + | // logged, then consider using g_uri_to_string_partial() to redact parts. | |
| 292 | + | func (x *Uri) ToString() string { | |
| 293 | + | ||
| 294 | + | cret := xUriToString(x.GoPointer()) | |
| 295 | + | return cret | |
| 296 | + | } | |
| 297 | + | ||
| 298 | + | var xUriToStringPartial func(uintptr, UriHideFlags) string | |
| 299 | + | ||
| 300 | + | // Returns a string representing @uri, subject to the options in | |
| 301 | + | // @flags. See g_uri_to_string() and #GUriHideFlags for more details. | |
| 302 | + | func (x *Uri) ToStringPartial(FlagsVar UriHideFlags) string { | |
| 303 | + | ||
| 304 | + | cret := xUriToStringPartial(x.GoPointer(), FlagsVar) | |
| 305 | + | return cret | |
| 306 | + | } | |
| 307 | + | ||
| 308 | + | var xUriUnref func(uintptr) | |
| 309 | + | ||
| 310 | + | // Atomically decrements the reference count of @uri by one. | |
| 311 | + | // | |
| 312 | + | // When the reference count reaches zero, the resources allocated by | |
| 313 | + | // @uri are freed | |
| 314 | + | func (x *Uri) Unref() { | |
| 315 | + | ||
| 316 | + | xUriUnref(x.GoPointer()) | |
| 317 | + | ||
| 318 | + | } | |
| 319 | + | ||
| 120 | 320 | // Many URI schemes include one or more attribute/value pairs as part of the URI | |
| 121 | 321 | // value. For example `scheme://server/path?query=string&is=there` has two | |
| 122 | 322 | // attributes – `query=string` and `is=there` – in its query part. | |
| @@ -136,6 +336,86 @@ type UriParamsIter struct { | |||
| 136 | 336 | Dummy3 uintptr | |
| 137 | 337 | } | |
| 138 | 338 | ||
| 339 | + | func (x *UriParamsIter) GoPointer() uintptr { | |
| 340 | + | return uintptr(unsafe.Pointer(x)) | |
| 341 | + | } | |
| 342 | + | ||
| 343 | + | var xUriParamsIterInit func(uintptr, string, int, string, UriParamsFlags) | |
| 344 | + | ||
| 345 | + | // Initializes an attribute/value pair iterator. | |
| 346 | + | // | |
| 347 | + | // The iterator keeps pointers to the @params and @separators arguments, those | |
| 348 | + | // variables must thus outlive the iterator and not be modified during the | |
| 349 | + | // iteration. | |
| 350 | + | // | |
| 351 | + | // If %G_URI_PARAMS_WWW_FORM is passed in @flags, `+` characters in the param | |
| 352 | + | // string will be replaced with spaces in the output. For example, `foo=bar+baz` | |
| 353 | + | // will give attribute `foo` with value `bar baz`. This is commonly used on the | |
| 354 | + | // web (the `https` and `http` schemes only), but is deprecated in favour of | |
| 355 | + | // the equivalent of encoding spaces as `%20`. | |
| 356 | + | // | |
| 357 | + | // Unlike with g_uri_parse_params(), %G_URI_PARAMS_CASE_INSENSITIVE has no | |
| 358 | + | // effect if passed to @flags for g_uri_params_iter_init(). The caller is | |
| 359 | + | // responsible for doing their own case-insensitive comparisons. | |
| 360 | + | // | |
| 361 | + | // |[<!-- language="C" --> | |
| 362 | + | // GUriParamsIter iter; | |
| 363 | + | // GError *error = NULL; | |
| 364 | + | // gchar *unowned_attr, *unowned_value; | |
| 365 | + | // | |
| 366 | + | // g_uri_params_iter_init (&iter, "foo=bar&baz=bar&Foo=frob&baz=bar2", -1, "&", G_URI_PARAMS_NONE); | |
| 367 | + | // while (g_uri_params_iter_next (&iter, &unowned_attr, &unowned_value, &error)) | |
| 368 | + | // | |
| 369 | + | // { | |
| 370 | + | // g_autofree gchar *attr = g_steal_pointer (&unowned_attr); | |
| 371 | + | // g_autofree gchar *value = g_steal_pointer (&unowned_value); | |
| 372 | + | // // do something with attr and value; this code will be called 4 times | |
| 373 | + | // // for the params string in this example: once with attr=foo and value=bar, | |
| 374 | + | // // then with baz/bar, then Foo/frob, then baz/bar2. | |
| 375 | + | // } | |
| 376 | + | // | |
| 377 | + | // if (error) | |
| 378 | + | // | |
| 379 | + | // // handle parsing error | |
| 380 | + | // | |
| 381 | + | // ]| | |
| 382 | + | func (x *UriParamsIter) Init(ParamsVar string, LengthVar int, SeparatorsVar string, FlagsVar UriParamsFlags) { | |
| 383 | + | ||
| 384 | + | xUriParamsIterInit(x.GoPointer(), ParamsVar, LengthVar, SeparatorsVar, FlagsVar) | |
| 385 | + | ||
| 386 | + | } | |
| 387 | + | ||
| 388 | + | var xUriParamsIterNext func(uintptr, string, string, **Error) bool | |
| 389 | + | ||
| 390 | + | // Advances @iter and retrieves the next attribute/value. %FALSE is returned if | |
| 391 | + | // an error has occurred (in which case @error is set), or if the end of the | |
| 392 | + | // iteration is reached (in which case @attribute and @value are set to %NULL | |
| 393 | + | // and the iterator becomes invalid). If %TRUE is returned, | |
| 394 | + | // g_uri_params_iter_next() may be called again to receive another | |
| 395 | + | // attribute/value pair. | |
| 396 | + | // | |
| 397 | + | // Note that the same @attribute may be returned multiple times, since URIs | |
| 398 | + | // allow repeated attributes. | |
| 399 | + | func (x *UriParamsIter) Next(AttributeVar string, ValueVar string) (bool, error) { | |
| 400 | + | var cerr *Error | |
| 401 | + | ||
| 402 | + | cret := xUriParamsIterNext(x.GoPointer(), AttributeVar, ValueVar, &cerr) | |
| 403 | + | if cerr == nil { | |
| 404 | + | return cret, nil | |
| 405 | + | } | |
| 406 | + | return cret, cerr | |
| 407 | + | ||
| 408 | + | } | |
| 409 | + | ||
| 410 | + | const ( | |
| 411 | + | // Generic delimiters characters as defined in | |
| 412 | + | // [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `:/?#[]@`. | |
| 413 | + | URI_RESERVED_CHARS_GENERIC_DELIMITERS string = ":/?#[]@" | |
| 414 | + | // Subcomponent delimiter characters as defined in | |
| 415 | + | // [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=`. | |
| 416 | + | URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS string = "!$&'()*+,;=" | |
| 417 | + | ) | |
| 418 | + | ||
| 139 | 419 | // Flags that describe a URI. | |
| 140 | 420 | // | |
| 141 | 421 | // When parsing a URI, if you need to choose different flags based on | |
| @@ -637,4 +917,24 @@ func init() { | |||
| 637 | 917 | core.PuregoSafeRegister(&xUriUnescapeSegment, lib, "g_uri_unescape_segment") | |
| 638 | 918 | core.PuregoSafeRegister(&xUriUnescapeString, lib, "g_uri_unescape_string") | |
| 639 | 919 | ||
| 920 | + | core.PuregoSafeRegister(&xUriGetAuthParams, lib, "g_uri_get_auth_params") | |
| 921 | + | core.PuregoSafeRegister(&xUriGetFlags, lib, "g_uri_get_flags") | |
| 922 | + | core.PuregoSafeRegister(&xUriGetFragment, lib, "g_uri_get_fragment") | |
| 923 | + | core.PuregoSafeRegister(&xUriGetHost, lib, "g_uri_get_host") | |
| 924 | + | core.PuregoSafeRegister(&xUriGetPassword, lib, "g_uri_get_password") | |
| 925 | + | core.PuregoSafeRegister(&xUriGetPath, lib, "g_uri_get_path") | |
| 926 | + | core.PuregoSafeRegister(&xUriGetPort, lib, "g_uri_get_port") | |
| 927 | + | core.PuregoSafeRegister(&xUriGetQuery, lib, "g_uri_get_query") | |
| 928 | + | core.PuregoSafeRegister(&xUriGetScheme, lib, "g_uri_get_scheme") | |
| 929 | + | core.PuregoSafeRegister(&xUriGetUser, lib, "g_uri_get_user") | |
| 930 | + | core.PuregoSafeRegister(&xUriGetUserinfo, lib, "g_uri_get_userinfo") | |
| 931 | + | core.PuregoSafeRegister(&xUriParseRelative, lib, "g_uri_parse_relative") | |
| 932 | + | core.PuregoSafeRegister(&xUriRef, lib, "g_uri_ref") | |
| 933 | + | core.PuregoSafeRegister(&xUriToString, lib, "g_uri_to_string") | |
| 934 | + | core.PuregoSafeRegister(&xUriToStringPartial, lib, "g_uri_to_string_partial") | |
| 935 | + | core.PuregoSafeRegister(&xUriUnref, lib, "g_uri_unref") | |
| 936 | + | ||
| 937 | + | core.PuregoSafeRegister(&xUriParamsIterInit, lib, "g_uri_params_iter_init") | |
| 938 | + | core.PuregoSafeRegister(&xUriParamsIterNext, lib, "g_uri_params_iter_next") | |
| 939 | + | ||
| 640 | 940 | } | |
M v4/glib/gutils.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -19,6 +21,10 @@ type DebugKey struct { | |||
| 19 | 21 | Value uint | |
| 20 | 22 | } | |
| 21 | 23 | ||
| 24 | + | func (x *DebugKey) GoPointer() uintptr { | |
| 25 | + | return uintptr(unsafe.Pointer(x)) | |
| 26 | + | } | |
| 27 | + | ||
| 22 | 28 | // Flags to modify the format of the string returned by g_format_size_full(). | |
| 23 | 29 | type FormatSizeFlags int | |
| 24 | 30 | ||
M v4/glib/gvariant.go +2361 -46 large diff (2407 lines changed): collapsed
M v4/glib/gvarianttype.go +413 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package glib | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -177,6 +179,388 @@ import ( | |||
| 177 | 179 | type VariantType struct { | |
| 178 | 180 | } | |
| 179 | 181 | ||
| 182 | + | func (x *VariantType) GoPointer() uintptr { | |
| 183 | + | return uintptr(unsafe.Pointer(x)) | |
| 184 | + | } | |
| 185 | + | ||
| 186 | + | var xNewVariantType func(string) *VariantType | |
| 187 | + | ||
| 188 | + | // Creates a new #GVariantType corresponding to the type string given | |
| 189 | + | // by @type_string. It is appropriate to call g_variant_type_free() on | |
| 190 | + | // the return value. | |
| 191 | + | // | |
| 192 | + | // It is a programmer error to call this function with an invalid type | |
| 193 | + | // string. Use g_variant_type_string_is_valid() if you are unsure. | |
| 194 | + | func NewVariantType(TypeStringVar string) *VariantType { | |
| 195 | + | ||
| 196 | + | cret := xNewVariantType(TypeStringVar) | |
| 197 | + | return cret | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | var xNewArrayVariantType func(*VariantType) *VariantType | |
| 201 | + | ||
| 202 | + | // Constructs the type corresponding to an array of elements of the | |
| 203 | + | // type @type. | |
| 204 | + | // | |
| 205 | + | // It is appropriate to call g_variant_type_free() on the return value. | |
| 206 | + | func NewArrayVariantType(ElementVar *VariantType) *VariantType { | |
| 207 | + | ||
| 208 | + | cret := xNewArrayVariantType(ElementVar) | |
| 209 | + | return cret | |
| 210 | + | } | |
| 211 | + | ||
| 212 | + | var xNewDictEntryVariantType func(*VariantType, *VariantType) *VariantType | |
| 213 | + | ||
| 214 | + | // Constructs the type corresponding to a dictionary entry with a key | |
| 215 | + | // of type @key and a value of type @value. | |
| 216 | + | // | |
| 217 | + | // It is appropriate to call g_variant_type_free() on the return value. | |
| 218 | + | func NewDictEntryVariantType(KeyVar *VariantType, ValueVar *VariantType) *VariantType { | |
| 219 | + | ||
| 220 | + | cret := xNewDictEntryVariantType(KeyVar, ValueVar) | |
| 221 | + | return cret | |
| 222 | + | } | |
| 223 | + | ||
| 224 | + | var xNewMaybeVariantType func(*VariantType) *VariantType | |
| 225 | + | ||
| 226 | + | // Constructs the type corresponding to a maybe instance containing | |
| 227 | + | // type @type or Nothing. | |
| 228 | + | // | |
| 229 | + | // It is appropriate to call g_variant_type_free() on the return value. | |
| 230 | + | func NewMaybeVariantType(ElementVar *VariantType) *VariantType { | |
| 231 | + | ||
| 232 | + | cret := xNewMaybeVariantType(ElementVar) | |
| 233 | + | return cret | |
| 234 | + | } | |
| 235 | + | ||
| 236 | + | var xNewTupleVariantType func(uintptr, int) *VariantType | |
| 237 | + | ||
| 238 | + | // Constructs a new tuple type, from @items. | |
| 239 | + | // | |
| 240 | + | // @length is the number of items in @items, or -1 to indicate that | |
| 241 | + | // @items is %NULL-terminated. | |
| 242 | + | // | |
| 243 | + | // It is appropriate to call g_variant_type_free() on the return value. | |
| 244 | + | func NewTupleVariantType(ItemsVar uintptr, LengthVar int) *VariantType { | |
| 245 | + | ||
| 246 | + | cret := xNewTupleVariantType(ItemsVar, LengthVar) | |
| 247 | + | return cret | |
| 248 | + | } | |
| 249 | + | ||
| 250 | + | var xVariantTypeCopy func(uintptr) *VariantType | |
| 251 | + | ||
| 252 | + | // Makes a copy of a #GVariantType. It is appropriate to call | |
| 253 | + | // g_variant_type_free() on the return value. @type may not be %NULL. | |
| 254 | + | func (x *VariantType) Copy() *VariantType { | |
| 255 | + | ||
| 256 | + | cret := xVariantTypeCopy(x.GoPointer()) | |
| 257 | + | return cret | |
| 258 | + | } | |
| 259 | + | ||
| 260 | + | var xVariantTypeDupString func(uintptr) string | |
| 261 | + | ||
| 262 | + | // Returns a newly-allocated copy of the type string corresponding to | |
| 263 | + | // @type. The returned string is nul-terminated. It is appropriate to | |
| 264 | + | // call g_free() on the return value. | |
| 265 | + | func (x *VariantType) DupString() string { | |
| 266 | + | ||
| 267 | + | cret := xVariantTypeDupString(x.GoPointer()) | |
| 268 | + | return cret | |
| 269 | + | } | |
| 270 | + | ||
| 271 | + | var xVariantTypeElement func(uintptr) *VariantType | |
| 272 | + | ||
| 273 | + | // Determines the element type of an array or maybe type. | |
| 274 | + | // | |
| 275 | + | // This function may only be used with array or maybe types. | |
| 276 | + | func (x *VariantType) Element() *VariantType { | |
| 277 | + | ||
| 278 | + | cret := xVariantTypeElement(x.GoPointer()) | |
| 279 | + | return cret | |
| 280 | + | } | |
| 281 | + | ||
| 282 | + | var xVariantTypeEqual func(uintptr, uintptr) bool | |
| 283 | + | ||
| 284 | + | // Compares @type1 and @type2 for equality. | |
| 285 | + | // | |
| 286 | + | // Only returns %TRUE if the types are exactly equal. Even if one type | |
| 287 | + | // is an indefinite type and the other is a subtype of it, %FALSE will | |
| 288 | + | // be returned if they are not exactly equal. If you want to check for | |
| 289 | + | // subtypes, use g_variant_type_is_subtype_of(). | |
| 290 | + | // | |
| 291 | + | // The argument types of @type1 and @type2 are only #gconstpointer to | |
| 292 | + | // allow use with #GHashTable without function pointer casting. For | |
| 293 | + | // both arguments, a valid #GVariantType must be provided. | |
| 294 | + | func (x *VariantType) Equal(Type2Var uintptr) bool { | |
| 295 | + | ||
| 296 | + | cret := xVariantTypeEqual(x.GoPointer(), Type2Var) | |
| 297 | + | return cret | |
| 298 | + | } | |
| 299 | + | ||
| 300 | + | var xVariantTypeFirst func(uintptr) *VariantType | |
| 301 | + | ||
| 302 | + | // Determines the first item type of a tuple or dictionary entry | |
| 303 | + | // type. | |
| 304 | + | // | |
| 305 | + | // This function may only be used with tuple or dictionary entry types, | |
| 306 | + | // but must not be used with the generic tuple type | |
| 307 | + | // %G_VARIANT_TYPE_TUPLE. | |
| 308 | + | // | |
| 309 | + | // In the case of a dictionary entry type, this returns the type of | |
| 310 | + | // the key. | |
| 311 | + | // | |
| 312 | + | // %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT. | |
| 313 | + | // | |
| 314 | + | // This call, together with g_variant_type_next() provides an iterator | |
| 315 | + | // interface over tuple and dictionary entry types. | |
| 316 | + | func (x *VariantType) First() *VariantType { | |
| 317 | + | ||
| 318 | + | cret := xVariantTypeFirst(x.GoPointer()) | |
| 319 | + | return cret | |
| 320 | + | } | |
| 321 | + | ||
| 322 | + | var xVariantTypeFree func(uintptr) | |
| 323 | + | ||
| 324 | + | // Frees a #GVariantType that was allocated with | |
| 325 | + | // g_variant_type_copy(), g_variant_type_new() or one of the container | |
| 326 | + | // type constructor functions. | |
| 327 | + | // | |
| 328 | + | // In the case that @type is %NULL, this function does nothing. | |
| 329 | + | // | |
| 330 | + | // Since 2.24 | |
| 331 | + | func (x *VariantType) Free() { | |
| 332 | + | ||
| 333 | + | xVariantTypeFree(x.GoPointer()) | |
| 334 | + | ||
| 335 | + | } | |
| 336 | + | ||
| 337 | + | var xVariantTypeGetStringLength func(uintptr) uint | |
| 338 | + | ||
| 339 | + | // Returns the length of the type string corresponding to the given | |
| 340 | + | // @type. This function must be used to determine the valid extent of | |
| 341 | + | // the memory region returned by g_variant_type_peek_string(). | |
| 342 | + | func (x *VariantType) GetStringLength() uint { | |
| 343 | + | ||
| 344 | + | cret := xVariantTypeGetStringLength(x.GoPointer()) | |
| 345 | + | return cret | |
| 346 | + | } | |
| 347 | + | ||
| 348 | + | var xVariantTypeHash func(uintptr) uint | |
| 349 | + | ||
| 350 | + | // Hashes @type. | |
| 351 | + | // | |
| 352 | + | // The argument type of @type is only #gconstpointer to allow use with | |
| 353 | + | // #GHashTable without function pointer casting. A valid | |
| 354 | + | // #GVariantType must be provided. | |
| 355 | + | func (x *VariantType) Hash() uint { | |
| 356 | + | ||
| 357 | + | cret := xVariantTypeHash(x.GoPointer()) | |
| 358 | + | return cret | |
| 359 | + | } | |
| 360 | + | ||
| 361 | + | var xVariantTypeIsArray func(uintptr) bool | |
| 362 | + | ||
| 363 | + | // Determines if the given @type is an array type. This is true if the | |
| 364 | + | // type string for @type starts with an 'a'. | |
| 365 | + | // | |
| 366 | + | // This function returns %TRUE for any indefinite type for which every | |
| 367 | + | // definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for | |
| 368 | + | // example. | |
| 369 | + | func (x *VariantType) IsArray() bool { | |
| 370 | + | ||
| 371 | + | cret := xVariantTypeIsArray(x.GoPointer()) | |
| 372 | + | return cret | |
| 373 | + | } | |
| 374 | + | ||
| 375 | + | var xVariantTypeIsBasic func(uintptr) bool | |
| 376 | + | ||
| 377 | + | // Determines if the given @type is a basic type. | |
| 378 | + | // | |
| 379 | + | // Basic types are booleans, bytes, integers, doubles, strings, object | |
| 380 | + | // paths and signatures. | |
| 381 | + | // | |
| 382 | + | // Only a basic type may be used as the key of a dictionary entry. | |
| 383 | + | // | |
| 384 | + | // This function returns %FALSE for all indefinite types except | |
| 385 | + | // %G_VARIANT_TYPE_BASIC. | |
| 386 | + | func (x *VariantType) IsBasic() bool { | |
| 387 | + | ||
| 388 | + | cret := xVariantTypeIsBasic(x.GoPointer()) | |
| 389 | + | return cret | |
| 390 | + | } | |
| 391 | + | ||
| 392 | + | var xVariantTypeIsContainer func(uintptr) bool | |
| 393 | + | ||
| 394 | + | // Determines if the given @type is a container type. | |
| 395 | + | // | |
| 396 | + | // Container types are any array, maybe, tuple, or dictionary | |
| 397 | + | // entry types plus the variant type. | |
| 398 | + | // | |
| 399 | + | // This function returns %TRUE for any indefinite type for which every | |
| 400 | + | // definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for | |
| 401 | + | // example. | |
| 402 | + | func (x *VariantType) IsContainer() bool { | |
| 403 | + | ||
| 404 | + | cret := xVariantTypeIsContainer(x.GoPointer()) | |
| 405 | + | return cret | |
| 406 | + | } | |
| 407 | + | ||
| 408 | + | var xVariantTypeIsDefinite func(uintptr) bool | |
| 409 | + | ||
| 410 | + | // Determines if the given @type is definite (ie: not indefinite). | |
| 411 | + | // | |
| 412 | + | // A type is definite if its type string does not contain any indefinite | |
| 413 | + | // type characters ('*', '?', or 'r'). | |
| 414 | + | // | |
| 415 | + | // A #GVariant instance may not have an indefinite type, so calling | |
| 416 | + | // this function on the result of g_variant_get_type() will always | |
| 417 | + | // result in %TRUE being returned. Calling this function on an | |
| 418 | + | // indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in | |
| 419 | + | // %FALSE being returned. | |
| 420 | + | func (x *VariantType) IsDefinite() bool { | |
| 421 | + | ||
| 422 | + | cret := xVariantTypeIsDefinite(x.GoPointer()) | |
| 423 | + | return cret | |
| 424 | + | } | |
| 425 | + | ||
| 426 | + | var xVariantTypeIsDictEntry func(uintptr) bool | |
| 427 | + | ||
| 428 | + | // Determines if the given @type is a dictionary entry type. This is | |
| 429 | + | // true if the type string for @type starts with a '{'. | |
| 430 | + | // | |
| 431 | + | // This function returns %TRUE for any indefinite type for which every | |
| 432 | + | // definite subtype is a dictionary entry type -- | |
| 433 | + | // %G_VARIANT_TYPE_DICT_ENTRY, for example. | |
| 434 | + | func (x *VariantType) IsDictEntry() bool { | |
| 435 | + | ||
| 436 | + | cret := xVariantTypeIsDictEntry(x.GoPointer()) | |
| 437 | + | return cret | |
| 438 | + | } | |
| 439 | + | ||
| 440 | + | var xVariantTypeIsMaybe func(uintptr) bool | |
| 441 | + | ||
| 442 | + | // Determines if the given @type is a maybe type. This is true if the | |
| 443 | + | // type string for @type starts with an 'm'. | |
| 444 | + | // | |
| 445 | + | // This function returns %TRUE for any indefinite type for which every | |
| 446 | + | // definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for | |
| 447 | + | // example. | |
| 448 | + | func (x *VariantType) IsMaybe() bool { | |
| 449 | + | ||
| 450 | + | cret := xVariantTypeIsMaybe(x.GoPointer()) | |
| 451 | + | return cret | |
| 452 | + | } | |
| 453 | + | ||
| 454 | + | var xVariantTypeIsSubtypeOf func(uintptr, *VariantType) bool | |
| 455 | + | ||
| 456 | + | // Checks if @type is a subtype of @supertype. | |
| 457 | + | // | |
| 458 | + | // This function returns %TRUE if @type is a subtype of @supertype. All | |
| 459 | + | // types are considered to be subtypes of themselves. Aside from that, | |
| 460 | + | // only indefinite types can have subtypes. | |
| 461 | + | func (x *VariantType) IsSubtypeOf(SupertypeVar *VariantType) bool { | |
| 462 | + | ||
| 463 | + | cret := xVariantTypeIsSubtypeOf(x.GoPointer(), SupertypeVar) | |
| 464 | + | return cret | |
| 465 | + | } | |
| 466 | + | ||
| 467 | + | var xVariantTypeIsTuple func(uintptr) bool | |
| 468 | + | ||
| 469 | + | // Determines if the given @type is a tuple type. This is true if the | |
| 470 | + | // type string for @type starts with a '(' or if @type is | |
| 471 | + | // %G_VARIANT_TYPE_TUPLE. | |
| 472 | + | // | |
| 473 | + | // This function returns %TRUE for any indefinite type for which every | |
| 474 | + | // definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for | |
| 475 | + | // example. | |
| 476 | + | func (x *VariantType) IsTuple() bool { | |
| 477 | + | ||
| 478 | + | cret := xVariantTypeIsTuple(x.GoPointer()) | |
| 479 | + | return cret | |
| 480 | + | } | |
| 481 | + | ||
| 482 | + | var xVariantTypeIsVariant func(uintptr) bool | |
| 483 | + | ||
| 484 | + | // Determines if the given @type is the variant type. | |
| 485 | + | func (x *VariantType) IsVariant() bool { | |
| 486 | + | ||
| 487 | + | cret := xVariantTypeIsVariant(x.GoPointer()) | |
| 488 | + | return cret | |
| 489 | + | } | |
| 490 | + | ||
| 491 | + | var xVariantTypeKey func(uintptr) *VariantType | |
| 492 | + | ||
| 493 | + | // Determines the key type of a dictionary entry type. | |
| 494 | + | // | |
| 495 | + | // This function may only be used with a dictionary entry type. Other | |
| 496 | + | // than the additional restriction, this call is equivalent to | |
| 497 | + | // g_variant_type_first(). | |
| 498 | + | func (x *VariantType) Key() *VariantType { | |
| 499 | + | ||
| 500 | + | cret := xVariantTypeKey(x.GoPointer()) | |
| 501 | + | return cret | |
| 502 | + | } | |
| 503 | + | ||
| 504 | + | var xVariantTypeNItems func(uintptr) uint | |
| 505 | + | ||
| 506 | + | // Determines the number of items contained in a tuple or | |
| 507 | + | // dictionary entry type. | |
| 508 | + | // | |
| 509 | + | // This function may only be used with tuple or dictionary entry types, | |
| 510 | + | // but must not be used with the generic tuple type | |
| 511 | + | // %G_VARIANT_TYPE_TUPLE. | |
| 512 | + | // | |
| 513 | + | // In the case of a dictionary entry type, this function will always | |
| 514 | + | // return 2. | |
| 515 | + | func (x *VariantType) NItems() uint { | |
| 516 | + | ||
| 517 | + | cret := xVariantTypeNItems(x.GoPointer()) | |
| 518 | + | return cret | |
| 519 | + | } | |
| 520 | + | ||
| 521 | + | var xVariantTypeNext func(uintptr) *VariantType | |
| 522 | + | ||
| 523 | + | // Determines the next item type of a tuple or dictionary entry | |
| 524 | + | // type. | |
| 525 | + | // | |
| 526 | + | // @type must be the result of a previous call to | |
| 527 | + | // g_variant_type_first() or g_variant_type_next(). | |
| 528 | + | // | |
| 529 | + | // If called on the key type of a dictionary entry then this call | |
| 530 | + | // returns the value type. If called on the value type of a dictionary | |
| 531 | + | // entry then this call returns %NULL. | |
| 532 | + | // | |
| 533 | + | // For tuples, %NULL is returned when @type is the last item in a tuple. | |
| 534 | + | func (x *VariantType) Next() *VariantType { | |
| 535 | + | ||
| 536 | + | cret := xVariantTypeNext(x.GoPointer()) | |
| 537 | + | return cret | |
| 538 | + | } | |
| 539 | + | ||
| 540 | + | var xVariantTypePeekString func(uintptr) string | |
| 541 | + | ||
| 542 | + | // Returns the type string corresponding to the given @type. The | |
| 543 | + | // result is not nul-terminated; in order to determine its length you | |
| 544 | + | // must call g_variant_type_get_string_length(). | |
| 545 | + | // | |
| 546 | + | // To get a nul-terminated string, see g_variant_type_dup_string(). | |
| 547 | + | func (x *VariantType) PeekString() string { | |
| 548 | + | ||
| 549 | + | cret := xVariantTypePeekString(x.GoPointer()) | |
| 550 | + | return cret | |
| 551 | + | } | |
| 552 | + | ||
| 553 | + | var xVariantTypeValue func(uintptr) *VariantType | |
| 554 | + | ||
| 555 | + | // Determines the value type of a dictionary entry type. | |
| 556 | + | // | |
| 557 | + | // This function may only be used with a dictionary entry type. | |
| 558 | + | func (x *VariantType) Value() *VariantType { | |
| 559 | + | ||
| 560 | + | cret := xVariantTypeValue(x.GoPointer()) | |
| 561 | + | return cret | |
| 562 | + | } | |
| 563 | + | ||
| 180 | 564 | var xVariantTypeChecked func(string) *VariantType | |
| 181 | 565 | ||
| 182 | 566 | func VariantTypeChecked(Arg0Var string) *VariantType { | |
| @@ -235,4 +619,33 @@ func init() { | |||
| 235 | 619 | core.PuregoSafeRegister(&xVariantTypeStringIsValid, lib, "g_variant_type_string_is_valid") | |
| 236 | 620 | core.PuregoSafeRegister(&xVariantTypeStringScan, lib, "g_variant_type_string_scan") | |
| 237 | 621 | ||
| 622 | + | core.PuregoSafeRegister(&xNewVariantType, lib, "g_variant_type_new") | |
| 623 | + | core.PuregoSafeRegister(&xNewArrayVariantType, lib, "g_variant_type_new_array") | |
| 624 | + | core.PuregoSafeRegister(&xNewDictEntryVariantType, lib, "g_variant_type_new_dict_entry") | |
| 625 | + | core.PuregoSafeRegister(&xNewMaybeVariantType, lib, "g_variant_type_new_maybe") | |
| 626 | + | core.PuregoSafeRegister(&xNewTupleVariantType, lib, "g_variant_type_new_tuple") | |
| 627 | + | ||
| 628 | + | core.PuregoSafeRegister(&xVariantTypeCopy, lib, "g_variant_type_copy") | |
| 629 | + | core.PuregoSafeRegister(&xVariantTypeDupString, lib, "g_variant_type_dup_string") | |
| 630 | + | core.PuregoSafeRegister(&xVariantTypeElement, lib, "g_variant_type_element") | |
| 631 | + | core.PuregoSafeRegister(&xVariantTypeEqual, lib, "g_variant_type_equal") | |
| 632 | + | core.PuregoSafeRegister(&xVariantTypeFirst, lib, "g_variant_type_first") | |
| 633 | + | core.PuregoSafeRegister(&xVariantTypeFree, lib, "g_variant_type_free") | |
| 634 | + | core.PuregoSafeRegister(&xVariantTypeGetStringLength, lib, "g_variant_type_get_string_length") | |
| 635 | + | core.PuregoSafeRegister(&xVariantTypeHash, lib, "g_variant_type_hash") | |
| 636 | + | core.PuregoSafeRegister(&xVariantTypeIsArray, lib, "g_variant_type_is_array") | |
| 637 | + | core.PuregoSafeRegister(&xVariantTypeIsBasic, lib, "g_variant_type_is_basic") | |
| 638 | + | core.PuregoSafeRegister(&xVariantTypeIsContainer, lib, "g_variant_type_is_container") | |
| 639 | + | core.PuregoSafeRegister(&xVariantTypeIsDefinite, lib, "g_variant_type_is_definite") | |
| 640 | + | core.PuregoSafeRegister(&xVariantTypeIsDictEntry, lib, "g_variant_type_is_dict_entry") | |
| 641 | + | core.PuregoSafeRegister(&xVariantTypeIsMaybe, lib, "g_variant_type_is_maybe") | |
| 642 | + | core.PuregoSafeRegister(&xVariantTypeIsSubtypeOf, lib, "g_variant_type_is_subtype_of") | |
| 643 | + | core.PuregoSafeRegister(&xVariantTypeIsTuple, lib, "g_variant_type_is_tuple") | |
| 644 | + | core.PuregoSafeRegister(&xVariantTypeIsVariant, lib, "g_variant_type_is_variant") | |
| 645 | + | core.PuregoSafeRegister(&xVariantTypeKey, lib, "g_variant_type_key") | |
| 646 | + | core.PuregoSafeRegister(&xVariantTypeNItems, lib, "g_variant_type_n_items") | |
| 647 | + | core.PuregoSafeRegister(&xVariantTypeNext, lib, "g_variant_type_next") | |
| 648 | + | core.PuregoSafeRegister(&xVariantTypePeekString, lib, "g_variant_type_peek_string") | |
| 649 | + | core.PuregoSafeRegister(&xVariantTypeValue, lib, "g_variant_type_value") | |
| 650 | + | ||
| 238 | 651 | } | |
M v4/gmodule/gmodule.go +51 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gmodule | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -25,6 +27,50 @@ type ModuleUnload func(*Module) | |||
| 25 | 27 | type Module struct { | |
| 26 | 28 | } | |
| 27 | 29 | ||
| 30 | + | func (x *Module) GoPointer() uintptr { | |
| 31 | + | return uintptr(unsafe.Pointer(x)) | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | var xModuleClose func(uintptr) bool | |
| 35 | + | ||
| 36 | + | // Closes a module. | |
| 37 | + | func (x *Module) Close() bool { | |
| 38 | + | ||
| 39 | + | cret := xModuleClose(x.GoPointer()) | |
| 40 | + | return cret | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | var xModuleMakeResident func(uintptr) | |
| 44 | + | ||
| 45 | + | // Ensures that a module will never be unloaded. | |
| 46 | + | // Any future g_module_close() calls on the module will be ignored. | |
| 47 | + | func (x *Module) MakeResident() { | |
| 48 | + | ||
| 49 | + | xModuleMakeResident(x.GoPointer()) | |
| 50 | + | ||
| 51 | + | } | |
| 52 | + | ||
| 53 | + | var xModuleName func(uintptr) string | |
| 54 | + | ||
| 55 | + | // Returns the filename that the module was opened with. | |
| 56 | + | // | |
| 57 | + | // If @module refers to the application itself, "main" is returned. | |
| 58 | + | func (x *Module) Name() string { | |
| 59 | + | ||
| 60 | + | cret := xModuleName(x.GoPointer()) | |
| 61 | + | return cret | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | var xModuleSymbol func(uintptr, string, uintptr) bool | |
| 65 | + | ||
| 66 | + | // Gets a symbol pointer from a module, such as one exported | |
| 67 | + | // by %G_MODULE_EXPORT. Note that a valid symbol can be %NULL. | |
| 68 | + | func (x *Module) Symbol(SymbolNameVar string, SymbolVar uintptr) bool { | |
| 69 | + | ||
| 70 | + | cret := xModuleSymbol(x.GoPointer(), SymbolNameVar, SymbolVar) | |
| 71 | + | return cret | |
| 72 | + | } | |
| 73 | + | ||
| 28 | 74 | // Flags passed to g_module_open(). | |
| 29 | 75 | // Note that these flags are not supported on all platforms. | |
| 30 | 76 | type ModuleFlags int | |
| @@ -103,4 +149,9 @@ func init() { | |||
| 103 | 149 | core.PuregoSafeRegister(&xNewModuleError, lib, "g_module_error") | |
| 104 | 150 | core.PuregoSafeRegister(&xModuleSupported, lib, "g_module_supported") | |
| 105 | 151 | ||
| 152 | + | core.PuregoSafeRegister(&xModuleClose, lib, "g_module_close") | |
| 153 | + | core.PuregoSafeRegister(&xModuleMakeResident, lib, "g_module_make_resident") | |
| 154 | + | core.PuregoSafeRegister(&xModuleName, lib, "g_module_name") | |
| 155 | + | core.PuregoSafeRegister(&xModuleSymbol, lib, "g_module_symbol") | |
| 156 | + | ||
| 106 | 157 | } | |
M v4/gobject/gclosure.go +311 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gobject | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -35,6 +37,10 @@ type CClosure struct { | |||
| 35 | 37 | Callback uintptr | |
| 36 | 38 | } | |
| 37 | 39 | ||
| 40 | + | func (x *CClosure) GoPointer() uintptr { | |
| 41 | + | return uintptr(unsafe.Pointer(x)) | |
| 42 | + | } | |
| 43 | + | ||
| 38 | 44 | // A #GClosure represents a callback supplied by the programmer. | |
| 39 | 45 | // | |
| 40 | 46 | // It will generally comprise a function of some kind and a marshaller | |
| @@ -105,12 +111,301 @@ type Closure struct { | |||
| 105 | 111 | Notifiers *ClosureNotifyData | |
| 106 | 112 | } | |
| 107 | 113 | ||
| 114 | + | func (x *Closure) GoPointer() uintptr { | |
| 115 | + | return uintptr(unsafe.Pointer(x)) | |
| 116 | + | } | |
| 117 | + | ||
| 118 | + | var xNewObjectClosure func(uint, uintptr) *Closure | |
| 119 | + | ||
| 120 | + | // A variant of g_closure_new_simple() which stores @object in the | |
| 121 | + | // @data field of the closure and calls g_object_watch_closure() on | |
| 122 | + | // @object and the created closure. This function is mainly useful | |
| 123 | + | // when implementing new types of closures. | |
| 124 | + | func NewObjectClosure(SizeofClosureVar uint, ObjectVar *Object) *Closure { | |
| 125 | + | ||
| 126 | + | cret := xNewObjectClosure(SizeofClosureVar, ObjectVar.GoPointer()) | |
| 127 | + | return cret | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | var xNewSimpleClosure func(uint, uintptr) *Closure | |
| 131 | + | ||
| 132 | + | // Allocates a struct of the given size and initializes the initial | |
| 133 | + | // part as a #GClosure. | |
| 134 | + | // | |
| 135 | + | // This function is mainly useful when implementing new types of closures: | |
| 136 | + | // | |
| 137 | + | // |[<!-- language="C" --> | |
| 138 | + | // typedef struct _MyClosure MyClosure; | |
| 139 | + | // struct _MyClosure | |
| 140 | + | // | |
| 141 | + | // { | |
| 142 | + | // GClosure closure; | |
| 143 | + | // // extra data goes here | |
| 144 | + | // }; | |
| 145 | + | // | |
| 146 | + | // static void | |
| 147 | + | // my_closure_finalize (gpointer notify_data, | |
| 148 | + | // | |
| 149 | + | // GClosure *closure) | |
| 150 | + | // | |
| 151 | + | // { | |
| 152 | + | // MyClosure *my_closure = (MyClosure *)closure; | |
| 153 | + | // | |
| 154 | + | // // free extra data here | |
| 155 | + | // } | |
| 156 | + | // | |
| 157 | + | // MyClosure *my_closure_new (gpointer data) | |
| 158 | + | // | |
| 159 | + | // { | |
| 160 | + | // GClosure *closure; | |
| 161 | + | // MyClosure *my_closure; | |
| 162 | + | // | |
| 163 | + | // closure = g_closure_new_simple (sizeof (MyClosure), data); | |
| 164 | + | // my_closure = (MyClosure *) closure; | |
| 165 | + | // | |
| 166 | + | // // initialize extra data here | |
| 167 | + | // | |
| 168 | + | // g_closure_add_finalize_notifier (closure, notify_data, | |
| 169 | + | // my_closure_finalize); | |
| 170 | + | // return my_closure; | |
| 171 | + | // } | |
| 172 | + | // | |
| 173 | + | // ]| | |
| 174 | + | func NewSimpleClosure(SizeofClosureVar uint, DataVar uintptr) *Closure { | |
| 175 | + | ||
| 176 | + | cret := xNewSimpleClosure(SizeofClosureVar, DataVar) | |
| 177 | + | return cret | |
| 178 | + | } | |
| 179 | + | ||
| 180 | + | var xClosureAddFinalizeNotifier func(uintptr, uintptr, uintptr) | |
| 181 | + | ||
| 182 | + | // Registers a finalization notifier which will be called when the | |
| 183 | + | // reference count of @closure goes down to 0. | |
| 184 | + | // | |
| 185 | + | // Multiple finalization notifiers on a single closure are invoked in | |
| 186 | + | // unspecified order. If a single call to g_closure_unref() results in | |
| 187 | + | // the closure being both invalidated and finalized, then the invalidate | |
| 188 | + | // notifiers will be run before the finalize notifiers. | |
| 189 | + | func (x *Closure) AddFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 190 | + | ||
| 191 | + | xClosureAddFinalizeNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 192 | + | ||
| 193 | + | } | |
| 194 | + | ||
| 195 | + | var xClosureAddInvalidateNotifier func(uintptr, uintptr, uintptr) | |
| 196 | + | ||
| 197 | + | // Registers an invalidation notifier which will be called when the | |
| 198 | + | // @closure is invalidated with g_closure_invalidate(). | |
| 199 | + | // | |
| 200 | + | // Invalidation notifiers are invoked before finalization notifiers, | |
| 201 | + | // in an unspecified order. | |
| 202 | + | func (x *Closure) AddInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 203 | + | ||
| 204 | + | xClosureAddInvalidateNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 205 | + | ||
| 206 | + | } | |
| 207 | + | ||
| 208 | + | var xClosureAddMarshalGuards func(uintptr, uintptr, uintptr, uintptr, uintptr) | |
| 209 | + | ||
| 210 | + | // Adds a pair of notifiers which get invoked before and after the | |
| 211 | + | // closure callback, respectively. | |
| 212 | + | // | |
| 213 | + | // This is typically used to protect the extra arguments for the | |
| 214 | + | // duration of the callback. See g_object_watch_closure() for an | |
| 215 | + | // example of marshal guards. | |
| 216 | + | func (x *Closure) AddMarshalGuards(PreMarshalDataVar uintptr, PreMarshalNotifyVar ClosureNotify, PostMarshalDataVar uintptr, PostMarshalNotifyVar ClosureNotify) { | |
| 217 | + | ||
| 218 | + | xClosureAddMarshalGuards(x.GoPointer(), PreMarshalDataVar, purego.NewCallback(PreMarshalNotifyVar), PostMarshalDataVar, purego.NewCallback(PostMarshalNotifyVar)) | |
| 219 | + | ||
| 220 | + | } | |
| 221 | + | ||
| 222 | + | var xClosureInvalidate func(uintptr) | |
| 223 | + | ||
| 224 | + | // Sets a flag on the closure to indicate that its calling | |
| 225 | + | // environment has become invalid, and thus causes any future | |
| 226 | + | // invocations of g_closure_invoke() on this @closure to be | |
| 227 | + | // ignored. | |
| 228 | + | // | |
| 229 | + | // Also, invalidation notifiers installed on the closure will | |
| 230 | + | // be called at this point. Note that unless you are holding a | |
| 231 | + | // reference to the closure yourself, the invalidation notifiers may | |
| 232 | + | // unref the closure and cause it to be destroyed, so if you need to | |
| 233 | + | // access the closure after calling g_closure_invalidate(), make sure | |
| 234 | + | // that you've previously called g_closure_ref(). | |
| 235 | + | // | |
| 236 | + | // Note that g_closure_invalidate() will also be called when the | |
| 237 | + | // reference count of a closure drops to zero (unless it has already | |
| 238 | + | // been invalidated before). | |
| 239 | + | func (x *Closure) Invalidate() { | |
| 240 | + | ||
| 241 | + | xClosureInvalidate(x.GoPointer()) | |
| 242 | + | ||
| 243 | + | } | |
| 244 | + | ||
| 245 | + | var xClosureInvoke func(uintptr, *Value, uint, uintptr, uintptr) | |
| 246 | + | ||
| 247 | + | // Invokes the closure, i.e. executes the callback represented by the @closure. | |
| 248 | + | func (x *Closure) Invoke(ReturnValueVar *Value, NParamValuesVar uint, ParamValuesVar uintptr, InvocationHintVar uintptr) { | |
| 249 | + | ||
| 250 | + | xClosureInvoke(x.GoPointer(), ReturnValueVar, NParamValuesVar, ParamValuesVar, InvocationHintVar) | |
| 251 | + | ||
| 252 | + | } | |
| 253 | + | ||
| 254 | + | var xClosureRef func(uintptr) *Closure | |
| 255 | + | ||
| 256 | + | // Increments the reference count on a closure to force it staying | |
| 257 | + | // alive while the caller holds a pointer to it. | |
| 258 | + | func (x *Closure) Ref() *Closure { | |
| 259 | + | ||
| 260 | + | cret := xClosureRef(x.GoPointer()) | |
| 261 | + | return cret | |
| 262 | + | } | |
| 263 | + | ||
| 264 | + | var xClosureRemoveFinalizeNotifier func(uintptr, uintptr, uintptr) | |
| 265 | + | ||
| 266 | + | // Removes a finalization notifier. | |
| 267 | + | // | |
| 268 | + | // Notice that notifiers are automatically removed after they are run. | |
| 269 | + | func (x *Closure) RemoveFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 270 | + | ||
| 271 | + | xClosureRemoveFinalizeNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 272 | + | ||
| 273 | + | } | |
| 274 | + | ||
| 275 | + | var xClosureRemoveInvalidateNotifier func(uintptr, uintptr, uintptr) | |
| 276 | + | ||
| 277 | + | // Removes an invalidation notifier. | |
| 278 | + | // | |
| 279 | + | // Notice that notifiers are automatically removed after they are run. | |
| 280 | + | func (x *Closure) RemoveInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 281 | + | ||
| 282 | + | xClosureRemoveInvalidateNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 283 | + | ||
| 284 | + | } | |
| 285 | + | ||
| 286 | + | var xClosureSetMarshal func(uintptr, uintptr) | |
| 287 | + | ||
| 288 | + | // Sets the marshaller of @closure. | |
| 289 | + | // | |
| 290 | + | // The `marshal_data` of @marshal provides a way for a meta marshaller to | |
| 291 | + | // provide additional information to the marshaller. | |
| 292 | + | // | |
| 293 | + | // For GObject's C predefined marshallers (the `g_cclosure_marshal_*()` | |
| 294 | + | // functions), what it provides is a callback function to use instead of | |
| 295 | + | // @closure->callback. | |
| 296 | + | // | |
| 297 | + | // See also: g_closure_set_meta_marshal() | |
| 298 | + | func (x *Closure) SetMarshal(MarshalVar ClosureMarshal) { | |
| 299 | + | ||
| 300 | + | xClosureSetMarshal(x.GoPointer(), purego.NewCallback(MarshalVar)) | |
| 301 | + | ||
| 302 | + | } | |
| 303 | + | ||
| 304 | + | var xClosureSetMetaMarshal func(uintptr, uintptr, uintptr) | |
| 305 | + | ||
| 306 | + | // Sets the meta marshaller of @closure. | |
| 307 | + | // | |
| 308 | + | // A meta marshaller wraps the @closure's marshal and modifies the way | |
| 309 | + | // it is called in some fashion. The most common use of this facility | |
| 310 | + | // is for C callbacks. | |
| 311 | + | // | |
| 312 | + | // The same marshallers (generated by [glib-genmarshal][glib-genmarshal]), | |
| 313 | + | // are used everywhere, but the way that we get the callback function | |
| 314 | + | // differs. In most cases we want to use the @closure's callback, but in | |
| 315 | + | // other cases we want to use some different technique to retrieve the | |
| 316 | + | // callback function. | |
| 317 | + | // | |
| 318 | + | // For example, class closures for signals (see | |
| 319 | + | // g_signal_type_cclosure_new()) retrieve the callback function from a | |
| 320 | + | // fixed offset in the class structure. The meta marshaller retrieves | |
| 321 | + | // the right callback and passes it to the marshaller as the | |
| 322 | + | // @marshal_data argument. | |
| 323 | + | func (x *Closure) SetMetaMarshal(MarshalDataVar uintptr, MetaMarshalVar ClosureMarshal) { | |
| 324 | + | ||
| 325 | + | xClosureSetMetaMarshal(x.GoPointer(), MarshalDataVar, purego.NewCallback(MetaMarshalVar)) | |
| 326 | + | ||
| 327 | + | } | |
| 328 | + | ||
| 329 | + | var xClosureSink func(uintptr) | |
| 330 | + | ||
| 331 | + | // Takes over the initial ownership of a closure. | |
| 332 | + | // | |
| 333 | + | // Each closure is initially created in a "floating" state, which means | |
| 334 | + | // that the initial reference count is not owned by any caller. | |
| 335 | + | // | |
| 336 | + | // This function checks to see if the object is still floating, and if so, | |
| 337 | + | // unsets the floating state and decreases the reference count. If the | |
| 338 | + | // closure is not floating, g_closure_sink() does nothing. | |
| 339 | + | // | |
| 340 | + | // The reason for the existence of the floating state is to prevent | |
| 341 | + | // cumbersome code sequences like: | |
| 342 | + | // | |
| 343 | + | // |[<!-- language="C" --> | |
| 344 | + | // closure = g_cclosure_new (cb_func, cb_data); | |
| 345 | + | // g_source_set_closure (source, closure); | |
| 346 | + | // g_closure_unref (closure); // GObject doesn't really need this | |
| 347 | + | // ]| | |
| 348 | + | // | |
| 349 | + | // Because g_source_set_closure() (and similar functions) take ownership of the | |
| 350 | + | // initial reference count, if it is unowned, we instead can write: | |
| 351 | + | // | |
| 352 | + | // |[<!-- language="C" --> | |
| 353 | + | // g_source_set_closure (source, g_cclosure_new (cb_func, cb_data)); | |
| 354 | + | // ]| | |
| 355 | + | // | |
| 356 | + | // Generally, this function is used together with g_closure_ref(). An example | |
| 357 | + | // of storing a closure for later notification looks like: | |
| 358 | + | // | |
| 359 | + | // |[<!-- language="C" --> | |
| 360 | + | // static GClosure *notify_closure = NULL; | |
| 361 | + | // void | |
| 362 | + | // foo_notify_set_closure (GClosure *closure) | |
| 363 | + | // | |
| 364 | + | // { | |
| 365 | + | // if (notify_closure) | |
| 366 | + | // g_closure_unref (notify_closure); | |
| 367 | + | // notify_closure = closure; | |
| 368 | + | // if (notify_closure) | |
| 369 | + | // { | |
| 370 | + | // g_closure_ref (notify_closure); | |
| 371 | + | // g_closure_sink (notify_closure); | |
| 372 | + | // } | |
| 373 | + | // } | |
| 374 | + | // | |
| 375 | + | // ]| | |
| 376 | + | // | |
| 377 | + | // Because g_closure_sink() may decrement the reference count of a closure | |
| 378 | + | // (if it hasn't been called on @closure yet) just like g_closure_unref(), | |
| 379 | + | // g_closure_ref() should be called prior to this function. | |
| 380 | + | func (x *Closure) Sink() { | |
| 381 | + | ||
| 382 | + | xClosureSink(x.GoPointer()) | |
| 383 | + | ||
| 384 | + | } | |
| 385 | + | ||
| 386 | + | var xClosureUnref func(uintptr) | |
| 387 | + | ||
| 388 | + | // Decrements the reference count of a closure after it was previously | |
| 389 | + | // incremented by the same caller. | |
| 390 | + | // | |
| 391 | + | // If no other callers are using the closure, then the closure will be | |
| 392 | + | // destroyed and freed. | |
| 393 | + | func (x *Closure) Unref() { | |
| 394 | + | ||
| 395 | + | xClosureUnref(x.GoPointer()) | |
| 396 | + | ||
| 397 | + | } | |
| 398 | + | ||
| 108 | 399 | type ClosureNotifyData struct { | |
| 109 | 400 | Data uintptr | |
| 110 | 401 | ||
| 111 | 402 | Notify ClosureNotify | |
| 112 | 403 | } | |
| 113 | 404 | ||
| 405 | + | func (x *ClosureNotifyData) GoPointer() uintptr { | |
| 406 | + | return uintptr(unsafe.Pointer(x)) | |
| 407 | + | } | |
| 408 | + | ||
| 114 | 409 | var xCclosureMarshalGeneric func(*Closure, *Value, uint, *Value, uintptr, uintptr) | |
| 115 | 410 | ||
| 116 | 411 | // A generic marshaller function implemented via | |
| @@ -169,4 +464,20 @@ func init() { | |||
| 169 | 464 | core.PuregoSafeRegister(&xCclosureNewSwap, lib, "g_cclosure_new_swap") | |
| 170 | 465 | core.PuregoSafeRegister(&xSignalTypeCclosureNew, lib, "g_signal_type_cclosure_new") | |
| 171 | 466 | ||
| 467 | + | core.PuregoSafeRegister(&xNewObjectClosure, lib, "g_closure_new_object") | |
| 468 | + | core.PuregoSafeRegister(&xNewSimpleClosure, lib, "g_closure_new_simple") | |
| 469 | + | ||
| 470 | + | core.PuregoSafeRegister(&xClosureAddFinalizeNotifier, lib, "g_closure_add_finalize_notifier") | |
| 471 | + | core.PuregoSafeRegister(&xClosureAddInvalidateNotifier, lib, "g_closure_add_invalidate_notifier") | |
| 472 | + | core.PuregoSafeRegister(&xClosureAddMarshalGuards, lib, "g_closure_add_marshal_guards") | |
| 473 | + | core.PuregoSafeRegister(&xClosureInvalidate, lib, "g_closure_invalidate") | |
| 474 | + | core.PuregoSafeRegister(&xClosureInvoke, lib, "g_closure_invoke") | |
| 475 | + | core.PuregoSafeRegister(&xClosureRef, lib, "g_closure_ref") | |
| 476 | + | core.PuregoSafeRegister(&xClosureRemoveFinalizeNotifier, lib, "g_closure_remove_finalize_notifier") | |
| 477 | + | core.PuregoSafeRegister(&xClosureRemoveInvalidateNotifier, lib, "g_closure_remove_invalidate_notifier") | |
| 478 | + | core.PuregoSafeRegister(&xClosureSetMarshal, lib, "g_closure_set_marshal") | |
| 479 | + | core.PuregoSafeRegister(&xClosureSetMetaMarshal, lib, "g_closure_set_meta_marshal") | |
| 480 | + | core.PuregoSafeRegister(&xClosureSink, lib, "g_closure_sink") | |
| 481 | + | core.PuregoSafeRegister(&xClosureUnref, lib, "g_closure_unref") | |
| 482 | + | ||
| 172 | 483 | } | |
M v4/gobject/genums.go +18 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gobject | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -20,6 +22,10 @@ type EnumClass struct { | |||
| 20 | 22 | Values *EnumValue | |
| 21 | 23 | } | |
| 22 | 24 | ||
| 25 | + | func (x *EnumClass) GoPointer() uintptr { | |
| 26 | + | return uintptr(unsafe.Pointer(x)) | |
| 27 | + | } | |
| 28 | + | ||
| 23 | 29 | // A structure which contains a single enum value, its name, and its | |
| 24 | 30 | // nickname. | |
| 25 | 31 | type EnumValue struct { | |
| @@ -30,6 +36,10 @@ type EnumValue struct { | |||
| 30 | 36 | ValueNick uintptr | |
| 31 | 37 | } | |
| 32 | 38 | ||
| 39 | + | func (x *EnumValue) GoPointer() uintptr { | |
| 40 | + | return uintptr(unsafe.Pointer(x)) | |
| 41 | + | } | |
| 42 | + | ||
| 33 | 43 | // The class of a flags type holds information about its | |
| 34 | 44 | // possible values. | |
| 35 | 45 | type FlagsClass struct { | |
| @@ -42,6 +52,10 @@ type FlagsClass struct { | |||
| 42 | 52 | Values *FlagsValue | |
| 43 | 53 | } | |
| 44 | 54 | ||
| 55 | + | func (x *FlagsClass) GoPointer() uintptr { | |
| 56 | + | return uintptr(unsafe.Pointer(x)) | |
| 57 | + | } | |
| 58 | + | ||
| 45 | 59 | // A structure which contains a single flags value, its name, and its | |
| 46 | 60 | // nickname. | |
| 47 | 61 | type FlagsValue struct { | |
| @@ -52,6 +66,10 @@ type FlagsValue struct { | |||
| 52 | 66 | ValueNick uintptr | |
| 53 | 67 | } | |
| 54 | 68 | ||
| 69 | + | func (x *FlagsValue) GoPointer() uintptr { | |
| 70 | + | return uintptr(unsafe.Pointer(x)) | |
| 71 | + | } | |
| 72 | + | ||
| 55 | 73 | var xEnumCompleteTypeInfo func([]interface{}, *TypeInfo, *EnumValue) | |
| 56 | 74 | ||
| 57 | 75 | // This function is meant to be called from the `complete_type_info` | |
M v4/gobject/gobject.go +308 -0 collapsed to keep the page light
M v4/gobject/gparam.go +135 -0 collapsed to keep the page light
M v4/gobject/gsignal.go +17 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gobject | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -35,6 +37,10 @@ type SignalInvocationHint struct { | |||
| 35 | 37 | RunType SignalFlags | |
| 36 | 38 | } | |
| 37 | 39 | ||
| 40 | + | func (x *SignalInvocationHint) GoPointer() uintptr { | |
| 41 | + | return uintptr(unsafe.Pointer(x)) | |
| 42 | + | } | |
| 43 | + | ||
| 38 | 44 | // A structure holding in-depth information for a specific signal. | |
| 39 | 45 | // | |
| 40 | 46 | // See also: g_signal_query() | |
| @@ -54,6 +60,10 @@ type SignalQuery struct { | |||
| 54 | 60 | ParamTypes uintptr | |
| 55 | 61 | } | |
| 56 | 62 | ||
| 63 | + | func (x *SignalQuery) GoPointer() uintptr { | |
| 64 | + | return uintptr(unsafe.Pointer(x)) | |
| 65 | + | } | |
| 66 | + | ||
| 57 | 67 | // This is the signature of marshaller functions, required to marshall | |
| 58 | 68 | // arrays of parameter values to signal emissions into C language callback | |
| 59 | 69 | // invocations. | |
| @@ -68,6 +78,13 @@ type SignalCMarshaller = ClosureMarshal | |||
| 68 | 78 | // marshalling the signal argument into GValues. | |
| 69 | 79 | type SignalCVaMarshaller = VaClosureMarshal | |
| 70 | 80 | ||
| 81 | + | const ( | |
| 82 | + | // A mask for all #GSignalFlags bits. | |
| 83 | + | SIGNAL_FLAGS_MASK int = 511 | |
| 84 | + | // A mask for all #GSignalMatchType bits. | |
| 85 | + | SIGNAL_MATCH_MASK int = 63 | |
| 86 | + | ) | |
| 87 | + | ||
| 71 | 88 | // The connection flags are used to specify the behaviour of a signal's | |
| 72 | 89 | // connection. | |
| 73 | 90 | type ConnectFlags int | |
M v4/gobject/gtype.go +226 -0 collapsed to keep the page light
M v4/gobject/gtypemodule.go +6 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gobject | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| @@ -12,6 +14,10 @@ type TypeModuleClass struct { | |||
| 12 | 14 | ParentClass uintptr | |
| 13 | 15 | } | |
| 14 | 16 | ||
| 17 | + | func (x *TypeModuleClass) GoPointer() uintptr { | |
| 18 | + | return uintptr(unsafe.Pointer(x)) | |
| 19 | + | } | |
| 20 | + | ||
| 15 | 21 | // #GTypeModule provides a simple implementation of the #GTypePlugin | |
| 16 | 22 | // interface. | |
| 17 | 23 | // | |
M v4/gobject/gtypeplugin.go +6 -0 collapsed to keep the page light
M v4/gobject/gvalue.go +801 -0 collapsed to keep the page light
M v4/gobject/gvaluearray.go +136 -0 collapsed to keep the page light
M v4/gobject/more.go +0 -30 collapsed to keep the page light
M v4/graphene/graphene-box.go +272 -0 collapsed to keep the page light
M v4/graphene/graphene-config.go +10 -0 collapsed to keep the page light
M v4/graphene/graphene-euler.go +285 -0 collapsed to keep the page light
M v4/graphene/graphene-frustum.go +128 -0 collapsed to keep the page light
M v4/graphene/graphene-matrix.go +854 -0 collapsed to keep the page light
M v4/graphene/graphene-plane.go +182 -0 collapsed to keep the page light
M v4/graphene/graphene-point.go +139 -0 collapsed to keep the page light
M v4/graphene/graphene-point3d.go +180 -0 collapsed to keep the page light
M v4/graphene/graphene-quad.go +104 -0 collapsed to keep the page light
M v4/graphene/graphene-quaternion.go +284 -0 collapsed to keep the page light
M v4/graphene/graphene-ray.go +227 -0 collapsed to keep the page light
M v4/graphene/graphene-rect.go +407 -0 collapsed to keep the page light
M v4/graphene/graphene-size.go +82 -0 collapsed to keep the page light
M v4/graphene/graphene-sphere.go +165 -0 collapsed to keep the page light
M v4/graphene/graphene-triangle.go +215 -0 collapsed to keep the page light
M v4/graphene/graphene-vec2.go +243 -0 collapsed to keep the page light
M v4/graphene/graphene-vec3.go +317 -0 collapsed to keep the page light
M v4/graphene/graphene-vec4.go +307 -0 collapsed to keep the page light
M v4/gsk/gskbroadwayrenderer.go +6 -0 collapsed to keep the page light
M v4/gsk/gskcairorenderer.go +6 -0 collapsed to keep the page light
M v4/gsk/gskglrenderer.go +6 -0 collapsed to keep the page light
M v4/gsk/gskglshader.go +163 -0 collapsed to keep the page light
M v4/gsk/gskrenderer.go +6 -0 collapsed to keep the page light
M v4/gsk/gskrendernode.go +34 -0 collapsed to keep the page light
M v4/gsk/gskroundedrect.go +145 -0 collapsed to keep the page light
M v4/gsk/gsktypes.go +358 -0 collapsed to keep the page light
M v4/gtk/gtkaccessible.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkactionable.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkadjustment.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkapplication.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkapplicationwindow.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkatcontext.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkbinlayout.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkbitset.go +56 -0 collapsed to keep the page light
M v4/gtk/gtkbookmarklist.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkboolfilter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkborder.go +51 -0 collapsed to keep the page light
M v4/gtk/gtkbox.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkboxlayout.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkbuildable.go +122 -0 collapsed to keep the page light
M v4/gtk/gtkbuilder.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkbuilderlistitemfactory.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkbuilderscope.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkbutton.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkcellarea.go +45 -0 collapsed to keep the page light
M v4/gtk/gtkcellareacontext.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkcelleditable.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcelllayout.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcellrenderer.go +14 -0 collapsed to keep the page light
M v4/gtk/gtkcellrenderertext.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcenterbox.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcenterlayout.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcheckbutton.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcolorchooser.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcolumnview.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcolumnviewcolumn.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcombobox.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkconstraint.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkconstraintguide.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkconstraintlayout.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkcsslocation.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcssprovider.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkcsssection.go +139 -0 collapsed to keep the page light
M v4/gtk/gtkcustomfilter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcustomlayout.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkcustomsorter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdialog.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdirectorylist.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdragicon.go +68 -0 collapsed to keep the page light
M v4/gtk/gtkdragsource.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdrawingarea.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdropcontrollermotion.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdropdown.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdroptarget.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkdroptargetasync.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeditable.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeditablelabel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkemojichooser.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkentry.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkentrybuffer.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkenums.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontroller.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontrollerfocus.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontrollerkey.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontrollerlegacy.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontrollermotion.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkeventcontrollerscroll.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkexpression.go +57 -0 collapsed to keep the page light
M v4/gtk/gtkfilechoosernative.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkfilter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkfilterlistmodel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkfixed.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkfixedlayout.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkflattenlistmodel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkflowbox.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkfontchooser.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkframe.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesture.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgestureclick.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturedrag.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturelongpress.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturepan.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturerotate.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturesingle.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturestylus.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgestureswipe.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgesturezoom.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkglarea.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgrid.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkgridlayout.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkgridview.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkicontheme.go +26 -0 collapsed to keep the page light
M v4/gtk/gtkimcontext.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkimcontextsimple.go +14 -0 collapsed to keep the page light
M v4/gtk/gtkimmulticontext.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkinscription.go +6 -0 collapsed to keep the page light
M v4/gtk/gtklayoutchild.go +6 -0 collapsed to keep the page light
M v4/gtk/gtklayoutmanager.go +6 -0 collapsed to keep the page light
M v4/gtk/gtklevelbar.go +9 -0 collapsed to keep the page light
M v4/gtk/gtklistbase.go +9 -1 collapsed to keep the page light
M v4/gtk/gtklistbox.go +6 -0 collapsed to keep the page light
M v4/gtk/gtklistitem.go +6 -0 collapsed to keep the page light
M v4/gtk/gtklistitemfactory.go +9 -1 collapsed to keep the page light
M v4/gtk/gtkliststore.go +10 -0 collapsed to keep the page light
M v4/gtk/gtklistview.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmain.go +9 -0 collapsed to keep the page light
M v4/gtk/gtkmaplistmodel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmediacontrols.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmediafile.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkmediastream.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmessagedialog.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmountoperation.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkmultifilter.go +14 -0 collapsed to keep the page light
M v4/gtk/gtkmultiselection.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkmultisorter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtknative.go +6 -0 collapsed to keep the page light
M v4/gtk/gtknativedialog.go +6 -0 collapsed to keep the page light
M v4/gtk/gtknoselection.go +6 -0 collapsed to keep the page light
M v4/gtk/gtknumericsorter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkorientable.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkoverlaylayout.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkpadcontroller.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkpapersize.go +283 -0 collapsed to keep the page light
M v4/gtk/gtkpasswordentry.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkpasswordentrybuffer.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkpicture.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkpopover.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkprinter.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkprintoperation.go +10 -0 collapsed to keep the page light
M v4/gtk/gtkprintoperationpreview.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkprintsettings.go +78 -0 collapsed to keep the page light
M v4/gtk/gtkrange.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkrecentmanager.go +336 -0 collapsed to keep the page light
M v4/gtk/gtkroot.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkscale.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkscalebutton.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkscrollable.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkselectionfiltermodel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkselectionmodel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtksettings.go +41 -0 collapsed to keep the page light
M v4/gtk/gtkshortcut.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkshortcutaction.go +96 -0 collapsed to keep the page light
M v4/gtk/gtkshortcutcontroller.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkshortcutlabel.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkshortcutmanager.go +6 -0 collapsed to keep the page light
M v4/gtk/gtkshortcutsgroup.go +6 -0
| @@ -1,9 +1,15 @@ | |||
| 1 | 1 | // Package gtk was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT | |
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | + | import "unsafe" | |
| 5 | + | ||
| 4 | 6 | type ShortcutsGroupClass struct { | |
| 5 | 7 | } | |
| 6 | 8 | ||
| 9 | + | func (x *ShortcutsGroupClass) GoPointer() uintptr { | |
| 10 | + | return uintptr(unsafe.Pointer(x)) | |
| 11 | + | } | |
| 12 | + | ||
| 7 | 13 | // A `GtkShortcutsGroup` represents a group of related keyboard shortcuts | |
| 8 | 14 | // or gestures. | |
| 9 | 15 | // | |