Re: [gedit-list] A solution for Bug #485471



Hi Daniel,
                Thanks for liking my idea and providing me insight into the gedit source code. I really appreciate it :-) . However, I have decided not to work on it. I talked with Paolo on IRC. He said that they don't want to implement this feature as saving things in the back is not good from point of view of privacy, and I think I also agree with him.

But I think your tips would be useful for me for fixing other bugs in gedit.
Thanks a lot :)

Abhinav

On Mon, Mar 14, 2011 at 2:19 AM, Daniel Trebbien <dtrebbien gmail com> wrote:
Hi Abhinav,

The document saver stuff is used to write document buffers to files, either when the user manually saves a document or the autosave kicks in.  Think of an instance of GeditDocumentSaver as representing the act of saving a document.

To fix bug 485471, you actually want to focus on gedit-tab.c.  In gedit_tab_set_auto_save_enabled(), for example, there is this if statement:
 	if (enable &&
 	    (tab->priv->auto_save_timeout <=0) &&
 	    !gedit_document_is_untitled (doc) &&
 	    !gedit_document_get_readonly (doc))
The part that checks whether the tab's GeditDocument is "untitled" is part of the reason why autosave does not work on new buffers.

You will need to modify gedit_tab_set_auto_save_enabled(), gedit_tab_set_auto_save_interval(), and install_auto_save_timeout_if_needed() at a minimum.  Also, you will need to decide how you are going to handle the case when Gedit crashes while the user is editing two or more new/"untitled" buffers.

I like your idea of an "unsaved files" list, but note that Gedit has migrated to gsettings, so perhaps the list of unsaved files can stored with gsettings somehow.  I am not sure, though.  I am not a Gedit developer.

Make sure that you are making changes off of Gedit master.  Among other things ~/.gnome2/gedit is now located at ~/.local/share/gedit, I believe.


On Sun, Mar 13, 2011 at 3:23 AM, Abhinav Upadhyay <er abhinav upadhyay gmail com> wrote:
HI, I wanted to learn about the internals of Gedit and so decided to start with fixing small bugs. I cam across this bug on bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=485471.

This bug still seems to be present in my version of Gedit , but I was wondering if it has been worked out in the latest development releases ?

I came up with the following solution and wanted your opinion and help on this:

1. On creating a new document/tab save it in ~/.gnome2/gedit/ directory with a name like ~yyyy-mm-dd-unsaved-document . I believe, if the file is once saved, then gedit will take care of autosaving it at set intervals ?

2. After this, when the user decides to save the document, we can check if the filename (uri ?) has this particular string format (~yyyy-mm-dd-unsaved-document) then we will open the file save as dialog box. (Also check the same when user closes the tab or the window)

3. Also, keep logging the list of new untitled files in a file (~/.gnome2/gedit/unsaved-files). When the user quits Gedit, we can safely delete this file. In case of a crash, Gedit won't be able to delete this file.

4. On each startup Gedit will try to read this file. If gedit was closed normally, then it won't find the file. But if it is able to read from the file, then it means that a crash had occurred, and it will ask the user if he would like to restore the unsaved files ?

I thought this would be an easy fix, but to start with, the gedit codebase is a bit overwhelming.
 I was thinking to start with adding a call to gedit_document_saver_save in gedit.c where it creates the new tab. I would appreciate if you provide some direction as in where to start ?

Thanks.
Abhinav

_______________________________________________
gedit-list mailing list
gedit-list gnome org
http://mail.gnome.org/mailman/listinfo/gedit-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]