places: Do not use nautilus' 'desktop-is-home-dir' setting

g_settings_schema_new() aborts if the requested schema is not found,
so the previous approach of handling the case of unstable nautilus
not being installed did not work.
Instead, remove the use of the setting altogether - the original intent
was to not have separate items for Desktop and Home in the places
section if the nautilus key was set. As the section has been removed
anyway, the impact of always adding the desktop folder is minimal
(e.g. searching for "desktop" will match the desktop folder even
if it's set to the home folder).
This commit is contained in:
Florian Müllner 2011-01-17 20:52:26 +01:00
parent 05f9be046f
commit ad52d783bd

View File

@ -15,9 +15,6 @@ const Main = imports.ui.main;
const Search = imports.ui.search; const Search = imports.ui.search;
const Util = imports.misc.util; const Util = imports.misc.util;
const NAUTILUS_PREFS_SCHEMA = 'org.gnome.nautilus.preferences';
const DESKTOP_IS_HOME_KEY = 'desktop-is-home-dir';
/** /**
* Represents a place object, which is most normally a bookmark entry, * Represents a place object, which is most normally a bookmark entry,
* a mount/volume, or a special place like the Home Folder, Computer, and Network. * a mount/volume, or a special place like the Home Folder, Computer, and Network.
@ -125,25 +122,6 @@ PlacesManager.prototype = {
this._mounts = []; this._mounts = [];
this._bookmarks = []; this._bookmarks = [];
this._settings = null;
this._isDesktopHome = false;
// The GNOME3 version of nautilus has been ported to GSettings; we
// don't require it though, so for now we'll have to deal with the
// case of GNOME3 nautilus not being installed.
try {
this._settings = new Gio.Settings({ schema: NAUTILUS_PREFS_SCHEMA });
} catch (e) {
log('Failed to get settings from Nautilus. Places may not work as expected');
}
if (this._settings != null) {
this._isDesktopHome = this._settings.get_boolean(DESKTOP_IS_HOME_KEY);
this._settings.connect('changed::' + DESKTOP_IS_HOME_KEY,
Lang.bind(this,
this._updateDesktopMenuVisibility));
}
let homeFile = Gio.file_new_for_path (GLib.get_home_dir()); let homeFile = Gio.file_new_for_path (GLib.get_home_dir());
let homeUri = homeFile.get_uri(); let homeUri = homeFile.get_uri();
let homeLabel = Shell.util_get_label_for_uri (homeUri); let homeLabel = Shell.util_get_label_for_uri (homeUri);
@ -201,10 +179,7 @@ PlacesManager.prototype = {
} }
this._defaultPlaces.push(this._home); this._defaultPlaces.push(this._home);
this._defaultPlaces.push(this._desktopMenu);
this._desktopMenuIndex = this._defaultPlaces.length;
if (!this._isDesktopHome)
this._defaultPlaces.push(this._desktopMenu);
if (this._network) if (this._network)
this._defaultPlaces.push(this._network); this._defaultPlaces.push(this._network);
@ -350,20 +325,6 @@ PlacesManager.prototype = {
this.emit('places-updated'); this.emit('places-updated');
}, },
_updateDesktopMenuVisibility: function() {
this._isDesktopHome = this._settings.get_boolean(DESKTOP_IS_HOME_KEY);
if (this._isDesktopHome)
this._removeById(this._defaultPlaces, 'special:desktop');
else
this._defaultPlaces.splice(this._desktopMenuIndex, 0,
this._desktopMenu);
/* See comment in _updateDevices for explanation why there are two signals. */
this.emit('defaults-updated');
this.emit('places-updated');
},
_addMount: function(mount) { _addMount: function(mount) {
let devItem = new PlaceDeviceInfo(mount); let devItem = new PlaceDeviceInfo(mount);
this._mounts.push(devItem); this._mounts.push(devItem);