How to remove KDE and XFCE applications from GNOME menu?

The code to show something only in XFCE follows the same idea:

ShowOnlyIn=XFCE;

Here are all the "ShowOnlyIn" possibilities:

http://standards.freedesktop.org/menu-spec/latest/apb.html

Unfortunately, as far as I know, the way XFCE stores it's .desktop files is the same as the way GNOME stores them, whereas KDE stores them in a separate folder (within /usr/share/applications). This is why the separation of KDE/GNOME, as described in the post you link to, is much easier to do en-mass.

All the files are stored in /usr/share/applications. The format of them is very simple, and you can copy any one of them to /home/you/.local/share/applications and it will override that menu entry for that user so you can more easily edit them without needing root privileges.

There is no simple way to separate XFCE apps from GNOME, especially since it's often a matter of opinion what you want to see. This also goes for KDE, since as long as you have the KDE libraries Dolphin, Konquorer, etc. will run in GNOME.

I suppose if you're intent on using the cmd line you could come up with some grep/sed junk to selectively find and replace text inside certain .desktop files, but I think the easiest way would be to copy the files you want to edit to ~/.local/share/applications so they don't get overwritten by updates and edit them by hand. Unless you've got a gazillion things installed it shouldn't be too difficult to cherry pick what you want.

As a side note, editing .desktop files is annoyingly difficult when using Nautilus. You either have to drag and drop them into a text editor, open them through the command line or write a Nautilus script that directs the file to a text editor. Other file managers do not suffer this problem, so I guess it's a bug. Also, a .desktop file has a different name when it's executable, which can also be confusing, since it's not the actual name of the file.

The menu works under the freedektop.org specification, which you can learn more about here:

http://standards.freedesktop.org/menu-spec/latest/index.html

EDIT: I forgot about this when I originally answered this question and it's a pretty significant caveat. This only works when using the correct panels/menus. For example, if you're using xfwm with the GNOME panel you will see the all the "ShowOnlyIn=GNOME" items and vice versa. Just thought I'd throw that in there for anyone this is not working for :)