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