1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::Actionable;
use glib::object::IsA;
use glib::translate::*;
use libc::c_char;

pub trait ActionableExtManual: 'static {
    /// Sets the target of an actionable widget.
    ///
    /// This is a convenience function that calls `g_variant_new()` for
    /// `format_string` and uses the result to call
    /// [``ActionableExt::set_action_target_value()``][crate::prelude::`ActionableExt::set_action_target_value()`].
    ///
    /// If you are setting a string-valued target and want to set
    /// the action name at the same time, you can use
    /// [``ActionableExt::set_detailed_action_name()``][crate::prelude::`ActionableExt::set_detailed_action_name()`].
    /// ## `format_string`
    /// a GVariant format string
    #[doc(alias = "gtk_actionable_set_action_target")]
    fn set_action_target(&self, string: &str);
}

impl<O: IsA<Actionable>> ActionableExtManual for O {
    fn set_action_target(&self, string: &str) {
        let string: Stash<*const c_char, _> = string.to_glib_none();
        unsafe {
            ffi::gtk_actionable_set_action_target(
                self.as_ref().to_glib_none().0,
                b"%s\0".as_ptr() as *const c_char,
                string.0,
            );
        }
    }
}