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