Gtk.Applicationwith a correctly set
application_idas we previously set up in Hello World.
ninjato build your project. It should still build without any errors. If you do encounter errors, double check your changes and resolve them before continuing.
granitein your build system and created a new
application_id, it's time to write some code.
12can be done with the following lines:
set_badge_visibleproperty to true, and use an int64 type for the
set_badgeproperty. The suffix
.beginis required here since these are asynchronous methods.
doublevalue type and is a range between
1: from 0% to 100%. As with badges, Don't forget that
.beginis required for asynchronous methods.
.desktopfile does not involve writing any code or using any external dependencies, though your app needs a way to distinguish between actions, e.g. with command line flags.
Actionsline in your app's .desktop file. This line should contain a
;separated list of unique action names:
Iconline is optional and should be an icon which represents the action that will be performed. The
Execline is required and should be your app's executable name and any command line argument required to trigger the action.
-nor any other argument will not automatically make your app open a new window; your app must handle and interpret command line arguments. The GLib.Application API provides many examples and an extensive documentation on how to handle these arguments, particularly the command_line signal.