1.109 <GtkLinkButton>

Class: <GtkLinkButton>

It derives from <GtkButton>.

A button with a hyperlink.

It is useful to show quick links to resources.

A link button is created by calling either link-button:new or link-button: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 <GtkLinkButton> can be set specifically using link-button:set-uri.

By default, <GtkLinkButton> calls file-launcher:launch when the button is clicked. This behaviour can be overridden by connecting to the link-button:activate-link signal and returning #t from the signal handler.

Shortcuts and Gestures

<GtkLinkButton> supports the following keyboard shortcuts:

  • Shift+F10 or Menu opens the context menu.

Actions

<GtkLinkButton> defines a set of built-in actions:

  • clipboard.copy copies the url to the clipboard.
  • menu.popup opens the context menu.

CSS nodes

<GtkLinkButton> has a single CSS node with name button. To differentiate it from a plain <GtkButton>, it gets the .link style class.

Accessibility

<GtkLinkButton> uses the Gtk.AccessibleRole.link role.

Properties

The URI bound to this button.

Its value is a string, or #f.

Set it with (set! (link-button:uri self) value).

The ’visited’ state of this button.

A visited link is drawn in a different color.

Its value is a boolean.

Set it with (set! (link-button:visited self) value).

Procedures

Method: get-uri self ⇒ %return

Retrieves the URI of the <GtkLinkButton>.

self

Passed: a <GtkLinkButton>.

a <GtkLinkButton>

%return

Returned: a string.

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

Method: get-visited? self ⇒ %return

Retrieves the “visited” state of the <GtkLinkButton>.

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 link-button:set-visited.

self

Passed: a <GtkLinkButton>.

a <GtkLinkButton>

%return

Returned: a boolean.

#t if the link has been visited, #f otherwise

Creates a new <GtkLinkButton> with the URI as its text.

uri

Passed: a string.

a valid URI

%return

Returned: a <GtkWidget>.

a new link button widget.

Creates a new <GtkLinkButton> containing a label.

uri

Passed: a string.

a valid URI

label

Passed, or left out: a string, or #f.

the text of the button

%return

Returned: a <GtkWidget>.

a new link button widget.

Method: set-uri self uri

Sets uri as the URI where the <GtkLinkButton> points.

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

self

Passed: a <GtkLinkButton>.

a <GtkLinkButton>

uri

Passed: a string.

a valid URI

Method: set-visited self visited

Sets the “visited” state of the <GtkLinkButton>.

See link-button:get-visited? for more details.

self

Passed: a <GtkLinkButton>.

a <GtkLinkButton>

visited

Passed: a boolean.

the new “visited” state

Signals

Connect a handler with (connect object link-button:activate-link handler). It is called as (handler self) ⇒ %return.

Emitted each time the <GtkLinkButton> is clicked.

The default handler will call file-launcher:launch with the URI stored inside the link-button:uri property.

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

self

Passed: a <GtkLinkButton>.

%return

Returned: a boolean.

#t if the signal has been handled