gtk/auto/popover.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Align, Bin, Buildable, Container, PopoverConstraint, PositionType, ResizeMode, Widget,
7};
8use glib::{
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::{boxed::Box as Box_, fmt, mem::transmute};
14
15glib::wrapper! {
16 /// GtkPopover is a bubble-like context window, primarily meant to
17 /// provide context-dependent information or options. Popovers are
18 /// attached to a widget, passed at construction time on [`new()`][Self::new()],
19 /// or updated afterwards through [`PopoverExt::set_relative_to()`][crate::prelude::PopoverExt::set_relative_to()], by
20 /// default they will point to the whole widget area, although this
21 /// behavior can be changed through [`PopoverExt::set_pointing_to()`][crate::prelude::PopoverExt::set_pointing_to()].
22 ///
23 /// The position of a popover relative to the widget it is attached to
24 /// can also be changed through [`PopoverExt::set_position()`][crate::prelude::PopoverExt::set_position()].
25 ///
26 /// By default, [`Popover`][crate::Popover] performs a GTK+ grab, in order to ensure
27 /// input events get redirected to it while it is shown, and also so
28 /// the popover is dismissed in the expected situations (clicks outside
29 /// the popover, or the Esc key being pressed). If no such modal behavior
30 /// is desired on a popover, [`PopoverExt::set_modal()`][crate::prelude::PopoverExt::set_modal()] may be called on it
31 /// to tweak its behavior.
32 ///
33 /// ## GtkPopover as menu replacement
34 ///
35 /// GtkPopover is often used to replace menus. To facilitate this, it
36 /// supports being populated from a [`gio::MenuModel`][crate::gio::MenuModel], using
37 /// [`from_model()`][Self::from_model()]. In addition to all the regular menu
38 /// model features, this function supports rendering sections in the
39 /// model in a more compact form, as a row of icon buttons instead of
40 /// menu items.
41 ///
42 /// To use this rendering, set the ”display-hint” attribute of the
43 /// section to ”horizontal-buttons” and set the icons of your items
44 /// with the ”verb-icon” attribute.
45 ///
46 ///
47 /// ```text
48 /// <section>
49 /// <attribute name="display-hint">horizontal-buttons</attribute>
50 /// <item>
51 /// <attribute name="label">Cut</attribute>
52 /// <attribute name="action">app.cut</attribute>
53 /// <attribute name="verb-icon">edit-cut-symbolic</attribute>
54 /// </item>
55 /// <item>
56 /// <attribute name="label">Copy</attribute>
57 /// <attribute name="action">app.copy</attribute>
58 /// <attribute name="verb-icon">edit-copy-symbolic</attribute>
59 /// </item>
60 /// <item>
61 /// <attribute name="label">Paste</attribute>
62 /// <attribute name="action">app.paste</attribute>
63 /// <attribute name="verb-icon">edit-paste-symbolic</attribute>
64 /// </item>
65 /// </section>
66 /// ```
67 ///
68 /// # CSS nodes
69 ///
70 /// GtkPopover has a single css node called popover. It always gets the
71 /// .background style class and it gets the .menu style class if it is
72 /// menu-like (e.g. [`PopoverMenu`][crate::PopoverMenu] or created using [`from_model()`][Self::from_model()].
73 ///
74 /// Particular uses of GtkPopover, such as touch selection popups
75 /// or magnifiers in [`Entry`][crate::Entry] or [`TextView`][crate::TextView] get style classes
76 /// like .touch-selection or .magnifier to differentiate from
77 /// plain popovers.
78 ///
79 /// ## Properties
80 ///
81 ///
82 /// #### `constrain-to`
83 /// Sets a constraint for the popover position.
84 ///
85 /// Readable | Writeable
86 ///
87 ///
88 /// #### `modal`
89 /// Sets whether the popover is modal (so other elements in the window do not
90 /// receive input while the popover is visible).
91 ///
92 /// Readable | Writeable
93 ///
94 ///
95 /// #### `pointing-to`
96 /// Marks a specific rectangle to be pointed.
97 ///
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `position`
102 /// Sets the preferred position of the popover.
103 ///
104 /// Readable | Writeable
105 ///
106 ///
107 /// #### `relative-to`
108 /// Sets the attached widget.
109 ///
110 /// Readable | Writeable
111 ///
112 ///
113 /// #### `transitions-enabled`
114 /// Whether show/hide transitions are enabled for this popover.
115 ///
116 /// Readable | Writeable
117 /// <details><summary><h4>Container</h4></summary>
118 ///
119 ///
120 /// #### `border-width`
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `child`
125 /// Writeable
126 ///
127 ///
128 /// #### `resize-mode`
129 /// Readable | Writeable
130 /// </details>
131 /// <details><summary><h4>Widget</h4></summary>
132 ///
133 ///
134 /// #### `app-paintable`
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `can-default`
139 /// Readable | Writeable
140 ///
141 ///
142 /// #### `can-focus`
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `composite-child`
147 /// Readable
148 ///
149 ///
150 /// #### `double-buffered`
151 /// Whether the widget is double buffered.
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `events`
157 /// Readable | Writeable
158 ///
159 ///
160 /// #### `expand`
161 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
162 ///
163 /// Readable | Writeable
164 ///
165 ///
166 /// #### `focus-on-click`
167 /// Whether the widget should grab focus when it is clicked with the mouse.
168 ///
169 /// This property is only relevant for widgets that can take focus.
170 ///
171 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
172 /// GtkComboBox) implemented this property individually.
173 ///
174 /// Readable | Writeable
175 ///
176 ///
177 /// #### `halign`
178 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `has-default`
184 /// Readable | Writeable
185 ///
186 ///
187 /// #### `has-focus`
188 /// Readable | Writeable
189 ///
190 ///
191 /// #### `has-tooltip`
192 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
193 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
194 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
195 /// whether it will provide a tooltip or not.
196 ///
197 /// Note that setting this property to [`true`] for the first time will change
198 /// the event masks of the GdkWindows of this widget to include leave-notify
199 /// and motion-notify events. This cannot and will not be undone when the
200 /// property is set to [`false`] again.
201 ///
202 /// Readable | Writeable
203 ///
204 ///
205 /// #### `height-request`
206 /// Readable | Writeable
207 ///
208 ///
209 /// #### `hexpand`
210 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
211 ///
212 /// Readable | Writeable
213 ///
214 ///
215 /// #### `hexpand-set`
216 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
217 ///
218 /// Readable | Writeable
219 ///
220 ///
221 /// #### `is-focus`
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `margin`
226 /// Sets all four sides' margin at once. If read, returns max
227 /// margin on any side.
228 ///
229 /// Readable | Writeable
230 ///
231 ///
232 /// #### `margin-bottom`
233 /// Margin on bottom side of widget.
234 ///
235 /// This property adds margin outside of the widget's normal size
236 /// request, the margin will be added in addition to the size from
237 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `margin-end`
243 /// Margin on end of widget, horizontally. This property supports
244 /// left-to-right and right-to-left text directions.
245 ///
246 /// This property adds margin outside of the widget's normal size
247 /// request, the margin will be added in addition to the size from
248 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
249 ///
250 /// Readable | Writeable
251 ///
252 ///
253 /// #### `margin-left`
254 /// Margin on left side of widget.
255 ///
256 /// This property adds margin outside of the widget's normal size
257 /// request, the margin will be added in addition to the size from
258 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259 ///
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `margin-right`
264 /// Margin on right side of widget.
265 ///
266 /// This property adds margin outside of the widget's normal size
267 /// request, the margin will be added in addition to the size from
268 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
269 ///
270 /// Readable | Writeable
271 ///
272 ///
273 /// #### `margin-start`
274 /// Margin on start of widget, horizontally. This property supports
275 /// left-to-right and right-to-left text directions.
276 ///
277 /// This property adds margin outside of the widget's normal size
278 /// request, the margin will be added in addition to the size from
279 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
280 ///
281 /// Readable | Writeable
282 ///
283 ///
284 /// #### `margin-top`
285 /// Margin on top side of widget.
286 ///
287 /// This property adds margin outside of the widget's normal size
288 /// request, the margin will be added in addition to the size from
289 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
290 ///
291 /// Readable | Writeable
292 ///
293 ///
294 /// #### `name`
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `no-show-all`
299 /// Readable | Writeable
300 ///
301 ///
302 /// #### `opacity`
303 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
304 /// more details about window opacity.
305 ///
306 /// Before 3.8 this was only available in GtkWindow
307 ///
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `parent`
312 /// Readable | Writeable
313 ///
314 ///
315 /// #### `receives-default`
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `scale-factor`
320 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
321 /// more details about widget scaling.
322 ///
323 /// Readable
324 ///
325 ///
326 /// #### `sensitive`
327 /// Readable | Writeable
328 ///
329 ///
330 /// #### `style`
331 /// The style of the widget, which contains information about how it will look (colors, etc).
332 ///
333 /// Readable | Writeable
334 ///
335 ///
336 /// #### `tooltip-markup`
337 /// Sets the text of tooltip to be the given string, which is marked up
338 /// with the [Pango text markup language][PangoMarkupFormat].
339 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
340 ///
341 /// This is a convenience property which will take care of getting the
342 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
343 /// will automatically be set to [`true`] and there will be taken care of
344 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
345 ///
346 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
347 /// are set, the last one wins.
348 ///
349 /// Readable | Writeable
350 ///
351 ///
352 /// #### `tooltip-text`
353 /// Sets the text of tooltip to be the given string.
354 ///
355 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
356 ///
357 /// This is a convenience property which will take care of getting the
358 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
359 /// will automatically be set to [`true`] and there will be taken care of
360 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
361 ///
362 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
363 /// are set, the last one wins.
364 ///
365 /// Readable | Writeable
366 ///
367 ///
368 /// #### `valign`
369 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `vexpand`
375 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
376 ///
377 /// Readable | Writeable
378 ///
379 ///
380 /// #### `vexpand-set`
381 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
382 ///
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `visible`
387 /// Readable | Writeable
388 ///
389 ///
390 /// #### `width-request`
391 /// Readable | Writeable
392 ///
393 ///
394 /// #### `window`
395 /// The widget's window if it is realized, [`None`] otherwise.
396 ///
397 /// Readable
398 /// </details>
399 ///
400 /// ## Signals
401 ///
402 ///
403 /// #### `closed`
404 /// This signal is emitted when the popover is dismissed either through
405 /// API or user interaction.
406 ///
407 ///
408 /// <details><summary><h4>Container</h4></summary>
409 ///
410 ///
411 /// #### `add`
412 ///
413 ///
414 ///
415 /// #### `check-resize`
416 ///
417 ///
418 ///
419 /// #### `remove`
420 ///
421 ///
422 ///
423 /// #### `set-focus-child`
424 ///
425 /// </details>
426 /// <details><summary><h4>Widget</h4></summary>
427 ///
428 ///
429 /// #### `accel-closures-changed`
430 ///
431 ///
432 ///
433 /// #### `button-press-event`
434 /// The ::button-press-event signal will be emitted when a button
435 /// (typically from a mouse) is pressed.
436 ///
437 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
438 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
439 ///
440 /// This signal will be sent to the grab widget if there is one.
441 ///
442 ///
443 ///
444 ///
445 /// #### `button-release-event`
446 /// The ::button-release-event signal will be emitted when a button
447 /// (typically from a mouse) is released.
448 ///
449 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
450 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
451 ///
452 /// This signal will be sent to the grab widget if there is one.
453 ///
454 ///
455 ///
456 ///
457 /// #### `can-activate-accel`
458 /// Determines whether an accelerator that activates the signal
459 /// identified by `signal_id` can currently be activated.
460 /// This signal is present to allow applications and derived
461 /// widgets to override the default [`Widget`][crate::Widget] handling
462 /// for determining whether an accelerator can be activated.
463 ///
464 ///
465 ///
466 ///
467 /// #### `child-notify`
468 /// The ::child-notify signal is emitted for each
469 /// [child property][child-properties] that has
470 /// changed on an object. The signal's detail holds the property name.
471 ///
472 /// Detailed
473 ///
474 ///
475 /// #### `composited-changed`
476 /// The ::composited-changed signal is emitted when the composited
477 /// status of `widgets` screen changes.
478 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
479 ///
480 /// Action
481 ///
482 ///
483 /// #### `configure-event`
484 /// The ::configure-event signal will be emitted when the size, position or
485 /// stacking of the `widget`'s window has changed.
486 ///
487 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
488 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
489 /// automatically for all new windows.
490 ///
491 ///
492 ///
493 ///
494 /// #### `damage-event`
495 /// Emitted when a redirected window belonging to `widget` gets drawn into.
496 /// The region/area members of the event shows what area of the redirected
497 /// drawable was drawn into.
498 ///
499 ///
500 ///
501 ///
502 /// #### `delete-event`
503 /// The ::delete-event signal is emitted if a user requests that
504 /// a toplevel window is closed. The default handler for this signal
505 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
506 /// this signal will cause the window to be hidden instead, so that
507 /// it can later be shown again without reconstructing it.
508 ///
509 ///
510 ///
511 ///
512 /// #### `destroy`
513 /// Signals that all holders of a reference to the widget should release
514 /// the reference that they hold. May result in finalization of the widget
515 /// if all references are released.
516 ///
517 /// This signal is not suitable for saving widget state.
518 ///
519 ///
520 ///
521 ///
522 /// #### `destroy-event`
523 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
524 /// You rarely get this signal, because most widgets disconnect themselves
525 /// from their window before they destroy it, so no widget owns the
526 /// window at destroy time.
527 ///
528 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
529 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
530 /// automatically for all new windows.
531 ///
532 ///
533 ///
534 ///
535 /// #### `direction-changed`
536 /// The ::direction-changed signal is emitted when the text direction
537 /// of a widget changes.
538 ///
539 ///
540 ///
541 ///
542 /// #### `drag-begin`
543 /// The ::drag-begin signal is emitted on the drag source when a drag is
544 /// started. A typical reason to connect to this signal is to set up a
545 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
546 ///
547 /// Note that some widgets set up a drag icon in the default handler of
548 /// this signal, so you may have to use `g_signal_connect_after()` to
549 /// override what the default handler did.
550 ///
551 ///
552 ///
553 ///
554 /// #### `drag-data-delete`
555 /// The ::drag-data-delete signal is emitted on the drag source when a drag
556 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
557 /// handler is responsible for deleting the data that has been dropped. What
558 /// "delete" means depends on the context of the drag operation.
559 ///
560 ///
561 ///
562 ///
563 /// #### `drag-data-get`
564 /// The ::drag-data-get signal is emitted on the drag source when the drop
565 /// site requests the data which is dragged. It is the responsibility of
566 /// the signal handler to fill `data` with the data in the format which
567 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
568 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
569 ///
570 ///
571 ///
572 ///
573 /// #### `drag-data-received`
574 /// The ::drag-data-received signal is emitted on the drop site when the
575 /// dragged data has been received. If the data was received in order to
576 /// determine whether the drop will be accepted, the handler is expected
577 /// to call `gdk_drag_status()` and not finish the drag.
578 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
579 /// (and this is the last target to be received), the handler for this
580 /// signal is expected to process the received data and then call
581 /// `gtk_drag_finish()`, setting the `success` parameter depending on
582 /// whether the data was processed successfully.
583 ///
584 /// Applications must create some means to determine why the signal was emitted
585 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
586 ///
587 /// The handler may inspect the selected action with
588 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
589 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
590 /// shown in the following example:
591 ///
592 ///
593 /// **⚠️ The following code is in C ⚠️**
594 ///
595 /// ```C
596 /// void
597 /// drag_data_received (GtkWidget *widget,
598 /// GdkDragContext *context,
599 /// gint x,
600 /// gint y,
601 /// GtkSelectionData *data,
602 /// guint info,
603 /// guint time)
604 /// {
605 /// if ((data->length >= 0) && (data->format == 8))
606 /// {
607 /// GdkDragAction action;
608 ///
609 /// // handle data here
610 ///
611 /// action = gdk_drag_context_get_selected_action (context);
612 /// if (action == GDK_ACTION_ASK)
613 /// {
614 /// GtkWidget *dialog;
615 /// gint response;
616 ///
617 /// dialog = gtk_message_dialog_new (NULL,
618 /// GTK_DIALOG_MODAL |
619 /// GTK_DIALOG_DESTROY_WITH_PARENT,
620 /// GTK_MESSAGE_INFO,
621 /// GTK_BUTTONS_YES_NO,
622 /// "Move the data ?\n");
623 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
624 /// gtk_widget_destroy (dialog);
625 ///
626 /// if (response == GTK_RESPONSE_YES)
627 /// action = GDK_ACTION_MOVE;
628 /// else
629 /// action = GDK_ACTION_COPY;
630 /// }
631 ///
632 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
633 /// }
634 /// else
635 /// gtk_drag_finish (context, FALSE, FALSE, time);
636 /// }
637 /// ```
638 ///
639 ///
640 ///
641 ///
642 /// #### `drag-drop`
643 /// The ::drag-drop signal is emitted on the drop site when the user drops
644 /// the data onto the widget. The signal handler must determine whether
645 /// the cursor position is in a drop zone or not. If it is not in a drop
646 /// zone, it returns [`false`] and no further processing is necessary.
647 /// Otherwise, the handler returns [`true`]. In this case, the handler must
648 /// ensure that `gtk_drag_finish()` is called to let the source know that
649 /// the drop is done. The call to `gtk_drag_finish()` can be done either
650 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
651 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
652 /// or more of the supported targets.
653 ///
654 ///
655 ///
656 ///
657 /// #### `drag-end`
658 /// The ::drag-end signal is emitted on the drag source when a drag is
659 /// finished. A typical reason to connect to this signal is to undo
660 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
661 ///
662 ///
663 ///
664 ///
665 /// #### `drag-failed`
666 /// The ::drag-failed signal is emitted on the drag source when a drag has
667 /// failed. The signal handler may hook custom code to handle a failed DnD
668 /// operation based on the type of error, it returns [`true`] is the failure has
669 /// been already handled (not showing the default "drag operation failed"
670 /// animation), otherwise it returns [`false`].
671 ///
672 ///
673 ///
674 ///
675 /// #### `drag-leave`
676 /// The ::drag-leave signal is emitted on the drop site when the cursor
677 /// leaves the widget. A typical reason to connect to this signal is to
678 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
679 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
680 ///
681 ///
682 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
683 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
684 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
685 ///
686 ///
687 ///
688 ///
689 /// #### `drag-motion`
690 /// The ::drag-motion signal is emitted on the drop site when the user
691 /// moves the cursor over the widget during a drag. The signal handler
692 /// must determine whether the cursor position is in a drop zone or not.
693 /// If it is not in a drop zone, it returns [`false`] and no further processing
694 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
695 /// handler is responsible for providing the necessary information for
696 /// displaying feedback to the user, by calling `gdk_drag_status()`.
697 ///
698 /// If the decision whether the drop will be accepted or rejected can't be
699 /// made based solely on the cursor position and the type of the data, the
700 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
701 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
702 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
703 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
704 /// when using the drag-motion signal that way.
705 ///
706 /// Also note that there is no drag-enter signal. The drag receiver has to
707 /// keep track of whether he has received any drag-motion signals since the
708 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
709 /// an "enter" signal. Upon an "enter", the handler will typically highlight
710 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
711 ///
712 ///
713 /// **⚠️ The following code is in C ⚠️**
714 ///
715 /// ```C
716 /// static void
717 /// drag_motion (GtkWidget *widget,
718 /// GdkDragContext *context,
719 /// gint x,
720 /// gint y,
721 /// guint time)
722 /// {
723 /// GdkAtom target;
724 ///
725 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
726 ///
727 /// if (!private_data->drag_highlight)
728 /// {
729 /// private_data->drag_highlight = 1;
730 /// gtk_drag_highlight (widget);
731 /// }
732 ///
733 /// target = gtk_drag_dest_find_target (widget, context, NULL);
734 /// if (target == GDK_NONE)
735 /// gdk_drag_status (context, 0, time);
736 /// else
737 /// {
738 /// private_data->pending_status
739 /// = gdk_drag_context_get_suggested_action (context);
740 /// gtk_drag_get_data (widget, context, target, time);
741 /// }
742 ///
743 /// return TRUE;
744 /// }
745 ///
746 /// static void
747 /// drag_data_received (GtkWidget *widget,
748 /// GdkDragContext *context,
749 /// gint x,
750 /// gint y,
751 /// GtkSelectionData *selection_data,
752 /// guint info,
753 /// guint time)
754 /// {
755 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
756 ///
757 /// if (private_data->suggested_action)
758 /// {
759 /// private_data->suggested_action = 0;
760 ///
761 /// // We are getting this data due to a request in drag_motion,
762 /// // rather than due to a request in drag_drop, so we are just
763 /// // supposed to call gdk_drag_status(), not actually paste in
764 /// // the data.
765 ///
766 /// str = gtk_selection_data_get_text (selection_data);
767 /// if (!data_is_acceptable (str))
768 /// gdk_drag_status (context, 0, time);
769 /// else
770 /// gdk_drag_status (context,
771 /// private_data->suggested_action,
772 /// time);
773 /// }
774 /// else
775 /// {
776 /// // accept the drop
777 /// }
778 /// }
779 /// ```
780 ///
781 ///
782 ///
783 ///
784 /// #### `draw`
785 /// This signal is emitted when a widget is supposed to render itself.
786 /// The `widget`'s top left corner must be painted at the origin of
787 /// the passed in context and be sized to the values returned by
788 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
789 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
790 ///
791 /// Signal handlers connected to this signal can modify the cairo
792 /// context passed as `cr` in any way they like and don't need to
793 /// restore it. The signal emission takes care of calling `cairo_save()`
794 /// before and `cairo_restore()` after invoking the handler.
795 ///
796 /// The signal handler will get a `cr` with a clip region already set to the
797 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
798 /// widgets that want to avoid redrawing themselves completely can get the full
799 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
800 /// get a finer-grained representation of the dirty region with
801 /// `cairo_copy_clip_rectangle_list()`.
802 ///
803 ///
804 ///
805 ///
806 /// #### `enter-notify-event`
807 /// The ::enter-notify-event will be emitted when the pointer enters
808 /// the `widget`'s window.
809 ///
810 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
811 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
812 ///
813 /// This signal will be sent to the grab widget if there is one.
814 ///
815 ///
816 ///
817 ///
818 /// #### `event`
819 /// The GTK+ main loop will emit three signals for each GDK event delivered
820 /// to a widget: one generic ::event signal, another, more specific,
821 /// signal that matches the type of event delivered (e.g.
822 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
823 /// [`event-after`][struct@crate::Widget#event-after] signal.
824 ///
825 ///
826 ///
827 ///
828 /// #### `event-after`
829 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
830 /// the second more specific signal, ::event-after will be emitted
831 /// regardless of the previous two signals handlers return values.
832 ///
833 ///
834 ///
835 ///
836 /// #### `focus`
837 ///
838 ///
839 ///
840 /// #### `focus-in-event`
841 /// The ::focus-in-event signal will be emitted when the keyboard focus
842 /// enters the `widget`'s window.
843 ///
844 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
845 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
846 ///
847 ///
848 ///
849 ///
850 /// #### `focus-out-event`
851 /// The ::focus-out-event signal will be emitted when the keyboard focus
852 /// leaves the `widget`'s window.
853 ///
854 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
855 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
856 ///
857 ///
858 ///
859 ///
860 /// #### `grab-broken-event`
861 /// Emitted when a pointer or keyboard grab on a window belonging
862 /// to `widget` gets broken.
863 ///
864 /// On X11, this happens when the grab window becomes unviewable
865 /// (i.e. it or one of its ancestors is unmapped), or if the same
866 /// application grabs the pointer or keyboard again.
867 ///
868 ///
869 ///
870 ///
871 /// #### `grab-focus`
872 /// Action
873 ///
874 ///
875 /// #### `grab-notify`
876 /// The ::grab-notify signal is emitted when a widget becomes
877 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
878 /// another widget, or when it becomes unshadowed due to a grab
879 /// being removed.
880 ///
881 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
882 /// grab widget in the grab stack of its window group is not
883 /// its ancestor.
884 ///
885 ///
886 ///
887 ///
888 /// #### `hide`
889 /// The ::hide signal is emitted when `widget` is hidden, for example with
890 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
891 ///
892 ///
893 ///
894 ///
895 /// #### `hierarchy-changed`
896 /// The ::hierarchy-changed signal is emitted when the
897 /// anchored state of a widget changes. A widget is
898 /// “anchored” when its toplevel
899 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
900 /// a widget changes from un-anchored to anchored or vice-versa.
901 ///
902 ///
903 ///
904 ///
905 /// #### `key-press-event`
906 /// The ::key-press-event signal is emitted when a key is pressed. The signal
907 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
908 ///
909 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
910 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
911 ///
912 /// This signal will be sent to the grab widget if there is one.
913 ///
914 ///
915 ///
916 ///
917 /// #### `key-release-event`
918 /// The ::key-release-event signal is emitted when a key is released.
919 ///
920 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
921 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
922 ///
923 /// This signal will be sent to the grab widget if there is one.
924 ///
925 ///
926 ///
927 ///
928 /// #### `keynav-failed`
929 /// Gets emitted if keyboard navigation fails.
930 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
931 ///
932 ///
933 ///
934 ///
935 /// #### `leave-notify-event`
936 /// The ::leave-notify-event will be emitted when the pointer leaves
937 /// the `widget`'s window.
938 ///
939 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
940 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
941 ///
942 /// This signal will be sent to the grab widget if there is one.
943 ///
944 ///
945 ///
946 ///
947 /// #### `map`
948 /// The ::map signal is emitted when `widget` is going to be mapped, that is
949 /// when the widget is visible (which is controlled with
950 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
951 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
952 /// be emitted.
953 ///
954 /// The ::map signal can be used to determine whether a widget will be drawn,
955 /// for instance it can resume an animation that was stopped during the
956 /// emission of [`unmap`][struct@crate::Widget#unmap].
957 ///
958 ///
959 ///
960 ///
961 /// #### `map-event`
962 /// The ::map-event signal will be emitted when the `widget`'s window is
963 /// mapped. A window is mapped when it becomes visible on the screen.
964 ///
965 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
966 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
967 /// automatically for all new windows.
968 ///
969 ///
970 ///
971 ///
972 /// #### `mnemonic-activate`
973 /// The default handler for this signal activates `widget` if `group_cycling`
974 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
975 ///
976 ///
977 ///
978 ///
979 /// #### `motion-notify-event`
980 /// The ::motion-notify-event signal is emitted when the pointer moves
981 /// over the widget's [`gdk::Window`][crate::gdk::Window].
982 ///
983 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
984 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
985 ///
986 /// This signal will be sent to the grab widget if there is one.
987 ///
988 ///
989 ///
990 ///
991 /// #### `move-focus`
992 /// Action
993 ///
994 ///
995 /// #### `parent-set`
996 /// The ::parent-set signal is emitted when a new parent
997 /// has been set on a widget.
998 ///
999 ///
1000 ///
1001 ///
1002 /// #### `popup-menu`
1003 /// This signal gets emitted whenever a widget should pop up a context
1004 /// menu. This usually happens through the standard key binding mechanism;
1005 /// by pressing a certain key while a widget is focused, the user can cause
1006 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1007 /// a menu with clipboard commands. See the
1008 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1009 /// for an example of how to use this signal.
1010 ///
1011 /// Action
1012 ///
1013 ///
1014 /// #### `property-notify-event`
1015 /// The ::property-notify-event signal will be emitted when a property on
1016 /// the `widget`'s window has been changed or deleted.
1017 ///
1018 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1019 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1020 ///
1021 ///
1022 ///
1023 ///
1024 /// #### `proximity-in-event`
1025 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1026 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1027 ///
1028 /// This signal will be sent to the grab widget if there is one.
1029 ///
1030 ///
1031 ///
1032 ///
1033 /// #### `proximity-out-event`
1034 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1035 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1036 ///
1037 /// This signal will be sent to the grab widget if there is one.
1038 ///
1039 ///
1040 ///
1041 ///
1042 /// #### `query-tooltip`
1043 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1044 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1045 /// focus in keyboard mode.
1046 ///
1047 /// Using the given coordinates, the signal handler should determine
1048 /// whether a tooltip should be shown for `widget`. If this is the case
1049 /// [`true`] should be returned, [`false`] otherwise. Note that if
1050 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1051 /// should not be used.
1052 ///
1053 /// The signal handler is free to manipulate `tooltip` with the therefore
1054 /// destined function calls.
1055 ///
1056 ///
1057 ///
1058 ///
1059 /// #### `realize`
1060 /// The ::realize signal is emitted when `widget` is associated with a
1061 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1062 /// widget has been mapped (that is, it is going to be drawn).
1063 ///
1064 ///
1065 ///
1066 ///
1067 /// #### `screen-changed`
1068 /// The ::screen-changed signal gets emitted when the
1069 /// screen of a widget has changed.
1070 ///
1071 ///
1072 ///
1073 ///
1074 /// #### `scroll-event`
1075 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1076 /// range is pressed. Wheel mice are usually configured to generate
1077 /// button press events for buttons 4 and 5 when the wheel is turned.
1078 ///
1079 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1080 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1081 ///
1082 /// This signal will be sent to the grab widget if there is one.
1083 ///
1084 ///
1085 ///
1086 ///
1087 /// #### `selection-clear-event`
1088 /// The ::selection-clear-event signal will be emitted when the
1089 /// the `widget`'s window has lost ownership of a selection.
1090 ///
1091 ///
1092 ///
1093 ///
1094 /// #### `selection-get`
1095 ///
1096 ///
1097 ///
1098 /// #### `selection-notify-event`
1099 ///
1100 ///
1101 ///
1102 /// #### `selection-received`
1103 ///
1104 ///
1105 ///
1106 /// #### `selection-request-event`
1107 /// The ::selection-request-event signal will be emitted when
1108 /// another client requests ownership of the selection owned by
1109 /// the `widget`'s window.
1110 ///
1111 ///
1112 ///
1113 ///
1114 /// #### `show`
1115 /// The ::show signal is emitted when `widget` is shown, for example with
1116 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1117 ///
1118 ///
1119 ///
1120 ///
1121 /// #### `show-help`
1122 /// Action
1123 ///
1124 ///
1125 /// #### `size-allocate`
1126 ///
1127 ///
1128 ///
1129 /// #### `state-changed`
1130 /// The ::state-changed signal is emitted when the widget state changes.
1131 /// See `gtk_widget_get_state()`.
1132 ///
1133 ///
1134 ///
1135 ///
1136 /// #### `state-flags-changed`
1137 /// The ::state-flags-changed signal is emitted when the widget state
1138 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1139 ///
1140 ///
1141 ///
1142 ///
1143 /// #### `style-set`
1144 /// The ::style-set signal is emitted when a new style has been set
1145 /// on a widget. Note that style-modifying functions like
1146 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1147 ///
1148 /// Note that this signal is emitted for changes to the deprecated
1149 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1150 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1151 ///
1152 ///
1153 ///
1154 ///
1155 /// #### `style-updated`
1156 /// The ::style-updated signal is a convenience signal that is emitted when the
1157 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1158 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1159 ///
1160 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1161 /// cause this signal to be emitted.
1162 ///
1163 ///
1164 ///
1165 ///
1166 /// #### `touch-event`
1167 ///
1168 ///
1169 ///
1170 /// #### `unmap`
1171 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1172 /// means that either it or any of its parents up to the toplevel widget have
1173 /// been set as hidden.
1174 ///
1175 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1176 /// used to, for example, stop an animation on the widget.
1177 ///
1178 ///
1179 ///
1180 ///
1181 /// #### `unmap-event`
1182 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1183 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1184 ///
1185 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1186 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1187 /// automatically for all new windows.
1188 ///
1189 ///
1190 ///
1191 ///
1192 /// #### `unrealize`
1193 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1194 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1195 /// called or the widget has been unmapped (that is, it is going to be
1196 /// hidden).
1197 ///
1198 ///
1199 ///
1200 ///
1201 /// #### `visibility-notify-event`
1202 /// The ::visibility-notify-event will be emitted when the `widget`'s
1203 /// window is obscured or unobscured.
1204 ///
1205 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1206 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1207 ///
1208 ///
1209 ///
1210 ///
1211 /// #### `window-state-event`
1212 /// The ::window-state-event will be emitted when the state of the
1213 /// toplevel window associated to the `widget` changes.
1214 ///
1215 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1216 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1217 /// this mask automatically for all new windows.
1218 ///
1219 ///
1220 /// </details>
1221 ///
1222 /// # Implements
1223 ///
1224 /// [`PopoverExt`][trait@crate::prelude::PopoverExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1225 #[doc(alias = "GtkPopover")]
1226 pub struct Popover(Object<ffi::GtkPopover, ffi::GtkPopoverClass>) @extends Bin, Container, Widget, @implements Buildable;
1227
1228 match fn {
1229 type_ => || ffi::gtk_popover_get_type(),
1230 }
1231}
1232
1233impl Popover {
1234 pub const NONE: Option<&'static Popover> = None;
1235
1236 /// Creates a new popover to point to `relative_to`
1237 /// ## `relative_to`
1238 /// [`Widget`][crate::Widget] the popover is related to
1239 ///
1240 /// # Returns
1241 ///
1242 /// a new [`Popover`][crate::Popover]
1243 #[doc(alias = "gtk_popover_new")]
1244 pub fn new(relative_to: Option<&impl IsA<Widget>>) -> Popover {
1245 assert_initialized_main_thread!();
1246 unsafe {
1247 Widget::from_glib_none(ffi::gtk_popover_new(
1248 relative_to.map(|p| p.as_ref()).to_glib_none().0,
1249 ))
1250 .unsafe_cast()
1251 }
1252 }
1253
1254 /// Creates a [`Popover`][crate::Popover] and populates it according to
1255 /// `model`. The popover is pointed to the `relative_to` widget.
1256 ///
1257 /// The created buttons are connected to actions found in the
1258 /// [`ApplicationWindow`][crate::ApplicationWindow] to which the popover belongs - typically
1259 /// by means of being attached to a widget that is contained within
1260 /// the `GtkApplicationWindows` widget hierarchy.
1261 ///
1262 /// Actions can also be added using [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()]
1263 /// on the menus attach widget or on any of its parent widgets.
1264 /// ## `relative_to`
1265 /// [`Widget`][crate::Widget] the popover is related to
1266 /// ## `model`
1267 /// a [`gio::MenuModel`][crate::gio::MenuModel]
1268 ///
1269 /// # Returns
1270 ///
1271 /// the new [`Popover`][crate::Popover]
1272 #[doc(alias = "gtk_popover_new_from_model")]
1273 #[doc(alias = "new_from_model")]
1274 pub fn from_model(
1275 relative_to: Option<&impl IsA<Widget>>,
1276 model: &impl IsA<gio::MenuModel>,
1277 ) -> Popover {
1278 assert_initialized_main_thread!();
1279 unsafe {
1280 Widget::from_glib_none(ffi::gtk_popover_new_from_model(
1281 relative_to.map(|p| p.as_ref()).to_glib_none().0,
1282 model.as_ref().to_glib_none().0,
1283 ))
1284 .unsafe_cast()
1285 }
1286 }
1287
1288 // rustdoc-stripper-ignore-next
1289 /// Creates a new builder-pattern struct instance to construct [`Popover`] objects.
1290 ///
1291 /// This method returns an instance of [`PopoverBuilder`](crate::builders::PopoverBuilder) which can be used to create [`Popover`] objects.
1292 pub fn builder() -> PopoverBuilder {
1293 PopoverBuilder::new()
1294 }
1295}
1296
1297impl Default for Popover {
1298 fn default() -> Self {
1299 glib::object::Object::new::<Self>()
1300 }
1301}
1302
1303// rustdoc-stripper-ignore-next
1304/// A [builder-pattern] type to construct [`Popover`] objects.
1305///
1306/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1307#[must_use = "The builder must be built to be used"]
1308pub struct PopoverBuilder {
1309 builder: glib::object::ObjectBuilder<'static, Popover>,
1310}
1311
1312impl PopoverBuilder {
1313 fn new() -> Self {
1314 Self {
1315 builder: glib::object::Object::builder(),
1316 }
1317 }
1318
1319 /// Sets a constraint for the popover position.
1320 pub fn constrain_to(self, constrain_to: PopoverConstraint) -> Self {
1321 Self {
1322 builder: self.builder.property("constrain-to", constrain_to),
1323 }
1324 }
1325
1326 /// Sets whether the popover is modal (so other elements in the window do not
1327 /// receive input while the popover is visible).
1328 pub fn modal(self, modal: bool) -> Self {
1329 Self {
1330 builder: self.builder.property("modal", modal),
1331 }
1332 }
1333
1334 /// Marks a specific rectangle to be pointed.
1335 pub fn pointing_to(self, pointing_to: &gdk::Rectangle) -> Self {
1336 Self {
1337 builder: self.builder.property("pointing-to", pointing_to),
1338 }
1339 }
1340
1341 /// Sets the preferred position of the popover.
1342 pub fn position(self, position: PositionType) -> Self {
1343 Self {
1344 builder: self.builder.property("position", position),
1345 }
1346 }
1347
1348 /// Sets the attached widget.
1349 pub fn relative_to(self, relative_to: &impl IsA<Widget>) -> Self {
1350 Self {
1351 builder: self
1352 .builder
1353 .property("relative-to", relative_to.clone().upcast()),
1354 }
1355 }
1356
1357 pub fn border_width(self, border_width: u32) -> Self {
1358 Self {
1359 builder: self.builder.property("border-width", border_width),
1360 }
1361 }
1362
1363 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1364 Self {
1365 builder: self.builder.property("child", child.clone().upcast()),
1366 }
1367 }
1368
1369 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1370 Self {
1371 builder: self.builder.property("resize-mode", resize_mode),
1372 }
1373 }
1374
1375 pub fn app_paintable(self, app_paintable: bool) -> Self {
1376 Self {
1377 builder: self.builder.property("app-paintable", app_paintable),
1378 }
1379 }
1380
1381 pub fn can_default(self, can_default: bool) -> Self {
1382 Self {
1383 builder: self.builder.property("can-default", can_default),
1384 }
1385 }
1386
1387 pub fn can_focus(self, can_focus: bool) -> Self {
1388 Self {
1389 builder: self.builder.property("can-focus", can_focus),
1390 }
1391 }
1392
1393 pub fn events(self, events: gdk::EventMask) -> Self {
1394 Self {
1395 builder: self.builder.property("events", events),
1396 }
1397 }
1398
1399 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1400 pub fn expand(self, expand: bool) -> Self {
1401 Self {
1402 builder: self.builder.property("expand", expand),
1403 }
1404 }
1405
1406 /// Whether the widget should grab focus when it is clicked with the mouse.
1407 ///
1408 /// This property is only relevant for widgets that can take focus.
1409 ///
1410 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1411 /// GtkComboBox) implemented this property individually.
1412 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1413 Self {
1414 builder: self.builder.property("focus-on-click", focus_on_click),
1415 }
1416 }
1417
1418 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1419 pub fn halign(self, halign: Align) -> Self {
1420 Self {
1421 builder: self.builder.property("halign", halign),
1422 }
1423 }
1424
1425 pub fn has_default(self, has_default: bool) -> Self {
1426 Self {
1427 builder: self.builder.property("has-default", has_default),
1428 }
1429 }
1430
1431 pub fn has_focus(self, has_focus: bool) -> Self {
1432 Self {
1433 builder: self.builder.property("has-focus", has_focus),
1434 }
1435 }
1436
1437 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1438 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1439 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1440 /// whether it will provide a tooltip or not.
1441 ///
1442 /// Note that setting this property to [`true`] for the first time will change
1443 /// the event masks of the GdkWindows of this widget to include leave-notify
1444 /// and motion-notify events. This cannot and will not be undone when the
1445 /// property is set to [`false`] again.
1446 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1447 Self {
1448 builder: self.builder.property("has-tooltip", has_tooltip),
1449 }
1450 }
1451
1452 pub fn height_request(self, height_request: i32) -> Self {
1453 Self {
1454 builder: self.builder.property("height-request", height_request),
1455 }
1456 }
1457
1458 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1459 pub fn hexpand(self, hexpand: bool) -> Self {
1460 Self {
1461 builder: self.builder.property("hexpand", hexpand),
1462 }
1463 }
1464
1465 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1466 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1467 Self {
1468 builder: self.builder.property("hexpand-set", hexpand_set),
1469 }
1470 }
1471
1472 pub fn is_focus(self, is_focus: bool) -> Self {
1473 Self {
1474 builder: self.builder.property("is-focus", is_focus),
1475 }
1476 }
1477
1478 /// Sets all four sides' margin at once. If read, returns max
1479 /// margin on any side.
1480 pub fn margin(self, margin: i32) -> Self {
1481 Self {
1482 builder: self.builder.property("margin", margin),
1483 }
1484 }
1485
1486 /// Margin on bottom side of widget.
1487 ///
1488 /// This property adds margin outside of the widget's normal size
1489 /// request, the margin will be added in addition to the size from
1490 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1491 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1492 Self {
1493 builder: self.builder.property("margin-bottom", margin_bottom),
1494 }
1495 }
1496
1497 /// Margin on end of widget, horizontally. This property supports
1498 /// left-to-right and right-to-left text directions.
1499 ///
1500 /// This property adds margin outside of the widget's normal size
1501 /// request, the margin will be added in addition to the size from
1502 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1503 pub fn margin_end(self, margin_end: i32) -> Self {
1504 Self {
1505 builder: self.builder.property("margin-end", margin_end),
1506 }
1507 }
1508
1509 /// Margin on start of widget, horizontally. This property supports
1510 /// left-to-right and right-to-left text directions.
1511 ///
1512 /// This property adds margin outside of the widget's normal size
1513 /// request, the margin will be added in addition to the size from
1514 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1515 pub fn margin_start(self, margin_start: i32) -> Self {
1516 Self {
1517 builder: self.builder.property("margin-start", margin_start),
1518 }
1519 }
1520
1521 /// Margin on top side of widget.
1522 ///
1523 /// This property adds margin outside of the widget's normal size
1524 /// request, the margin will be added in addition to the size from
1525 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1526 pub fn margin_top(self, margin_top: i32) -> Self {
1527 Self {
1528 builder: self.builder.property("margin-top", margin_top),
1529 }
1530 }
1531
1532 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1533 Self {
1534 builder: self.builder.property("name", name.into()),
1535 }
1536 }
1537
1538 pub fn no_show_all(self, no_show_all: bool) -> Self {
1539 Self {
1540 builder: self.builder.property("no-show-all", no_show_all),
1541 }
1542 }
1543
1544 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1545 /// more details about window opacity.
1546 ///
1547 /// Before 3.8 this was only available in GtkWindow
1548 pub fn opacity(self, opacity: f64) -> Self {
1549 Self {
1550 builder: self.builder.property("opacity", opacity),
1551 }
1552 }
1553
1554 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1555 Self {
1556 builder: self.builder.property("parent", parent.clone().upcast()),
1557 }
1558 }
1559
1560 pub fn receives_default(self, receives_default: bool) -> Self {
1561 Self {
1562 builder: self.builder.property("receives-default", receives_default),
1563 }
1564 }
1565
1566 pub fn sensitive(self, sensitive: bool) -> Self {
1567 Self {
1568 builder: self.builder.property("sensitive", sensitive),
1569 }
1570 }
1571
1572 /// Sets the text of tooltip to be the given string, which is marked up
1573 /// with the [Pango text markup language][PangoMarkupFormat].
1574 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1575 ///
1576 /// This is a convenience property which will take care of getting the
1577 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1578 /// will automatically be set to [`true`] and there will be taken care of
1579 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1580 ///
1581 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1582 /// are set, the last one wins.
1583 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1584 Self {
1585 builder: self
1586 .builder
1587 .property("tooltip-markup", tooltip_markup.into()),
1588 }
1589 }
1590
1591 /// Sets the text of tooltip to be the given string.
1592 ///
1593 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1594 ///
1595 /// This is a convenience property which will take care of getting the
1596 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1597 /// will automatically be set to [`true`] and there will be taken care of
1598 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1599 ///
1600 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1601 /// are set, the last one wins.
1602 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1603 Self {
1604 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1605 }
1606 }
1607
1608 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1609 pub fn valign(self, valign: Align) -> Self {
1610 Self {
1611 builder: self.builder.property("valign", valign),
1612 }
1613 }
1614
1615 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1616 pub fn vexpand(self, vexpand: bool) -> Self {
1617 Self {
1618 builder: self.builder.property("vexpand", vexpand),
1619 }
1620 }
1621
1622 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1623 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1624 Self {
1625 builder: self.builder.property("vexpand-set", vexpand_set),
1626 }
1627 }
1628
1629 pub fn visible(self, visible: bool) -> Self {
1630 Self {
1631 builder: self.builder.property("visible", visible),
1632 }
1633 }
1634
1635 pub fn width_request(self, width_request: i32) -> Self {
1636 Self {
1637 builder: self.builder.property("width-request", width_request),
1638 }
1639 }
1640
1641 // rustdoc-stripper-ignore-next
1642 /// Build the [`Popover`].
1643 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1644 pub fn build(self) -> Popover {
1645 self.builder.build()
1646 }
1647}
1648
1649mod sealed {
1650 pub trait Sealed {}
1651 impl<T: super::IsA<super::Popover>> Sealed for T {}
1652}
1653
1654/// Trait containing all [`struct@Popover`] methods.
1655///
1656/// # Implementors
1657///
1658/// [`PopoverMenu`][struct@crate::PopoverMenu], [`Popover`][struct@crate::Popover]
1659pub trait PopoverExt: IsA<Popover> + sealed::Sealed + 'static {
1660 /// Establishes a binding between a [`Popover`][crate::Popover] and a [`gio::MenuModel`][crate::gio::MenuModel].
1661 ///
1662 /// The contents of `self` are removed and then refilled with menu items
1663 /// according to `model`. When `model` changes, `self` is updated.
1664 /// Calling this function twice on `self` with different `model` will
1665 /// cause the first binding to be replaced with a binding to the new
1666 /// model. If `model` is [`None`] then any previous binding is undone and
1667 /// all children are removed.
1668 ///
1669 /// If `action_namespace` is non-[`None`] then the effect is as if all
1670 /// actions mentioned in the `model` have their names prefixed with the
1671 /// namespace, plus a dot. For example, if the action “quit” is
1672 /// mentioned and `action_namespace` is “app” then the effective action
1673 /// name is “app.quit”.
1674 ///
1675 /// This function uses [`Actionable`][crate::Actionable] to define the action name and
1676 /// target values on the created menu items. If you want to use an
1677 /// action group other than “app” and “win”, or if you want to use a
1678 /// [`MenuShell`][crate::MenuShell] outside of a [`ApplicationWindow`][crate::ApplicationWindow], then you will need
1679 /// to attach your own action group to the widget hierarchy using
1680 /// [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()]. As an example, if you created a
1681 /// group with a “quit” action and inserted it with the name “mygroup”
1682 /// then you would use the action name “mygroup.quit” in your
1683 /// [`gio::MenuModel`][crate::gio::MenuModel].
1684 /// ## `model`
1685 /// the [`gio::MenuModel`][crate::gio::MenuModel] to bind to or [`None`] to remove
1686 /// binding
1687 /// ## `action_namespace`
1688 /// the namespace for actions in `model`
1689 #[doc(alias = "gtk_popover_bind_model")]
1690 fn bind_model(&self, model: Option<&impl IsA<gio::MenuModel>>, action_namespace: Option<&str>) {
1691 unsafe {
1692 ffi::gtk_popover_bind_model(
1693 self.as_ref().to_glib_none().0,
1694 model.map(|p| p.as_ref()).to_glib_none().0,
1695 action_namespace.to_glib_none().0,
1696 );
1697 }
1698 }
1699
1700 /// Returns the constraint for placing this popover.
1701 /// See [`set_constrain_to()`][Self::set_constrain_to()].
1702 ///
1703 /// # Returns
1704 ///
1705 /// the constraint for placing this popover.
1706 #[doc(alias = "gtk_popover_get_constrain_to")]
1707 #[doc(alias = "get_constrain_to")]
1708 fn constrain_to(&self) -> PopoverConstraint {
1709 unsafe {
1710 from_glib(ffi::gtk_popover_get_constrain_to(
1711 self.as_ref().to_glib_none().0,
1712 ))
1713 }
1714 }
1715
1716 /// Gets the widget that should be set as the default while
1717 /// the popover is shown.
1718 ///
1719 /// # Returns
1720 ///
1721 /// the default widget,
1722 /// or [`None`] if there is none
1723 #[doc(alias = "gtk_popover_get_default_widget")]
1724 #[doc(alias = "get_default_widget")]
1725 fn default_widget(&self) -> Option<Widget> {
1726 unsafe {
1727 from_glib_none(ffi::gtk_popover_get_default_widget(
1728 self.as_ref().to_glib_none().0,
1729 ))
1730 }
1731 }
1732
1733 /// Returns whether the popover is modal, see gtk_popover_set_modal to
1734 /// see the implications of this.
1735 ///
1736 /// # Returns
1737 ///
1738 /// [`true`] if `self` is modal
1739 #[doc(alias = "gtk_popover_get_modal")]
1740 #[doc(alias = "get_modal")]
1741 fn is_modal(&self) -> bool {
1742 unsafe { from_glib(ffi::gtk_popover_get_modal(self.as_ref().to_glib_none().0)) }
1743 }
1744
1745 /// If a rectangle to point to has been set, this function will
1746 /// return [`true`] and fill in `rect` with such rectangle, otherwise
1747 /// it will return [`false`] and fill in `rect` with the attached
1748 /// widget width and height if a widget exists, otherwise it will zero-out `rect`.
1749 ///
1750 /// # Returns
1751 ///
1752 /// [`true`] if a rectangle to point to was set.
1753 ///
1754 /// ## `rect`
1755 /// location to store the rectangle
1756 #[doc(alias = "gtk_popover_get_pointing_to")]
1757 #[doc(alias = "get_pointing_to")]
1758 fn pointing_to(&self) -> Option<gdk::Rectangle> {
1759 unsafe {
1760 let mut rect = gdk::Rectangle::uninitialized();
1761 let ret = from_glib(ffi::gtk_popover_get_pointing_to(
1762 self.as_ref().to_glib_none().0,
1763 rect.to_glib_none_mut().0,
1764 ));
1765 if ret {
1766 Some(rect)
1767 } else {
1768 None
1769 }
1770 }
1771 }
1772
1773 /// Returns the preferred position of `self`.
1774 ///
1775 /// # Returns
1776 ///
1777 /// The preferred position.
1778 #[doc(alias = "gtk_popover_get_position")]
1779 #[doc(alias = "get_position")]
1780 fn position(&self) -> PositionType {
1781 unsafe {
1782 from_glib(ffi::gtk_popover_get_position(
1783 self.as_ref().to_glib_none().0,
1784 ))
1785 }
1786 }
1787
1788 /// Returns the widget `self` is currently attached to
1789 ///
1790 /// # Returns
1791 ///
1792 /// a [`Widget`][crate::Widget]
1793 #[doc(alias = "gtk_popover_get_relative_to")]
1794 #[doc(alias = "get_relative_to")]
1795 fn relative_to(&self) -> Option<Widget> {
1796 unsafe {
1797 from_glib_none(ffi::gtk_popover_get_relative_to(
1798 self.as_ref().to_glib_none().0,
1799 ))
1800 }
1801 }
1802
1803 /// Pops `self` down.This is different than a [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()] call
1804 /// in that it shows the popover with a transition. If you want to hide
1805 /// the popover without a transition, use [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1806 #[doc(alias = "gtk_popover_popdown")]
1807 fn popdown(&self) {
1808 unsafe {
1809 ffi::gtk_popover_popdown(self.as_ref().to_glib_none().0);
1810 }
1811 }
1812
1813 /// Pops `self` up. This is different than a [`WidgetExt::show()`][crate::prelude::WidgetExt::show()] call
1814 /// in that it shows the popover with a transition. If you want to show
1815 /// the popover without a transition, use [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1816 #[doc(alias = "gtk_popover_popup")]
1817 fn popup(&self) {
1818 unsafe {
1819 ffi::gtk_popover_popup(self.as_ref().to_glib_none().0);
1820 }
1821 }
1822
1823 /// Sets a constraint for positioning this popover.
1824 ///
1825 /// Note that not all platforms support placing popovers freely,
1826 /// and may already impose constraints.
1827 /// ## `constraint`
1828 /// the new constraint
1829 #[doc(alias = "gtk_popover_set_constrain_to")]
1830 fn set_constrain_to(&self, constraint: PopoverConstraint) {
1831 unsafe {
1832 ffi::gtk_popover_set_constrain_to(
1833 self.as_ref().to_glib_none().0,
1834 constraint.into_glib(),
1835 );
1836 }
1837 }
1838
1839 /// Sets the widget that should be set as default widget while
1840 /// the popover is shown (see [`GtkWindowExt::set_default()`][crate::prelude::GtkWindowExt::set_default()]). [`Popover`][crate::Popover]
1841 /// remembers the previous default widget and reestablishes it
1842 /// when the popover is dismissed.
1843 /// ## `widget`
1844 /// the new default widget, or [`None`]
1845 #[doc(alias = "gtk_popover_set_default_widget")]
1846 fn set_default_widget(&self, widget: Option<&impl IsA<Widget>>) {
1847 unsafe {
1848 ffi::gtk_popover_set_default_widget(
1849 self.as_ref().to_glib_none().0,
1850 widget.map(|p| p.as_ref()).to_glib_none().0,
1851 );
1852 }
1853 }
1854
1855 /// Sets whether `self` is modal, a modal popover will grab all input
1856 /// within the toplevel and grab the keyboard focus on it when being
1857 /// displayed. Clicking outside the popover area or pressing Esc will
1858 /// dismiss the popover and ungrab input.
1859 /// ## `modal`
1860 /// [`true`] to make popover claim all input within the toplevel
1861 #[doc(alias = "gtk_popover_set_modal")]
1862 fn set_modal(&self, modal: bool) {
1863 unsafe {
1864 ffi::gtk_popover_set_modal(self.as_ref().to_glib_none().0, modal.into_glib());
1865 }
1866 }
1867
1868 /// Sets the rectangle that `self` will point to, in the
1869 /// coordinate space of the widget `self` is attached to,
1870 /// see [`set_relative_to()`][Self::set_relative_to()].
1871 /// ## `rect`
1872 /// rectangle to point to
1873 #[doc(alias = "gtk_popover_set_pointing_to")]
1874 fn set_pointing_to(&self, rect: &gdk::Rectangle) {
1875 unsafe {
1876 ffi::gtk_popover_set_pointing_to(self.as_ref().to_glib_none().0, rect.to_glib_none().0);
1877 }
1878 }
1879
1880 /// Sets the preferred position for `self` to appear. If the `self`
1881 /// is currently visible, it will be immediately updated.
1882 ///
1883 /// This preference will be respected where possible, although
1884 /// on lack of space (eg. if close to the window edges), the
1885 /// [`Popover`][crate::Popover] may choose to appear on the opposite side
1886 /// ## `position`
1887 /// preferred popover position
1888 #[doc(alias = "gtk_popover_set_position")]
1889 fn set_position(&self, position: PositionType) {
1890 unsafe {
1891 ffi::gtk_popover_set_position(self.as_ref().to_glib_none().0, position.into_glib());
1892 }
1893 }
1894
1895 /// Sets a new widget to be attached to `self`. If `self` is
1896 /// visible, the position will be updated.
1897 ///
1898 /// Note: the ownership of popovers is always given to their `relative_to`
1899 /// widget, so if `relative_to` is set to [`None`] on an attached `self`, it
1900 /// will be detached from its previous widget, and consequently destroyed
1901 /// unless extra references are kept.
1902 /// ## `relative_to`
1903 /// a [`Widget`][crate::Widget]
1904 #[doc(alias = "gtk_popover_set_relative_to")]
1905 fn set_relative_to(&self, relative_to: Option<&impl IsA<Widget>>) {
1906 unsafe {
1907 ffi::gtk_popover_set_relative_to(
1908 self.as_ref().to_glib_none().0,
1909 relative_to.map(|p| p.as_ref()).to_glib_none().0,
1910 );
1911 }
1912 }
1913
1914 /// This signal is emitted when the popover is dismissed either through
1915 /// API or user interaction.
1916 #[doc(alias = "closed")]
1917 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1918 unsafe extern "C" fn closed_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1919 this: *mut ffi::GtkPopover,
1920 f: glib::ffi::gpointer,
1921 ) {
1922 let f: &F = &*(f as *const F);
1923 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1924 }
1925 unsafe {
1926 let f: Box_<F> = Box_::new(f);
1927 connect_raw(
1928 self.as_ptr() as *mut _,
1929 b"closed\0".as_ptr() as *const _,
1930 Some(transmute::<_, unsafe extern "C" fn()>(
1931 closed_trampoline::<Self, F> as *const (),
1932 )),
1933 Box_::into_raw(f),
1934 )
1935 }
1936 }
1937
1938 #[doc(alias = "constrain-to")]
1939 fn connect_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1940 unsafe extern "C" fn notify_constrain_to_trampoline<
1941 P: IsA<Popover>,
1942 F: Fn(&P) + 'static,
1943 >(
1944 this: *mut ffi::GtkPopover,
1945 _param_spec: glib::ffi::gpointer,
1946 f: glib::ffi::gpointer,
1947 ) {
1948 let f: &F = &*(f as *const F);
1949 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1950 }
1951 unsafe {
1952 let f: Box_<F> = Box_::new(f);
1953 connect_raw(
1954 self.as_ptr() as *mut _,
1955 b"notify::constrain-to\0".as_ptr() as *const _,
1956 Some(transmute::<_, unsafe extern "C" fn()>(
1957 notify_constrain_to_trampoline::<Self, F> as *const (),
1958 )),
1959 Box_::into_raw(f),
1960 )
1961 }
1962 }
1963
1964 #[doc(alias = "modal")]
1965 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1966 unsafe extern "C" fn notify_modal_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1967 this: *mut ffi::GtkPopover,
1968 _param_spec: glib::ffi::gpointer,
1969 f: glib::ffi::gpointer,
1970 ) {
1971 let f: &F = &*(f as *const F);
1972 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1973 }
1974 unsafe {
1975 let f: Box_<F> = Box_::new(f);
1976 connect_raw(
1977 self.as_ptr() as *mut _,
1978 b"notify::modal\0".as_ptr() as *const _,
1979 Some(transmute::<_, unsafe extern "C" fn()>(
1980 notify_modal_trampoline::<Self, F> as *const (),
1981 )),
1982 Box_::into_raw(f),
1983 )
1984 }
1985 }
1986
1987 #[doc(alias = "pointing-to")]
1988 fn connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1989 unsafe extern "C" fn notify_pointing_to_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
1990 this: *mut ffi::GtkPopover,
1991 _param_spec: glib::ffi::gpointer,
1992 f: glib::ffi::gpointer,
1993 ) {
1994 let f: &F = &*(f as *const F);
1995 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
1996 }
1997 unsafe {
1998 let f: Box_<F> = Box_::new(f);
1999 connect_raw(
2000 self.as_ptr() as *mut _,
2001 b"notify::pointing-to\0".as_ptr() as *const _,
2002 Some(transmute::<_, unsafe extern "C" fn()>(
2003 notify_pointing_to_trampoline::<Self, F> as *const (),
2004 )),
2005 Box_::into_raw(f),
2006 )
2007 }
2008 }
2009
2010 #[doc(alias = "position")]
2011 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2012 unsafe extern "C" fn notify_position_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
2013 this: *mut ffi::GtkPopover,
2014 _param_spec: glib::ffi::gpointer,
2015 f: glib::ffi::gpointer,
2016 ) {
2017 let f: &F = &*(f as *const F);
2018 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
2019 }
2020 unsafe {
2021 let f: Box_<F> = Box_::new(f);
2022 connect_raw(
2023 self.as_ptr() as *mut _,
2024 b"notify::position\0".as_ptr() as *const _,
2025 Some(transmute::<_, unsafe extern "C" fn()>(
2026 notify_position_trampoline::<Self, F> as *const (),
2027 )),
2028 Box_::into_raw(f),
2029 )
2030 }
2031 }
2032
2033 #[doc(alias = "relative-to")]
2034 fn connect_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2035 unsafe extern "C" fn notify_relative_to_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>(
2036 this: *mut ffi::GtkPopover,
2037 _param_spec: glib::ffi::gpointer,
2038 f: glib::ffi::gpointer,
2039 ) {
2040 let f: &F = &*(f as *const F);
2041 f(Popover::from_glib_borrow(this).unsafe_cast_ref())
2042 }
2043 unsafe {
2044 let f: Box_<F> = Box_::new(f);
2045 connect_raw(
2046 self.as_ptr() as *mut _,
2047 b"notify::relative-to\0".as_ptr() as *const _,
2048 Some(transmute::<_, unsafe extern "C" fn()>(
2049 notify_relative_to_trampoline::<Self, F> as *const (),
2050 )),
2051 Box_::into_raw(f),
2052 )
2053 }
2054 }
2055}
2056
2057impl<O: IsA<Popover>> PopoverExt for O {}
2058
2059impl fmt::Display for Popover {
2060 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2061 f.write_str("Popover")
2062 }
2063}