NOTE: This page is a recollection of what I've written previously. I do not guarantee it's accuracy.
This is how Odysseus finds all your installed feedreaders, or opens your non-HTTP URIs and non-HTML downloads.
MIME Apps
In implementing the MIME Apps Specification, GIO reads all the standardized file paths (some of which are desktop-specific) upon first query and updated the next query after those files change. It builds a hashset (or rather a hashmap where the values provide little additional information) of all Desktop Entries in each apps
directory to spead up presence tests, and it parses all the “MIME lists” files performing all necessary deduplications.
With all that work it becomes trivial to look up all apps for a given MIMEtype or, by prefixing it with x-scheme-handler/
, URI scheme. And almost as trivial (requiring more filtering and fallbacks) to find the appropriate default app to use for given URI scheme or MIMEtype.
Desktop Entries
GIO’s Desktop Entry Specification implementation is little more than a shallow wrapper around GLib’s “Key File” parser with all the standard keys being loaded into structure fields for faster access. GLib’s “Key File” parser in turn wraps it’s own line splitter (seperate from GIO’s, with chunked input), with logic to parse groups and their key-value pairs into an in-memory structure, even dropping keys for unsupported locales.