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::{SignalHandlerId, connect_raw},
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            unsafe {
321                let f: &F = &*(f as *const F);
322                f(&from_glib_borrow(this))
323            }
324        }
325        unsafe {
326            let f: Box_<F> = Box_::new(f);
327            connect_raw(
328                self.as_ptr() as *mut _,
329                c"notify::accessible-description".as_ptr() as *const _,
330                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
331                    notify_accessible_description_trampoline::<F> as *const (),
332                )),
333                Box_::into_raw(f),
334            )
335        }
336    }
337
338    #[cfg(feature = "v4_12")]
339    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
340    #[doc(alias = "accessible-label")]
341    pub fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
342        unsafe extern "C" fn notify_accessible_label_trampoline<F: Fn(&ColumnViewRow) + 'static>(
343            this: *mut ffi::GtkColumnViewRow,
344            _param_spec: glib::ffi::gpointer,
345            f: glib::ffi::gpointer,
346        ) {
347            unsafe {
348                let f: &F = &*(f as *const F);
349                f(&from_glib_borrow(this))
350            }
351        }
352        unsafe {
353            let f: Box_<F> = Box_::new(f);
354            connect_raw(
355                self.as_ptr() as *mut _,
356                c"notify::accessible-label".as_ptr() as *const _,
357                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
358                    notify_accessible_label_trampoline::<F> as *const (),
359                )),
360                Box_::into_raw(f),
361            )
362        }
363    }
364
365    #[cfg(feature = "v4_12")]
366    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
367    #[doc(alias = "activatable")]
368    pub fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369        unsafe extern "C" fn notify_activatable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
370            this: *mut ffi::GtkColumnViewRow,
371            _param_spec: glib::ffi::gpointer,
372            f: glib::ffi::gpointer,
373        ) {
374            unsafe {
375                let f: &F = &*(f as *const F);
376                f(&from_glib_borrow(this))
377            }
378        }
379        unsafe {
380            let f: Box_<F> = Box_::new(f);
381            connect_raw(
382                self.as_ptr() as *mut _,
383                c"notify::activatable".as_ptr() as *const _,
384                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
385                    notify_activatable_trampoline::<F> as *const (),
386                )),
387                Box_::into_raw(f),
388            )
389        }
390    }
391
392    #[cfg(feature = "v4_12")]
393    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
394    #[doc(alias = "focusable")]
395    pub fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
396        unsafe extern "C" fn notify_focusable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
397            this: *mut ffi::GtkColumnViewRow,
398            _param_spec: glib::ffi::gpointer,
399            f: glib::ffi::gpointer,
400        ) {
401            unsafe {
402                let f: &F = &*(f as *const F);
403                f(&from_glib_borrow(this))
404            }
405        }
406        unsafe {
407            let f: Box_<F> = Box_::new(f);
408            connect_raw(
409                self.as_ptr() as *mut _,
410                c"notify::focusable".as_ptr() as *const _,
411                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
412                    notify_focusable_trampoline::<F> as *const (),
413                )),
414                Box_::into_raw(f),
415            )
416        }
417    }
418
419    #[cfg(feature = "v4_12")]
420    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
421    #[doc(alias = "item")]
422    pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
423        unsafe extern "C" fn notify_item_trampoline<F: Fn(&ColumnViewRow) + 'static>(
424            this: *mut ffi::GtkColumnViewRow,
425            _param_spec: glib::ffi::gpointer,
426            f: glib::ffi::gpointer,
427        ) {
428            unsafe {
429                let f: &F = &*(f as *const F);
430                f(&from_glib_borrow(this))
431            }
432        }
433        unsafe {
434            let f: Box_<F> = Box_::new(f);
435            connect_raw(
436                self.as_ptr() as *mut _,
437                c"notify::item".as_ptr() as *const _,
438                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439                    notify_item_trampoline::<F> as *const (),
440                )),
441                Box_::into_raw(f),
442            )
443        }
444    }
445
446    #[cfg(feature = "v4_12")]
447    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
448    #[doc(alias = "position")]
449    pub fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450        unsafe extern "C" fn notify_position_trampoline<F: Fn(&ColumnViewRow) + 'static>(
451            this: *mut ffi::GtkColumnViewRow,
452            _param_spec: glib::ffi::gpointer,
453            f: glib::ffi::gpointer,
454        ) {
455            unsafe {
456                let f: &F = &*(f as *const F);
457                f(&from_glib_borrow(this))
458            }
459        }
460        unsafe {
461            let f: Box_<F> = Box_::new(f);
462            connect_raw(
463                self.as_ptr() as *mut _,
464                c"notify::position".as_ptr() as *const _,
465                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
466                    notify_position_trampoline::<F> as *const (),
467                )),
468                Box_::into_raw(f),
469            )
470        }
471    }
472
473    #[cfg(feature = "v4_12")]
474    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
475    #[doc(alias = "selectable")]
476    pub fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
477        unsafe extern "C" fn notify_selectable_trampoline<F: Fn(&ColumnViewRow) + 'static>(
478            this: *mut ffi::GtkColumnViewRow,
479            _param_spec: glib::ffi::gpointer,
480            f: glib::ffi::gpointer,
481        ) {
482            unsafe {
483                let f: &F = &*(f as *const F);
484                f(&from_glib_borrow(this))
485            }
486        }
487        unsafe {
488            let f: Box_<F> = Box_::new(f);
489            connect_raw(
490                self.as_ptr() as *mut _,
491                c"notify::selectable".as_ptr() as *const _,
492                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
493                    notify_selectable_trampoline::<F> as *const (),
494                )),
495                Box_::into_raw(f),
496            )
497        }
498    }
499
500    #[cfg(feature = "v4_12")]
501    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
502    #[doc(alias = "selected")]
503    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
504        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&ColumnViewRow) + 'static>(
505            this: *mut ffi::GtkColumnViewRow,
506            _param_spec: glib::ffi::gpointer,
507            f: glib::ffi::gpointer,
508        ) {
509            unsafe {
510                let f: &F = &*(f as *const F);
511                f(&from_glib_borrow(this))
512            }
513        }
514        unsafe {
515            let f: Box_<F> = Box_::new(f);
516            connect_raw(
517                self.as_ptr() as *mut _,
518                c"notify::selected".as_ptr() as *const _,
519                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
520                    notify_selected_trampoline::<F> as *const (),
521                )),
522                Box_::into_raw(f),
523            )
524        }
525    }
526}
527
528// rustdoc-stripper-ignore-next
529/// A [builder-pattern] type to construct [`ColumnViewRow`] objects.
530///
531/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
532#[must_use = "The builder must be built to be used"]
533pub struct ColumnViewRowBuilder {
534    builder: glib::object::ObjectBuilder<'static, ColumnViewRow>,
535}
536
537impl ColumnViewRowBuilder {
538    fn new() -> Self {
539        Self {
540            builder: glib::object::Object::builder(),
541        }
542    }
543
544    /// The accessible description to set on the row.
545    #[cfg(feature = "v4_12")]
546    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
547    pub fn accessible_description(self, accessible_description: impl Into<glib::GString>) -> Self {
548        Self {
549            builder: self
550                .builder
551                .property("accessible-description", accessible_description.into()),
552        }
553    }
554
555    /// The accessible label to set on the row.
556    #[cfg(feature = "v4_12")]
557    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
558    pub fn accessible_label(self, accessible_label: impl Into<glib::GString>) -> Self {
559        Self {
560            builder: self
561                .builder
562                .property("accessible-label", accessible_label.into()),
563        }
564    }
565
566    /// If the row can be activated by the user.
567    #[cfg(feature = "v4_12")]
568    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
569    pub fn activatable(self, activatable: bool) -> Self {
570        Self {
571            builder: self.builder.property("activatable", activatable),
572        }
573    }
574
575    /// If the row can be focused with the keyboard.
576    #[cfg(feature = "v4_12")]
577    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
578    pub fn focusable(self, focusable: bool) -> Self {
579        Self {
580            builder: self.builder.property("focusable", focusable),
581        }
582    }
583
584    /// If the row can be selected by the user.
585    #[cfg(feature = "v4_12")]
586    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
587    pub fn selectable(self, selectable: bool) -> Self {
588        Self {
589            builder: self.builder.property("selectable", selectable),
590        }
591    }
592
593    // rustdoc-stripper-ignore-next
594    /// Build the [`ColumnViewRow`].
595    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
596    pub fn build(self) -> ColumnViewRow {
597        assert_initialized_main_thread!();
598        self.builder.build()
599    }
600}