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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

#[cfg(feature = "v3_30")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_30")))]
use glib::{prelude::*, translate::*};
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `base-model`
    ///  The "base-model" property is the [`gio::ListModel`][crate::gio::ListModel] that will be wrapped.
    ///
    /// This base model is not accessible after creation so that API creators can
    /// be sure the consumer cannot mutate the underlying model. That is useful
    /// when you want to give a caller access to a [`gio::ListModel`][crate::gio::ListModel] without the ability
    /// to introspect on the type and mutate it without your knowledge (such as
    /// with `GListStore`).
    ///
    /// Writeable | Construct Only
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`], [`trait@gio::prelude::ListModelExt`]
    #[doc(alias = "DzlReadOnlyListModel")]
    pub struct ReadOnlyListModel(Object<ffi::DzlReadOnlyListModel, ffi::DzlReadOnlyListModelClass>) @implements gio::ListModel;

    match fn {
        type_ => || ffi::dzl_read_only_list_model_get_type(),
    }
}

impl ReadOnlyListModel {
    /// Creates a new [`ReadOnlyListModel`][crate::ReadOnlyListModel] which is a read-only wrapper around
    /// `base_model`. This is useful when you want to give API consumers access to
    /// a [`gio::ListModel`][crate::gio::ListModel] but without the ability to mutate the underlying list.
    /// ## `base_model`
    /// a [`gio::ListModel`][crate::gio::ListModel]
    ///
    /// # Returns
    ///
    /// a [`ReadOnlyListModel`][crate::ReadOnlyListModel]
    #[cfg(feature = "v3_30")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v3_30")))]
    #[doc(alias = "dzl_read_only_list_model_new")]
    pub fn new(base_model: &impl IsA<gio::ListModel>) -> Option<gio::ListModel> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::dzl_read_only_list_model_new(
                base_model.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl fmt::Display for ReadOnlyListModel {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("ReadOnlyListModel")
    }
}