mirror of
https://github.com/elementary/gala.git
synced 2024-11-23 20:07:21 +03:00
Dialogs: Implement InhibitShortcutsDialog (#1948)
This commit is contained in:
parent
32f1230d01
commit
81f8472823
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user