dbusmenu_glib/auto/
client.rs1use 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 = "DbusmenuClient")]
12 pub struct Client(Object<ffi::DbusmenuClient, ffi::DbusmenuClientClass>);
13
14 match fn {
15 type_ => || ffi::dbusmenu_client_get_type(),
16 }
17}
18
19impl Client {
20 pub const NONE: Option<&'static Client> = None;
21
22
23 #[doc(alias = "dbusmenu_client_new")]
37 pub fn new(name: &str, object: &str) -> Client {
38 assert_initialized_main_thread!();
39 unsafe {
40 from_glib_full(ffi::dbusmenu_client_new(name.to_glib_none().0, object.to_glib_none().0))
41 }
42 }
43}
44
45pub trait ClientExt: 'static {
51 #[doc(alias = "dbusmenu_client_add_type_handler_full")]
72 fn add_type_handler_full<P: Fn(&Menuitem, &Menuitem, &Client) -> bool + 'static>(&self, type_: &str, newfunc: P) -> bool;
73
74 #[doc(alias = "dbusmenu_client_get_icon_paths")]
82 #[doc(alias = "get_icon_paths")]
83 fn icon_paths(&self) -> Vec<glib::GString>;
84
85 #[doc(alias = "dbusmenu_client_get_root")]
99 #[doc(alias = "get_root")]
100 fn root(&self) -> Option<Menuitem>;
101
102 #[doc(alias = "dbusmenu_client_get_status")]
110 #[doc(alias = "get_status")]
111 fn status(&self) -> Status;
112
113 #[doc(alias = "dbusmenu_client_get_text_direction")]
119 #[doc(alias = "get_text_direction")]
120 fn text_direction(&self) -> TextDirection;
121
122 #[doc(alias = "dbus-name")]
123 fn dbus_name(&self) -> Option<glib::GString>;
124
125 #[doc(alias = "dbus-object")]
126 fn dbus_object(&self) -> Option<glib::GString>;
127
128 #[doc(alias = "group-events")]
129 fn is_group_events(&self) -> bool;
130
131 #[doc(alias = "group-events")]
132 fn set_group_events(&self, group_events: bool);
133
134 #[doc(alias = "layout-updated")]
144 fn connect_layout_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
145
146 #[doc(alias = "group-events")]
153 fn connect_group_events_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
154}
155
156impl<O: IsA<Client>> ClientExt for O {
157 fn add_type_handler_full<P: Fn(&Menuitem, &Menuitem, &Client) -> bool + 'static>(&self, type_: &str, newfunc: P) -> bool {
158 let newfunc_data: Box_<P> = Box_::new(newfunc);
159 unsafe extern "C" fn newfunc_func<P: Fn(&Menuitem, &Menuitem, &Client) -> bool + 'static>(newitem: *mut ffi::DbusmenuMenuitem, parent: *mut ffi::DbusmenuMenuitem, client: *mut ffi::DbusmenuClient, user_data: glib::ffi::gpointer) -> glib::ffi::gboolean {
160 let newitem = from_glib_borrow(newitem);
161 let parent = from_glib_borrow(parent);
162 let client = from_glib_borrow(client);
163 let callback: &P = &*(user_data as *mut _);
164 (*callback)(&newitem, &parent, &client)
165 .into_glib()
166 }
167 let newfunc = Some(newfunc_func::<P> as _);
168 unsafe extern "C" fn destroy_func_func<P: Fn(&Menuitem, &Menuitem, &Client) -> bool + 'static>(data: glib::ffi::gpointer) {
169 let _callback: Box_<P> = Box_::from_raw(data as *mut _);
170 }
171 let destroy_call4 = Some(destroy_func_func::<P> as _);
172 let super_callback0: Box_<P> = newfunc_data;
173 unsafe {
174 from_glib(ffi::dbusmenu_client_add_type_handler_full(self.as_ref().to_glib_none().0, type_.to_glib_none().0, newfunc, Box_::into_raw(super_callback0) as *mut _, destroy_call4))
175 }
176 }
177
178 fn icon_paths(&self) -> Vec<glib::GString> {
179 unsafe {
180 FromGlibPtrContainer::from_glib_none(ffi::dbusmenu_client_get_icon_paths(self.as_ref().to_glib_none().0))
181 }
182 }
183
184 fn root(&self) -> Option<Menuitem> {
185 unsafe {
186 from_glib_none(ffi::dbusmenu_client_get_root(self.as_ref().to_glib_none().0))
187 }
188 }
189
190 fn status(&self) -> Status {
191 unsafe {
192 from_glib(ffi::dbusmenu_client_get_status(self.as_ref().to_glib_none().0))
193 }
194 }
195
196 fn text_direction(&self) -> TextDirection {
197 unsafe {
198 from_glib(ffi::dbusmenu_client_get_text_direction(self.as_ref().to_glib_none().0))
199 }
200 }
201
202 fn dbus_name(&self) -> Option<glib::GString> {
203 glib::ObjectExt::property(self.as_ref(), "dbus-name")
204 }
205
206 fn dbus_object(&self) -> Option<glib::GString> {
207 glib::ObjectExt::property(self.as_ref(), "dbus-object")
208 }
209
210 fn is_group_events(&self) -> bool {
211 glib::ObjectExt::property(self.as_ref(), "group-events")
212 }
213
214 fn set_group_events(&self, group_events: bool) {
215 glib::ObjectExt::set_property(self.as_ref(),"group-events", group_events)
216 }
217
218 fn connect_layout_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
232 unsafe extern "C" fn layout_updated_trampoline<P: IsA<Client>, F: Fn(&P) + 'static>(this: *mut ffi::DbusmenuClient, f: glib::ffi::gpointer) {
233 let f: &F = &*(f as *const F);
234 f(Client::from_glib_borrow(this).unsafe_cast_ref())
235 }
236 unsafe {
237 let f: Box_<F> = Box_::new(f);
238 connect_raw(self.as_ptr() as *mut _, b"layout-updated\0".as_ptr() as *const _,
239 Some(transmute::<_, unsafe extern "C" fn()>(layout_updated_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
240 }
241 }
242
243 fn connect_group_events_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
252 unsafe extern "C" fn notify_group_events_trampoline<P: IsA<Client>, F: Fn(&P) + 'static>(this: *mut ffi::DbusmenuClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
253 let f: &F = &*(f as *const F);
254 f(Client::from_glib_borrow(this).unsafe_cast_ref())
255 }
256 unsafe {
257 let f: Box_<F> = Box_::new(f);
258 connect_raw(self.as_ptr() as *mut _, b"notify::group-events\0".as_ptr() as *const _,
259 Some(transmute::<_, unsafe extern "C" fn()>(notify_group_events_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
260 }
261 }
262}
263
264impl fmt::Display for Client {
265 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
266 f.write_str("Client")
267 }
268}