[gedit-list] Event For Shutdown Suggestion?




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]