gtk4/combo_box.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, ComboBox};
6
7mod sealed {
8 pub trait Sealed {}
9 impl<T: super::IsA<super::ComboBox>> Sealed for T {}
10}
11
12// rustdoc-stripper-ignore-next
13/// Trait containing manually implemented methods of
14/// [`ComboBox`](crate::ComboBox).
15#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
16#[allow(deprecated)]
17pub trait ComboBoxExtManual: sealed::Sealed + IsA<ComboBox> + 'static {
18 #[doc(alias = "gtk_combo_box_set_row_separator_func")]
19 #[doc(alias = "set_row_separator_func")]
20 fn unset_row_separator_func(&self) {
21 unsafe {
22 ffi::gtk_combo_box_set_row_separator_func(
23 self.as_ref().to_glib_none().0,
24 None,
25 std::ptr::null_mut(),
26 None,
27 );
28 }
29 }
30
31 /// Sets the active item of @self to be the item at @index.
32 ///
33 /// # Deprecated since 4.10
34 ///
35 /// Use [`DropDown`][crate::DropDown]
36 /// ## `index_`
37 /// An index in the model passed during construction,
38 /// or -1 to have no active item
39 #[doc(alias = "gtk_combo_box_set_active")]
40 fn set_active(&self, index_: Option<u32>) {
41 let index_ = match index_ {
42 Some(i) => i as _,
43 None => -1,
44 };
45 unsafe {
46 ffi::gtk_combo_box_set_active(self.as_ref().to_glib_none().0, index_);
47 }
48 }
49
50 /// Returns the index of the currently active item.
51 ///
52 /// If the model is a non-flat treemodel, and the active item is not
53 /// an immediate child of the root of the tree, this function returns
54 /// `gtk_tree_path_get_indices (path)[0]`, where `path` is the
55 /// [`TreePath`][crate::TreePath] of the active item.
56 ///
57 /// # Deprecated since 4.10
58 ///
59 /// Use [`DropDown`][crate::DropDown]
60 ///
61 /// # Returns
62 ///
63 /// An integer which is the index of the currently active item,
64 /// or -1 if there’s no active item
65 #[doc(alias = "gtk_combo_box_get_active")]
66 #[doc(alias = "get_active")]
67 fn active(&self) -> Option<u32> {
68 match unsafe { ffi::gtk_combo_box_get_active(self.as_ref().to_glib_none().0) } {
69 -1 => None,
70 x => Some(x as _),
71 }
72 }
73}
74
75impl<O: IsA<ComboBox>> ComboBoxExtManual for O {}