places-menu: Use Gio.File to check for equality
Strings may be different, but still refer to the same file
('/home/user' vs. '/home/user/', or even '/home/user/./').
Account for that by comparing files for equality rather than
paths.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/340>
This commit is contained in:
committed by
Marge Bot
parent
527ce99851
commit
1506a730c5
@@ -325,11 +325,11 @@ export class PlacesManager extends EventEmitter {
|
||||
this._places.special.forEach(p => p.destroy());
|
||||
this._places.special = [];
|
||||
|
||||
let homePath = GLib.get_home_dir();
|
||||
const homeFile = Gio.File.new_for_path(GLib.get_home_dir());
|
||||
|
||||
this._places.special.push(new PlaceInfo(
|
||||
'special',
|
||||
Gio.File.new_for_path(homePath),
|
||||
homeFile,
|
||||
_('Home')));
|
||||
|
||||
let specials = [];
|
||||
@@ -340,11 +340,12 @@ export class PlacesManager extends EventEmitter {
|
||||
|
||||
for (let i = 0; i < dirs.length; i++) {
|
||||
let specialPath = GLib.get_user_special_dir(dirs[i]);
|
||||
if (!specialPath || specialPath === homePath)
|
||||
continue;
|
||||
const specialFile = specialPath
|
||||
? Gio.File.new_for_path(specialPath)
|
||||
: null;
|
||||
|
||||
const file = Gio.File.new_for_path(specialPath);
|
||||
specials.push(new PlaceInfo('special', file));
|
||||
if (specialFile && !specialFile.equal(homeFile))
|
||||
specials.push(new PlaceInfo('special', file));
|
||||
}
|
||||
|
||||
specials.sort((a, b) => GLib.utf8_collate(a.name, b.name));
|
||||
|
||||
Reference in New Issue
Block a user