[gnome-documents] collections: use the provider icon for remote collections



commit b92541ab3066517252d475ea2dbbb41244d58bed
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Oct 19 18:59:34 2011 -0400

    collections: use the provider icon for remote collections

 src/collections.js |   18 ++++++++++++++----
 src/query.js       |    2 +-
 src/sidebar.js     |    2 +-
 src/sources.js     |    2 ++
 4 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/collections.js b/src/collections.js
index d60cc36..4afae10 100644
--- a/src/collections.js
+++ b/src/collections.js
@@ -27,7 +27,8 @@ const Manager = imports.manager;
 
 const CollectionQueryColumns = {
     URN: 0,
-    NAME: 1
+    NAME: 1,
+    DATASOURCE_URN: 2
 };
 
 function Collection(params) {
@@ -41,10 +42,19 @@ Collection.prototype = {
 
             this.id = cursor.get_string(CollectionQueryColumns.URN)[0];
             this.name = cursor.get_string(CollectionQueryColumns.NAME)[0];
-        }
 
-        // TODO add icon for remote categories
-        this.icon = '';
+            let datasource = cursor.get_string(CollectionQueryColumns.DATASOURCE_URN)[0];
+            let source = Global.sourceManager.getItemById(datasource);
+
+            if (source) {
+                let icon = source.icon;
+
+                if (icon.names)
+                    this.icon = icon.names[0];
+            } else {
+                this.icon = '';
+            }
+        }
     },
 
     getWhere: function() {
diff --git a/src/query.js b/src/query.js
index 40f1179..d6b1e49 100644
--- a/src/query.js
+++ b/src/query.js
@@ -208,7 +208,7 @@ QueryBuilder.prototype = {
     },
 
     buildCollectionsQuery: function() {
-        let sparql = 'SELECT ?urn nie:title(?urn) WHERE { ' +
+        let sparql = 'SELECT ?urn nie:title(?urn) nie:dataSource(?urn) WHERE { ' +
             '{ ?urn a nfo:DataContainer } ' +
             '{ ?doc nie:isPartOf ?urn } ' +
             'FILTER ((fn:starts-with (nao:identifier(?urn), "gd:collection")) &&' +
diff --git a/src/sidebar.js b/src/sidebar.js
index b4ed4df..fc66df9 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -124,7 +124,7 @@ SidebarModel.prototype = {
         // row to the right position
         let iter = this.model.append();
         Gd.sidebar_store_set(this.model, iter,
-                             collection.id, collection.name, '',
+                             collection.id, collection.name, collection.icon,
                              '', SidebarModelSections.COLLECTIONS);
 
         this._checkHeader();
diff --git a/src/sources.js b/src/sources.js
index dfb7513..48a53ee 100644
--- a/src/sources.js
+++ b/src/sources.js
@@ -43,11 +43,13 @@ Source.prototype = {
     _init: function(params) {
         this.id = null;
         this.name = null;
+        this.icon = null;
 
         if (params.object) {
             let account = params.object.get_account();
             this.id = 'gd:goa-account:' + account.id;
             this.name = account.provider_name;
+            this.icon = Gio.icon_new_for_string(account.provider_icon);
         } else {
             this.id = params.id;
             this.name = params.name;



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