gtk4/
actionable.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{translate::*, Variant};
4
5use crate::{prelude::*, Actionable};
6
7mod sealed {
8    pub trait Sealed {}
9    impl<T: super::IsA<super::Actionable>> Sealed for T {}
10}
11
12// rustdoc-stripper-ignore-next
13/// Trait containing manually implemented methods of
14/// [`Actionable`](crate::Actionable).
15pub trait ActionableExtManual: sealed::Sealed + IsA<Actionable> + 'static {
16    /// Sets the target of an actionable widget.
17    ///
18    /// This is a convenience function that calls `GLib::Variant::new()` for
19    /// @format_string and uses the result to call
20    /// [`ActionableExt::set_action_target_value()`][crate::prelude::ActionableExt::set_action_target_value()].
21    ///
22    /// If you are setting a string-valued target and want to set
23    /// the action name at the same time, you can use
24    /// [`ActionableExt::set_detailed_action_name()`][crate::prelude::ActionableExt::set_detailed_action_name()].
25    /// ## `format_string`
26    /// a [`glib::Variant`][struct@crate::glib::Variant] format string
27    #[doc(alias = "gtk_actionable_set_action_target")]
28    #[doc(alias = "gtk_actionable_set_action_target_value")]
29    fn set_action_target(&self, target: Option<impl Into<Variant>>) {
30        unsafe {
31            crate::ffi::gtk_actionable_set_action_target_value(
32                self.as_ref().to_glib_none().0,
33                target.map(|v| v.into()).to_glib_none().0,
34            );
35        }
36    }
37}
38
39impl<O: IsA<Actionable>> ActionableExtManual for O {}