gtk4/
tree_view.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, CellRenderer, TreeView, TreeViewColumn, TreeViewColumnSizing};
6
7mod sealed {
8    pub trait Sealed {}
9    impl<T: super::IsA<super::TreeView>> Sealed for T {}
10}
11
12// rustdoc-stripper-ignore-next
13/// Trait containing manually implemented methods of
14/// [`TreeView`](crate::TreeView).
15#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
16#[allow(deprecated)]
17pub trait TreeViewExtManual: sealed::Sealed + IsA<TreeView> + 'static {
18    #[doc(alias = "gtk_tree_view_insert_column_with_attributes")]
19    fn insert_column_with_attributes(
20        &self,
21        position: i32,
22        title: &str,
23        cell: &impl IsA<CellRenderer>,
24        attributes: &[(&str, i32)],
25    ) -> i32 {
26        let column = TreeViewColumn::new();
27        if self.as_ref().is_fixed_height_mode() {
28            column.set_sizing(TreeViewColumnSizing::Fixed);
29        }
30        column.set_title(title);
31        column.pack_start(cell, true);
32        attributes.iter().for_each(|(attribute, column_id)| {
33            column.add_attribute(cell, attribute, *column_id);
34        });
35        self.as_ref().insert_column(&column, position)
36    }
37
38    #[doc(alias = "gtk_tree_view_set_row_separator_func")]
39    #[doc(alias = "set_row_separator_func")]
40    fn unset_row_separator_func(&self) {
41        unsafe {
42            ffi::gtk_tree_view_set_row_separator_func(
43                self.as_ref().to_glib_none().0,
44                None,
45                std::ptr::null_mut(),
46                None,
47            );
48        }
49    }
50}
51
52impl<O: IsA<TreeView>> TreeViewExtManual for O {}