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 crate::{
6    Adjustment, Align, Buildable, Container, Orientable, Orientation, Range, SensitivityType,
7    Widget,
8};
9use glib::{prelude::*, translate::*};
10use std::fmt;
11
12glib::wrapper! {
13    #[doc(alias = "GtkScrollbar")]
14    pub struct Scrollbar(Object<ffi::GtkScrollbar, ffi::GtkScrollbarClass>) @extends Range, Widget, @implements Buildable, Orientable;
15
16    match fn {
17        type_ => || ffi::gtk_scrollbar_get_type(),
18    }
19}
20
21impl Scrollbar {
22    pub const NONE: Option<&'static Scrollbar> = None;
23
24    #[doc(alias = "gtk_scrollbar_new")]
25    pub fn new(orientation: Orientation, adjustment: Option<&impl IsA<Adjustment>>) -> Scrollbar {
26        assert_initialized_main_thread!();
27        unsafe {
28            Widget::from_glib_none(ffi::gtk_scrollbar_new(
29                orientation.into_glib(),
30                adjustment.map(|p| p.as_ref()).to_glib_none().0,
31            ))
32            .unsafe_cast()
33        }
34    }
35
36    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`Scrollbar`] objects.
38    ///
39    /// This method returns an instance of [`ScrollbarBuilder`](crate::builders::ScrollbarBuilder) which can be used to create [`Scrollbar`] objects.
40    pub fn builder() -> ScrollbarBuilder {
41        ScrollbarBuilder::new()
42    }
43}
44
45impl Default for Scrollbar {
46    fn default() -> Self {
47        glib::object::Object::new::<Self>()
48    }
49}
50
51// rustdoc-stripper-ignore-next
52/// A [builder-pattern] type to construct [`Scrollbar`] objects.
53///
54/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
55#[must_use = "The builder must be built to be used"]
56pub struct ScrollbarBuilder {
57    builder: glib::object::ObjectBuilder<'static, Scrollbar>,
58}
59
60impl ScrollbarBuilder {
61    fn new() -> Self {
62        Self {
63            builder: glib::object::Object::builder(),
64        }
65    }
66
67    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
68        Self {
69            builder: self
70                .builder
71                .property("adjustment", adjustment.clone().upcast()),
72        }
73    }
74
75    pub fn fill_level(self, fill_level: f64) -> Self {
76        Self {
77            builder: self.builder.property("fill-level", fill_level),
78        }
79    }
80
81    pub fn inverted(self, inverted: bool) -> Self {
82        Self {
83            builder: self.builder.property("inverted", inverted),
84        }
85    }
86
87    pub fn lower_stepper_sensitivity(self, lower_stepper_sensitivity: SensitivityType) -> Self {
88        Self {
89            builder: self
90                .builder
91                .property("lower-stepper-sensitivity", lower_stepper_sensitivity),
92        }
93    }
94
95    pub fn restrict_to_fill_level(self, restrict_to_fill_level: bool) -> Self {
96        Self {
97            builder: self
98                .builder
99                .property("restrict-to-fill-level", restrict_to_fill_level),
100        }
101    }
102
103    pub fn round_digits(self, round_digits: i32) -> Self {
104        Self {
105            builder: self.builder.property("round-digits", round_digits),
106        }
107    }
108
109    pub fn show_fill_level(self, show_fill_level: bool) -> Self {
110        Self {
111            builder: self.builder.property("show-fill-level", show_fill_level),
112        }
113    }
114
115    pub fn upper_stepper_sensitivity(self, upper_stepper_sensitivity: SensitivityType) -> Self {
116        Self {
117            builder: self
118                .builder
119                .property("upper-stepper-sensitivity", upper_stepper_sensitivity),
120        }
121    }
122
123    pub fn app_paintable(self, app_paintable: bool) -> Self {
124        Self {
125            builder: self.builder.property("app-paintable", app_paintable),
126        }
127    }
128
129    pub fn can_default(self, can_default: bool) -> Self {
130        Self {
131            builder: self.builder.property("can-default", can_default),
132        }
133    }
134
135    pub fn can_focus(self, can_focus: bool) -> Self {
136        Self {
137            builder: self.builder.property("can-focus", can_focus),
138        }
139    }
140
141    pub fn events(self, events: gdk::EventMask) -> Self {
142        Self {
143            builder: self.builder.property("events", events),
144        }
145    }
146
147    pub fn expand(self, expand: bool) -> Self {
148        Self {
149            builder: self.builder.property("expand", expand),
150        }
151    }
152
153    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
154        Self {
155            builder: self.builder.property("focus-on-click", focus_on_click),
156        }
157    }
158
159    pub fn halign(self, halign: Align) -> Self {
160        Self {
161            builder: self.builder.property("halign", halign),
162        }
163    }
164
165    pub fn has_default(self, has_default: bool) -> Self {
166        Self {
167            builder: self.builder.property("has-default", has_default),
168        }
169    }
170
171    pub fn has_focus(self, has_focus: bool) -> Self {
172        Self {
173            builder: self.builder.property("has-focus", has_focus),
174        }
175    }
176
177    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
178        Self {
179            builder: self.builder.property("has-tooltip", has_tooltip),
180        }
181    }
182
183    pub fn height_request(self, height_request: i32) -> Self {
184        Self {
185            builder: self.builder.property("height-request", height_request),
186        }
187    }
188
189    pub fn hexpand(self, hexpand: bool) -> Self {
190        Self {
191            builder: self.builder.property("hexpand", hexpand),
192        }
193    }
194
195    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
196        Self {
197            builder: self.builder.property("hexpand-set", hexpand_set),
198        }
199    }
200
201    pub fn is_focus(self, is_focus: bool) -> Self {
202        Self {
203            builder: self.builder.property("is-focus", is_focus),
204        }
205    }
206
207    pub fn margin(self, margin: i32) -> Self {
208        Self {
209            builder: self.builder.property("margin", margin),
210        }
211    }
212
213    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
214        Self {
215            builder: self.builder.property("margin-bottom", margin_bottom),
216        }
217    }
218
219    pub fn margin_end(self, margin_end: i32) -> Self {
220        Self {
221            builder: self.builder.property("margin-end", margin_end),
222        }
223    }
224
225    pub fn margin_start(self, margin_start: i32) -> Self {
226        Self {
227            builder: self.builder.property("margin-start", margin_start),
228        }
229    }
230
231    pub fn margin_top(self, margin_top: i32) -> Self {
232        Self {
233            builder: self.builder.property("margin-top", margin_top),
234        }
235    }
236
237    pub fn name(self, name: impl Into<glib::GString>) -> Self {
238        Self {
239            builder: self.builder.property("name", name.into()),
240        }
241    }
242
243    pub fn no_show_all(self, no_show_all: bool) -> Self {
244        Self {
245            builder: self.builder.property("no-show-all", no_show_all),
246        }
247    }
248
249    pub fn opacity(self, opacity: f64) -> Self {
250        Self {
251            builder: self.builder.property("opacity", opacity),
252        }
253    }
254
255    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
256        Self {
257            builder: self.builder.property("parent", parent.clone().upcast()),
258        }
259    }
260
261    pub fn receives_default(self, receives_default: bool) -> Self {
262        Self {
263            builder: self.builder.property("receives-default", receives_default),
264        }
265    }
266
267    pub fn sensitive(self, sensitive: bool) -> Self {
268        Self {
269            builder: self.builder.property("sensitive", sensitive),
270        }
271    }
272
273    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
274        Self {
275            builder: self
276                .builder
277                .property("tooltip-markup", tooltip_markup.into()),
278        }
279    }
280
281    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
282        Self {
283            builder: self.builder.property("tooltip-text", tooltip_text.into()),
284        }
285    }
286
287    pub fn valign(self, valign: Align) -> Self {
288        Self {
289            builder: self.builder.property("valign", valign),
290        }
291    }
292
293    pub fn vexpand(self, vexpand: bool) -> Self {
294        Self {
295            builder: self.builder.property("vexpand", vexpand),
296        }
297    }
298
299    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
300        Self {
301            builder: self.builder.property("vexpand-set", vexpand_set),
302        }
303    }
304
305    pub fn visible(self, visible: bool) -> Self {
306        Self {
307            builder: self.builder.property("visible", visible),
308        }
309    }
310
311    pub fn width_request(self, width_request: i32) -> Self {
312        Self {
313            builder: self.builder.property("width-request", width_request),
314        }
315    }
316
317    pub fn orientation(self, orientation: Orientation) -> Self {
318        Self {
319            builder: self.builder.property("orientation", orientation),
320        }
321    }
322
323    // rustdoc-stripper-ignore-next
324    /// Build the [`Scrollbar`].
325    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
326    pub fn build(self) -> Scrollbar {
327        self.builder.build()
328    }
329}
330
331impl fmt::Display for Scrollbar {
332    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
333        f.write_str("Scrollbar")
334    }
335}