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