-
-
Notifications
You must be signed in to change notification settings - Fork 113
Handle closing second or subsequent window #1620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I don't think moving unsaved files from window A to window B is expected behaviour at all. I don't like this behaviour. Window B should: A) Autosave all files from the window that are unsaved. B) Ask to save them (I think this is discouraged by elementary guidelines, but it might make sense in this specific context where the user closes the window with unsaved files?) |
|
Yeah I agree I don't think this is the expected behavior. If I'm closing a window with tabs, I would expect those tabs to close. If I wanted to keep the tabs, I'd move them to the other window. There seems to be a couple of issues in #721:
|
|
@danirabbit @kaixoo12 Thanks for the input - I'll rework this PR accordingly. Note that with the suggested behaviour, the documents will be saved but not restored. |
|
@danirabbit I think |
|
Note: The PR currently restores the doc in the last closed window, not the first opened window. Please confirm whether this is the correct behaviour. |
|
@jeremypw I just tested it. The behaviour is definitely better. |
|
@flodavid Thanks for the review! I am glad the PR improves things for you. Could you expand a little on the question of what to do when a second or subsequent window is closed? The idea of automatically moving docs to another window has been vetoed by the design team but I am not sure whether moving the address of the docs to another windows "closed docs" list has been considered. This may be possible, but it would not cause those documents to be restored after closing the last window and then restarting. At the moment the settings can only restore one list of docs and that is the docs that were open in the last window to be closed. Closing another window will overwrite that list with the docs open in that window. We would have to change the structure of the settings quite significantly to restore the docs that were open in all windows opened in the session, and that may not always be what the user wants. This is not an easy question to solve and is probably outside the scope of this PR. |
|
One solution may be to cause the close window signal to throw up a list of options when there are more than one window. Ideally it should be possible to save the session exactly - i.e. each window saves and restores separately. |
@jeremypw I do not mean that documents of all closed windows should be restored on restart, but it would be nice if they were added to the "Closed tabs" menu of some window still open. This way, it would be easy to restore any document if needed, as long as there is one open window left. That said, you may be right that it's outside the scope of this PR. |
flodavid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am no expert in the codebase or in even in Vala, but I took the liberty of reviewing the changes since it has been pending for quite some time.
I added some minor suggestions but it looks good to me.
|
|
||
| public async bool handle_quit_window (MainWindow window_to_close) { | ||
| unowned List<Gtk.Window> windows = get_windows (); | ||
| var n_windows = windows.length (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be replaced by bool is_last_window = windows.length () == 1; since the comparison is made two times
| unowned List<Gtk.Window> windows; | ||
| windows = get_windows (); | ||
| //NOTE This yields the last opened window at head of list (may change in future?) | ||
| while (windows.length () > 0) { | ||
| if (!yield handle_quit_window ((MainWindow) (windows.first ().data))) { | ||
| return; | ||
| } | ||
|
|
||
| windows = get_windows (); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be replaced by:
unowned List<Gtk.Window> windows = null;
do {
windows = get_windows ();
if (!yield handle_quit_window ((MainWindow) (windows.first ().data))) {
return;
}
windows = get_windows ();
} while (windows.length () > 0);
Fixes #721
Fixes #1593
When a second or subsequent window is closed its documents are just closed after saving if required.
Closing a second or subsequent window (with
<Alt>F4or otherwise) only closes the focused window.<Ctrl>Qcloses all windows. Only the docs in the last closed window will be restored.NOTE: Restarting or closing down the system still causes unsaved data to be lost as in 'master'.
Some names are changed to make clearer their function.