GNOME Bugzilla – Bug 761138
GtkSourceFile: add API to set/get string metadata
Last modified: 2016-06-12 11:02:47 UTC
Gvfs metadata is not supported on Windows. For that, gedit uses the gedit-metadata-manager. Since it is a useful feature for other text editors, it makes sense to have it in GtkSourceView. So the gedit-metadata-manager would be moved to GtkSourceView, as internal functions. An API would be exposed in GtkSourceFile to set/get string metadata. If gvfs metadata is supported, GtkSourceFile would use that, otherwise the metadata-manager is used. GtkSourceFile can also handle location changes without loosing metadata. The metadata would be kept in memory in a GFileInfo, and when the location changes the in-memory metadata is saved to the new location. GtkSourceView could even have standard metadata that is shared between all GtkSourceView applications, with the 'gtksourceview' namespace in the key. For example the cursor location, the GtkSourceLanguage used and the character encoding. But this can be done in a later iteration.
After looking at gedit-metadata-manager in more details, it is not really suitable for GtkSourceView, because it does sync I/O on the main thread, with potentially a big amount of data (e.g. after storing file metadata of every file opened with gedit during 10 years…). Also, the GSV API should report GErrors when trying to save the metadata. It is currently not done with the GeditDocument API. And it should be possible to save the metadata either sync or async. Saving synchronously is needed for example on application shutdown, when the main loop has already exited. So, it's more complicated than I initially thought. If such a feature is included in GtkSourceView, it should be well done.
(In reply to Sébastien Wilmet from comment #1) > After looking at gedit-metadata-manager in more details, it is not really > suitable for GtkSourceView, because it does sync I/O on the main thread, > with potentially a big amount of data (e.g. after storing file metadata of > every file opened with gedit during 10 years…). No, actually the gedit-metadata-manager keeps the metadata for only the last 50 opened files. But it isn't great either. See bug #761515, to use for example SQLite.
Implemented in Gtef: https://github.com/swilmet/gtef It'll maybe be moved one day to GtkSourceView, but it is not worth keeping this bug open.