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::Adjustment;
6 use crate::Align;
7 use crate::Buildable;
8 use crate::Container;
9 use crate::Orientable;
10 use crate::Orientation;
11 use crate::Range;
12 use crate::SensitivityType;
13 use crate::Widget;
14 use glib::object::Cast;
15 use glib::object::IsA;
16 use glib::translate::*;
17 use glib::StaticType;
18 use glib::ToValue;
19 use std::fmt;
20 
21 glib::wrapper! {
22     #[doc(alias = "GtkScrollbar")]
23     pub struct Scrollbar(Object<ffi::GtkScrollbar, ffi::GtkScrollbarClass>) @extends Range, Widget, @implements Buildable, Orientable;
24 
25     match fn {
26         type_ => || ffi::gtk_scrollbar_get_type(),
27     }
28 }
29 
30 impl Scrollbar {
31     #[doc(alias = "gtk_scrollbar_new")]
new<P: IsA<Adjustment>>(orientation: Orientation, adjustment: Option<&P>) -> Scrollbar32     pub fn new<P: IsA<Adjustment>>(orientation: Orientation, adjustment: Option<&P>) -> Scrollbar {
33         assert_initialized_main_thread!();
34         unsafe {
35             Widget::from_glib_none(ffi::gtk_scrollbar_new(
36                 orientation.into_glib(),
37                 adjustment.map(|p| p.as_ref()).to_glib_none().0,
38             ))
39             .unsafe_cast()
40         }
41     }
42 
43     // rustdoc-stripper-ignore-next
44     /// Creates a new builder-pattern struct instance to construct [`Scrollbar`] objects.
45     ///
46     /// This method returns an instance of [`ScrollbarBuilder`] which can be used to create [`Scrollbar`] objects.
builder() -> ScrollbarBuilder47     pub fn builder() -> ScrollbarBuilder {
48         ScrollbarBuilder::default()
49     }
50 }
51 
52 #[derive(Clone, Default)]
53 // rustdoc-stripper-ignore-next
54 /// A [builder-pattern] type to construct [`Scrollbar`] objects.
55 ///
56 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
57 pub struct ScrollbarBuilder {
58     adjustment: Option<Adjustment>,
59     fill_level: Option<f64>,
60     inverted: Option<bool>,
61     lower_stepper_sensitivity: Option<SensitivityType>,
62     restrict_to_fill_level: Option<bool>,
63     round_digits: Option<i32>,
64     show_fill_level: Option<bool>,
65     upper_stepper_sensitivity: Option<SensitivityType>,
66     app_paintable: Option<bool>,
67     can_default: Option<bool>,
68     can_focus: Option<bool>,
69     events: Option<gdk::EventMask>,
70     expand: Option<bool>,
71     #[cfg(any(feature = "v3_20", feature = "dox"))]
72     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
73     focus_on_click: Option<bool>,
74     halign: Option<Align>,
75     has_default: Option<bool>,
76     has_focus: Option<bool>,
77     has_tooltip: Option<bool>,
78     height_request: Option<i32>,
79     hexpand: Option<bool>,
80     hexpand_set: Option<bool>,
81     is_focus: Option<bool>,
82     margin: Option<i32>,
83     margin_bottom: Option<i32>,
84     margin_end: Option<i32>,
85     margin_start: Option<i32>,
86     margin_top: Option<i32>,
87     name: Option<String>,
88     no_show_all: Option<bool>,
89     opacity: Option<f64>,
90     parent: Option<Container>,
91     receives_default: Option<bool>,
92     sensitive: Option<bool>,
93     tooltip_markup: Option<String>,
94     tooltip_text: Option<String>,
95     valign: Option<Align>,
96     vexpand: Option<bool>,
97     vexpand_set: Option<bool>,
98     visible: Option<bool>,
99     width_request: Option<i32>,
100     orientation: Option<Orientation>,
101 }
102 
103 impl ScrollbarBuilder {
104     // rustdoc-stripper-ignore-next
105     /// Create a new [`ScrollbarBuilder`].
new() -> Self106     pub fn new() -> Self {
107         Self::default()
108     }
109 
110     // rustdoc-stripper-ignore-next
111     /// Build the [`Scrollbar`].
build(self) -> Scrollbar112     pub fn build(self) -> Scrollbar {
113         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
114         if let Some(ref adjustment) = self.adjustment {
115             properties.push(("adjustment", adjustment));
116         }
117         if let Some(ref fill_level) = self.fill_level {
118             properties.push(("fill-level", fill_level));
119         }
120         if let Some(ref inverted) = self.inverted {
121             properties.push(("inverted", inverted));
122         }
123         if let Some(ref lower_stepper_sensitivity) = self.lower_stepper_sensitivity {
124             properties.push(("lower-stepper-sensitivity", lower_stepper_sensitivity));
125         }
126         if let Some(ref restrict_to_fill_level) = self.restrict_to_fill_level {
127             properties.push(("restrict-to-fill-level", restrict_to_fill_level));
128         }
129         if let Some(ref round_digits) = self.round_digits {
130             properties.push(("round-digits", round_digits));
131         }
132         if let Some(ref show_fill_level) = self.show_fill_level {
133             properties.push(("show-fill-level", show_fill_level));
134         }
135         if let Some(ref upper_stepper_sensitivity) = self.upper_stepper_sensitivity {
136             properties.push(("upper-stepper-sensitivity", upper_stepper_sensitivity));
137         }
138         if let Some(ref app_paintable) = self.app_paintable {
139             properties.push(("app-paintable", app_paintable));
140         }
141         if let Some(ref can_default) = self.can_default {
142             properties.push(("can-default", can_default));
143         }
144         if let Some(ref can_focus) = self.can_focus {
145             properties.push(("can-focus", can_focus));
146         }
147         if let Some(ref events) = self.events {
148             properties.push(("events", events));
149         }
150         if let Some(ref expand) = self.expand {
151             properties.push(("expand", expand));
152         }
153         #[cfg(any(feature = "v3_20", feature = "dox"))]
154         if let Some(ref focus_on_click) = self.focus_on_click {
155             properties.push(("focus-on-click", focus_on_click));
156         }
157         if let Some(ref halign) = self.halign {
158             properties.push(("halign", halign));
159         }
160         if let Some(ref has_default) = self.has_default {
161             properties.push(("has-default", has_default));
162         }
163         if let Some(ref has_focus) = self.has_focus {
164             properties.push(("has-focus", has_focus));
165         }
166         if let Some(ref has_tooltip) = self.has_tooltip {
167             properties.push(("has-tooltip", has_tooltip));
168         }
169         if let Some(ref height_request) = self.height_request {
170             properties.push(("height-request", height_request));
171         }
172         if let Some(ref hexpand) = self.hexpand {
173             properties.push(("hexpand", hexpand));
174         }
175         if let Some(ref hexpand_set) = self.hexpand_set {
176             properties.push(("hexpand-set", hexpand_set));
177         }
178         if let Some(ref is_focus) = self.is_focus {
179             properties.push(("is-focus", is_focus));
180         }
181         if let Some(ref margin) = self.margin {
182             properties.push(("margin", margin));
183         }
184         if let Some(ref margin_bottom) = self.margin_bottom {
185             properties.push(("margin-bottom", margin_bottom));
186         }
187         if let Some(ref margin_end) = self.margin_end {
188             properties.push(("margin-end", margin_end));
189         }
190         if let Some(ref margin_start) = self.margin_start {
191             properties.push(("margin-start", margin_start));
192         }
193         if let Some(ref margin_top) = self.margin_top {
194             properties.push(("margin-top", margin_top));
195         }
196         if let Some(ref name) = self.name {
197             properties.push(("name", name));
198         }
199         if let Some(ref no_show_all) = self.no_show_all {
200             properties.push(("no-show-all", no_show_all));
201         }
202         if let Some(ref opacity) = self.opacity {
203             properties.push(("opacity", opacity));
204         }
205         if let Some(ref parent) = self.parent {
206             properties.push(("parent", parent));
207         }
208         if let Some(ref receives_default) = self.receives_default {
209             properties.push(("receives-default", receives_default));
210         }
211         if let Some(ref sensitive) = self.sensitive {
212             properties.push(("sensitive", sensitive));
213         }
214         if let Some(ref tooltip_markup) = self.tooltip_markup {
215             properties.push(("tooltip-markup", tooltip_markup));
216         }
217         if let Some(ref tooltip_text) = self.tooltip_text {
218             properties.push(("tooltip-text", tooltip_text));
219         }
220         if let Some(ref valign) = self.valign {
221             properties.push(("valign", valign));
222         }
223         if let Some(ref vexpand) = self.vexpand {
224             properties.push(("vexpand", vexpand));
225         }
226         if let Some(ref vexpand_set) = self.vexpand_set {
227             properties.push(("vexpand-set", vexpand_set));
228         }
229         if let Some(ref visible) = self.visible {
230             properties.push(("visible", visible));
231         }
232         if let Some(ref width_request) = self.width_request {
233             properties.push(("width-request", width_request));
234         }
235         if let Some(ref orientation) = self.orientation {
236             properties.push(("orientation", orientation));
237         }
238         glib::Object::new::<Scrollbar>(&properties)
239             .expect("Failed to create an instance of Scrollbar")
240     }
241 
adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self242     pub fn adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self {
243         self.adjustment = Some(adjustment.clone().upcast());
244         self
245     }
246 
fill_level(mut self, fill_level: f64) -> Self247     pub fn fill_level(mut self, fill_level: f64) -> Self {
248         self.fill_level = Some(fill_level);
249         self
250     }
251 
inverted(mut self, inverted: bool) -> Self252     pub fn inverted(mut self, inverted: bool) -> Self {
253         self.inverted = Some(inverted);
254         self
255     }
256 
lower_stepper_sensitivity(mut self, lower_stepper_sensitivity: SensitivityType) -> Self257     pub fn lower_stepper_sensitivity(mut self, lower_stepper_sensitivity: SensitivityType) -> Self {
258         self.lower_stepper_sensitivity = Some(lower_stepper_sensitivity);
259         self
260     }
261 
restrict_to_fill_level(mut self, restrict_to_fill_level: bool) -> Self262     pub fn restrict_to_fill_level(mut self, restrict_to_fill_level: bool) -> Self {
263         self.restrict_to_fill_level = Some(restrict_to_fill_level);
264         self
265     }
266 
round_digits(mut self, round_digits: i32) -> Self267     pub fn round_digits(mut self, round_digits: i32) -> Self {
268         self.round_digits = Some(round_digits);
269         self
270     }
271 
show_fill_level(mut self, show_fill_level: bool) -> Self272     pub fn show_fill_level(mut self, show_fill_level: bool) -> Self {
273         self.show_fill_level = Some(show_fill_level);
274         self
275     }
276 
upper_stepper_sensitivity(mut self, upper_stepper_sensitivity: SensitivityType) -> Self277     pub fn upper_stepper_sensitivity(mut self, upper_stepper_sensitivity: SensitivityType) -> Self {
278         self.upper_stepper_sensitivity = Some(upper_stepper_sensitivity);
279         self
280     }
281 
app_paintable(mut self, app_paintable: bool) -> Self282     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
283         self.app_paintable = Some(app_paintable);
284         self
285     }
286 
can_default(mut self, can_default: bool) -> Self287     pub fn can_default(mut self, can_default: bool) -> Self {
288         self.can_default = Some(can_default);
289         self
290     }
291 
can_focus(mut self, can_focus: bool) -> Self292     pub fn can_focus(mut self, can_focus: bool) -> Self {
293         self.can_focus = Some(can_focus);
294         self
295     }
296 
events(mut self, events: gdk::EventMask) -> Self297     pub fn events(mut self, events: gdk::EventMask) -> Self {
298         self.events = Some(events);
299         self
300     }
301 
expand(mut self, expand: bool) -> Self302     pub fn expand(mut self, expand: bool) -> Self {
303         self.expand = Some(expand);
304         self
305     }
306 
307     #[cfg(any(feature = "v3_20", feature = "dox"))]
308     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self309     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
310         self.focus_on_click = Some(focus_on_click);
311         self
312     }
313 
halign(mut self, halign: Align) -> Self314     pub fn halign(mut self, halign: Align) -> Self {
315         self.halign = Some(halign);
316         self
317     }
318 
has_default(mut self, has_default: bool) -> Self319     pub fn has_default(mut self, has_default: bool) -> Self {
320         self.has_default = Some(has_default);
321         self
322     }
323 
has_focus(mut self, has_focus: bool) -> Self324     pub fn has_focus(mut self, has_focus: bool) -> Self {
325         self.has_focus = Some(has_focus);
326         self
327     }
328 
has_tooltip(mut self, has_tooltip: bool) -> Self329     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
330         self.has_tooltip = Some(has_tooltip);
331         self
332     }
333 
height_request(mut self, height_request: i32) -> Self334     pub fn height_request(mut self, height_request: i32) -> Self {
335         self.height_request = Some(height_request);
336         self
337     }
338 
hexpand(mut self, hexpand: bool) -> Self339     pub fn hexpand(mut self, hexpand: bool) -> Self {
340         self.hexpand = Some(hexpand);
341         self
342     }
343 
hexpand_set(mut self, hexpand_set: bool) -> Self344     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
345         self.hexpand_set = Some(hexpand_set);
346         self
347     }
348 
is_focus(mut self, is_focus: bool) -> Self349     pub fn is_focus(mut self, is_focus: bool) -> Self {
350         self.is_focus = Some(is_focus);
351         self
352     }
353 
margin(mut self, margin: i32) -> Self354     pub fn margin(mut self, margin: i32) -> Self {
355         self.margin = Some(margin);
356         self
357     }
358 
margin_bottom(mut self, margin_bottom: i32) -> Self359     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
360         self.margin_bottom = Some(margin_bottom);
361         self
362     }
363 
margin_end(mut self, margin_end: i32) -> Self364     pub fn margin_end(mut self, margin_end: i32) -> Self {
365         self.margin_end = Some(margin_end);
366         self
367     }
368 
margin_start(mut self, margin_start: i32) -> Self369     pub fn margin_start(mut self, margin_start: i32) -> Self {
370         self.margin_start = Some(margin_start);
371         self
372     }
373 
margin_top(mut self, margin_top: i32) -> Self374     pub fn margin_top(mut self, margin_top: i32) -> Self {
375         self.margin_top = Some(margin_top);
376         self
377     }
378 
name(mut self, name: &str) -> Self379     pub fn name(mut self, name: &str) -> Self {
380         self.name = Some(name.to_string());
381         self
382     }
383 
no_show_all(mut self, no_show_all: bool) -> Self384     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
385         self.no_show_all = Some(no_show_all);
386         self
387     }
388 
opacity(mut self, opacity: f64) -> Self389     pub fn opacity(mut self, opacity: f64) -> Self {
390         self.opacity = Some(opacity);
391         self
392     }
393 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self394     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
395         self.parent = Some(parent.clone().upcast());
396         self
397     }
398 
receives_default(mut self, receives_default: bool) -> Self399     pub fn receives_default(mut self, receives_default: bool) -> Self {
400         self.receives_default = Some(receives_default);
401         self
402     }
403 
sensitive(mut self, sensitive: bool) -> Self404     pub fn sensitive(mut self, sensitive: bool) -> Self {
405         self.sensitive = Some(sensitive);
406         self
407     }
408 
tooltip_markup(mut self, tooltip_markup: &str) -> Self409     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
410         self.tooltip_markup = Some(tooltip_markup.to_string());
411         self
412     }
413 
tooltip_text(mut self, tooltip_text: &str) -> Self414     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
415         self.tooltip_text = Some(tooltip_text.to_string());
416         self
417     }
418 
valign(mut self, valign: Align) -> Self419     pub fn valign(mut self, valign: Align) -> Self {
420         self.valign = Some(valign);
421         self
422     }
423 
vexpand(mut self, vexpand: bool) -> Self424     pub fn vexpand(mut self, vexpand: bool) -> Self {
425         self.vexpand = Some(vexpand);
426         self
427     }
428 
vexpand_set(mut self, vexpand_set: bool) -> Self429     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
430         self.vexpand_set = Some(vexpand_set);
431         self
432     }
433 
visible(mut self, visible: bool) -> Self434     pub fn visible(mut self, visible: bool) -> Self {
435         self.visible = Some(visible);
436         self
437     }
438 
width_request(mut self, width_request: i32) -> Self439     pub fn width_request(mut self, width_request: i32) -> Self {
440         self.width_request = Some(width_request);
441         self
442     }
443 
orientation(mut self, orientation: Orientation) -> Self444     pub fn orientation(mut self, orientation: Orientation) -> Self {
445         self.orientation = Some(orientation);
446         self
447     }
448 }
449 
450 pub const NONE_SCROLLBAR: Option<&Scrollbar> = None;
451 
452 impl fmt::Display for Scrollbar {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result453     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
454         f.write_str("Scrollbar")
455     }
456 }
457