Developer Documentation
  • Developer Docs
  • Writing Apps
    • The Basic Setup
    • Hello World
    • Our First App
      • Metadata
      • The Build System
      • Translations
      • Icons
      • Packaging
      • Continuous Integration
    • Boxes and Grids
    • Popovers
    • Panes
    • Code Style
      • GObject-style Construction
    • Creating Logs
  • APIs
    • Actions
    • Notifications
    • Launchers
    • State Saving
    • Custom Resources
    • Color Scheme
    • System Settings
    • Valadoc
  • AppCenter
    • Publishing Requirements
    • Submission Process
    • Monetizing Your App
    • Publishing Updates
    • Markdown Badges
    • Dashboard
Powered by GitBook

Links

  • Homepage
  • Support
  • Developer
  • Blog

Other Docs

  • HIG
  • Contributor Guide

Made with ❤️ by contributors from all over the world

On this page
  • Opening a link
  • Use cases

Was this helpful?

Edit on GitHub
Export as PDF
  1. APIs

System Settings

Deep linking to System Settings

Some of the features of your application may depend on system level settings or services, such as Internet connectivity or app level access to the network. While your app cannot directly change those settings, it can prompt users to change them by linking to specific panes in the System Settings.

elementary OS implements a special settings:// URI scheme for linking to System Settings. The links lead to specific settings panes. You can find most commonly used ones in the Granite.SettingsUri namespace in the Granite library.

Opening a link

First, make sure you've included recent enough version of Granite and Gtk in the build dependencies declared in your meson.build file. You can get those dependencies by using the elementary Flatpak runtime version 7.2 or newer:

executable(
    meson.project_name(),
    'src' / 'Application.vala',
    dependencies: [
        dependency('granite-7', version: '>= 7.3.0'),
        dependency('gtk4', version: '>= 4.10.0')
    ],
    install: true
)
runtime: io.elementary.Platform
runtime-version: '7.2'
sdk: io.elementary.Sdk

Then you can open Network settings by launching Granite.SettingsUri.NETWORK:

var button = new Gtk.Button.with_label ("Change network settings");
button.clicked.connect (() => {
    var launcher = new Gtk.UriLauncher (Granite.SettingsUri.NETWORK);
    launcher.launch.begin(null, null, (obj, res) => {
        try {
            launcher.launch.end (res);
        } catch (Error e) {
            warning ("Failed to open network settings: %s", e.message);
        }
    });
});

Use cases

There are roughly two categories of settings that you can prompt users to change: general purpose and app specific. General ones include:

  • Granite.SettingsUri.NETWORK, where connection to the Internet can be enabled

  • Granite.SettingsUri.ONLINE_ACCOUNTS, where users can add their CalDAV and IMAP accounts

  • Granite.SettingsUri.SOUND_INPUT, where microphone input can be enabled

while app specific ones are:

  • Granite.SettingsUri.LOCATION, where access to location data can be granted

  • Granite.SettingsUri.NOTIFICATIONS, where presentation of app notifications can be customized

  • Granite.SettingsUri.SHORTCUTS, where global keyboard shortcuts can be added

PreviousColor SchemeNextPublishing Requirements

Last updated 1 year ago

Was this helpful?

You can find out more about the Gtk.UriLauncher in .

Granite.SettingsUri.PERMISSIONS, where are managed

its documentation
Flatpak permissions