1// Same copyright and license as the rest of the files in this project
2
3package gtk
4
5// #include <gtk/gtk.h>
6// #include "gtk.go.h"
7import "C"
8import (
9	"errors"
10	"runtime"
11	"unsafe"
12
13	"github.com/gotk3/gotk3/gdk"
14	"github.com/gotk3/gotk3/glib"
15)
16
17/*
18 * GtkWindow
19 */
20
21// gtk_window_set_has_user_ref_count is NOT included, see GTK documentation for why that is.
22
23// Window is a representation of GTK's GtkWindow.
24type Window struct {
25	Bin
26}
27
28// IWindow is an interface type implemented by all structs embedding a
29// Window.  It is meant to be used as an argument type for wrapper
30// functions that wrap around a C GTK function taking a GtkWindow.
31type IWindow interface {
32	toWindow() *C.GtkWindow
33	ToWindow() *Window
34}
35
36// native returns a pointer to the underlying GtkWindow.
37func (v *Window) native() *C.GtkWindow {
38	if v == nil || v.GObject == nil {
39		return nil
40	}
41	p := unsafe.Pointer(v.GObject)
42	return C.toGtkWindow(p)
43}
44
45func (v *Window) toWindow() *C.GtkWindow {
46	if v == nil {
47		return nil
48	}
49	return v.native()
50}
51
52// ToWindow is a helper getter, e.g.: it returns *gtk.ApplicationWindow as a *gtk.Window.
53// In other cases, where you have a gtk.IWindow, use the type assertion.
54func (v *Window) ToWindow() *Window {
55	return v
56}
57
58func marshalWindow(p uintptr) (interface{}, error) {
59	c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
60	obj := glib.Take(unsafe.Pointer(c))
61	return wrapWindow(obj), nil
62}
63
64func wrapWindow(obj *glib.Object) *Window {
65	if obj == nil {
66		return nil
67	}
68
69	return &Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}
70}
71
72// WindowNew is a wrapper around gtk_window_new().
73func WindowNew(t WindowType) (*Window, error) {
74	c := C.gtk_window_new(C.GtkWindowType(t))
75	if c == nil {
76		return nil, nilPtrErr
77	}
78	return wrapWindow(glib.Take(unsafe.Pointer(c))), nil
79}
80
81// SetTitle is a wrapper around gtk_window_set_title().
82func (v *Window) SetTitle(title string) {
83	cstr := C.CString(title)
84	defer C.free(unsafe.Pointer(cstr))
85	C.gtk_window_set_title(v.native(), (*C.gchar)(cstr))
86}
87
88// SetResizable is a wrapper around gtk_window_set_resizable().
89func (v *Window) SetResizable(resizable bool) {
90	C.gtk_window_set_resizable(v.native(), gbool(resizable))
91}
92
93// GetResizable is a wrapper around gtk_window_get_resizable().
94func (v *Window) GetResizable() bool {
95	c := C.gtk_window_get_resizable(v.native())
96	return gobool(c)
97}
98
99// ActivateFocus is a wrapper around gtk_window_activate_focus().
100func (v *Window) ActivateFocus() bool {
101	c := C.gtk_window_activate_focus(v.native())
102	return gobool(c)
103}
104
105// ActivateDefault is a wrapper around gtk_window_activate_default().
106func (v *Window) ActivateDefault() bool {
107	c := C.gtk_window_activate_default(v.native())
108	return gobool(c)
109}
110
111// SetModal is a wrapper around gtk_window_set_modal().
112func (v *Window) SetModal(modal bool) {
113	C.gtk_window_set_modal(v.native(), gbool(modal))
114}
115
116// SetDefaultSize is a wrapper around gtk_window_set_default_size().
117func (v *Window) SetDefaultSize(width, height int) {
118	C.gtk_window_set_default_size(v.native(), C.gint(width), C.gint(height))
119}
120
121// SetIcon is a wrapper around gtk_window_set_icon().
122func (v *Window) SetIcon(icon *gdk.Pixbuf) {
123	iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native()))
124	C.gtk_window_set_icon(v.native(), iconPtr)
125}
126
127// WindowSetDefaultIcon is a wrapper around gtk_window_set_default_icon().
128func WindowSetDefaultIcon(icon *gdk.Pixbuf) {
129	iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native()))
130	C.gtk_window_set_default_icon(iconPtr)
131}
132
133// SetGeometryHints is a wrapper around gtk_window_set_geometry_hints().
134func (v *Window) SetGeometryHints(geometryWidget IWidget, geometry gdk.Geometry, geometryMask gdk.WindowHints) {
135	var gW *C.GtkWidget = nil
136	if geometryWidget != nil {
137		gW = geometryWidget.toWidget()
138	}
139	C.gtk_window_set_geometry_hints(v.native(), gW, nativeGdkGeometry(geometry), C.GdkWindowHints(geometryMask))
140}
141
142// SetGravity is a wrapper around gtk_window_set_gravity().
143func (v *Window) SetGravity(gravity gdk.Gravity) {
144	C.gtk_window_set_gravity(v.native(), C.GdkGravity(gravity))
145}
146
147// GetGravity is a wrapper around gtk_window_get_gravity().
148func (v *Window) GetGravity() gdk.Gravity {
149	c := C.gtk_window_get_gravity(v.native())
150	return gdk.Gravity(c)
151}
152
153// SetPosition is a wrapper around gtk_window_set_position().
154func (v *Window) SetPosition(position WindowPosition) {
155	C.gtk_window_set_position(v.native(), C.GtkWindowPosition(position))
156}
157
158// SetTransientFor is a wrapper around gtk_window_set_transient_for().
159func (v *Window) SetTransientFor(parent IWindow) {
160	var pw *C.GtkWindow = nil
161	if parent != nil {
162		pw = parent.toWindow()
163	}
164	C.gtk_window_set_transient_for(v.native(), pw)
165}
166
167// SetAttachedTo is a wrapper around gtk_window_set_attached_to().
168func (v *Window) SetAttachedTo(attachWidget IWidget) {
169	var aW *C.GtkWidget = nil
170	if attachWidget != nil {
171		aW = attachWidget.toWidget()
172	}
173	C.gtk_window_set_attached_to(v.native(), aW)
174}
175
176// SetDestroyWithParent is a wrapper around
177// gtk_window_set_destroy_with_parent().
178func (v *Window) SetDestroyWithParent(setting bool) {
179	C.gtk_window_set_destroy_with_parent(v.native(), gbool(setting))
180}
181
182// SetHideTitlebarWhenMaximized is a wrapper around
183// gtk_window_set_hide_titlebar_when_maximized().
184func (v *Window) SetHideTitlebarWhenMaximized(setting bool) {
185	C.gtk_window_set_hide_titlebar_when_maximized(v.native(),
186		gbool(setting))
187}
188
189// IsActive is a wrapper around gtk_window_is_active().
190func (v *Window) IsActive() bool {
191	c := C.gtk_window_is_active(v.native())
192	return gobool(c)
193}
194
195// HasToplevelFocus is a wrapper around gtk_window_has_toplevel_focus().
196func (v *Window) HasToplevelFocus() bool {
197	c := C.gtk_window_has_toplevel_focus(v.native())
198	return gobool(c)
199}
200
201// GetFocus is a wrapper around gtk_window_get_focus().
202func (v *Window) GetFocus() (IWidget, error) {
203	c := C.gtk_window_get_focus(v.native())
204	if c == nil {
205		return nil, nil
206	}
207	return castWidget(c)
208}
209
210// SetFocus is a wrapper around gtk_window_set_focus().
211func (v *Window) SetFocus(w *Widget) {
212	C.gtk_window_set_focus(v.native(), w.native())
213}
214
215// GetDefaultWidget is a wrapper around gtk_window_get_default_widget().
216// See SetDefault() for the setter.
217func (v *Window) GetDefaultWidget() (IWidget, error) {
218	c := C.gtk_window_get_default_widget(v.native())
219	if c == nil {
220		return nil, nil
221	}
222	return castWidget(c)
223}
224
225// SetDefault is a wrapper around gtk_window_set_default().
226// See GetDefaultWidget() for the getter.
227func (v *Window) SetDefault(widget IWidget) {
228	C.gtk_window_set_default(v.native(), widget.toWidget())
229}
230
231// Present is a wrapper around gtk_window_present().
232func (v *Window) Present() {
233	C.gtk_window_present(v.native())
234}
235
236// PresentWithTime is a wrapper around gtk_window_present_with_time().
237func (v *Window) PresentWithTime(ts uint32) {
238	C.gtk_window_present_with_time(v.native(), C.guint32(ts))
239}
240
241// Iconify is a wrapper around gtk_window_iconify().
242func (v *Window) Iconify() {
243	C.gtk_window_iconify(v.native())
244}
245
246// Deiconify is a wrapper around gtk_window_deiconify().
247func (v *Window) Deiconify() {
248	C.gtk_window_deiconify(v.native())
249}
250
251// Stick is a wrapper around gtk_window_stick().
252func (v *Window) Stick() {
253	C.gtk_window_stick(v.native())
254}
255
256// Unstick is a wrapper around gtk_window_unstick().
257func (v *Window) Unstick() {
258	C.gtk_window_unstick(v.native())
259}
260
261// Maximize is a wrapper around gtk_window_maximize().
262func (v *Window) Maximize() {
263	C.gtk_window_maximize(v.native())
264}
265
266// Unmaximize is a wrapper around gtk_window_unmaximize().
267func (v *Window) Unmaximize() {
268	C.gtk_window_unmaximize(v.native())
269}
270
271// Fullscreen is a wrapper around gtk_window_fullscreen().
272func (v *Window) Fullscreen() {
273	C.gtk_window_fullscreen(v.native())
274}
275
276// Unfullscreen is a wrapper around gtk_window_unfullscreen().
277func (v *Window) Unfullscreen() {
278	C.gtk_window_unfullscreen(v.native())
279}
280
281// SetKeepAbove is a wrapper around gtk_window_set_keep_above().
282func (v *Window) SetKeepAbove(setting bool) {
283	C.gtk_window_set_keep_above(v.native(), gbool(setting))
284}
285
286// SetKeepBelow is a wrapper around gtk_window_set_keep_below().
287func (v *Window) SetKeepBelow(setting bool) {
288	C.gtk_window_set_keep_below(v.native(), gbool(setting))
289}
290
291// SetDecorated is a wrapper around gtk_window_set_decorated().
292func (v *Window) SetDecorated(setting bool) {
293	C.gtk_window_set_decorated(v.native(), gbool(setting))
294}
295
296// SetDeletable is a wrapper around gtk_window_set_deletable().
297func (v *Window) SetDeletable(setting bool) {
298	C.gtk_window_set_deletable(v.native(), gbool(setting))
299}
300
301// SetTypeHint is a wrapper around gtk_window_set_type_hint().
302func (v *Window) SetTypeHint(typeHint gdk.WindowTypeHint) {
303	C.gtk_window_set_type_hint(v.native(), C.GdkWindowTypeHint(typeHint))
304}
305
306// SetSkipTaskbarHint is a wrapper around gtk_window_set_skip_taskbar_hint().
307func (v *Window) SetSkipTaskbarHint(setting bool) {
308	C.gtk_window_set_skip_taskbar_hint(v.native(), gbool(setting))
309}
310
311// SetSkipPagerHint is a wrapper around gtk_window_set_skip_pager_hint().
312func (v *Window) SetSkipPagerHint(setting bool) {
313	C.gtk_window_set_skip_pager_hint(v.native(), gbool(setting))
314}
315
316// SetUrgencyHint is a wrapper around gtk_window_set_urgency_hint().
317func (v *Window) SetUrgencyHint(setting bool) {
318	C.gtk_window_set_urgency_hint(v.native(), gbool(setting))
319}
320
321// SetAcceptFocus is a wrapper around gtk_window_set_accept_focus().
322func (v *Window) SetAcceptFocus(setting bool) {
323	C.gtk_window_set_accept_focus(v.native(), gbool(setting))
324}
325
326// SetFocusOnMap is a wrapper around gtk_window_set_focus_on_map().
327func (v *Window) SetFocusOnMap(setting bool) {
328	C.gtk_window_set_focus_on_map(v.native(), gbool(setting))
329}
330
331// SetStartupID is a wrapper around gtk_window_set_startup_id().
332func (v *Window) SetStartupID(sid string) {
333	cstr := (*C.gchar)(C.CString(sid))
334	defer C.free(unsafe.Pointer(cstr))
335	C.gtk_window_set_startup_id(v.native(), cstr)
336}
337
338// SetRole is a wrapper around gtk_window_set_role().
339func (v *Window) SetRole(s string) {
340	cstr := (*C.gchar)(C.CString(s))
341	defer C.free(unsafe.Pointer(cstr))
342	C.gtk_window_set_role(v.native(), cstr)
343}
344
345// GetDecorated is a wrapper around gtk_window_get_decorated().
346func (v *Window) GetDecorated() bool {
347	c := C.gtk_window_get_decorated(v.native())
348	return gobool(c)
349}
350
351// GetDeletable is a wrapper around gtk_window_get_deletable().
352func (v *Window) GetDeletable() bool {
353	c := C.gtk_window_get_deletable(v.native())
354	return gobool(c)
355}
356
357// WindowGetDefaultIconName is a wrapper around gtk_window_get_default_icon_name().
358func WindowGetDefaultIconName() (string, error) {
359	return stringReturn(C.gtk_window_get_default_icon_name())
360}
361
362// GetDefaultSize is a wrapper around gtk_window_get_default_size().
363func (v *Window) GetDefaultSize() (width, height int) {
364	var w, h C.gint
365	C.gtk_window_get_default_size(v.native(), &w, &h)
366	return int(w), int(h)
367}
368
369// GetDestroyWithParent is a wrapper around
370// gtk_window_get_destroy_with_parent().
371func (v *Window) GetDestroyWithParent() bool {
372	c := C.gtk_window_get_destroy_with_parent(v.native())
373	return gobool(c)
374}
375
376// GetHideTitlebarWhenMaximized is a wrapper around
377// gtk_window_get_hide_titlebar_when_maximized().
378func (v *Window) GetHideTitlebarWhenMaximized() bool {
379	c := C.gtk_window_get_hide_titlebar_when_maximized(v.native())
380	return gobool(c)
381}
382
383// GetIcon is a wrapper around gtk_window_get_icon().
384func (v *Window) GetIcon() (*gdk.Pixbuf, error) {
385	c := C.gtk_window_get_icon(v.native())
386	if c == nil {
387		return nil, nil
388	}
389	return &gdk.Pixbuf{glib.Take(unsafe.Pointer(c))}, nil
390}
391
392// GetIconName is a wrapper around gtk_window_get_icon_name().
393func (v *Window) GetIconName() (string, error) {
394	return stringReturn(C.gtk_window_get_icon_name(v.native()))
395}
396
397// GetModal is a wrapper around gtk_window_get_modal().
398func (v *Window) GetModal() bool {
399	c := C.gtk_window_get_modal(v.native())
400	return gobool(c)
401}
402
403// GetPosition is a wrapper around gtk_window_get_position().
404func (v *Window) GetPosition() (int, int) {
405	var x, y C.gint
406	C.gtk_window_get_position(v.native(), &x, &y)
407	return int(x), int(y)
408}
409
410func stringReturn(c *C.gchar) (string, error) {
411	if c == nil {
412		return "", nilPtrErr
413	}
414	return C.GoString((*C.char)(c)), nil
415}
416
417// GetRole is a wrapper around gtk_window_get_role().
418func (v *Window) GetRole() (string, error) {
419	return stringReturn(C.gtk_window_get_role(v.native()))
420}
421
422// GetSize is a wrapper around gtk_window_get_size().
423func (v *Window) GetSize() (width, height int) {
424	var w, h C.gint
425	C.gtk_window_get_size(v.native(), &w, &h)
426	return int(w), int(h)
427}
428
429// GetTitle is a wrapper around gtk_window_get_title().
430func (v *Window) GetTitle() (string, error) {
431	return stringReturn(C.gtk_window_get_title(v.native()))
432}
433
434// GetTransientFor is a wrapper around gtk_window_get_transient_for().
435func (v *Window) GetTransientFor() (*Window, error) {
436	c := C.gtk_window_get_transient_for(v.native())
437	if c == nil {
438		return nil, nil
439	}
440	return wrapWindow(glib.Take(unsafe.Pointer(c))), nil
441}
442
443// GetAttachedTo is a wrapper around gtk_window_get_attached_to().
444func (v *Window) GetAttachedTo() (IWidget, error) {
445	c := C.gtk_window_get_attached_to(v.native())
446	if c == nil {
447		return nil, nil
448	}
449	return castWidget(c)
450}
451
452// GetTypeHint is a wrapper around gtk_window_get_type_hint().
453func (v *Window) GetTypeHint() gdk.WindowTypeHint {
454	c := C.gtk_window_get_type_hint(v.native())
455	return gdk.WindowTypeHint(c)
456}
457
458// GetSkipTaskbarHint is a wrapper around gtk_window_get_skip_taskbar_hint().
459func (v *Window) GetSkipTaskbarHint() bool {
460	c := C.gtk_window_get_skip_taskbar_hint(v.native())
461	return gobool(c)
462}
463
464// GetSkipPagerHint is a wrapper around gtk_window_get_skip_pager_hint().
465func (v *Window) GetSkipPagerHint() bool {
466	c := C.gtk_window_get_skip_pager_hint(v.native())
467	return gobool(c)
468}
469
470// GetUrgencyHint is a wrapper around gtk_window_get_urgency_hint().
471func (v *Window) GetUrgencyHint() bool {
472	c := C.gtk_window_get_urgency_hint(v.native())
473	return gobool(c)
474}
475
476// GetAcceptFocus is a wrapper around gtk_window_get_accept_focus().
477func (v *Window) GetAcceptFocus() bool {
478	c := C.gtk_window_get_accept_focus(v.native())
479	return gobool(c)
480}
481
482// GetFocusOnMap is a wrapper around gtk_window_get_focus_on_map().
483func (v *Window) GetFocusOnMap() bool {
484	c := C.gtk_window_get_focus_on_map(v.native())
485	return gobool(c)
486}
487
488// GetWindowType is a wrapper around gtk_window_get_window_type().
489func (v *Window) GetWindowType() WindowType {
490	c := C.gtk_window_get_window_type(v.native())
491	return WindowType(c)
492}
493
494// HasGroup is a wrapper around gtk_window_has_group().
495func (v *Window) HasGroup() bool {
496	c := C.gtk_window_has_group(v.native())
497	return gobool(c)
498}
499
500// Move is a wrapper around gtk_window_move().
501func (v *Window) Move(x, y int) {
502	C.gtk_window_move(v.native(), C.gint(x), C.gint(y))
503}
504
505// Resize is a wrapper around gtk_window_resize().
506func (v *Window) Resize(width, height int) {
507	C.gtk_window_resize(v.native(), C.gint(width), C.gint(height))
508}
509
510// WindowSetDefaultIconFromFile is a wrapper around gtk_window_set_default_icon_from_file().
511func WindowSetDefaultIconFromFile(file string) error {
512	cstr := C.CString(file)
513	defer C.free(unsafe.Pointer(cstr))
514	var err *C.GError = nil
515	res := C.gtk_window_set_default_icon_from_file((*C.gchar)(cstr), &err)
516	if res == 0 {
517		defer C.g_error_free(err)
518		return errors.New(C.GoString((*C.char)(err.message)))
519	}
520	return nil
521}
522
523// WindowSetDefaultIconName is a wrapper around gtk_window_set_default_icon_name().
524func WindowSetDefaultIconName(s string) {
525	cstr := (*C.gchar)(C.CString(s))
526	defer C.free(unsafe.Pointer(cstr))
527	C.gtk_window_set_default_icon_name(cstr)
528}
529
530// SetIconFromFile is a wrapper around gtk_window_set_icon_from_file().
531func (v *Window) SetIconFromFile(file string) error {
532	cstr := C.CString(file)
533	defer C.free(unsafe.Pointer(cstr))
534	var err *C.GError = nil
535	res := C.gtk_window_set_icon_from_file(v.native(), (*C.gchar)(cstr), &err)
536	if res == 0 {
537		defer C.g_error_free(err)
538		return errors.New(C.GoString((*C.char)(err.message)))
539	}
540	return nil
541}
542
543// SetIconName is a wrapper around gtk_window_set_icon_name().
544func (v *Window) SetIconName(name string) {
545	cstr := C.CString(name)
546	defer C.free(unsafe.Pointer(cstr))
547	C.gtk_window_set_icon_name(v.native(), (*C.gchar)(cstr))
548}
549
550// WindowSetAutoStartupNotification is a wrapper around
551// gtk_window_set_auto_startup_notification().
552func WindowSetAutoStartupNotification(setting bool) {
553	C.gtk_window_set_auto_startup_notification(gbool(setting))
554}
555
556// GetMnemonicsVisible is a wrapper around
557// gtk_window_get_mnemonics_visible().
558func (v *Window) GetMnemonicsVisible() bool {
559	c := C.gtk_window_get_mnemonics_visible(v.native())
560	return gobool(c)
561}
562
563// SetMnemonicsVisible is a wrapper around
564// gtk_window_set_mnemonics_visible().
565func (v *Window) SetMnemonicsVisible(setting bool) {
566	C.gtk_window_set_mnemonics_visible(v.native(), gbool(setting))
567}
568
569// GetFocusVisible is a wrapper around gtk_window_get_focus_visible().
570func (v *Window) GetFocusVisible() bool {
571	c := C.gtk_window_get_focus_visible(v.native())
572	return gobool(c)
573}
574
575// SetFocusVisible is a wrapper around gtk_window_set_focus_visible().
576func (v *Window) SetFocusVisible(setting bool) {
577	C.gtk_window_set_focus_visible(v.native(), gbool(setting))
578}
579
580// GetApplication is a wrapper around gtk_window_get_application().
581func (v *Window) GetApplication() (*Application, error) {
582	c := C.gtk_window_get_application(v.native())
583	if c == nil {
584		return nil, nil
585	}
586	return wrapApplication(glib.Take(unsafe.Pointer(c))), nil
587}
588
589// SetApplication is a wrapper around gtk_window_set_application().
590func (v *Window) SetApplication(a *Application) {
591	C.gtk_window_set_application(v.native(), a.native())
592}
593
594// ActivateKey is a wrapper around gtk_window_activate_key().
595func (v *Window) ActivateKey(event *gdk.EventKey) bool {
596	c := C.gtk_window_activate_key(v.native(), (*C.GdkEventKey)(unsafe.Pointer(event.Native())))
597	return gobool(c)
598}
599
600// AddMnemonic is a wrapper around gtk_window_add_mnemonic().
601func (v *Window) AddMnemonic(keyval uint, target *Widget) {
602	C.gtk_window_add_mnemonic(v.native(), C.guint(keyval), target.native())
603}
604
605// RemoveMnemonic is a wrapper around gtk_window_remove_mnemonic().
606func (v *Window) RemoveMnemonic(keyval uint, target *Widget) {
607	C.gtk_window_remove_mnemonic(v.native(), C.guint(keyval), target.native())
608}
609
610// ActivateMnemonic is a wrapper around gtk_window_mnemonic_activate().
611func (v *Window) ActivateMnemonic(keyval uint, mods gdk.ModifierType) bool {
612	c := C.gtk_window_mnemonic_activate(v.native(), C.guint(keyval), C.GdkModifierType(mods))
613	return gobool(c)
614}
615
616// GetMnemonicModifier is a wrapper around gtk_window_get_mnemonic_modifier().
617func (v *Window) GetMnemonicModifier() gdk.ModifierType {
618	c := C.gtk_window_get_mnemonic_modifier(v.native())
619	return gdk.ModifierType(c)
620}
621
622// SetMnemonicModifier is a wrapper around gtk_window_set_mnemonic_modifier().
623func (v *Window) SetMnemonicModifier(mods gdk.ModifierType) {
624	C.gtk_window_set_mnemonic_modifier(v.native(), C.GdkModifierType(mods))
625}
626
627// SetScreen is a wrapper around gtk_window_set_screen().
628func (v *Window) SetScreen(screen *gdk.Screen) {
629	C.gtk_window_set_screen(v.native(), C.toGdkScreen(unsafe.Pointer(screen.Native())))
630}
631
632// GetScreen is a wrapper around gtk_window_get_screen().
633func (v *Window) GetScreen() *gdk.Screen {
634	c := C.gtk_window_get_screen(v.native())
635	return &gdk.Screen{glib.Take(unsafe.Pointer(c))}
636}
637
638// PropagateKeyEvent is a wrapper around gtk_window_propagate_key_event().
639func (v *Window) PropagateKeyEvent(event *gdk.EventKey) bool {
640	c := C.gtk_window_propagate_key_event(v.native(), (*C.GdkEventKey)(unsafe.Pointer(event.Native())))
641	return gobool(c)
642}
643
644// WindowListToplevels is a wrapper around gtk_window_list_toplevels().
645// Returned list is wrapped to return *gtk.Window elements.
646// TODO: Use IWindow and wrap to correct type
647func WindowListToplevels() *glib.List {
648	clist := C.gtk_window_list_toplevels()
649	if clist == nil {
650		return nil
651	}
652	glist := glib.WrapList(uintptr(unsafe.Pointer(clist)))
653	glist.DataWrapper(func(ptr unsafe.Pointer) interface{} {
654		return wrapWindow(glib.Take(ptr))
655	})
656	runtime.SetFinalizer(glist, func(l *glib.List) {
657		l.Free()
658	})
659	return glist
660}
661
662// WindowGetDefaultIconList is a wrapper around gtk_window_get_default_icon_list().
663// Returned list is wrapped to return *gdk.Pixbuf elements.
664func WindowGetDefaultIconList() *glib.List {
665	clist := C.gtk_window_get_default_icon_list()
666	if clist == nil {
667		return nil
668	}
669	glist := glib.WrapList(uintptr(unsafe.Pointer(clist)))
670	glist.DataWrapper(func(ptr unsafe.Pointer) interface{} {
671		return &gdk.Pixbuf{glib.Take(ptr)}
672	})
673	runtime.SetFinalizer(glist, func(l *glib.List) {
674		l.Free()
675	})
676	return glist
677}
678
679// GetIconList is a wrapper around gtk_window_get_icon_list().
680// Returned list is wrapped to return *gdk.Pixbuf elements.
681func (v *Window) GetIconList() *glib.List {
682	clist := C.gtk_window_get_icon_list(v.native())
683	if clist == nil {
684		return nil
685	}
686	glist := glib.WrapList(uintptr(unsafe.Pointer(clist)))
687	glist.DataWrapper(func(ptr unsafe.Pointer) interface{} {
688		return &gdk.Pixbuf{glib.Take(ptr)}
689	})
690	runtime.SetFinalizer(glist, func(l *glib.List) {
691		l.Free()
692	})
693	return glist
694}
695
696// WindowSetDefaultIconList is a wrapper around gtk_window_set_default_icon_list().
697// List should only contain *gdk.Pixbuf elements!
698func WindowSetDefaultIconList(list *glib.List) {
699	native := (*C.struct__GList)(unsafe.Pointer(list.Native()))
700	C.gtk_window_set_default_icon_list(native)
701}
702
703// SetIconList is a wrapper around gtk_window_set_icon_list().
704// List should only contain *gdk.Pixbuf elements!
705func (v *Window) SetIconList(list *glib.List) {
706	native := (*C.struct__GList)(unsafe.Pointer(list.Native()))
707	C.gtk_window_set_icon_list(v.native(), native)
708}
709
710// BeginResizeDrag is a wrapper around gtk_window_begin_resize_drag().
711func (v *Window) BeginResizeDrag(edge gdk.WindowEdge, button gdk.Button, rootX, rootY int, timestamp uint32) {
712	C.gtk_window_begin_resize_drag(v.native(), C.GdkWindowEdge(edge), C.gint(button), C.gint(rootX), C.gint(rootY), C.guint32(timestamp))
713}
714
715// BeginMoveDrag is a wrapper around gtk_window_begin_move_drag().
716func (v *Window) BeginMoveDrag(button gdk.Button, rootX, rootY int, timestamp uint32) {
717	C.gtk_window_begin_move_drag(v.native(), C.gint(button), C.gint(rootX), C.gint(rootY), C.guint32(timestamp))
718}
719
720// GetGroup is a wrapper around gtk_window_get_group().
721func (v *Window) GetGroup() *WindowGroup {
722	c := C.gtk_window_get_group(v.native())
723	if c == nil {
724		return nil
725	}
726	return wrapWindowGroup(glib.Take(unsafe.Pointer(c)))
727}
728