libshumate/auto/
symbol_event.rs1use crate::{Location, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "ShumateSymbolEvent")]
71 pub struct SymbolEvent(Object<ffi::ShumateSymbolEvent, ffi::ShumateSymbolEventClass>) @implements Location;
72
73 match fn {
74 type_ => || ffi::shumate_symbol_event_get_type(),
75 }
76}
77
78impl SymbolEvent {
79 pub fn builder() -> SymbolEventBuilder {
84 SymbolEventBuilder::new()
85 }
86
87 #[doc(alias = "shumate_symbol_event_get_feature_id")]
97 #[doc(alias = "get_feature_id")]
98 #[doc(alias = "feature-id")]
99 pub fn feature_id(&self) -> Option<glib::GString> {
100 unsafe {
101 from_glib_none(ffi::shumate_symbol_event_get_feature_id(
102 self.to_glib_none().0,
103 ))
104 }
105 }
106
107 #[doc(alias = "shumate_symbol_event_get_layer")]
118 #[doc(alias = "get_layer")]
119 pub fn layer(&self) -> Option<glib::GString> {
120 unsafe { from_glib_none(ffi::shumate_symbol_event_get_layer(self.to_glib_none().0)) }
121 }
122
123 #[cfg(feature = "v1_5")]
129 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
130 #[doc(alias = "shumate_symbol_event_get_n_press")]
131 #[doc(alias = "get_n_press")]
132 #[doc(alias = "n-press")]
133 pub fn n_press(&self) -> i32 {
134 unsafe { ffi::shumate_symbol_event_get_n_press(self.to_glib_none().0) }
135 }
136
137 #[doc(alias = "shumate_symbol_event_get_source_layer")]
144 #[doc(alias = "get_source_layer")]
145 #[doc(alias = "source-layer")]
146 pub fn source_layer(&self) -> Option<glib::GString> {
147 unsafe {
148 from_glib_none(ffi::shumate_symbol_event_get_source_layer(
149 self.to_glib_none().0,
150 ))
151 }
152 }
153
154 #[doc(alias = "shumate_symbol_event_get_tag")]
166 #[doc(alias = "get_tag")]
167 pub fn tag(&self, tag_name: &str) -> Option<glib::GString> {
168 unsafe {
169 from_glib_none(ffi::shumate_symbol_event_get_tag(
170 self.to_glib_none().0,
171 tag_name.to_glib_none().0,
172 ))
173 }
174 }
175
176 #[cfg(feature = "v1_5")]
178 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
179 #[doc(alias = "n-press")]
180 pub fn set_n_press(&self, n_press: u32) {
181 ObjectExt::set_property(self, "n-press", n_press)
182 }
183
184 #[cfg(not(feature = "v1_1"))]
185 #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1"))))]
186 #[doc(alias = "source-layer")]
187 pub fn source_layer(&self) -> Option<glib::GString> {
188 ObjectExt::property(self, "source-layer")
189 }
190
191 #[cfg(feature = "v1_1")]
192 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
193 #[doc(alias = "feature-id")]
194 pub fn connect_feature_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
195 unsafe extern "C" fn notify_feature_id_trampoline<F: Fn(&SymbolEvent) + 'static>(
196 this: *mut ffi::ShumateSymbolEvent,
197 _param_spec: glib::ffi::gpointer,
198 f: glib::ffi::gpointer,
199 ) {
200 unsafe {
201 let f: &F = &*(f as *const F);
202 f(&from_glib_borrow(this))
203 }
204 }
205 unsafe {
206 let f: Box_<F> = Box_::new(f);
207 connect_raw(
208 self.as_ptr() as *mut _,
209 c"notify::feature-id".as_ptr(),
210 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
211 notify_feature_id_trampoline::<F> as *const (),
212 )),
213 Box_::into_raw(f),
214 )
215 }
216 }
217
218 #[cfg(feature = "v1_1")]
219 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
220 #[doc(alias = "layer")]
221 pub fn connect_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
222 unsafe extern "C" fn notify_layer_trampoline<F: Fn(&SymbolEvent) + 'static>(
223 this: *mut ffi::ShumateSymbolEvent,
224 _param_spec: glib::ffi::gpointer,
225 f: glib::ffi::gpointer,
226 ) {
227 unsafe {
228 let f: &F = &*(f as *const F);
229 f(&from_glib_borrow(this))
230 }
231 }
232 unsafe {
233 let f: Box_<F> = Box_::new(f);
234 connect_raw(
235 self.as_ptr() as *mut _,
236 c"notify::layer".as_ptr(),
237 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
238 notify_layer_trampoline::<F> as *const (),
239 )),
240 Box_::into_raw(f),
241 )
242 }
243 }
244
245 #[cfg(feature = "v1_5")]
246 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
247 #[doc(alias = "n-press")]
248 pub fn connect_n_press_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
249 unsafe extern "C" fn notify_n_press_trampoline<F: Fn(&SymbolEvent) + 'static>(
250 this: *mut ffi::ShumateSymbolEvent,
251 _param_spec: glib::ffi::gpointer,
252 f: glib::ffi::gpointer,
253 ) {
254 unsafe {
255 let f: &F = &*(f as *const F);
256 f(&from_glib_borrow(this))
257 }
258 }
259 unsafe {
260 let f: Box_<F> = Box_::new(f);
261 connect_raw(
262 self.as_ptr() as *mut _,
263 c"notify::n-press".as_ptr(),
264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265 notify_n_press_trampoline::<F> as *const (),
266 )),
267 Box_::into_raw(f),
268 )
269 }
270 }
271
272 #[doc(alias = "source-layer")]
273 pub fn connect_source_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
274 unsafe extern "C" fn notify_source_layer_trampoline<F: Fn(&SymbolEvent) + 'static>(
275 this: *mut ffi::ShumateSymbolEvent,
276 _param_spec: glib::ffi::gpointer,
277 f: glib::ffi::gpointer,
278 ) {
279 unsafe {
280 let f: &F = &*(f as *const F);
281 f(&from_glib_borrow(this))
282 }
283 }
284 unsafe {
285 let f: Box_<F> = Box_::new(f);
286 connect_raw(
287 self.as_ptr() as *mut _,
288 c"notify::source-layer".as_ptr(),
289 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290 notify_source_layer_trampoline::<F> as *const (),
291 )),
292 Box_::into_raw(f),
293 )
294 }
295 }
296}
297
298#[must_use = "The builder must be built to be used"]
303pub struct SymbolEventBuilder {
304 builder: glib::object::ObjectBuilder<'static, SymbolEvent>,
305}
306
307impl SymbolEventBuilder {
308 fn new() -> Self {
309 Self {
310 builder: glib::object::Object::builder(),
311 }
312 }
313
314 #[cfg(feature = "v1_5")]
316 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
317 pub fn n_press(self, n_press: u32) -> Self {
318 Self {
319 builder: self.builder.property("n-press", n_press),
320 }
321 }
322
323 pub fn latitude(self, latitude: f64) -> Self {
325 Self {
326 builder: self.builder.property("latitude", latitude),
327 }
328 }
329
330 pub fn longitude(self, longitude: f64) -> Self {
332 Self {
333 builder: self.builder.property("longitude", longitude),
334 }
335 }
336
337 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
340 pub fn build(self) -> SymbolEvent {
341 assert_initialized_main_thread!();
342 self.builder.build()
343 }
344}