Skip to content
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

WindowManager: confirm_display_change() Fixes #1516

Merged
merged 3 commits into from Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Dialogs.vala
Expand Up @@ -61,6 +61,7 @@ namespace Gala {
Object (title: title, body: body, icon: icon);
}

[Signal (run = "first")]
public virtual signal void show () {
if (portal == null) {
return;
Expand Down
18 changes: 16 additions & 2 deletions src/WindowManager.vala
Expand Up @@ -2121,24 +2121,38 @@ namespace Gala {
}

public override void confirm_display_change () {
var timeout = Meta.MonitorManager.get_display_configuration_timeout ();
var summary = ngettext (
"Changes will automatically revert after %i second.",
"Changes will automatically revert after %i seconds.",
timeout
);
uint dialog_timeout_id = 0;

var dialog = new AccessDialog (
_("Keep new display settings?"),
_("Changes will automatically revert after 30 seconds."),
summary.printf (timeout),
"preferences-desktop-display"
) {
accept_label = _("Keep Settings"),
deny_label = _("Use Previous Settings")
};

dialog.show.connect (() => {
Timeout.add_seconds (30, () => {
dialog_timeout_id = Timeout.add_seconds (timeout, () => {
dialog_timeout_id = 0;
dialog.close ();

return Source.REMOVE;
});
});

dialog.response.connect ((res) => {
if (dialog_timeout_id != 0) {
Source.remove (dialog_timeout_id);
dialog_timeout_id = 0;
}

complete_display_change (res == 0);
});

Expand Down