gtk/auto/
scrollbar.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::translate::*;
9use glib::StaticType;
10use glib::ToValue;
11use gtk_sys;
12use std::fmt;
13use Adjustment;
14use Align;
15use Buildable;
16use Container;
17use Orientable;
18use Orientation;
19use Range;
20use SensitivityType;
21use Widget;
22
23glib_wrapper! {
24    pub struct Scrollbar(Object<gtk_sys::GtkScrollbar, gtk_sys::GtkScrollbarClass, ScrollbarClass>) @extends Range, Widget, @implements Buildable, Orientable;
25
26    match fn {
27        get_type => || gtk_sys::gtk_scrollbar_get_type(),
28    }
29}
30
31impl Scrollbar {
32    pub fn new<P: IsA<Adjustment>>(orientation: Orientation, adjustment: Option<&P>) -> Scrollbar {
33        assert_initialized_main_thread!();
34        unsafe {
35            Widget::from_glib_none(gtk_sys::gtk_scrollbar_new(
36                orientation.to_glib(),
37                adjustment.map(|p| p.as_ref()).to_glib_none().0,
38            ))
39            .unsafe_cast()
40        }
41    }
42}
43
44pub struct ScrollbarBuilder {
45    adjustment: Option<Adjustment>,
46    fill_level: Option<f64>,
47    inverted: Option<bool>,
48    lower_stepper_sensitivity: Option<SensitivityType>,
49    restrict_to_fill_level: Option<bool>,
50    round_digits: Option<i32>,
51    show_fill_level: Option<bool>,
52    upper_stepper_sensitivity: Option<SensitivityType>,
53    app_paintable: Option<bool>,
54    can_default: Option<bool>,
55    can_focus: Option<bool>,
56    events: Option<gdk::EventMask>,
57    expand: Option<bool>,
58    #[cfg(any(feature = "v3_20", feature = "dox"))]
59    focus_on_click: Option<bool>,
60    halign: Option<Align>,
61    has_default: Option<bool>,
62    has_focus: Option<bool>,
63    has_tooltip: Option<bool>,
64    height_request: Option<i32>,
65    hexpand: Option<bool>,
66    hexpand_set: Option<bool>,
67    is_focus: Option<bool>,
68    margin: Option<i32>,
69    margin_bottom: Option<i32>,
70    margin_end: Option<i32>,
71    margin_start: Option<i32>,
72    margin_top: Option<i32>,
73    name: Option<String>,
74    no_show_all: Option<bool>,
75    opacity: Option<f64>,
76    parent: Option<Container>,
77    receives_default: Option<bool>,
78    sensitive: Option<bool>,
79    //style: /*Unknown type*/,
80    tooltip_markup: Option<String>,
81    tooltip_text: Option<String>,
82    valign: Option<Align>,
83    vexpand: Option<bool>,
84    vexpand_set: Option<bool>,
85    visible: Option<bool>,
86    width_request: Option<i32>,
87}
88
89impl ScrollbarBuilder {
90    pub fn new() -> Self {
91        Self {
92            adjustment: None,
93            fill_level: None,
94            inverted: None,
95            lower_stepper_sensitivity: None,
96            restrict_to_fill_level: None,
97            round_digits: None,
98            show_fill_level: None,
99            upper_stepper_sensitivity: None,
100            app_paintable: None,
101            can_default: None,
102            can_focus: None,
103            events: None,
104            expand: None,
105            #[cfg(any(feature = "v3_20", feature = "dox"))]
106            focus_on_click: None,
107            halign: None,
108            has_default: None,
109            has_focus: None,
110            has_tooltip: None,
111            height_request: None,
112            hexpand: None,
113            hexpand_set: None,
114            is_focus: None,
115            margin: None,
116            margin_bottom: None,
117            margin_end: None,
118            margin_start: None,
119            margin_top: None,
120            name: None,
121            no_show_all: None,
122            opacity: None,
123            parent: None,
124            receives_default: None,
125            sensitive: None,
126            tooltip_markup: None,
127            tooltip_text: None,
128            valign: None,
129            vexpand: None,
130            vexpand_set: None,
131            visible: None,
132            width_request: None,
133        }
134    }
135
136    pub fn build(self) -> Scrollbar {
137        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
138        if let Some(ref adjustment) = self.adjustment {
139            properties.push(("adjustment", adjustment));
140        }
141        if let Some(ref fill_level) = self.fill_level {
142            properties.push(("fill-level", fill_level));
143        }
144        if let Some(ref inverted) = self.inverted {
145            properties.push(("inverted", inverted));
146        }
147        if let Some(ref lower_stepper_sensitivity) = self.lower_stepper_sensitivity {
148            properties.push(("lower-stepper-sensitivity", lower_stepper_sensitivity));
149        }
150        if let Some(ref restrict_to_fill_level) = self.restrict_to_fill_level {
151            properties.push(("restrict-to-fill-level", restrict_to_fill_level));
152        }
153        if let Some(ref round_digits) = self.round_digits {
154            properties.push(("round-digits", round_digits));
155        }
156        if let Some(ref show_fill_level) = self.show_fill_level {
157            properties.push(("show-fill-level", show_fill_level));
158        }
159        if let Some(ref upper_stepper_sensitivity) = self.upper_stepper_sensitivity {
160            properties.push(("upper-stepper-sensitivity", upper_stepper_sensitivity));
161        }
162        if let Some(ref app_paintable) = self.app_paintable {
163            properties.push(("app-paintable", app_paintable));
164        }
165        if let Some(ref can_default) = self.can_default {
166            properties.push(("can-default", can_default));
167        }
168        if let Some(ref can_focus) = self.can_focus {
169            properties.push(("can-focus", can_focus));
170        }
171        if let Some(ref events) = self.events {
172            properties.push(("events", events));
173        }
174        if let Some(ref expand) = self.expand {
175            properties.push(("expand", expand));
176        }
177        #[cfg(any(feature = "v3_20", feature = "dox"))]
178        {
179            if let Some(ref focus_on_click) = self.focus_on_click {
180                properties.push(("focus-on-click", focus_on_click));
181            }
182        }
183        if let Some(ref halign) = self.halign {
184            properties.push(("halign", halign));
185        }
186        if let Some(ref has_default) = self.has_default {
187            properties.push(("has-default", has_default));
188        }
189        if let Some(ref has_focus) = self.has_focus {
190            properties.push(("has-focus", has_focus));
191        }
192        if let Some(ref has_tooltip) = self.has_tooltip {
193            properties.push(("has-tooltip", has_tooltip));
194        }
195        if let Some(ref height_request) = self.height_request {
196            properties.push(("height-request", height_request));
197        }
198        if let Some(ref hexpand) = self.hexpand {
199            properties.push(("hexpand", hexpand));
200        }
201        if let Some(ref hexpand_set) = self.hexpand_set {
202            properties.push(("hexpand-set", hexpand_set));
203        }
204        if let Some(ref is_focus) = self.is_focus {
205            properties.push(("is-focus", is_focus));
206        }
207        if let Some(ref margin) = self.margin {
208            properties.push(("margin", margin));
209        }
210        if let Some(ref margin_bottom) = self.margin_bottom {
211            properties.push(("margin-bottom", margin_bottom));
212        }
213        if let Some(ref margin_end) = self.margin_end {
214            properties.push(("margin-end", margin_end));
215        }
216        if let Some(ref margin_start) = self.margin_start {
217            properties.push(("margin-start", margin_start));
218        }
219        if let Some(ref margin_top) = self.margin_top {
220            properties.push(("margin-top", margin_top));
221        }
222        if let Some(ref name) = self.name {
223            properties.push(("name", name));
224        }
225        if let Some(ref no_show_all) = self.no_show_all {
226            properties.push(("no-show-all", no_show_all));
227        }
228        if let Some(ref opacity) = self.opacity {
229            properties.push(("opacity", opacity));
230        }
231        if let Some(ref parent) = self.parent {
232            properties.push(("parent", parent));
233        }
234        if let Some(ref receives_default) = self.receives_default {
235            properties.push(("receives-default", receives_default));
236        }
237        if let Some(ref sensitive) = self.sensitive {
238            properties.push(("sensitive", sensitive));
239        }
240        if let Some(ref tooltip_markup) = self.tooltip_markup {
241            properties.push(("tooltip-markup", tooltip_markup));
242        }
243        if let Some(ref tooltip_text) = self.tooltip_text {
244            properties.push(("tooltip-text", tooltip_text));
245        }
246        if let Some(ref valign) = self.valign {
247            properties.push(("valign", valign));
248        }
249        if let Some(ref vexpand) = self.vexpand {
250            properties.push(("vexpand", vexpand));
251        }
252        if let Some(ref vexpand_set) = self.vexpand_set {
253            properties.push(("vexpand-set", vexpand_set));
254        }
255        if let Some(ref visible) = self.visible {
256            properties.push(("visible", visible));
257        }
258        if let Some(ref width_request) = self.width_request {
259            properties.push(("width-request", width_request));
260        }
261        glib::Object::new(Scrollbar::static_type(), &properties)
262            .expect("object new")
263            .downcast()
264            .expect("downcast")
265    }
266
267    pub fn adjustment(mut self, adjustment: &Adjustment) -> Self {
268        self.adjustment = Some(adjustment.clone());
269        self
270    }
271
272    pub fn fill_level(mut self, fill_level: f64) -> Self {
273        self.fill_level = Some(fill_level);
274        self
275    }
276
277    pub fn inverted(mut self, inverted: bool) -> Self {
278        self.inverted = Some(inverted);
279        self
280    }
281
282    pub fn lower_stepper_sensitivity(mut self, lower_stepper_sensitivity: SensitivityType) -> Self {
283        self.lower_stepper_sensitivity = Some(lower_stepper_sensitivity);
284        self
285    }
286
287    pub fn restrict_to_fill_level(mut self, restrict_to_fill_level: bool) -> Self {
288        self.restrict_to_fill_level = Some(restrict_to_fill_level);
289        self
290    }
291
292    pub fn round_digits(mut self, round_digits: i32) -> Self {
293        self.round_digits = Some(round_digits);
294        self
295    }
296
297    pub fn show_fill_level(mut self, show_fill_level: bool) -> Self {
298        self.show_fill_level = Some(show_fill_level);
299        self
300    }
301
302    pub fn upper_stepper_sensitivity(mut self, upper_stepper_sensitivity: SensitivityType) -> Self {
303        self.upper_stepper_sensitivity = Some(upper_stepper_sensitivity);
304        self
305    }
306
307    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
308        self.app_paintable = Some(app_paintable);
309        self
310    }
311
312    pub fn can_default(mut self, can_default: bool) -> Self {
313        self.can_default = Some(can_default);
314        self
315    }
316
317    pub fn can_focus(mut self, can_focus: bool) -> Self {
318        self.can_focus = Some(can_focus);
319        self
320    }
321
322    pub fn events(mut self, events: gdk::EventMask) -> Self {
323        self.events = Some(events);
324        self
325    }
326
327    pub fn expand(mut self, expand: bool) -> Self {
328        self.expand = Some(expand);
329        self
330    }
331
332    #[cfg(any(feature = "v3_20", feature = "dox"))]
333    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
334        self.focus_on_click = Some(focus_on_click);
335        self
336    }
337
338    pub fn halign(mut self, halign: Align) -> Self {
339        self.halign = Some(halign);
340        self
341    }
342
343    pub fn has_default(mut self, has_default: bool) -> Self {
344        self.has_default = Some(has_default);
345        self
346    }
347
348    pub fn has_focus(mut self, has_focus: bool) -> Self {
349        self.has_focus = Some(has_focus);
350        self
351    }
352
353    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
354        self.has_tooltip = Some(has_tooltip);
355        self
356    }
357
358    pub fn height_request(mut self, height_request: i32) -> Self {
359        self.height_request = Some(height_request);
360        self
361    }
362
363    pub fn hexpand(mut self, hexpand: bool) -> Self {
364        self.hexpand = Some(hexpand);
365        self
366    }
367
368    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
369        self.hexpand_set = Some(hexpand_set);
370        self
371    }
372
373    pub fn is_focus(mut self, is_focus: bool) -> Self {
374        self.is_focus = Some(is_focus);
375        self
376    }
377
378    pub fn margin(mut self, margin: i32) -> Self {
379        self.margin = Some(margin);
380        self
381    }
382
383    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
384        self.margin_bottom = Some(margin_bottom);
385        self
386    }
387
388    pub fn margin_end(mut self, margin_end: i32) -> Self {
389        self.margin_end = Some(margin_end);
390        self
391    }
392
393    pub fn margin_start(mut self, margin_start: i32) -> Self {
394        self.margin_start = Some(margin_start);
395        self
396    }
397
398    pub fn margin_top(mut self, margin_top: i32) -> Self {
399        self.margin_top = Some(margin_top);
400        self
401    }
402
403    pub fn name(mut self, name: &str) -> Self {
404        self.name = Some(name.to_string());
405        self
406    }
407
408    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
409        self.no_show_all = Some(no_show_all);
410        self
411    }
412
413    pub fn opacity(mut self, opacity: f64) -> Self {
414        self.opacity = Some(opacity);
415        self
416    }
417
418    pub fn parent(mut self, parent: &Container) -> Self {
419        self.parent = Some(parent.clone());
420        self
421    }
422
423    pub fn receives_default(mut self, receives_default: bool) -> Self {
424        self.receives_default = Some(receives_default);
425        self
426    }
427
428    pub fn sensitive(mut self, sensitive: bool) -> Self {
429        self.sensitive = Some(sensitive);
430        self
431    }
432
433    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
434        self.tooltip_markup = Some(tooltip_markup.to_string());
435        self
436    }
437
438    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
439        self.tooltip_text = Some(tooltip_text.to_string());
440        self
441    }
442
443    pub fn valign(mut self, valign: Align) -> Self {
444        self.valign = Some(valign);
445        self
446    }
447
448    pub fn vexpand(mut self, vexpand: bool) -> Self {
449        self.vexpand = Some(vexpand);
450        self
451    }
452
453    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
454        self.vexpand_set = Some(vexpand_set);
455        self
456    }
457
458    pub fn visible(mut self, visible: bool) -> Self {
459        self.visible = Some(visible);
460        self
461    }
462
463    pub fn width_request(mut self, width_request: i32) -> Self {
464        self.width_request = Some(width_request);
465        self
466    }
467}
468
469pub const NONE_SCROLLBAR: Option<&Scrollbar> = None;
470
471impl fmt::Display for Scrollbar {
472    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
473        write!(f, "Scrollbar")
474    }
475}