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 
5 use crate::Align;
6 use crate::Bin;
7 use crate::Buildable;
8 use crate::Container;
9 use crate::ResizeMode;
10 use crate::Widget;
11 use glib::object::Cast;
12 use glib::object::IsA;
13 use glib::signal::connect_raw;
14 use glib::signal::SignalHandlerId;
15 use glib::translate::*;
16 use glib::StaticType;
17 use glib::ToValue;
18 use std::boxed::Box as Box_;
19 use std::fmt;
20 use std::mem::transmute;
21 
22 glib::wrapper! {
23     #[doc(alias = "GtkEventBox")]
24     pub struct EventBox(Object<ffi::GtkEventBox, ffi::GtkEventBoxClass>) @extends Bin, Container, Widget, @implements Buildable;
25 
26     match fn {
27         type_ => || ffi::gtk_event_box_get_type(),
28     }
29 }
30 
31 impl EventBox {
32     #[doc(alias = "gtk_event_box_new")]
new() -> EventBox33     pub fn new() -> EventBox {
34         assert_initialized_main_thread!();
35         unsafe { Widget::from_glib_none(ffi::gtk_event_box_new()).unsafe_cast() }
36     }
37 
38     // rustdoc-stripper-ignore-next
39     /// Creates a new builder-pattern struct instance to construct [`EventBox`] objects.
40     ///
41     /// This method returns an instance of [`EventBoxBuilder`] which can be used to create [`EventBox`] objects.
builder() -> EventBoxBuilder42     pub fn builder() -> EventBoxBuilder {
43         EventBoxBuilder::default()
44     }
45 }
46 
47 impl Default for EventBox {
default() -> Self48     fn default() -> Self {
49         Self::new()
50     }
51 }
52 
53 #[derive(Clone, Default)]
54 // rustdoc-stripper-ignore-next
55 /// A [builder-pattern] type to construct [`EventBox`] objects.
56 ///
57 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
58 pub struct EventBoxBuilder {
59     above_child: Option<bool>,
60     visible_window: Option<bool>,
61     border_width: Option<u32>,
62     child: Option<Widget>,
63     resize_mode: Option<ResizeMode>,
64     app_paintable: Option<bool>,
65     can_default: Option<bool>,
66     can_focus: Option<bool>,
67     events: Option<gdk::EventMask>,
68     expand: Option<bool>,
69     #[cfg(any(feature = "v3_20", feature = "dox"))]
70     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
71     focus_on_click: Option<bool>,
72     halign: Option<Align>,
73     has_default: Option<bool>,
74     has_focus: Option<bool>,
75     has_tooltip: Option<bool>,
76     height_request: Option<i32>,
77     hexpand: Option<bool>,
78     hexpand_set: Option<bool>,
79     is_focus: Option<bool>,
80     margin: Option<i32>,
81     margin_bottom: Option<i32>,
82     margin_end: Option<i32>,
83     margin_start: Option<i32>,
84     margin_top: Option<i32>,
85     name: Option<String>,
86     no_show_all: Option<bool>,
87     opacity: Option<f64>,
88     parent: Option<Container>,
89     receives_default: Option<bool>,
90     sensitive: Option<bool>,
91     tooltip_markup: Option<String>,
92     tooltip_text: Option<String>,
93     valign: Option<Align>,
94     vexpand: Option<bool>,
95     vexpand_set: Option<bool>,
96     visible: Option<bool>,
97     width_request: Option<i32>,
98 }
99 
100 impl EventBoxBuilder {
101     // rustdoc-stripper-ignore-next
102     /// Create a new [`EventBoxBuilder`].
new() -> Self103     pub fn new() -> Self {
104         Self::default()
105     }
106 
107     // rustdoc-stripper-ignore-next
108     /// Build the [`EventBox`].
build(self) -> EventBox109     pub fn build(self) -> EventBox {
110         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
111         if let Some(ref above_child) = self.above_child {
112             properties.push(("above-child", above_child));
113         }
114         if let Some(ref visible_window) = self.visible_window {
115             properties.push(("visible-window", visible_window));
116         }
117         if let Some(ref border_width) = self.border_width {
118             properties.push(("border-width", border_width));
119         }
120         if let Some(ref child) = self.child {
121             properties.push(("child", child));
122         }
123         if let Some(ref resize_mode) = self.resize_mode {
124             properties.push(("resize-mode", resize_mode));
125         }
126         if let Some(ref app_paintable) = self.app_paintable {
127             properties.push(("app-paintable", app_paintable));
128         }
129         if let Some(ref can_default) = self.can_default {
130             properties.push(("can-default", can_default));
131         }
132         if let Some(ref can_focus) = self.can_focus {
133             properties.push(("can-focus", can_focus));
134         }
135         if let Some(ref events) = self.events {
136             properties.push(("events", events));
137         }
138         if let Some(ref expand) = self.expand {
139             properties.push(("expand", expand));
140         }
141         #[cfg(any(feature = "v3_20", feature = "dox"))]
142         if let Some(ref focus_on_click) = self.focus_on_click {
143             properties.push(("focus-on-click", focus_on_click));
144         }
145         if let Some(ref halign) = self.halign {
146             properties.push(("halign", halign));
147         }
148         if let Some(ref has_default) = self.has_default {
149             properties.push(("has-default", has_default));
150         }
151         if let Some(ref has_focus) = self.has_focus {
152             properties.push(("has-focus", has_focus));
153         }
154         if let Some(ref has_tooltip) = self.has_tooltip {
155             properties.push(("has-tooltip", has_tooltip));
156         }
157         if let Some(ref height_request) = self.height_request {
158             properties.push(("height-request", height_request));
159         }
160         if let Some(ref hexpand) = self.hexpand {
161             properties.push(("hexpand", hexpand));
162         }
163         if let Some(ref hexpand_set) = self.hexpand_set {
164             properties.push(("hexpand-set", hexpand_set));
165         }
166         if let Some(ref is_focus) = self.is_focus {
167             properties.push(("is-focus", is_focus));
168         }
169         if let Some(ref margin) = self.margin {
170             properties.push(("margin", margin));
171         }
172         if let Some(ref margin_bottom) = self.margin_bottom {
173             properties.push(("margin-bottom", margin_bottom));
174         }
175         if let Some(ref margin_end) = self.margin_end {
176             properties.push(("margin-end", margin_end));
177         }
178         if let Some(ref margin_start) = self.margin_start {
179             properties.push(("margin-start", margin_start));
180         }
181         if let Some(ref margin_top) = self.margin_top {
182             properties.push(("margin-top", margin_top));
183         }
184         if let Some(ref name) = self.name {
185             properties.push(("name", name));
186         }
187         if let Some(ref no_show_all) = self.no_show_all {
188             properties.push(("no-show-all", no_show_all));
189         }
190         if let Some(ref opacity) = self.opacity {
191             properties.push(("opacity", opacity));
192         }
193         if let Some(ref parent) = self.parent {
194             properties.push(("parent", parent));
195         }
196         if let Some(ref receives_default) = self.receives_default {
197             properties.push(("receives-default", receives_default));
198         }
199         if let Some(ref sensitive) = self.sensitive {
200             properties.push(("sensitive", sensitive));
201         }
202         if let Some(ref tooltip_markup) = self.tooltip_markup {
203             properties.push(("tooltip-markup", tooltip_markup));
204         }
205         if let Some(ref tooltip_text) = self.tooltip_text {
206             properties.push(("tooltip-text", tooltip_text));
207         }
208         if let Some(ref valign) = self.valign {
209             properties.push(("valign", valign));
210         }
211         if let Some(ref vexpand) = self.vexpand {
212             properties.push(("vexpand", vexpand));
213         }
214         if let Some(ref vexpand_set) = self.vexpand_set {
215             properties.push(("vexpand-set", vexpand_set));
216         }
217         if let Some(ref visible) = self.visible {
218             properties.push(("visible", visible));
219         }
220         if let Some(ref width_request) = self.width_request {
221             properties.push(("width-request", width_request));
222         }
223         glib::Object::new::<EventBox>(&properties)
224             .expect("Failed to create an instance of EventBox")
225     }
226 
above_child(mut self, above_child: bool) -> Self227     pub fn above_child(mut self, above_child: bool) -> Self {
228         self.above_child = Some(above_child);
229         self
230     }
231 
visible_window(mut self, visible_window: bool) -> Self232     pub fn visible_window(mut self, visible_window: bool) -> Self {
233         self.visible_window = Some(visible_window);
234         self
235     }
236 
border_width(mut self, border_width: u32) -> Self237     pub fn border_width(mut self, border_width: u32) -> Self {
238         self.border_width = Some(border_width);
239         self
240     }
241 
child<P: IsA<Widget>>(mut self, child: &P) -> Self242     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
243         self.child = Some(child.clone().upcast());
244         self
245     }
246 
resize_mode(mut self, resize_mode: ResizeMode) -> Self247     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
248         self.resize_mode = Some(resize_mode);
249         self
250     }
251 
app_paintable(mut self, app_paintable: bool) -> Self252     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
253         self.app_paintable = Some(app_paintable);
254         self
255     }
256 
can_default(mut self, can_default: bool) -> Self257     pub fn can_default(mut self, can_default: bool) -> Self {
258         self.can_default = Some(can_default);
259         self
260     }
261 
can_focus(mut self, can_focus: bool) -> Self262     pub fn can_focus(mut self, can_focus: bool) -> Self {
263         self.can_focus = Some(can_focus);
264         self
265     }
266 
events(mut self, events: gdk::EventMask) -> Self267     pub fn events(mut self, events: gdk::EventMask) -> Self {
268         self.events = Some(events);
269         self
270     }
271 
expand(mut self, expand: bool) -> Self272     pub fn expand(mut self, expand: bool) -> Self {
273         self.expand = Some(expand);
274         self
275     }
276 
277     #[cfg(any(feature = "v3_20", feature = "dox"))]
278     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self279     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
280         self.focus_on_click = Some(focus_on_click);
281         self
282     }
283 
halign(mut self, halign: Align) -> Self284     pub fn halign(mut self, halign: Align) -> Self {
285         self.halign = Some(halign);
286         self
287     }
288 
has_default(mut self, has_default: bool) -> Self289     pub fn has_default(mut self, has_default: bool) -> Self {
290         self.has_default = Some(has_default);
291         self
292     }
293 
has_focus(mut self, has_focus: bool) -> Self294     pub fn has_focus(mut self, has_focus: bool) -> Self {
295         self.has_focus = Some(has_focus);
296         self
297     }
298 
has_tooltip(mut self, has_tooltip: bool) -> Self299     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
300         self.has_tooltip = Some(has_tooltip);
301         self
302     }
303 
height_request(mut self, height_request: i32) -> Self304     pub fn height_request(mut self, height_request: i32) -> Self {
305         self.height_request = Some(height_request);
306         self
307     }
308 
hexpand(mut self, hexpand: bool) -> Self309     pub fn hexpand(mut self, hexpand: bool) -> Self {
310         self.hexpand = Some(hexpand);
311         self
312     }
313 
hexpand_set(mut self, hexpand_set: bool) -> Self314     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
315         self.hexpand_set = Some(hexpand_set);
316         self
317     }
318 
is_focus(mut self, is_focus: bool) -> Self319     pub fn is_focus(mut self, is_focus: bool) -> Self {
320         self.is_focus = Some(is_focus);
321         self
322     }
323 
margin(mut self, margin: i32) -> Self324     pub fn margin(mut self, margin: i32) -> Self {
325         self.margin = Some(margin);
326         self
327     }
328 
margin_bottom(mut self, margin_bottom: i32) -> Self329     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
330         self.margin_bottom = Some(margin_bottom);
331         self
332     }
333 
margin_end(mut self, margin_end: i32) -> Self334     pub fn margin_end(mut self, margin_end: i32) -> Self {
335         self.margin_end = Some(margin_end);
336         self
337     }
338 
margin_start(mut self, margin_start: i32) -> Self339     pub fn margin_start(mut self, margin_start: i32) -> Self {
340         self.margin_start = Some(margin_start);
341         self
342     }
343 
margin_top(mut self, margin_top: i32) -> Self344     pub fn margin_top(mut self, margin_top: i32) -> Self {
345         self.margin_top = Some(margin_top);
346         self
347     }
348 
name(mut self, name: &str) -> Self349     pub fn name(mut self, name: &str) -> Self {
350         self.name = Some(name.to_string());
351         self
352     }
353 
no_show_all(mut self, no_show_all: bool) -> Self354     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
355         self.no_show_all = Some(no_show_all);
356         self
357     }
358 
opacity(mut self, opacity: f64) -> Self359     pub fn opacity(mut self, opacity: f64) -> Self {
360         self.opacity = Some(opacity);
361         self
362     }
363 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self364     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
365         self.parent = Some(parent.clone().upcast());
366         self
367     }
368 
receives_default(mut self, receives_default: bool) -> Self369     pub fn receives_default(mut self, receives_default: bool) -> Self {
370         self.receives_default = Some(receives_default);
371         self
372     }
373 
sensitive(mut self, sensitive: bool) -> Self374     pub fn sensitive(mut self, sensitive: bool) -> Self {
375         self.sensitive = Some(sensitive);
376         self
377     }
378 
tooltip_markup(mut self, tooltip_markup: &str) -> Self379     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
380         self.tooltip_markup = Some(tooltip_markup.to_string());
381         self
382     }
383 
tooltip_text(mut self, tooltip_text: &str) -> Self384     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
385         self.tooltip_text = Some(tooltip_text.to_string());
386         self
387     }
388 
valign(mut self, valign: Align) -> Self389     pub fn valign(mut self, valign: Align) -> Self {
390         self.valign = Some(valign);
391         self
392     }
393 
vexpand(mut self, vexpand: bool) -> Self394     pub fn vexpand(mut self, vexpand: bool) -> Self {
395         self.vexpand = Some(vexpand);
396         self
397     }
398 
vexpand_set(mut self, vexpand_set: bool) -> Self399     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
400         self.vexpand_set = Some(vexpand_set);
401         self
402     }
403 
visible(mut self, visible: bool) -> Self404     pub fn visible(mut self, visible: bool) -> Self {
405         self.visible = Some(visible);
406         self
407     }
408 
width_request(mut self, width_request: i32) -> Self409     pub fn width_request(mut self, width_request: i32) -> Self {
410         self.width_request = Some(width_request);
411         self
412     }
413 }
414 
415 pub const NONE_EVENT_BOX: Option<&EventBox> = None;
416 
417 pub trait EventBoxExt: 'static {
418     #[doc(alias = "gtk_event_box_get_above_child")]
419     #[doc(alias = "get_above_child")]
is_above_child(&self) -> bool420     fn is_above_child(&self) -> bool;
421 
422     #[doc(alias = "gtk_event_box_get_visible_window")]
423     #[doc(alias = "get_visible_window")]
is_visible_window(&self) -> bool424     fn is_visible_window(&self) -> bool;
425 
426     #[doc(alias = "gtk_event_box_set_above_child")]
set_above_child(&self, above_child: bool)427     fn set_above_child(&self, above_child: bool);
428 
429     #[doc(alias = "gtk_event_box_set_visible_window")]
set_visible_window(&self, visible_window: bool)430     fn set_visible_window(&self, visible_window: bool);
431 
432     #[doc(alias = "above-child")]
connect_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId433     fn connect_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
434 
435     #[doc(alias = "visible-window")]
connect_visible_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId436     fn connect_visible_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
437 }
438 
439 impl<O: IsA<EventBox>> EventBoxExt for O {
is_above_child(&self) -> bool440     fn is_above_child(&self) -> bool {
441         unsafe {
442             from_glib(ffi::gtk_event_box_get_above_child(
443                 self.as_ref().to_glib_none().0,
444             ))
445         }
446     }
447 
is_visible_window(&self) -> bool448     fn is_visible_window(&self) -> bool {
449         unsafe {
450             from_glib(ffi::gtk_event_box_get_visible_window(
451                 self.as_ref().to_glib_none().0,
452             ))
453         }
454     }
455 
set_above_child(&self, above_child: bool)456     fn set_above_child(&self, above_child: bool) {
457         unsafe {
458             ffi::gtk_event_box_set_above_child(
459                 self.as_ref().to_glib_none().0,
460                 above_child.into_glib(),
461             );
462         }
463     }
464 
set_visible_window(&self, visible_window: bool)465     fn set_visible_window(&self, visible_window: bool) {
466         unsafe {
467             ffi::gtk_event_box_set_visible_window(
468                 self.as_ref().to_glib_none().0,
469                 visible_window.into_glib(),
470             );
471         }
472     }
473 
connect_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId474     fn connect_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
475         unsafe extern "C" fn notify_above_child_trampoline<
476             P: IsA<EventBox>,
477             F: Fn(&P) + 'static,
478         >(
479             this: *mut ffi::GtkEventBox,
480             _param_spec: glib::ffi::gpointer,
481             f: glib::ffi::gpointer,
482         ) {
483             let f: &F = &*(f as *const F);
484             f(EventBox::from_glib_borrow(this).unsafe_cast_ref())
485         }
486         unsafe {
487             let f: Box_<F> = Box_::new(f);
488             connect_raw(
489                 self.as_ptr() as *mut _,
490                 b"notify::above-child\0".as_ptr() as *const _,
491                 Some(transmute::<_, unsafe extern "C" fn()>(
492                     notify_above_child_trampoline::<Self, F> as *const (),
493                 )),
494                 Box_::into_raw(f),
495             )
496         }
497     }
498 
connect_visible_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId499     fn connect_visible_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
500         unsafe extern "C" fn notify_visible_window_trampoline<
501             P: IsA<EventBox>,
502             F: Fn(&P) + 'static,
503         >(
504             this: *mut ffi::GtkEventBox,
505             _param_spec: glib::ffi::gpointer,
506             f: glib::ffi::gpointer,
507         ) {
508             let f: &F = &*(f as *const F);
509             f(EventBox::from_glib_borrow(this).unsafe_cast_ref())
510         }
511         unsafe {
512             let f: Box_<F> = Box_::new(f);
513             connect_raw(
514                 self.as_ptr() as *mut _,
515                 b"notify::visible-window\0".as_ptr() as *const _,
516                 Some(transmute::<_, unsafe extern "C" fn()>(
517                     notify_visible_window_trampoline::<Self, F> as *const (),
518                 )),
519                 Box_::into_raw(f),
520             )
521         }
522     }
523 }
524 
525 impl fmt::Display for EventBox {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result526     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
527         f.write_str("EventBox")
528     }
529 }
530