Contents Menu Expand Light mode Dark mode Auto light/dark mode
GNOME Developer Documentation
GNOME Developer Documentation

Contents

  • Platform Introduction
    • Platform Components
      • Libraries
      • Services
    • Programming Languages
    • GNOME Builder
    • Flatpak
  • Guidelines
    • Programming Guidelines
      • C Coding Style
      • Managing Memory
      • The Importance of Writing Good Code
      • Optimizing GNOME Applications
      • Namespacing
      • Introspection
    • Accessibility
      • Coding Guidelines for Supporting Accessibility
      • Making Custom Components Accessible
    • Localization
      • Best Practices for Localization
    • Maintainer Guidelines
      • API Stability
      • Parallel Installability
      • Integrating with GNOME
    • Developer Documentation Style Guidelines
  • Tools
    • Valgrind
    • Massif
    • Sysprof
  • Tutorials
    • Beginners Tutorials
      • Getting Started
        • Adding A Content View
        • Loading Content From A File
        • Showing The Cursor Position
        • Saving The Content To A File
        • Saving The Application State
        • Notifying The User With Toasts
        • Forcing The Dark Color Scheme
      • UI components
        • Windows
        • Images
        • Labels
        • Buttons
        • Boxes
        • Stacks
        • Leaflets
        • Toggles
        • Check Boxes
        • Radio Buttons
        • Spin Buttons
        • Link Buttons
        • Switches
        • Menu Buttons
        • Entries
        • Password Entries
        • Messages
        • File Dialogs
        • Spinners
        • Level Bars
    • Application ID
    • Using GtkApplication
    • Saving and Loading Window State
    • Using Notifications
    • Themed Icons
    • Dealing With Deprecations
    • Actions
    • Menus
    • Writing a Search Provider
    • Pre- and Post-Conditions
    • Main Contexts
    • Using GLib Lists
    • Threading
    • Asynchronous Programming
    • Drag and Drop
    • Widget Templates
  • Specifications
    • GVariant Specification 1.0
This Page
  • Show on GitLab
  • Edit on GitLab
  • Show Source

Link Buttons#

A button showing an hyper link to a resource.

GtkWidget *link = gtk_link_button_new ("https://developer.gnome.org");

gtk_button_set_label (GTK_BUTTON (link), "Developer Documentation");
link = Gtk.LinkButton(uri="https://developer.gnome.org",
                      label="Developer Documentation")
var link = new Gtk.LinkButton.with_label ("https://developer.gnome.org",
                                          "Developer Documentation");
const link = new Gtk.LinkButton({
  uri: "https://developer.gnome.org",
  label: "Developer Documentation",
});

It is possible to use a link to any resource that has a URI scheme with a handler defined in the operating system; for instance, this button will open the help browser:

GtkWidget *help = gtk_link_button_new ("help:devhelp");

gtk_button_set_label (GTK_BUTTON (help), "Open the Devhelp documentation");
help = Gtk.LinkButton(uri="help:devhelp", label="Open the Devhelp documentation")
var help = new Gtk.LinkButton.with_label ("help:devhelp",
                                          "Open the Devhelp documentation");
const help = new Gtk.LinkButton({
   uri: "help:devhelp",
   label: "Open the Devhelp documentation"
});

Useful methods for the component#

  • If you want to know whether the user clicked the button and visited the URL, then you can use the get_visited() method. If you change the URL of the link button, the GtkLinkButton:visited property will be reset.

API references#

In the examples we used the following classes:

  • GtkLinkButton

Next
Switches
Previous
Spin Buttons
Contents
  • Link Buttons
    • Useful methods for the component
    • API references