[gnome-shell] [Places] Hide desktop icon when desktop_is_home_dir



commit 74446ce3e0380ac315b5da2d9641d40dbe0e3fa4
Author: Florian Müllner <fmuellner src gnome org>
Date:   Thu Jan 14 16:23:47 2010 +0100

    [Places] Hide desktop icon when desktop_is_home_dir
    
    With the above preference set to true, the home and desktop entries
    both represent the same location. Hide the desktop icon in that case
    to avoid redundancy.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=606922

 js/ui/placeDisplay.js |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index 745acc9..666ba60 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -114,7 +114,7 @@ PlacesManager.prototype = {
         this._defaultPlaces = [];
         this._mounts = [];
         this._bookmarks = [];
-        this._isDesktopHome = false;
+        this._isDesktopHome = gconf.get_boolean(DESKTOP_IS_HOME_KEY);
 
         let homeFile = Gio.file_new_for_path (GLib.get_home_dir());
         let homeUri = homeFile.get_uri();
@@ -172,6 +172,7 @@ PlacesManager.prototype = {
 
         this._defaultPlaces.push(this._home);
 
+        this._desktopMenuIndex = this._defaultPlaces.length;
         if (!this._isDesktopHome)
             this._defaultPlaces.push(this._desktopMenu);
 
@@ -211,7 +212,6 @@ PlacesManager.prototype = {
         }));
 
         this._reloadBookmarks();
-        this._updateDesktopMenuVisibility();
 
         gconf.connect('changed::' + DESKTOP_IS_HOME_KEY, Lang.bind(this, this._updateDesktopMenuVisibility));
 
@@ -327,6 +327,12 @@ PlacesManager.prototype = {
         let gconf = Shell.GConf.get_default();
         this._isDesktopHome = gconf.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');
@@ -353,13 +359,13 @@ PlacesManager.prototype = {
         return this._mounts;
     },
 
-    _lookupById: function(sourceArray, id) {
+    _lookupIndexById: function(sourceArray, id) {
         for (let i = 0; i < sourceArray.length; i++) {
             let place = sourceArray[i];
             if (place.id == id)
-                return place;
+                return i;
         }
-        return null;
+        return -1;
     },
 
     lookupPlaceById: function(id) {
@@ -372,7 +378,11 @@ PlacesManager.prototype = {
             sourceArray = this._mounts;
         else if (type == 'bookmark')
             sourceArray = this._bookmarks;
-        return this._lookupById(sourceArray, id);
+        return sourceArray[this._lookupIndexById(sourceArray, id)];
+    },
+
+    _removeById: function(sourceArray, id) {
+        sourceArray.splice(this._lookupIndexById(sourceArray, id), 1);
     }
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]