libshumate/auto/marker.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use 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 /// Markers represent points of interest on a map. Markers need to be
16 /// placed on a layer (a [`MarkerLayer`][crate::MarkerLayer]). Layers have to be added to a
17 /// [`Map`][crate::Map] for the markers to show on the map.
18 ///
19 /// A marker is nothing more than a regular [`gtk::Widget`][crate::gtk::Widget]. You can draw on
20 /// it what ever you want. Set the marker's position on the map using
21 /// [`LocationExt::set_location()`][crate::prelude::LocationExt::set_location()].
22 ///
23 /// This is a base class of all markers. A typical usage of a marker is for
24 /// instance to add a `Gtk::Image` with a pin image and add the
25 /// `Gtk::GestureClick` controller to listen to click events and show
26 /// a `Gtk::Popover` with the description of the marker.
27 ///
28 /// ## CSS nodes
29 ///
30 /// `ShumateMarker` has a single CSS node with the name “map-marker”.
31 ///
32 /// ## Properties
33 ///
34 ///
35 /// #### `child`
36 /// The child widget of the marker
37 ///
38 /// Readable | Writeable
39 ///
40 ///
41 /// #### `selectable`
42 /// The selectable state of the marker
43 ///
44 /// Readable | Writeable
45 ///
46 ///
47 /// #### `x-hotspot`
48 /// The x hotspot of the marker, a negative value means that the actual
49 /// x hotspot is calculated with the [`halign`][struct@crate::gtk::Widget#halign] property.
50 /// The x hotspot should not be more than the width of the widget.
51 ///
52 /// Readable | Writeable
53 ///
54 ///
55 /// #### `y-hotspot`
56 /// The y hotspot of the marker, a negative value means that the actual
57 /// y hotspot is calculated with the [`valign`][struct@crate::gtk::Widget#valign] property.
58 /// The y hotspot should not be more than the height of the widget.
59 ///
60 /// Readable | Writeable
61 /// <details><summary><h4>Widget</h4></summary>
62 ///
63 ///
64 /// #### `can-focus`
65 /// Whether the widget or any of its descendents can accept
66 /// the input focus.
67 ///
68 /// This property is meant to be set by widget implementations,
69 /// typically in their instance init function.
70 ///
71 /// Readable | Writeable
72 ///
73 ///
74 /// #### `can-target`
75 /// Whether the widget can receive pointer events.
76 ///
77 /// Readable | Writeable
78 ///
79 ///
80 /// #### `css-classes`
81 /// A list of css classes applied to this widget.
82 ///
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `css-name`
87 /// The name of this widget in the CSS tree.
88 ///
89 /// This property is meant to be set by widget implementations,
90 /// typically in their instance init function.
91 ///
92 /// Readable | Writeable | Construct Only
93 ///
94 ///
95 /// #### `cursor`
96 /// The cursor used by @widget.
97 ///
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `focus-on-click`
102 /// Whether the widget should grab focus when it is clicked with the mouse.
103 ///
104 /// This property is only relevant for widgets that can take focus.
105 ///
106 /// Readable | Writeable
107 ///
108 ///
109 /// #### `focusable`
110 /// Whether this widget itself will accept the input focus.
111 ///
112 /// Readable | Writeable
113 ///
114 ///
115 /// #### `halign`
116 /// How to distribute horizontal space if widget gets extra space.
117 ///
118 /// Readable | Writeable
119 ///
120 ///
121 /// #### `has-default`
122 /// Whether the widget is the default widget.
123 ///
124 /// Readable
125 ///
126 ///
127 /// #### `has-focus`
128 /// Whether the widget has the input focus.
129 ///
130 /// Readable
131 ///
132 ///
133 /// #### `has-tooltip`
134 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
135 /// signal on @widget.
136 ///
137 /// A true value indicates that @widget can have a tooltip, in this case
138 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
139 /// determine whether it will provide a tooltip or not.
140 ///
141 /// Readable | Writeable
142 ///
143 ///
144 /// #### `height-request`
145 /// Overrides for height request of the widget.
146 ///
147 /// If this is -1, the natural request will be used.
148 ///
149 /// Readable | Writeable
150 ///
151 ///
152 /// #### `hexpand`
153 /// Whether to expand horizontally.
154 ///
155 /// Readable | Writeable
156 ///
157 ///
158 /// #### `hexpand-set`
159 /// Whether to use the `hexpand` property.
160 ///
161 /// Readable | Writeable
162 ///
163 ///
164 /// #### `layout-manager`
165 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
166 /// the preferred size of the widget, and allocate its children.
167 ///
168 /// This property is meant to be set by widget implementations,
169 /// typically in their instance init function.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `limit-events`
175 /// Makes this widget act like a modal dialog, with respect to
176 /// event delivery.
177 ///
178 /// Global event controllers will not handle events with targets
179 /// inside the widget, unless they are set up to ignore propagation
180 /// limits. See `Gtk::EventController::set_propagation_limit()`.
181 ///
182 /// Readable | Writeable
183 ///
184 ///
185 /// #### `margin-bottom`
186 /// Margin on bottom side of widget.
187 ///
188 /// This property adds margin outside of the widget's normal size
189 /// request, the margin will be added in addition to the size from
190 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
191 ///
192 /// Readable | Writeable
193 ///
194 ///
195 /// #### `margin-end`
196 /// Margin on end of widget, horizontally.
197 ///
198 /// This property supports left-to-right and right-to-left text
199 /// directions.
200 ///
201 /// This property adds margin outside of the widget's normal size
202 /// request, the margin will be added in addition to the size from
203 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
204 ///
205 /// Readable | Writeable
206 ///
207 ///
208 /// #### `margin-start`
209 /// Margin on start of widget, horizontally.
210 ///
211 /// This property supports left-to-right and right-to-left text
212 /// directions.
213 ///
214 /// This property adds margin outside of the widget's normal size
215 /// request, the margin will be added in addition to the size from
216 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
217 ///
218 /// Readable | Writeable
219 ///
220 ///
221 /// #### `margin-top`
222 /// Margin on top side of widget.
223 ///
224 /// This property adds margin outside of the widget's normal size
225 /// request, the margin will be added in addition to the size from
226 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
227 ///
228 /// Readable | Writeable
229 ///
230 ///
231 /// #### `name`
232 /// The name of the widget.
233 ///
234 /// Readable | Writeable
235 ///
236 ///
237 /// #### `opacity`
238 /// The requested opacity of the widget.
239 ///
240 /// Readable | Writeable
241 ///
242 ///
243 /// #### `overflow`
244 /// How content outside the widget's content area is treated.
245 ///
246 /// This property is meant to be set by widget implementations,
247 /// typically in their instance init function.
248 ///
249 /// Readable | Writeable
250 ///
251 ///
252 /// #### `parent`
253 /// The parent widget of this widget.
254 ///
255 /// Readable
256 ///
257 ///
258 /// #### `receives-default`
259 /// Whether the widget will receive the default action when it is focused.
260 ///
261 /// Readable | Writeable
262 ///
263 ///
264 /// #### `root`
265 /// The `GtkRoot` widget of the widget tree containing this widget.
266 ///
267 /// This will be `NULL` if the widget is not contained in a root widget.
268 ///
269 /// Readable
270 ///
271 ///
272 /// #### `scale-factor`
273 /// The scale factor of the widget.
274 ///
275 /// Readable
276 ///
277 ///
278 /// #### `sensitive`
279 /// Whether the widget responds to input.
280 ///
281 /// Readable | Writeable
282 ///
283 ///
284 /// #### `tooltip-markup`
285 /// Sets the text of tooltip to be the given string, which is marked up
286 /// with Pango markup.
287 ///
288 /// Also see `Gtk::Tooltip::set_markup()`.
289 ///
290 /// This is a convenience property which will take care of getting the
291 /// tooltip shown if the given string is not `NULL`:
292 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
293 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
294 /// the default signal handler.
295 ///
296 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
297 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
298 ///
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `tooltip-text`
303 /// Sets the text of tooltip to be the given string.
304 ///
305 /// Also see `Gtk::Tooltip::set_text()`.
306 ///
307 /// This is a convenience property which will take care of getting the
308 /// tooltip shown if the given string is not `NULL`:
309 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
310 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
311 /// the default signal handler.
312 ///
313 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
314 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
315 ///
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `valign`
320 /// How to distribute vertical space if widget gets extra space.
321 ///
322 /// Readable | Writeable
323 ///
324 ///
325 /// #### `vexpand`
326 /// Whether to expand vertically.
327 ///
328 /// Readable | Writeable
329 ///
330 ///
331 /// #### `vexpand-set`
332 /// Whether to use the `vexpand` property.
333 ///
334 /// Readable | Writeable
335 ///
336 ///
337 /// #### `visible`
338 /// Whether the widget is visible.
339 ///
340 /// Readable | Writeable
341 ///
342 ///
343 /// #### `width-request`
344 /// Overrides for width request of the widget.
345 ///
346 /// If this is -1, the natural request will be used.
347 ///
348 /// Readable | Writeable
349 /// </details>
350 /// <details><summary><h4>Accessible</h4></summary>
351 ///
352 ///
353 /// #### `accessible-role`
354 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
355 ///
356 /// The accessible role cannot be changed once set.
357 ///
358 /// Readable | Writeable
359 /// </details>
360 /// <details><summary><h4>Location</h4></summary>
361 ///
362 ///
363 /// #### `latitude`
364 /// The latitude coordonate in degrees
365 ///
366 /// Readable | Writeable
367 ///
368 ///
369 /// #### `longitude`
370 /// The longitude coordonate in degrees
371 ///
372 /// Readable | Writeable
373 /// </details>
374 ///
375 /// # Implements
376 ///
377 /// [`MarkerExt`][trait@crate::prelude::MarkerExt], [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`LocationExt`][trait@crate::prelude::LocationExt]
378 #[doc(alias = "ShumateMarker")]
379 pub struct Marker(Object<ffi::ShumateMarker, ffi::ShumateMarkerClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Location;
380
381 match fn {
382 type_ => || ffi::shumate_marker_get_type(),
383 }
384}
385
386impl Marker {
387 pub const NONE: Option<&'static Marker> = None;
388
389 /// Creates an instance of #ShumateMarker.
390 ///
391 /// # Returns
392 ///
393 /// a new #ShumateMarker.
394 #[doc(alias = "shumate_marker_new")]
395 pub fn new() -> Marker {
396 assert_initialized_main_thread!();
397 unsafe { from_glib_none(ffi::shumate_marker_new()) }
398 }
399
400 // rustdoc-stripper-ignore-next
401 /// Creates a new builder-pattern struct instance to construct [`Marker`] objects.
402 ///
403 /// This method returns an instance of [`MarkerBuilder`](crate::builders::MarkerBuilder) which can be used to create [`Marker`] objects.
404 pub fn builder() -> MarkerBuilder {
405 MarkerBuilder::new()
406 }
407}
408
409impl Default for Marker {
410 fn default() -> Self {
411 Self::new()
412 }
413}
414
415// rustdoc-stripper-ignore-next
416/// A [builder-pattern] type to construct [`Marker`] objects.
417///
418/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
419#[must_use = "The builder must be built to be used"]
420pub struct MarkerBuilder {
421 builder: glib::object::ObjectBuilder<'static, Marker>,
422}
423
424impl MarkerBuilder {
425 fn new() -> Self {
426 Self {
427 builder: glib::object::Object::builder(),
428 }
429 }
430
431 /// The child widget of the marker
432 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
433 Self {
434 builder: self.builder.property("child", child.clone().upcast()),
435 }
436 }
437
438 /// The selectable state of the marker
439 pub fn selectable(self, selectable: bool) -> Self {
440 Self {
441 builder: self.builder.property("selectable", selectable),
442 }
443 }
444
445 /// The x hotspot of the marker, a negative value means that the actual
446 /// x hotspot is calculated with the [`halign`][struct@crate::gtk::Widget#halign] property.
447 /// The x hotspot should not be more than the width of the widget.
448 #[cfg(feature = "v1_5")]
449 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
450 pub fn x_hotspot(self, x_hotspot: f64) -> Self {
451 Self {
452 builder: self.builder.property("x-hotspot", x_hotspot),
453 }
454 }
455
456 /// The y hotspot of the marker, a negative value means that the actual
457 /// y hotspot is calculated with the [`valign`][struct@crate::gtk::Widget#valign] property.
458 /// The y hotspot should not be more than the height of the widget.
459 #[cfg(feature = "v1_5")]
460 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
461 pub fn y_hotspot(self, y_hotspot: f64) -> Self {
462 Self {
463 builder: self.builder.property("y-hotspot", y_hotspot),
464 }
465 }
466
467 /// Whether the widget or any of its descendents can accept
468 /// the input focus.
469 ///
470 /// This property is meant to be set by widget implementations,
471 /// typically in their instance init function.
472 pub fn can_focus(self, can_focus: bool) -> Self {
473 Self {
474 builder: self.builder.property("can-focus", can_focus),
475 }
476 }
477
478 /// Whether the widget can receive pointer events.
479 pub fn can_target(self, can_target: bool) -> Self {
480 Self {
481 builder: self.builder.property("can-target", can_target),
482 }
483 }
484
485 /// A list of css classes applied to this widget.
486 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
487 Self {
488 builder: self.builder.property("css-classes", css_classes.into()),
489 }
490 }
491
492 /// The name of this widget in the CSS tree.
493 ///
494 /// This property is meant to be set by widget implementations,
495 /// typically in their instance init function.
496 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
497 Self {
498 builder: self.builder.property("css-name", css_name.into()),
499 }
500 }
501
502 /// The cursor used by @widget.
503 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
504 Self {
505 builder: self.builder.property("cursor", cursor.clone()),
506 }
507 }
508
509 /// Whether the widget should grab focus when it is clicked with the mouse.
510 ///
511 /// This property is only relevant for widgets that can take focus.
512 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
513 Self {
514 builder: self.builder.property("focus-on-click", focus_on_click),
515 }
516 }
517
518 /// Whether this widget itself will accept the input focus.
519 pub fn focusable(self, focusable: bool) -> Self {
520 Self {
521 builder: self.builder.property("focusable", focusable),
522 }
523 }
524
525 /// How to distribute horizontal space if widget gets extra space.
526 pub fn halign(self, halign: gtk::Align) -> Self {
527 Self {
528 builder: self.builder.property("halign", halign),
529 }
530 }
531
532 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
533 /// signal on @widget.
534 ///
535 /// A true value indicates that @widget can have a tooltip, in this case
536 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
537 /// determine whether it will provide a tooltip or not.
538 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
539 Self {
540 builder: self.builder.property("has-tooltip", has_tooltip),
541 }
542 }
543
544 /// Overrides for height request of the widget.
545 ///
546 /// If this is -1, the natural request will be used.
547 pub fn height_request(self, height_request: i32) -> Self {
548 Self {
549 builder: self.builder.property("height-request", height_request),
550 }
551 }
552
553 /// Whether to expand horizontally.
554 pub fn hexpand(self, hexpand: bool) -> Self {
555 Self {
556 builder: self.builder.property("hexpand", hexpand),
557 }
558 }
559
560 /// Whether to use the `hexpand` property.
561 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
562 Self {
563 builder: self.builder.property("hexpand-set", hexpand_set),
564 }
565 }
566
567 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
568 /// the preferred size of the widget, and allocate its children.
569 ///
570 /// This property is meant to be set by widget implementations,
571 /// typically in their instance init function.
572 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
573 Self {
574 builder: self
575 .builder
576 .property("layout-manager", layout_manager.clone().upcast()),
577 }
578 }
579
580 /// Makes this widget act like a modal dialog, with respect to
581 /// event delivery.
582 ///
583 /// Global event controllers will not handle events with targets
584 /// inside the widget, unless they are set up to ignore propagation
585 /// limits. See `Gtk::EventController::set_propagation_limit()`.
586 #[cfg(feature = "gtk_v4_18")]
587 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
588 pub fn limit_events(self, limit_events: bool) -> Self {
589 Self {
590 builder: self.builder.property("limit-events", limit_events),
591 }
592 }
593
594 /// Margin on bottom side of widget.
595 ///
596 /// This property adds margin outside of the widget's normal size
597 /// request, the margin will be added in addition to the size from
598 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
599 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
600 Self {
601 builder: self.builder.property("margin-bottom", margin_bottom),
602 }
603 }
604
605 /// Margin on end of widget, horizontally.
606 ///
607 /// This property supports left-to-right and right-to-left text
608 /// directions.
609 ///
610 /// This property adds margin outside of the widget's normal size
611 /// request, the margin will be added in addition to the size from
612 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
613 pub fn margin_end(self, margin_end: i32) -> Self {
614 Self {
615 builder: self.builder.property("margin-end", margin_end),
616 }
617 }
618
619 /// Margin on start of widget, horizontally.
620 ///
621 /// This property supports left-to-right and right-to-left text
622 /// directions.
623 ///
624 /// This property adds margin outside of the widget's normal size
625 /// request, the margin will be added in addition to the size from
626 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
627 pub fn margin_start(self, margin_start: i32) -> Self {
628 Self {
629 builder: self.builder.property("margin-start", margin_start),
630 }
631 }
632
633 /// Margin on top side of widget.
634 ///
635 /// This property adds margin outside of the widget's normal size
636 /// request, the margin will be added in addition to the size from
637 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
638 pub fn margin_top(self, margin_top: i32) -> Self {
639 Self {
640 builder: self.builder.property("margin-top", margin_top),
641 }
642 }
643
644 /// The name of the widget.
645 pub fn name(self, name: impl Into<glib::GString>) -> Self {
646 Self {
647 builder: self.builder.property("name", name.into()),
648 }
649 }
650
651 /// The requested opacity of the widget.
652 pub fn opacity(self, opacity: f64) -> Self {
653 Self {
654 builder: self.builder.property("opacity", opacity),
655 }
656 }
657
658 /// How content outside the widget's content area is treated.
659 ///
660 /// This property is meant to be set by widget implementations,
661 /// typically in their instance init function.
662 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
663 Self {
664 builder: self.builder.property("overflow", overflow),
665 }
666 }
667
668 /// Whether the widget will receive the default action when it is focused.
669 pub fn receives_default(self, receives_default: bool) -> Self {
670 Self {
671 builder: self.builder.property("receives-default", receives_default),
672 }
673 }
674
675 /// Whether the widget responds to input.
676 pub fn sensitive(self, sensitive: bool) -> Self {
677 Self {
678 builder: self.builder.property("sensitive", sensitive),
679 }
680 }
681
682 /// Sets the text of tooltip to be the given string, which is marked up
683 /// with Pango markup.
684 ///
685 /// Also see `Gtk::Tooltip::set_markup()`.
686 ///
687 /// This is a convenience property which will take care of getting the
688 /// tooltip shown if the given string is not `NULL`:
689 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
690 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
691 /// the default signal handler.
692 ///
693 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
694 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
695 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
696 Self {
697 builder: self
698 .builder
699 .property("tooltip-markup", tooltip_markup.into()),
700 }
701 }
702
703 /// Sets the text of tooltip to be the given string.
704 ///
705 /// Also see `Gtk::Tooltip::set_text()`.
706 ///
707 /// This is a convenience property which will take care of getting the
708 /// tooltip shown if the given string is not `NULL`:
709 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
710 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
711 /// the default signal handler.
712 ///
713 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
714 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
715 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
716 Self {
717 builder: self.builder.property("tooltip-text", tooltip_text.into()),
718 }
719 }
720
721 /// How to distribute vertical space if widget gets extra space.
722 pub fn valign(self, valign: gtk::Align) -> Self {
723 Self {
724 builder: self.builder.property("valign", valign),
725 }
726 }
727
728 /// Whether to expand vertically.
729 pub fn vexpand(self, vexpand: bool) -> Self {
730 Self {
731 builder: self.builder.property("vexpand", vexpand),
732 }
733 }
734
735 /// Whether to use the `vexpand` property.
736 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
737 Self {
738 builder: self.builder.property("vexpand-set", vexpand_set),
739 }
740 }
741
742 /// Whether the widget is visible.
743 pub fn visible(self, visible: bool) -> Self {
744 Self {
745 builder: self.builder.property("visible", visible),
746 }
747 }
748
749 /// Overrides for width request of the widget.
750 ///
751 /// If this is -1, the natural request will be used.
752 pub fn width_request(self, width_request: i32) -> Self {
753 Self {
754 builder: self.builder.property("width-request", width_request),
755 }
756 }
757
758 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
759 ///
760 /// The accessible role cannot be changed once set.
761 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
762 Self {
763 builder: self.builder.property("accessible-role", accessible_role),
764 }
765 }
766
767 /// The latitude coordonate in degrees
768 pub fn latitude(self, latitude: f64) -> Self {
769 Self {
770 builder: self.builder.property("latitude", latitude),
771 }
772 }
773
774 /// The longitude coordonate in degrees
775 pub fn longitude(self, longitude: f64) -> Self {
776 Self {
777 builder: self.builder.property("longitude", longitude),
778 }
779 }
780
781 // rustdoc-stripper-ignore-next
782 /// Build the [`Marker`].
783 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
784 pub fn build(self) -> Marker {
785 assert_initialized_main_thread!();
786 self.builder.build()
787 }
788}
789
790/// Trait containing all [`struct@Marker`] methods.
791///
792/// # Implementors
793///
794/// [`Marker`][struct@crate::Marker], [`Point`][struct@crate::Point]
795pub trait MarkerExt: IsA<Marker> + 'static {
796 #[doc(alias = "shumate_marker_animate_in")]
797 fn animate_in(&self) {
798 unsafe {
799 ffi::shumate_marker_animate_in(self.as_ref().to_glib_none().0);
800 }
801 }
802
803 #[doc(alias = "shumate_marker_animate_in_with_delay")]
804 fn animate_in_with_delay(&self, delay: u32) {
805 unsafe {
806 ffi::shumate_marker_animate_in_with_delay(self.as_ref().to_glib_none().0, delay);
807 }
808 }
809
810 #[doc(alias = "shumate_marker_animate_out")]
811 fn animate_out(&self) {
812 unsafe {
813 ffi::shumate_marker_animate_out(self.as_ref().to_glib_none().0);
814 }
815 }
816
817 #[doc(alias = "shumate_marker_animate_out_with_delay")]
818 fn animate_out_with_delay(&self, delay: u32) {
819 unsafe {
820 ffi::shumate_marker_animate_out_with_delay(self.as_ref().to_glib_none().0, delay);
821 }
822 }
823
824 /// Retrieves the current child of @self.
825 ///
826 /// # Returns
827 ///
828 /// a #GtkWidget.
829 #[doc(alias = "shumate_marker_get_child")]
830 #[doc(alias = "get_child")]
831 fn child(&self) -> Option<gtk::Widget> {
832 unsafe {
833 from_glib_none(ffi::shumate_marker_get_child(
834 self.as_ref().to_glib_none().0,
835 ))
836 }
837 }
838
839 #[doc(alias = "shumate_marker_get_draggable")]
840 #[doc(alias = "get_draggable")]
841 fn is_draggable(&self) -> bool {
842 unsafe {
843 from_glib(ffi::shumate_marker_get_draggable(
844 self.as_ref().to_glib_none().0,
845 ))
846 }
847 }
848
849 /// Get the hotspot point for the given marker. The value is in pixel relative
850 /// to the top-left corner. Any negative value means that the hotspot get
851 /// computed with the [`halign`][struct@crate::gtk::Widget#halign] or [`valign`][struct@crate::gtk::Widget#valign]
852 /// properties.
853 ///
854 /// # Returns
855 ///
856 ///
857 /// ## `x_hotspot`
858 /// return value for the x hotspot
859 ///
860 /// ## `y_hotspot`
861 /// return value for the y hotspot
862 #[cfg(feature = "v1_5")]
863 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
864 #[doc(alias = "shumate_marker_get_hotspot")]
865 #[doc(alias = "get_hotspot")]
866 fn hotspot(&self) -> (f64, f64) {
867 unsafe {
868 let mut x_hotspot = std::mem::MaybeUninit::uninit();
869 let mut y_hotspot = std::mem::MaybeUninit::uninit();
870 ffi::shumate_marker_get_hotspot(
871 self.as_ref().to_glib_none().0,
872 x_hotspot.as_mut_ptr(),
873 y_hotspot.as_mut_ptr(),
874 );
875 (x_hotspot.assume_init(), y_hotspot.assume_init())
876 }
877 }
878
879 /// Checks whether the marker is selectable.
880 ///
881 /// # Returns
882 ///
883 /// the selectable or not state of the marker.
884 #[doc(alias = "shumate_marker_get_selectable")]
885 #[doc(alias = "get_selectable")]
886 #[doc(alias = "selectable")]
887 fn is_selectable(&self) -> bool {
888 unsafe {
889 from_glib(ffi::shumate_marker_get_selectable(
890 self.as_ref().to_glib_none().0,
891 ))
892 }
893 }
894
895 /// Checks whether the marker is selected.
896 ///
897 /// # Returns
898 ///
899 /// [`true`] if the marker is selected, otherwise [`false`]
900 #[doc(alias = "shumate_marker_is_selected")]
901 fn is_selected(&self) -> bool {
902 unsafe {
903 from_glib(ffi::shumate_marker_is_selected(
904 self.as_ref().to_glib_none().0,
905 ))
906 }
907 }
908
909 /// Sets the child widget of @self.
910 /// ## `child`
911 /// a #GtkWidget
912 #[doc(alias = "shumate_marker_set_child")]
913 #[doc(alias = "child")]
914 fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
915 unsafe {
916 ffi::shumate_marker_set_child(
917 self.as_ref().to_glib_none().0,
918 child.map(|p| p.as_ref()).to_glib_none().0,
919 );
920 }
921 }
922
923 #[doc(alias = "shumate_marker_set_draggable")]
924 fn set_draggable(&self, value: bool) {
925 unsafe {
926 ffi::shumate_marker_set_draggable(self.as_ref().to_glib_none().0, value.into_glib());
927 }
928 }
929
930 /// Set the hotspot point for the given marker. The value is in pixel relative
931 /// to the top-left corner. Use any negative value to fallback to the
932 /// [`halign`][struct@crate::gtk::Widget#halign] or [`valign`][struct@crate::gtk::Widget#valign] properties.
933 /// ## `x_hotspot`
934 /// the x hotspot
935 /// ## `y_hotspot`
936 /// the y hotspot
937 #[cfg(feature = "v1_5")]
938 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
939 #[doc(alias = "shumate_marker_set_hotspot")]
940 fn set_hotspot(&self, x_hotspot: f64, y_hotspot: f64) {
941 unsafe {
942 ffi::shumate_marker_set_hotspot(self.as_ref().to_glib_none().0, x_hotspot, y_hotspot);
943 }
944 }
945
946 /// Sets the marker as selectable or not.
947 /// ## `value`
948 /// the selectable state
949 #[doc(alias = "shumate_marker_set_selectable")]
950 #[doc(alias = "selectable")]
951 fn set_selectable(&self, value: bool) {
952 unsafe {
953 ffi::shumate_marker_set_selectable(self.as_ref().to_glib_none().0, value.into_glib());
954 }
955 }
956
957 /// The x hotspot of the marker, a negative value means that the actual
958 /// x hotspot is calculated with the [`halign`][struct@crate::gtk::Widget#halign] property.
959 /// The x hotspot should not be more than the width of the widget.
960 #[cfg(feature = "v1_5")]
961 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
962 #[doc(alias = "x-hotspot")]
963 fn x_hotspot(&self) -> f64 {
964 ObjectExt::property(self.as_ref(), "x-hotspot")
965 }
966
967 /// The x hotspot of the marker, a negative value means that the actual
968 /// x hotspot is calculated with the [`halign`][struct@crate::gtk::Widget#halign] property.
969 /// The x hotspot should not be more than the width of the widget.
970 #[cfg(feature = "v1_5")]
971 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
972 #[doc(alias = "x-hotspot")]
973 fn set_x_hotspot(&self, x_hotspot: f64) {
974 ObjectExt::set_property(self.as_ref(), "x-hotspot", x_hotspot)
975 }
976
977 /// The y hotspot of the marker, a negative value means that the actual
978 /// y hotspot is calculated with the [`valign`][struct@crate::gtk::Widget#valign] property.
979 /// The y hotspot should not be more than the height of the widget.
980 #[cfg(feature = "v1_5")]
981 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
982 #[doc(alias = "y-hotspot")]
983 fn y_hotspot(&self) -> f64 {
984 ObjectExt::property(self.as_ref(), "y-hotspot")
985 }
986
987 /// The y hotspot of the marker, a negative value means that the actual
988 /// y hotspot is calculated with the [`valign`][struct@crate::gtk::Widget#valign] property.
989 /// The y hotspot should not be more than the height of the widget.
990 #[cfg(feature = "v1_5")]
991 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
992 #[doc(alias = "y-hotspot")]
993 fn set_y_hotspot(&self, y_hotspot: f64) {
994 ObjectExt::set_property(self.as_ref(), "y-hotspot", y_hotspot)
995 }
996
997 #[doc(alias = "child")]
998 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
999 unsafe extern "C" fn notify_child_trampoline<P: IsA<Marker>, F: Fn(&P) + 'static>(
1000 this: *mut ffi::ShumateMarker,
1001 _param_spec: glib::ffi::gpointer,
1002 f: glib::ffi::gpointer,
1003 ) {
1004 unsafe {
1005 let f: &F = &*(f as *const F);
1006 f(Marker::from_glib_borrow(this).unsafe_cast_ref())
1007 }
1008 }
1009 unsafe {
1010 let f: Box_<F> = Box_::new(f);
1011 connect_raw(
1012 self.as_ptr() as *mut _,
1013 c"notify::child".as_ptr(),
1014 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1015 notify_child_trampoline::<Self, F> as *const (),
1016 )),
1017 Box_::into_raw(f),
1018 )
1019 }
1020 }
1021
1022 #[doc(alias = "selectable")]
1023 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1024 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<Marker>, F: Fn(&P) + 'static>(
1025 this: *mut ffi::ShumateMarker,
1026 _param_spec: glib::ffi::gpointer,
1027 f: glib::ffi::gpointer,
1028 ) {
1029 unsafe {
1030 let f: &F = &*(f as *const F);
1031 f(Marker::from_glib_borrow(this).unsafe_cast_ref())
1032 }
1033 }
1034 unsafe {
1035 let f: Box_<F> = Box_::new(f);
1036 connect_raw(
1037 self.as_ptr() as *mut _,
1038 c"notify::selectable".as_ptr(),
1039 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1040 notify_selectable_trampoline::<Self, F> as *const (),
1041 )),
1042 Box_::into_raw(f),
1043 )
1044 }
1045 }
1046
1047 #[cfg(feature = "v1_5")]
1048 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1049 #[doc(alias = "x-hotspot")]
1050 fn connect_x_hotspot_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1051 unsafe extern "C" fn notify_x_hotspot_trampoline<P: IsA<Marker>, F: Fn(&P) + 'static>(
1052 this: *mut ffi::ShumateMarker,
1053 _param_spec: glib::ffi::gpointer,
1054 f: glib::ffi::gpointer,
1055 ) {
1056 unsafe {
1057 let f: &F = &*(f as *const F);
1058 f(Marker::from_glib_borrow(this).unsafe_cast_ref())
1059 }
1060 }
1061 unsafe {
1062 let f: Box_<F> = Box_::new(f);
1063 connect_raw(
1064 self.as_ptr() as *mut _,
1065 c"notify::x-hotspot".as_ptr(),
1066 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1067 notify_x_hotspot_trampoline::<Self, F> as *const (),
1068 )),
1069 Box_::into_raw(f),
1070 )
1071 }
1072 }
1073
1074 #[cfg(feature = "v1_5")]
1075 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1076 #[doc(alias = "y-hotspot")]
1077 fn connect_y_hotspot_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1078 unsafe extern "C" fn notify_y_hotspot_trampoline<P: IsA<Marker>, F: Fn(&P) + 'static>(
1079 this: *mut ffi::ShumateMarker,
1080 _param_spec: glib::ffi::gpointer,
1081 f: glib::ffi::gpointer,
1082 ) {
1083 unsafe {
1084 let f: &F = &*(f as *const F);
1085 f(Marker::from_glib_borrow(this).unsafe_cast_ref())
1086 }
1087 }
1088 unsafe {
1089 let f: Box_<F> = Box_::new(f);
1090 connect_raw(
1091 self.as_ptr() as *mut _,
1092 c"notify::y-hotspot".as_ptr(),
1093 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1094 notify_y_hotspot_trampoline::<Self, F> as *const (),
1095 )),
1096 Box_::into_raw(f),
1097 )
1098 }
1099 }
1100}
1101
1102impl<O: IsA<Marker>> MarkerExt for O {}