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