Skip to main content

gtk/auto/
gl_area.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Align, Buildable, Container, Widget, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`GLArea`][crate::GLArea] is a widget that allows drawing with OpenGL.
16    ///
17    /// [`GLArea`][crate::GLArea] sets up its own [`gdk::GLContext`][crate::gdk::GLContext] for the window it creates, and
18    /// creates a custom GL framebuffer that the widget will do GL rendering onto.
19    /// It also ensures that this framebuffer is the default GL rendering target
20    /// when rendering.
21    ///
22    /// In order to draw, you have to connect to the [`render`][struct@crate::GLArea#render] signal,
23    /// or subclass [`GLArea`][crate::GLArea] and override the `GtkGLAreaClass.render()` virtual
24    /// function.
25    ///
26    /// The [`GLArea`][crate::GLArea] widget ensures that the [`gdk::GLContext`][crate::gdk::GLContext] is associated with
27    /// the widget's drawing area, and it is kept updated when the size and
28    /// position of the drawing area changes.
29    ///
30    /// ## Drawing with GtkGLArea ##
31    ///
32    /// The simplest way to draw using OpenGL commands in a [`GLArea`][crate::GLArea] is to
33    /// create a widget instance and connect to the [`render`][struct@crate::GLArea#render] signal:
34    ///
35    ///
36    ///
37    /// **⚠️ The following code is in C ⚠️**
38    ///
39    /// ```C
40    ///   // create a GtkGLArea instance
41    ///   GtkWidget *gl_area = gtk_gl_area_new ();
42    ///
43    ///   // connect to the "render" signal
44    ///   g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL);
45    /// ```
46    ///
47    /// The ``render()`` function will be called when the [`GLArea`][crate::GLArea] is ready
48    /// for you to draw its content:
49    ///
50    ///
51    ///
52    /// **⚠️ The following code is in C ⚠️**
53    ///
54    /// ```C
55    ///   static gboolean
56    ///   render (GtkGLArea *area, GdkGLContext *context)
57    ///   {
58    ///     // inside this function it's safe to use GL; the given
59    ///     // #GdkGLContext has been made current to the drawable
60    ///     // surface used by the #GtkGLArea and the viewport has
61    ///     // already been set to be the size of the allocation
62    ///
63    ///     // we can start by clearing the buffer
64    ///     glClearColor (0, 0, 0, 0);
65    ///     glClear (GL_COLOR_BUFFER_BIT);
66    ///
67    ///     // draw your object
68    ///     draw_an_object ();
69    ///
70    ///     // we completed our drawing; the draw commands will be
71    ///     // flushed at the end of the signal emission chain, and
72    ///     // the buffers will be drawn on the window
73    ///     return TRUE;
74    ///   }
75    /// ```
76    ///
77    /// If you need to initialize OpenGL state, e.g. buffer objects or
78    /// shaders, you should use the [`realize`][struct@crate::Widget#realize] signal; you
79    /// can use the [`unrealize`][struct@crate::Widget#unrealize] signal to clean up. Since the
80    /// [`gdk::GLContext`][crate::gdk::GLContext] creation and initialization may fail, you will
81    /// need to check for errors, using [`GLAreaExt::error()`][crate::prelude::GLAreaExt::error()]. An example
82    /// of how to safely initialize the GL state is:
83    ///
84    ///
85    ///
86    /// **⚠️ The following code is in C ⚠️**
87    ///
88    /// ```C
89    ///   static void
90    ///   on_realize (GtkGLarea *area)
91    ///   {
92    ///     // We need to make the context current if we want to
93    ///     // call GL API
94    ///     gtk_gl_area_make_current (area);
95    ///
96    ///     // If there were errors during the initialization or
97    ///     // when trying to make the context current, this
98    ///     // function will return a #GError for you to catch
99    ///     if (gtk_gl_area_get_error (area) != NULL)
100    ///       return;
101    ///
102    ///     // You can also use gtk_gl_area_set_error() in order
103    ///     // to show eventual initialization errors on the
104    ///     // GtkGLArea widget itself
105    ///     GError *internal_error = NULL;
106    ///     init_buffer_objects (&error);
107    ///     if (error != NULL)
108    ///       {
109    ///         gtk_gl_area_set_error (area, error);
110    ///         g_error_free (error);
111    ///         return;
112    ///       }
113    ///
114    ///     init_shaders (&error);
115    ///     if (error != NULL)
116    ///       {
117    ///         gtk_gl_area_set_error (area, error);
118    ///         g_error_free (error);
119    ///         return;
120    ///       }
121    ///   }
122    /// ```
123    ///
124    /// If you need to change the options for creating the [`gdk::GLContext`][crate::gdk::GLContext]
125    /// you should use the [`create-context`][struct@crate::GLArea#create-context] signal.
126    ///
127    /// ## Properties
128    ///
129    ///
130    /// #### `auto-render`
131    ///  If set to [`true`] the [`render`][struct@crate::GLArea#render] signal will be emitted every time
132    /// the widget draws. This is the default and is useful if drawing the widget
133    /// is faster.
134    ///
135    /// If set to [`false`] the data from previous rendering is kept around and will
136    /// be used for drawing the widget the next time, unless the window is resized.
137    /// In order to force a rendering [`GLAreaExt::queue_render()`][crate::prelude::GLAreaExt::queue_render()] must be called.
138    /// This mode is useful when the scene changes seldomly, but takes a long time
139    /// to redraw.
140    ///
141    /// Readable | Writable
142    ///
143    ///
144    /// #### `context`
145    ///  The [`gdk::GLContext`][crate::gdk::GLContext] used by the [`GLArea`][crate::GLArea] widget.
146    ///
147    /// The [`GLArea`][crate::GLArea] widget is responsible for creating the [`gdk::GLContext`][crate::gdk::GLContext]
148    /// instance. If you need to render with other kinds of buffers (stencil,
149    /// depth, etc), use render buffers.
150    ///
151    /// Readable
152    ///
153    ///
154    /// #### `has-alpha`
155    ///  If set to [`true`] the buffer allocated by the widget will have an alpha channel
156    /// component, and when rendering to the window the result will be composited over
157    /// whatever is below the widget.
158    ///
159    /// If set to [`false`] there will be no alpha channel, and the buffer will fully
160    /// replace anything below the widget.
161    ///
162    /// Readable | Writable
163    ///
164    ///
165    /// #### `has-depth-buffer`
166    ///  If set to [`true`] the widget will allocate and enable a depth buffer for the
167    /// target framebuffer.
168    ///
169    /// Readable | Writable
170    ///
171    ///
172    /// #### `has-stencil-buffer`
173    ///  If set to [`true`] the widget will allocate and enable a stencil buffer for the
174    /// target framebuffer.
175    ///
176    /// Readable | Writable
177    ///
178    ///
179    /// #### `use-es`
180    ///  If set to [`true`] the widget will try to create a [`gdk::GLContext`][crate::gdk::GLContext] using
181    /// OpenGL ES instead of OpenGL.
182    ///
183    /// See also: [`GLContext::set_use_es()`][crate::gdk::GLContext::set_use_es()]
184    ///
185    /// Readable | Writable
186    /// <details><summary><h4>Widget</h4></summary>
187    ///
188    ///
189    /// #### `app-paintable`
190    ///  Readable | Writable
191    ///
192    ///
193    /// #### `can-default`
194    ///  Readable | Writable
195    ///
196    ///
197    /// #### `can-focus`
198    ///  Readable | Writable
199    ///
200    ///
201    /// #### `composite-child`
202    ///  Readable
203    ///
204    ///
205    /// #### `double-buffered`
206    ///  Whether the widget is double buffered.
207    ///
208    /// Readable | Writable
209    ///
210    ///
211    /// #### `events`
212    ///  Readable | Writable
213    ///
214    ///
215    /// #### `expand`
216    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
217    ///
218    /// Readable | Writable
219    ///
220    ///
221    /// #### `focus-on-click`
222    ///  Whether the widget should grab focus when it is clicked with the mouse.
223    ///
224    /// This property is only relevant for widgets that can take focus.
225    ///
226    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
227    /// GtkComboBox) implemented this property individually.
228    ///
229    /// Readable | Writable
230    ///
231    ///
232    /// #### `halign`
233    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
234    ///
235    /// Readable | Writable
236    ///
237    ///
238    /// #### `has-default`
239    ///  Readable | Writable
240    ///
241    ///
242    /// #### `has-focus`
243    ///  Readable | Writable
244    ///
245    ///
246    /// #### `has-tooltip`
247    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
248    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
249    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
250    /// whether it will provide a tooltip or not.
251    ///
252    /// Note that setting this property to [`true`] for the first time will change
253    /// the event masks of the GdkWindows of this widget to include leave-notify
254    /// and motion-notify events. This cannot and will not be undone when the
255    /// property is set to [`false`] again.
256    ///
257    /// Readable | Writable
258    ///
259    ///
260    /// #### `height-request`
261    ///  Readable | Writable
262    ///
263    ///
264    /// #### `hexpand`
265    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
266    ///
267    /// Readable | Writable
268    ///
269    ///
270    /// #### `hexpand-set`
271    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
272    ///
273    /// Readable | Writable
274    ///
275    ///
276    /// #### `is-focus`
277    ///  Readable | Writable
278    ///
279    ///
280    /// #### `margin`
281    ///  Sets all four sides' margin at once. If read, returns max
282    /// margin on any side.
283    ///
284    /// Readable | Writable
285    ///
286    ///
287    /// #### `margin-bottom`
288    ///  Margin on bottom side of widget.
289    ///
290    /// This property adds margin outside of the widget's normal size
291    /// request, the margin will be added in addition to the size from
292    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
293    ///
294    /// Readable | Writable
295    ///
296    ///
297    /// #### `margin-end`
298    ///  Margin on end of widget, horizontally. This property supports
299    /// left-to-right and right-to-left text directions.
300    ///
301    /// This property adds margin outside of the widget's normal size
302    /// request, the margin will be added in addition to the size from
303    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
304    ///
305    /// Readable | Writable
306    ///
307    ///
308    /// #### `margin-left`
309    ///  Margin on left side of widget.
310    ///
311    /// This property adds margin outside of the widget's normal size
312    /// request, the margin will be added in addition to the size from
313    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
314    ///
315    /// Readable | Writable
316    ///
317    ///
318    /// #### `margin-right`
319    ///  Margin on right side of widget.
320    ///
321    /// This property adds margin outside of the widget's normal size
322    /// request, the margin will be added in addition to the size from
323    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
324    ///
325    /// Readable | Writable
326    ///
327    ///
328    /// #### `margin-start`
329    ///  Margin on start of widget, horizontally. This property supports
330    /// left-to-right and right-to-left text directions.
331    ///
332    /// This property adds margin outside of the widget's normal size
333    /// request, the margin will be added in addition to the size from
334    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
335    ///
336    /// Readable | Writable
337    ///
338    ///
339    /// #### `margin-top`
340    ///  Margin on top side of widget.
341    ///
342    /// This property adds margin outside of the widget's normal size
343    /// request, the margin will be added in addition to the size from
344    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
345    ///
346    /// Readable | Writable
347    ///
348    ///
349    /// #### `name`
350    ///  Readable | Writable
351    ///
352    ///
353    /// #### `no-show-all`
354    ///  Readable | Writable
355    ///
356    ///
357    /// #### `opacity`
358    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
359    /// more details about window opacity.
360    ///
361    /// Before 3.8 this was only available in GtkWindow
362    ///
363    /// Readable | Writable
364    ///
365    ///
366    /// #### `parent`
367    ///  Readable | Writable
368    ///
369    ///
370    /// #### `receives-default`
371    ///  Readable | Writable
372    ///
373    ///
374    /// #### `scale-factor`
375    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
376    /// more details about widget scaling.
377    ///
378    /// Readable
379    ///
380    ///
381    /// #### `sensitive`
382    ///  Readable | Writable
383    ///
384    ///
385    /// #### `style`
386    ///  The style of the widget, which contains information about how it will look (colors, etc).
387    ///
388    /// Readable | Writable
389    ///
390    ///
391    /// #### `tooltip-markup`
392    ///  Sets the text of tooltip to be the given string, which is marked up
393    /// with the [Pango text markup language][PangoMarkupFormat].
394    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
395    ///
396    /// This is a convenience property which will take care of getting the
397    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
398    /// will automatically be set to [`true`] and there will be taken care of
399    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
400    ///
401    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
402    /// are set, the last one wins.
403    ///
404    /// Readable | Writable
405    ///
406    ///
407    /// #### `tooltip-text`
408    ///  Sets the text of tooltip to be the given string.
409    ///
410    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
411    ///
412    /// This is a convenience property which will take care of getting the
413    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
414    /// will automatically be set to [`true`] and there will be taken care of
415    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
416    ///
417    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
418    /// are set, the last one wins.
419    ///
420    /// Readable | Writable
421    ///
422    ///
423    /// #### `valign`
424    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
425    ///
426    /// Readable | Writable
427    ///
428    ///
429    /// #### `vexpand`
430    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
431    ///
432    /// Readable | Writable
433    ///
434    ///
435    /// #### `vexpand-set`
436    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
437    ///
438    /// Readable | Writable
439    ///
440    ///
441    /// #### `visible`
442    ///  Readable | Writable
443    ///
444    ///
445    /// #### `width-request`
446    ///  Readable | Writable
447    ///
448    ///
449    /// #### `window`
450    ///  The widget's window if it is realized, [`None`] otherwise.
451    ///
452    /// Readable
453    /// </details>
454    ///
455    /// ## Signals
456    ///
457    ///
458    /// #### `create-context`
459    ///  The ::create-context signal is emitted when the widget is being
460    /// realized, and allows you to override how the GL context is
461    /// created. This is useful when you want to reuse an existing GL
462    /// context, or if you want to try creating different kinds of GL
463    /// options.
464    ///
465    /// If context creation fails then the signal handler can use
466    /// [`GLAreaExt::set_error()`][crate::prelude::GLAreaExt::set_error()] to register a more detailed error
467    /// of how the construction failed.
468    ///
469    ///
470    ///
471    ///
472    /// #### `render`
473    ///  The ::render signal is emitted every time the contents
474    /// of the [`GLArea`][crate::GLArea] should be redrawn.
475    ///
476    /// The `context` is bound to the `area` prior to emitting this function,
477    /// and the buffers are painted to the window once the emission terminates.
478    ///
479    ///
480    ///
481    ///
482    /// #### `resize`
483    ///  The ::resize signal is emitted once when the widget is realized, and
484    /// then each time the widget is changed while realized. This is useful
485    /// in order to keep GL state up to date with the widget size, like for
486    /// instance camera properties which may depend on the width/height ratio.
487    ///
488    /// The GL context for the area is guaranteed to be current when this signal
489    /// is emitted.
490    ///
491    /// The default handler sets up the GL viewport.
492    ///
493    ///
494    /// <details><summary><h4>Widget</h4></summary>
495    ///
496    ///
497    /// #### `accel-closures-changed`
498    ///
499    ///
500    ///
501    /// #### `button-press-event`
502    ///  The ::button-press-event signal will be emitted when a button
503    /// (typically from a mouse) is pressed.
504    ///
505    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
506    /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
507    ///
508    /// This signal will be sent to the grab widget if there is one.
509    ///
510    ///
511    ///
512    ///
513    /// #### `button-release-event`
514    ///  The ::button-release-event signal will be emitted when a button
515    /// (typically from a mouse) is released.
516    ///
517    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
518    /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
519    ///
520    /// This signal will be sent to the grab widget if there is one.
521    ///
522    ///
523    ///
524    ///
525    /// #### `can-activate-accel`
526    ///  Determines whether an accelerator that activates the signal
527    /// identified by `signal_id` can currently be activated.
528    /// This signal is present to allow applications and derived
529    /// widgets to override the default [`Widget`][crate::Widget] handling
530    /// for determining whether an accelerator can be activated.
531    ///
532    ///
533    ///
534    ///
535    /// #### `child-notify`
536    ///  The ::child-notify signal is emitted for each
537    /// [child property][child-properties] that has
538    /// changed on an object. The signal's detail holds the property name.
539    ///
540    /// Detailed
541    ///
542    ///
543    /// #### `composited-changed`
544    ///  The ::composited-changed signal is emitted when the composited
545    /// status of `widgets` screen changes.
546    /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
547    ///
548    /// Action
549    ///
550    ///
551    /// #### `configure-event`
552    ///  The ::configure-event signal will be emitted when the size, position or
553    /// stacking of the `widget`'s window has changed.
554    ///
555    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
556    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
557    /// automatically for all new windows.
558    ///
559    ///
560    ///
561    ///
562    /// #### `damage-event`
563    ///  Emitted when a redirected window belonging to `widget` gets drawn into.
564    /// The region/area members of the event shows what area of the redirected
565    /// drawable was drawn into.
566    ///
567    ///
568    ///
569    ///
570    /// #### `delete-event`
571    ///  The ::delete-event signal is emitted if a user requests that
572    /// a toplevel window is closed. The default handler for this signal
573    /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
574    /// this signal will cause the window to be hidden instead, so that
575    /// it can later be shown again without reconstructing it.
576    ///
577    ///
578    ///
579    ///
580    /// #### `destroy`
581    ///  Signals that all holders of a reference to the widget should release
582    /// the reference that they hold. May result in finalization of the widget
583    /// if all references are released.
584    ///
585    /// This signal is not suitable for saving widget state.
586    ///
587    ///
588    ///
589    ///
590    /// #### `destroy-event`
591    ///  The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
592    /// You rarely get this signal, because most widgets disconnect themselves
593    /// from their window before they destroy it, so no widget owns the
594    /// window at destroy time.
595    ///
596    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
597    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
598    /// automatically for all new windows.
599    ///
600    ///
601    ///
602    ///
603    /// #### `direction-changed`
604    ///  The ::direction-changed signal is emitted when the text direction
605    /// of a widget changes.
606    ///
607    ///
608    ///
609    ///
610    /// #### `drag-begin`
611    ///  The ::drag-begin signal is emitted on the drag source when a drag is
612    /// started. A typical reason to connect to this signal is to set up a
613    /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
614    ///
615    /// Note that some widgets set up a drag icon in the default handler of
616    /// this signal, so you may have to use `g_signal_connect_after()` to
617    /// override what the default handler did.
618    ///
619    ///
620    ///
621    ///
622    /// #### `drag-data-delete`
623    ///  The ::drag-data-delete signal is emitted on the drag source when a drag
624    /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
625    /// handler is responsible for deleting the data that has been dropped. What
626    /// "delete" means depends on the context of the drag operation.
627    ///
628    ///
629    ///
630    ///
631    /// #### `drag-data-get`
632    ///  The ::drag-data-get signal is emitted on the drag source when the drop
633    /// site requests the data which is dragged. It is the responsibility of
634    /// the signal handler to fill `data` with the data in the format which
635    /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
636    /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
637    ///
638    ///
639    ///
640    ///
641    /// #### `drag-data-received`
642    ///  The ::drag-data-received signal is emitted on the drop site when the
643    /// dragged data has been received. If the data was received in order to
644    /// determine whether the drop will be accepted, the handler is expected
645    /// to call `gdk_drag_status()` and not finish the drag.
646    /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
647    /// (and this is the last target to be received), the handler for this
648    /// signal is expected to process the received data and then call
649    /// `gtk_drag_finish()`, setting the `success` parameter depending on
650    /// whether the data was processed successfully.
651    ///
652    /// Applications must create some means to determine why the signal was emitted
653    /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
654    ///
655    /// The handler may inspect the selected action with
656    /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
657    /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
658    /// shown in the following example:
659    ///
660    ///
661    /// **⚠️ The following code is in C ⚠️**
662    ///
663    /// ```C
664    /// void
665    /// drag_data_received (GtkWidget          *widget,
666    ///                     GdkDragContext     *context,
667    ///                     gint                x,
668    ///                     gint                y,
669    ///                     GtkSelectionData   *data,
670    ///                     guint               info,
671    ///                     guint               time)
672    /// {
673    ///   if ((data->length >= 0) && (data->format == 8))
674    ///     {
675    ///       GdkDragAction action;
676    ///
677    ///       // handle data here
678    ///
679    ///       action = gdk_drag_context_get_selected_action (context);
680    ///       if (action == GDK_ACTION_ASK)
681    ///         {
682    ///           GtkWidget *dialog;
683    ///           gint response;
684    ///
685    ///           dialog = gtk_message_dialog_new (NULL,
686    ///                                            GTK_DIALOG_MODAL |
687    ///                                            GTK_DIALOG_DESTROY_WITH_PARENT,
688    ///                                            GTK_MESSAGE_INFO,
689    ///                                            GTK_BUTTONS_YES_NO,
690    ///                                            "Move the data ?\n");
691    ///           response = gtk_dialog_run (GTK_DIALOG (dialog));
692    ///           gtk_widget_destroy (dialog);
693    ///
694    ///           if (response == GTK_RESPONSE_YES)
695    ///             action = GDK_ACTION_MOVE;
696    ///           else
697    ///             action = GDK_ACTION_COPY;
698    ///          }
699    ///
700    ///       gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
701    ///     }
702    ///   else
703    ///     gtk_drag_finish (context, FALSE, FALSE, time);
704    ///  }
705    /// ```
706    ///
707    ///
708    ///
709    ///
710    /// #### `drag-drop`
711    ///  The ::drag-drop signal is emitted on the drop site when the user drops
712    /// the data onto the widget. The signal handler must determine whether
713    /// the cursor position is in a drop zone or not. If it is not in a drop
714    /// zone, it returns [`false`] and no further processing is necessary.
715    /// Otherwise, the handler returns [`true`]. In this case, the handler must
716    /// ensure that `gtk_drag_finish()` is called to let the source know that
717    /// the drop is done. The call to `gtk_drag_finish()` can be done either
718    /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
719    /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
720    /// or more of the supported targets.
721    ///
722    ///
723    ///
724    ///
725    /// #### `drag-end`
726    ///  The ::drag-end signal is emitted on the drag source when a drag is
727    /// finished. A typical reason to connect to this signal is to undo
728    /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
729    ///
730    ///
731    ///
732    ///
733    /// #### `drag-failed`
734    ///  The ::drag-failed signal is emitted on the drag source when a drag has
735    /// failed. The signal handler may hook custom code to handle a failed DnD
736    /// operation based on the type of error, it returns [`true`] is the failure has
737    /// been already handled (not showing the default "drag operation failed"
738    /// animation), otherwise it returns [`false`].
739    ///
740    ///
741    ///
742    ///
743    /// #### `drag-leave`
744    ///  The ::drag-leave signal is emitted on the drop site when the cursor
745    /// leaves the widget. A typical reason to connect to this signal is to
746    /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
747    /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
748    ///
749    ///
750    /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
751    /// ::drag-drop signal, for instance to allow cleaning up of a preview item
752    /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
753    ///
754    ///
755    ///
756    ///
757    /// #### `drag-motion`
758    ///  The ::drag-motion signal is emitted on the drop site when the user
759    /// moves the cursor over the widget during a drag. The signal handler
760    /// must determine whether the cursor position is in a drop zone or not.
761    /// If it is not in a drop zone, it returns [`false`] and no further processing
762    /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
763    /// handler is responsible for providing the necessary information for
764    /// displaying feedback to the user, by calling `gdk_drag_status()`.
765    ///
766    /// If the decision whether the drop will be accepted or rejected can't be
767    /// made based solely on the cursor position and the type of the data, the
768    /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
769    /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
770    /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
771    /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
772    /// when using the drag-motion signal that way.
773    ///
774    /// Also note that there is no drag-enter signal. The drag receiver has to
775    /// keep track of whether he has received any drag-motion signals since the
776    /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
777    /// an "enter" signal. Upon an "enter", the handler will typically highlight
778    /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
779    ///
780    ///
781    /// **⚠️ The following code is in C ⚠️**
782    ///
783    /// ```C
784    /// static void
785    /// drag_motion (GtkWidget      *widget,
786    ///              GdkDragContext *context,
787    ///              gint            x,
788    ///              gint            y,
789    ///              guint           time)
790    /// {
791    ///   GdkAtom target;
792    ///
793    ///   PrivateData *private_data = GET_PRIVATE_DATA (widget);
794    ///
795    ///   if (!private_data->drag_highlight)
796    ///    {
797    ///      private_data->drag_highlight = 1;
798    ///      gtk_drag_highlight (widget);
799    ///    }
800    ///
801    ///   target = gtk_drag_dest_find_target (widget, context, NULL);
802    ///   if (target == GDK_NONE)
803    ///     gdk_drag_status (context, 0, time);
804    ///   else
805    ///    {
806    ///      private_data->pending_status
807    ///         = gdk_drag_context_get_suggested_action (context);
808    ///      gtk_drag_get_data (widget, context, target, time);
809    ///    }
810    ///
811    ///   return TRUE;
812    /// }
813    ///
814    /// static void
815    /// drag_data_received (GtkWidget        *widget,
816    ///                     GdkDragContext   *context,
817    ///                     gint              x,
818    ///                     gint              y,
819    ///                     GtkSelectionData *selection_data,
820    ///                     guint             info,
821    ///                     guint             time)
822    /// {
823    ///   PrivateData *private_data = GET_PRIVATE_DATA (widget);
824    ///
825    ///   if (private_data->suggested_action)
826    ///    {
827    ///      private_data->suggested_action = 0;
828    ///
829    ///      // We are getting this data due to a request in drag_motion,
830    ///      // rather than due to a request in drag_drop, so we are just
831    ///      // supposed to call gdk_drag_status(), not actually paste in
832    ///      // the data.
833    ///
834    ///      str = gtk_selection_data_get_text (selection_data);
835    ///      if (!data_is_acceptable (str))
836    ///        gdk_drag_status (context, 0, time);
837    ///      else
838    ///        gdk_drag_status (context,
839    ///                         private_data->suggested_action,
840    ///                         time);
841    ///    }
842    ///   else
843    ///    {
844    ///      // accept the drop
845    ///    }
846    /// }
847    /// ```
848    ///
849    ///
850    ///
851    ///
852    /// #### `draw`
853    ///  This signal is emitted when a widget is supposed to render itself.
854    /// The `widget`'s top left corner must be painted at the origin of
855    /// the passed in context and be sized to the values returned by
856    /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
857    /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
858    ///
859    /// Signal handlers connected to this signal can modify the cairo
860    /// context passed as `cr` in any way they like and don't need to
861    /// restore it. The signal emission takes care of calling `cairo_save()`
862    /// before and `cairo_restore()` after invoking the handler.
863    ///
864    /// The signal handler will get a `cr` with a clip region already set to the
865    /// widget's dirty region, i.e. to the area that needs repainting. Complicated
866    /// widgets that want to avoid redrawing themselves completely can get the full
867    /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
868    /// get a finer-grained representation of the dirty region with
869    /// `cairo_copy_clip_rectangle_list()`.
870    ///
871    ///
872    ///
873    ///
874    /// #### `enter-notify-event`
875    ///  The ::enter-notify-event will be emitted when the pointer enters
876    /// the `widget`'s window.
877    ///
878    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
879    /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
880    ///
881    /// This signal will be sent to the grab widget if there is one.
882    ///
883    ///
884    ///
885    ///
886    /// #### `event`
887    ///  The GTK+ main loop will emit three signals for each GDK event delivered
888    /// to a widget: one generic ::event signal, another, more specific,
889    /// signal that matches the type of event delivered (e.g.
890    /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
891    /// [`event-after`][struct@crate::Widget#event-after] signal.
892    ///
893    ///
894    ///
895    ///
896    /// #### `event-after`
897    ///  After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
898    /// the second more specific signal, ::event-after will be emitted
899    /// regardless of the previous two signals handlers return values.
900    ///
901    ///
902    ///
903    ///
904    /// #### `focus`
905    ///
906    ///
907    ///
908    /// #### `focus-in-event`
909    ///  The ::focus-in-event signal will be emitted when the keyboard focus
910    /// enters the `widget`'s window.
911    ///
912    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
913    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
914    ///
915    ///
916    ///
917    ///
918    /// #### `focus-out-event`
919    ///  The ::focus-out-event signal will be emitted when the keyboard focus
920    /// leaves the `widget`'s window.
921    ///
922    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
923    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
924    ///
925    ///
926    ///
927    ///
928    /// #### `grab-broken-event`
929    ///  Emitted when a pointer or keyboard grab on a window belonging
930    /// to `widget` gets broken.
931    ///
932    /// On X11, this happens when the grab window becomes unviewable
933    /// (i.e. it or one of its ancestors is unmapped), or if the same
934    /// application grabs the pointer or keyboard again.
935    ///
936    ///
937    ///
938    ///
939    /// #### `grab-focus`
940    ///  Action
941    ///
942    ///
943    /// #### `grab-notify`
944    ///  The ::grab-notify signal is emitted when a widget becomes
945    /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
946    /// another widget, or when it becomes unshadowed due to a grab
947    /// being removed.
948    ///
949    /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
950    /// grab widget in the grab stack of its window group is not
951    /// its ancestor.
952    ///
953    ///
954    ///
955    ///
956    /// #### `hide`
957    ///  The ::hide signal is emitted when `widget` is hidden, for example with
958    /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
959    ///
960    ///
961    ///
962    ///
963    /// #### `hierarchy-changed`
964    ///  The ::hierarchy-changed signal is emitted when the
965    /// anchored state of a widget changes. A widget is
966    /// “anchored” when its toplevel
967    /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
968    /// a widget changes from un-anchored to anchored or vice-versa.
969    ///
970    ///
971    ///
972    ///
973    /// #### `key-press-event`
974    ///  The ::key-press-event signal is emitted when a key is pressed. The signal
975    /// emission will reoccur at the key-repeat rate when the key is kept pressed.
976    ///
977    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
978    /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
979    ///
980    /// This signal will be sent to the grab widget if there is one.
981    ///
982    ///
983    ///
984    ///
985    /// #### `key-release-event`
986    ///  The ::key-release-event signal is emitted when a key is released.
987    ///
988    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
989    /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
990    ///
991    /// This signal will be sent to the grab widget if there is one.
992    ///
993    ///
994    ///
995    ///
996    /// #### `keynav-failed`
997    ///  Gets emitted if keyboard navigation fails.
998    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
999    ///
1000    ///
1001    ///
1002    ///
1003    /// #### `leave-notify-event`
1004    ///  The ::leave-notify-event will be emitted when the pointer leaves
1005    /// the `widget`'s window.
1006    ///
1007    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1008    /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1009    ///
1010    /// This signal will be sent to the grab widget if there is one.
1011    ///
1012    ///
1013    ///
1014    ///
1015    /// #### `map`
1016    ///  The ::map signal is emitted when `widget` is going to be mapped, that is
1017    /// when the widget is visible (which is controlled with
1018    /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1019    /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1020    /// be emitted.
1021    ///
1022    /// The ::map signal can be used to determine whether a widget will be drawn,
1023    /// for instance it can resume an animation that was stopped during the
1024    /// emission of [`unmap`][struct@crate::Widget#unmap].
1025    ///
1026    ///
1027    ///
1028    ///
1029    /// #### `map-event`
1030    ///  The ::map-event signal will be emitted when the `widget`'s window is
1031    /// mapped. A window is mapped when it becomes visible on the screen.
1032    ///
1033    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1034    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1035    /// automatically for all new windows.
1036    ///
1037    ///
1038    ///
1039    ///
1040    /// #### `mnemonic-activate`
1041    ///  The default handler for this signal activates `widget` if `group_cycling`
1042    /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1043    ///
1044    ///
1045    ///
1046    ///
1047    /// #### `motion-notify-event`
1048    ///  The ::motion-notify-event signal is emitted when the pointer moves
1049    /// over the widget's [`gdk::Window`][crate::gdk::Window].
1050    ///
1051    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1052    /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1053    ///
1054    /// This signal will be sent to the grab widget if there is one.
1055    ///
1056    ///
1057    ///
1058    ///
1059    /// #### `move-focus`
1060    ///  Action
1061    ///
1062    ///
1063    /// #### `parent-set`
1064    ///  The ::parent-set signal is emitted when a new parent
1065    /// has been set on a widget.
1066    ///
1067    ///
1068    ///
1069    ///
1070    /// #### `popup-menu`
1071    ///  This signal gets emitted whenever a widget should pop up a context
1072    /// menu. This usually happens through the standard key binding mechanism;
1073    /// by pressing a certain key while a widget is focused, the user can cause
1074    /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1075    /// a menu with clipboard commands. See the
1076    /// [Popup Menu Migration Checklist][checklist-popup-menu]
1077    /// for an example of how to use this signal.
1078    ///
1079    /// Action
1080    ///
1081    ///
1082    /// #### `property-notify-event`
1083    ///  The ::property-notify-event signal will be emitted when a property on
1084    /// the `widget`'s window has been changed or deleted.
1085    ///
1086    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1087    /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1088    ///
1089    ///
1090    ///
1091    ///
1092    /// #### `proximity-in-event`
1093    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1094    /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1095    ///
1096    /// This signal will be sent to the grab widget if there is one.
1097    ///
1098    ///
1099    ///
1100    ///
1101    /// #### `proximity-out-event`
1102    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1103    /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1104    ///
1105    /// This signal will be sent to the grab widget if there is one.
1106    ///
1107    ///
1108    ///
1109    ///
1110    /// #### `query-tooltip`
1111    ///  Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1112    /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1113    /// focus in keyboard mode.
1114    ///
1115    /// Using the given coordinates, the signal handler should determine
1116    /// whether a tooltip should be shown for `widget`. If this is the case
1117    /// [`true`] should be returned, [`false`] otherwise. Note that if
1118    /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1119    /// should not be used.
1120    ///
1121    /// The signal handler is free to manipulate `tooltip` with the therefore
1122    /// destined function calls.
1123    ///
1124    ///
1125    ///
1126    ///
1127    /// #### `realize`
1128    ///  The ::realize signal is emitted when `widget` is associated with a
1129    /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1130    /// widget has been mapped (that is, it is going to be drawn).
1131    ///
1132    ///
1133    ///
1134    ///
1135    /// #### `screen-changed`
1136    ///  The ::screen-changed signal gets emitted when the
1137    /// screen of a widget has changed.
1138    ///
1139    ///
1140    ///
1141    ///
1142    /// #### `scroll-event`
1143    ///  The ::scroll-event signal is emitted when a button in the 4 to 7
1144    /// range is pressed. Wheel mice are usually configured to generate
1145    /// button press events for buttons 4 and 5 when the wheel is turned.
1146    ///
1147    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1148    /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1149    ///
1150    /// This signal will be sent to the grab widget if there is one.
1151    ///
1152    ///
1153    ///
1154    ///
1155    /// #### `selection-clear-event`
1156    ///  The ::selection-clear-event signal will be emitted when the
1157    /// the `widget`'s window has lost ownership of a selection.
1158    ///
1159    ///
1160    ///
1161    ///
1162    /// #### `selection-get`
1163    ///
1164    ///
1165    ///
1166    /// #### `selection-notify-event`
1167    ///
1168    ///
1169    ///
1170    /// #### `selection-received`
1171    ///
1172    ///
1173    ///
1174    /// #### `selection-request-event`
1175    ///  The ::selection-request-event signal will be emitted when
1176    /// another client requests ownership of the selection owned by
1177    /// the `widget`'s window.
1178    ///
1179    ///
1180    ///
1181    ///
1182    /// #### `show`
1183    ///  The ::show signal is emitted when `widget` is shown, for example with
1184    /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1185    ///
1186    ///
1187    ///
1188    ///
1189    /// #### `show-help`
1190    ///  Action
1191    ///
1192    ///
1193    /// #### `size-allocate`
1194    ///
1195    ///
1196    ///
1197    /// #### `state-changed`
1198    ///  The ::state-changed signal is emitted when the widget state changes.
1199    /// See `gtk_widget_get_state()`.
1200    ///
1201    ///
1202    ///
1203    ///
1204    /// #### `state-flags-changed`
1205    ///  The ::state-flags-changed signal is emitted when the widget state
1206    /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1207    ///
1208    ///
1209    ///
1210    ///
1211    /// #### `style-set`
1212    ///  The ::style-set signal is emitted when a new style has been set
1213    /// on a widget. Note that style-modifying functions like
1214    /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1215    ///
1216    /// Note that this signal is emitted for changes to the deprecated
1217    /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1218    /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1219    ///
1220    ///
1221    ///
1222    ///
1223    /// #### `style-updated`
1224    ///  The ::style-updated signal is a convenience signal that is emitted when the
1225    /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1226    /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1227    ///
1228    /// Note that style-modifying functions like `gtk_widget_override_color()` also
1229    /// cause this signal to be emitted.
1230    ///
1231    ///
1232    ///
1233    ///
1234    /// #### `touch-event`
1235    ///
1236    ///
1237    ///
1238    /// #### `unmap`
1239    ///  The ::unmap signal is emitted when `widget` is going to be unmapped, which
1240    /// means that either it or any of its parents up to the toplevel widget have
1241    /// been set as hidden.
1242    ///
1243    /// As ::unmap indicates that a widget will not be shown any longer, it can be
1244    /// used to, for example, stop an animation on the widget.
1245    ///
1246    ///
1247    ///
1248    ///
1249    /// #### `unmap-event`
1250    ///  The ::unmap-event signal will be emitted when the `widget`'s window is
1251    /// unmapped. A window is unmapped when it becomes invisible on the screen.
1252    ///
1253    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1254    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1255    /// automatically for all new windows.
1256    ///
1257    ///
1258    ///
1259    ///
1260    /// #### `unrealize`
1261    ///  The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1262    /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1263    /// called or the widget has been unmapped (that is, it is going to be
1264    /// hidden).
1265    ///
1266    ///
1267    ///
1268    ///
1269    /// #### `visibility-notify-event`
1270    ///  The ::visibility-notify-event will be emitted when the `widget`'s
1271    /// window is obscured or unobscured.
1272    ///
1273    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1274    /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1275    ///
1276    ///
1277    ///
1278    ///
1279    /// #### `window-state-event`
1280    ///  The ::window-state-event will be emitted when the state of the
1281    /// toplevel window associated to the `widget` changes.
1282    ///
1283    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1284    /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1285    /// this mask automatically for all new windows.
1286    ///
1287    ///
1288    /// </details>
1289    ///
1290    /// # Implements
1291    ///
1292    /// [`GLAreaExt`][trait@crate::prelude::GLAreaExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1293    #[doc(alias = "GtkGLArea")]
1294    pub struct GLArea(Object<ffi::GtkGLArea, ffi::GtkGLAreaClass>) @extends Widget, @implements Buildable;
1295
1296    match fn {
1297        type_ => || ffi::gtk_gl_area_get_type(),
1298    }
1299}
1300
1301impl GLArea {
1302    pub const NONE: Option<&'static GLArea> = None;
1303
1304    /// Creates a new [`GLArea`][crate::GLArea] widget.
1305    ///
1306    /// # Returns
1307    ///
1308    /// a new [`GLArea`][crate::GLArea]
1309    #[doc(alias = "gtk_gl_area_new")]
1310    pub fn new() -> GLArea {
1311        assert_initialized_main_thread!();
1312        unsafe { Widget::from_glib_none(ffi::gtk_gl_area_new()).unsafe_cast() }
1313    }
1314
1315    // rustdoc-stripper-ignore-next
1316    /// Creates a new builder-pattern struct instance to construct [`GLArea`] objects.
1317    ///
1318    /// This method returns an instance of [`GLAreaBuilder`](crate::builders::GLAreaBuilder) which can be used to create [`GLArea`] objects.
1319    pub fn builder() -> GLAreaBuilder {
1320        GLAreaBuilder::new()
1321    }
1322}
1323
1324impl Default for GLArea {
1325    fn default() -> Self {
1326        Self::new()
1327    }
1328}
1329
1330// rustdoc-stripper-ignore-next
1331/// A [builder-pattern] type to construct [`GLArea`] objects.
1332///
1333/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1334#[must_use = "The builder must be built to be used"]
1335pub struct GLAreaBuilder {
1336    builder: glib::object::ObjectBuilder<'static, GLArea>,
1337}
1338
1339impl GLAreaBuilder {
1340    fn new() -> Self {
1341        Self {
1342            builder: glib::object::Object::builder(),
1343        }
1344    }
1345
1346    /// If set to [`true`] the [`render`][struct@crate::GLArea#render] signal will be emitted every time
1347    /// the widget draws. This is the default and is useful if drawing the widget
1348    /// is faster.
1349    ///
1350    /// If set to [`false`] the data from previous rendering is kept around and will
1351    /// be used for drawing the widget the next time, unless the window is resized.
1352    /// In order to force a rendering [`GLAreaExt::queue_render()`][crate::prelude::GLAreaExt::queue_render()] must be called.
1353    /// This mode is useful when the scene changes seldomly, but takes a long time
1354    /// to redraw.
1355    pub fn auto_render(self, auto_render: bool) -> Self {
1356        Self {
1357            builder: self.builder.property("auto-render", auto_render),
1358        }
1359    }
1360
1361    /// If set to [`true`] the buffer allocated by the widget will have an alpha channel
1362    /// component, and when rendering to the window the result will be composited over
1363    /// whatever is below the widget.
1364    ///
1365    /// If set to [`false`] there will be no alpha channel, and the buffer will fully
1366    /// replace anything below the widget.
1367    pub fn has_alpha(self, has_alpha: bool) -> Self {
1368        Self {
1369            builder: self.builder.property("has-alpha", has_alpha),
1370        }
1371    }
1372
1373    /// If set to [`true`] the widget will allocate and enable a depth buffer for the
1374    /// target framebuffer.
1375    pub fn has_depth_buffer(self, has_depth_buffer: bool) -> Self {
1376        Self {
1377            builder: self.builder.property("has-depth-buffer", has_depth_buffer),
1378        }
1379    }
1380
1381    /// If set to [`true`] the widget will allocate and enable a stencil buffer for the
1382    /// target framebuffer.
1383    pub fn has_stencil_buffer(self, has_stencil_buffer: bool) -> Self {
1384        Self {
1385            builder: self
1386                .builder
1387                .property("has-stencil-buffer", has_stencil_buffer),
1388        }
1389    }
1390
1391    /// If set to [`true`] the widget will try to create a [`gdk::GLContext`][crate::gdk::GLContext] using
1392    /// OpenGL ES instead of OpenGL.
1393    ///
1394    /// See also: [`GLContext::set_use_es()`][crate::gdk::GLContext::set_use_es()]
1395    pub fn use_es(self, use_es: bool) -> Self {
1396        Self {
1397            builder: self.builder.property("use-es", use_es),
1398        }
1399    }
1400
1401    pub fn app_paintable(self, app_paintable: bool) -> Self {
1402        Self {
1403            builder: self.builder.property("app-paintable", app_paintable),
1404        }
1405    }
1406
1407    pub fn can_default(self, can_default: bool) -> Self {
1408        Self {
1409            builder: self.builder.property("can-default", can_default),
1410        }
1411    }
1412
1413    pub fn can_focus(self, can_focus: bool) -> Self {
1414        Self {
1415            builder: self.builder.property("can-focus", can_focus),
1416        }
1417    }
1418
1419    pub fn events(self, events: gdk::EventMask) -> Self {
1420        Self {
1421            builder: self.builder.property("events", events),
1422        }
1423    }
1424
1425    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1426    pub fn expand(self, expand: bool) -> Self {
1427        Self {
1428            builder: self.builder.property("expand", expand),
1429        }
1430    }
1431
1432    /// Whether the widget should grab focus when it is clicked with the mouse.
1433    ///
1434    /// This property is only relevant for widgets that can take focus.
1435    ///
1436    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1437    /// GtkComboBox) implemented this property individually.
1438    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1439        Self {
1440            builder: self.builder.property("focus-on-click", focus_on_click),
1441        }
1442    }
1443
1444    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1445    pub fn halign(self, halign: Align) -> Self {
1446        Self {
1447            builder: self.builder.property("halign", halign),
1448        }
1449    }
1450
1451    pub fn has_default(self, has_default: bool) -> Self {
1452        Self {
1453            builder: self.builder.property("has-default", has_default),
1454        }
1455    }
1456
1457    pub fn has_focus(self, has_focus: bool) -> Self {
1458        Self {
1459            builder: self.builder.property("has-focus", has_focus),
1460        }
1461    }
1462
1463    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1464    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1465    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1466    /// whether it will provide a tooltip or not.
1467    ///
1468    /// Note that setting this property to [`true`] for the first time will change
1469    /// the event masks of the GdkWindows of this widget to include leave-notify
1470    /// and motion-notify events. This cannot and will not be undone when the
1471    /// property is set to [`false`] again.
1472    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1473        Self {
1474            builder: self.builder.property("has-tooltip", has_tooltip),
1475        }
1476    }
1477
1478    pub fn height_request(self, height_request: i32) -> Self {
1479        Self {
1480            builder: self.builder.property("height-request", height_request),
1481        }
1482    }
1483
1484    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1485    pub fn hexpand(self, hexpand: bool) -> Self {
1486        Self {
1487            builder: self.builder.property("hexpand", hexpand),
1488        }
1489    }
1490
1491    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1492    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1493        Self {
1494            builder: self.builder.property("hexpand-set", hexpand_set),
1495        }
1496    }
1497
1498    pub fn is_focus(self, is_focus: bool) -> Self {
1499        Self {
1500            builder: self.builder.property("is-focus", is_focus),
1501        }
1502    }
1503
1504    /// Sets all four sides' margin at once. If read, returns max
1505    /// margin on any side.
1506    pub fn margin(self, margin: i32) -> Self {
1507        Self {
1508            builder: self.builder.property("margin", margin),
1509        }
1510    }
1511
1512    /// Margin on bottom side of widget.
1513    ///
1514    /// This property adds margin outside of the widget's normal size
1515    /// request, the margin will be added in addition to the size from
1516    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1517    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1518        Self {
1519            builder: self.builder.property("margin-bottom", margin_bottom),
1520        }
1521    }
1522
1523    /// Margin on end of widget, horizontally. This property supports
1524    /// left-to-right and right-to-left text directions.
1525    ///
1526    /// This property adds margin outside of the widget's normal size
1527    /// request, the margin will be added in addition to the size from
1528    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1529    pub fn margin_end(self, margin_end: i32) -> Self {
1530        Self {
1531            builder: self.builder.property("margin-end", margin_end),
1532        }
1533    }
1534
1535    /// Margin on start of widget, horizontally. This property supports
1536    /// left-to-right and right-to-left text directions.
1537    ///
1538    /// This property adds margin outside of the widget's normal size
1539    /// request, the margin will be added in addition to the size from
1540    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1541    pub fn margin_start(self, margin_start: i32) -> Self {
1542        Self {
1543            builder: self.builder.property("margin-start", margin_start),
1544        }
1545    }
1546
1547    /// Margin on top side of widget.
1548    ///
1549    /// This property adds margin outside of the widget's normal size
1550    /// request, the margin will be added in addition to the size from
1551    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1552    pub fn margin_top(self, margin_top: i32) -> Self {
1553        Self {
1554            builder: self.builder.property("margin-top", margin_top),
1555        }
1556    }
1557
1558    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1559        Self {
1560            builder: self.builder.property("name", name.into()),
1561        }
1562    }
1563
1564    pub fn no_show_all(self, no_show_all: bool) -> Self {
1565        Self {
1566            builder: self.builder.property("no-show-all", no_show_all),
1567        }
1568    }
1569
1570    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1571    /// more details about window opacity.
1572    ///
1573    /// Before 3.8 this was only available in GtkWindow
1574    pub fn opacity(self, opacity: f64) -> Self {
1575        Self {
1576            builder: self.builder.property("opacity", opacity),
1577        }
1578    }
1579
1580    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1581        Self {
1582            builder: self.builder.property("parent", parent.clone().upcast()),
1583        }
1584    }
1585
1586    pub fn receives_default(self, receives_default: bool) -> Self {
1587        Self {
1588            builder: self.builder.property("receives-default", receives_default),
1589        }
1590    }
1591
1592    pub fn sensitive(self, sensitive: bool) -> Self {
1593        Self {
1594            builder: self.builder.property("sensitive", sensitive),
1595        }
1596    }
1597
1598    /// Sets the text of tooltip to be the given string, which is marked up
1599    /// with the [Pango text markup language][PangoMarkupFormat].
1600    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1601    ///
1602    /// This is a convenience property which will take care of getting the
1603    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1604    /// will automatically be set to [`true`] and there will be taken care of
1605    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1606    ///
1607    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1608    /// are set, the last one wins.
1609    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1610        Self {
1611            builder: self
1612                .builder
1613                .property("tooltip-markup", tooltip_markup.into()),
1614        }
1615    }
1616
1617    /// Sets the text of tooltip to be the given string.
1618    ///
1619    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1620    ///
1621    /// This is a convenience property which will take care of getting the
1622    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1623    /// will automatically be set to [`true`] and there will be taken care of
1624    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1625    ///
1626    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1627    /// are set, the last one wins.
1628    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1629        Self {
1630            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1631        }
1632    }
1633
1634    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1635    pub fn valign(self, valign: Align) -> Self {
1636        Self {
1637            builder: self.builder.property("valign", valign),
1638        }
1639    }
1640
1641    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1642    pub fn vexpand(self, vexpand: bool) -> Self {
1643        Self {
1644            builder: self.builder.property("vexpand", vexpand),
1645        }
1646    }
1647
1648    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1649    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1650        Self {
1651            builder: self.builder.property("vexpand-set", vexpand_set),
1652        }
1653    }
1654
1655    pub fn visible(self, visible: bool) -> Self {
1656        Self {
1657            builder: self.builder.property("visible", visible),
1658        }
1659    }
1660
1661    pub fn width_request(self, width_request: i32) -> Self {
1662        Self {
1663            builder: self.builder.property("width-request", width_request),
1664        }
1665    }
1666
1667    // rustdoc-stripper-ignore-next
1668    /// Build the [`GLArea`].
1669    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1670    pub fn build(self) -> GLArea {
1671        assert_initialized_main_thread!();
1672        self.builder.build()
1673    }
1674}
1675
1676/// Trait containing all [`struct@GLArea`] methods.
1677///
1678/// # Implementors
1679///
1680/// [`GLArea`][struct@crate::GLArea]
1681pub trait GLAreaExt: IsA<GLArea> + 'static {
1682    /// Ensures that the `self` framebuffer object is made the current draw
1683    /// and read target, and that all the required buffers for the `self`
1684    /// are created and bound to the frambuffer.
1685    ///
1686    /// This function is automatically called before emitting the
1687    /// [`render`][struct@crate::GLArea#render] signal, and doesn't normally need to be called
1688    /// by application code.
1689    #[doc(alias = "gtk_gl_area_attach_buffers")]
1690    fn attach_buffers(&self) {
1691        unsafe {
1692            ffi::gtk_gl_area_attach_buffers(self.as_ref().to_glib_none().0);
1693        }
1694    }
1695
1696    /// Returns whether the area is in auto render mode or not.
1697    ///
1698    /// # Returns
1699    ///
1700    /// [`true`] if the `self` is auto rendering, [`false`] otherwise
1701    #[doc(alias = "gtk_gl_area_get_auto_render")]
1702    #[doc(alias = "get_auto_render")]
1703    #[doc(alias = "auto-render")]
1704    fn is_auto_render(&self) -> bool {
1705        unsafe {
1706            from_glib(ffi::gtk_gl_area_get_auto_render(
1707                self.as_ref().to_glib_none().0,
1708            ))
1709        }
1710    }
1711
1712    /// Retrieves the [`gdk::GLContext`][crate::gdk::GLContext] used by `self`.
1713    ///
1714    /// # Returns
1715    ///
1716    /// the [`gdk::GLContext`][crate::gdk::GLContext]
1717    #[doc(alias = "gtk_gl_area_get_context")]
1718    #[doc(alias = "get_context")]
1719    fn context(&self) -> Option<gdk::GLContext> {
1720        unsafe { from_glib_none(ffi::gtk_gl_area_get_context(self.as_ref().to_glib_none().0)) }
1721    }
1722
1723    /// Gets the current error set on the `self`.
1724    ///
1725    /// # Returns
1726    ///
1727    /// the [`glib::Error`][crate::glib::Error] or [`None`]
1728    #[doc(alias = "gtk_gl_area_get_error")]
1729    #[doc(alias = "get_error")]
1730    fn error(&self) -> Option<glib::Error> {
1731        unsafe { from_glib_none(ffi::gtk_gl_area_get_error(self.as_ref().to_glib_none().0)) }
1732    }
1733
1734    /// Returns whether the area has an alpha component.
1735    ///
1736    /// # Returns
1737    ///
1738    /// [`true`] if the `self` has an alpha component, [`false`] otherwise
1739    #[doc(alias = "gtk_gl_area_get_has_alpha")]
1740    #[doc(alias = "get_has_alpha")]
1741    #[doc(alias = "has-alpha")]
1742    fn has_alpha(&self) -> bool {
1743        unsafe {
1744            from_glib(ffi::gtk_gl_area_get_has_alpha(
1745                self.as_ref().to_glib_none().0,
1746            ))
1747        }
1748    }
1749
1750    /// Returns whether the area has a depth buffer.
1751    ///
1752    /// # Returns
1753    ///
1754    /// [`true`] if the `self` has a depth buffer, [`false`] otherwise
1755    #[doc(alias = "gtk_gl_area_get_has_depth_buffer")]
1756    #[doc(alias = "get_has_depth_buffer")]
1757    #[doc(alias = "has-depth-buffer")]
1758    fn has_depth_buffer(&self) -> bool {
1759        unsafe {
1760            from_glib(ffi::gtk_gl_area_get_has_depth_buffer(
1761                self.as_ref().to_glib_none().0,
1762            ))
1763        }
1764    }
1765
1766    /// Returns whether the area has a stencil buffer.
1767    ///
1768    /// # Returns
1769    ///
1770    /// [`true`] if the `self` has a stencil buffer, [`false`] otherwise
1771    #[doc(alias = "gtk_gl_area_get_has_stencil_buffer")]
1772    #[doc(alias = "get_has_stencil_buffer")]
1773    #[doc(alias = "has-stencil-buffer")]
1774    fn has_stencil_buffer(&self) -> bool {
1775        unsafe {
1776            from_glib(ffi::gtk_gl_area_get_has_stencil_buffer(
1777                self.as_ref().to_glib_none().0,
1778            ))
1779        }
1780    }
1781
1782    /// Retrieves the required version of OpenGL set
1783    /// using [`set_required_version()`][Self::set_required_version()].
1784    ///
1785    /// # Returns
1786    ///
1787    ///
1788    /// ## `major`
1789    /// return location for the required major version
1790    ///
1791    /// ## `minor`
1792    /// return location for the required minor version
1793    #[doc(alias = "gtk_gl_area_get_required_version")]
1794    #[doc(alias = "get_required_version")]
1795    fn required_version(&self) -> (i32, i32) {
1796        unsafe {
1797            let mut major = std::mem::MaybeUninit::uninit();
1798            let mut minor = std::mem::MaybeUninit::uninit();
1799            ffi::gtk_gl_area_get_required_version(
1800                self.as_ref().to_glib_none().0,
1801                major.as_mut_ptr(),
1802                minor.as_mut_ptr(),
1803            );
1804            (major.assume_init(), minor.assume_init())
1805        }
1806    }
1807
1808    /// Retrieves the value set by [`set_use_es()`][Self::set_use_es()].
1809    ///
1810    /// # Returns
1811    ///
1812    /// [`true`] if the [`GLArea`][crate::GLArea] should create an OpenGL ES context
1813    ///  and [`false`] otherwise
1814    #[doc(alias = "gtk_gl_area_get_use_es")]
1815    #[doc(alias = "get_use_es")]
1816    #[doc(alias = "use-es")]
1817    fn uses_es(&self) -> bool {
1818        unsafe { from_glib(ffi::gtk_gl_area_get_use_es(self.as_ref().to_glib_none().0)) }
1819    }
1820
1821    /// Ensures that the [`gdk::GLContext`][crate::gdk::GLContext] used by `self` is associated with
1822    /// the [`GLArea`][crate::GLArea].
1823    ///
1824    /// This function is automatically called before emitting the
1825    /// [`render`][struct@crate::GLArea#render] signal, and doesn't normally need to be called
1826    /// by application code.
1827    #[doc(alias = "gtk_gl_area_make_current")]
1828    fn make_current(&self) {
1829        unsafe {
1830            ffi::gtk_gl_area_make_current(self.as_ref().to_glib_none().0);
1831        }
1832    }
1833
1834    /// Marks the currently rendered data (if any) as invalid, and queues
1835    /// a redraw of the widget, ensuring that the [`render`][struct@crate::GLArea#render] signal
1836    /// is emitted during the draw.
1837    ///
1838    /// This is only needed when the [`set_auto_render()`][Self::set_auto_render()] has
1839    /// been called with a [`false`] value. The default behaviour is to
1840    /// emit [`render`][struct@crate::GLArea#render] on each draw.
1841    #[doc(alias = "gtk_gl_area_queue_render")]
1842    fn queue_render(&self) {
1843        unsafe {
1844            ffi::gtk_gl_area_queue_render(self.as_ref().to_glib_none().0);
1845        }
1846    }
1847
1848    /// If `auto_render` is [`true`] the [`render`][struct@crate::GLArea#render] signal will be
1849    /// emitted every time the widget draws. This is the default and is
1850    /// useful if drawing the widget is faster.
1851    ///
1852    /// If `auto_render` is [`false`] the data from previous rendering is kept
1853    /// around and will be used for drawing the widget the next time,
1854    /// unless the window is resized. In order to force a rendering
1855    /// [`queue_render()`][Self::queue_render()] must be called. This mode is useful when
1856    /// the scene changes seldomly, but takes a long time to redraw.
1857    /// ## `auto_render`
1858    /// a boolean
1859    #[doc(alias = "gtk_gl_area_set_auto_render")]
1860    #[doc(alias = "auto-render")]
1861    fn set_auto_render(&self, auto_render: bool) {
1862        unsafe {
1863            ffi::gtk_gl_area_set_auto_render(
1864                self.as_ref().to_glib_none().0,
1865                auto_render.into_glib(),
1866            );
1867        }
1868    }
1869
1870    /// Sets an error on the area which will be shown instead of the
1871    /// GL rendering. This is useful in the [`create-context`][struct@crate::GLArea#create-context]
1872    /// signal if GL context creation fails.
1873    /// ## `error`
1874    /// a new [`glib::Error`][crate::glib::Error], or [`None`] to unset the error
1875    #[doc(alias = "gtk_gl_area_set_error")]
1876    fn set_error(&self, error: Option<&glib::Error>) {
1877        unsafe {
1878            ffi::gtk_gl_area_set_error(self.as_ref().to_glib_none().0, error.to_glib_none().0);
1879        }
1880    }
1881
1882    /// If `has_alpha` is [`true`] the buffer allocated by the widget will have
1883    /// an alpha channel component, and when rendering to the window the
1884    /// result will be composited over whatever is below the widget.
1885    ///
1886    /// If `has_alpha` is [`false`] there will be no alpha channel, and the
1887    /// buffer will fully replace anything below the widget.
1888    /// ## `has_alpha`
1889    /// [`true`] to add an alpha component
1890    #[doc(alias = "gtk_gl_area_set_has_alpha")]
1891    #[doc(alias = "has-alpha")]
1892    fn set_has_alpha(&self, has_alpha: bool) {
1893        unsafe {
1894            ffi::gtk_gl_area_set_has_alpha(self.as_ref().to_glib_none().0, has_alpha.into_glib());
1895        }
1896    }
1897
1898    /// If `has_depth_buffer` is [`true`] the widget will allocate and
1899    /// enable a depth buffer for the target framebuffer. Otherwise
1900    /// there will be none.
1901    /// ## `has_depth_buffer`
1902    /// [`true`] to add a depth buffer
1903    #[doc(alias = "gtk_gl_area_set_has_depth_buffer")]
1904    #[doc(alias = "has-depth-buffer")]
1905    fn set_has_depth_buffer(&self, has_depth_buffer: bool) {
1906        unsafe {
1907            ffi::gtk_gl_area_set_has_depth_buffer(
1908                self.as_ref().to_glib_none().0,
1909                has_depth_buffer.into_glib(),
1910            );
1911        }
1912    }
1913
1914    /// If `has_stencil_buffer` is [`true`] the widget will allocate and
1915    /// enable a stencil buffer for the target framebuffer. Otherwise
1916    /// there will be none.
1917    /// ## `has_stencil_buffer`
1918    /// [`true`] to add a stencil buffer
1919    #[doc(alias = "gtk_gl_area_set_has_stencil_buffer")]
1920    #[doc(alias = "has-stencil-buffer")]
1921    fn set_has_stencil_buffer(&self, has_stencil_buffer: bool) {
1922        unsafe {
1923            ffi::gtk_gl_area_set_has_stencil_buffer(
1924                self.as_ref().to_glib_none().0,
1925                has_stencil_buffer.into_glib(),
1926            );
1927        }
1928    }
1929
1930    /// Sets the required version of OpenGL to be used when creating the context
1931    /// for the widget.
1932    ///
1933    /// This function must be called before the area has been realized.
1934    /// ## `major`
1935    /// the major version
1936    /// ## `minor`
1937    /// the minor version
1938    #[doc(alias = "gtk_gl_area_set_required_version")]
1939    fn set_required_version(&self, major: i32, minor: i32) {
1940        unsafe {
1941            ffi::gtk_gl_area_set_required_version(self.as_ref().to_glib_none().0, major, minor);
1942        }
1943    }
1944
1945    /// Sets whether the `self` should create an OpenGL or an OpenGL ES context.
1946    ///
1947    /// You should check the capabilities of the [`gdk::GLContext`][crate::gdk::GLContext] before drawing
1948    /// with either API.
1949    /// ## `use_es`
1950    /// whether to use OpenGL or OpenGL ES
1951    #[doc(alias = "gtk_gl_area_set_use_es")]
1952    #[doc(alias = "use-es")]
1953    fn set_use_es(&self, use_es: bool) {
1954        unsafe {
1955            ffi::gtk_gl_area_set_use_es(self.as_ref().to_glib_none().0, use_es.into_glib());
1956        }
1957    }
1958
1959    /// The ::create-context signal is emitted when the widget is being
1960    /// realized, and allows you to override how the GL context is
1961    /// created. This is useful when you want to reuse an existing GL
1962    /// context, or if you want to try creating different kinds of GL
1963    /// options.
1964    ///
1965    /// If context creation fails then the signal handler can use
1966    /// [`set_error()`][Self::set_error()] to register a more detailed error
1967    /// of how the construction failed.
1968    ///
1969    /// # Returns
1970    ///
1971    /// a newly created [`gdk::GLContext`][crate::gdk::GLContext];
1972    ///  the [`GLArea`][crate::GLArea] widget will take ownership of the returned value.
1973    #[doc(alias = "create-context")]
1974    fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>(
1975        &self,
1976        f: F,
1977    ) -> SignalHandlerId {
1978        unsafe extern "C" fn create_context_trampoline<
1979            P: IsA<GLArea>,
1980            F: Fn(&P) -> Option<gdk::GLContext> + 'static,
1981        >(
1982            this: *mut ffi::GtkGLArea,
1983            f: glib::ffi::gpointer,
1984        ) -> *mut gdk::ffi::GdkGLContext {
1985            unsafe {
1986                let f: &F = &*(f as *const F);
1987                f(GLArea::from_glib_borrow(this).unsafe_cast_ref()).to_glib_full()
1988            }
1989        }
1990        unsafe {
1991            let f: Box_<F> = Box_::new(f);
1992            connect_raw(
1993                self.as_ptr() as *mut _,
1994                c"create-context".as_ptr(),
1995                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1996                    create_context_trampoline::<Self, F> as *const (),
1997                )),
1998                Box_::into_raw(f),
1999            )
2000        }
2001    }
2002
2003    /// The ::render signal is emitted every time the contents
2004    /// of the [`GLArea`][crate::GLArea] should be redrawn.
2005    ///
2006    /// The `context` is bound to the `area` prior to emitting this function,
2007    /// and the buffers are painted to the window once the emission terminates.
2008    /// ## `context`
2009    /// the [`gdk::GLContext`][crate::gdk::GLContext] used by `area`
2010    ///
2011    /// # Returns
2012    ///
2013    /// [`true`] to stop other handlers from being invoked for the event.
2014    ///  [`false`] to propagate the event further.
2015    #[doc(alias = "render")]
2016    fn connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::Propagation + 'static>(
2017        &self,
2018        f: F,
2019    ) -> SignalHandlerId {
2020        unsafe extern "C" fn render_trampoline<
2021            P: IsA<GLArea>,
2022            F: Fn(&P, &gdk::GLContext) -> glib::Propagation + 'static,
2023        >(
2024            this: *mut ffi::GtkGLArea,
2025            context: *mut gdk::ffi::GdkGLContext,
2026            f: glib::ffi::gpointer,
2027        ) -> glib::ffi::gboolean {
2028            unsafe {
2029                let f: &F = &*(f as *const F);
2030                f(
2031                    GLArea::from_glib_borrow(this).unsafe_cast_ref(),
2032                    &from_glib_borrow(context),
2033                )
2034                .into_glib()
2035            }
2036        }
2037        unsafe {
2038            let f: Box_<F> = Box_::new(f);
2039            connect_raw(
2040                self.as_ptr() as *mut _,
2041                c"render".as_ptr(),
2042                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2043                    render_trampoline::<Self, F> as *const (),
2044                )),
2045                Box_::into_raw(f),
2046            )
2047        }
2048    }
2049
2050    /// The ::resize signal is emitted once when the widget is realized, and
2051    /// then each time the widget is changed while realized. This is useful
2052    /// in order to keep GL state up to date with the widget size, like for
2053    /// instance camera properties which may depend on the width/height ratio.
2054    ///
2055    /// The GL context for the area is guaranteed to be current when this signal
2056    /// is emitted.
2057    ///
2058    /// The default handler sets up the GL viewport.
2059    /// ## `width`
2060    /// the width of the viewport
2061    /// ## `height`
2062    /// the height of the viewport
2063    #[doc(alias = "resize")]
2064    fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
2065        unsafe extern "C" fn resize_trampoline<P: IsA<GLArea>, F: Fn(&P, i32, i32) + 'static>(
2066            this: *mut ffi::GtkGLArea,
2067            width: std::ffi::c_int,
2068            height: std::ffi::c_int,
2069            f: glib::ffi::gpointer,
2070        ) {
2071            unsafe {
2072                let f: &F = &*(f as *const F);
2073                f(
2074                    GLArea::from_glib_borrow(this).unsafe_cast_ref(),
2075                    width,
2076                    height,
2077                )
2078            }
2079        }
2080        unsafe {
2081            let f: Box_<F> = Box_::new(f);
2082            connect_raw(
2083                self.as_ptr() as *mut _,
2084                c"resize".as_ptr(),
2085                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2086                    resize_trampoline::<Self, F> as *const (),
2087                )),
2088                Box_::into_raw(f),
2089            )
2090        }
2091    }
2092
2093    #[doc(alias = "auto-render")]
2094    fn connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2095        unsafe extern "C" fn notify_auto_render_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
2096            this: *mut ffi::GtkGLArea,
2097            _param_spec: glib::ffi::gpointer,
2098            f: glib::ffi::gpointer,
2099        ) {
2100            unsafe {
2101                let f: &F = &*(f as *const F);
2102                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2103            }
2104        }
2105        unsafe {
2106            let f: Box_<F> = Box_::new(f);
2107            connect_raw(
2108                self.as_ptr() as *mut _,
2109                c"notify::auto-render".as_ptr(),
2110                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2111                    notify_auto_render_trampoline::<Self, F> as *const (),
2112                )),
2113                Box_::into_raw(f),
2114            )
2115        }
2116    }
2117
2118    #[doc(alias = "context")]
2119    fn connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2120        unsafe extern "C" fn notify_context_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
2121            this: *mut ffi::GtkGLArea,
2122            _param_spec: glib::ffi::gpointer,
2123            f: glib::ffi::gpointer,
2124        ) {
2125            unsafe {
2126                let f: &F = &*(f as *const F);
2127                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2128            }
2129        }
2130        unsafe {
2131            let f: Box_<F> = Box_::new(f);
2132            connect_raw(
2133                self.as_ptr() as *mut _,
2134                c"notify::context".as_ptr(),
2135                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2136                    notify_context_trampoline::<Self, F> as *const (),
2137                )),
2138                Box_::into_raw(f),
2139            )
2140        }
2141    }
2142
2143    #[doc(alias = "has-alpha")]
2144    fn connect_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2145        unsafe extern "C" fn notify_has_alpha_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
2146            this: *mut ffi::GtkGLArea,
2147            _param_spec: glib::ffi::gpointer,
2148            f: glib::ffi::gpointer,
2149        ) {
2150            unsafe {
2151                let f: &F = &*(f as *const F);
2152                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2153            }
2154        }
2155        unsafe {
2156            let f: Box_<F> = Box_::new(f);
2157            connect_raw(
2158                self.as_ptr() as *mut _,
2159                c"notify::has-alpha".as_ptr(),
2160                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2161                    notify_has_alpha_trampoline::<Self, F> as *const (),
2162                )),
2163                Box_::into_raw(f),
2164            )
2165        }
2166    }
2167
2168    #[doc(alias = "has-depth-buffer")]
2169    fn connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2170        unsafe extern "C" fn notify_has_depth_buffer_trampoline<
2171            P: IsA<GLArea>,
2172            F: Fn(&P) + 'static,
2173        >(
2174            this: *mut ffi::GtkGLArea,
2175            _param_spec: glib::ffi::gpointer,
2176            f: glib::ffi::gpointer,
2177        ) {
2178            unsafe {
2179                let f: &F = &*(f as *const F);
2180                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2181            }
2182        }
2183        unsafe {
2184            let f: Box_<F> = Box_::new(f);
2185            connect_raw(
2186                self.as_ptr() as *mut _,
2187                c"notify::has-depth-buffer".as_ptr(),
2188                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2189                    notify_has_depth_buffer_trampoline::<Self, F> as *const (),
2190                )),
2191                Box_::into_raw(f),
2192            )
2193        }
2194    }
2195
2196    #[doc(alias = "has-stencil-buffer")]
2197    fn connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2198        unsafe extern "C" fn notify_has_stencil_buffer_trampoline<
2199            P: IsA<GLArea>,
2200            F: Fn(&P) + 'static,
2201        >(
2202            this: *mut ffi::GtkGLArea,
2203            _param_spec: glib::ffi::gpointer,
2204            f: glib::ffi::gpointer,
2205        ) {
2206            unsafe {
2207                let f: &F = &*(f as *const F);
2208                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2209            }
2210        }
2211        unsafe {
2212            let f: Box_<F> = Box_::new(f);
2213            connect_raw(
2214                self.as_ptr() as *mut _,
2215                c"notify::has-stencil-buffer".as_ptr(),
2216                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2217                    notify_has_stencil_buffer_trampoline::<Self, F> as *const (),
2218                )),
2219                Box_::into_raw(f),
2220            )
2221        }
2222    }
2223
2224    #[doc(alias = "use-es")]
2225    fn connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2226        unsafe extern "C" fn notify_use_es_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>(
2227            this: *mut ffi::GtkGLArea,
2228            _param_spec: glib::ffi::gpointer,
2229            f: glib::ffi::gpointer,
2230        ) {
2231            unsafe {
2232                let f: &F = &*(f as *const F);
2233                f(GLArea::from_glib_borrow(this).unsafe_cast_ref())
2234            }
2235        }
2236        unsafe {
2237            let f: Box_<F> = Box_::new(f);
2238            connect_raw(
2239                self.as_ptr() as *mut _,
2240                c"notify::use-es".as_ptr(),
2241                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2242                    notify_use_es_trampoline::<Self, F> as *const (),
2243                )),
2244                Box_::into_raw(f),
2245            )
2246        }
2247    }
2248}
2249
2250impl<O: IsA<GLArea>> GLAreaExt for O {}