gtk4/auto/
column_view_column.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, ColumnView, ListItemFactory, Sorter};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkColumnViewColumn")]
15    pub struct ColumnViewColumn(Object<ffi::GtkColumnViewColumn, ffi::GtkColumnViewColumnClass>);
16
17    match fn {
18        type_ => || ffi::gtk_column_view_column_get_type(),
19    }
20}
21
22impl ColumnViewColumn {
23    #[doc(alias = "gtk_column_view_column_new")]
24    pub fn new(
25        title: Option<&str>,
26        factory: Option<impl IsA<ListItemFactory>>,
27    ) -> ColumnViewColumn {
28        assert_initialized_main_thread!();
29        unsafe {
30            from_glib_full(ffi::gtk_column_view_column_new(
31                title.to_glib_none().0,
32                factory.map(|p| p.upcast()).into_glib_ptr(),
33            ))
34        }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`ColumnViewColumn`] objects.
39    ///
40    /// This method returns an instance of [`ColumnViewColumnBuilder`](crate::builders::ColumnViewColumnBuilder) which can be used to create [`ColumnViewColumn`] objects.
41    pub fn builder() -> ColumnViewColumnBuilder {
42        ColumnViewColumnBuilder::new()
43    }
44
45    #[doc(alias = "gtk_column_view_column_get_column_view")]
46    #[doc(alias = "get_column_view")]
47    #[doc(alias = "column-view")]
48    pub fn column_view(&self) -> Option<ColumnView> {
49        unsafe {
50            from_glib_none(ffi::gtk_column_view_column_get_column_view(
51                self.to_glib_none().0,
52            ))
53        }
54    }
55
56    #[doc(alias = "gtk_column_view_column_get_expand")]
57    #[doc(alias = "get_expand")]
58    #[doc(alias = "expand")]
59    pub fn expands(&self) -> bool {
60        unsafe {
61            from_glib(ffi::gtk_column_view_column_get_expand(
62                self.to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "gtk_column_view_column_get_factory")]
68    #[doc(alias = "get_factory")]
69    pub fn factory(&self) -> Option<ListItemFactory> {
70        unsafe {
71            from_glib_none(ffi::gtk_column_view_column_get_factory(
72                self.to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "gtk_column_view_column_get_fixed_width")]
78    #[doc(alias = "get_fixed_width")]
79    #[doc(alias = "fixed-width")]
80    pub fn fixed_width(&self) -> i32 {
81        unsafe { ffi::gtk_column_view_column_get_fixed_width(self.to_glib_none().0) }
82    }
83
84    #[doc(alias = "gtk_column_view_column_get_header_menu")]
85    #[doc(alias = "get_header_menu")]
86    #[doc(alias = "header-menu")]
87    pub fn header_menu(&self) -> Option<gio::MenuModel> {
88        unsafe {
89            from_glib_none(ffi::gtk_column_view_column_get_header_menu(
90                self.to_glib_none().0,
91            ))
92        }
93    }
94
95    #[cfg(feature = "v4_10")]
96    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
97    #[doc(alias = "gtk_column_view_column_get_id")]
98    #[doc(alias = "get_id")]
99    pub fn id(&self) -> Option<glib::GString> {
100        unsafe { from_glib_none(ffi::gtk_column_view_column_get_id(self.to_glib_none().0)) }
101    }
102
103    #[doc(alias = "gtk_column_view_column_get_resizable")]
104    #[doc(alias = "get_resizable")]
105    #[doc(alias = "resizable")]
106    pub fn is_resizable(&self) -> bool {
107        unsafe {
108            from_glib(ffi::gtk_column_view_column_get_resizable(
109                self.to_glib_none().0,
110            ))
111        }
112    }
113
114    #[doc(alias = "gtk_column_view_column_get_sorter")]
115    #[doc(alias = "get_sorter")]
116    pub fn sorter(&self) -> Option<Sorter> {
117        unsafe {
118            from_glib_none(ffi::gtk_column_view_column_get_sorter(
119                self.to_glib_none().0,
120            ))
121        }
122    }
123
124    #[doc(alias = "gtk_column_view_column_get_title")]
125    #[doc(alias = "get_title")]
126    pub fn title(&self) -> Option<glib::GString> {
127        unsafe { from_glib_none(ffi::gtk_column_view_column_get_title(self.to_glib_none().0)) }
128    }
129
130    #[doc(alias = "gtk_column_view_column_get_visible")]
131    #[doc(alias = "get_visible")]
132    #[doc(alias = "visible")]
133    pub fn is_visible(&self) -> bool {
134        unsafe {
135            from_glib(ffi::gtk_column_view_column_get_visible(
136                self.to_glib_none().0,
137            ))
138        }
139    }
140
141    #[doc(alias = "gtk_column_view_column_set_expand")]
142    #[doc(alias = "expand")]
143    pub fn set_expand(&self, expand: bool) {
144        unsafe {
145            ffi::gtk_column_view_column_set_expand(self.to_glib_none().0, expand.into_glib());
146        }
147    }
148
149    #[doc(alias = "gtk_column_view_column_set_factory")]
150    #[doc(alias = "factory")]
151    pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
152        unsafe {
153            ffi::gtk_column_view_column_set_factory(
154                self.to_glib_none().0,
155                factory.map(|p| p.as_ref()).to_glib_none().0,
156            );
157        }
158    }
159
160    #[doc(alias = "gtk_column_view_column_set_fixed_width")]
161    #[doc(alias = "fixed-width")]
162    pub fn set_fixed_width(&self, fixed_width: i32) {
163        unsafe {
164            ffi::gtk_column_view_column_set_fixed_width(self.to_glib_none().0, fixed_width);
165        }
166    }
167
168    #[doc(alias = "gtk_column_view_column_set_header_menu")]
169    #[doc(alias = "header-menu")]
170    pub fn set_header_menu(&self, menu: Option<&impl IsA<gio::MenuModel>>) {
171        unsafe {
172            ffi::gtk_column_view_column_set_header_menu(
173                self.to_glib_none().0,
174                menu.map(|p| p.as_ref()).to_glib_none().0,
175            );
176        }
177    }
178
179    #[cfg(feature = "v4_10")]
180    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
181    #[doc(alias = "gtk_column_view_column_set_id")]
182    #[doc(alias = "id")]
183    pub fn set_id(&self, id: Option<&str>) {
184        unsafe {
185            ffi::gtk_column_view_column_set_id(self.to_glib_none().0, id.to_glib_none().0);
186        }
187    }
188
189    #[doc(alias = "gtk_column_view_column_set_resizable")]
190    #[doc(alias = "resizable")]
191    pub fn set_resizable(&self, resizable: bool) {
192        unsafe {
193            ffi::gtk_column_view_column_set_resizable(self.to_glib_none().0, resizable.into_glib());
194        }
195    }
196
197    #[doc(alias = "gtk_column_view_column_set_sorter")]
198    #[doc(alias = "sorter")]
199    pub fn set_sorter(&self, sorter: Option<&impl IsA<Sorter>>) {
200        unsafe {
201            ffi::gtk_column_view_column_set_sorter(
202                self.to_glib_none().0,
203                sorter.map(|p| p.as_ref()).to_glib_none().0,
204            );
205        }
206    }
207
208    #[doc(alias = "gtk_column_view_column_set_title")]
209    #[doc(alias = "title")]
210    pub fn set_title(&self, title: Option<&str>) {
211        unsafe {
212            ffi::gtk_column_view_column_set_title(self.to_glib_none().0, title.to_glib_none().0);
213        }
214    }
215
216    #[doc(alias = "gtk_column_view_column_set_visible")]
217    #[doc(alias = "visible")]
218    pub fn set_visible(&self, visible: bool) {
219        unsafe {
220            ffi::gtk_column_view_column_set_visible(self.to_glib_none().0, visible.into_glib());
221        }
222    }
223
224    #[doc(alias = "column-view")]
225    pub fn connect_column_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
226        unsafe extern "C" fn notify_column_view_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
227            this: *mut ffi::GtkColumnViewColumn,
228            _param_spec: glib::ffi::gpointer,
229            f: glib::ffi::gpointer,
230        ) {
231            let f: &F = &*(f as *const F);
232            f(&from_glib_borrow(this))
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(
237                self.as_ptr() as *mut _,
238                c"notify::column-view".as_ptr() as *const _,
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
240                    notify_column_view_trampoline::<F> as *const (),
241                )),
242                Box_::into_raw(f),
243            )
244        }
245    }
246
247    #[doc(alias = "expand")]
248    pub fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
249        unsafe extern "C" fn notify_expand_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
250            this: *mut ffi::GtkColumnViewColumn,
251            _param_spec: glib::ffi::gpointer,
252            f: glib::ffi::gpointer,
253        ) {
254            let f: &F = &*(f as *const F);
255            f(&from_glib_borrow(this))
256        }
257        unsafe {
258            let f: Box_<F> = Box_::new(f);
259            connect_raw(
260                self.as_ptr() as *mut _,
261                c"notify::expand".as_ptr() as *const _,
262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
263                    notify_expand_trampoline::<F> as *const (),
264                )),
265                Box_::into_raw(f),
266            )
267        }
268    }
269
270    #[doc(alias = "factory")]
271    pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
272        unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
273            this: *mut ffi::GtkColumnViewColumn,
274            _param_spec: glib::ffi::gpointer,
275            f: glib::ffi::gpointer,
276        ) {
277            let f: &F = &*(f as *const F);
278            f(&from_glib_borrow(this))
279        }
280        unsafe {
281            let f: Box_<F> = Box_::new(f);
282            connect_raw(
283                self.as_ptr() as *mut _,
284                c"notify::factory".as_ptr() as *const _,
285                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
286                    notify_factory_trampoline::<F> as *const (),
287                )),
288                Box_::into_raw(f),
289            )
290        }
291    }
292
293    #[doc(alias = "fixed-width")]
294    pub fn connect_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
295        unsafe extern "C" fn notify_fixed_width_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
296            this: *mut ffi::GtkColumnViewColumn,
297            _param_spec: glib::ffi::gpointer,
298            f: glib::ffi::gpointer,
299        ) {
300            let f: &F = &*(f as *const F);
301            f(&from_glib_borrow(this))
302        }
303        unsafe {
304            let f: Box_<F> = Box_::new(f);
305            connect_raw(
306                self.as_ptr() as *mut _,
307                c"notify::fixed-width".as_ptr() as *const _,
308                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
309                    notify_fixed_width_trampoline::<F> as *const (),
310                )),
311                Box_::into_raw(f),
312            )
313        }
314    }
315
316    #[doc(alias = "header-menu")]
317    pub fn connect_header_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
318        unsafe extern "C" fn notify_header_menu_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
319            this: *mut ffi::GtkColumnViewColumn,
320            _param_spec: glib::ffi::gpointer,
321            f: glib::ffi::gpointer,
322        ) {
323            let f: &F = &*(f as *const F);
324            f(&from_glib_borrow(this))
325        }
326        unsafe {
327            let f: Box_<F> = Box_::new(f);
328            connect_raw(
329                self.as_ptr() as *mut _,
330                c"notify::header-menu".as_ptr() as *const _,
331                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
332                    notify_header_menu_trampoline::<F> as *const (),
333                )),
334                Box_::into_raw(f),
335            )
336        }
337    }
338
339    #[cfg(feature = "v4_10")]
340    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
341    #[doc(alias = "id")]
342    pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
343        unsafe extern "C" fn notify_id_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
344            this: *mut ffi::GtkColumnViewColumn,
345            _param_spec: glib::ffi::gpointer,
346            f: glib::ffi::gpointer,
347        ) {
348            let f: &F = &*(f as *const F);
349            f(&from_glib_borrow(this))
350        }
351        unsafe {
352            let f: Box_<F> = Box_::new(f);
353            connect_raw(
354                self.as_ptr() as *mut _,
355                c"notify::id".as_ptr() as *const _,
356                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
357                    notify_id_trampoline::<F> as *const (),
358                )),
359                Box_::into_raw(f),
360            )
361        }
362    }
363
364    #[doc(alias = "resizable")]
365    pub fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
366        unsafe extern "C" fn notify_resizable_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
367            this: *mut ffi::GtkColumnViewColumn,
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                c"notify::resizable".as_ptr() as *const _,
379                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
380                    notify_resizable_trampoline::<F> as *const (),
381                )),
382                Box_::into_raw(f),
383            )
384        }
385    }
386
387    #[doc(alias = "sorter")]
388    pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
389        unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
390            this: *mut ffi::GtkColumnViewColumn,
391            _param_spec: glib::ffi::gpointer,
392            f: glib::ffi::gpointer,
393        ) {
394            let f: &F = &*(f as *const F);
395            f(&from_glib_borrow(this))
396        }
397        unsafe {
398            let f: Box_<F> = Box_::new(f);
399            connect_raw(
400                self.as_ptr() as *mut _,
401                c"notify::sorter".as_ptr() as *const _,
402                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
403                    notify_sorter_trampoline::<F> as *const (),
404                )),
405                Box_::into_raw(f),
406            )
407        }
408    }
409
410    #[doc(alias = "title")]
411    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
412        unsafe extern "C" fn notify_title_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
413            this: *mut ffi::GtkColumnViewColumn,
414            _param_spec: glib::ffi::gpointer,
415            f: glib::ffi::gpointer,
416        ) {
417            let f: &F = &*(f as *const F);
418            f(&from_glib_borrow(this))
419        }
420        unsafe {
421            let f: Box_<F> = Box_::new(f);
422            connect_raw(
423                self.as_ptr() as *mut _,
424                c"notify::title".as_ptr() as *const _,
425                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
426                    notify_title_trampoline::<F> as *const (),
427                )),
428                Box_::into_raw(f),
429            )
430        }
431    }
432
433    #[doc(alias = "visible")]
434    pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
435        unsafe extern "C" fn notify_visible_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
436            this: *mut ffi::GtkColumnViewColumn,
437            _param_spec: glib::ffi::gpointer,
438            f: glib::ffi::gpointer,
439        ) {
440            let f: &F = &*(f as *const F);
441            f(&from_glib_borrow(this))
442        }
443        unsafe {
444            let f: Box_<F> = Box_::new(f);
445            connect_raw(
446                self.as_ptr() as *mut _,
447                c"notify::visible".as_ptr() as *const _,
448                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
449                    notify_visible_trampoline::<F> as *const (),
450                )),
451                Box_::into_raw(f),
452            )
453        }
454    }
455}
456
457impl Default for ColumnViewColumn {
458    fn default() -> Self {
459        glib::object::Object::new::<Self>()
460    }
461}
462
463// rustdoc-stripper-ignore-next
464/// A [builder-pattern] type to construct [`ColumnViewColumn`] objects.
465///
466/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
467#[must_use = "The builder must be built to be used"]
468pub struct ColumnViewColumnBuilder {
469    builder: glib::object::ObjectBuilder<'static, ColumnViewColumn>,
470}
471
472impl ColumnViewColumnBuilder {
473    fn new() -> Self {
474        Self {
475            builder: glib::object::Object::builder(),
476        }
477    }
478
479    pub fn expand(self, expand: bool) -> Self {
480        Self {
481            builder: self.builder.property("expand", expand),
482        }
483    }
484
485    pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
486        Self {
487            builder: self.builder.property("factory", factory.clone().upcast()),
488        }
489    }
490
491    pub fn fixed_width(self, fixed_width: i32) -> Self {
492        Self {
493            builder: self.builder.property("fixed-width", fixed_width),
494        }
495    }
496
497    pub fn header_menu(self, header_menu: &impl IsA<gio::MenuModel>) -> Self {
498        Self {
499            builder: self
500                .builder
501                .property("header-menu", header_menu.clone().upcast()),
502        }
503    }
504
505    #[cfg(feature = "v4_10")]
506    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
507    pub fn id(self, id: impl Into<glib::GString>) -> Self {
508        Self {
509            builder: self.builder.property("id", id.into()),
510        }
511    }
512
513    pub fn resizable(self, resizable: bool) -> Self {
514        Self {
515            builder: self.builder.property("resizable", resizable),
516        }
517    }
518
519    pub fn sorter(self, sorter: &impl IsA<Sorter>) -> Self {
520        Self {
521            builder: self.builder.property("sorter", sorter.clone().upcast()),
522        }
523    }
524
525    pub fn title(self, title: impl Into<glib::GString>) -> Self {
526        Self {
527            builder: self.builder.property("title", title.into()),
528        }
529    }
530
531    pub fn visible(self, visible: bool) -> Self {
532        Self {
533            builder: self.builder.property("visible", visible),
534        }
535    }
536
537    // rustdoc-stripper-ignore-next
538    /// Build the [`ColumnViewColumn`].
539    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
540    pub fn build(self) -> ColumnViewColumn {
541        assert_initialized_main_thread!();
542        self.builder.build()
543    }
544}