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