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
use crate::prelude::*;
use crate::{TreeIter, TreeModel};
use glib::translate::*;
use glib::value::FromValue;
use glib::IsA;
pub trait TreeModelExtManual: 'static {
#[doc(alias = "gtk_tree_model_get")]
#[doc(alias = "gtk_tree_model_get_value")]
#[doc(alias = "gtk_tree_model_get_valist")]
fn get_value(&self, iter: &TreeIter, column: i32) -> glib::Value;
#[doc(alias = "gtk_tree_model_get")]
#[doc(alias = "gtk_tree_model_get_value")]
#[doc(alias = "gtk_tree_model_get_valist")]
fn get<V: for<'b> FromValue<'b> + 'static>(&self, iter: &TreeIter, column: i32) -> V;
}
impl<O: IsA<TreeModel>> TreeModelExtManual for O {
fn get_value(&self, iter: &TreeIter, column: i32) -> glib::Value {
let total_columns = self.as_ref().n_columns();
assert!(
column < total_columns,
"TreeModel has {} columns but TreeModelExt::get got {} passed as a column number",
total_columns,
column
);
unsafe {
let mut value = glib::Value::uninitialized();
ffi::gtk_tree_model_get_value(
self.as_ref().to_glib_none().0,
mut_override(iter.to_glib_none().0),
column,
value.to_glib_none_mut().0,
);
value
}
}
fn get<V: for<'b> FromValue<'b> + 'static>(&self, iter: &TreeIter, column: i32) -> V {
let value = self.get_value(iter, column);
value
.get_owned::<V>()
.expect("Failed to get TreeModel value")
}
}