gio/auto/action_map.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Action, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// part of the interface
10 /// name.
11 ///
12 /// # Implements
13 ///
14 /// [`ActionMapExt`][trait@crate::prelude::ActionMapExt], [`ActionMapExtManual`][trait@crate::prelude::ActionMapExtManual]
15 #[doc(alias = "GActionMap")]
16 pub struct ActionMap(Interface<ffi::GActionMap, ffi::GActionMapInterface>);
17
18 match fn {
19 type_ => || ffi::g_action_map_get_type(),
20 }
21}
22
23impl ActionMap {
24 pub const NONE: Option<&'static ActionMap> = None;
25}
26
27/// Trait containing all [`struct@ActionMap`] methods.
28///
29/// # Implementors
30///
31/// [`ActionMap`][struct@crate::ActionMap], [`Application`][struct@crate::Application], [`SimpleActionGroup`][struct@crate::SimpleActionGroup]
32pub trait ActionMapExt: IsA<ActionMap> + 'static {
33 /// Adds an action to the @self.
34 ///
35 /// If the action map already contains an action with the same name
36 /// as @action then the old action is dropped from the action map.
37 ///
38 /// The action map takes its own reference on @action.
39 /// ## `action`
40 /// a [`Action`][crate::Action]
41 #[doc(alias = "g_action_map_add_action")]
42 fn add_action(&self, action: &impl IsA<Action>) {
43 unsafe {
44 ffi::g_action_map_add_action(
45 self.as_ref().to_glib_none().0,
46 action.as_ref().to_glib_none().0,
47 );
48 }
49 }
50
51 /// Looks up the action with the name @action_name in @self.
52 ///
53 /// If no such action exists, returns `NULL`.
54 /// ## `action_name`
55 /// the name of an action
56 ///
57 /// # Returns
58 ///
59 /// a [`Action`][crate::Action]
60 #[doc(alias = "g_action_map_lookup_action")]
61 fn lookup_action(&self, action_name: &str) -> Option<Action> {
62 unsafe {
63 from_glib_none(ffi::g_action_map_lookup_action(
64 self.as_ref().to_glib_none().0,
65 action_name.to_glib_none().0,
66 ))
67 }
68 }
69
70 /// Removes the named action from the action map.
71 ///
72 /// If no action of this name is in the map then nothing happens.
73 /// ## `action_name`
74 /// the name of the action
75 #[doc(alias = "g_action_map_remove_action")]
76 fn remove_action(&self, action_name: &str) {
77 unsafe {
78 ffi::g_action_map_remove_action(
79 self.as_ref().to_glib_none().0,
80 action_name.to_glib_none().0,
81 );
82 }
83 }
84}
85
86impl<O: IsA<ActionMap>> ActionMapExt for O {}