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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
// 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
use crate::ffi;
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// A [`gio::ListModel`][crate::gio::ListModel] representing values of a given enum.
///
/// `BisEnumListModel` contains objects of type [`EnumListItem`][crate::EnumListItem].
///
/// ## Properties
///
///
/// #### `enum-type`
/// The type of the enum represented by the model.
///
/// Readable | Writeable | Construct Only
///
/// # Implements
///
/// [`trait@glib::ObjectExt`], [`trait@gio::prelude::ListModelExt`]
#[doc(alias = "BisEnumListModel")]
pub struct EnumListModel(Object<ffi::BisEnumListModel, ffi::BisEnumListModelClass>) @implements gio::ListModel;
match fn {
type_ => || ffi::bis_enum_list_model_get_type(),
}
}
impl EnumListModel {
/// Creates a new `BisEnumListModel` for @enum_type.
/// ## `enum_type`
/// the type of the enum to construct the model from
///
/// # Returns
///
/// the newly created `BisEnumListModel`
#[doc(alias = "bis_enum_list_model_new")]
pub fn new(enum_type: glib::types::Type) -> EnumListModel {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::bis_enum_list_model_new(enum_type.into_glib())) }
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`EnumListModel`] objects.
///
/// This method returns an instance of [`EnumListModelBuilder`](crate::builders::EnumListModelBuilder) which can be used to create [`EnumListModel`] objects.
pub fn builder() -> EnumListModelBuilder {
EnumListModelBuilder::new()
}
/// Finds the position of a given enum value in @self.
/// ## `value`
/// an enum value
#[doc(alias = "bis_enum_list_model_find_position")]
pub fn find_position(&self, value: i32) -> u32 {
unsafe { ffi::bis_enum_list_model_find_position(self.to_glib_none().0, value) }
}
/// Gets the type of the enum represented by @self.
///
/// # Returns
///
/// the enum type
#[doc(alias = "bis_enum_list_model_get_enum_type")]
#[doc(alias = "get_enum_type")]
#[doc(alias = "enum-type")]
pub fn enum_type(&self) -> glib::types::Type {
unsafe {
from_glib(ffi::bis_enum_list_model_get_enum_type(
self.to_glib_none().0,
))
}
}
}
impl Default for EnumListModel {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`EnumListModel`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct EnumListModelBuilder {
builder: glib::object::ObjectBuilder<'static, EnumListModel>,
}
impl EnumListModelBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
/// The type of the enum represented by the model.
pub fn enum_type(self, enum_type: glib::types::Type) -> Self {
Self {
builder: self.builder.property("enum-type", enum_type),
}
}
// rustdoc-stripper-ignore-next
/// Build the [`EnumListModel`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> EnumListModel {
self.builder.build()
}
}