1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
// Take a look at the license at the top of the repository in the LICENSE file.
use glib::translate::*;
use crate::{prelude::*, CellRenderer, TreeView, TreeViewColumn, TreeViewColumnSizing};
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::TreeView>> Sealed for T {}
}
// rustdoc-stripper-ignore-next
/// Trait containing manually implemented methods of
/// [`TreeView`](crate::TreeView).
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
pub trait TreeViewExtManual: sealed::Sealed + IsA<TreeView> + 'static {
/// Creates a new [`TreeViewColumn`][crate::TreeViewColumn] and inserts it into the @self at
/// @position. If @position is -1, then the newly created column is inserted at
/// the end. The column is initialized with the attributes given. If @self
/// has “fixed_height” mode enabled, then the new column will have its sizing
/// property set to be GTK_TREE_VIEW_COLUMN_FIXED.
///
/// # Deprecated since 4.10
///
/// Use [`ListView`][crate::ListView] or [`ColumnView`][crate::ColumnView] instead
/// ## `position`
/// The position to insert the new column in
/// ## `title`
/// The title to set the header to
/// ## `cell`
/// The [`CellRenderer`][crate::CellRenderer]
///
/// # Returns
///
/// The number of columns in @self after insertion.
#[doc(alias = "gtk_tree_view_insert_column_with_attributes")]
fn insert_column_with_attributes(
&self,
position: i32,
title: &str,
cell: &impl IsA<CellRenderer>,
attributes: &[(&str, i32)],
) -> i32 {
let column = TreeViewColumn::new();
if self.as_ref().is_fixed_height_mode() {
column.set_sizing(TreeViewColumnSizing::Fixed);
}
column.set_title(title);
column.pack_start(cell, true);
attributes.iter().for_each(|(attribute, column_id)| {
column.add_attribute(cell, attribute, *column_id);
});
self.as_ref().insert_column(&column, position)
}
#[doc(alias = "gtk_tree_view_set_row_separator_func")]
#[doc(alias = "set_row_separator_func")]
fn unset_row_separator_func(&self) {
unsafe {
ffi::gtk_tree_view_set_row_separator_func(
self.as_ref().to_glib_none().0,
None,
std::ptr::null_mut(),
None,
);
}
}
}
impl<O: IsA<TreeView>> TreeViewExtManual for O {}