[gnome-documents] all: remove ability to set an item as favorite



commit c028a603bb7b31850d9d7b6b7311f9aee3fa505a
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 21 17:26:54 2012 +0200

    all: remove ability to set an item as favorite
    
    Since we don't have any way to get back the list of favorites yet, this
    is really obscure and doesn't serve any purpose.
    We'll probably put it back in next cycle, together with a good way to
    see all favorites at a glance.

 src/documents.js    |   54 ---------------------------------------------------
 src/query.js        |    6 +---
 src/selections.js   |   43 ----------------------------------------
 src/trackerUtils.js |   16 ---------------
 4 files changed, 2 insertions(+), 117 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index ff2c40e..a4b1244 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -276,7 +276,6 @@ const DocCommon = new Lang.Class({
         this.author = null;
         this.mtime = null;
         this.resourceUrn = null;
-        this.favorite = null;
         this.pixbuf = null;
         this.pristinePixbuf = null;
         this.defaultAppName = null;
@@ -287,7 +286,6 @@ const DocCommon = new Lang.Class({
         this.typeDescription = null;
         this.sourceName = null;
 
-        this.favorite = false;
         this.shared = false;
 
         this.collection = false;
@@ -327,7 +325,6 @@ const DocCommon = new Lang.Class({
         this.identifier = cursor.get_string(Query.QueryColumns.IDENTIFIER)[0];
         this.author = cursor.get_string(Query.QueryColumns.AUTHOR)[0];
         this.resourceUrn = cursor.get_string(Query.QueryColumns.RESOURCE_URN)[0];
-        this.favorite = cursor.get_boolean(Query.QueryColumns.FAVORITE);
 
         let mtime = cursor.get_string(Query.QueryColumns.MTIME)[0];
         if (mtime) {
@@ -546,10 +543,6 @@ const DocCommon = new Lang.Class({
 
         activeItem = Global.searchCategoryManager.getActiveItem();
 
-        if (this.favorite &&
-            (!activeItem ||
-             (activeItem.id != Searchbar.SearchCategoryStock.FAVORITES)))
-            emblemIcons.push(this._createSymbolicEmblem('emblem-favorite'));
         if (this.shared &&
             (!activeItem ||
              (activeItem.id != Searchbar.SearchCategoryStock.SHARED)))
@@ -623,10 +616,6 @@ const DocCommon = new Lang.Class({
             }));
     },
 
-    setFavorite: function(favorite) {
-        TrackerUtils.setFavorite(this.id, favorite, null);
-    },
-
     getWhere: function() {
         let retval = '';
 
@@ -783,46 +772,6 @@ const GoogleDocument = new Lang.Class({
         this.parent(cursor);
     },
 
-    setFavorite: function(favorite) {
-        this.parent(favorite);
-
-        this._createGDataEntry(null, Lang.bind(this,
-            function(entry, service, exception) {
-                if (!entry) {
-                    log('Unable to call setFavorite on ' + this.name + ': ' + exception.toString());
-                    return;
-                }
-
-                let starred = null;
-                let categories = entry.get_categories();
-                categories.forEach(
-                    function(category) {
-                        if (category.scheme == _GOOGLE_DOCS_SCHEME_LABELS &&
-                            category.term == _GOOGLE_DOCS_TERM_STARRED)
-                            starred = category;
-                    });
-
-                if (!starred) {
-                    starred = new GData.Category({ scheme: _GOOGLE_DOCS_SCHEME_LABELS,
-                                                   term: _GOOGLE_DOCS_TERM_STARRED });
-                    entry.add_category(starred);
-                }
-
-                starred.set_label(favorite ? 'starred' : '');
-
-                service.update_entry_async
-                    (service.get_primary_authorization_domain(),
-                     entry, null, Lang.bind(this,
-                         function(service, res) {
-                             try {
-                                 service.update_entry_finish(res);
-                             } catch (e) {
-                                 log('Unable to call setFavorite on ' + this.name + ': ' + e.toString());
-                             }
-                         }));
-            }));
-    },
-
     canTrash: function() {
         return false;
     }
@@ -916,9 +865,6 @@ const SkydriveDocument = new Lang.Class({
         this.typeDescription = description;
     },
 
-    setFavorite: function(favorite) {
-    },
-
     canTrash: function() {
         return false;
     }
diff --git a/src/query.js b/src/query.js
index 79785de..c3e3f2d 100644
--- a/src/query.js
+++ b/src/query.js
@@ -37,9 +37,8 @@ const QueryColumns = {
     IDENTIFIER: 7,
     RDFTYPE: 8,
     RESOURCE_URN: 9,
-    FAVORITE: 10,
-    SHARED: 11,
-    DATE_CREATED: 12
+    SHARED: 10,
+    DATE_CREATED: 11
 };
 
 const QueryFlags = {
@@ -197,7 +196,6 @@ const QueryBuilder = new Lang.Class({
             'nao:identifier(?urn) ' + // identifier
             'rdf:type(?urn) ' + // type
             'nie:dataSource(?urn) ' + // resource URN
-            '( EXISTS { ?urn nao:hasTag nao:predefined-tag-favorite } ) ' + // favorite
             '( EXISTS { ?urn nco:contributor ?contributor FILTER ( ?contributor != ?creator ) } ) ' + // shared
             'tracker:coalesce(nfo:fileCreated(?urn), nie:contentCreated(?urn)) ' + // date created
             whereSparql + tailSparql;
diff --git a/src/selections.js b/src/selections.js
index a3ca2d4..e15fbca 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -764,11 +764,6 @@ const SelectionToolbar = new Lang.Class({
         this._leftGroup = new Gtk.ToolItem({ child: this._leftBox });
         this.widget.insert(this._leftGroup, -1);
 
-        this._toolbarFavorite = new Gtk.ToggleButton({ child: new Gtk.Image ({ icon_name: 'emblem-favorite-symbolic',
-                                                                               pixel_size: 32 })});
-        this._leftBox.add(this._toolbarFavorite);
-        this._toolbarFavorite.connect('clicked', Lang.bind(this, this._onToolbarFavorite));
-
         this._toolbarProperties = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'document-properties-symbolic',
                                                                            pixel_size: 32 })});
         this._toolbarProperties.set_tooltip_text(_("Properties"));
@@ -855,8 +850,6 @@ const SelectionToolbar = new Lang.Class({
 
     _setItemVisibility: function() {
         let apps = [];
-        let favCount = 0;
-        let showFavorite = true;
         let showTrash = true;
         let showPrint = true;
         let showProperties = true;
@@ -869,9 +862,6 @@ const SelectionToolbar = new Lang.Class({
             function(urn) {
                 let doc = Global.documentManager.getItemById(urn);
 
-                if (doc.favorite)
-                    favCount++;
-
                 if ((doc.defaultAppName) &&
                     (apps.indexOf(doc.defaultAppName) == -1))
                     apps.push(doc.defaultAppName);
@@ -880,7 +870,6 @@ const SelectionToolbar = new Lang.Class({
                 showPrint &= !doc.collection;
             }));
 
-        showFavorite &= ((favCount == 0) || (favCount == selection.length));
         showOpen = (apps.length > 0);
 
         if (selection.length > 1) {
@@ -898,29 +887,10 @@ const SelectionToolbar = new Lang.Class({
         }
         this._toolbarOpen.set_tooltip_text(openLabel);
 
-        if (showFavorite) {
-            let isFavorite = (favCount == selection.length);
-            let favoriteLabel = '';
-
-            if (isFavorite) {
-                favoriteLabel = _("Remove from favorites");
-                this._toolbarFavorite.set_active(true);
-                this._toolbarFavorite.get_style_context().add_class('documents-favorite');
-            } else {
-                favoriteLabel = _("Add to favorites");
-                this._toolbarFavorite.set_active(false);
-                this._toolbarFavorite.get_style_context().remove_class('documents-favorite');
-            }
-
-            this._toolbarFavorite.reset_style();
-            this._toolbarFavorite.set_tooltip_text(favoriteLabel);
-        }
-
         this._toolbarPrint.set_visible(showPrint);
         this._toolbarProperties.set_visible(showProperties);
         this._toolbarTrash.set_visible(showTrash);
         this._toolbarOpen.set_visible(showOpen);
-        this._toolbarFavorite.set_visible(showFavorite);
 
         this._insideRefresh = false;
     },
@@ -952,19 +922,6 @@ const SelectionToolbar = new Lang.Class({
             }));
     },
 
-    _onToolbarFavorite: function(widget) {
-        if (this._insideRefresh)
-            return;
-
-        let selection = Global.selectionController.getSelection();
-
-        selection.forEach(Lang.bind(this,
-            function(urn) {
-                let doc = Global.documentManager.getItemById(urn);
-                doc.setFavorite(!doc.favorite);
-            }));
-    },
-
     _onToolbarTrash: function(widget) {
         let selection = Global.selectionController.getSelection();
 
diff --git a/src/trackerUtils.js b/src/trackerUtils.js
index d667da6..e7156e0 100644
--- a/src/trackerUtils.js
+++ b/src/trackerUtils.js
@@ -23,22 +23,6 @@ const GLib = imports.gi.GLib;
 
 const Global = imports.global;
 
-function setFavorite(urn, isFavorite, callback) {
-    let sparql = ('%s { <%s> nao:hasTag nao:predefined-tag-favorite }').format((isFavorite ? 'INSERT OR REPLACE' : 'DELETE'), urn);
-
-    Global.connectionQueue.update(sparql, null,
-        function(object, res) {
-            try {
-                object.update_finish(res);
-            } catch (e) {
-                log('Unable to set the favorite property on ' + urn + ' to ' + isFavorite + ': ' + e.toString());
-            }
-
-            if (callback)
-                callback();
-        });
-}
-
 function setEditedName(newTitle, docId, callback) {
     let sparql = ('INSERT OR REPLACE { <%s> nfo:fileName\"%s\" }'.format(docId, newTitle));
 



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