[gnome-documents] documents: don't show the emblem if we're browsing the same category



commit 4405726501c3c4d464da339d26704527c1d7f29f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Aug 31 12:35:58 2011 -0400

    documents: don't show the emblem if we're browsing the same category
    
    E.g. don't show the favorite emblem if we're browsing favorites.

 src/categories.js |   23 +++++++++++++++--------
 src/documents.js  |   11 ++++++++---
 2 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/categories.js b/src/categories.js
index 643de99..c382c97 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -26,6 +26,13 @@ const _ = imports.gettext.gettext;
 
 const Global = imports.global;
 
+const StockCategories = {
+    RECENT: 'recent',
+    FAVORITES: 'favorites',
+    SHARED: 'shared',
+    PRIVATE: 'private'
+};
+
 function Category(id, name, icon) {
     this._init(id, name, icon);
 };
@@ -38,11 +45,11 @@ Category.prototype = {
     },
 
     getWhere: function() {
-        if (this.id == 'favorites')
+        if (this.id == StockCategories.FAVORITES)
             return '{ ?urn nao:hasTag nao:predefined-tag-favorite }';
 
         // require to have a contributor, and creator, and they should be different
-        if (this.id == 'shared')
+        if (this.id == StockCategories.SHARED)
             return '{ ?urn nco:contributor ?contributor . ?urn nco:creator ?creator FILTER (?contributor != ?creator ) }';
 
         return '{ }';
@@ -50,7 +57,7 @@ Category.prototype = {
 
     getFilter: function() {
         // require to be not local
-        if (this.id == 'shared')
+        if (this.id == StockCategories.SHARED)
             return Global.queryBuilder.buildFilterNotLocal();
 
         return '(true)';
@@ -67,20 +74,20 @@ CategoryManager.prototype = {
 
         let category;
         // Translators: this refers to new and recent documents
-        category = new Category('recent', _("New and Recent"), '');
+        category = new Category(StockCategories.RECENT, _("New and Recent"), '');
         this._categories[category.id] = category;
         // Translators: this refers to favorite documents
-        category = new Category('favorites', _("Favorites"), 'emblem-favorite-symbolic');
+        category = new Category(StockCategories.FAVORITES, _("Favorites"), 'emblem-favorite-symbolic');
         this._categories[category.id] = category;
         // Translators: this refers to shared documents
-        category = new Category('shared', _("Shared with you"), 'emblem-shared-symbolic');
+        category = new Category(StockCategories.SHARED, _("Shared with you"), 'emblem-shared-symbolic');
         this._categories[category.id] = category;
 
         // unimplemented
-        category = new Category('private', _("Private"), 'channel-secure-symbolic');
+        category = new Category(StockCategories.PRIVATE, _("Private"), 'channel-secure-symbolic');
         this._categories[category.id] = category;
 
-        this.setActiveCategoryId('recent');
+        this.setActiveCategoryId(StockCategories.RECENT);
     },
 
     setActiveCategoryId: function(id) {
diff --git a/src/documents.js b/src/documents.js
index b30bd51..284aeb5 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -31,6 +31,7 @@ const _ = imports.gettext.gettext;
 const Lang = imports.lang;
 const Signals = imports.signals;
 
+const Categories = imports.categories;
 const ChangeMonitor = imports.changeMonitor;
 const Global = imports.global;
 const Path = imports.path;
@@ -67,10 +68,12 @@ DocCommon.prototype = {
         this._refreshIconId =
             Global.settings.connect('changed::list-view',
                                     Lang.bind(this, this.refreshIcon));
-
         this._changesId =
             Global.changeMonitor.connect('changes-pending',
                                          Lang.bind(this, this._onChangesPending));
+        this._categoryId =
+            Global.categoryManager.connect('active-category-changed',
+                                           Lang.bind(this, this.refreshIcon));
     },
 
     _onChangesPending: function(monitor, changes) {
@@ -161,9 +164,10 @@ DocCommon.prototype = {
         let emblemIcons = [];
         let pixbuf = this.pixbuf;
 
-        if (this.favorite)
+        if (this.favorite &&
+            (Global.categoryManager.getActiveCategoryId() != Categories.StockCategories.FAVORITES))
             emblemIcons.push(this._createSymbolicEmblem('emblem-favorite'));
-        if (this.shared)
+        if (this.shared && (Global.categoryManager.getActiveCategoryId() != Categories.StockCategories.SHARED))
             emblemIcons.push(this._createSymbolicEmblem('emblem-shared'));
 
         if (emblemIcons.length > 0) {
@@ -203,6 +207,7 @@ DocCommon.prototype = {
     destroy: function() {
         Global.settings.disconnect(this._refreshIconId);
         Global.changeMonitor.disconnect(this._changesId);
+        Global.categoryManager.disconnect(this._categoryId);
     },
 
     open: function(screen, timestamp) {



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