Libadwaita is being developed as a successor to Libhandy 1.4. As such, it offers to GTK 4 many features Libhandy was offering to GTK 3.
Migrating from Libhandy 1.4 to Libadwaita implies migrating from GTK 3 to 4. This guide only focuses on on Libhandy and Libadwaita, and is designed to be used together with the GTK 3 to 4 migration guide.
If you notice that some differences between Libhandy and Libadwaita are missing in this guide, please report them.
The steps outlined in the following sections assume that your software is working with Libhandy 1.4, which is the latest stable release of Libhandy 1.x. It includes all the necessary APIs and tools to help you port your software to Libadwaita. If you are using an older version of Libhandy, you should first get your software to build and work with Libhandy 1.4.
Over the years, a number of functions, and in some cases, entire widgets have been deprecated. These deprecations are clearly spelled out in the API reference, with hints about the recommended replacements. The API reference for Libhandy 1.4 also includes an index of all deprecated symbols.
Following GTK4’s emphasis on composition and delegation over subclassing,
AdwHeaderBar are no longer derivable. As a
replacement, you can subclass
GtkBox and include a leaflet or a
header bar as a child widget.
HdyKeypad has been removed from Libadwaita. Applications that had used it can
copy it in tree instead.
The following named colors have been removed from the stylesheet in Libadwaita:
Applications should not use them.
HdyFlap provides the “content”, “flap” and “separator” properties that can be
used for managing children instead of
GtkContainer API. In Libadwaita
AdwFlap:separator are the only way to manage
HdyValueObject has been removed. While it’s not practical to replace the cases
where it’s storing strings in GTK3, as the preferred replacement only exists in
4, it can also be used with any other
GValue. That use has no
replacement and you can instead create your own objects to store those values.
HdyStyleManager instead of
If your application is setting
TRUE to request dark appearance, consider setting
HDY_COLOR_SCHEME_PREFER_DARK and making sure the application can work with
light appearance as well. If that’s not possible, set it to
If your application is using light appearance, consider setting the color scheme
HDY_COLOR_SCHEME_PREFER_LIGHT and support dark appearance.
In libadwaita color schemes will be the only way to request dark appearance.
This section outlines porting tasks that you need to tackle when you get to the point that you actually build your application against Libadwaita 1. Making it possible to prepare for these in GTK 3 would have been either impossible or impractical.
Same as GTK itself, all widgets that have children have a new API to replace
The following widgets that formerly subclassed
GtkBin have a “child” property now:
For other widgets use the following replacements:
Adding children in a UI file still works.
HdySearchBar has been removed, use
HdyWindowHandle has been removed, use
AdwExpanderRow API Changes
The “use-underline” property and its accessors have been removed. Use
AdwPreferencesRow:use-underline and its accessors instead.
The title and subtitle have markup enabled, make sure to escape it with
g_markup_escape_text() if this is unwanted.
AdwClamp API Changes
HdyClamp previously had
.large style classes
depending on the current size of its child. These style classes are now
added to the child instead of the clamp itself.
AdwComboRow API Changes
expr = gtk_property_expression_new (ADW_TYPE_ENUM_LIST_ITEM, NULL, "nick"); model = G_LIST_MODEL (adw_enum_list_model_new (GTK_TYPE_ORIENTATION)); adw_combo_row_set_expression (row, expr); adw_combo_row_set_model (row, model);
AdwPreferencesGroup API Changes
HdyPreferencesGroup:use-markup has been removed, the labels always use markup now.
AdwHeaderBar API Changes
GtkHeaderBar:show-title-buttons property has been split into
AdwHeaderBar:show-end-title-buttons to simplify creating multi-pane
layouts. The corresponding getter and the setter have been split as well.
AdwWindowTitle widget may be useful for replacing the title and subtitle.
HdyHeaderGroup has been removed. Its behavior can be replicated by changing
AdwHeaderBar:show-end-title-buttons properties depending on the
layout, for example binding them to the
<object class="AdwLeaflet" id="leaflet"> <child> <object class="GtkBox"> <property name="orientation">vertical</property> <object class="AdwHeaderBar"> <binding name="show-end-title-buttons"> <lookup name="folded">leaflet</lookup> </binding> </object> ... </object> </child> ... <child> <object class="GtkBox"> <property name="orientation">vertical</property> <object class="AdwHeaderBar"> <binding name="show-start-title-buttons"> <lookup name="folded">leaflet</lookup> </binding> </object> ... </object> </child> </object>
AdwSqueezer API Changes
The child properties of
HdySqueezer have been converted into
page objects, similarly to
GtkStack. For example,
adw_squeezer_page_set_enabled() should be used to replace
vhomogeneous-unfolded properties have been replaced by a single
AdwLeaflet:homogeneous property, set to
TRUE by default,
applied when the leaflet is folded for the opposite orientation.
When unfolded, children are never homogeneous. Use
to make them homogeneous if needed.
interpolate-size property has been removed with no replacement, it’s
always enabled when
AdwLeaflet:homogeneous is set to
AdwViewSwitcher API Changes
The “narrow-ellipsize” property has been removed. Narrow view switchers always ellipsize their labels, wide switchers never do.
AdwViewSwitcherBar API Changes
AdwViewSwitcherTitle API Changes
The “policy” property has been removed, the behavior is similar to the removed
auto policy. If you had used
narrow policies, use an
AdwSqueezer with an
AdwViewSwitcher and an
AdwWindowTitle inside, with the switcher having the desired policy.
AdwAvatar API Changes
HdyAvatar:loadable-icon property has been removed along with its getter
and setter. It can be replaced by
functions have been removed, use the newly added
GIcon, so it should just work for that case.
adw_avatar_draw_to_texture() does not have the
size parameter. Instead,
it uses the avatar’s current size, with no replacement.
AdwStyleManager API Changes
When used with the default style manager,
ADW_COLOR_SCHEME_DEFAULT is now
ADW_COLOR_SCHEME_PREFER_LIGHT instead of
HDY_COLOR_SCHEME_FORCE_LIGHT, following the system dark style preference by
default. Make sure your application works with it, or otherwise set the
ADW_COLOR_SCHEME_FORCE_LIGHT color scheme manually.
Most widgets don’t have a backdrop state anymore, and the following public colors have been removed:
.list-button style class has been renamed to the more accurate name
The public colors
been renamed to
If you were using
theme_selected_bg_color as a text color, use
accent_color instead to make sure the text is readable. You can also use the
.accent style class to apply the correct color.
.sidebar style class doesn’t provide a border by default. Instead, use a
GtkSeparator with the style class
The following rules are used when deciding when to make buttons flat or not:
The following buttons get flat appearance:
- Icon-only buttons;
- Buttons with an icon and a label (using
- Menu buttons containing an arrow;
- Any other button with the
The following buttons keep default appearance:
- Text-only buttons;
- Buttons with other content;
- Buttons within widgets containing the
- Buttons with the
- Buttons with the
It’s important to avoid ambiguous layouts, for example text-only buttons with no icon, since such a button would be indistinguishable from the window title without hovering it.
In rare cases, the existing layout may need a redesign to work with the new style.
The same rules are also used for the
.toolbar style class now, instead of
making every button appear flat.
If you had text-only buttons, consider using
example, the following button:
<object class="GtkButton"> <property name="label" translatable="yes">_Open</property> <property name="use-underline">True</property> </object>
can be changed into:
<object class="GtkButton"> <property name="child"> <object class="AdwButtonContent"> <property name="icon-name">document-open-symbolic</property> <property name="label" translatable="yes">_Open</property> <property name="use-underline">True</property> </object> </property> </object>
One exception are the two primary buttons in a dialog, for example, “Cancel” and “Open”. Those buttons should retain their default appearance.
If you had split buttons implemented via a
GtkBox with the
class and two buttons packed inside, use
AdwSplitButton as follows:
<object class="AdwSplitButton"> <property name="menu-model">some_menu</property> <property name="icon-name">view-list-symbolic</property> </object>
For other linked together buttons, simply stop linking them.
If multiple linked groups were used to separate different groups of actions, insert extra spacing as follows:
<object class="GtkSeparator"> <style> <class name="spacer"/> </style> </object>
.raised style classes can always be used to override the
GtkButton:has-frame property will not be set to
FALSE when a button gets the flat appearance automatically. It also cannot be
TRUE to make a button raised, the style class should be used directly instead.