gtk4/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    ffi, Accessible, AccessibleRole, Actionable, Align, Buildable, Button, ConstraintTarget,
7    LayoutManager, Overflow, Widget,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// A [`LinkButton`][crate::LinkButton] is a button with a hyperlink.
19    ///
20    /// ![An example GtkLinkButton](link-button.png)
21    ///
22    /// It is useful to show quick links to resources.
23    ///
24    /// A link button is created by calling either [`new()`][Self::new()] or
25    /// [`with_label()`][Self::with_label()]. If using the former, the URI you
26    /// pass to the constructor is used as a label for the widget.
27    ///
28    /// The URI bound to a [`LinkButton`][crate::LinkButton] can be set specifically using
29    /// [`set_uri()`][Self::set_uri()].
30    ///
31    /// By default, [`LinkButton`][crate::LinkButton] calls [`FileLauncher::launch()`][crate::FileLauncher::launch()] when the button
32    /// is clicked. This behaviour can be overridden by connecting to the
33    /// [`activate-link`][struct@crate::LinkButton#activate-link] signal and returning [`true`] from
34    /// the signal handler.
35    ///
36    /// # Shortcuts and Gestures
37    ///
38    /// [`LinkButton`][crate::LinkButton] supports the following keyboard shortcuts:
39    ///
40    /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
41    ///
42    /// # Actions
43    ///
44    /// [`LinkButton`][crate::LinkButton] defines a set of built-in actions:
45    ///
46    /// - `clipboard.copy` copies the url to the clipboard.
47    /// - `menu.popup` opens the context menu.
48    ///
49    /// # CSS nodes
50    ///
51    /// [`LinkButton`][crate::LinkButton] has a single CSS node with name button. To differentiate
52    /// it from a plain [`Button`][crate::Button], it gets the .link style class.
53    ///
54    /// # Accessibility
55    ///
56    /// [`LinkButton`][crate::LinkButton] uses the [`AccessibleRole::Link`][crate::AccessibleRole::Link] role.
57    ///
58    /// ## Properties
59    ///
60    ///
61    /// #### `uri`
62    ///  The URI bound to this button.
63    ///
64    /// Readable | Writeable
65    ///
66    ///
67    /// #### `visited`
68    ///  The 'visited' state of this button.
69    ///
70    /// A visited link is drawn in a different color.
71    ///
72    /// Readable | Writeable
73    /// <details><summary><h4>Button</h4></summary>
74    ///
75    ///
76    /// #### `can-shrink`
77    ///  Whether the size of the button can be made smaller than the natural
78    /// size of its contents.
79    ///
80    /// For text buttons, setting this property will allow ellipsizing the label.
81    ///
82    /// If the contents of a button are an icon or a custom widget, setting this
83    /// property has no effect.
84    ///
85    /// Readable | Writeable
86    ///
87    ///
88    /// #### `child`
89    ///  The child widget.
90    ///
91    /// Readable | Writeable
92    ///
93    ///
94    /// #### `has-frame`
95    ///  Whether the button has a frame.
96    ///
97    /// Readable | Writeable
98    ///
99    ///
100    /// #### `icon-name`
101    ///  The name of the icon used to automatically populate the button.
102    ///
103    /// Readable | Writeable
104    ///
105    ///
106    /// #### `label`
107    ///  Text of the label inside the button, if the button contains a label widget.
108    ///
109    /// Readable | Writeable
110    ///
111    ///
112    /// #### `use-underline`
113    ///  If set, an underline in the text indicates that the following character is
114    /// to be used as mnemonic.
115    ///
116    /// Readable | Writeable
117    /// </details>
118    /// <details><summary><h4>Widget</h4></summary>
119    ///
120    ///
121    /// #### `can-focus`
122    ///  Whether the widget or any of its descendents can accept
123    /// the input focus.
124    ///
125    /// This property is meant to be set by widget implementations,
126    /// typically in their instance init function.
127    ///
128    /// Readable | Writeable
129    ///
130    ///
131    /// #### `can-target`
132    ///  Whether the widget can receive pointer events.
133    ///
134    /// Readable | Writeable
135    ///
136    ///
137    /// #### `css-classes`
138    ///  A list of css classes applied to this widget.
139    ///
140    /// Readable | Writeable
141    ///
142    ///
143    /// #### `css-name`
144    ///  The name of this widget in the CSS tree.
145    ///
146    /// This property is meant to be set by widget implementations,
147    /// typically in their instance init function.
148    ///
149    /// Readable | Writeable | Construct Only
150    ///
151    ///
152    /// #### `cursor`
153    ///  The cursor used by @widget.
154    ///
155    /// Readable | Writeable
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    /// Readable | Writeable
164    ///
165    ///
166    /// #### `focusable`
167    ///  Whether this widget itself will accept the input focus.
168    ///
169    /// Readable | Writeable
170    ///
171    ///
172    /// #### `halign`
173    ///  How to distribute horizontal space if widget gets extra space.
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `has-default`
179    ///  Whether the widget is the default widget.
180    ///
181    /// Readable
182    ///
183    ///
184    /// #### `has-focus`
185    ///  Whether the widget has the input focus.
186    ///
187    /// Readable
188    ///
189    ///
190    /// #### `has-tooltip`
191    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
192    /// signal on @widget.
193    ///
194    /// A true value indicates that @widget can have a tooltip, in this case
195    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
196    /// determine whether it will provide a tooltip or not.
197    ///
198    /// Readable | Writeable
199    ///
200    ///
201    /// #### `height-request`
202    ///  Overrides for height request of the widget.
203    ///
204    /// If this is -1, the natural request will be used.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `hexpand`
210    ///  Whether to expand horizontally.
211    ///
212    /// Readable | Writeable
213    ///
214    ///
215    /// #### `hexpand-set`
216    ///  Whether to use the `hexpand` property.
217    ///
218    /// Readable | Writeable
219    ///
220    ///
221    /// #### `layout-manager`
222    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
223    /// the preferred size of the widget, and allocate its children.
224    ///
225    /// This property is meant to be set by widget implementations,
226    /// typically in their instance init function.
227    ///
228    /// Readable | Writeable
229    ///
230    ///
231    /// #### `limit-events`
232    ///  Makes this widget act like a modal dialog, with respect to
233    /// event delivery.
234    ///
235    /// Global event controllers will not handle events with targets
236    /// inside the widget, unless they are set up to ignore propagation
237    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
238    ///
239    /// Readable | Writeable
240    ///
241    ///
242    /// #### `margin-bottom`
243    ///  Margin on bottom side of widget.
244    ///
245    /// This property adds margin outside of the widget's normal size
246    /// request, the margin will be added in addition to the size from
247    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `margin-end`
253    ///  Margin on end of widget, horizontally.
254    ///
255    /// This property supports left-to-right and right-to-left text
256    /// directions.
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 | Writeable
263    ///
264    ///
265    /// #### `margin-start`
266    ///  Margin on start of widget, horizontally.
267    ///
268    /// This property supports left-to-right and right-to-left text
269    /// directions.
270    ///
271    /// This property adds margin outside of the widget's normal size
272    /// request, the margin will be added in addition to the size from
273    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `margin-top`
279    ///  Margin on top side of widget.
280    ///
281    /// This property adds margin outside of the widget's normal size
282    /// request, the margin will be added in addition to the size from
283    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
284    ///
285    /// Readable | Writeable
286    ///
287    ///
288    /// #### `name`
289    ///  The name of the widget.
290    ///
291    /// Readable | Writeable
292    ///
293    ///
294    /// #### `opacity`
295    ///  The requested opacity of the widget.
296    ///
297    /// Readable | Writeable
298    ///
299    ///
300    /// #### `overflow`
301    ///  How content outside the widget's content area is treated.
302    ///
303    /// This property is meant to be set by widget implementations,
304    /// typically in their instance init function.
305    ///
306    /// Readable | Writeable
307    ///
308    ///
309    /// #### `parent`
310    ///  The parent widget of this widget.
311    ///
312    /// Readable
313    ///
314    ///
315    /// #### `receives-default`
316    ///  Whether the widget will receive the default action when it is focused.
317    ///
318    /// Readable | Writeable
319    ///
320    ///
321    /// #### `root`
322    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
323    ///
324    /// This will be `NULL` if the widget is not contained in a root widget.
325    ///
326    /// Readable
327    ///
328    ///
329    /// #### `scale-factor`
330    ///  The scale factor of the widget.
331    ///
332    /// Readable
333    ///
334    ///
335    /// #### `sensitive`
336    ///  Whether the widget responds to input.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `tooltip-markup`
342    ///  Sets the text of tooltip to be the given string, which is marked up
343    /// with Pango markup.
344    ///
345    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
346    ///
347    /// This is a convenience property which will take care of getting the
348    /// tooltip shown if the given string is not `NULL`:
349    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
350    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
351    /// the default signal handler.
352    ///
353    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
354    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
355    ///
356    /// Readable | Writeable
357    ///
358    ///
359    /// #### `tooltip-text`
360    ///  Sets the text of tooltip to be the given string.
361    ///
362    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
363    ///
364    /// This is a convenience property which will take care of getting the
365    /// tooltip shown if the given string is not `NULL`:
366    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
367    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
368    /// the default signal handler.
369    ///
370    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
371    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
372    ///
373    /// Readable | Writeable
374    ///
375    ///
376    /// #### `valign`
377    ///  How to distribute vertical space if widget gets extra space.
378    ///
379    /// Readable | Writeable
380    ///
381    ///
382    /// #### `vexpand`
383    ///  Whether to expand vertically.
384    ///
385    /// Readable | Writeable
386    ///
387    ///
388    /// #### `vexpand-set`
389    ///  Whether to use the `vexpand` property.
390    ///
391    /// Readable | Writeable
392    ///
393    ///
394    /// #### `visible`
395    ///  Whether the widget is visible.
396    ///
397    /// Readable | Writeable
398    ///
399    ///
400    /// #### `width-request`
401    ///  Overrides for width request of the widget.
402    ///
403    /// If this is -1, the natural request will be used.
404    ///
405    /// Readable | Writeable
406    /// </details>
407    /// <details><summary><h4>Accessible</h4></summary>
408    ///
409    ///
410    /// #### `accessible-role`
411    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
412    ///
413    /// The accessible role cannot be changed once set.
414    ///
415    /// Readable | Writeable
416    /// </details>
417    /// <details><summary><h4>Actionable</h4></summary>
418    ///
419    ///
420    /// #### `action-name`
421    ///  The name of the action with which this widget should be associated.
422    ///
423    /// Readable | Writeable
424    ///
425    ///
426    /// #### `action-target`
427    ///  The target value of the actionable widget's action.
428    ///
429    /// Readable | Writeable
430    /// </details>
431    ///
432    /// ## Signals
433    ///
434    ///
435    /// #### `activate-link`
436    ///  Emitted each time the [`LinkButton`][crate::LinkButton] is clicked.
437    ///
438    /// The default handler will call [`FileLauncher::launch()`][crate::FileLauncher::launch()] with the URI
439    /// stored inside the [`uri`][struct@crate::LinkButton#uri] property.
440    ///
441    /// To override the default behavior, you can connect to the
442    /// ::activate-link signal and stop the propagation of the signal
443    /// by returning [`true`] from your handler.
444    ///
445    ///
446    /// <details><summary><h4>Button</h4></summary>
447    ///
448    ///
449    /// #### `activate`
450    ///  Emitted to animate press then release.
451    ///
452    /// This is an action signal. Applications should never connect
453    /// to this signal, but use the [`clicked`][struct@crate::Button#clicked] signal.
454    ///
455    /// The default bindings for this signal are all forms of the
456    /// <kbd>␣</kbd> and <kbd>Enter</kbd> keys.
457    ///
458    /// Action
459    ///
460    ///
461    /// #### `clicked`
462    ///  Emitted when the button has been activated (pressed and released).
463    ///
464    /// Action
465    /// </details>
466    /// <details><summary><h4>Widget</h4></summary>
467    ///
468    ///
469    /// #### `destroy`
470    ///  Signals that all holders of a reference to the widget should release
471    /// the reference that they hold.
472    ///
473    /// May result in finalization of the widget if all references are released.
474    ///
475    /// This signal is not suitable for saving widget state.
476    ///
477    ///
478    ///
479    ///
480    /// #### `direction-changed`
481    ///  Emitted when the text direction of a widget changes.
482    ///
483    ///
484    ///
485    ///
486    /// #### `hide`
487    ///  Emitted when @widget is hidden.
488    ///
489    ///
490    ///
491    ///
492    /// #### `keynav-failed`
493    ///  Emitted if keyboard navigation fails.
494    ///
495    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
496    ///
497    ///
498    ///
499    ///
500    /// #### `map`
501    ///  Emitted when @widget is going to be mapped.
502    ///
503    /// A widget is mapped when the widget is visible (which is controlled with
504    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
505    /// are also visible.
506    ///
507    /// The `::map` signal can be used to determine whether a widget will be drawn,
508    /// for instance it can resume an animation that was stopped during the
509    /// emission of [`unmap`][struct@crate::Widget#unmap].
510    ///
511    ///
512    ///
513    ///
514    /// #### `mnemonic-activate`
515    ///  Emitted when a widget is activated via a mnemonic.
516    ///
517    /// The default handler for this signal activates @widget if @group_cycling
518    /// is false, or just makes @widget grab focus if @group_cycling is true.
519    ///
520    ///
521    ///
522    ///
523    /// #### `move-focus`
524    ///  Emitted when the focus is moved.
525    ///
526    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
527    ///
528    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
529    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
530    ///
531    /// Action
532    ///
533    ///
534    /// #### `query-tooltip`
535    ///  Emitted when the widget’s tooltip is about to be shown.
536    ///
537    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
538    /// is true and the hover timeout has expired with the cursor hovering
539    /// above @widget; or emitted when @widget got focus in keyboard mode.
540    ///
541    /// Using the given coordinates, the signal handler should determine
542    /// whether a tooltip should be shown for @widget. If this is the case
543    /// true should be returned, false otherwise. Note that if @keyboard_mode
544    /// is true, the values of @x and @y are undefined and should not be used.
545    ///
546    /// The signal handler is free to manipulate @tooltip with the therefore
547    /// destined function calls.
548    ///
549    ///
550    ///
551    ///
552    /// #### `realize`
553    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
554    ///
555    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
556    /// or the widget has been mapped (that is, it is going to be drawn).
557    ///
558    ///
559    ///
560    ///
561    /// #### `show`
562    ///  Emitted when @widget is shown.
563    ///
564    ///
565    ///
566    ///
567    /// #### `state-flags-changed`
568    ///  Emitted when the widget state changes.
569    ///
570    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
571    ///
572    ///
573    ///
574    ///
575    /// #### `unmap`
576    ///  Emitted when @widget is going to be unmapped.
577    ///
578    /// A widget is unmapped when either it or any of its parents up to the
579    /// toplevel widget have been set as hidden.
580    ///
581    /// As `::unmap` indicates that a widget will not be shown any longer,
582    /// it can be used to, for example, stop an animation on the widget.
583    ///
584    ///
585    ///
586    ///
587    /// #### `unrealize`
588    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
589    ///
590    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
591    /// or the widget has been unmapped (that is, it is going to be hidden).
592    ///
593    ///
594    /// </details>
595    ///
596    /// # Implements
597    ///
598    /// [`ButtonExt`][trait@crate::prelude::ButtonExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`ActionableExtManual`][trait@crate::prelude::ActionableExtManual]
599    #[doc(alias = "GtkLinkButton")]
600    pub struct LinkButton(Object<ffi::GtkLinkButton>) @extends Button, Widget, @implements Accessible, Buildable, ConstraintTarget, Actionable;
601
602    match fn {
603        type_ => || ffi::gtk_link_button_get_type(),
604    }
605}
606
607impl LinkButton {
608    /// Creates a new [`LinkButton`][crate::LinkButton] with the URI as its text.
609    /// ## `uri`
610    /// a valid URI
611    ///
612    /// # Returns
613    ///
614    /// a new link button widget.
615    #[doc(alias = "gtk_link_button_new")]
616    pub fn new(uri: &str) -> LinkButton {
617        assert_initialized_main_thread!();
618        unsafe {
619            Widget::from_glib_none(ffi::gtk_link_button_new(uri.to_glib_none().0)).unsafe_cast()
620        }
621    }
622
623    /// Creates a new [`LinkButton`][crate::LinkButton] containing a label.
624    /// ## `uri`
625    /// a valid URI
626    /// ## `label`
627    /// the text of the button
628    ///
629    /// # Returns
630    ///
631    /// a new link button widget.
632    #[doc(alias = "gtk_link_button_new_with_label")]
633    #[doc(alias = "new_with_label")]
634    pub fn with_label(uri: &str, label: &str) -> LinkButton {
635        assert_initialized_main_thread!();
636        unsafe {
637            Widget::from_glib_none(ffi::gtk_link_button_new_with_label(
638                uri.to_glib_none().0,
639                label.to_glib_none().0,
640            ))
641            .unsafe_cast()
642        }
643    }
644
645    // rustdoc-stripper-ignore-next
646    /// Creates a new builder-pattern struct instance to construct [`LinkButton`] objects.
647    ///
648    /// This method returns an instance of [`LinkButtonBuilder`](crate::builders::LinkButtonBuilder) which can be used to create [`LinkButton`] objects.
649    pub fn builder() -> LinkButtonBuilder {
650        LinkButtonBuilder::new()
651    }
652
653    /// Retrieves the URI of the [`LinkButton`][crate::LinkButton].
654    ///
655    /// # Returns
656    ///
657    /// a valid URI. The returned string is owned by the link button
658    ///   and should not be modified or freed.
659    #[doc(alias = "gtk_link_button_get_uri")]
660    #[doc(alias = "get_uri")]
661    pub fn uri(&self) -> glib::GString {
662        unsafe { from_glib_none(ffi::gtk_link_button_get_uri(self.to_glib_none().0)) }
663    }
664
665    /// Retrieves the “visited” state of the [`LinkButton`][crate::LinkButton].
666    ///
667    /// The button becomes visited when it is clicked. If the URI
668    /// is changed on the button, the “visited” state is unset again.
669    ///
670    /// The state may also be changed using [`set_visited()`][Self::set_visited()].
671    ///
672    /// # Returns
673    ///
674    /// [`true`] if the link has been visited, [`false`] otherwise
675    #[doc(alias = "gtk_link_button_get_visited")]
676    #[doc(alias = "get_visited")]
677    #[doc(alias = "visited")]
678    pub fn is_visited(&self) -> bool {
679        unsafe { from_glib(ffi::gtk_link_button_get_visited(self.to_glib_none().0)) }
680    }
681
682    /// Sets @uri as the URI where the [`LinkButton`][crate::LinkButton] points.
683    ///
684    /// As a side-effect this unsets the “visited” state of the button.
685    /// ## `uri`
686    /// a valid URI
687    #[doc(alias = "gtk_link_button_set_uri")]
688    #[doc(alias = "uri")]
689    pub fn set_uri(&self, uri: &str) {
690        unsafe {
691            ffi::gtk_link_button_set_uri(self.to_glib_none().0, uri.to_glib_none().0);
692        }
693    }
694
695    /// Sets the “visited” state of the [`LinkButton`][crate::LinkButton].
696    ///
697    /// See [`is_visited()`][Self::is_visited()] for more details.
698    /// ## `visited`
699    /// the new “visited” state
700    #[doc(alias = "gtk_link_button_set_visited")]
701    #[doc(alias = "visited")]
702    pub fn set_visited(&self, visited: bool) {
703        unsafe {
704            ffi::gtk_link_button_set_visited(self.to_glib_none().0, visited.into_glib());
705        }
706    }
707
708    /// Emitted each time the [`LinkButton`][crate::LinkButton] is clicked.
709    ///
710    /// The default handler will call [`FileLauncher::launch()`][crate::FileLauncher::launch()] with the URI
711    /// stored inside the [`uri`][struct@crate::LinkButton#uri] property.
712    ///
713    /// To override the default behavior, you can connect to the
714    /// ::activate-link signal and stop the propagation of the signal
715    /// by returning [`true`] from your handler.
716    ///
717    /// # Returns
718    ///
719    /// [`true`] if the signal has been handled
720    #[doc(alias = "activate-link")]
721    pub fn connect_activate_link<F: Fn(&Self) -> glib::Propagation + 'static>(
722        &self,
723        f: F,
724    ) -> SignalHandlerId {
725        unsafe extern "C" fn activate_link_trampoline<
726            F: Fn(&LinkButton) -> glib::Propagation + 'static,
727        >(
728            this: *mut ffi::GtkLinkButton,
729            f: glib::ffi::gpointer,
730        ) -> glib::ffi::gboolean {
731            let f: &F = &*(f as *const F);
732            f(&from_glib_borrow(this)).into_glib()
733        }
734        unsafe {
735            let f: Box_<F> = Box_::new(f);
736            connect_raw(
737                self.as_ptr() as *mut _,
738                b"activate-link\0".as_ptr() as *const _,
739                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
740                    activate_link_trampoline::<F> as *const (),
741                )),
742                Box_::into_raw(f),
743            )
744        }
745    }
746
747    #[doc(alias = "uri")]
748    pub fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
749        unsafe extern "C" fn notify_uri_trampoline<F: Fn(&LinkButton) + 'static>(
750            this: *mut ffi::GtkLinkButton,
751            _param_spec: glib::ffi::gpointer,
752            f: glib::ffi::gpointer,
753        ) {
754            let f: &F = &*(f as *const F);
755            f(&from_glib_borrow(this))
756        }
757        unsafe {
758            let f: Box_<F> = Box_::new(f);
759            connect_raw(
760                self.as_ptr() as *mut _,
761                b"notify::uri\0".as_ptr() as *const _,
762                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
763                    notify_uri_trampoline::<F> as *const (),
764                )),
765                Box_::into_raw(f),
766            )
767        }
768    }
769
770    #[doc(alias = "visited")]
771    pub fn connect_visited_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
772        unsafe extern "C" fn notify_visited_trampoline<F: Fn(&LinkButton) + 'static>(
773            this: *mut ffi::GtkLinkButton,
774            _param_spec: glib::ffi::gpointer,
775            f: glib::ffi::gpointer,
776        ) {
777            let f: &F = &*(f as *const F);
778            f(&from_glib_borrow(this))
779        }
780        unsafe {
781            let f: Box_<F> = Box_::new(f);
782            connect_raw(
783                self.as_ptr() as *mut _,
784                b"notify::visited\0".as_ptr() as *const _,
785                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
786                    notify_visited_trampoline::<F> as *const (),
787                )),
788                Box_::into_raw(f),
789            )
790        }
791    }
792}
793
794impl Default for LinkButton {
795    fn default() -> Self {
796        glib::object::Object::new::<Self>()
797    }
798}
799
800// rustdoc-stripper-ignore-next
801/// A [builder-pattern] type to construct [`LinkButton`] objects.
802///
803/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
804#[must_use = "The builder must be built to be used"]
805pub struct LinkButtonBuilder {
806    builder: glib::object::ObjectBuilder<'static, LinkButton>,
807}
808
809impl LinkButtonBuilder {
810    fn new() -> Self {
811        Self {
812            builder: glib::object::Object::builder(),
813        }
814    }
815
816    /// The URI bound to this button.
817    pub fn uri(self, uri: impl Into<glib::GString>) -> Self {
818        Self {
819            builder: self.builder.property("uri", uri.into()),
820        }
821    }
822
823    /// The 'visited' state of this button.
824    ///
825    /// A visited link is drawn in a different color.
826    pub fn visited(self, visited: bool) -> Self {
827        Self {
828            builder: self.builder.property("visited", visited),
829        }
830    }
831
832    /// Whether the size of the button can be made smaller than the natural
833    /// size of its contents.
834    ///
835    /// For text buttons, setting this property will allow ellipsizing the label.
836    ///
837    /// If the contents of a button are an icon or a custom widget, setting this
838    /// property has no effect.
839    #[cfg(feature = "v4_12")]
840    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
841    pub fn can_shrink(self, can_shrink: bool) -> Self {
842        Self {
843            builder: self.builder.property("can-shrink", can_shrink),
844        }
845    }
846
847    /// The child widget.
848    pub fn child(self, child: &impl IsA<Widget>) -> Self {
849        Self {
850            builder: self.builder.property("child", child.clone().upcast()),
851        }
852    }
853
854    /// Whether the button has a frame.
855    pub fn has_frame(self, has_frame: bool) -> Self {
856        Self {
857            builder: self.builder.property("has-frame", has_frame),
858        }
859    }
860
861    /// The name of the icon used to automatically populate the button.
862    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
863        Self {
864            builder: self.builder.property("icon-name", icon_name.into()),
865        }
866    }
867
868    /// Text of the label inside the button, if the button contains a label widget.
869    pub fn label(self, label: impl Into<glib::GString>) -> Self {
870        Self {
871            builder: self.builder.property("label", label.into()),
872        }
873    }
874
875    /// If set, an underline in the text indicates that the following character is
876    /// to be used as mnemonic.
877    pub fn use_underline(self, use_underline: bool) -> Self {
878        Self {
879            builder: self.builder.property("use-underline", use_underline),
880        }
881    }
882
883    /// Whether the widget or any of its descendents can accept
884    /// the input focus.
885    ///
886    /// This property is meant to be set by widget implementations,
887    /// typically in their instance init function.
888    pub fn can_focus(self, can_focus: bool) -> Self {
889        Self {
890            builder: self.builder.property("can-focus", can_focus),
891        }
892    }
893
894    /// Whether the widget can receive pointer events.
895    pub fn can_target(self, can_target: bool) -> Self {
896        Self {
897            builder: self.builder.property("can-target", can_target),
898        }
899    }
900
901    /// A list of css classes applied to this widget.
902    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
903        Self {
904            builder: self.builder.property("css-classes", css_classes.into()),
905        }
906    }
907
908    /// The name of this widget in the CSS tree.
909    ///
910    /// This property is meant to be set by widget implementations,
911    /// typically in their instance init function.
912    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
913        Self {
914            builder: self.builder.property("css-name", css_name.into()),
915        }
916    }
917
918    /// The cursor used by @widget.
919    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
920        Self {
921            builder: self.builder.property("cursor", cursor.clone()),
922        }
923    }
924
925    /// Whether the widget should grab focus when it is clicked with the mouse.
926    ///
927    /// This property is only relevant for widgets that can take focus.
928    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
929        Self {
930            builder: self.builder.property("focus-on-click", focus_on_click),
931        }
932    }
933
934    /// Whether this widget itself will accept the input focus.
935    pub fn focusable(self, focusable: bool) -> Self {
936        Self {
937            builder: self.builder.property("focusable", focusable),
938        }
939    }
940
941    /// How to distribute horizontal space if widget gets extra space.
942    pub fn halign(self, halign: Align) -> Self {
943        Self {
944            builder: self.builder.property("halign", halign),
945        }
946    }
947
948    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
949    /// signal on @widget.
950    ///
951    /// A true value indicates that @widget can have a tooltip, in this case
952    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
953    /// determine whether it will provide a tooltip or not.
954    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
955        Self {
956            builder: self.builder.property("has-tooltip", has_tooltip),
957        }
958    }
959
960    /// Overrides for height request of the widget.
961    ///
962    /// If this is -1, the natural request will be used.
963    pub fn height_request(self, height_request: i32) -> Self {
964        Self {
965            builder: self.builder.property("height-request", height_request),
966        }
967    }
968
969    /// Whether to expand horizontally.
970    pub fn hexpand(self, hexpand: bool) -> Self {
971        Self {
972            builder: self.builder.property("hexpand", hexpand),
973        }
974    }
975
976    /// Whether to use the `hexpand` property.
977    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
978        Self {
979            builder: self.builder.property("hexpand-set", hexpand_set),
980        }
981    }
982
983    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
984    /// the preferred size of the widget, and allocate its children.
985    ///
986    /// This property is meant to be set by widget implementations,
987    /// typically in their instance init function.
988    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
989        Self {
990            builder: self
991                .builder
992                .property("layout-manager", layout_manager.clone().upcast()),
993        }
994    }
995
996    /// Makes this widget act like a modal dialog, with respect to
997    /// event delivery.
998    ///
999    /// Global event controllers will not handle events with targets
1000    /// inside the widget, unless they are set up to ignore propagation
1001    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1002    #[cfg(feature = "v4_18")]
1003    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1004    pub fn limit_events(self, limit_events: bool) -> Self {
1005        Self {
1006            builder: self.builder.property("limit-events", limit_events),
1007        }
1008    }
1009
1010    /// Margin on bottom side of widget.
1011    ///
1012    /// This property adds margin outside of the widget's normal size
1013    /// request, the margin will be added in addition to the size from
1014    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1015    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1016        Self {
1017            builder: self.builder.property("margin-bottom", margin_bottom),
1018        }
1019    }
1020
1021    /// Margin on end of widget, horizontally.
1022    ///
1023    /// This property supports left-to-right and right-to-left text
1024    /// directions.
1025    ///
1026    /// This property adds margin outside of the widget's normal size
1027    /// request, the margin will be added in addition to the size from
1028    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1029    pub fn margin_end(self, margin_end: i32) -> Self {
1030        Self {
1031            builder: self.builder.property("margin-end", margin_end),
1032        }
1033    }
1034
1035    /// Margin on start of widget, horizontally.
1036    ///
1037    /// This property supports left-to-right and right-to-left text
1038    /// directions.
1039    ///
1040    /// This property adds margin outside of the widget's normal size
1041    /// request, the margin will be added in addition to the size from
1042    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1043    pub fn margin_start(self, margin_start: i32) -> Self {
1044        Self {
1045            builder: self.builder.property("margin-start", margin_start),
1046        }
1047    }
1048
1049    /// Margin on top side of widget.
1050    ///
1051    /// This property adds margin outside of the widget's normal size
1052    /// request, the margin will be added in addition to the size from
1053    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1054    pub fn margin_top(self, margin_top: i32) -> Self {
1055        Self {
1056            builder: self.builder.property("margin-top", margin_top),
1057        }
1058    }
1059
1060    /// The name of the widget.
1061    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1062        Self {
1063            builder: self.builder.property("name", name.into()),
1064        }
1065    }
1066
1067    /// The requested opacity of the widget.
1068    pub fn opacity(self, opacity: f64) -> Self {
1069        Self {
1070            builder: self.builder.property("opacity", opacity),
1071        }
1072    }
1073
1074    /// How content outside the widget's content area is treated.
1075    ///
1076    /// This property is meant to be set by widget implementations,
1077    /// typically in their instance init function.
1078    pub fn overflow(self, overflow: Overflow) -> Self {
1079        Self {
1080            builder: self.builder.property("overflow", overflow),
1081        }
1082    }
1083
1084    /// Whether the widget will receive the default action when it is focused.
1085    pub fn receives_default(self, receives_default: bool) -> Self {
1086        Self {
1087            builder: self.builder.property("receives-default", receives_default),
1088        }
1089    }
1090
1091    /// Whether the widget responds to input.
1092    pub fn sensitive(self, sensitive: bool) -> Self {
1093        Self {
1094            builder: self.builder.property("sensitive", sensitive),
1095        }
1096    }
1097
1098    /// Sets the text of tooltip to be the given string, which is marked up
1099    /// with Pango markup.
1100    ///
1101    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1102    ///
1103    /// This is a convenience property which will take care of getting the
1104    /// tooltip shown if the given string is not `NULL`:
1105    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1106    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1107    /// the default signal handler.
1108    ///
1109    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1110    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1111    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1112        Self {
1113            builder: self
1114                .builder
1115                .property("tooltip-markup", tooltip_markup.into()),
1116        }
1117    }
1118
1119    /// Sets the text of tooltip to be the given string.
1120    ///
1121    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1122    ///
1123    /// This is a convenience property which will take care of getting the
1124    /// tooltip shown if the given string is not `NULL`:
1125    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1126    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1127    /// the default signal handler.
1128    ///
1129    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1130    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1131    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1132        Self {
1133            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1134        }
1135    }
1136
1137    /// How to distribute vertical space if widget gets extra space.
1138    pub fn valign(self, valign: Align) -> Self {
1139        Self {
1140            builder: self.builder.property("valign", valign),
1141        }
1142    }
1143
1144    /// Whether to expand vertically.
1145    pub fn vexpand(self, vexpand: bool) -> Self {
1146        Self {
1147            builder: self.builder.property("vexpand", vexpand),
1148        }
1149    }
1150
1151    /// Whether to use the `vexpand` property.
1152    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1153        Self {
1154            builder: self.builder.property("vexpand-set", vexpand_set),
1155        }
1156    }
1157
1158    /// Whether the widget is visible.
1159    pub fn visible(self, visible: bool) -> Self {
1160        Self {
1161            builder: self.builder.property("visible", visible),
1162        }
1163    }
1164
1165    /// Overrides for width request of the widget.
1166    ///
1167    /// If this is -1, the natural request will be used.
1168    pub fn width_request(self, width_request: i32) -> Self {
1169        Self {
1170            builder: self.builder.property("width-request", width_request),
1171        }
1172    }
1173
1174    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1175    ///
1176    /// The accessible role cannot be changed once set.
1177    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1178        Self {
1179            builder: self.builder.property("accessible-role", accessible_role),
1180        }
1181    }
1182
1183    /// The name of the action with which this widget should be associated.
1184    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1185        Self {
1186            builder: self.builder.property("action-name", action_name.into()),
1187        }
1188    }
1189
1190    /// The target value of the actionable widget's action.
1191    pub fn action_target(self, action_target: &glib::Variant) -> Self {
1192        Self {
1193            builder: self
1194                .builder
1195                .property("action-target", action_target.clone()),
1196        }
1197    }
1198
1199    // rustdoc-stripper-ignore-next
1200    /// Build the [`LinkButton`].
1201    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1202    pub fn build(self) -> LinkButton {
1203        assert_initialized_main_thread!();
1204        self.builder.build()
1205    }
1206}