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