Desktop App Support - GTK


#1

Graphical applications which use the GTK+ Toolkit require additional libraries and environment configuration to function correctly inside a snap.

The details have been collected into a remote part, which can be included in any snap at build time.

GTK2 based applications should use the desktop-gtk2 remote part. GTK3 applications should reference the desktop-gtk3 part.

In this snippet the remote part is referenced in an after section.

parts:
    audiocoder:
        after: [desktop-gtk3]

In addition the launcher script which sets up the environment should prefix the binary name in the apps section. Typically it’s also necessary to specify the full path to the target binary after the launcher.

apps:
   command: desktop-launch $SNAP/usr/bin/audiocoder-gtk
       plugs: [network, desktop, desktop-legacy]

These pre-defined parts do not automatically pull in all necessary GTK libraries, but the minimum required by most applications.

The developer is expected to list any further libraries as stage-packages or additional parts.


Importing PIL and gi into a Snap
How can I build package with python and gtk?
Proposed new documentation outline
Questions regarding the usage of the gnome-platform content snaps
#2

I think it would be helpful to link this back to Bundling runtime dependencies - Libraries


#3

Should there also be minimal example to define .desktop file integrated into the snapcraft.yaml. Gtk apps need to have a .desktop entry in order to run correctly in snap.


#4

Great article, I would like to see some info on using the gnome-platform content snap though.


#5

The unofficial Snapcrafters Template Plus has implemented an example desktop entry: https://github.com/Lin-Buo-Ren/snapcrafters-template-plus/blob/master/snap/gui/my-awesome-app.desktop


#6

Does [desktop-gtk3] still apply when using a base? such as base: core18 ?

When using a base, I get an error: Cannot find the definition for part ‘desktop-gtk3’


#7

When using bases, snapcraft no longer support remote parts. You need to redefine the part. You can see below for an example. Going forward snapcraft will include an extension for “gnome” which provides what the remote part did, however that isn’t done yet.

https://bazaar.launchpad.net/~ubuntu-desktop/quadrapassel/snap/view/head:/snapcraft.yaml#L62