After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 731615 - Use the GtkSourceView API for the file loading and saving
Use the GtkSourceView API for the file loading and saving
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: file loading and saving
git master
Other All
: Normal enhancement
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2014-06-13 12:34 UTC by Sébastien Wilmet
Modified: 2014-07-09 12:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sébastien Wilmet 2014-06-13 12:34:02 UTC
See bug #721016 for the GtkSourceView part.
The branch in gedit:
https://git.gnome.org/browse/gedit/log/?h=wip/loader-saver

GeditEncoding is simply defined as:
> typedef GtkSourceEncoding GeditEncoding;
And the gedit_encoding functions use gtk_source_encoding.
And gedit is normally fully ported to GtkSourceEncoding. Some API for gedit plugins is modified, but with the typedef it still works fine.

I first wanted to not break the gedit API, but for GeditDocument it will be more complicated. I think there will be fewer bugs if the old API is removed. It makes things clearer. If I document clearly on the wiki what changed, it should be easy to update the few plugins that use the removed API.

For the file loading and saving, the implementation in gedit core is in GeditTab and GeditDocument. And some plugins use the GeditDocument API. The problem is that GeditDocument do some extra work which is not done by gsv. For example the time_of_last_save_or_load to display the time in a dialog. If a plugin uses the gsv API, the time will be wrong. Also, the gsv API is quite low-level. GeditTab on the other hand displays the error in an info bar, shows the progress, etc. Currently the GeditDocument API is the high-level API, and the info bar is shown thanks to the emitted signals. So the idea is to move the high-level API to GeditTab, so at least the "loading" and "saving" signals can be removed (which report the progress). GeditTab would call private functions in GeditDocument which do some extra work. Some of the GeditDocument API would still be there of course (but at the end some of the features will be moved to GtkSourceFile, like the content type, mime type, shortname, etc). The gsv API can be used by a plugin to save the buffer to a secondary file. For all other purposes, the high-level gedit API should be enough.
Comment 1 Sébastien Wilmet 2014-07-01 13:22:23 UTC
I think the port to GtkSourceFile is finally done!

The branches:
https://git.gnome.org/browse/gtksourceview/log/?h=wip/loader-saver
https://git.gnome.org/browse/gedit/log/?h=wip/loader-saver
https://git.gnome.org/browse/gedit-plugins/log/?h=wip/loader-saver

Here is a summary of the changes in gedit:
- GeditEncoding has been removed (progressively)
- Add gedit_document_get_file(), to get the associated GtkSourceFile (always the same).
- Remove the following public GeditDocument functions:
    gedit_document_load
    gedit_document_load_stream
    gedit_document_load_cancel
    gedit_document_save
    gedit_document_save_as
  Plugins should not need those functions. But I see one use case: a refactoring feature for Java, which renames a class and should rename the file too (with gedit_document_save_as()). But keeping those functions in GeditDocument would have been more complicated to port the code.

- Remove the GeditDocumentCompressionType and GeditDocumentNewlineType enums.
- Remove the "loading" and "saving" signals, used for progress info.
- Remove all paramaters of the "load" and "save" signals.
- Remove error param of the "loaded" and "saved" signals.
- Remove the following properties in GeditDocument: "compression-type", "newline-type", "encoding" and "location".
- Deprecate the following functions:
    gedit_document_get_location()
    gedit_document_set_location()
    gedit_document_get_encoding()
    gedit_document_get_newline_type()
    gedit_document_get_compression_type()

And gedit and gedit-plugins have been fully ported for all these changes, normally.
Comment 2 Sébastien Wilmet 2014-07-01 13:58:23 UTC
Forgot to say, the FileLoader and FileSaver are now created in GeditTab, not GeditDocument. GeditTab is a more appropriate place, because it is the place where error and progress info is displayed, actions in the info bar are handled by re-configuring the loader or saver and relaunching the operation.

Some of the code is better than before, and it fixes some bugs (like a save instead of a "save as" after an error). But some post-processing done initially in GeditDocument is now done partially in GeditTab, some one function (load_cb) is a bit bigger. And there are still some post-processing in GeditDocument, in the loaded and saved default signal handlers (the GeditDocument signals are emitted from GeditTab).
Comment 3 Sébastien Wilmet 2014-07-09 12:07:05 UTC
Finally done!