Re: [gedit-list] Event For Shutdown Suggestion?



Looking at this even further I can see that there is no way to tell if gedit is closing and have a way to get at the tabs. This seems like a reasonable thing that we should be able to find out. If a new event seems too much maybe we could just put the GEDIT_IS_QUITTING on the header file and make it part of the API? That or have a new GeditWindowState that says gedit is closing (GEDIT_WINDOW_STATE_CLOSING).

For now I do not see any other way around this so I am going to check the GEDIT_IS_QUITTING (but hardcoded in my app) on the window object. Keeping track of the tabs is not good enough (and error prone at best).

Whatever the solution I would like to do the work once I know what direction to take...


-Jeff Johnston



On Sun, Sep 5, 2010 at 9:29 PM, Jeff Johnston <jeff.johnston.mn@gmail.com> wrote:

I am wondering if anyone else would find it useful to have a gedit close event?

What I would like to do is save the tabs that are opened when gedit shuts down. The problem is that gedit closes all the tabs and destroys the window before I have a chance to do anything. What would be really useful is to have an event that is invoked when gedit is shut down, but fires before any cleanup is done.

I saw that gedit sets a variable on the window object that says the app is quiting. I started to write a 'tab-removed' event that took advantage of that, but it felt very hacky. I could just persist the state of the tabs as they are opened and closed, but that leads to other issues. Ideally I could just take a snapshot of the tabs just before gedit closes down.

On a related note this is the flip side of the question I had about loading tabs on startup. The solution there was to use a "realize" event on the window. However, for both startup and shutdown I could see it being very useful to have an event that gets invoked when gedit is all the way up and just before any cleanup is done. That would give custom plugins a last chance to do something with full access to gedit's api while it is fully intact.

I would be more than willing to do the work! I have been digging into the gedit source code and I think it is very easy to follow.


This is the code I found (2.30.3) that clearly shows that the tabs are all closed and then the window is destroyed.

gedit-commands-file.c (1766)

g_object_set_data (G_OBJECT (window),
               GEDIT_IS_QUITTING,
               GBOOLEAN_TO_POINTER (is_quitting));

...

if (unsaved_docs == NULL)
    {
        /* There is no document to save -> close all tabs */
        gedit_window_close_all_tabs (window);

        if (is_quitting)
            gtk_widget_destroy (GTK_WIDGET (window));

        return;
    }




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