Make menu buttons activatable
MenuButtons don't implement the Actionable interface in GTK 4.
Related issue: #3525 (closed)
In the following example neither the label nor the action row would activate the menu button. Both would be activated if MenuButton is replaced by Button.
# test.py
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Adw
def on_activate(app):
Adw.init()
window = Gtk.ApplicationWindow(application=app)
builder = Gtk.Builder.new_from_file("test.ui")
box = builder.get_object("container")
window.set_child(box)
window.show()
app = Gtk.Application()
app.connect("activate", on_activate)
app.run()
<!-- test.ui -->
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="menu">
<item>
<attribute name="label">About</attribute>
<attribute name="action">app.about</attribute>
</item>
</menu>
<object class="GtkBox" id="container">
<child>
<object class="GtkLabel">
<property name="label">_Test</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">button</property>
</object>
</child>
<child>
<object class="GtkListBox">
<child>
<object class="GtkListBoxRow">
<child>
<object class="GtkMenuButton" id="button">
<property name="menu-model">menu</property>
<property name="margin_end">12</property>
<property name="margin_start">12</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="activatable-widget">button2</property>
<child>
<object class="GtkMenuButton" id="button2">
<property name="menu-model">menu</property>
<property name="margin_end">12</property>
<property name="margin_start">12</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
EDIT: Both mnemonic_widget
on a Label and activatable_widget
on an AdwActionRow depend on this.
EDIT: Added reproducer
Edited by Maximiliano