Hello world,
few months ago already tried to ask about this here: https://discourse.gnome.org/t/gtk4-migrating-from-gtk3-menu-items-and-markup/7561
If it is possible I am sorry but I did not find a way to re-open / refresh the same topic.
Migrating my app from GTK3 to GTK4 I re-created a bunch of pop menus, menus that need to be able to use pango markup, so basically this is what I was doing with, and what I am doing now:
- GTK3
GtkWidget * markup_menu_item (gchar * label)
{
GtkWidget * item = gtk_menu_item_new ();
GtkWidget * lab = gtk_label_new (label);
gtk_label_set_use_markup (GTK_LABEL(lab), TRUE);
gtk_container_add (GTK_CONTAINER(item), lab);
return item;
}
- GTK4
GMenuItem * menu_item (const gchar * label,
const gchar * action,
const gchar * accel,
const gchar * custom,
gboolean use_markup)
{
GMenuItem * item = g_menu_item_new (label, action);
if (accel) g_menu_item_set_attribute (item, "accel", "s", accel, NULL);
if (custom) g_menu_item_set_attribute (item, "custom", "s", custom, NULL);
if (use_markup)
{
// What would be the attribute (if any ?)
// g_menu_item_set_attribute (item, ???, use_markup, NULL);
}
}
Here is some illustrations of why I need to be able to do this (chemical formula mostly), first what I have with GTK3:
Then what I have with GTK4:
So my question is, is there anyway to achieve the GTK3 result with GTK4 ?
If not yet, will there be a way ?
Maybe an action that can be performed on the entire menu ?
Thanks for your lights.
All the best.
S.