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