Amtk Introduction

Amtk Introduction — Introduction to the Actions, Menus and Toolbars Kit for GTK+ applications.

Amtk is the acronym for “Actions, Menus and Toolbars Kit”. Amtk has been initially created as a basic GtkUIManager replacement based on GAction. GtkUIManager has been deprecated in GTK+ 3 (and removed in GTK+ 4), without a good replacement for applications that want to keep a traditional UI (with a GtkMenuBar, a GtkToolbar and a GtkStatusbar). Amtk is now suitable for both a traditional UI and for a new UI with a GtkHeaderBar and a “hamburger menu”.

With Amtk, menus, toolbars or other objects like GtkShortcutsWindow are created programmatically (not with a *.ui file), but with convenient APIs. The support for an XML format will maybe be added in the future, contributions welcome.

General advantages

  • Primarily, encoding the information about an action only once, to create various objects such as a menu item, a toolbar item, a GtkShortcutsShortcut, etc. The information needed about an action: a label (i.e. a short description), possibly an icon, a tooltip (i.e. a longer description) and keyboard shortcuts. This is implemented by AmtkActionInfo, with AmtkFactory functions to create various objects.

    This also has the nice benefit that all the information about an action is centralized in only one place, to keep related information close together. This permits to more easily catch inconsistencies.

  • Amtk has been designed to be able to share AmtkActionInfo's in a library (with translations); this is a bit similar to GtkStockItem, to reduce the amount of work that an application (and translators) need to do. As a result the library can provide a higher-level API.

Advantages for a traditional UI

Sanity checks

Amtk has several functions to do various sanity checks. They normally don't impact too much the performances, so it is recommended to always run them, although they could be disabled on production. The functions:

GTK+ dependency

Amtk 5 depends on GTK+ 3.

pkg-config name

For Amtk 5, the pkg-config name is: amtk-5

To compile a program that uses Amtk 5, you can for example use the following command:

$ gcc hello.c `pkg-config --cflags --libs amtk-5` -o hello