appFavorites: Display its own notification for every pin/unpin
Show a notification for each user action instead of updating the notification currently displayed when the user pins or unpins. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3387>
This commit is contained in:
parent
a21558d67f
commit
ab4f80b8ae
@ -1,11 +1,10 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
|
import * as MessageTray from './messageTray.js';
|
||||||
import Shell from 'gi://Shell';
|
import Shell from 'gi://Shell';
|
||||||
import * as ParentalControlsManager from '../misc/parentalControlsManager.js';
|
import * as ParentalControlsManager from '../misc/parentalControlsManager.js';
|
||||||
import * as Signals from '../misc/signals.js';
|
import * as Signals from '../misc/signals.js';
|
||||||
|
|
||||||
import * as Main from './main.js';
|
|
||||||
|
|
||||||
// In alphabetical order
|
// In alphabetical order
|
||||||
const RENAMED_DESKTOP_IDS = {
|
const RENAMED_DESKTOP_IDS = {
|
||||||
'baobab.desktop': 'org.gnome.baobab.desktop',
|
'baobab.desktop': 'org.gnome.baobab.desktop',
|
||||||
@ -161,13 +160,11 @@ class AppFavorites extends Signals.EventEmitter {
|
|||||||
if (!this._addFavorite(appId, pos))
|
if (!this._addFavorite(appId, pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let app = Shell.AppSystem.get_default().lookup_app(appId);
|
const app = Shell.AppSystem.get_default().lookup_app(appId);
|
||||||
|
|
||||||
let msg = _('%s has been pinned to the dash.').format(app.get_name());
|
this._showNotification(_('%s has been pinned to the dash.').format(app.get_name()),
|
||||||
Main.overview.setMessage(msg, {
|
null,
|
||||||
forFeedback: true,
|
() => this._removeFavorite(appId));
|
||||||
undoCallback: () => this._removeFavorite(appId),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addFavorite(appId) {
|
addFavorite(appId) {
|
||||||
@ -196,11 +193,22 @@ class AppFavorites extends Signals.EventEmitter {
|
|||||||
if (!this._removeFavorite(appId))
|
if (!this._removeFavorite(appId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let msg = _('%s has been unpinned from the dash.').format(app.get_name());
|
this._showNotification(_('%s has been unpinned from the dash.').format(app.get_name()),
|
||||||
Main.overview.setMessage(msg, {
|
null,
|
||||||
|
() => this._addFavorite(appId, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
_showNotification(title, body, undoCallback) {
|
||||||
|
const source = MessageTray.getSystemSource();
|
||||||
|
const notification = new MessageTray.Notification({
|
||||||
|
source,
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
isTransient: true,
|
||||||
forFeedback: true,
|
forFeedback: true,
|
||||||
undoCallback: () => this._addFavorite(appId, pos),
|
|
||||||
});
|
});
|
||||||
|
notification.addAction(_('Undo'), () => undoCallback());
|
||||||
|
source.addNotification(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user