About all my projects
Gnome::Gtk4::LinkButton

Gnome::Gtk4::LinkButton

Description

A Gnome::Gtk4::LinkButton is a button with a hyperlink.

No caption

It is useful to show quick links to resources.

A link button is created by calling either .newlinkbutton() or .new-with-label(). If using the former, the URI you pass to the constructor is used as a label for the widget.

The URI bound to a Gnome::Gtk4::LinkButton can be set specifically using .set-uri().

By default, Gnome::Gtk4::LinkButton calls .launch() in class Gnome::Gtk4::FileLauncher when the button is clicked. This behaviour can be overridden by connecting to the activate-link signal and returning True from the signal handler.

CSS nodes

Gnome::Gtk4::LinkButton has a single CSS node with name button. To differentiate it from a plain Gnome::Gtk4::Button, it gets the .link style class.

Accessibility

Gnome::Gtk4::LinkButton uses the GTK_ACCESSIBLE_ROLE_LINK role.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-linkbutton

Creates a new Gnome::Gtk4::LinkButton with the URI as its text.

method new-linkbutton ( Str $uri --> Gnome::Gtk4::LinkButton \)
  • $uri; a valid URI.

new-with-label

Creates a new Gnome::Gtk4::LinkButton containing a label.

method new-with-label ( Str $uri, Str $label --> Gnome::Gtk4::LinkButton \)
  • $uri; a valid URI.

  • $label; the text of the button.

Methods

get-uri

Retrieves the URI of the Gnome::Gtk4::LinkButton.

method get-uri (--> Str )

Return value; a valid URI. The returned string is owned by the link button and should not be modified or freed..

get-visited

Retrieves the “visited” state of the Gnome::Gtk4::LinkButton.

The button becomes visited when it is clicked. If the URI is changed on the button, the “visited” state is unset again.

The state may also be changed using .set-visited().

method get-visited (--> Bool )

Return value; True if the link has been visited, False otherwise.

set-uri

Sets $uri as the URI where the Gnome::Gtk4::LinkButton points.

As a side-effect this unsets the “visited” state of the button.

method set-uri ( Str $uri )
  • $uri; a valid URI.

set-visited

Sets the “visited” state of the Gnome::Gtk4::LinkButton.

See .get-visited() for more details.

method set-visited ( Bool() $visited )
  • $visited; the new “visited” state.

Signals

Emitted each time the Gnome::Gtk4::LinkButton is clicked.

The default handler will call .launch() in class Gnome::Gtk4::FileLauncher with the URI stored inside the uri property.

To override the default behavior, you can connect to the activate-link signal and stop the propagation of the signal by returning True from your handler.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::LinkButton :$_widget,
  *C<user>-options
  --> gboolean
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::LinkButton object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if the signal has been handled