gtk4/auto/
column_view_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::ffi;
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// [`ColumnViewRow`][crate::ColumnViewRow] is used by [`ColumnView`][crate::ColumnView] to allow configuring
15    /// how rows are displayed.
16    ///
17    /// It is not used to set the widgets displayed in the individual cells. For that
18    /// see `GtkColumnViewColumn::set_factory()` and [`ColumnViewCell`][crate::ColumnViewCell].
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `accessible-description`
24    ///  The accessible description to set on the row.
25    ///
26    /// Readable | Writeable
27    ///
28    ///
29    /// #### `accessible-label`
30    ///  The accessible label to set on the row.
31    ///
32    /// Readable | Writeable
33    ///
34    ///
35    /// #### `activatable`
36    ///  If the row can be activated by the user.
37    ///
38    /// Readable | Writeable
39    ///
40    ///
41    /// #### `focusable`
42    ///  If the row can be focused with the keyboard.
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `item`
48    ///  The item for this row.
49    ///
50    /// Readable
51    ///
52    ///
53    /// #### `position`
54    ///  Position of the row.
55    ///
56    /// Readable
57    ///
58    ///
59    /// #### `selectable`
60    ///  If the row can be selected by the user.
61    ///
62    /// Readable | Writeable
63    ///
64    ///
65    /// #### `selected`
66    ///  If the item in the row is currently selected.
67    ///
68    /// Readable
69    ///
70    /// # Implements
71    ///
72    /// [`trait@glib::ObjectExt`]
73    #[doc(alias = "GtkColumnViewRow")]
74    pub struct ColumnViewRow(Object<ffi::GtkColumnViewRow, ffi::GtkColumnViewRowClass>);
75
76    match fn {
77        type_ => || ffi::gtk_column_view_row_get_type(),
78    }
79}
80
81impl ColumnViewRow {
82    // rustdoc-stripper-ignore-next
83    /// Creates a new builder-pattern struct instance to construct [`ColumnViewRow`] objects.
84    ///
85    /// This method returns an instance of [`ColumnViewRowBuilder`](crate::builders::ColumnViewRowBuilder) which can be used to create [`ColumnViewRow`] objects.
86    pub fn builder() -> ColumnViewRowBuilder {
87        ColumnViewRowBuilder::new()
88    }
89
90    /// Gets the accessible description of @self.
91    ///
92    /// # Returns
93    ///
94    /// the accessible description
95    #[doc(alias = "gtk_column_view_row_get_accessible_description")]
96    #[doc(alias = "get_accessible_description")]
97    #[doc(alias = "accessible-description")]
98    pub fn accessible_description(&self) -> glib::GString {
99        unsafe {
100            from_glib_none(ffi::gtk_column_view_row_get_accessible_description(
101                self.to_glib_none().0,
102            ))
103        }
104    }
105
106    /// Gets the accessible label of @self.
107    ///
108    /// # Returns
109    ///
110    /// the accessible label
111    #[doc(alias = "gtk_column_view_row_get_accessible_label")]
112    #[doc(alias = "get_accessible_label")]
113    #[doc(alias = "accessible-label")]
114    pub fn accessible_label(&self) -> glib::GString {
115        unsafe {
116            from_glib_none(ffi::gtk_column_view_row_get_accessible_label(
117                self.to_glib_none().0,
118            ))
119        }
120    }
121
122    /// Checks if the row has been set to be activatable via
123    /// gtk_column_view_row_set_activatable().
124    ///
125    /// # Returns
126    ///
127    /// [`true`] if the row is activatable
128    #[doc(alias = "gtk_column_view_row_get_activatable")]
129    #[doc(alias = "get_activatable")]
130    #[doc(alias = "activatable")]
131    pub fn is_activatable(&self) -> bool {
132        unsafe {
133            from_glib(ffi::gtk_column_view_row_get_activatable(
134                self.to_glib_none().0,
135            ))
136        }
137    }
138
139    /// Checks if a row item has been set to be focusable via
140    /// gtk_column_view_row_set_focusable().
141    ///
142    /// # Returns
143    ///
144    /// [`true`] if the row is focusable
145    #[doc(alias = "gtk_column_view_row_get_focusable")]
146    #[doc(alias = "get_focusable")]
147    #[doc(alias = "focusable")]
148    pub fn is_focusable(&self) -> bool {
149        unsafe {
150            from_glib(ffi::gtk_column_view_row_get_focusable(
151                self.to_glib_none().0,
152            ))
153        }
154    }
155
156    /// Gets the model item that associated with @self.
157    ///
158    /// If @self is unbound, this function returns [`None`].
159    ///
160    /// # Returns
161    ///
162    /// The item displayed
163    #[doc(alias = "gtk_column_view_row_get_item")]
164    #[doc(alias = "get_item")]
165    pub fn item(&self) -> Option<glib::Object> {
166        unsafe { from_glib_none(ffi::gtk_column_view_row_get_item(self.to_glib_none().0)) }
167    }
168
169    /// Gets the position in the model that @self currently displays.
170    ///
171    /// If @self is unbound, `GTK_INVALID_LIST_POSITION` is returned.
172    ///
173    /// # Returns
174    ///
175    /// The position of this row
176    #[doc(alias = "gtk_column_view_row_get_position")]
177    #[doc(alias = "get_position")]
178    pub fn position(&self) -> u32 {
179        unsafe { ffi::gtk_column_view_row_get_position(self.to_glib_none().0) }
180    }
181
182    /// Checks if the row has been set to be selectable via
183    /// gtk_column_view_row_set_selectable().
184    ///
185    /// Do not confuse this function with [`is_selected()`][Self::is_selected()].
186    ///
187    /// # Returns
188    ///
189    /// [`true`] if the row is selectable
190    #[doc(alias = "gtk_column_view_row_get_selectable")]
191    #[doc(alias = "get_selectable")]
192    #[doc(alias = "selectable")]
193    pub fn is_selectable(&self) -> bool {
194        unsafe {
195            from_glib(ffi::gtk_column_view_row_get_selectable(
196                self.to_glib_none().0,
197            ))
198        }
199    }
200
201    /// Checks if the item is selected that this row corresponds to.
202    ///
203    /// The selected state is maintained by the list widget and its model
204    /// and cannot be set otherwise.
205    ///
206    /// # Returns
207    ///
208    /// [`true`] if the item is selected.
209    #[doc(alias = "gtk_column_view_row_get_selected")]
210    #[doc(alias = "get_selected")]
211    #[doc(alias = "selected")]
212    pub fn is_selected(&self) -> bool {
213        unsafe { from_glib(ffi::gtk_column_view_row_get_selected(self.to_glib_none().0)) }
214    }
215
216    /// Sets the accessible description for the row,
217    /// which may be used by e.g. screen readers.
218    /// ## `description`
219    /// the description
220    #[doc(alias = "gtk_column_view_row_set_accessible_description")]
221    #[doc(alias = "accessible-description")]
222    pub fn set_accessible_description(&self, description: &str) {
223        unsafe {
224            ffi::gtk_column_view_row_set_accessible_description(
225                self.to_glib_none().0,
226                description.to_glib_none().0,
227            );
228        }
229    }
230
231    /// Sets the accessible label for the row,
232    /// which may be used by e.g. screen readers.
233    /// ## `label`
234    /// the label
235    #[doc(alias = "gtk_column_view_row_set_accessible_label")]
236    #[doc(alias = "accessible-label")]
237    pub fn set_accessible_label(&self, label: &str) {
238        unsafe {
239            ffi::gtk_column_view_row_set_accessible_label(
240                self.to_glib_none().0,
241                label.to_glib_none().0,
242            );
243        }
244    }
245
246    /// Sets @self to be activatable.
247    ///
248    /// If a row is activatable, double-clicking on the row, using
249    /// the Return key or calling gtk_widget_activate() will activate
250    /// the row. Activating instructs the containing columnview to
251    /// emit the [`activate`][struct@crate::ColumnView#activate] signal.
252    ///
253    /// By default, row are activatable.
254    /// ## `activatable`
255    /// if the row should be activatable
256    #[doc(alias = "gtk_column_view_row_set_activatable")]
257    #[doc(alias = "activatable")]
258    pub fn set_activatable(&self, activatable: bool) {
259        unsafe {
260            ffi::gtk_column_view_row_set_activatable(
261                self.to_glib_none().0,
262                activatable.into_glib(),
263            );
264        }
265    }
266
267    /// Sets @self to be focusable.
268    ///
269    /// If a row is focusable, it can be focused using the keyboard.
270    /// This works similar to [`WidgetExt::set_focusable()`][crate::prelude::WidgetExt::set_focusable()].
271    ///
272    /// Note that if row are not focusable, the contents of cells can still be focused if
273    /// they are focusable.
274    ///
275    /// By default, rows are focusable.
276    /// ## `focusable`
277    /// if the row should be focusable
278    #[doc(alias = "gtk_column_view_row_set_focusable")]
279    #[doc(alias = "focusable")]
280    pub fn set_focusable(&self, focusable: bool) {
281        unsafe {
282            ffi::gtk_column_view_row_set_focusable(self.to_glib_none().0, focusable.into_glib());
283        }
284    }
285
286    /// Sets @self to be selectable.
287    ///
288    /// If a row is selectable, clicking on the row or using the keyboard
289    /// will try to select or unselect the row. Whether this succeeds is up to
290    /// the model to determine, as it is managing the selected state.
291    ///
292    /// Note that this means that making a row non-selectable has no
293    /// influence on the selected state at all. A non-selectable row
294    /// may still be selected.
295    ///
296    /// By default, rows are selectable.
297    /// ## `selectable`
298    /// if the row should be selectable
299    #[doc(alias = "gtk_column_view_row_set_selectable")]
300    #[doc(alias = "selectable")]
301    pub fn set_selectable(&self, selectable: bool) {
302        unsafe {
303            ffi::gtk_column_view_row_set_selectable(self.to_glib_none().0, selectable.into_glib());
304        }
305    }
306
307    #[cfg(feature = "v4_12")]
308    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
309    #[doc(alias = "accessible-description")]
310    pub fn connect_accessible_description_notify<F: Fn(&Self) + 'static>(
311        &self,
312        f: F,
313    ) -> SignalHandlerId {
314        unsafe extern "C" fn notify_accessible_description_trampoline<
315            F: Fn(&ColumnViewRow) + 'static,
316        >(
317            this: *mut ffi::GtkColumnViewRow,
318            _param_spec: glib::ffi::gpointer,
319            f: glib::ffi::gpointer,
320        ) {
321            let f: &F = &*(f as *const F);
322            f(&from_glib_borrow(this))
323        }
324        unsafe {
325            let f: Box_<F> = Box_::new(f);
326            connect_raw(
327                self.as_ptr() as *mut _,
328                b"notify::accessible-description\0".as_ptr() as *const _,
329                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
330                    notify_accessible_description_trampoline::<F> as *const (),
331                )),
332                Box_::into_raw(f),
333            )
334        }
335    }
336
337    #[cfg(feature = "v4_12")]
338    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
339    #[doc(alias = "accessible-label")]
340    pub fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
341        unsafe extern "C" fn notify_accessible_label_trampoline<F: Fn(&ColumnViewRow) + 'static>(
342            this: *mut ffi::GtkColumnViewRow,
343            _param_spec: glib::ffi::gpointer,
344            f: glib::ffi::gpointer,
345        ) {
346            let f: &F = &*(f as *const F);
347            f(&from_glib_borrow(this))
348        }
349        unsafe {
350            let f: Box_<F> = Box_::new(f);
351            connect_raw(
352                self.as_ptr() as *mut _,
353                b"notify::accessible-label\0".as_ptr() as *const _,
354                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
355                    notify_accessible_label_trampoline::<F> as *const (),
356                )),
357                Box_::into_raw(f),
358            )
359        }
360    }
361
362    #[cfg(feature = "v4_12")]
363    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
364    #[doc(alias = "activatable")]
365    pub fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
366        unsafe extern "C" fn notify_activatable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
367            this: *mut ffi::GtkColumnViewRow,
368            _param_spec: glib::ffi::gpointer,
369            f: glib::ffi::gpointer,
370        ) {
371            let f: &F = &*(f as *const F);
372            f(&from_glib_borrow(this))
373        }
374        unsafe {
375            let f: Box_<F> = Box_::new(f);
376            connect_raw(
377                self.as_ptr() as *mut _,
378                b"notify::activatable\0".as_ptr() as *const _,
379                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
380                    notify_activatable_trampoline::<F> as *const (),
381                )),
382                Box_::into_raw(f),
383            )
384        }
385    }
386
387    #[cfg(feature = "v4_12")]
388    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
389    #[doc(alias = "focusable")]
390    pub fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
391        unsafe extern "C" fn notify_focusable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
392            this: *mut ffi::GtkColumnViewRow,
393            _param_spec: glib::ffi::gpointer,
394            f: glib::ffi::gpointer,
395        ) {
396            let f: &F = &*(f as *const F);
397            f(&from_glib_borrow(this))
398        }
399        unsafe {
400            let f: Box_<F> = Box_::new(f);
401            connect_raw(
402                self.as_ptr() as *mut _,
403                b"notify::focusable\0".as_ptr() as *const _,
404                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
405                    notify_focusable_trampoline::<F> as *const (),
406                )),
407                Box_::into_raw(f),
408            )
409        }
410    }
411
412    #[cfg(feature = "v4_12")]
413    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
414    #[doc(alias = "item")]
415    pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
416        unsafe extern "C" fn notify_item_trampoline<F: Fn(&ColumnViewRow) + 'static>(
417            this: *mut ffi::GtkColumnViewRow,
418            _param_spec: glib::ffi::gpointer,
419            f: glib::ffi::gpointer,
420        ) {
421            let f: &F = &*(f as *const F);
422            f(&from_glib_borrow(this))
423        }
424        unsafe {
425            let f: Box_<F> = Box_::new(f);
426            connect_raw(
427                self.as_ptr() as *mut _,
428                b"notify::item\0".as_ptr() as *const _,
429                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
430                    notify_item_trampoline::<F> as *const (),
431                )),
432                Box_::into_raw(f),
433            )
434        }
435    }
436
437    #[cfg(feature = "v4_12")]
438    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
439    #[doc(alias = "position")]
440    pub fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
441        unsafe extern "C" fn notify_position_trampoline<F: Fn(&ColumnViewRow) + 'static>(
442            this: *mut ffi::GtkColumnViewRow,
443            _param_spec: glib::ffi::gpointer,
444            f: glib::ffi::gpointer,
445        ) {
446            let f: &F = &*(f as *const F);
447            f(&from_glib_borrow(this))
448        }
449        unsafe {
450            let f: Box_<F> = Box_::new(f);
451            connect_raw(
452                self.as_ptr() as *mut _,
453                b"notify::position\0".as_ptr() as *const _,
454                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
455                    notify_position_trampoline::<F> as *const (),
456                )),
457                Box_::into_raw(f),
458            )
459        }
460    }
461
462    #[cfg(feature = "v4_12")]
463    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
464    #[doc(alias = "selectable")]
465    pub fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
466        unsafe extern "C" fn notify_selectable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
467            this: *mut ffi::GtkColumnViewRow,
468            _param_spec: glib::ffi::gpointer,
469            f: glib::ffi::gpointer,
470        ) {
471            let f: &F = &*(f as *const F);
472            f(&from_glib_borrow(this))
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                b"notify::selectable\0".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_selectable_trampoline::<F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[cfg(feature = "v4_12")]
488    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
489    #[doc(alias = "selected")]
490    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
491        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&ColumnViewRow) + 'static>(
492            this: *mut ffi::GtkColumnViewRow,
493            _param_spec: glib::ffi::gpointer,
494            f: glib::ffi::gpointer,
495        ) {
496            let f: &F = &*(f as *const F);
497            f(&from_glib_borrow(this))
498        }
499        unsafe {
500            let f: Box_<F> = Box_::new(f);
501            connect_raw(
502                self.as_ptr() as *mut _,
503                b"notify::selected\0".as_ptr() as *const _,
504                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
505                    notify_selected_trampoline::<F> as *const (),
506                )),
507                Box_::into_raw(f),
508            )
509        }
510    }
511}
512
513// rustdoc-stripper-ignore-next
514/// A [builder-pattern] type to construct [`ColumnViewRow`] objects.
515///
516/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
517#[must_use = "The builder must be built to be used"]
518pub struct ColumnViewRowBuilder {
519    builder: glib::object::ObjectBuilder<'static, ColumnViewRow>,
520}
521
522impl ColumnViewRowBuilder {
523    fn new() -> Self {
524        Self {
525            builder: glib::object::Object::builder(),
526        }
527    }
528
529    /// The accessible description to set on the row.
530    #[cfg(feature = "v4_12")]
531    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
532    pub fn accessible_description(self, accessible_description: impl Into<glib::GString>) -> Self {
533        Self {
534            builder: self
535                .builder
536                .property("accessible-description", accessible_description.into()),
537        }
538    }
539
540    /// The accessible label to set on the row.
541    #[cfg(feature = "v4_12")]
542    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
543    pub fn accessible_label(self, accessible_label: impl Into<glib::GString>) -> Self {
544        Self {
545            builder: self
546                .builder
547                .property("accessible-label", accessible_label.into()),
548        }
549    }
550
551    /// If the row can be activated by the user.
552    #[cfg(feature = "v4_12")]
553    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
554    pub fn activatable(self, activatable: bool) -> Self {
555        Self {
556            builder: self.builder.property("activatable", activatable),
557        }
558    }
559
560    /// If the row can be focused with the keyboard.
561    #[cfg(feature = "v4_12")]
562    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
563    pub fn focusable(self, focusable: bool) -> Self {
564        Self {
565            builder: self.builder.property("focusable", focusable),
566        }
567    }
568
569    /// If the row can be selected by the user.
570    #[cfg(feature = "v4_12")]
571    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
572    pub fn selectable(self, selectable: bool) -> Self {
573        Self {
574            builder: self.builder.property("selectable", selectable),
575        }
576    }
577
578    // rustdoc-stripper-ignore-next
579    /// Build the [`ColumnViewRow`].
580    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
581    pub fn build(self) -> ColumnViewRow {
582        assert_initialized_main_thread!();
583        self.builder.build()
584    }
585}