How to show icon on context menu? [duplicate]

Thanks to @vanadium, I was able to fix this problem by following the instructions as follows.

From the accepted answer in this link:

Both gtk-menu-image and gtk-button-images were deprecated and ignored, after that they made them deprecated but not ignored: https://git.gnome.org/browse/gtk+/commit/?id=627a03683f5f41efbfc86cc0f10e1b7c11e9bb25 https://git.gnome.org/browse/gtk+/commit/?id=c46aca463a9d66cf402ec8c3f9f2e2efc98c42ca

the problem is the gsettings keys (org.gnome.desktop.interface buttons-have-icons and menus-have-icons) are gone so I don't see a way to set them...

However it seems you can set the relevant GtkSettings via the gnome-settings-daemon xsettings plguin: open dconf-editor -> org.gnome.settings-daemon.plugins.xsettings and change the overrides key from:

{}

to:

{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}

usually the change is instantaneous (e.g. in gimp), but some apps need to be restarted (e.g. firefox).

Or just use gsettings:

gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"

but note that this method overwrites the current value of that key; one obvious caveat is if you've previously enabled pasting with the middle click from gnome-tweak-tool -> "keyboard and mouse", you'll need to re-set it there again (unlike the above gsettings command, gnome-tweak-tool "adds" new values to the overrides key and doesn't blindly overwrite it).

Edit: testing recently, it seems now that toggling either of these settings in gnome-tweak-tool remove the custom values added above:

  • Top Bar -> "show application menu"
  • Keyboard and mouse -> middle-click paste so if you toggle any of those settings you'll have to re-add the 'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1> bits.