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")]
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 let f: &F = &*(f as *const F);
449 f(&from_glib_borrow(this))
450 }
451 unsafe {
452 let f: Box_<F> = Box_::new(f);
453 connect_raw(
454 self.as_ptr() as *mut _,
455 c"notify::column-view".as_ptr() as *const _,
456 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
457 notify_column_view_trampoline::<F> as *const (),
458 )),
459 Box_::into_raw(f),
460 )
461 }
462 }
463
464 #[doc(alias = "expand")]
465 pub fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
466 unsafe extern "C" fn notify_expand_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
467 this: *mut ffi::GtkColumnViewColumn,
468 _param_spec: glib::ffi::gpointer,
469 f: glib::ffi::gpointer,
470 ) {
471 let f: &F = &*(f as *const F);
472 f(&from_glib_borrow(this))
473 }
474 unsafe {
475 let f: Box_<F> = Box_::new(f);
476 connect_raw(
477 self.as_ptr() as *mut _,
478 c"notify::expand".as_ptr() as *const _,
479 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480 notify_expand_trampoline::<F> as *const (),
481 )),
482 Box_::into_raw(f),
483 )
484 }
485 }
486
487 #[doc(alias = "factory")]
488 pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
489 unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
490 this: *mut ffi::GtkColumnViewColumn,
491 _param_spec: glib::ffi::gpointer,
492 f: glib::ffi::gpointer,
493 ) {
494 let f: &F = &*(f as *const F);
495 f(&from_glib_borrow(this))
496 }
497 unsafe {
498 let f: Box_<F> = Box_::new(f);
499 connect_raw(
500 self.as_ptr() as *mut _,
501 c"notify::factory".as_ptr() as *const _,
502 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
503 notify_factory_trampoline::<F> as *const (),
504 )),
505 Box_::into_raw(f),
506 )
507 }
508 }
509
510 #[doc(alias = "fixed-width")]
511 pub fn connect_fixed_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
512 unsafe extern "C" fn notify_fixed_width_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
513 this: *mut ffi::GtkColumnViewColumn,
514 _param_spec: glib::ffi::gpointer,
515 f: glib::ffi::gpointer,
516 ) {
517 let f: &F = &*(f as *const F);
518 f(&from_glib_borrow(this))
519 }
520 unsafe {
521 let f: Box_<F> = Box_::new(f);
522 connect_raw(
523 self.as_ptr() as *mut _,
524 c"notify::fixed-width".as_ptr() as *const _,
525 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
526 notify_fixed_width_trampoline::<F> as *const (),
527 )),
528 Box_::into_raw(f),
529 )
530 }
531 }
532
533 #[doc(alias = "header-menu")]
534 pub fn connect_header_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
535 unsafe extern "C" fn notify_header_menu_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
536 this: *mut ffi::GtkColumnViewColumn,
537 _param_spec: glib::ffi::gpointer,
538 f: glib::ffi::gpointer,
539 ) {
540 let f: &F = &*(f as *const F);
541 f(&from_glib_borrow(this))
542 }
543 unsafe {
544 let f: Box_<F> = Box_::new(f);
545 connect_raw(
546 self.as_ptr() as *mut _,
547 c"notify::header-menu".as_ptr() as *const _,
548 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
549 notify_header_menu_trampoline::<F> as *const (),
550 )),
551 Box_::into_raw(f),
552 )
553 }
554 }
555
556 #[cfg(feature = "v4_10")]
557 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
558 #[doc(alias = "id")]
559 pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
560 unsafe extern "C" fn notify_id_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
561 this: *mut ffi::GtkColumnViewColumn,
562 _param_spec: glib::ffi::gpointer,
563 f: glib::ffi::gpointer,
564 ) {
565 let f: &F = &*(f as *const F);
566 f(&from_glib_borrow(this))
567 }
568 unsafe {
569 let f: Box_<F> = Box_::new(f);
570 connect_raw(
571 self.as_ptr() as *mut _,
572 c"notify::id".as_ptr() as *const _,
573 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
574 notify_id_trampoline::<F> as *const (),
575 )),
576 Box_::into_raw(f),
577 )
578 }
579 }
580
581 #[doc(alias = "resizable")]
582 pub fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
583 unsafe extern "C" fn notify_resizable_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
584 this: *mut ffi::GtkColumnViewColumn,
585 _param_spec: glib::ffi::gpointer,
586 f: glib::ffi::gpointer,
587 ) {
588 let f: &F = &*(f as *const F);
589 f(&from_glib_borrow(this))
590 }
591 unsafe {
592 let f: Box_<F> = Box_::new(f);
593 connect_raw(
594 self.as_ptr() as *mut _,
595 c"notify::resizable".as_ptr() as *const _,
596 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
597 notify_resizable_trampoline::<F> as *const (),
598 )),
599 Box_::into_raw(f),
600 )
601 }
602 }
603
604 #[doc(alias = "sorter")]
605 pub fn connect_sorter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
606 unsafe extern "C" fn notify_sorter_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
607 this: *mut ffi::GtkColumnViewColumn,
608 _param_spec: glib::ffi::gpointer,
609 f: glib::ffi::gpointer,
610 ) {
611 let f: &F = &*(f as *const F);
612 f(&from_glib_borrow(this))
613 }
614 unsafe {
615 let f: Box_<F> = Box_::new(f);
616 connect_raw(
617 self.as_ptr() as *mut _,
618 c"notify::sorter".as_ptr() as *const _,
619 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
620 notify_sorter_trampoline::<F> as *const (),
621 )),
622 Box_::into_raw(f),
623 )
624 }
625 }
626
627 #[doc(alias = "title")]
628 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
629 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
630 this: *mut ffi::GtkColumnViewColumn,
631 _param_spec: glib::ffi::gpointer,
632 f: glib::ffi::gpointer,
633 ) {
634 let f: &F = &*(f as *const F);
635 f(&from_glib_borrow(this))
636 }
637 unsafe {
638 let f: Box_<F> = Box_::new(f);
639 connect_raw(
640 self.as_ptr() as *mut _,
641 c"notify::title".as_ptr() as *const _,
642 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
643 notify_title_trampoline::<F> as *const (),
644 )),
645 Box_::into_raw(f),
646 )
647 }
648 }
649
650 #[doc(alias = "visible")]
651 pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
652 unsafe extern "C" fn notify_visible_trampoline<F: Fn(&ColumnViewColumn) + 'static>(
653 this: *mut ffi::GtkColumnViewColumn,
654 _param_spec: glib::ffi::gpointer,
655 f: glib::ffi::gpointer,
656 ) {
657 let f: &F = &*(f as *const F);
658 f(&from_glib_borrow(this))
659 }
660 unsafe {
661 let f: Box_<F> = Box_::new(f);
662 connect_raw(
663 self.as_ptr() as *mut _,
664 c"notify::visible".as_ptr() as *const _,
665 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
666 notify_visible_trampoline::<F> as *const (),
667 )),
668 Box_::into_raw(f),
669 )
670 }
671 }
672}
673
674impl Default for ColumnViewColumn {
675 fn default() -> Self {
676 glib::object::Object::new::<Self>()
677 }
678}
679
680#[must_use = "The builder must be built to be used"]
685pub struct ColumnViewColumnBuilder {
686 builder: glib::object::ObjectBuilder<'static, ColumnViewColumn>,
687}
688
689impl ColumnViewColumnBuilder {
690 fn new() -> Self {
691 Self {
692 builder: glib::object::Object::builder(),
693 }
694 }
695
696 pub fn expand(self, expand: bool) -> Self {
698 Self {
699 builder: self.builder.property("expand", expand),
700 }
701 }
702
703 pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
707 Self {
708 builder: self.builder.property("factory", factory.clone().upcast()),
709 }
710 }
711
712 pub fn fixed_width(self, fixed_width: i32) -> Self {
715 Self {
716 builder: self.builder.property("fixed-width", fixed_width),
717 }
718 }
719
720 pub fn header_menu(self, header_menu: &impl IsA<gio::MenuModel>) -> Self {
722 Self {
723 builder: self
724 .builder
725 .property("header-menu", header_menu.clone().upcast()),
726 }
727 }
728
729 #[cfg(feature = "v4_10")]
737 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
738 pub fn id(self, id: impl Into<glib::GString>) -> Self {
739 Self {
740 builder: self.builder.property("id", id.into()),
741 }
742 }
743
744 pub fn resizable(self, resizable: bool) -> Self {
746 Self {
747 builder: self.builder.property("resizable", resizable),
748 }
749 }
750
751 pub fn sorter(self, sorter: &impl IsA<Sorter>) -> Self {
753 Self {
754 builder: self.builder.property("sorter", sorter.clone().upcast()),
755 }
756 }
757
758 pub fn title(self, title: impl Into<glib::GString>) -> Self {
760 Self {
761 builder: self.builder.property("title", title.into()),
762 }
763 }
764
765 pub fn visible(self, visible: bool) -> Self {
767 Self {
768 builder: self.builder.property("visible", visible),
769 }
770 }
771
772 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
775 pub fn build(self) -> ColumnViewColumn {
776 assert_initialized_main_thread!();
777 self.builder.build()
778 }
779}