Skip to content

Improve "--quit" option

This MR completes !30 (merged), as discussed in its header. It makes the --quit option behave as follows:

  • get the active window if there is one, else exit;
  • if it is a MousepadWindow and if we haven't already tried, try to save all documents;
  • else, if we haven't already tried, try to close the window gracefully;
  • else, as a last resort, destroy the window;
  • go to the first point.

When all windows are destroyed, the application switches automatically to shutdown().

To achieve this, I had in particular to add each "child window of a main window" (in practice a dialog window created from a MousepadWindow at some point in its life cycle) to the application windows list. This led me to move some code from mousepad/mousepad-window.c into mousepad/mousepad-dialogs.c, which is probably not a bad thing.

For the loop above, I used a combination of g_timeout_add() and g_signal_connect() to the GtkApplication "window-removed" signal, by delaying save/close/destroy actions so that everything runs smoothly.

Merge request reports

Loading