[go: up one dir, main page]

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
299pub trait ListBoxRowExt: IsA<ListBoxRow> + 'static {
300    #[doc(alias = "gtk_list_box_row_changed")]
301    fn changed(&self) {
302        unsafe {
303            ffi::gtk_list_box_row_changed(self.as_ref().to_glib_none().0);
304        }
305    }
306
307    #[doc(alias = "gtk_list_box_row_get_activatable")]
308    #[doc(alias = "get_activatable")]
309    #[doc(alias = "activatable")]
310    fn is_activatable(&self) -> bool {
311        unsafe {
312            from_glib(ffi::gtk_list_box_row_get_activatable(
313                self.as_ref().to_glib_none().0,
314            ))
315        }
316    }
317
318    #[doc(alias = "gtk_list_box_row_get_child")]
319    #[doc(alias = "get_child")]
320    fn child(&self) -> Option<Widget> {
321        unsafe {
322            from_glib_none(ffi::gtk_list_box_row_get_child(
323                self.as_ref().to_glib_none().0,
324            ))
325        }
326    }
327
328    #[doc(alias = "gtk_list_box_row_get_header")]
329    #[doc(alias = "get_header")]
330    fn header(&self) -> Option<Widget> {
331        unsafe {
332            from_glib_none(ffi::gtk_list_box_row_get_header(
333                self.as_ref().to_glib_none().0,
334            ))
335        }
336    }
337
338    #[doc(alias = "gtk_list_box_row_get_index")]
339    #[doc(alias = "get_index")]
340    fn index(&self) -> i32 {
341        unsafe { ffi::gtk_list_box_row_get_index(self.as_ref().to_glib_none().0) }
342    }
343
344    #[doc(alias = "gtk_list_box_row_get_selectable")]
345    #[doc(alias = "get_selectable")]
346    #[doc(alias = "selectable")]
347    fn is_selectable(&self) -> bool {
348        unsafe {
349            from_glib(ffi::gtk_list_box_row_get_selectable(
350                self.as_ref().to_glib_none().0,
351            ))
352        }
353    }
354
355    #[doc(alias = "gtk_list_box_row_is_selected")]
356    fn is_selected(&self) -> bool {
357        unsafe {
358            from_glib(ffi::gtk_list_box_row_is_selected(
359                self.as_ref().to_glib_none().0,
360            ))
361        }
362    }
363
364    #[doc(alias = "gtk_list_box_row_set_activatable")]
365    #[doc(alias = "activatable")]
366    fn set_activatable(&self, activatable: bool) {
367        unsafe {
368            ffi::gtk_list_box_row_set_activatable(
369                self.as_ref().to_glib_none().0,
370                activatable.into_glib(),
371            );
372        }
373    }
374
375    #[doc(alias = "gtk_list_box_row_set_child")]
376    #[doc(alias = "child")]
377    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
378        unsafe {
379            ffi::gtk_list_box_row_set_child(
380                self.as_ref().to_glib_none().0,
381                child.map(|p| p.as_ref()).to_glib_none().0,
382            );
383        }
384    }
385
386    #[doc(alias = "gtk_list_box_row_set_header")]
387    fn set_header(&self, header: Option<&impl IsA<Widget>>) {
388        unsafe {
389            ffi::gtk_list_box_row_set_header(
390                self.as_ref().to_glib_none().0,
391                header.map(|p| p.as_ref()).to_glib_none().0,
392            );
393        }
394    }
395
396    #[doc(alias = "gtk_list_box_row_set_selectable")]
397    #[doc(alias = "selectable")]
398    fn set_selectable(&self, selectable: bool) {
399        unsafe {
400            ffi::gtk_list_box_row_set_selectable(
401                self.as_ref().to_glib_none().0,
402                selectable.into_glib(),
403            );
404        }
405    }
406
407    #[doc(alias = "activate")]
408    fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
409        unsafe extern "C" fn activate_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
410            this: *mut ffi::GtkListBoxRow,
411            f: glib::ffi::gpointer,
412        ) {
413            let f: &F = &*(f as *const F);
414            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
415        }
416        unsafe {
417            let f: Box_<F> = Box_::new(f);
418            connect_raw(
419                self.as_ptr() as *mut _,
420                c"activate".as_ptr() as *const _,
421                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
422                    activate_trampoline::<Self, F> as *const (),
423                )),
424                Box_::into_raw(f),
425            )
426        }
427    }
428
429    fn emit_activate(&self) {
430        self.emit_by_name::<()>("activate", &[]);
431    }
432
433    #[doc(alias = "activatable")]
434    fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
435        unsafe extern "C" fn notify_activatable_trampoline<
436            P: IsA<ListBoxRow>,
437            F: Fn(&P) + 'static,
438        >(
439            this: *mut ffi::GtkListBoxRow,
440            _param_spec: glib::ffi::gpointer,
441            f: glib::ffi::gpointer,
442        ) {
443            let f: &F = &*(f as *const F);
444            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
445        }
446        unsafe {
447            let f: Box_<F> = Box_::new(f);
448            connect_raw(
449                self.as_ptr() as *mut _,
450                c"notify::activatable".as_ptr() as *const _,
451                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
452                    notify_activatable_trampoline::<Self, F> as *const (),
453                )),
454                Box_::into_raw(f),
455            )
456        }
457    }
458
459    #[doc(alias = "child")]
460    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
461        unsafe extern "C" fn notify_child_trampoline<P: IsA<ListBoxRow>, F: Fn(&P) + 'static>(
462            this: *mut ffi::GtkListBoxRow,
463            _param_spec: glib::ffi::gpointer,
464            f: glib::ffi::gpointer,
465        ) {
466            let f: &F = &*(f as *const F);
467            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
468        }
469        unsafe {
470            let f: Box_<F> = Box_::new(f);
471            connect_raw(
472                self.as_ptr() as *mut _,
473                c"notify::child".as_ptr() as *const _,
474                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
475                    notify_child_trampoline::<Self, F> as *const (),
476                )),
477                Box_::into_raw(f),
478            )
479        }
480    }
481
482    #[doc(alias = "selectable")]
483    fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
484        unsafe extern "C" fn notify_selectable_trampoline<
485            P: IsA<ListBoxRow>,
486            F: Fn(&P) + 'static,
487        >(
488            this: *mut ffi::GtkListBoxRow,
489            _param_spec: glib::ffi::gpointer,
490            f: glib::ffi::gpointer,
491        ) {
492            let f: &F = &*(f as *const F);
493            f(ListBoxRow::from_glib_borrow(this).unsafe_cast_ref())
494        }
495        unsafe {
496            let f: Box_<F> = Box_::new(f);
497            connect_raw(
498                self.as_ptr() as *mut _,
499                c"notify::selectable".as_ptr() as *const _,
500                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
501                    notify_selectable_trampoline::<Self, F> as *const (),
502                )),
503                Box_::into_raw(f),
504            )
505        }
506    }
507}
508
509impl<O: IsA<ListBoxRow>> ListBoxRowExt for O {}