1use gdk;
6use gio;
7use glib::object::Cast;
8use glib::object::IsA;
9use glib::signal::connect_raw;
10use glib::signal::SignalHandlerId;
11use glib::translate::*;
12use glib::StaticType;
13use glib::ToValue;
14use glib_sys;
15use gtk_sys;
16use std::boxed::Box as Box_;
17use std::fmt;
18use std::mem::transmute;
19use Align;
20use Bin;
21use Buildable;
22use Container;
23#[cfg(any(feature = "v3_20", feature = "dox"))]
24use PopoverConstraint;
25use PositionType;
26use ResizeMode;
27use Widget;
28
29glib_wrapper! {
30 pub struct Popover(Object<gtk_sys::GtkPopover, gtk_sys::GtkPopoverClass, PopoverClass>) @extends Bin, Container, Widget, @implements Buildable;
31
32 match fn {
33 get_type => || gtk_sys::gtk_popover_get_type(),
34 }
35}
36
37impl Popover {
38 pub fn new<P: IsA<Widget>>(relative_to: Option<&P>) -> Popover {
39 assert_initialized_main_thread!();
40 unsafe {
41 Widget::from_glib_none(gtk_sys::gtk_popover_new(
42 relative_to.map(|p| p.as_ref()).to_glib_none().0,
43 ))
44 .unsafe_cast()
45 }
46 }
47
48 pub fn new_from_model<P: IsA<Widget>, Q: IsA<gio::MenuModel>>(
49 relative_to: Option<&P>,
50 model: &Q,
51 ) -> Popover {
52 assert_initialized_main_thread!();
53 unsafe {
54 Widget::from_glib_none(gtk_sys::gtk_popover_new_from_model(
55 relative_to.map(|p| p.as_ref()).to_glib_none().0,
56 model.as_ref().to_glib_none().0,
57 ))
58 .unsafe_cast()
59 }
60 }
61}
62
63pub struct PopoverBuilder {
64 #[cfg(any(feature = "v3_20", feature = "dox"))]
65 constrain_to: Option<PopoverConstraint>,
66 modal: Option<bool>,
67 pointing_to: Option<gdk::Rectangle>,
68 position: Option<PositionType>,
69 relative_to: Option<Widget>,
70 #[cfg(any(feature = "v3_16", feature = "dox"))]
71 transitions_enabled: Option<bool>,
72 border_width: Option<u32>,
73 child: Option<Widget>,
74 resize_mode: Option<ResizeMode>,
75 app_paintable: Option<bool>,
76 can_default: Option<bool>,
77 can_focus: Option<bool>,
78 events: Option<gdk::EventMask>,
79 expand: Option<bool>,
80 #[cfg(any(feature = "v3_20", feature = "dox"))]
81 focus_on_click: Option<bool>,
82 halign: Option<Align>,
83 has_default: Option<bool>,
84 has_focus: Option<bool>,
85 has_tooltip: Option<bool>,
86 height_request: Option<i32>,
87 hexpand: Option<bool>,
88 hexpand_set: Option<bool>,
89 is_focus: Option<bool>,
90 margin: Option<i32>,
91 margin_bottom: Option<i32>,
92 margin_end: Option<i32>,
93 margin_start: Option<i32>,
94 margin_top: Option<i32>,
95 name: Option<String>,
96 no_show_all: Option<bool>,
97 opacity: Option<f64>,
98 parent: Option<Container>,
99 receives_default: Option<bool>,
100 sensitive: Option<bool>,
101 tooltip_markup: Option<String>,
103 tooltip_text: Option<String>,
104 valign: Option<Align>,
105 vexpand: Option<bool>,
106 vexpand_set: Option<bool>,
107 visible: Option<bool>,
108 width_request: Option<i32>,
109}
110
111impl PopoverBuilder {
112 pub fn new() -> Self {
113 Self {
114 #[cfg(any(feature = "v3_20", feature = "dox"))]
115 constrain_to: None,
116 modal: None,
117 pointing_to: None,
118 position: None,
119 relative_to: None,
120 #[cfg(any(feature = "v3_16", feature = "dox"))]
121 transitions_enabled: None,
122 border_width: None,
123 child: None,
124 resize_mode: None,
125 app_paintable: None,
126 can_default: None,
127 can_focus: None,
128 events: None,
129 expand: None,
130 #[cfg(any(feature = "v3_20", feature = "dox"))]
131 focus_on_click: None,
132 halign: None,
133 has_default: None,
134 has_focus: None,
135 has_tooltip: None,
136 height_request: None,
137 hexpand: None,
138 hexpand_set: None,
139 is_focus: None,
140 margin: None,
141 margin_bottom: None,
142 margin_end: None,
143 margin_start: None,
144 margin_top: None,
145 name: None,
146 no_show_all: None,
147 opacity: None,
148 parent: None,
149 receives_default: None,
150 sensitive: None,
151 tooltip_markup: None,
152 tooltip_text: None,
153 valign: None,
154 vexpand: None,
155 vexpand_set: None,
156 visible: None,
157 width_request: None,
158 }
159 }
160
161 pub fn build(self) -> Popover {
162 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
163 #[cfg(any(feature = "v3_20", feature = "dox"))]
164 {
165 if let Some(ref constrain_to) = self.constrain_to {
166 properties.push(("constrain-to", constrain_to));
167 }
168 }
169 if let Some(ref modal) = self.modal {
170 properties.push(("modal", modal));
171 }
172 if let Some(ref pointing_to) = self.pointing_to {
173 properties.push(("pointing-to", pointing_to));
174 }
175 if let Some(ref position) = self.position {
176 properties.push(("position", position));
177 }
178 if let Some(ref relative_to) = self.relative_to {
179 properties.push(("relative-to", relative_to));
180 }
181 #[cfg(any(feature = "v3_16", feature = "dox"))]
182 {
183 if let Some(ref transitions_enabled) = self.transitions_enabled {
184 properties.push(("transitions-enabled", transitions_enabled));
185 }
186 }
187 if let Some(ref border_width) = self.border_width {
188 properties.push(("border-width", border_width));
189 }
190 if let Some(ref child) = self.child {
191 properties.push(("child", child));
192 }
193 if let Some(ref resize_mode) = self.resize_mode {
194 properties.push(("resize-mode", resize_mode));
195 }
196 if let Some(ref app_paintable) = self.app_paintable {
197 properties.push(("app-paintable", app_paintable));
198 }
199 if let Some(ref can_default) = self.can_default {
200 properties.push(("can-default", can_default));
201 }
202 if let Some(ref can_focus) = self.can_focus {
203 properties.push(("can-focus", can_focus));
204 }
205 if let Some(ref events) = self.events {
206 properties.push(("events", events));
207 }
208 if let Some(ref expand) = self.expand {
209 properties.push(("expand", expand));
210 }
211 #[cfg(any(feature = "v3_20", feature = "dox"))]
212 {
213 if let Some(ref focus_on_click) = self.focus_on_click {
214 properties.push(("focus-on-click", focus_on_click));
215 }
216 }
217 if let Some(ref halign) = self.halign {
218 properties.push(("halign", halign));
219 }
220 if let Some(ref has_default) = self.has_default {
221 properties.push(("has-default", has_default));
222 }
223 if let Some(ref has_focus) = self.has_focus {
224 properties.push(("has-focus", has_focus));
225 }
226 if let Some(ref has_tooltip) = self.has_tooltip {
227 properties.push(("has-tooltip", has_tooltip));
228 }
229 if let Some(ref height_request) = self.height_request {
230 properties.push(("height-request", height_request));
231 }
232 if let Some(ref hexpand) = self.hexpand {
233 properties.push(("hexpand", hexpand));
234 }
235 if let Some(ref hexpand_set) = self.hexpand_set {
236 properties.push(("hexpand-set", hexpand_set));
237 }
238 if let Some(ref is_focus) = self.is_focus {
239 properties.push(("is-focus", is_focus));
240 }
241 if let Some(ref margin) = self.margin {
242 properties.push(("margin", margin));
243 }
244 if let Some(ref margin_bottom) = self.margin_bottom {
245 properties.push(("margin-bottom", margin_bottom));
246 }
247 if let Some(ref margin_end) = self.margin_end {
248 properties.push(("margin-end", margin_end));
249 }
250 if let Some(ref margin_start) = self.margin_start {
251 properties.push(("margin-start", margin_start));
252 }
253 if let Some(ref margin_top) = self.margin_top {
254 properties.push(("margin-top", margin_top));
255 }
256 if let Some(ref name) = self.name {
257 properties.push(("name", name));
258 }
259 if let Some(ref no_show_all) = self.no_show_all {
260 properties.push(("no-show-all", no_show_all));
261 }
262 if let Some(ref opacity) = self.opacity {
263 properties.push(("opacity", opacity));
264 }
265 if let Some(ref parent) = self.parent {
266 properties.push(("parent", parent));
267 }
268 if let Some(ref receives_default) = self.receives_default {
269 properties.push(("receives-default", receives_default));
270 }
271 if let Some(ref sensitive) = self.sensitive {
272 properties.push(("sensitive", sensitive));
273 }
274 if let Some(ref tooltip_markup) = self.tooltip_markup {
275 properties.push(("tooltip-markup", tooltip_markup));
276 }
277 if let Some(ref tooltip_text) = self.tooltip_text {
278 properties.push(("tooltip-text", tooltip_text));
279 }
280 if let Some(ref valign) = self.valign {
281 properties.push(("valign", valign));
282 }
283 if let Some(ref vexpand) = self.vexpand {
284 properties.push(("vexpand", vexpand));
285 }
286 if let Some(ref vexpand_set) = self.vexpand_set {
287 properties.push(("vexpand-set", vexpand_set));
288 }
289 if let Some(ref visible) = self.visible {
290 properties.push(("visible", visible));
291 }
292 if let Some(ref width_request) = self.width_request {
293 properties.push(("width-request", width_request));
294 }
295 glib::Object::new(Popover::static_type(), &properties)
296 .expect("object new")
297 .downcast()
298 .expect("downcast")
299 }
300
301 #[cfg(any(feature = "v3_20", feature = "dox"))]
302 pub fn constrain_to(mut self, constrain_to: PopoverConstraint) -> Self {
303 self.constrain_to = Some(constrain_to);
304 self
305 }
306
307 pub fn modal(mut self, modal: bool) -> Self {
308 self.modal = Some(modal);
309 self
310 }
311
312 pub fn pointing_to(mut self, pointing_to: &gdk::Rectangle) -> Self {
313 self.pointing_to = Some(pointing_to.clone());
314 self
315 }
316
317 pub fn position(mut self, position: PositionType) -> Self {
318 self.position = Some(position);
319 self
320 }
321
322 pub fn relative_to(mut self, relative_to: &Widget) -> Self {
323 self.relative_to = Some(relative_to.clone());
324 self
325 }
326
327 #[cfg(any(feature = "v3_16", feature = "dox"))]
328 pub fn transitions_enabled(mut self, transitions_enabled: bool) -> Self {
329 self.transitions_enabled = Some(transitions_enabled);
330 self
331 }
332
333 pub fn border_width(mut self, border_width: u32) -> Self {
334 self.border_width = Some(border_width);
335 self
336 }
337
338 pub fn child(mut self, child: &Widget) -> Self {
339 self.child = Some(child.clone());
340 self
341 }
342
343 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
344 self.resize_mode = Some(resize_mode);
345 self
346 }
347
348 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
349 self.app_paintable = Some(app_paintable);
350 self
351 }
352
353 pub fn can_default(mut self, can_default: bool) -> Self {
354 self.can_default = Some(can_default);
355 self
356 }
357
358 pub fn can_focus(mut self, can_focus: bool) -> Self {
359 self.can_focus = Some(can_focus);
360 self
361 }
362
363 pub fn events(mut self, events: gdk::EventMask) -> Self {
364 self.events = Some(events);
365 self
366 }
367
368 pub fn expand(mut self, expand: bool) -> Self {
369 self.expand = Some(expand);
370 self
371 }
372
373 #[cfg(any(feature = "v3_20", feature = "dox"))]
374 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
375 self.focus_on_click = Some(focus_on_click);
376 self
377 }
378
379 pub fn halign(mut self, halign: Align) -> Self {
380 self.halign = Some(halign);
381 self
382 }
383
384 pub fn has_default(mut self, has_default: bool) -> Self {
385 self.has_default = Some(has_default);
386 self
387 }
388
389 pub fn has_focus(mut self, has_focus: bool) -> Self {
390 self.has_focus = Some(has_focus);
391 self
392 }
393
394 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
395 self.has_tooltip = Some(has_tooltip);
396 self
397 }
398
399 pub fn height_request(mut self, height_request: i32) -> Self {
400 self.height_request = Some(height_request);
401 self
402 }
403
404 pub fn hexpand(mut self, hexpand: bool) -> Self {
405 self.hexpand = Some(hexpand);
406 self
407 }
408
409 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
410 self.hexpand_set = Some(hexpand_set);
411 self
412 }
413
414 pub fn is_focus(mut self, is_focus: bool) -> Self {
415 self.is_focus = Some(is_focus);
416 self
417 }
418
419 pub fn margin(mut self, margin: i32) -> Self {
420 self.margin = Some(margin);
421 self
422 }
423
424 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
425 self.margin_bottom = Some(margin_bottom);
426 self
427 }
428
429 pub fn margin_end(mut self, margin_end: i32) -> Self {
430 self.margin_end = Some(margin_end);
431 self
432 }
433
434 pub fn margin_start(mut self, margin_start: i32) -> Self {
435 self.margin_start = Some(margin_start);
436 self
437 }
438
439 pub fn margin_top(mut self, margin_top: i32) -> Self {
440 self.margin_top = Some(margin_top);
441 self
442 }
443
444 pub fn name(mut self, name: &str) -> Self {
445 self.name = Some(name.to_string());
446 self
447 }
448
449 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
450 self.no_show_all = Some(no_show_all);
451 self
452 }
453
454 pub fn opacity(mut self, opacity: f64) -> Self {
455 self.opacity = Some(opacity);
456 self
457 }
458
459 pub fn parent(mut self, parent: &Container) -> Self {
460 self.parent = Some(parent.clone());
461 self
462 }
463
464 pub fn receives_default(mut self, receives_default: bool) -> Self {
465 self.receives_default = Some(receives_default);
466 self
467 }
468
469 pub fn sensitive(mut self, sensitive: bool) -> Self {
470 self.sensitive = Some(sensitive);
471 self
472 }
473
474 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
475 self.tooltip_markup = Some(tooltip_markup.to_string());
476 self
477 }
478
479 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
480 self.tooltip_text = Some(tooltip_text.to_string());
481 self
482 }
483
484 pub fn valign(mut self, valign: Align) -> Self {
485 self.valign = Some(valign);
486 self
487 }
488
489 pub fn vexpand(mut self, vexpand: bool) -> Self {
490 self.vexpand = Some(vexpand);
491 self
492 }
493
494 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
495 self.vexpand_set = Some(vexpand_set);
496 self
497 }
498
499 pub fn visible(mut self, visible: bool) -> Self {
500 self.visible = Some(visible);
501 self
502 }
503
504 pub fn width_request(mut self, width_request: i32) -> Self {
505 self.width_request = Some(width_request);
506 self
507 }
508}
509
510pub const NONE_POPOVER: Option<&Popover> = None;
511
512pub trait PopoverExt: 'static {
513 fn bind_model<P: IsA<gio::MenuModel>>(&self, model: Option<&P>, action_namespace: Option<&str>);
514
515 #[cfg(any(feature = "v3_20", feature = "dox"))]
516 fn get_constrain_to(&self) -> PopoverConstraint;
517
518 #[cfg(any(feature = "v3_18", feature = "dox"))]
519 fn get_default_widget(&self) -> Option<Widget>;
520
521 fn get_modal(&self) -> bool;
522
523 fn get_pointing_to(&self) -> Option<gdk::Rectangle>;
524
525 fn get_position(&self) -> PositionType;
526
527 fn get_relative_to(&self) -> Option<Widget>;
528
529 #[cfg_attr(feature = "v3_22", deprecated)]
530 #[cfg(any(feature = "v3_16", feature = "dox"))]
531 fn get_transitions_enabled(&self) -> bool;
532
533 #[cfg(any(feature = "v3_22", feature = "dox"))]
534 fn popdown(&self);
535
536 #[cfg(any(feature = "v3_22", feature = "dox"))]
537 fn popup(&self);
538
539 #[cfg(any(feature = "v3_20", feature = "dox"))]
540 fn set_constrain_to(&self, constraint: PopoverConstraint);
541
542 #[cfg(any(feature = "v3_18", feature = "dox"))]
543 fn set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>);
544
545 fn set_modal(&self, modal: bool);
546
547 fn set_pointing_to(&self, rect: &gdk::Rectangle);
548
549 fn set_position(&self, position: PositionType);
550
551 fn set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>);
552
553 #[cfg_attr(feature = "v3_22", deprecated)]
554 #[cfg(any(feature = "v3_16", feature = "dox"))]
555 fn set_transitions_enabled(&self, transitions_enabled: bool);
556
557 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
558
559 #[cfg(any(feature = "v3_20", feature = "dox"))]
560 fn connect_property_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F)
561 -> SignalHandlerId;
562
563 fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
564
565 fn connect_property_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
566
567 fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
568
569 fn connect_property_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
570
571 #[cfg_attr(feature = "v3_22", deprecated)]
572 #[cfg(any(feature = "v3_16", feature = "dox"))]
573 fn connect_property_transitions_enabled_notify<F: Fn(&Self) + 'static>(
574 &self,
575 f: F,
576 ) -> SignalHandlerId;
577}
578
579impl<O: IsA<Popover>> PopoverExt for O {
580 fn bind_model<P: IsA<gio::MenuModel>>(
581 &self,
582 model: Option<&P>,
583 action_namespace: Option<&str>,
584 ) {
585 unsafe {
586 gtk_sys::gtk_popover_bind_model(
587 self.as_ref().to_glib_none().0,
588 model.map(|p| p.as_ref()).to_glib_none().0,
589 action_namespace.to_glib_none().0,
590 );
591 }
592 }
593
594 #[cfg(any(feature = "v3_20", feature = "dox"))]
595 fn get_constrain_to(&self) -> PopoverConstraint {
596 unsafe {
597 from_glib(gtk_sys::gtk_popover_get_constrain_to(
598 self.as_ref().to_glib_none().0,
599 ))
600 }
601 }
602
603 #[cfg(any(feature = "v3_18", feature = "dox"))]
604 fn get_default_widget(&self) -> Option<Widget> {
605 unsafe {
606 from_glib_none(gtk_sys::gtk_popover_get_default_widget(
607 self.as_ref().to_glib_none().0,
608 ))
609 }
610 }
611
612 fn get_modal(&self) -> bool {
613 unsafe {
614 from_glib(gtk_sys::gtk_popover_get_modal(
615 self.as_ref().to_glib_none().0,
616 ))
617 }
618 }
619
620 fn get_pointing_to(&self) -> Option<gdk::Rectangle> {
621 unsafe {
622 let mut rect = gdk::Rectangle::uninitialized();
623 let ret = from_glib(gtk_sys::gtk_popover_get_pointing_to(
624 self.as_ref().to_glib_none().0,
625 rect.to_glib_none_mut().0,
626 ));
627 if ret {
628 Some(rect)
629 } else {
630 None
631 }
632 }
633 }
634
635 fn get_position(&self) -> PositionType {
636 unsafe {
637 from_glib(gtk_sys::gtk_popover_get_position(
638 self.as_ref().to_glib_none().0,
639 ))
640 }
641 }
642
643 fn get_relative_to(&self) -> Option<Widget> {
644 unsafe {
645 from_glib_none(gtk_sys::gtk_popover_get_relative_to(
646 self.as_ref().to_glib_none().0,
647 ))
648 }
649 }
650
651 #[cfg(any(feature = "v3_16", feature = "dox"))]
652 fn get_transitions_enabled(&self) -> bool {
653 unsafe {
654 from_glib(gtk_sys::gtk_popover_get_transitions_enabled(
655 self.as_ref().to_glib_none().0,
656 ))
657 }
658 }
659
660 #[cfg(any(feature = "v3_22", feature = "dox"))]
661 fn popdown(&self) {
662 unsafe {
663 gtk_sys::gtk_popover_popdown(self.as_ref().to_glib_none().0);
664 }
665 }
666
667 #[cfg(any(feature = "v3_22", feature = "dox"))]
668 fn popup(&self) {
669 unsafe {
670 gtk_sys::gtk_popover_popup(self.as_ref().to_glib_none().0);
671 }
672 }
673
674 #[cfg(any(feature = "v3_20", feature = "dox"))]
675 fn set_constrain_to(&self, constraint: PopoverConstraint) {
676 unsafe {
677 gtk_sys::gtk_popover_set_constrain_to(
678 self.as_ref().to_glib_none().0,
679 constraint.to_glib(),
680 );
681 }
682 }
683
684 #[cfg(any(feature = "v3_18", feature = "dox"))]
685 fn set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>) {
686 unsafe {
687 gtk_sys::gtk_popover_set_default_widget(
688 self.as_ref().to_glib_none().0,
689 widget.map(|p| p.as_ref()).to_glib_none().0,
690 );
691 }
692 }
693
694 fn set_modal(&self, modal: bool) {
695 unsafe {
696 gtk_sys::gtk_popover_set_modal(self.as_ref().to_glib_none().0, modal.to_glib());
697 }
698 }
699
700 fn set_pointing_to(&self, rect: &gdk::Rectangle) {
701 unsafe {
702 gtk_sys::gtk_popover_set_pointing_to(
703 self.as_ref().to_glib_none().0,
704 rect.to_glib_none().0,
705 );
706 }
707 }
708
709 fn set_position(&self, position: PositionType) {
710 unsafe {
711 gtk_sys::gtk_popover_set_position(self.as_ref().to_glib_none().0, position.to_glib());
712 }
713 }
714
715 fn set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>) {
716 unsafe {
717 gtk_sys::gtk_popover_set_relative_to(
718 self.as_ref().to_glib_none().0,
719 relative_to.map(|p| p.as_ref()).to_glib_none().0,
720 );
721 }
722 }
723
724 #[cfg(any(feature = "v3_16", feature = "dox"))]
725 fn set_transitions_enabled(&self, transitions_enabled: bool) {
726 unsafe {
727 gtk_sys::gtk_popover_set_transitions_enabled(
728 self.as_ref().to_glib_none().0,
729 transitions_enabled.to_glib(),
730 );
731 }
732 }
733
734 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
735 unsafe extern "C" fn closed_trampoline<P, F: Fn(&P) + 'static>(
736 this: *mut gtk_sys::GtkPopover,
737 f: glib_sys::gpointer,
738 ) where
739 P: IsA<Popover>,
740 {
741 let f: &F = &*(f as *const F);
742 f(&Popover::from_glib_borrow(this).unsafe_cast())
743 }
744 unsafe {
745 let f: Box_<F> = Box_::new(f);
746 connect_raw(
747 self.as_ptr() as *mut _,
748 b"closed\0".as_ptr() as *const _,
749 Some(transmute(closed_trampoline::<Self, F> as usize)),
750 Box_::into_raw(f),
751 )
752 }
753 }
754
755 #[cfg(any(feature = "v3_20", feature = "dox"))]
756 fn connect_property_constrain_to_notify<F: Fn(&Self) + 'static>(
757 &self,
758 f: F,
759 ) -> SignalHandlerId {
760 unsafe extern "C" fn notify_constrain_to_trampoline<P, F: Fn(&P) + 'static>(
761 this: *mut gtk_sys::GtkPopover,
762 _param_spec: glib_sys::gpointer,
763 f: glib_sys::gpointer,
764 ) where
765 P: IsA<Popover>,
766 {
767 let f: &F = &*(f as *const F);
768 f(&Popover::from_glib_borrow(this).unsafe_cast())
769 }
770 unsafe {
771 let f: Box_<F> = Box_::new(f);
772 connect_raw(
773 self.as_ptr() as *mut _,
774 b"notify::constrain-to\0".as_ptr() as *const _,
775 Some(transmute(
776 notify_constrain_to_trampoline::<Self, F> as usize,
777 )),
778 Box_::into_raw(f),
779 )
780 }
781 }
782
783 fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
784 unsafe extern "C" fn notify_modal_trampoline<P, F: Fn(&P) + 'static>(
785 this: *mut gtk_sys::GtkPopover,
786 _param_spec: glib_sys::gpointer,
787 f: glib_sys::gpointer,
788 ) where
789 P: IsA<Popover>,
790 {
791 let f: &F = &*(f as *const F);
792 f(&Popover::from_glib_borrow(this).unsafe_cast())
793 }
794 unsafe {
795 let f: Box_<F> = Box_::new(f);
796 connect_raw(
797 self.as_ptr() as *mut _,
798 b"notify::modal\0".as_ptr() as *const _,
799 Some(transmute(notify_modal_trampoline::<Self, F> as usize)),
800 Box_::into_raw(f),
801 )
802 }
803 }
804
805 fn connect_property_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
806 unsafe extern "C" fn notify_pointing_to_trampoline<P, F: Fn(&P) + 'static>(
807 this: *mut gtk_sys::GtkPopover,
808 _param_spec: glib_sys::gpointer,
809 f: glib_sys::gpointer,
810 ) where
811 P: IsA<Popover>,
812 {
813 let f: &F = &*(f as *const F);
814 f(&Popover::from_glib_borrow(this).unsafe_cast())
815 }
816 unsafe {
817 let f: Box_<F> = Box_::new(f);
818 connect_raw(
819 self.as_ptr() as *mut _,
820 b"notify::pointing-to\0".as_ptr() as *const _,
821 Some(transmute(notify_pointing_to_trampoline::<Self, F> as usize)),
822 Box_::into_raw(f),
823 )
824 }
825 }
826
827 fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
828 unsafe extern "C" fn notify_position_trampoline<P, F: Fn(&P) + 'static>(
829 this: *mut gtk_sys::GtkPopover,
830 _param_spec: glib_sys::gpointer,
831 f: glib_sys::gpointer,
832 ) where
833 P: IsA<Popover>,
834 {
835 let f: &F = &*(f as *const F);
836 f(&Popover::from_glib_borrow(this).unsafe_cast())
837 }
838 unsafe {
839 let f: Box_<F> = Box_::new(f);
840 connect_raw(
841 self.as_ptr() as *mut _,
842 b"notify::position\0".as_ptr() as *const _,
843 Some(transmute(notify_position_trampoline::<Self, F> as usize)),
844 Box_::into_raw(f),
845 )
846 }
847 }
848
849 fn connect_property_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
850 unsafe extern "C" fn notify_relative_to_trampoline<P, F: Fn(&P) + 'static>(
851 this: *mut gtk_sys::GtkPopover,
852 _param_spec: glib_sys::gpointer,
853 f: glib_sys::gpointer,
854 ) where
855 P: IsA<Popover>,
856 {
857 let f: &F = &*(f as *const F);
858 f(&Popover::from_glib_borrow(this).unsafe_cast())
859 }
860 unsafe {
861 let f: Box_<F> = Box_::new(f);
862 connect_raw(
863 self.as_ptr() as *mut _,
864 b"notify::relative-to\0".as_ptr() as *const _,
865 Some(transmute(notify_relative_to_trampoline::<Self, F> as usize)),
866 Box_::into_raw(f),
867 )
868 }
869 }
870
871 #[cfg(any(feature = "v3_16", feature = "dox"))]
872 fn connect_property_transitions_enabled_notify<F: Fn(&Self) + 'static>(
873 &self,
874 f: F,
875 ) -> SignalHandlerId {
876 unsafe extern "C" fn notify_transitions_enabled_trampoline<P, F: Fn(&P) + 'static>(
877 this: *mut gtk_sys::GtkPopover,
878 _param_spec: glib_sys::gpointer,
879 f: glib_sys::gpointer,
880 ) where
881 P: IsA<Popover>,
882 {
883 let f: &F = &*(f as *const F);
884 f(&Popover::from_glib_borrow(this).unsafe_cast())
885 }
886 unsafe {
887 let f: Box_<F> = Box_::new(f);
888 connect_raw(
889 self.as_ptr() as *mut _,
890 b"notify::transitions-enabled\0".as_ptr() as *const _,
891 Some(transmute(
892 notify_transitions_enabled_trampoline::<Self, F> as usize,
893 )),
894 Box_::into_raw(f),
895 )
896 }
897 }
898}
899
900impl fmt::Display for Popover {
901 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
902 write!(f, "Popover")
903 }
904}