ui: Add InhibitShortcutsDialog
https://bugzilla.gnome.org/show_bug.cgi?id=783342
This commit is contained in:
@ -59,6 +59,7 @@
|
||||
<file>ui/grabHelper.js</file>
|
||||
<file>ui/ibusCandidatePopup.js</file>
|
||||
<file>ui/iconGrid.js</file>
|
||||
<file>ui/inhibitShortcutsDialog.js</file>
|
||||
<file>ui/keyboard.js</file>
|
||||
<file>ui/layout.js</file>
|
||||
<file>ui/lightbox.js</file>
|
||||
|
94
js/ui/inhibitShortcutsDialog.js
Normal file
94
js/ui/inhibitShortcutsDialog.js
Normal file
@ -0,0 +1,94 @@
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
|
||||
const Dialog = imports.ui.dialog;
|
||||
const ModalDialog = imports.ui.modalDialog;
|
||||
|
||||
const WAYLAND_KEYBINDINGS_SCHEMA = 'org.gnome.mutter.wayland.keybindings';
|
||||
|
||||
var DialogResponse = Meta.InhibitShortcutsDialogResponse;
|
||||
|
||||
var InhibitShortcutsDialog = new Lang.Class({
|
||||
Name: 'InhibitShortcutsDialog',
|
||||
Extends: GObject.Object,
|
||||
Implements: [Meta.InhibitShortcutsDialog],
|
||||
Properties: {
|
||||
'window': GObject.ParamSpec.override('window', Meta.InhibitShortcutsDialog)
|
||||
},
|
||||
|
||||
_init: function(window) {
|
||||
this.parent();
|
||||
this._window = window;
|
||||
|
||||
this._dialog = new ModalDialog.ModalDialog();
|
||||
this._buildLayout();
|
||||
},
|
||||
|
||||
get window() {
|
||||
return this._window;
|
||||
},
|
||||
|
||||
set window(window) {
|
||||
this._window = window;
|
||||
},
|
||||
|
||||
_getRestoreAccel: function() {
|
||||
let settings = new Gio.Settings({ schema_id: WAYLAND_KEYBINDINGS_SCHEMA });
|
||||
let accel = settings.get_strv('restore-shortcuts')[0] || '';
|
||||
return Gtk.accelerator_get_label.apply(null,
|
||||
Gtk.accelerator_parse(accel));
|
||||
},
|
||||
|
||||
_buildLayout: function() {
|
||||
let windowTracker = Shell.WindowTracker.get_default();
|
||||
let app = windowTracker.get_window_app(this._window);
|
||||
let name = app ? app.get_name() : this._window.title;
|
||||
|
||||
/* Translators: %s is an application name like "Settings" */
|
||||
let title = name ? _("%s wants to inhibit shortcuts").format(name)
|
||||
: _("Application wants to inhibit shortcuts");
|
||||
let icon = new Gio.ThemedIcon({ name: 'dialog-warning-symbolic' });
|
||||
|
||||
let contentParams = { icon, title };
|
||||
|
||||
/* Translators: %s is a keyboard shortcut like "Super+x" */
|
||||
let restoreAccel = this._getRestoreAccel();
|
||||
if (restoreAccel)
|
||||
contentParams.subtitle =
|
||||
_("You can restore shortcuts by pressing %s.").format(restoreAccel);
|
||||
|
||||
let content = new Dialog.MessageDialogContent(contentParams);
|
||||
this._dialog.contentLayout.add_actor(content);
|
||||
|
||||
this._dialog.addButton({ label: _("Deny"),
|
||||
action: () => {
|
||||
this._emitResponse(DialogResponse.DENY);
|
||||
},
|
||||
key: Clutter.KEY_Escape });
|
||||
|
||||
this._dialog.addButton({ label: _("Allow"),
|
||||
action: () => {
|
||||
this._emitResponse(DialogResponse.ALLOW);
|
||||
},
|
||||
default: true });
|
||||
},
|
||||
|
||||
_emitResponse: function(response) {
|
||||
this.emit('response', response);
|
||||
this._dialog.close();
|
||||
},
|
||||
|
||||
vfunc_show: function() {
|
||||
this._dialog.open();
|
||||
},
|
||||
|
||||
vfunc_hide: function() {
|
||||
this._dialog.close();
|
||||
}
|
||||
});
|
@ -14,6 +14,7 @@ const Signals = imports.signals;
|
||||
const AltTab = imports.ui.altTab;
|
||||
const Dialog = imports.ui.dialog;
|
||||
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
|
||||
const InhibitShortcutsDialog = imports.ui.inhibitShortcutsDialog;
|
||||
const Main = imports.ui.main;
|
||||
const ModalDialog = imports.ui.modalDialog;
|
||||
const Tweener = imports.ui.tweener;
|
||||
@ -711,6 +712,7 @@ var WindowManager = new Lang.Class({
|
||||
this._shellwm.connect('filter-keybinding', Lang.bind(this, this._filterKeybinding));
|
||||
this._shellwm.connect('confirm-display-change', Lang.bind(this, this._confirmDisplayChange));
|
||||
this._shellwm.connect('create-close-dialog', Lang.bind(this, this._createCloseDialog));
|
||||
this._shellwm.connect('create-inhibit-shortcuts-dialog', Lang.bind(this, this._createInhibitShortcutsDialog));
|
||||
global.screen.connect('restacked', Lang.bind(this, this._syncStacking));
|
||||
|
||||
this._workspaceSwitcherPopup = null;
|
||||
@ -1976,6 +1978,10 @@ var WindowManager = new Lang.Class({
|
||||
return new CloseDialog.CloseDialog(window);
|
||||
},
|
||||
|
||||
_createInhibitShortcutsDialog: function (shellwm, window) {
|
||||
return new InhibitShortcutsDialog.InhibitShortcutsDialog(window);
|
||||
},
|
||||
|
||||
_showResizePopup: function(display, show, rect, displayW, displayH) {
|
||||
if (show) {
|
||||
if (!this._resizePopup)
|
||||
|
Reference in New Issue
Block a user