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 gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::StaticType;
12use glib::ToValue;
13use glib_sys;
14use gtk_sys;
15use std::boxed::Box as Box_;
16use std::fmt;
17use std::mem::transmute;
18use Align;
19use Bin;
20use Buildable;
21use Container;
22use ResizeMode;
23use Widget;
24
25glib_wrapper! {
26    pub struct EventBox(Object<gtk_sys::GtkEventBox, gtk_sys::GtkEventBoxClass, EventBoxClass>) @extends Bin, Container, Widget, @implements Buildable;
27
28    match fn {
29        get_type => || gtk_sys::gtk_event_box_get_type(),
30    }
31}
32
33impl EventBox {
34    pub fn new() -> EventBox {
35        assert_initialized_main_thread!();
36        unsafe { Widget::from_glib_none(gtk_sys::gtk_event_box_new()).unsafe_cast() }
37    }
38}
39
40impl Default for EventBox {
41    fn default() -> Self {
42        Self::new()
43    }
44}
45
46pub struct EventBoxBuilder {
47    above_child: Option<bool>,
48    visible_window: Option<bool>,
49    border_width: Option<u32>,
50    child: Option<Widget>,
51    resize_mode: Option<ResizeMode>,
52    app_paintable: Option<bool>,
53    can_default: Option<bool>,
54    can_focus: Option<bool>,
55    events: Option<gdk::EventMask>,
56    expand: Option<bool>,
57    #[cfg(any(feature = "v3_20", feature = "dox"))]
58    focus_on_click: Option<bool>,
59    halign: Option<Align>,
60    has_default: Option<bool>,
61    has_focus: Option<bool>,
62    has_tooltip: Option<bool>,
63    height_request: Option<i32>,
64    hexpand: Option<bool>,
65    hexpand_set: Option<bool>,
66    is_focus: Option<bool>,
67    margin: Option<i32>,
68    margin_bottom: Option<i32>,
69    margin_end: Option<i32>,
70    margin_start: Option<i32>,
71    margin_top: Option<i32>,
72    name: Option<String>,
73    no_show_all: Option<bool>,
74    opacity: Option<f64>,
75    parent: Option<Container>,
76    receives_default: Option<bool>,
77    sensitive: Option<bool>,
78    //style: /*Unknown type*/,
79    tooltip_markup: Option<String>,
80    tooltip_text: Option<String>,
81    valign: Option<Align>,
82    vexpand: Option<bool>,
83    vexpand_set: Option<bool>,
84    visible: Option<bool>,
85    width_request: Option<i32>,
86}
87
88impl EventBoxBuilder {
89    pub fn new() -> Self {
90        Self {
91            above_child: None,
92            visible_window: None,
93            border_width: None,
94            child: None,
95            resize_mode: None,
96            app_paintable: None,
97            can_default: None,
98            can_focus: None,
99            events: None,
100            expand: None,
101            #[cfg(any(feature = "v3_20", feature = "dox"))]
102            focus_on_click: None,
103            halign: None,
104            has_default: None,
105            has_focus: None,
106            has_tooltip: None,
107            height_request: None,
108            hexpand: None,
109            hexpand_set: None,
110            is_focus: None,
111            margin: None,
112            margin_bottom: None,
113            margin_end: None,
114            margin_start: None,
115            margin_top: None,
116            name: None,
117            no_show_all: None,
118            opacity: None,
119            parent: None,
120            receives_default: None,
121            sensitive: None,
122            tooltip_markup: None,
123            tooltip_text: None,
124            valign: None,
125            vexpand: None,
126            vexpand_set: None,
127            visible: None,
128            width_request: None,
129        }
130    }
131
132    pub fn build(self) -> EventBox {
133        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
134        if let Some(ref above_child) = self.above_child {
135            properties.push(("above-child", above_child));
136        }
137        if let Some(ref visible_window) = self.visible_window {
138            properties.push(("visible-window", visible_window));
139        }
140        if let Some(ref border_width) = self.border_width {
141            properties.push(("border-width", border_width));
142        }
143        if let Some(ref child) = self.child {
144            properties.push(("child", child));
145        }
146        if let Some(ref resize_mode) = self.resize_mode {
147            properties.push(("resize-mode", resize_mode));
148        }
149        if let Some(ref app_paintable) = self.app_paintable {
150            properties.push(("app-paintable", app_paintable));
151        }
152        if let Some(ref can_default) = self.can_default {
153            properties.push(("can-default", can_default));
154        }
155        if let Some(ref can_focus) = self.can_focus {
156            properties.push(("can-focus", can_focus));
157        }
158        if let Some(ref events) = self.events {
159            properties.push(("events", events));
160        }
161        if let Some(ref expand) = self.expand {
162            properties.push(("expand", expand));
163        }
164        #[cfg(any(feature = "v3_20", feature = "dox"))]
165        {
166            if let Some(ref focus_on_click) = self.focus_on_click {
167                properties.push(("focus-on-click", focus_on_click));
168            }
169        }
170        if let Some(ref halign) = self.halign {
171            properties.push(("halign", halign));
172        }
173        if let Some(ref has_default) = self.has_default {
174            properties.push(("has-default", has_default));
175        }
176        if let Some(ref has_focus) = self.has_focus {
177            properties.push(("has-focus", has_focus));
178        }
179        if let Some(ref has_tooltip) = self.has_tooltip {
180            properties.push(("has-tooltip", has_tooltip));
181        }
182        if let Some(ref height_request) = self.height_request {
183            properties.push(("height-request", height_request));
184        }
185        if let Some(ref hexpand) = self.hexpand {
186            properties.push(("hexpand", hexpand));
187        }
188        if let Some(ref hexpand_set) = self.hexpand_set {
189            properties.push(("hexpand-set", hexpand_set));
190        }
191        if let Some(ref is_focus) = self.is_focus {
192            properties.push(("is-focus", is_focus));
193        }
194        if let Some(ref margin) = self.margin {
195            properties.push(("margin", margin));
196        }
197        if let Some(ref margin_bottom) = self.margin_bottom {
198            properties.push(("margin-bottom", margin_bottom));
199        }
200        if let Some(ref margin_end) = self.margin_end {
201            properties.push(("margin-end", margin_end));
202        }
203        if let Some(ref margin_start) = self.margin_start {
204            properties.push(("margin-start", margin_start));
205        }
206        if let Some(ref margin_top) = self.margin_top {
207            properties.push(("margin-top", margin_top));
208        }
209        if let Some(ref name) = self.name {
210            properties.push(("name", name));
211        }
212        if let Some(ref no_show_all) = self.no_show_all {
213            properties.push(("no-show-all", no_show_all));
214        }
215        if let Some(ref opacity) = self.opacity {
216            properties.push(("opacity", opacity));
217        }
218        if let Some(ref parent) = self.parent {
219            properties.push(("parent", parent));
220        }
221        if let Some(ref receives_default) = self.receives_default {
222            properties.push(("receives-default", receives_default));
223        }
224        if let Some(ref sensitive) = self.sensitive {
225            properties.push(("sensitive", sensitive));
226        }
227        if let Some(ref tooltip_markup) = self.tooltip_markup {
228            properties.push(("tooltip-markup", tooltip_markup));
229        }
230        if let Some(ref tooltip_text) = self.tooltip_text {
231            properties.push(("tooltip-text", tooltip_text));
232        }
233        if let Some(ref valign) = self.valign {
234            properties.push(("valign", valign));
235        }
236        if let Some(ref vexpand) = self.vexpand {
237            properties.push(("vexpand", vexpand));
238        }
239        if let Some(ref vexpand_set) = self.vexpand_set {
240            properties.push(("vexpand-set", vexpand_set));
241        }
242        if let Some(ref visible) = self.visible {
243            properties.push(("visible", visible));
244        }
245        if let Some(ref width_request) = self.width_request {
246            properties.push(("width-request", width_request));
247        }
248        glib::Object::new(EventBox::static_type(), &properties)
249            .expect("object new")
250            .downcast()
251            .expect("downcast")
252    }
253
254    pub fn above_child(mut self, above_child: bool) -> Self {
255        self.above_child = Some(above_child);
256        self
257    }
258
259    pub fn visible_window(mut self, visible_window: bool) -> Self {
260        self.visible_window = Some(visible_window);
261        self
262    }
263
264    pub fn border_width(mut self, border_width: u32) -> Self {
265        self.border_width = Some(border_width);
266        self
267    }
268
269    pub fn child(mut self, child: &Widget) -> Self {
270        self.child = Some(child.clone());
271        self
272    }
273
274    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
275        self.resize_mode = Some(resize_mode);
276        self
277    }
278
279    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
280        self.app_paintable = Some(app_paintable);
281        self
282    }
283
284    pub fn can_default(mut self, can_default: bool) -> Self {
285        self.can_default = Some(can_default);
286        self
287    }
288
289    pub fn can_focus(mut self, can_focus: bool) -> Self {
290        self.can_focus = Some(can_focus);
291        self
292    }
293
294    pub fn events(mut self, events: gdk::EventMask) -> Self {
295        self.events = Some(events);
296        self
297    }
298
299    pub fn expand(mut self, expand: bool) -> Self {
300        self.expand = Some(expand);
301        self
302    }
303
304    #[cfg(any(feature = "v3_20", feature = "dox"))]
305    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
306        self.focus_on_click = Some(focus_on_click);
307        self
308    }
309
310    pub fn halign(mut self, halign: Align) -> Self {
311        self.halign = Some(halign);
312        self
313    }
314
315    pub fn has_default(mut self, has_default: bool) -> Self {
316        self.has_default = Some(has_default);
317        self
318    }
319
320    pub fn has_focus(mut self, has_focus: bool) -> Self {
321        self.has_focus = Some(has_focus);
322        self
323    }
324
325    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
326        self.has_tooltip = Some(has_tooltip);
327        self
328    }
329
330    pub fn height_request(mut self, height_request: i32) -> Self {
331        self.height_request = Some(height_request);
332        self
333    }
334
335    pub fn hexpand(mut self, hexpand: bool) -> Self {
336        self.hexpand = Some(hexpand);
337        self
338    }
339
340    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
341        self.hexpand_set = Some(hexpand_set);
342        self
343    }
344
345    pub fn is_focus(mut self, is_focus: bool) -> Self {
346        self.is_focus = Some(is_focus);
347        self
348    }
349
350    pub fn margin(mut self, margin: i32) -> Self {
351        self.margin = Some(margin);
352        self
353    }
354
355    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
356        self.margin_bottom = Some(margin_bottom);
357        self
358    }
359
360    pub fn margin_end(mut self, margin_end: i32) -> Self {
361        self.margin_end = Some(margin_end);
362        self
363    }
364
365    pub fn margin_start(mut self, margin_start: i32) -> Self {
366        self.margin_start = Some(margin_start);
367        self
368    }
369
370    pub fn margin_top(mut self, margin_top: i32) -> Self {
371        self.margin_top = Some(margin_top);
372        self
373    }
374
375    pub fn name(mut self, name: &str) -> Self {
376        self.name = Some(name.to_string());
377        self
378    }
379
380    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
381        self.no_show_all = Some(no_show_all);
382        self
383    }
384
385    pub fn opacity(mut self, opacity: f64) -> Self {
386        self.opacity = Some(opacity);
387        self
388    }
389
390    pub fn parent(mut self, parent: &Container) -> Self {
391        self.parent = Some(parent.clone());
392        self
393    }
394
395    pub fn receives_default(mut self, receives_default: bool) -> Self {
396        self.receives_default = Some(receives_default);
397        self
398    }
399
400    pub fn sensitive(mut self, sensitive: bool) -> Self {
401        self.sensitive = Some(sensitive);
402        self
403    }
404
405    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
406        self.tooltip_markup = Some(tooltip_markup.to_string());
407        self
408    }
409
410    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
411        self.tooltip_text = Some(tooltip_text.to_string());
412        self
413    }
414
415    pub fn valign(mut self, valign: Align) -> Self {
416        self.valign = Some(valign);
417        self
418    }
419
420    pub fn vexpand(mut self, vexpand: bool) -> Self {
421        self.vexpand = Some(vexpand);
422        self
423    }
424
425    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
426        self.vexpand_set = Some(vexpand_set);
427        self
428    }
429
430    pub fn visible(mut self, visible: bool) -> Self {
431        self.visible = Some(visible);
432        self
433    }
434
435    pub fn width_request(mut self, width_request: i32) -> Self {
436        self.width_request = Some(width_request);
437        self
438    }
439}
440
441pub const NONE_EVENT_BOX: Option<&EventBox> = None;
442
443pub trait EventBoxExt: 'static {
444    fn get_above_child(&self) -> bool;
445
446    fn get_visible_window(&self) -> bool;
447
448    fn set_above_child(&self, above_child: bool);
449
450    fn set_visible_window(&self, visible_window: bool);
451
452    fn connect_property_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
453
454    fn connect_property_visible_window_notify<F: Fn(&Self) + 'static>(
455        &self,
456        f: F,
457    ) -> SignalHandlerId;
458}
459
460impl<O: IsA<EventBox>> EventBoxExt for O {
461    fn get_above_child(&self) -> bool {
462        unsafe {
463            from_glib(gtk_sys::gtk_event_box_get_above_child(
464                self.as_ref().to_glib_none().0,
465            ))
466        }
467    }
468
469    fn get_visible_window(&self) -> bool {
470        unsafe {
471            from_glib(gtk_sys::gtk_event_box_get_visible_window(
472                self.as_ref().to_glib_none().0,
473            ))
474        }
475    }
476
477    fn set_above_child(&self, above_child: bool) {
478        unsafe {
479            gtk_sys::gtk_event_box_set_above_child(
480                self.as_ref().to_glib_none().0,
481                above_child.to_glib(),
482            );
483        }
484    }
485
486    fn set_visible_window(&self, visible_window: bool) {
487        unsafe {
488            gtk_sys::gtk_event_box_set_visible_window(
489                self.as_ref().to_glib_none().0,
490                visible_window.to_glib(),
491            );
492        }
493    }
494
495    fn connect_property_above_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
496        unsafe extern "C" fn notify_above_child_trampoline<P, F: Fn(&P) + 'static>(
497            this: *mut gtk_sys::GtkEventBox,
498            _param_spec: glib_sys::gpointer,
499            f: glib_sys::gpointer,
500        ) where
501            P: IsA<EventBox>,
502        {
503            let f: &F = &*(f as *const F);
504            f(&EventBox::from_glib_borrow(this).unsafe_cast())
505        }
506        unsafe {
507            let f: Box_<F> = Box_::new(f);
508            connect_raw(
509                self.as_ptr() as *mut _,
510                b"notify::above-child\0".as_ptr() as *const _,
511                Some(transmute(notify_above_child_trampoline::<Self, F> as usize)),
512                Box_::into_raw(f),
513            )
514        }
515    }
516
517    fn connect_property_visible_window_notify<F: Fn(&Self) + 'static>(
518        &self,
519        f: F,
520    ) -> SignalHandlerId {
521        unsafe extern "C" fn notify_visible_window_trampoline<P, F: Fn(&P) + 'static>(
522            this: *mut gtk_sys::GtkEventBox,
523            _param_spec: glib_sys::gpointer,
524            f: glib_sys::gpointer,
525        ) where
526            P: IsA<EventBox>,
527        {
528            let f: &F = &*(f as *const F);
529            f(&EventBox::from_glib_borrow(this).unsafe_cast())
530        }
531        unsafe {
532            let f: Box_<F> = Box_::new(f);
533            connect_raw(
534                self.as_ptr() as *mut _,
535                b"notify::visible-window\0".as_ptr() as *const _,
536                Some(transmute(
537                    notify_visible_window_trampoline::<Self, F> as usize,
538                )),
539                Box_::into_raw(f),
540            )
541        }
542    }
543}
544
545impl fmt::Display for EventBox {
546    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
547        write!(f, "EventBox")
548    }
549}