Dialogs: Implement InhibitShortcutsDialog (#1948)

This commit is contained in:
Leonhard 2024-06-17 19:07:12 +02:00 committed by GitHub
parent 32f1230d01
commit 81f8472823
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 60 additions and 0 deletions

View File

@ -196,4 +196,60 @@ namespace Gala {
}
}
}
public class InhibitShortcutsDialog : AccessDialog, Meta.InhibitShortcutsDialog {
public Meta.Window window {
owned get { return parent; }
construct { parent = value; }
}
public App app { get; construct; }
public InhibitShortcutsDialog (Gala.App app, Meta.Window window) {
Object (app: app, window: window);
}
construct {
icon = "preferences-desktop-keyboard";
var window_title = app.name;
if (window_title != null) {
title = _("“%s” wants to inhibit system shortcuts").printf (window_title);
} else {
title = _("An application wants to inhibit system shortcuts");
}
body = _("All system shortcuts will be redirected to the application.");
accept_label = _("Allow");
deny_label = _("Deny");
}
public override void show () {
if (path != null) {
return;
}
// Naive check to always allow inhibiting by our settings app. This is needed for setting custom shortcuts
if (app.id == "io.elementary.settings.desktop") {
on_response (0);
return;
}
base.show ();
}
public void hide () {
if (path != null) {
close ();
}
}
protected override void on_response (uint response_id) {
if (response_id == 0) {
base.response (Meta.InhibitShortcutsDialogResponse.ALLOW);
} else {
base.response (Meta.InhibitShortcutsDialogResponse.DENY);
}
}
}
}

View File

@ -2336,6 +2336,10 @@ namespace Gala {
return new CloseDialog (window_tracker.get_app_for_window (window), window);
}
public override Meta.InhibitShortcutsDialog create_inhibit_shortcuts_dialog (Meta.Window window) {
return new InhibitShortcutsDialog (window_tracker.get_app_for_window (window), window);
}
public override unowned Meta.PluginInfo? plugin_info () {
return info;
}