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