Skip to main content

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::{CellRenderer, TreeView, TreeViewColumn, TreeViewColumnSizing, ffi, prelude::*};
6
7// rustdoc-stripper-ignore-next
8/// Trait containing manually implemented methods of
9/// [`TreeView`](crate::TreeView).
10#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
11#[allow(deprecated)]
12pub trait TreeViewExtManual: IsA<TreeView> + 'static {
13    ///  mode enabled, then the new column will have its sizing
14    /// property set to be GTK_TREE_VIEW_COLUMN_FIXED.
15    ///
16    /// # Deprecated since 4.10
17    ///
18    /// Use [`ListView`][crate::ListView] or [`ColumnView`][crate::ColumnView] instead
19    /// ## `position`
20    /// The position to insert the new column in
21    /// ## `title`
22    /// The title to set the header to
23    /// ## `cell`
24    /// The [`CellRenderer`][crate::CellRenderer]
25    ///
26    /// # Returns
27    ///
28    /// The number of columns in @self after insertion.
29    #[doc(alias = "gtk_tree_view_insert_column_with_attributes")]
30    fn insert_column_with_attributes(
31        &self,
32        position: i32,
33        title: &str,
34        cell: &impl IsA<CellRenderer>,
35        attributes: &[(&str, i32)],
36    ) -> i32 {
37        let column = TreeViewColumn::new();
38        if self.as_ref().is_fixed_height_mode() {
39            column.set_sizing(TreeViewColumnSizing::Fixed);
40        }
41        column.set_title(title);
42        column.pack_start(cell, true);
43        attributes.iter().for_each(|(attribute, column_id)| {
44            column.add_attribute(cell, attribute, *column_id);
45        });
46        self.as_ref().insert_column(&column, position)
47    }
48
49    #[doc(alias = "gtk_tree_view_set_row_separator_func")]
50    #[doc(alias = "set_row_separator_func")]
51    fn unset_row_separator_func(&self) {
52        unsafe {
53            ffi::gtk_tree_view_set_row_separator_func(
54                self.as_ref().to_glib_none().0,
55                None,
56                std::ptr::null_mut(),
57                None,
58            );
59        }
60    }
61}
62
63impl<O: IsA<TreeView>> TreeViewExtManual for O {}