dbusmenu_glib/auto/
server.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from /nix/store/39vgdpiqy94qwa8rraha7q4wcd8hdwcj-dbusmenu-gtk3-gir
3// from /nix/store/ahri9v0b3c1jyls6691sjfzf2s461fzz-source
4// DO NOT EDIT
5
6use crate::{Menuitem,Status,TextDirection};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_,fmt,mem::transmute};
9
10glib::wrapper! {
11    #[doc(alias = "DbusmenuServer")]
12    pub struct Server(Object<ffi::DbusmenuServer, ffi::DbusmenuServerClass>);
13
14    match fn {
15        type_ => || ffi::dbusmenu_server_get_type(),
16    }
17}
18
19impl Server {
20        pub const NONE: Option<&'static Server> = None;
21    
22
23    /// Creates a new [`Server`][crate::Server] object with a specific object
24    ///     path on DBus. If `object` is set to NULL the default object
25    ///     name of "/com/canonical/dbusmenu" will be used.
26    ///
27    /// Return value: A brand new [`Server`][crate::Server]
28    /// ## `object`
29    /// The object name to show for this menu structure
30    ///         on DBus. May be NULL.
31    #[doc(alias = "dbusmenu_server_new")]
32    pub fn new(object: &str) -> Server {
33        assert_initialized_main_thread!();
34        unsafe {
35            from_glib_full(ffi::dbusmenu_server_new(object.to_glib_none().0))
36        }
37    }
38}
39
40/// Trait containing all [`struct@Server`] methods.
41///
42/// # Implementors
43///
44/// [`Server`][struct@crate::Server]
45pub trait ServerExt: 'static {
46    /// Gets the stored and exported icon paths from the server.
47    ///
48    /// # Returns
49    ///
50    /// A NULL-terminated list of icon paths with
51    ///  memory managed by the server. Duplicate if you want
52    ///  to keep them.
53    #[doc(alias = "dbusmenu_server_get_icon_paths")]
54    #[doc(alias = "get_icon_paths")]
55    fn icon_paths(&self) -> Vec<glib::GString>;
56
57    /// Gets the current statust hat the server is sending out over
58    ///     DBus.
59    ///
60    /// Return value: The current status the server is sending
61    #[doc(alias = "dbusmenu_server_get_status")]
62    #[doc(alias = "get_status")]
63    fn status(&self) -> Status;
64
65    /// Returns the value of the text direction that is being exported
66    ///     over DBus for this server. It should relate to the direction
67    ///     of the labels and other text fields that are being exported by
68    ///     this server.
69    ///
70    /// Return value: Text direction exported for this server.
71    #[doc(alias = "dbusmenu_server_get_text_direction")]
72    #[doc(alias = "get_text_direction")]
73    fn text_direction(&self) -> TextDirection;
74
75    /// Sets the icon paths for the server. This will replace previously
76    ///     set icon theme paths.
77    #[doc(alias = "dbusmenu_server_set_icon_paths")]
78    fn set_icon_paths(&self, icon_paths: &[&str]);
79
80    /// This function contains all of the `GValue` wrapping
81    ///     required to set the property [`root-node`][struct@crate::Server#root-node]
82    ///     on the server `self`.
83    /// ## `root`
84    /// The new root [`Menuitem`][crate::Menuitem] tree
85    #[doc(alias = "dbusmenu_server_set_root")]
86    fn set_root(&self, root: &impl IsA<Menuitem>);
87
88    /// Changes the status of the server.
89    /// ## `status`
90    /// Status value to set on the server
91    #[doc(alias = "dbusmenu_server_set_status")]
92    fn set_status(&self, status: Status);
93
94    /// Sets the text direction that should be exported over DBus for
95    ///     this server. If the value is set to [`TextDirection::None`][crate::TextDirection::None]
96    ///     the default detection will be used for setting the value and
97    ///     exported over DBus.
98    /// ## `dir`
99    /// Direction of the text
100    #[doc(alias = "dbusmenu_server_set_text_direction")]
101    fn set_text_direction(&self, dir: TextDirection);
102
103    #[doc(alias = "dbus-object")]
104    fn dbus_object(&self) -> Option<glib::GString>;
105
106    #[doc(alias = "root-node")]
107    fn root_node(&self) -> Option<Menuitem>;
108
109    #[doc(alias = "root-node")]
110    fn set_root_node<P: IsA<Menuitem>>(&self, root_node: Option<&P>);
111
112    fn version(&self) -> u32;
113
114    /// This is signaled when a menuitem under this server
115    ///         sends its activate signal.
116    /// ## `arg1`
117    /// The ID of the parent for this update.
118    /// ## `arg2`
119    /// The timestamp of when the event happened
120    #[doc(alias = "item-activation-requested")]
121    fn connect_item_activation_requested<F: Fn(&Self, i32, u32) + 'static>(&self, f: F) -> SignalHandlerId;
122
123    #[doc(alias = "item-property-updated")]
124    fn connect_item_property_updated<F: Fn(&Self, i32, &str, &glib::Variant) + 'static>(&self, f: F) -> SignalHandlerId;
125
126    #[doc(alias = "item-updated")]
127    fn connect_item_updated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;
128
129    /// This signal is emitted any time the layout of the
130    ///         menuitems under this server is changed.
131    /// ## `arg1`
132    /// A revision number representing which revision the update
133    ///          represents itself as.
134    /// ## `arg2`
135    /// The ID of the parent for this update.
136    #[doc(alias = "layout-updated")]
137    fn connect_layout_updated<F: Fn(&Self, u32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
138
139    #[doc(alias = "root-node")]
140    fn connect_root_node_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
141
142    #[doc(alias = "version")]
143    fn connect_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
144}
145
146impl<O: IsA<Server>> ServerExt for O {
147    fn icon_paths(&self) -> Vec<glib::GString> {
148        unsafe {
149            FromGlibPtrContainer::from_glib_none(ffi::dbusmenu_server_get_icon_paths(self.as_ref().to_glib_none().0))
150        }
151    }
152
153    fn status(&self) -> Status {
154        unsafe {
155            from_glib(ffi::dbusmenu_server_get_status(self.as_ref().to_glib_none().0))
156        }
157    }
158
159    fn text_direction(&self) -> TextDirection {
160        unsafe {
161            from_glib(ffi::dbusmenu_server_get_text_direction(self.as_ref().to_glib_none().0))
162        }
163    }
164
165    fn set_icon_paths(&self, icon_paths: &[&str]) {
166        unsafe {
167            ffi::dbusmenu_server_set_icon_paths(self.as_ref().to_glib_none().0, icon_paths.to_glib_none().0);
168        }
169    }
170
171    fn set_root(&self, root: &impl IsA<Menuitem>) {
172        unsafe {
173            ffi::dbusmenu_server_set_root(self.as_ref().to_glib_none().0, root.as_ref().to_glib_none().0);
174        }
175    }
176
177    fn set_status(&self, status: Status) {
178        unsafe {
179            ffi::dbusmenu_server_set_status(self.as_ref().to_glib_none().0, status.into_glib());
180        }
181    }
182
183    fn set_text_direction(&self, dir: TextDirection) {
184        unsafe {
185            ffi::dbusmenu_server_set_text_direction(self.as_ref().to_glib_none().0, dir.into_glib());
186        }
187    }
188
189    fn dbus_object(&self) -> Option<glib::GString> {
190        glib::ObjectExt::property(self.as_ref(), "dbus-object")
191    }
192
193    fn root_node(&self) -> Option<Menuitem> {
194        glib::ObjectExt::property(self.as_ref(), "root-node")
195    }
196
197    fn set_root_node<P: IsA<Menuitem>>(&self, root_node: Option<&P>) {
198        glib::ObjectExt::set_property(self.as_ref(),"root-node", root_node)
199    }
200
201    fn version(&self) -> u32 {
202        glib::ObjectExt::property(self.as_ref(), "version")
203    }
204
205    fn connect_item_activation_requested<F: Fn(&Self, i32, u32) + 'static>(&self, f: F) -> SignalHandlerId {
206        unsafe extern "C" fn item_activation_requested_trampoline<P: IsA<Server>, F: Fn(&P, i32, u32) + 'static>(this: *mut ffi::DbusmenuServer, arg1: libc::c_int, arg2: libc::c_uint, f: glib::ffi::gpointer) {
207            let f: &F = &*(f as *const F);
208            f(Server::from_glib_borrow(this).unsafe_cast_ref(), arg1, arg2)
209        }
210        unsafe {
211            let f: Box_<F> = Box_::new(f);
212            connect_raw(self.as_ptr() as *mut _, b"item-activation-requested\0".as_ptr() as *const _,
213                Some(transmute::<_, unsafe extern "C" fn()>(item_activation_requested_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
214        }
215    }
216
217    fn connect_item_property_updated<F: Fn(&Self, i32, &str, &glib::Variant) + 'static>(&self, f: F) -> SignalHandlerId {
218        unsafe extern "C" fn item_property_updated_trampoline<P: IsA<Server>, F: Fn(&P, i32, &str, &glib::Variant) + 'static>(this: *mut ffi::DbusmenuServer, object: libc::c_int, p0: *mut libc::c_char, p1: *mut glib::ffi::GVariant, f: glib::ffi::gpointer) {
219            let f: &F = &*(f as *const F);
220            f(Server::from_glib_borrow(this).unsafe_cast_ref(), object, &glib::GString::from_glib_borrow(p0), &from_glib_borrow(p1))
221        }
222        unsafe {
223            let f: Box_<F> = Box_::new(f);
224            connect_raw(self.as_ptr() as *mut _, b"item-property-updated\0".as_ptr() as *const _,
225                Some(transmute::<_, unsafe extern "C" fn()>(item_property_updated_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
226        }
227    }
228
229    fn connect_item_updated<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
230        unsafe extern "C" fn item_updated_trampoline<P: IsA<Server>, F: Fn(&P, i32) + 'static>(this: *mut ffi::DbusmenuServer, object: libc::c_int, f: glib::ffi::gpointer) {
231            let f: &F = &*(f as *const F);
232            f(Server::from_glib_borrow(this).unsafe_cast_ref(), object)
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(self.as_ptr() as *mut _, b"item-updated\0".as_ptr() as *const _,
237                Some(transmute::<_, unsafe extern "C" fn()>(item_updated_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
238        }
239    }
240
241    fn connect_layout_updated<F: Fn(&Self, u32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
242        unsafe extern "C" fn layout_updated_trampoline<P: IsA<Server>, F: Fn(&P, u32, i32) + 'static>(this: *mut ffi::DbusmenuServer, arg1: libc::c_uint, arg2: libc::c_int, f: glib::ffi::gpointer) {
243            let f: &F = &*(f as *const F);
244            f(Server::from_glib_borrow(this).unsafe_cast_ref(), arg1, arg2)
245        }
246        unsafe {
247            let f: Box_<F> = Box_::new(f);
248            connect_raw(self.as_ptr() as *mut _, b"layout-updated\0".as_ptr() as *const _,
249                Some(transmute::<_, unsafe extern "C" fn()>(layout_updated_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
250        }
251    }
252
253    fn connect_root_node_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
254        unsafe extern "C" fn notify_root_node_trampoline<P: IsA<Server>, F: Fn(&P) + 'static>(this: *mut ffi::DbusmenuServer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
255            let f: &F = &*(f as *const F);
256            f(Server::from_glib_borrow(this).unsafe_cast_ref())
257        }
258        unsafe {
259            let f: Box_<F> = Box_::new(f);
260            connect_raw(self.as_ptr() as *mut _, b"notify::root-node\0".as_ptr() as *const _,
261                Some(transmute::<_, unsafe extern "C" fn()>(notify_root_node_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
262        }
263    }
264
265    fn connect_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
266        unsafe extern "C" fn notify_version_trampoline<P: IsA<Server>, F: Fn(&P) + 'static>(this: *mut ffi::DbusmenuServer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
267            let f: &F = &*(f as *const F);
268            f(Server::from_glib_borrow(this).unsafe_cast_ref())
269        }
270        unsafe {
271            let f: Box_<F> = Box_::new(f);
272            connect_raw(self.as_ptr() as *mut _, b"notify::version\0".as_ptr() as *const _,
273                Some(transmute::<_, unsafe extern "C" fn()>(notify_version_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
274        }
275    }
276}
277
278impl fmt::Display for Server {
279    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
280        f.write_str("Server")
281    }
282}