Skip to main content

gtk/auto/
event_box.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, Bin, Buildable, Container, ResizeMode, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    /// The [`EventBox`][crate::EventBox] widget is a subclass of [`Bin`][crate::Bin] which also has its
15    /// own window. It is useful since it allows you to catch events for widgets
16    /// which do not have their own window.
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `above-child`
22    ///  Readable | Writeable
23    ///
24    ///
25    /// #### `visible-window`
26    ///  Readable | Writeable
27    /// <details><summary><h4>Container</h4></summary>
28    ///
29    ///
30    /// #### `border-width`
31    ///  Readable | Writeable
32    ///
33    ///
34    /// #### `child`
35    ///  Writeable
36    ///
37    ///
38    /// #### `resize-mode`
39    ///  Readable | Writeable
40    /// </details>
41    /// <details><summary><h4>Widget</h4></summary>
42    ///
43    ///
44    /// #### `app-paintable`
45    ///  Readable | Writeable
46    ///
47    ///
48    /// #### `can-default`
49    ///  Readable | Writeable
50    ///
51    ///
52    /// #### `can-focus`
53    ///  Readable | Writeable
54    ///
55    ///
56    /// #### `composite-child`
57    ///  Readable
58    ///
59    ///
60    /// #### `double-buffered`
61    ///  Whether the widget is double buffered.
62    ///
63    /// Readable | Writeable
64    ///
65    ///
66    /// #### `events`
67    ///  Readable | Writeable
68    ///
69    ///
70    /// #### `expand`
71    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
72    ///
73    /// Readable | Writeable
74    ///
75    ///
76    /// #### `focus-on-click`
77    ///  Whether the widget should grab focus when it is clicked with the mouse.
78    ///
79    /// This property is only relevant for widgets that can take focus.
80    ///
81    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
82    /// GtkComboBox) implemented this property individually.
83    ///
84    /// Readable | Writeable
85    ///
86    ///
87    /// #### `halign`
88    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
89    ///
90    /// Readable | Writeable
91    ///
92    ///
93    /// #### `has-default`
94    ///  Readable | Writeable
95    ///
96    ///
97    /// #### `has-focus`
98    ///  Readable | Writeable
99    ///
100    ///
101    /// #### `has-tooltip`
102    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
103    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
104    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
105    /// whether it will provide a tooltip or not.
106    ///
107    /// Note that setting this property to [`true`] for the first time will change
108    /// the event masks of the GdkWindows of this widget to include leave-notify
109    /// and motion-notify events. This cannot and will not be undone when the
110    /// property is set to [`false`] again.
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `height-request`
116    ///  Readable | Writeable
117    ///
118    ///
119    /// #### `hexpand`
120    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
121    ///
122    /// Readable | Writeable
123    ///
124    ///
125    /// #### `hexpand-set`
126    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
127    ///
128    /// Readable | Writeable
129    ///
130    ///
131    /// #### `is-focus`
132    ///  Readable | Writeable
133    ///
134    ///
135    /// #### `margin`
136    ///  Sets all four sides' margin at once. If read, returns max
137    /// margin on any side.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `margin-bottom`
143    ///  Margin on bottom side of widget.
144    ///
145    /// This property adds margin outside of the widget's normal size
146    /// request, the margin will be added in addition to the size from
147    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
148    ///
149    /// Readable | Writeable
150    ///
151    ///
152    /// #### `margin-end`
153    ///  Margin on end of widget, horizontally. This property supports
154    /// left-to-right and right-to-left text directions.
155    ///
156    /// This property adds margin outside of the widget's normal size
157    /// request, the margin will be added in addition to the size from
158    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `margin-left`
164    ///  Margin on left side of widget.
165    ///
166    /// This property adds margin outside of the widget's normal size
167    /// request, the margin will be added in addition to the size from
168    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
169    ///
170    /// Readable | Writeable
171    ///
172    ///
173    /// #### `margin-right`
174    ///  Margin on right side of widget.
175    ///
176    /// This property adds margin outside of the widget's normal size
177    /// request, the margin will be added in addition to the size from
178    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
179    ///
180    /// Readable | Writeable
181    ///
182    ///
183    /// #### `margin-start`
184    ///  Margin on start of widget, horizontally. This property supports
185    /// left-to-right and right-to-left text directions.
186    ///
187    /// This property adds margin outside of the widget's normal size
188    /// request, the margin will be added in addition to the size from
189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `margin-top`
195    ///  Margin on top side of widget.
196    ///
197    /// This property adds margin outside of the widget's normal size
198    /// request, the margin will be added in addition to the size from
199    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
200    ///
201    /// Readable | Writeable
202    ///
203    ///
204    /// #### `name`
205    ///  Readable | Writeable
206    ///
207    ///
208    /// #### `no-show-all`
209    ///  Readable | Writeable
210    ///
211    ///
212    /// #### `opacity`
213    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
214    /// more details about window opacity.
215    ///
216    /// Before 3.8 this was only available in GtkWindow
217    ///
218    /// Readable | Writeable
219    ///
220    ///
221    /// #### `parent`
222    ///  Readable | Writeable
223    ///
224    ///
225    /// #### `receives-default`
226    ///  Readable | Writeable
227    ///
228    ///
229    /// #### `scale-factor`
230    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
231    /// more details about widget scaling.
232    ///
233    /// Readable
234    ///
235    ///
236    /// #### `sensitive`
237    ///  Readable | Writeable
238    ///
239    ///
240    /// #### `style`
241    ///  The style of the widget, which contains information about how it will look (colors, etc).
242    ///
243    /// Readable | Writeable
244    ///
245    ///
246    /// #### `tooltip-markup`
247    ///  Sets the text of tooltip to be the given string, which is marked up
248    /// with the [Pango text markup language][PangoMarkupFormat].
249    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
250    ///
251    /// This is a convenience property which will take care of getting the
252    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
253    /// will automatically be set to [`true`] and there will be taken care of
254    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
255    ///
256    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
257    /// are set, the last one wins.
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `tooltip-text`
263    ///  Sets the text of tooltip to be the given string.
264    ///
265    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
266    ///
267    /// This is a convenience property which will take care of getting the
268    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
269    /// will automatically be set to [`true`] and there will be taken care of
270    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
271    ///
272    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
273    /// are set, the last one wins.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `valign`
279    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
280    ///
281    /// Readable | Writeable
282    ///
283    ///
284    /// #### `vexpand`
285    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
286    ///
287    /// Readable | Writeable
288    ///
289    ///
290    /// #### `vexpand-set`
291    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
292    ///
293    /// Readable | Writeable
294    ///
295    ///
296    /// #### `visible`
297    ///  Readable | Writeable
298    ///
299    ///
300    /// #### `width-request`
301    ///  Readable | Writeable
302    ///
303    ///
304    /// #### `window`
305    ///  The widget's window if it is realized, [`None`] otherwise.
306    ///
307    /// Readable
308    /// </details>
309    ///
310    /// # Implements
311    ///
312    /// [`EventBoxExt`][trait@crate::prelude::EventBoxExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
313    #[doc(alias = "GtkEventBox")]
314    pub struct EventBox(Object<ffi::GtkEventBox, ffi::GtkEventBoxClass>) @extends Bin, Container, Widget, @implements Buildable;
315
316    match fn {
317        type_ => || ffi::gtk_event_box_get_type(),
318    }
319}
320
321impl EventBox {
322    pub const NONE: Option<&'static EventBox> = None;
323
324    /// Creates a new [`EventBox`][crate::EventBox].
325    ///
326    /// # Returns
327    ///
328    /// a new [`EventBox`][crate::EventBox]
329    #[doc(alias = "gtk_event_box_new")]
330    pub fn new() -> EventBox {
331        assert_initialized_main_thread!();
332        unsafe { Widget::from_glib_none(ffi::gtk_event_box_new()).unsafe_cast() }
333    }
334
335    // rustdoc-stripper-ignore-next
336    /// Creates a new builder-pattern struct instance to construct [`EventBox`] objects.
337    ///
338    /// This method returns an instance of [`EventBoxBuilder`](crate::builders::EventBoxBuilder) which can be used to create [`EventBox`] objects.
339    pub fn builder() -> EventBoxBuilder {
340        EventBoxBuilder::new()
341    }
342}
343
344impl Default for EventBox {
345    fn default() -> Self {
346        Self::new()
347    }
348}
349
350// rustdoc-stripper-ignore-next
351/// A [builder-pattern] type to construct [`EventBox`] objects.
352///
353/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
354#[must_use = "The builder must be built to be used"]
355pub struct EventBoxBuilder {
356    builder: glib::object::ObjectBuilder<'static, EventBox>,
357}
358
359impl EventBoxBuilder {
360    fn new() -> Self {
361        Self {
362            builder: glib::object::Object::builder(),
363        }
364    }
365
366    pub fn above_child(self, above_child: bool) -> Self {
367        Self {
368            builder: self.builder.property("above-child", above_child),
369        }
370    }
371
372    pub fn visible_window(self, visible_window: bool) -> Self {
373        Self {
374            builder: self.builder.property("visible-window", visible_window),
375        }
376    }
377
378    pub fn border_width(self, border_width: u32) -> Self {
379        Self {
380            builder: self.builder.property("border-width", border_width),
381        }
382    }
383
384    pub fn child(self, child: &impl IsA<Widget>) -> Self {
385        Self {
386            builder: self.builder.property("child", child.clone().upcast()),
387        }
388    }
389
390    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
391        Self {
392            builder: self.builder.property("resize-mode", resize_mode),
393        }
394    }
395
396    pub fn app_paintable(self, app_paintable: bool) -> Self {
397        Self {
398            builder: self.builder.property("app-paintable", app_paintable),
399        }
400    }
401
402    pub fn can_default(self, can_default: bool) -> Self {
403        Self {
404            builder: self.builder.property("can-default", can_default),
405        }
406    }
407
408    pub fn can_focus(self, can_focus: bool) -> Self {
409        Self {
410            builder: self.builder.property("can-focus", can_focus),
411        }
412    }
413
414    pub fn events(self, events: gdk::EventMask) -> Self {
415        Self {
416            builder: self.builder.property("events", events),
417        }
418    }
419
420    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
421    pub fn expand(self, expand: bool) -> Self {
422        Self {
423            builder: self.builder.property("expand", expand),
424        }
425    }
426
427    /// Whether the widget should grab focus when it is clicked with the mouse.
428    ///
429    /// This property is only relevant for widgets that can take focus.
430    ///
431    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
432    /// GtkComboBox) implemented this property individually.
433    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
434        Self {
435            builder: self.builder.property("focus-on-click", focus_on_click),
436        }
437    }
438
439    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
440    pub fn halign(self, halign: Align) -> Self {
441        Self {
442            builder: self.builder.property("halign", halign),
443        }
444    }
445
446    pub fn has_default(self, has_default: bool) -> Self {
447        Self {
448            builder: self.builder.property("has-default", has_default),
449        }
450    }
451
452    pub fn has_focus(self, has_focus: bool) -> Self {
453        Self {
454            builder: self.builder.property("has-focus", has_focus),
455        }
456    }
457
458    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
459    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
460    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
461    /// whether it will provide a tooltip or not.
462    ///
463    /// Note that setting this property to [`true`] for the first time will change
464    /// the event masks of the GdkWindows of this widget to include leave-notify
465    /// and motion-notify events. This cannot and will not be undone when the
466    /// property is set to [`false`] again.
467    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
468        Self {
469            builder: self.builder.property("has-tooltip", has_tooltip),
470        }
471    }
472
473    pub fn height_request(self, height_request: i32) -> Self {
474        Self {
475            builder: self.builder.property("height-request", height_request),
476        }
477    }
478
479    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
480    pub fn hexpand(self, hexpand: bool) -> Self {
481        Self {
482            builder: self.builder.property("hexpand", hexpand),
483        }
484    }
485
486    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
487    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
488        Self {
489            builder: self.builder.property("hexpand-set", hexpand_set),
490        }
491    }
492
493    pub fn is_focus(self, is_focus: bool) -> Self {
494        Self {
495            builder: self.builder.property("is-focus", is_focus),
496        }
497    }
498
499    /// Sets all four sides' margin at once. If read, returns max
500    /// margin on any side.
501    pub fn margin(self, margin: i32) -> Self {
502        Self {
503            builder: self.builder.property("margin", margin),
504        }
505    }
506
507    /// Margin on bottom side of widget.
508    ///
509    /// This property adds margin outside of the widget's normal size
510    /// request, the margin will be added in addition to the size from
511    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
512    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
513        Self {
514            builder: self.builder.property("margin-bottom", margin_bottom),
515        }
516    }
517
518    /// Margin on end of widget, horizontally. This property supports
519    /// left-to-right and right-to-left text directions.
520    ///
521    /// This property adds margin outside of the widget's normal size
522    /// request, the margin will be added in addition to the size from
523    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
524    pub fn margin_end(self, margin_end: i32) -> Self {
525        Self {
526            builder: self.builder.property("margin-end", margin_end),
527        }
528    }
529
530    /// Margin on start of widget, horizontally. This property supports
531    /// left-to-right and right-to-left text directions.
532    ///
533    /// This property adds margin outside of the widget's normal size
534    /// request, the margin will be added in addition to the size from
535    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
536    pub fn margin_start(self, margin_start: i32) -> Self {
537        Self {
538            builder: self.builder.property("margin-start", margin_start),
539        }
540    }
541
542    /// Margin on top side of widget.
543    ///
544    /// This property adds margin outside of the widget's normal size
545    /// request, the margin will be added in addition to the size from
546    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
547    pub fn margin_top(self, margin_top: i32) -> Self {
548        Self {
549            builder: self.builder.property("margin-top", margin_top),
550        }
551    }
552
553    pub fn name(self, name: impl Into<glib::GString>) -> Self {
554        Self {
555            builder: self.builder.property("name", name.into()),
556        }
557    }
558
559    pub fn no_show_all(self, no_show_all: bool) -> Self {
560        Self {
561            builder: self.builder.property("no-show-all", no_show_all),
562        }
563    }
564
565    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
566    /// more details about window opacity.
567    ///
568    /// Before 3.8 this was only available in GtkWindow
569    pub fn opacity(self, opacity: f64) -> Self {
570        Self {
571            builder: self.builder.property("opacity", opacity),
572        }
573    }
574
575    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
576        Self {
577            builder: self.builder.property("parent", parent.clone().upcast()),
578        }
579    }
580
581    pub fn receives_default(self, receives_default: bool) -> Self {
582        Self {
583            builder: self.builder.property("receives-default", receives_default),
584        }
585    }
586
587    pub fn sensitive(self, sensitive: bool) -> Self {
588        Self {
589            builder: self.builder.property("sensitive", sensitive),
590        }
591    }
592
593    /// Sets the text of tooltip to be the given string, which is marked up
594    /// with the [Pango text markup language][PangoMarkupFormat].
595    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
596    ///
597    /// This is a convenience property which will take care of getting the
598    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
599    /// will automatically be set to [`true`] and there will be taken care of
600    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
601    ///
602    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
603    /// are set, the last one wins.
604    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
605        Self {
606            builder: self
607                .builder
608                .property("tooltip-markup", tooltip_markup.into()),
609        }
610    }
611
612    /// Sets the text of tooltip to be the given string.
613    ///
614    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
615    ///
616    /// This is a convenience property which will take care of getting the
617    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
618    /// will automatically be set to [`true`] and there will be taken care of
619    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
620    ///
621    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
622    /// are set, the last one wins.
623    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
624        Self {
625            builder: self.builder.property("tooltip-text", tooltip_text.into()),
626        }
627    }
628
629    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
630    pub fn valign(self, valign: Align) -> Self {
631        Self {
632            builder: self.builder.property("valign", valign),
633        }
634    }
635
636    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
637    pub fn vexpand(self, vexpand: bool) -> Self {
638        Self {
639            builder: self.builder.property("vexpand", vexpand),
640        }
641    }
642
643    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
644    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
645        Self {
646            builder: self.builder.property("vexpand-set", vexpand_set),
647        }
648    }
649
650    pub fn visible(self, visible: bool) -> Self {
651        Self {
652            builder: self.builder.property("visible", visible),
653        }
654    }
655
656    pub fn width_request(self, width_request: i32) -> Self {
657        Self {
658            builder: self.builder.property("width-request", width_request),
659        }
660    }
661
662    // rustdoc-stripper-ignore-next
663    /// Build the [`EventBox`].
664    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
665    pub fn build(self) -> EventBox {
666        self.builder.build()
667    }
668}
669
670mod sealed {
671    pub trait Sealed {}
672    impl<T: super::IsA<super::EventBox>> Sealed for T {}
673}
674
675/// Trait containing all [`struct@EventBox`] methods.
676///
677/// # Implementors
678///
679/// [`EventBox`][struct@crate::EventBox]
680pub trait EventBoxExt: IsA<EventBox> + sealed::Sealed + 'static {
681    /// Returns whether the event box window is above or below the
682    /// windows of its child. See [`set_above_child()`][Self::set_above_child()]
683    /// for details.
684    ///
685    /// # Returns
686    ///
687    /// [`true`] if the event box window is above the
688    ///  window of its child
689    #[doc(alias = "gtk_event_box_get_above_child")]
690    #[doc(alias = "get_above_child")]
691    fn is_above_child(&self) -> bool {
692        unsafe {
693            from_glib(ffi::gtk_event_box_get_above_child(
694                self.as_ref().to_glib_none().0,
695            ))
696        }
697    }
698
699    /// Returns whether the event box has a visible window.
700    /// See [`set_visible_window()`][Self::set_visible_window()] for details.
701    ///
702    /// # Returns
703    ///
704    /// [`true`] if the event box window is visible
705    #[doc(alias = "gtk_event_box_get_visible_window")]
706    #[doc(alias = "get_visible_window")]
707    fn is_visible_window(&self) -> bool {
708        unsafe {
709            from_glib(ffi::gtk_event_box_get_visible_window(
710                self.as_ref().to_glib_none().0,
711            ))
712        }
713    }
714
715    /// Set whether the event box window is positioned above the windows
716    /// of its child, as opposed to below it. If the window is above, all
717    /// events inside the event box will go to the event box. If the window
718    /// is below, events in windows of child widgets will first got to that
719    /// widget, and then to its parents.
720    ///
721    /// The default is to keep the window below the child.
722    /// ## `above_child`
723    /// [`true`] if the event box window is above its child
724    #[doc(alias = "gtk_event_box_set_above_child")]
725    fn set_above_child(&self, above_child: bool) {
726        unsafe {
727            ffi::gtk_event_box_set_above_child(
728                self.as_ref().to_glib_none().0,
729                above_child.into_glib(),
730            );
731        }
732    }
733
734    /// Set whether the event box uses a visible or invisible child
735    /// window. The default is to use visible windows.
736    ///
737    /// In an invisible window event box, the window that the
738    /// event box creates is a `GDK_INPUT_ONLY` window, which
739    /// means that it is invisible and only serves to receive
740    /// events.
741    ///
742    /// A visible window event box creates a visible (`GDK_INPUT_OUTPUT`)
743    /// window that acts as the parent window for all the widgets
744    /// contained in the event box.
745    ///
746    /// You should generally make your event box invisible if
747    /// you just want to trap events. Creating a visible window
748    /// may cause artifacts that are visible to the user, especially
749    /// if the user is using a theme with gradients or pixmaps.
750    ///
751    /// The main reason to create a non input-only event box is if
752    /// you want to set the background to a different color or
753    /// draw on it.
754    ///
755    /// There is one unexpected issue for an invisible event box that has its
756    /// window below the child. (See [`set_above_child()`][Self::set_above_child()].)
757    /// Since the input-only window is not an ancestor window of any windows
758    /// that descendent widgets of the event box create, events on these
759    /// windows aren’t propagated up by the windowing system, but only by GTK+.
760    /// The practical effect of this is if an event isn’t in the event
761    /// mask for the descendant window (see [`WidgetExtManual::add_events()`][crate::prelude::WidgetExtManual::add_events()]),
762    /// it won’t be received by the event box.
763    ///
764    /// This problem doesn’t occur for visible event boxes, because in
765    /// that case, the event box window is actually the ancestor of the
766    /// descendant windows, not just at the same place on the screen.
767    /// ## `visible_window`
768    /// [`true`] to make the event box have a visible window
769    #[doc(alias = "gtk_event_box_set_visible_window")]
770    fn set_visible_window(&self, visible_window: bool) {
771        unsafe {
772            ffi::gtk_event_box_set_visible_window(
773                self.as_ref().to_glib_none().0,
774                visible_window.into_glib(),
775            );
776        }
777    }
778
779    #[doc(alias = "above-child")]
780    fn connect_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
781        unsafe extern "C" fn notify_above_child_trampoline<
782            P: IsA<EventBox>,
783            F: Fn(&P) + 'static,
784        >(
785            this: *mut ffi::GtkEventBox,
786            _param_spec: glib::ffi::gpointer,
787            f: glib::ffi::gpointer,
788        ) {
789            let f: &F = &*(f as *const F);
790            f(EventBox::from_glib_borrow(this).unsafe_cast_ref())
791        }
792        unsafe {
793            let f: Box_<F> = Box_::new(f);
794            connect_raw(
795                self.as_ptr() as *mut _,
796                b"notify::above-child\0".as_ptr() as *const _,
797                Some(transmute::<_, unsafe extern "C" fn()>(
798                    notify_above_child_trampoline::<Self, F> as *const (),
799                )),
800                Box_::into_raw(f),
801            )
802        }
803    }
804
805    #[doc(alias = "visible-window")]
806    fn connect_visible_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
807        unsafe extern "C" fn notify_visible_window_trampoline<
808            P: IsA<EventBox>,
809            F: Fn(&P) + 'static,
810        >(
811            this: *mut ffi::GtkEventBox,
812            _param_spec: glib::ffi::gpointer,
813            f: glib::ffi::gpointer,
814        ) {
815            let f: &F = &*(f as *const F);
816            f(EventBox::from_glib_borrow(this).unsafe_cast_ref())
817        }
818        unsafe {
819            let f: Box_<F> = Box_::new(f);
820            connect_raw(
821                self.as_ptr() as *mut _,
822                b"notify::visible-window\0".as_ptr() as *const _,
823                Some(transmute::<_, unsafe extern "C" fn()>(
824                    notify_visible_window_trampoline::<Self, F> as *const (),
825                )),
826                Box_::into_raw(f),
827            )
828        }
829    }
830}
831
832impl<O: IsA<EventBox>> EventBoxExt for O {}
833
834impl fmt::Display for EventBox {
835    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
836        f.write_str("EventBox")
837    }
838}