1use crate::{ffi, Buildable};
6use glib::translate::*;
7
8glib::wrapper! {
9 #[doc(alias = "GtkStringList")]
10 pub struct StringList(Object<ffi::GtkStringList, ffi::GtkStringListClass>) @implements gio::ListModel, Buildable;
11
12 match fn {
13 type_ => || ffi::gtk_string_list_get_type(),
14 }
15}
16
17impl StringList {
18 #[doc(alias = "gtk_string_list_new")]
19 pub fn new(strings: &[&str]) -> StringList {
20 assert_initialized_main_thread!();
21 unsafe { from_glib_full(ffi::gtk_string_list_new(strings.to_glib_none().0)) }
22 }
23
24 #[doc(alias = "gtk_string_list_append")]
25 pub fn append(&self, string: &str) {
26 unsafe {
27 ffi::gtk_string_list_append(self.to_glib_none().0, string.to_glib_none().0);
28 }
29 }
30
31 #[cfg(feature = "v4_18")]
32 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
33 #[doc(alias = "gtk_string_list_find")]
34 pub fn find(&self, string: &str) -> u32 {
35 unsafe { ffi::gtk_string_list_find(self.to_glib_none().0, string.to_glib_none().0) }
36 }
37
38 #[doc(alias = "gtk_string_list_get_string")]
39 #[doc(alias = "get_string")]
40 pub fn string(&self, position: u32) -> Option<glib::GString> {
41 unsafe {
42 from_glib_none(ffi::gtk_string_list_get_string(
43 self.to_glib_none().0,
44 position,
45 ))
46 }
47 }
48
49 #[doc(alias = "gtk_string_list_remove")]
50 pub fn remove(&self, position: u32) {
51 unsafe {
52 ffi::gtk_string_list_remove(self.to_glib_none().0, position);
53 }
54 }
55
56 #[doc(alias = "gtk_string_list_splice")]
57 pub fn splice(&self, position: u32, n_removals: u32, additions: &[&str]) {
58 unsafe {
59 ffi::gtk_string_list_splice(
60 self.to_glib_none().0,
61 position,
62 n_removals,
63 additions.to_glib_none().0,
64 );
65 }
66 }
67}