Skip to main content

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