Architecture
This page covers some important parts of libtuner and Tuner that are useful to consider when creating plugins.
Object tree
Tuner uses custom object-tree system that is not compatible with Gtk.Widget system. That blocks usage template feature of Gtk.Builder.
Tuner.Widget and Tuner.Binding
All interface elements are created using Tuner.Widget. Some widgets do not work without assigning the binding property to them. Tuner.Binding is a simple tool that binds a certain widget property (for example active in the internal Tuner.Switch widget) to the required backend.
The following example creates a Tuner.Switch with a binding to a Tuner.Setting, which implements the GSettings backend. When the application starts, an Adw.SwitchRow will be created and the active property will be bound to the allow-volume-above-100-percent key. This will allow changing the active property in Adw.SwitchRow to change the GSettings value, also when the GSettings value is changed independently, the switch will be synchronized.
Tuner.Switch {
title: _("Over Amplification");
binding: Tuner.Setting {
schema-id: "org.gnome.desktop.sound";
schema-key: "allow-volume-above-100-percent";
}
}Merging and priority system
Merging system in Tuner allows to extends existing plugins interface by other plugins.
There are there different priorities in Tuner: plugin priority, page priorirty, group priority.
The
plugin prioritydetermines the order in which they are loaded. If two plugins try to addTuner.Pagewith the sametag, the plugin with the higher priority dictates all page information (icon,title, etc.). Their content will be merged. Also, if the plugin with the higher priority does not set an icon, the icon from the plugin with the lower priority can be used if it has one.Page Prioritydetermines the order of pages in the sidebar. The lower the priority, the higher the page will be listed. That does not apply to internal pages.Tuner.Grouphas its own priority, which determines the order in the group list. A group with a lower priority will be displayed higher in the page interface. Groups also have atagproperty, if two groups have the sametagthey will be merged, widgets from the group with a higher plugin priority will be higher in the interface of the resulting group.
For example, this system allows Tweaks and Panel plugins to exist separately and independently.
Only Panel plugin loaded
The panel plugin sets its own icon for the row.

Only Tweaks plugin loaded
The tweaks plugin sets its own icon for the row.

Tweaks and Panel are loaded simultaneously
The icon for the row is set using the Tweaks plugin since it has higher priority.
Their content was merged and despite the fact that the panel plugin had a lower priority, the group from the panel plugin turned out to be higher because the priority of this group was lower than the priority of the groups from the tweaks plugin.
