(closed) GTK4: adding a custom widget to PopoverMenu/GMenu item

Hi everyone,

I cannot figure out how to add some widget to popover menu.

It works fine with simple text like:

g_menu_append_item(menu, g_menu_item_new("OptionN",  "app.opt_n"));
GtkWidget *popover = gtk_popover_menu_new_from_model(G_MENU_MODEL(menu));

When I’m trying to add some custom widget by setting it via “custom” attribute:

GMenuItem *optn = g_menu_item_new("OptionN", "app.opt_n");
g_menu_item_set_attribute(optn, "custom", "s", "attrn");
g_menu_append_item(menu, optn);
GtkWidget *popover = gtk_popover_menu_new_from_model(G_MENU_MODEL(menu));
gtk_popover_menu_add_child(GTK_POPOVER_MENU(popover), some_gtk_widget, "attrn");

this OptionN item box disappears and GTK inspector shows it like GtkGizmo instanse in that place.
I cannot sort out what missed at adding widget as popover menu child.
Is there any docs how to properly add widgets to popover menus?

Q is closed, sorry for disturbing.
It’s achived by adding widgets in ListBox and setting that list as popover’s child, but still not sure if it’s the right way.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.