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