1use crate::{ColumnView, ListItemFactory, Sorter, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GtkColumnViewColumn")]
102 pub struct ColumnViewColumn(Object<ffi::GtkColumnViewColumn, ffi::GtkColumnViewColumnClass>);
103
104 match fn {
105 type_ => || ffi::gtk_column_view_column_get_type(),
106 }
107}
108
109impl ColumnViewColumn {
110 #[doc(alias = "gtk_column_view_column_new")]
132 pub fn new(
133 title: Option<&str>,
134 factory: Option<impl IsA<ListItemFactory>>,
135 ) -> ColumnViewColumn {
136 assert_initialized_main_thread!();
137 unsafe {
138 from_glib_full(ffi::gtk_column_view_column_new(
139 title.to_glib_none().0,
140 factory.map(|p| p.upcast()).into_glib_ptr(),
141 ))
142 }
143 }
144
145 pub fn builder() -> ColumnViewColumnBuilder {
150 ColumnViewColumnBuilder::new()
151 }
152
153 #[doc(alias = "gtk_column_view_column_get_column_view")]
161 #[doc(alias = "get_column_view")]
162 #[doc(alias = "column-view")]
163 pub fn column_view(&self) -> Option<ColumnView> {
164 unsafe {
165 from_glib_none(ffi::gtk_column_view_column_get_column_view(
166 self.to_glib_none().0,
167 ))
168 }
169 }
170
171 #[doc(alias = "gtk_column_view_column_get_expand")]
177 #[doc(alias = "get_expand")]
178 #[doc(alias = "expand")]
179 pub fn expands(&self) -> bool {
180 unsafe {
181 from_glib(ffi::gtk_column_view_column_get_expand(
182 self.to_glib_none().0,
183 ))
184 }
185 }
186
187 #[doc(alias = "gtk_column_view_column_get_factory")]
194 #[doc(alias = "get_factory")]
195 pub fn factory(&self) -> Option<ListItemFactory> {
196 unsafe {
197 from_glib_none(ffi::gtk_column_view_column_get_factory(
198 self.to_glib_none().0,
199 ))
200 }
201 }
202
203 #[doc(alias = "gtk_column_view_column_get_fixed_width")]
209 #[doc(alias = "get_fixed_width")]
210 #[doc(alias = "fixed-width")]
211 pub fn fixed_width(&self) -> i32 {
212 unsafe { ffi::gtk_column_view_column_get_fixed_width(self.to_glib_none().0) }
213 }
214
215 #[doc(alias = "gtk_column_view_column_get_header_menu")]
222 #[doc(alias = "get_header_menu")]
223 #[doc(alias = "header-menu")]
224 pub fn header_menu(&self) -> Option<gio::MenuModel> {
225 unsafe {
226 from_glib_none(ffi::gtk_column_view_column_get_header_menu(
227 self.to_glib_none().0,
228 ))
229 }
230 }
231
232 #[cfg(feature = "v4_10")]
238 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
239 #[doc(alias = "gtk_column_view_column_get_id")]
240 #[doc(alias = "get_id")]
241 pub fn id(&self) -> Option<glib::GString> {
242 unsafe { from_glib_none(ffi::gtk_column_view_column_get_id(self.to_glib_none().0)) }
243 }
244
245 #[doc(alias = "gtk_column_view_column_get_resizable")]
251 #[doc(alias = "get_resizable")]
252 #[doc(alias = "resizable")]
253 pub fn is_resizable(&self) -> bool {
254 unsafe {
255 from_glib(ffi::gtk_column_view_column_get_resizable(
256 self.to_glib_none().0,
257 ))
258 }
259 }
260
261 #[doc(alias = "gtk_column_view_column_get_sorter")]
267 #[doc(alias = "get_sorter")]
268 pub fn sorter(&self) -> Option<Sorter> {
269 unsafe {
270 from_glib_none(ffi::gtk_column_view_column_get_sorter(
271 self.to_glib_none().0,
272 ))
273 }
274 }
275
276 #[doc(alias = "gtk_column_view_column_get_title")]
282 #[doc(alias = "get_title")]
283 pub fn title(&self) -> Option<glib::GString> {
284 unsafe { from_glib_none(ffi::gtk_column_view_column_get_title(self.to_glib_none().0)) }
285 }
286
287 #[doc(alias = "gtk_column_view_column_get_visible")]
293 #[doc(alias = "get_visible")]
294 #[doc(alias = "visible")]
295 pub fn is_visible(&self) -> bool {
296 unsafe {
297 from_glib(ffi::gtk_column_view_column_get_visible(
298 self.to_glib_none().0,
299 ))
300 }
301 }
302
303 #[doc(alias = "gtk_column_view_column_set_expand")]
310 #[doc(alias = "expand")]
311 pub fn set_expand(&self, expand: bool) {
312 unsafe {
313 ffi::gtk_column_view_column_set_expand(self.to_glib_none().0, expand.into_glib());
314 }
315 }
316
317 #[doc(alias = "gtk_column_view_column_set_factory")]
322 #[doc(alias = "factory")]
323 pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
324 unsafe {
325 ffi::gtk_column_view_column_set_factory(
326 self.to_glib_none().0,
327 factory.map(|p| p.as_ref()).to_glib_none().0,
328 );
329 }
330 }
331
332 #[doc(alias = "gtk_column_view_column_set_fixed_width")]
336 #[doc(alias = "fixed-width")]
337 pub fn set_fixed_width(&self, fixed_width: i32) {
338 unsafe {
339 ffi::gtk_column_view_column_set_fixed_width(self.to_glib_none().0, fixed_width);
340 }
341 }
342
343 #[doc(alias = "gtk_column_view_column_set_header_menu")]
348 #[doc(alias = "header-menu")]
349 pub fn set_header_menu(&self, menu: Option<&impl IsA<gio::MenuModel>>) {
350 unsafe {
351 ffi::gtk_column_view_column_set_header_menu(
352 self.to_glib_none().0,
353 menu.map(|p| p.as_ref()).to_glib_none().0,
354 );
355 }
356 }
357
358 #[cfg(feature = "v4_10")]
367 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
368 #[doc(alias = "gtk_column_view_column_set_id")]
369 #[doc(alias = "id")]
370 pub fn set_id(&self, id: Option<&str>) {
371 unsafe {
372 ffi::gtk_column_view_column_set_id(self.to_glib_none().0, id.to_glib_none().0);
373 }
374 }
375
376 #[doc(alias = "gtk_column_view_column_set_resizable")]
380 #[doc(alias = "resizable")]
381 pub fn set_resizable(&self, resizable: bool) {
382 unsafe {
383 ffi::gtk_column_view_column_set_resizable(self.to_glib_none().0, resizable.into_glib());
384 }
385 }
386
387 #[doc(alias = "gtk_column_view_column_set_sorter")]
400 #[doc(alias = "sorter")]
401 pub fn set_sorter(&self, sorter: Option<&impl IsA<Sorter>>) {
402 unsafe {
403 ffi::gtk_column_view_column_set_sorter(
404 self.to_glib_none().0,
405 sorter.map(|p| p.as_ref()).to_glib_none().0,
406 );
407 }
408 }
409
410 #[doc(alias = "gtk_column_view_column_set_title")]
418 #[doc(alias = "title")]
419 pub fn set_title(&self, title: Option<&str>) {
420 unsafe {
421 ffi::gtk_column_view_column_set_title(self.to_glib_none().0, title.to_glib_none().0);
422 }
423 }
424
425 #[doc(alias = "gtk_column_view_column_set_visible")]
429 #[doc(alias = "visible")]
430 pub fn set_visible(&self, visible: bool) {
431 unsafe {
432 ffi::gtk_column_view_column_set_visible(self.to_glib_none().0, visible.into_glib());
433 }
434 }
435
436 #[doc(alias = "column-view")]
437 pub fn connect_column_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
438 unsafe extern "C" fn notify_column_view_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
439 this: *mut ffi::GtkColumnViewColumn,
440 _param_spec: glib::ffi::gpointer,
441 f: glib::ffi::gpointer,
442 ) {
443 unsafe {
444 let f: &F = &*(f as *const F);
445 f(&from_glib_borrow(this))
446 }
447 }
448 unsafe {
449 let f: Box_<F> = Box_::new(f);
450 connect_raw(
451 self.as_ptr() as *mut _,
452 c"notify::column-view".as_ptr(),
453 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
454 notify_column_view_trampoline::<F> as *const (),
455 )),
456 Box_::into_raw(f),
457 )
458 }
459 }
460
461 #[doc(alias = "expand")]
462 pub fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
463 unsafe extern "C" fn notify_expand_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
464 this: *mut ffi::GtkColumnViewColumn,
465 _param_spec: glib::ffi::gpointer,
466 f: glib::ffi::gpointer,
467 ) {
468 unsafe {
469 let f: &F = &*(f as *const F);
470 f(&from_glib_borrow(this))
471 }
472 }
473 unsafe {
474 let f: Box_<F> = Box_::new(f);
475 connect_raw(
476 self.as_ptr() as *mut _,
477 c"notify::expand".as_ptr(),
478 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
479 notify_expand_trampoline::<F> as *const (),
480 )),
481 Box_::into_raw(f),
482 )
483 }
484 }
485
486 #[doc(alias = "factory")]
487 pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
488 unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
489 this: *mut ffi::GtkColumnViewColumn,
490 _param_spec: glib::ffi::gpointer,
491 f: glib::ffi::gpointer,
492 ) {
493 unsafe {
494 let f: &F = &*(f as *const F);
495 f(&from_glib_borrow(this))
496 }
497 }
498 unsafe {
499 let f: Box_<F> = Box_::new(f);
500 connect_raw(
501 self.as_ptr() as *mut _,
502 c"notify::factory".as_ptr(),
503 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
504 notify_factory_trampoline::<F> as *const (),
505 )),
506 Box_::into_raw(f),
507 )
508 }
509 }
510
511 #[doc(alias = "fixed-width")]
512 pub fn connect_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
513 unsafe extern "C" fn notify_fixed_width_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
514 this: *mut ffi::GtkColumnViewColumn,
515 _param_spec: glib::ffi::gpointer,
516 f: glib::ffi::gpointer,
517 ) {
518 unsafe {
519 let f: &F = &*(f as *const F);
520 f(&from_glib_borrow(this))
521 }
522 }
523 unsafe {
524 let f: Box_<F> = Box_::new(f);
525 connect_raw(
526 self.as_ptr() as *mut _,
527 c"notify::fixed-width".as_ptr(),
528 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
529 notify_fixed_width_trampoline::<F> as *const (),
530 )),
531 Box_::into_raw(f),
532 )
533 }
534 }
535
536 #[doc(alias = "header-menu")]
537 pub fn connect_header_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
538 unsafe extern "C" fn notify_header_menu_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
539 this: *mut ffi::GtkColumnViewColumn,
540 _param_spec: glib::ffi::gpointer,
541 f: glib::ffi::gpointer,
542 ) {
543 unsafe {
544 let f: &F = &*(f as *const F);
545 f(&from_glib_borrow(this))
546 }
547 }
548 unsafe {
549 let f: Box_<F> = Box_::new(f);
550 connect_raw(
551 self.as_ptr() as *mut _,
552 c"notify::header-menu".as_ptr(),
553 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
554 notify_header_menu_trampoline::<F> as *const (),
555 )),
556 Box_::into_raw(f),
557 )
558 }
559 }
560
561 #[cfg(feature = "v4_10")]
562 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
563 #[doc(alias = "id")]
564 pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
565 unsafe extern "C" fn notify_id_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
566 this: *mut ffi::GtkColumnViewColumn,
567 _param_spec: glib::ffi::gpointer,
568 f: glib::ffi::gpointer,
569 ) {
570 unsafe {
571 let f: &F = &*(f as *const F);
572 f(&from_glib_borrow(this))
573 }
574 }
575 unsafe {
576 let f: Box_<F> = Box_::new(f);
577 connect_raw(
578 self.as_ptr() as *mut _,
579 c"notify::id".as_ptr(),
580 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
581 notify_id_trampoline::<F> as *const (),
582 )),
583 Box_::into_raw(f),
584 )
585 }
586 }
587
588 #[doc(alias = "resizable")]
589 pub fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
590 unsafe extern "C" fn notify_resizable_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
591 this: *mut ffi::GtkColumnViewColumn,
592 _param_spec: glib::ffi::gpointer,
593 f: glib::ffi::gpointer,
594 ) {
595 unsafe {
596 let f: &F = &*(f as *const F);
597 f(&from_glib_borrow(this))
598 }
599 }
600 unsafe {
601 let f: Box_<F> = Box_::new(f);
602 connect_raw(
603 self.as_ptr() as *mut _,
604 c"notify::resizable".as_ptr(),
605 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
606 notify_resizable_trampoline::<F> as *const (),
607 )),
608 Box_::into_raw(f),
609 )
610 }
611 }
612
613 #[doc(alias = "sorter")]
614 pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
615 unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
616 this: *mut ffi::GtkColumnViewColumn,
617 _param_spec: glib::ffi::gpointer,
618 f: glib::ffi::gpointer,
619 ) {
620 unsafe {
621 let f: &F = &*(f as *const F);
622 f(&from_glib_borrow(this))
623 }
624 }
625 unsafe {
626 let f: Box_<F> = Box_::new(f);
627 connect_raw(
628 self.as_ptr() as *mut _,
629 c"notify::sorter".as_ptr(),
630 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
631 notify_sorter_trampoline::<F> as *const (),
632 )),
633 Box_::into_raw(f),
634 )
635 }
636 }
637
638 #[doc(alias = "title")]
639 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
640 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
641 this: *mut ffi::GtkColumnViewColumn,
642 _param_spec: glib::ffi::gpointer,
643 f: glib::ffi::gpointer,
644 ) {
645 unsafe {
646 let f: &F = &*(f as *const F);
647 f(&from_glib_borrow(this))
648 }
649 }
650 unsafe {
651 let f: Box_<F> = Box_::new(f);
652 connect_raw(
653 self.as_ptr() as *mut _,
654 c"notify::title".as_ptr(),
655 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
656 notify_title_trampoline::<F> as *const (),
657 )),
658 Box_::into_raw(f),
659 )
660 }
661 }
662
663 #[doc(alias = "visible")]
664 pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
665 unsafe extern "C" fn notify_visible_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
666 this: *mut ffi::GtkColumnViewColumn,
667 _param_spec: glib::ffi::gpointer,
668 f: glib::ffi::gpointer,
669 ) {
670 unsafe {
671 let f: &F = &*(f as *const F);
672 f(&from_glib_borrow(this))
673 }
674 }
675 unsafe {
676 let f: Box_<F> = Box_::new(f);
677 connect_raw(
678 self.as_ptr() as *mut _,
679 c"notify::visible".as_ptr(),
680 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
681 notify_visible_trampoline::<F> as *const (),
682 )),
683 Box_::into_raw(f),
684 )
685 }
686 }
687}
688
689impl Default for ColumnViewColumn {
690 fn default() -> Self {
691 glib::object::Object::new::<Self>()
692 }
693}
694
695#[must_use = "The builder must be built to be used"]
700pub struct ColumnViewColumnBuilder {
701 builder: glib::object::ObjectBuilder<'static, ColumnViewColumn>,
702}
703
704impl ColumnViewColumnBuilder {
705 fn new() -> Self {
706 Self {
707 builder: glib::object::Object::builder(),
708 }
709 }
710
711 pub fn expand(self, expand: bool) -> Self {
713 Self {
714 builder: self.builder.property("expand", expand),
715 }
716 }
717
718 pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
722 Self {
723 builder: self.builder.property("factory", factory.clone().upcast()),
724 }
725 }
726
727 pub fn fixed_width(self, fixed_width: i32) -> Self {
730 Self {
731 builder: self.builder.property("fixed-width", fixed_width),
732 }
733 }
734
735 pub fn header_menu(self, header_menu: &impl IsA<gio::MenuModel>) -> Self {
737 Self {
738 builder: self
739 .builder
740 .property("header-menu", header_menu.clone().upcast()),
741 }
742 }
743
744 #[cfg(feature = "v4_10")]
752 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
753 pub fn id(self, id: impl Into<glib::GString>) -> Self {
754 Self {
755 builder: self.builder.property("id", id.into()),
756 }
757 }
758
759 pub fn resizable(self, resizable: bool) -> Self {
761 Self {
762 builder: self.builder.property("resizable", resizable),
763 }
764 }
765
766 pub fn sorter(self, sorter: &impl IsA<Sorter>) -> Self {
768 Self {
769 builder: self.builder.property("sorter", sorter.clone().upcast()),
770 }
771 }
772
773 pub fn title(self, title: impl Into<glib::GString>) -> Self {
775 Self {
776 builder: self.builder.property("title", title.into()),
777 }
778 }
779
780 pub fn visible(self, visible: bool) -> Self {
782 Self {
783 builder: self.builder.property("visible", visible),
784 }
785 }
786
787 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
790 pub fn build(self) -> ColumnViewColumn {
791 assert_initialized_main_thread!();
792 self.builder.build()
793 }
794}