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