[gnome-maps/wip/places: 6/6] PlaceStore: add storing of favorites



commit 7aa041dd5fc449814446d1300dfbca556cc52718
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Jan 13 14:02:08 2014 +0100

    PlaceStore: add storing of favorites
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722102

 src/placeStore.js |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/placeStore.js b/src/placeStore.js
index cdbbfeb..3121c6e 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -37,6 +37,7 @@ const _ICON_SIZE = 20;
 const PlaceType = {
     ANY: -1,
     RECENT: 0,
+    FAVORITE: 1
 };
 
 const Columns = {
@@ -67,6 +68,18 @@ const PlaceStore = new Lang.Class({
                                GObject.TYPE_DOUBLE]);
     },
 
+    addFavorite: function(place) {
+        if (!this._exists(place, PlaceType.FAVORITE)) {
+            if (this._exists(place, PlaceType.RECENT)) {
+                this._removeIf((function(model, iter) {
+                    let p = model.get_value(iter, Columns.PLACE);
+                    return p.name === place.name;
+                }), true);
+            }
+            this._addPlace(place, PlaceTYPE.FAVORITE, new Date().getTime());
+        }
+    },
+
     addRecent: function(place) {
         if (this._exists(place, PlaceType.RECENT))
             return;


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