[go: up one dir, main page]

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    #[doc(alias = "gtk_tree_view_insert_column_with_attributes")]
14    fn insert_column_with_attributes(
15        &self,
16        position: i32,
17        title: &str,
18        cell: &impl IsA<CellRenderer>,
19        attributes: &[(&str, i32)],
20    ) -> i32 {
21        let column = TreeViewColumn::new();
22        if self.as_ref().is_fixed_height_mode() {
23            column.set_sizing(TreeViewColumnSizing::Fixed);
24        }
25        column.set_title(title);
26        column.pack_start(cell, true);
27        attributes.iter().for_each(|(attribute, column_id)| {
28            column.add_attribute(cell, attribute, *column_id);
29        });
30        self.as_ref().insert_column(&column, position)
31    }
32
33    #[doc(alias = "gtk_tree_view_set_row_separator_func")]
34    #[doc(alias = "set_row_separator_func")]
35    fn unset_row_separator_func(&self) {
36        unsafe {
37            ffi::gtk_tree_view_set_row_separator_func(
38                self.as_ref().to_glib_none().0,
39                None,
40                std::ptr::null_mut(),
41                None,
42            );
43        }
44    }
45}
46
47impl<O: IsA<TreeView>> TreeViewExtManual for O {}