[go: up one dir, main page]

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    #[doc(alias = "gtk_combo_box_set_active")]
27    fn set_active(&self, index_: Option<u32>) {
28        let index_ = match index_ {
29            Some(i) => i as _,
30            None => -1,
31        };
32        unsafe {
33            ffi::gtk_combo_box_set_active(self.as_ref().to_glib_none().0, index_);
34        }
35    }
36
37    #[doc(alias = "gtk_combo_box_get_active")]
38    #[doc(alias = "get_active")]
39    fn active(&self) -> Option<u32> {
40        match unsafe { ffi::gtk_combo_box_get_active(self.as_ref().to_glib_none().0) } {
41            -1 => None,
42            x => Some(x as _),
43        }
44    }
45}
46
47impl<O: IsA<ComboBox>> ComboBoxExtManual for O {}