1package gtk 2 3// #include <gtk/gtk.h> 4// #include "gtk.go.h" 5import "C" 6import ( 7 "unsafe" 8 9 "github.com/gotk3/gotk3/gdk" 10 "github.com/gotk3/gotk3/glib" 11) 12 13func init() { 14 tm := []glib.TypeMarshaler{ 15 {glib.Type(C.gtk_about_dialog_get_type()), marshalAboutDialog}, 16 } 17 18 glib.RegisterGValueMarshalers(tm) 19 20 WrapMap["GtkAboutDialog"] = wrapAboutDialog 21} 22 23/* 24 * GtkAboutDialog 25 */ 26 27// AboutDialog is a representation of GTK's GtkAboutDialog. 28type AboutDialog struct { 29 Dialog 30} 31 32// native returns a pointer to the underlying GtkAboutDialog. 33func (v *AboutDialog) native() *C.GtkAboutDialog { 34 if v == nil || v.GObject == nil { 35 return nil 36 } 37 p := unsafe.Pointer(v.GObject) 38 return C.toGtkAboutDialog(p) 39} 40 41func marshalAboutDialog(p uintptr) (interface{}, error) { 42 c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) 43 obj := glib.Take(unsafe.Pointer(c)) 44 return wrapAboutDialog(obj), nil 45} 46 47func wrapAboutDialog(obj *glib.Object) *AboutDialog { 48 return &AboutDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} 49} 50 51// AboutDialogNew is a wrapper around gtk_about_dialog_new(). 52func AboutDialogNew() (*AboutDialog, error) { 53 c := C.gtk_about_dialog_new() 54 if c == nil { 55 return nil, nilPtrErr 56 } 57 obj := glib.Take(unsafe.Pointer(c)) 58 return wrapAboutDialog(obj), nil 59} 60 61// GetComments is a wrapper around gtk_about_dialog_get_comments(). 62func (v *AboutDialog) GetComments() string { 63 c := C.gtk_about_dialog_get_comments(v.native()) 64 return C.GoString((*C.char)(c)) 65} 66 67// SetComments is a wrapper around gtk_about_dialog_set_comments(). 68func (v *AboutDialog) SetComments(comments string) { 69 cstr := C.CString(comments) 70 defer C.free(unsafe.Pointer(cstr)) 71 C.gtk_about_dialog_set_comments(v.native(), (*C.gchar)(cstr)) 72} 73 74// GetCopyright is a wrapper around gtk_about_dialog_get_copyright(). 75func (v *AboutDialog) GetCopyright() string { 76 c := C.gtk_about_dialog_get_copyright(v.native()) 77 return C.GoString((*C.char)(c)) 78} 79 80// SetCopyright is a wrapper around gtk_about_dialog_set_copyright(). 81func (v *AboutDialog) SetCopyright(copyright string) { 82 cstr := C.CString(copyright) 83 defer C.free(unsafe.Pointer(cstr)) 84 C.gtk_about_dialog_set_copyright(v.native(), (*C.gchar)(cstr)) 85} 86 87// GetLicense is a wrapper around gtk_about_dialog_get_license(). 88func (v *AboutDialog) GetLicense() string { 89 c := C.gtk_about_dialog_get_license(v.native()) 90 return C.GoString((*C.char)(c)) 91} 92 93// SetLicense is a wrapper around gtk_about_dialog_set_license(). 94func (v *AboutDialog) SetLicense(license string) { 95 cstr := C.CString(license) 96 defer C.free(unsafe.Pointer(cstr)) 97 C.gtk_about_dialog_set_license(v.native(), (*C.gchar)(cstr)) 98} 99 100// GetLicenseType is a wrapper around gtk_about_dialog_get_license_type(). 101func (v *AboutDialog) GetLicenseType() License { 102 c := C.gtk_about_dialog_get_license_type(v.native()) 103 return License(c) 104} 105 106// SetLicenseType is a wrapper around gtk_about_dialog_set_license_type(). 107func (v *AboutDialog) SetLicenseType(license License) { 108 C.gtk_about_dialog_set_license_type(v.native(), C.GtkLicense(license)) 109} 110 111// GetLogo is a wrapper around gtk_about_dialog_get_logo(). 112func (v *AboutDialog) GetLogo() (*gdk.Pixbuf, error) { 113 c := C.gtk_about_dialog_get_logo(v.native()) 114 if c == nil { 115 return nil, nilPtrErr 116 } 117 118 p := &gdk.Pixbuf{glib.Take(unsafe.Pointer(c))} 119 return p, nil 120} 121 122// SetLogo is a wrapper around gtk_about_dialog_set_logo(). 123func (v *AboutDialog) SetLogo(logo *gdk.Pixbuf) { 124 logoPtr := (*C.GdkPixbuf)(unsafe.Pointer(logo.Native())) 125 C.gtk_about_dialog_set_logo(v.native(), logoPtr) 126} 127 128// GetLogoIconName is a wrapper around gtk_about_dialog_get_logo_icon_name(). 129func (v *AboutDialog) GetLogoIconName() string { 130 c := C.gtk_about_dialog_get_logo_icon_name(v.native()) 131 return C.GoString((*C.char)(c)) 132} 133 134// SetLogoIconName is a wrapper around gtk_about_dialog_set_logo_icon_name(). 135func (v *AboutDialog) SetLogoIconName(name string) { 136 cstr := C.CString(name) 137 defer C.free(unsafe.Pointer(cstr)) 138 C.gtk_about_dialog_set_logo_icon_name(v.native(), (*C.gchar)(cstr)) 139} 140 141// GetProgramName is a wrapper around gtk_about_dialog_get_program_name(). 142func (v *AboutDialog) GetProgramName() string { 143 c := C.gtk_about_dialog_get_program_name(v.native()) 144 return C.GoString((*C.char)(c)) 145} 146 147// SetProgramName is a wrapper around gtk_about_dialog_set_program_name(). 148func (v *AboutDialog) SetProgramName(name string) { 149 cstr := C.CString(name) 150 defer C.free(unsafe.Pointer(cstr)) 151 C.gtk_about_dialog_set_program_name(v.native(), (*C.gchar)(cstr)) 152} 153 154// GetAuthors is a wrapper around gtk_about_dialog_get_authors(). 155func (v *AboutDialog) GetAuthors() []string { 156 var authors []string 157 cauthors := C.gtk_about_dialog_get_authors(v.native()) 158 if cauthors == nil { 159 return nil 160 } 161 for { 162 if *cauthors == nil { 163 break 164 } 165 authors = append(authors, C.GoString((*C.char)(*cauthors))) 166 cauthors = C.next_gcharptr(cauthors) 167 } 168 return authors 169} 170 171// SetAuthors is a wrapper around gtk_about_dialog_set_authors(). 172func (v *AboutDialog) SetAuthors(authors []string) { 173 cauthors := C.make_strings(C.int(len(authors) + 1)) 174 for i, author := range authors { 175 cstr := C.CString(author) 176 defer C.free(unsafe.Pointer(cstr)) 177 C.set_string(cauthors, C.int(i), (*C.gchar)(cstr)) 178 } 179 180 C.set_string(cauthors, C.int(len(authors)), nil) 181 C.gtk_about_dialog_set_authors(v.native(), cauthors) 182 C.destroy_strings(cauthors) 183} 184 185// GetArtists is a wrapper around gtk_about_dialog_get_artists(). 186func (v *AboutDialog) GetArtists() []string { 187 var artists []string 188 cartists := C.gtk_about_dialog_get_artists(v.native()) 189 if cartists == nil { 190 return nil 191 } 192 for { 193 if *cartists == nil { 194 break 195 } 196 artists = append(artists, C.GoString((*C.char)(*cartists))) 197 cartists = C.next_gcharptr(cartists) 198 } 199 return artists 200} 201 202// SetArtists is a wrapper around gtk_about_dialog_set_artists(). 203func (v *AboutDialog) SetArtists(artists []string) { 204 cartists := C.make_strings(C.int(len(artists) + 1)) 205 for i, artist := range artists { 206 cstr := C.CString(artist) 207 defer C.free(unsafe.Pointer(cstr)) 208 C.set_string(cartists, C.int(i), (*C.gchar)(cstr)) 209 } 210 211 C.set_string(cartists, C.int(len(artists)), nil) 212 C.gtk_about_dialog_set_artists(v.native(), cartists) 213 C.destroy_strings(cartists) 214} 215 216// GetDocumenters is a wrapper around gtk_about_dialog_get_documenters(). 217func (v *AboutDialog) GetDocumenters() []string { 218 var documenters []string 219 cdocumenters := C.gtk_about_dialog_get_documenters(v.native()) 220 if cdocumenters == nil { 221 return nil 222 } 223 for { 224 if *cdocumenters == nil { 225 break 226 } 227 documenters = append(documenters, C.GoString((*C.char)(*cdocumenters))) 228 cdocumenters = C.next_gcharptr(cdocumenters) 229 } 230 return documenters 231} 232 233// SetDocumenters is a wrapper around gtk_about_dialog_set_documenters(). 234func (v *AboutDialog) SetDocumenters(documenters []string) { 235 cdocumenters := C.make_strings(C.int(len(documenters) + 1)) 236 for i, doc := range documenters { 237 cstr := C.CString(doc) 238 defer C.free(unsafe.Pointer(cstr)) 239 C.set_string(cdocumenters, C.int(i), (*C.gchar)(cstr)) 240 } 241 242 C.set_string(cdocumenters, C.int(len(documenters)), nil) 243 C.gtk_about_dialog_set_documenters(v.native(), cdocumenters) 244 C.destroy_strings(cdocumenters) 245} 246 247// GetTranslatorCredits is a wrapper around gtk_about_dialog_get_translator_credits(). 248func (v *AboutDialog) GetTranslatorCredits() string { 249 c := C.gtk_about_dialog_get_translator_credits(v.native()) 250 return C.GoString((*C.char)(c)) 251} 252 253// SetTranslatorCredits is a wrapper around gtk_about_dialog_set_translator_credits(). 254func (v *AboutDialog) SetTranslatorCredits(translatorCredits string) { 255 cstr := C.CString(translatorCredits) 256 defer C.free(unsafe.Pointer(cstr)) 257 C.gtk_about_dialog_set_translator_credits(v.native(), (*C.gchar)(cstr)) 258} 259 260// GetVersion is a wrapper around gtk_about_dialog_get_version(). 261func (v *AboutDialog) GetVersion() string { 262 c := C.gtk_about_dialog_get_version(v.native()) 263 return C.GoString((*C.char)(c)) 264} 265 266// SetVersion is a wrapper around gtk_about_dialog_set_version(). 267func (v *AboutDialog) SetVersion(version string) { 268 cstr := C.CString(version) 269 defer C.free(unsafe.Pointer(cstr)) 270 C.gtk_about_dialog_set_version(v.native(), (*C.gchar)(cstr)) 271} 272 273// GetWebsite is a wrapper around gtk_about_dialog_get_website(). 274func (v *AboutDialog) GetWebsite() string { 275 c := C.gtk_about_dialog_get_website(v.native()) 276 return C.GoString((*C.char)(c)) 277} 278 279// SetWebsite is a wrapper around gtk_about_dialog_set_website(). 280func (v *AboutDialog) SetWebsite(website string) { 281 cstr := C.CString(website) 282 defer C.free(unsafe.Pointer(cstr)) 283 C.gtk_about_dialog_set_website(v.native(), (*C.gchar)(cstr)) 284} 285 286// GetWebsiteLabel is a wrapper around gtk_about_dialog_get_website_label(). 287func (v *AboutDialog) GetWebsiteLabel() string { 288 c := C.gtk_about_dialog_get_website_label(v.native()) 289 return C.GoString((*C.char)(c)) 290} 291 292// SetWebsiteLabel is a wrapper around gtk_about_dialog_set_website_label(). 293func (v *AboutDialog) SetWebsiteLabel(websiteLabel string) { 294 cstr := C.CString(websiteLabel) 295 defer C.free(unsafe.Pointer(cstr)) 296 C.gtk_about_dialog_set_website_label(v.native(), (*C.gchar)(cstr)) 297} 298 299// GetWrapLicense is a wrapper around gtk_about_dialog_get_wrap_license(). 300func (v *AboutDialog) GetWrapLicense() bool { 301 return gobool(C.gtk_about_dialog_get_wrap_license(v.native())) 302} 303 304// SetWrapLicense is a wrapper around gtk_about_dialog_set_wrap_license(). 305func (v *AboutDialog) SetWrapLicense(wrapLicense bool) { 306 C.gtk_about_dialog_set_wrap_license(v.native(), gbool(wrapLicense)) 307} 308 309// AddCreditSection is a wrapper around gtk_about_dialog_add_credit_section(). 310func (v *AboutDialog) AddCreditSection(sectionName string, people []string) { 311 cname := (*C.gchar)(C.CString(sectionName)) 312 defer C.free(unsafe.Pointer(cname)) 313 314 cpeople := C.make_strings(C.int(len(people)) + 1) 315 defer C.destroy_strings(cpeople) 316 for i, p := range people { 317 cp := (*C.gchar)(C.CString(p)) 318 defer C.free(unsafe.Pointer(cp)) 319 C.set_string(cpeople, C.int(i), cp) 320 } 321 C.set_string(cpeople, C.int(len(people)), nil) 322 323 C.gtk_about_dialog_add_credit_section(v.native(), cname, cpeople) 324} 325