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")]
341 #[doc(alias = "fixed-width")]
342 pub fn set_fixed_width(&self, fixed_width: i32) {
343 unsafe {
344 ffi::gtk_column_view_column_set_fixed_width(self.to_glib_none().0, fixed_width);
345 }
346 }
347
348 #[doc(alias = "gtk_column_view_column_set_header_menu")]
353 #[doc(alias = "header-menu")]
354 pub fn set_header_menu(&self, menu: Option<&impl IsA<gio::MenuModel>>) {
355 unsafe {
356 ffi::gtk_column_view_column_set_header_menu(
357 self.to_glib_none().0,
358 menu.map(|p| p.as_ref()).to_glib_none().0,
359 );
360 }
361 }
362
363 #[cfg(feature = "v4_10")]
372 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
373 #[doc(alias = "gtk_column_view_column_set_id")]
374 #[doc(alias = "id")]
375 pub fn set_id(&self, id: Option<&str>) {
376 unsafe {
377 ffi::gtk_column_view_column_set_id(self.to_glib_none().0, id.to_glib_none().0);
378 }
379 }
380
381 #[doc(alias = "gtk_column_view_column_set_resizable")]
385 #[doc(alias = "resizable")]
386 pub fn set_resizable(&self, resizable: bool) {
387 unsafe {
388 ffi::gtk_column_view_column_set_resizable(self.to_glib_none().0, resizable.into_glib());
389 }
390 }
391
392 #[doc(alias = "gtk_column_view_column_set_sorter")]
405 #[doc(alias = "sorter")]
406 pub fn set_sorter(&self, sorter: Option<&impl IsA<Sorter>>) {
407 unsafe {
408 ffi::gtk_column_view_column_set_sorter(
409 self.to_glib_none().0,
410 sorter.map(|p| p.as_ref()).to_glib_none().0,
411 );
412 }
413 }
414
415 #[doc(alias = "gtk_column_view_column_set_title")]
423 #[doc(alias = "title")]
424 pub fn set_title(&self, title: Option<&str>) {
425 unsafe {
426 ffi::gtk_column_view_column_set_title(self.to_glib_none().0, title.to_glib_none().0);
427 }
428 }
429
430 #[doc(alias = "gtk_column_view_column_set_visible")]
434 #[doc(alias = "visible")]
435 pub fn set_visible(&self, visible: bool) {
436 unsafe {
437 ffi::gtk_column_view_column_set_visible(self.to_glib_none().0, visible.into_glib());
438 }
439 }
440
441 #[doc(alias = "column-view")]
442 pub fn connect_column_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
443 unsafe extern "C" fn notify_column_view_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
444 this: *mut ffi::GtkColumnViewColumn,
445 _param_spec: glib::ffi::gpointer,
446 f: glib::ffi::gpointer,
447 ) {
448 unsafe {
449 let f: &F = &*(f as *const F);
450 f(&from_glib_borrow(this))
451 }
452 }
453 unsafe {
454 let f: Box_<F> = Box_::new(f);
455 connect_raw(
456 self.as_ptr() as *mut _,
457 c"notify::column-view".as_ptr() as *const _,
458 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459 notify_column_view_trampoline::<F> as *const (),
460 )),
461 Box_::into_raw(f),
462 )
463 }
464 }
465
466 #[doc(alias = "expand")]
467 pub fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
468 unsafe extern "C" fn notify_expand_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
469 this: *mut ffi::GtkColumnViewColumn,
470 _param_spec: glib::ffi::gpointer,
471 f: glib::ffi::gpointer,
472 ) {
473 unsafe {
474 let f: &F = &*(f as *const F);
475 f(&from_glib_borrow(this))
476 }
477 }
478 unsafe {
479 let f: Box_<F> = Box_::new(f);
480 connect_raw(
481 self.as_ptr() as *mut _,
482 c"notify::expand".as_ptr() as *const _,
483 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
484 notify_expand_trampoline::<F> as *const (),
485 )),
486 Box_::into_raw(f),
487 )
488 }
489 }
490
491 #[doc(alias = "factory")]
492 pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
493 unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
494 this: *mut ffi::GtkColumnViewColumn,
495 _param_spec: glib::ffi::gpointer,
496 f: glib::ffi::gpointer,
497 ) {
498 unsafe {
499 let f: &F = &*(f as *const F);
500 f(&from_glib_borrow(this))
501 }
502 }
503 unsafe {
504 let f: Box_<F> = Box_::new(f);
505 connect_raw(
506 self.as_ptr() as *mut _,
507 c"notify::factory".as_ptr() as *const _,
508 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
509 notify_factory_trampoline::<F> as *const (),
510 )),
511 Box_::into_raw(f),
512 )
513 }
514 }
515
516 #[doc(alias = "fixed-width")]
517 pub fn connect_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
518 unsafe extern "C" fn notify_fixed_width_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
519 this: *mut ffi::GtkColumnViewColumn,
520 _param_spec: glib::ffi::gpointer,
521 f: glib::ffi::gpointer,
522 ) {
523 unsafe {
524 let f: &F = &*(f as *const F);
525 f(&from_glib_borrow(this))
526 }
527 }
528 unsafe {
529 let f: Box_<F> = Box_::new(f);
530 connect_raw(
531 self.as_ptr() as *mut _,
532 c"notify::fixed-width".as_ptr() as *const _,
533 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
534 notify_fixed_width_trampoline::<F> as *const (),
535 )),
536 Box_::into_raw(f),
537 )
538 }
539 }
540
541 #[doc(alias = "header-menu")]
542 pub fn connect_header_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
543 unsafe extern "C" fn notify_header_menu_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
544 this: *mut ffi::GtkColumnViewColumn,
545 _param_spec: glib::ffi::gpointer,
546 f: glib::ffi::gpointer,
547 ) {
548 unsafe {
549 let f: &F = &*(f as *const F);
550 f(&from_glib_borrow(this))
551 }
552 }
553 unsafe {
554 let f: Box_<F> = Box_::new(f);
555 connect_raw(
556 self.as_ptr() as *mut _,
557 c"notify::header-menu".as_ptr() as *const _,
558 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
559 notify_header_menu_trampoline::<F> as *const (),
560 )),
561 Box_::into_raw(f),
562 )
563 }
564 }
565
566 #[cfg(feature = "v4_10")]
567 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
568 #[doc(alias = "id")]
569 pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
570 unsafe extern "C" fn notify_id_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
571 this: *mut ffi::GtkColumnViewColumn,
572 _param_spec: glib::ffi::gpointer,
573 f: glib::ffi::gpointer,
574 ) {
575 unsafe {
576 let f: &F = &*(f as *const F);
577 f(&from_glib_borrow(this))
578 }
579 }
580 unsafe {
581 let f: Box_<F> = Box_::new(f);
582 connect_raw(
583 self.as_ptr() as *mut _,
584 c"notify::id".as_ptr() as *const _,
585 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
586 notify_id_trampoline::<F> as *const (),
587 )),
588 Box_::into_raw(f),
589 )
590 }
591 }
592
593 #[doc(alias = "resizable")]
594 pub fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
595 unsafe extern "C" fn notify_resizable_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
596 this: *mut ffi::GtkColumnViewColumn,
597 _param_spec: glib::ffi::gpointer,
598 f: glib::ffi::gpointer,
599 ) {
600 unsafe {
601 let f: &F = &*(f as *const F);
602 f(&from_glib_borrow(this))
603 }
604 }
605 unsafe {
606 let f: Box_<F> = Box_::new(f);
607 connect_raw(
608 self.as_ptr() as *mut _,
609 c"notify::resizable".as_ptr() as *const _,
610 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
611 notify_resizable_trampoline::<F> as *const (),
612 )),
613 Box_::into_raw(f),
614 )
615 }
616 }
617
618 #[doc(alias = "sorter")]
619 pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
620 unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
621 this: *mut ffi::GtkColumnViewColumn,
622 _param_spec: glib::ffi::gpointer,
623 f: glib::ffi::gpointer,
624 ) {
625 unsafe {
626 let f: &F = &*(f as *const F);
627 f(&from_glib_borrow(this))
628 }
629 }
630 unsafe {
631 let f: Box_<F> = Box_::new(f);
632 connect_raw(
633 self.as_ptr() as *mut _,
634 c"notify::sorter".as_ptr() as *const _,
635 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
636 notify_sorter_trampoline::<F> as *const (),
637 )),
638 Box_::into_raw(f),
639 )
640 }
641 }
642
643 #[doc(alias = "title")]
644 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
645 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
646 this: *mut ffi::GtkColumnViewColumn,
647 _param_spec: glib::ffi::gpointer,
648 f: glib::ffi::gpointer,
649 ) {
650 unsafe {
651 let f: &F = &*(f as *const F);
652 f(&from_glib_borrow(this))
653 }
654 }
655 unsafe {
656 let f: Box_<F> = Box_::new(f);
657 connect_raw(
658 self.as_ptr() as *mut _,
659 c"notify::title".as_ptr() as *const _,
660 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
661 notify_title_trampoline::<F> as *const (),
662 )),
663 Box_::into_raw(f),
664 )
665 }
666 }
667
668 #[doc(alias = "visible")]
669 pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
670 unsafe extern "C" fn notify_visible_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
671 this: *mut ffi::GtkColumnViewColumn,
672 _param_spec: glib::ffi::gpointer,
673 f: glib::ffi::gpointer,
674 ) {
675 unsafe {
676 let f: &F = &*(f as *const F);
677 f(&from_glib_borrow(this))
678 }
679 }
680 unsafe {
681 let f: Box_<F> = Box_::new(f);
682 connect_raw(
683 self.as_ptr() as *mut _,
684 c"notify::visible".as_ptr() as *const _,
685 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
686 notify_visible_trampoline::<F> as *const (),
687 )),
688 Box_::into_raw(f),
689 )
690 }
691 }
692}
693
694impl Default for ColumnViewColumn {
695 fn default() -> Self {
696 glib::object::Object::new::<Self>()
697 }
698}
699
700#[must_use = "The builder must be built to be used"]
705pub struct ColumnViewColumnBuilder {
706 builder: glib::object::ObjectBuilder<'static, ColumnViewColumn>,
707}
708
709impl ColumnViewColumnBuilder {
710 fn new() -> Self {
711 Self {
712 builder: glib::object::Object::builder(),
713 }
714 }
715
716 pub fn expand(self, expand: bool) -> Self {
718 Self {
719 builder: self.builder.property("expand", expand),
720 }
721 }
722
723 pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
727 Self {
728 builder: self.builder.property("factory", factory.clone().upcast()),
729 }
730 }
731
732 pub fn fixed_width(self, fixed_width: i32) -> Self {
735 Self {
736 builder: self.builder.property("fixed-width", fixed_width),
737 }
738 }
739
740 pub fn header_menu(self, header_menu: &impl IsA<gio::MenuModel>) -> Self {
742 Self {
743 builder: self
744 .builder
745 .property("header-menu", header_menu.clone().upcast()),
746 }
747 }
748
749 #[cfg(feature = "v4_10")]
757 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
758 pub fn id(self, id: impl Into<glib::GString>) -> Self {
759 Self {
760 builder: self.builder.property("id", id.into()),
761 }
762 }
763
764 pub fn resizable(self, resizable: bool) -> Self {
766 Self {
767 builder: self.builder.property("resizable", resizable),
768 }
769 }
770
771 pub fn sorter(self, sorter: &impl IsA<Sorter>) -> Self {
773 Self {
774 builder: self.builder.property("sorter", sorter.clone().upcast()),
775 }
776 }
777
778 pub fn title(self, title: impl Into<glib::GString>) -> Self {
780 Self {
781 builder: self.builder.property("title", title.into()),
782 }
783 }
784
785 pub fn visible(self, visible: bool) -> Self {
787 Self {
788 builder: self.builder.property("visible", visible),
789 }
790 }
791
792 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
795 pub fn build(self) -> ColumnViewColumn {
796 assert_initialized_main_thread!();
797 self.builder.build()
798 }
799}