gio/auto/
dbus_object_manager.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::{DBusInterface, DBusObject, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// The `GDBusObjectManager` type is the base type for service- and
16    /// client-side implementations of the standardized
17    /// [`org.freedesktop.DBus.ObjectManager`](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
18    /// interface.
19    ///
20    /// See [`DBusObjectManagerClient`][crate::DBusObjectManagerClient] for the client-side implementation
21    /// and [`DBusObjectManagerServer`][crate::DBusObjectManagerServer] for the service-side implementation.
22    ///
23    /// ## Signals
24    ///
25    ///
26    /// #### `interface-added`
27    ///  Emitted when @interface is added to @object.
28    ///
29    /// This signal exists purely as a convenience to avoid having to
30    /// connect signals to all objects managed by @manager.
31    ///
32    ///
33    ///
34    ///
35    /// #### `interface-removed`
36    ///  Emitted when @interface has been removed from @object.
37    ///
38    /// This signal exists purely as a convenience to avoid having to
39    /// connect signals to all objects managed by @manager.
40    ///
41    ///
42    ///
43    ///
44    /// #### `object-added`
45    ///  Emitted when @object is added to @manager.
46    ///
47    ///
48    ///
49    ///
50    /// #### `object-removed`
51    ///  Emitted when @object is removed from @manager.
52    ///
53    ///
54    ///
55    /// # Implements
56    ///
57    /// [`DBusObjectManagerExt`][trait@crate::prelude::DBusObjectManagerExt]
58    #[doc(alias = "GDBusObjectManager")]
59    pub struct DBusObjectManager(Interface<ffi::GDBusObjectManager, ffi::GDBusObjectManagerIface>);
60
61    match fn {
62        type_ => || ffi::g_dbus_object_manager_get_type(),
63    }
64}
65
66impl DBusObjectManager {
67    pub const NONE: Option<&'static DBusObjectManager> = None;
68}
69
70/// Trait containing all [`struct@DBusObjectManager`] methods.
71///
72/// # Implementors
73///
74/// [`DBusObjectManagerClient`][struct@crate::DBusObjectManagerClient], [`DBusObjectManagerServer`][struct@crate::DBusObjectManagerServer], [`DBusObjectManager`][struct@crate::DBusObjectManager]
75pub trait DBusObjectManagerExt: IsA<DBusObjectManager> + 'static {
76    /// Gets the interface proxy for @interface_name at @object_path, if
77    /// any.
78    /// ## `object_path`
79    /// Object path to look up.
80    /// ## `interface_name`
81    /// D-Bus interface name to look up.
82    ///
83    /// # Returns
84    ///
85    /// A #GDBusInterface instance or [`None`]. Free
86    ///   with g_object_unref().
87    #[doc(alias = "g_dbus_object_manager_get_interface")]
88    #[doc(alias = "get_interface")]
89    fn interface(&self, object_path: &str, interface_name: &str) -> Option<DBusInterface> {
90        unsafe {
91            from_glib_full(ffi::g_dbus_object_manager_get_interface(
92                self.as_ref().to_glib_none().0,
93                object_path.to_glib_none().0,
94                interface_name.to_glib_none().0,
95            ))
96        }
97    }
98
99    /// Gets the #GDBusObject at @object_path, if any.
100    /// ## `object_path`
101    /// Object path to look up.
102    ///
103    /// # Returns
104    ///
105    /// A #GDBusObject or [`None`]. Free with
106    ///   g_object_unref().
107    #[doc(alias = "g_dbus_object_manager_get_object")]
108    #[doc(alias = "get_object")]
109    fn object(&self, object_path: &str) -> Option<DBusObject> {
110        unsafe {
111            from_glib_full(ffi::g_dbus_object_manager_get_object(
112                self.as_ref().to_glib_none().0,
113                object_path.to_glib_none().0,
114            ))
115        }
116    }
117
118    /// Gets the object path that @self is for.
119    ///
120    /// # Returns
121    ///
122    /// A string owned by @self. Do not free.
123    #[doc(alias = "g_dbus_object_manager_get_object_path")]
124    #[doc(alias = "get_object_path")]
125    fn object_path(&self) -> glib::GString {
126        unsafe {
127            from_glib_none(ffi::g_dbus_object_manager_get_object_path(
128                self.as_ref().to_glib_none().0,
129            ))
130        }
131    }
132
133    /// Gets all #GDBusObject objects known to @self.
134    ///
135    /// # Returns
136    ///
137    /// A list of
138    ///   #GDBusObject objects. The returned list should be freed with
139    ///   g_list_free() after each element has been freed with
140    ///   g_object_unref().
141    #[doc(alias = "g_dbus_object_manager_get_objects")]
142    #[doc(alias = "get_objects")]
143    fn objects(&self) -> Vec<DBusObject> {
144        unsafe {
145            FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_manager_get_objects(
146                self.as_ref().to_glib_none().0,
147            ))
148        }
149    }
150
151    /// Emitted when @interface is added to @object.
152    ///
153    /// This signal exists purely as a convenience to avoid having to
154    /// connect signals to all objects managed by @manager.
155    /// ## `object`
156    /// The #GDBusObject on which an interface was added.
157    /// ## `interface`
158    /// The #GDBusInterface that was added.
159    #[doc(alias = "interface-added")]
160    fn connect_interface_added<F: Fn(&Self, &DBusObject, &DBusInterface) + 'static>(
161        &self,
162        f: F,
163    ) -> SignalHandlerId {
164        unsafe extern "C" fn interface_added_trampoline<
165            P: IsA<DBusObjectManager>,
166            F: Fn(&P, &DBusObject, &DBusInterface) + 'static,
167        >(
168            this: *mut ffi::GDBusObjectManager,
169            object: *mut ffi::GDBusObject,
170            interface: *mut ffi::GDBusInterface,
171            f: glib::ffi::gpointer,
172        ) {
173            unsafe {
174                let f: &F = &*(f as *const F);
175                f(
176                    DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
177                    &from_glib_borrow(object),
178                    &from_glib_borrow(interface),
179                )
180            }
181        }
182        unsafe {
183            let f: Box_<F> = Box_::new(f);
184            connect_raw(
185                self.as_ptr() as *mut _,
186                c"interface-added".as_ptr() as *const _,
187                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
188                    interface_added_trampoline::<Self, F> as *const (),
189                )),
190                Box_::into_raw(f),
191            )
192        }
193    }
194
195    /// Emitted when @interface has been removed from @object.
196    ///
197    /// This signal exists purely as a convenience to avoid having to
198    /// connect signals to all objects managed by @manager.
199    /// ## `object`
200    /// The #GDBusObject on which an interface was removed.
201    /// ## `interface`
202    /// The #GDBusInterface that was removed.
203    #[doc(alias = "interface-removed")]
204    fn connect_interface_removed<F: Fn(&Self, &DBusObject, &DBusInterface) + 'static>(
205        &self,
206        f: F,
207    ) -> SignalHandlerId {
208        unsafe extern "C" fn interface_removed_trampoline<
209            P: IsA<DBusObjectManager>,
210            F: Fn(&P, &DBusObject, &DBusInterface) + 'static,
211        >(
212            this: *mut ffi::GDBusObjectManager,
213            object: *mut ffi::GDBusObject,
214            interface: *mut ffi::GDBusInterface,
215            f: glib::ffi::gpointer,
216        ) {
217            unsafe {
218                let f: &F = &*(f as *const F);
219                f(
220                    DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
221                    &from_glib_borrow(object),
222                    &from_glib_borrow(interface),
223                )
224            }
225        }
226        unsafe {
227            let f: Box_<F> = Box_::new(f);
228            connect_raw(
229                self.as_ptr() as *mut _,
230                c"interface-removed".as_ptr() as *const _,
231                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232                    interface_removed_trampoline::<Self, F> as *const (),
233                )),
234                Box_::into_raw(f),
235            )
236        }
237    }
238
239    /// Emitted when @object is added to @manager.
240    /// ## `object`
241    /// The #GDBusObject that was added.
242    #[doc(alias = "object-added")]
243    fn connect_object_added<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
244        unsafe extern "C" fn object_added_trampoline<
245            P: IsA<DBusObjectManager>,
246            F: Fn(&P, &DBusObject) + 'static,
247        >(
248            this: *mut ffi::GDBusObjectManager,
249            object: *mut ffi::GDBusObject,
250            f: glib::ffi::gpointer,
251        ) {
252            unsafe {
253                let f: &F = &*(f as *const F);
254                f(
255                    DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
256                    &from_glib_borrow(object),
257                )
258            }
259        }
260        unsafe {
261            let f: Box_<F> = Box_::new(f);
262            connect_raw(
263                self.as_ptr() as *mut _,
264                c"object-added".as_ptr() as *const _,
265                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
266                    object_added_trampoline::<Self, F> as *const (),
267                )),
268                Box_::into_raw(f),
269            )
270        }
271    }
272
273    /// Emitted when @object is removed from @manager.
274    /// ## `object`
275    /// The #GDBusObject that was removed.
276    #[doc(alias = "object-removed")]
277    fn connect_object_removed<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
278        unsafe extern "C" fn object_removed_trampoline<
279            P: IsA<DBusObjectManager>,
280            F: Fn(&P, &DBusObject) + 'static,
281        >(
282            this: *mut ffi::GDBusObjectManager,
283            object: *mut ffi::GDBusObject,
284            f: glib::ffi::gpointer,
285        ) {
286            unsafe {
287                let f: &F = &*(f as *const F);
288                f(
289                    DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
290                    &from_glib_borrow(object),
291                )
292            }
293        }
294        unsafe {
295            let f: Box_<F> = Box_::new(f);
296            connect_raw(
297                self.as_ptr() as *mut _,
298                c"object-removed".as_ptr() as *const _,
299                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
300                    object_removed_trampoline::<Self, F> as *const (),
301                )),
302                Box_::into_raw(f),
303            )
304        }
305    }
306}
307
308impl<O: IsA<DBusObjectManager>> DBusObjectManagerExt for O {}