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::{ffi, DBusInterface, DBusObject};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
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 `Gio::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/// [`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            let f: &F = &*(f as *const F);
174            f(
175                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
176                &from_glib_borrow(object),
177                &from_glib_borrow(interface),
178            )
179        }
180        unsafe {
181            let f: Box_<F> = Box_::new(f);
182            connect_raw(
183                self.as_ptr() as *mut _,
184                c"interface-added".as_ptr() as *const _,
185                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
186                    interface_added_trampoline::<Self, F> as *const (),
187                )),
188                Box_::into_raw(f),
189            )
190        }
191    }
192
193    /// Emitted when @interface has been removed from @object.
194    ///
195    /// This signal exists purely as a convenience to avoid having to
196    /// connect signals to all objects managed by @manager.
197    /// ## `object`
198    /// The #GDBusObject on which an interface was removed.
199    /// ## `interface`
200    /// The #GDBusInterface that was removed.
201    #[doc(alias = "interface-removed")]
202    fn connect_interface_removed<F: Fn(&Self, &DBusObject, &DBusInterface) + 'static>(
203        &self,
204        f: F,
205    ) -> SignalHandlerId {
206        unsafe extern "C" fn interface_removed_trampoline<
207            P: IsA<DBusObjectManager>,
208            F: Fn(&P, &DBusObject, &DBusInterface) + 'static,
209        >(
210            this: *mut ffi::GDBusObjectManager,
211            object: *mut ffi::GDBusObject,
212            interface: *mut ffi::GDBusInterface,
213            f: glib::ffi::gpointer,
214        ) {
215            let f: &F = &*(f as *const F);
216            f(
217                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
218                &from_glib_borrow(object),
219                &from_glib_borrow(interface),
220            )
221        }
222        unsafe {
223            let f: Box_<F> = Box_::new(f);
224            connect_raw(
225                self.as_ptr() as *mut _,
226                c"interface-removed".as_ptr() as *const _,
227                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
228                    interface_removed_trampoline::<Self, F> as *const (),
229                )),
230                Box_::into_raw(f),
231            )
232        }
233    }
234
235    /// Emitted when @object is added to @manager.
236    /// ## `object`
237    /// The #GDBusObject that was added.
238    #[doc(alias = "object-added")]
239    fn connect_object_added<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
240        unsafe extern "C" fn object_added_trampoline<
241            P: IsA<DBusObjectManager>,
242            F: Fn(&P, &DBusObject) + 'static,
243        >(
244            this: *mut ffi::GDBusObjectManager,
245            object: *mut ffi::GDBusObject,
246            f: glib::ffi::gpointer,
247        ) {
248            let f: &F = &*(f as *const F);
249            f(
250                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
251                &from_glib_borrow(object),
252            )
253        }
254        unsafe {
255            let f: Box_<F> = Box_::new(f);
256            connect_raw(
257                self.as_ptr() as *mut _,
258                c"object-added".as_ptr() as *const _,
259                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
260                    object_added_trampoline::<Self, F> as *const (),
261                )),
262                Box_::into_raw(f),
263            )
264        }
265    }
266
267    /// Emitted when @object is removed from @manager.
268    /// ## `object`
269    /// The #GDBusObject that was removed.
270    #[doc(alias = "object-removed")]
271    fn connect_object_removed<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
272        unsafe extern "C" fn object_removed_trampoline<
273            P: IsA<DBusObjectManager>,
274            F: Fn(&P, &DBusObject) + 'static,
275        >(
276            this: *mut ffi::GDBusObjectManager,
277            object: *mut ffi::GDBusObject,
278            f: glib::ffi::gpointer,
279        ) {
280            let f: &F = &*(f as *const F);
281            f(
282                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
283                &from_glib_borrow(object),
284            )
285        }
286        unsafe {
287            let f: Box_<F> = Box_::new(f);
288            connect_raw(
289                self.as_ptr() as *mut _,
290                c"object-removed".as_ptr() as *const _,
291                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
292                    object_removed_trampoline::<Self, F> as *const (),
293                )),
294                Box_::into_raw(f),
295            )
296        }
297    }
298}
299
300impl<O: IsA<DBusObjectManager>> DBusObjectManagerExt for O {}