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 /// Creates a new [`TreeViewColumn`][crate::TreeViewColumn] and inserts it into the @self at
19 /// @position. If @position is -1, then the newly created column is inserted at
20 /// the end. The column is initialized with the attributes given. If @self
21 /// has “fixed_height” mode enabled, then the new column will have its sizing
22 /// property set to be GTK_TREE_VIEW_COLUMN_FIXED.
23 ///
24 /// # Deprecated since 4.10
25 ///
26 /// Use [`ListView`][crate::ListView] or [`ColumnView`][crate::ColumnView] instead
27 /// ## `position`
28 /// The position to insert the new column in
29 /// ## `title`
30 /// The title to set the header to
31 /// ## `cell`
32 /// The [`CellRenderer`][crate::CellRenderer]
33 ///
34 /// # Returns
35 ///
36 /// The number of columns in @self after insertion.
37 #[doc(alias = "gtk_tree_view_insert_column_with_attributes")]
38 fn insert_column_with_attributes(
39 &self,
40 position: i32,
41 title: &str,
42 cell: &impl IsA<CellRenderer>,
43 attributes: &[(&str, i32)],
44 ) -> i32 {
45 let column = TreeViewColumn::new();
46 if self.as_ref().is_fixed_height_mode() {
47 column.set_sizing(TreeViewColumnSizing::Fixed);
48 }
49 column.set_title(title);
50 column.pack_start(cell, true);
51 attributes.iter().for_each(|(attribute, column_id)| {
52 column.add_attribute(cell, attribute, *column_id);
53 });
54 self.as_ref().insert_column(&column, position)
55 }
56
57 #[doc(alias = "gtk_tree_view_set_row_separator_func")]
58 #[doc(alias = "set_row_separator_func")]
59 fn unset_row_separator_func(&self) {
60 unsafe {
61 ffi::gtk_tree_view_set_row_separator_func(
62 self.as_ref().to_glib_none().0,
63 None,
64 std::ptr::null_mut(),
65 None,
66 );
67 }
68 }
69}
70
71impl<O: IsA<TreeView>> TreeViewExtManual for O {}