Bygga program

This chapter is similar to Building applications and following sections in the Getting Started chapter in the GTK documentation. The same application is built, but gtkmm is used instead of GTK.

Ett program består av ett antal filer:

Binärfilen

Denna installeras i /usr/bin.

A desktop file

The desktop file provides important information about the application to the desktop shell, such as its name, icon, D-Bus name, commandline to launch it, etc. It is installed in /usr/share/applications.

En ikon

Ikonen installeras i /usr/share/icons/hicolor/48x48/apps, där den kommer hittas oavsett aktuellt tema.

Ett inställningsschema

Om programmet använder Gio::Settings kommer det installera sitt schema i /usr/share/glib-2.0/schemas så att verktyg som dconf-editor kan hitta det.

Andra resurser

Other files, such as Gtk::Builder ui files, are best loaded from resources stored in the application binary itself. This eliminates the need for most of the files that would traditionally be installed in an application-specific location in /usr/share.

gtkmm includes application support that is built on top of Gio::Application. In this chapter we'll build a simple application by starting from scratch, adding more and more pieces over time. Along the way, we'll learn about Gtk::Application, Gtk::Builder, resources, menus, settings, Gtk::HeaderBar, Gtk::Stack, Gtk::SearchBar, Gtk::ListBox, and more.

The full, buildable sources for these examples can be found in the examples/book/buildapp directory of the gtkmm-documentation source distribution, or online in the gtkmm-documentation git repository. You can build each example separately by using meson and ninja with the meson.build file or by using make with the Makefile.example file. For more information, see the README included in the buildapp directory.