gtk4/auto/
list_box_row.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    ffi, Accessible, AccessibleRole, Actionable, Align, Buildable, ConstraintTarget, LayoutManager,
7    Overflow, Widget,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "GtkListBoxRow")]
19    pub struct ListBoxRow(Object<ffi::GtkListBoxRow, ffi::GtkListBoxRowClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable;
20
21    match fn {
22        type_ => || ffi::gtk_list_box_row_get_type(),
23    }
24}
25
26impl ListBoxRow {
27    pub const NONE: Option<&'static ListBoxRow> = None;
28
29    #[doc(alias = "gtk_list_box_row_new")]
30    pub fn new() -> ListBoxRow {
31        assert_initialized_main_thread!();
32        unsafe { Widget::from_glib_none(ffi::gtk_list_box_row_new()).unsafe_cast() }
33    }
34
35    // rustdoc-stripper-ignore-next
36    /// Creates a new builder-pattern struct instance to construct [`ListBoxRow`] objects.
37    ///
38    /// This method returns an instance of [`ListBoxRowBuilder`](crate::builders::ListBoxRowBuilder) which can be used to create [`ListBoxRow`] objects.
39    pub fn builder() -> ListBoxRowBuilder {
40        ListBoxRowBuilder::new()
41    }
42}
43
44impl Default for ListBoxRow {
45    fn default() -> Self {
46        Self::new()
47    }
48}
49
50// rustdoc-stripper-ignore-next
51/// A [builder-pattern] type to construct [`ListBoxRow`] objects.
52///
53/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
54#[must_use = "The builder must be built to be used"]
55pub struct ListBoxRowBuilder {
56    builder: glib::object::ObjectBuilder<'static, ListBoxRow>,
57}
58
59impl ListBoxRowBuilder {
60    fn new() -> Self {
61        Self {
62            builder: glib::object::Object::builder(),
63        }
64    }
65
66    pub fn activatable(self, activatable: bool) -> Self {
67        Self {
68            builder: self.builder.property("activatable", activatable),
69        }
70    }
71
72    pub fn child(self, child: &impl IsA<Widget>) -> Self {
73        Self {
74            builder: self.builder.property("child", child.clone().upcast()),
75        }
76    }
77
78    pub fn selectable(self, selectable: bool) -> Self {
79        Self {
80            builder: self.builder.property("selectable", selectable),
81        }
82    }
83
84    pub fn can_focus(self, can_focus: bool) -> Self {
85        Self {
86            builder: self.builder.property("can-focus", can_focus),
87        }
88    }
89
90    pub fn can_target(self, can_target: bool) -> Self {
91        Self {
92            builder: self.builder.property("can-target", can_target),
93        }
94    }
95
96    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
97        Self {
98            builder: self.builder.property("css-classes", css_classes.into()),
99        }
100    }
101
102    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
103        Self {
104            builder: self.builder.property("css-name", css_name.into()),
105        }
106    }
107
108    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
109        Self {
110            builder: self.builder.property("cursor", cursor.clone()),
111        }
112    }
113
114    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
115        Self {
116            builder: self.builder.property("focus-on-click", focus_on_click),
117        }
118    }
119
120    pub fn focusable(self, focusable: bool) -> Self {
121        Self {
122            builder: self.builder.property("focusable", focusable),
123        }
124    }
125
126    pub fn halign(self, halign: Align) -> Self {
127        Self {
128            builder: self.builder.property("halign", halign),
129        }
130    }
131
132    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
133        Self {
134            builder: self.builder.property("has-tooltip", has_tooltip),
135        }
136    }
137
138    pub fn height_request(self, height_request: i32) -> Self {
139        Self {
140            builder: self.builder.property("height-request", height_request),
141        }
142    }
143
144    pub fn hexpand(self, hexpand: bool) -> Self {
145        Self {
146            builder: self.builder.property("hexpand", hexpand),
147        }
148    }
149
150    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
151        Self {
152            builder: self.builder.property("hexpand-set", hexpand_set),
153        }
154    }
155
156    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
157        Self {
158            builder: self
159                .builder
160                .property("layout-manager", layout_manager.clone().upcast()),
161        }
162    }
163
164    #[cfg(feature = "v4_18")]
165    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
166    pub fn limit_events(self, limit_events: bool) -> Self {
167        Self {
168            builder: self.builder.property("limit-events", limit_events),
169        }
170    }
171
172    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
173        Self {
174            builder: self.builder.property("margin-bottom", margin_bottom),
175        }
176    }
177
178    pub fn margin_end(self, margin_end: i32) -> Self {
179        Self {
180            builder: self.builder.property("margin-end", margin_end),
181        }
182    }
183
184    pub fn margin_start(self, margin_start: i32) -> Self {
185        Self {
186            builder: self.builder.property("margin-start", margin_start),
187        }
188    }
189
190    pub fn margin_top(self, margin_top: i32) -> Self {
191        Self {
192            builder: self.builder.property("margin-top", margin_top),
193        }
194    }
195
196    pub fn name(self, name: impl Into<glib::GString>) -> Self {
197        Self {
198            builder: self.builder.property("name", name.into()),
199        }
200    }
201
202    pub fn opacity(self, opacity: f64) -> Self {
203        Self {
204            builder: self.builder.property("opacity", opacity),
205        }
206    }
207
208    pub fn overflow(self, overflow: Overflow) -> Self {
209        Self {
210            builder: self.builder.property("overflow", overflow),
211        }
212    }
213
214    pub fn receives_default(self, receives_default: bool) -> Self {
215        Self {
216            builder: self.builder.property("receives-default", receives_default),
217        }
218    }
219
220    pub fn sensitive(self, sensitive: bool) -> Self {
221        Self {
222            builder: self.builder.property("sensitive", sensitive),
223        }
224    }
225
226    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
227        Self {
228            builder: self
229                .builder
230                .property("tooltip-markup", tooltip_markup.into()),
231        }
232    }
233
234    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
235        Self {
236            builder: self.builder.property("tooltip-text", tooltip_text.into()),
237        }
238    }
239
240    pub fn valign(self, valign: Align) -> Self {
241        Self {
242            builder: self.builder.property("valign", valign),
243        }
244    }
245
246    pub fn vexpand(self, vexpand: bool) -> Self {
247        Self {
248            builder: self.builder.property("vexpand", vexpand),
249        }
250    }
251
252    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
253        Self {
254            builder: self.builder.property("vexpand-set", vexpand_set),
255        }
256    }
257
258    pub fn visible(self, visible: bool) -> Self {
259        Self {
260            builder: self.builder.property("visible", visible),
261        }
262    }
263
264    pub fn width_request(self, width_request: i32) -> Self {
265        Self {
266            builder: self.builder.property("width-request", width_request),
267        }
268    }
269
270    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
271        Self {
272            builder: self.builder.property("accessible-role", accessible_role),
273        }
274    }
275
276    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
277        Self {
278            builder: self.builder.property("action-name", action_name.into()),
279        }
280    }
281
282    pub fn action_target(self, action_target: &glib::Variant) -> Self {
283        Self {
284            builder: self
285                .builder
286                .property("action-target", action_target.clone()),
287        }
288    }
289
290    // rustdoc-stripper-ignore-next
291    /// Build the [`ListBoxRow`].
292    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
293    pub fn build(self) -> ListBoxRow {
294        assert_initialized_main_thread!();
295        self.builder.build()
296    }
297}
298
299mod sealed {
300    pub trait Sealed {}
301    impl<T: super::IsA<super::ListBoxRow>> Sealed for T {}
302}
303
304pub trait ListBoxRowExt: IsA<ListBoxRow> + sealed::Sealed + 'static {
305    #[doc(alias = "gtk_list_box_row_changed")]
306    fn changed(&self) {
307        unsafe {
308            ffi::gtk_list_box_row_changed(self.as_ref().to_glib_none().0);
309        }
310    }
311
312    #[doc(alias = "gtk_list_box_row_get_activatable")]
313    #[doc(alias = "get_activatable")]
314    #[doc(alias = "activatable")]
315    fn is_activatable(&self) -> bool {
316        unsafe {
317            from_glib(ffi::gtk_list_box_row_get_activatable(
318                self.as_ref().to_glib_none().0,
319            ))
320        }
321    }
322
323    #[doc(alias = "gtk_list_box_row_get_child")]
324    #[doc(alias = "get_child")]
325    fn child(&self) -> Option<Widget> {
326        unsafe {
327            from_glib_none(ffi::gtk_list_box_row_get_child(
328                self.as_ref().to_glib_none().0,
329            ))
330        }
331    }
332
333    #[doc(alias = "gtk_list_box_row_get_header")]
334    #[doc(alias = "get_header")]
335    fn header(&self) -> Option<Widget> {
336        unsafe {
337            from_glib_none(ffi::gtk_list_box_row_get_header(
338                self.as_ref().to_glib_none().0,
339            ))
340        }
341    }
342
343    #[doc(alias = "gtk_list_box_row_get_index")]
344    #[doc(alias = "get_index")]
345    fn index(&self) -> i32 {
346        unsafe { ffi::gtk_list_box_row_get_index(self.as_ref().to_glib_none().0) }
347    }
348
349    #[doc(alias = "gtk_list_box_row_get_selectable")]
350    #[doc(alias = "get_selectable")]
351    #[doc(alias = "selectable")]
352    fn is_selectable(&self) -> bool {
353        unsafe {
354            from_glib(ffi::gtk_list_box_row_get_selectable(
355                self.as_ref().to_glib_none().0,
356            ))
357        }
358    }
359
360    #[doc(alias = "gtk_list_box_row_is_selected")]
361    fn is_selected(&self) -> bool {
362        unsafe {
363            from_glib(ffi::gtk_list_box_row_is_selected(
364                self.as_ref().to_glib_none().0,
365            ))
366        }
367    }
368
369    #[doc(alias = "gtk_list_box_row_set_activatable")]
370    #[doc(alias = "activatable")]
371    fn set_activatable(&self, activatable: bool) {
372        unsafe {
373            ffi::gtk_list_box_row_set_activatable(
374                self.as_ref().to_glib_none().0,
375                activatable.into_glib(),
376            );
377        }
378    }
379
380    #[doc(alias = "gtk_list_box_row_set_child")]
381    #[doc(alias = "child")]
382    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
383        unsafe {
384            ffi::gtk_list_box_row_set_child(
385                self.as_ref().to_glib_none().0,
386                child.map(|p| p.as_ref()).to_glib_none().0,
387            );
388        }
389    }
390
391    #[doc(alias = "gtk_list_box_row_set_header")]
392    fn set_header(&self, header: Option<&impl IsA<Widget>>) {
393        unsafe {
394            ffi::gtk_list_box_row_set_header(
395                self.as_ref().to_glib_none().0,
396                header.map(|p| p.as_ref()).to_glib_none().0,
397            );
398        }
399    }
400
401    #[doc(alias = "gtk_list_box_row_set_selectable")]
402    #[doc(alias = "selectable")]
403    fn set_selectable(&self, selectable: bool) {
404        unsafe {
405            ffi::gtk_list_box_row_set_selectable(
406                self.as_ref().to_glib_none().0,
407                selectable.into_glib(),
408            );
409        }
410    }
411
412    #[doc(alias = "activate")]
413    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
414        unsafe extern "C" fn activate_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
415            this: *mut ffi::GtkListBoxRow,
416            f: glib::ffi::gpointer,
417        ) {
418            let f: &F = &*(f as *const F);
419            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
420        }
421        unsafe {
422            let f: Box_<F> = Box_::new(f);
423            connect_raw(
424                self.as_ptr() as *mut _,
425                b"activate\0".as_ptr() as *const _,
426                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
427                    activate_trampoline::<Self, F> as *const (),
428                )),
429                Box_::into_raw(f),
430            )
431        }
432    }
433
434    fn emit_activate(&self) {
435        self.emit_by_name::<()>("activate", &[]);
436    }
437
438    #[doc(alias = "activatable")]
439    fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
440        unsafe extern "C" fn notify_activatable_trampoline<
441            P: IsA<ListBoxRow>,
442            F: Fn(&P) + 'static,
443        >(
444            this: *mut ffi::GtkListBoxRow,
445            _param_spec: glib::ffi::gpointer,
446            f: glib::ffi::gpointer,
447        ) {
448            let f: &F = &*(f as *const F);
449            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
450        }
451        unsafe {
452            let f: Box_<F> = Box_::new(f);
453            connect_raw(
454                self.as_ptr() as *mut _,
455                b"notify::activatable\0".as_ptr() as *const _,
456                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
457                    notify_activatable_trampoline::<Self, F> as *const (),
458                )),
459                Box_::into_raw(f),
460            )
461        }
462    }
463
464    #[doc(alias = "child")]
465    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
466        unsafe extern "C" fn notify_child_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
467            this: *mut ffi::GtkListBoxRow,
468            _param_spec: glib::ffi::gpointer,
469            f: glib::ffi::gpointer,
470        ) {
471            let f: &F = &*(f as *const F);
472            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                b"notify::child\0".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_child_trampoline::<Self, F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[doc(alias = "selectable")]
488    fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
489        unsafe extern "C" fn notify_selectable_trampoline<
490            P: IsA<ListBoxRow>,
491            F: Fn(&P) + 'static,
492        >(
493            this: *mut ffi::GtkListBoxRow,
494            _param_spec: glib::ffi::gpointer,
495            f: glib::ffi::gpointer,
496        ) {
497            let f: &F = &*(f as *const F);
498            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
499        }
500        unsafe {
501            let f: Box_<F> = Box_::new(f);
502            connect_raw(
503                self.as_ptr() as *mut _,
504                b"notify::selectable\0".as_ptr() as *const _,
505                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
506                    notify_selectable_trampoline::<Self, F> as *const (),
507                )),
508                Box_::into_raw(f),
509            )
510        }
511    }
512}
513
514impl<O: IsA<ListBoxRow>> ListBoxRowExt for O {}