appFavorites: Hide favourites which are blacklisted by parental controls
If a favourite is set for an app which is blocked by parental controls, that favourite should be hidden. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/465
This commit is contained in:
parent
143ab6ac7f
commit
91b13effc8
@ -2,6 +2,7 @@
|
|||||||
/* exported getAppFavorites */
|
/* exported getAppFavorites */
|
||||||
|
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
|
const ParentalControlsManager = imports.misc.parentalControlsManager;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
@ -64,6 +65,13 @@ const RENAMED_DESKTOP_IDS = {
|
|||||||
|
|
||||||
class AppFavorites {
|
class AppFavorites {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
// Filter the apps through the user’s parental controls.
|
||||||
|
this._parentalControlsManager = ParentalControlsManager.getDefault();
|
||||||
|
this._parentalControlsManager.connect('app-filter-changed', () => {
|
||||||
|
this.reload();
|
||||||
|
this.emit('changed');
|
||||||
|
});
|
||||||
|
|
||||||
this.FAVORITE_APPS_KEY = 'favorite-apps';
|
this.FAVORITE_APPS_KEY = 'favorite-apps';
|
||||||
this._favorites = {};
|
this._favorites = {};
|
||||||
global.settings.connect('changed::%s'.format(this.FAVORITE_APPS_KEY), this._onFavsChanged.bind(this));
|
global.settings.connect('changed::%s'.format(this.FAVORITE_APPS_KEY), this._onFavsChanged.bind(this));
|
||||||
@ -95,7 +103,7 @@ class AppFavorites {
|
|||||||
global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
|
global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
|
||||||
|
|
||||||
let apps = ids.map(id => appSys.lookup_app(id))
|
let apps = ids.map(id => appSys.lookup_app(id))
|
||||||
.filter(app => app != null);
|
.filter(app => app !== null && this._parentalControlsManager.shouldShowApp(app.app_info));
|
||||||
this._favorites = {};
|
this._favorites = {};
|
||||||
for (let i = 0; i < apps.length; i++) {
|
for (let i = 0; i < apps.length; i++) {
|
||||||
let app = apps[i];
|
let app = apps[i];
|
||||||
@ -134,6 +142,9 @@ class AppFavorites {
|
|||||||
if (!app)
|
if (!app)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!this._parentalControlsManager.shouldShowApp(app.app_info))
|
||||||
|
return false;
|
||||||
|
|
||||||
let ids = this._getIds();
|
let ids = this._getIds();
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
ids.push(appId);
|
ids.push(appId);
|
||||||
|
Loading…
Reference in New Issue
Block a user