[gnome-books/wip/hadess/more-dead-code-cleanup] overview: Fix warning with un-thumbnailable files



commit 602b425b309280f50778bb68cc8371ee63eff6f1
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 28 17:42:58 2019 +0100

    overview: Fix warning with un-thumbnailable files
    
    If some files are not thumbnail-able, we'd get warnings like:
    gtk+-3/gtk/gtkliststore.c:836: Unable to convert from gpointer to CairoSurface
    
    Don't try to insert a JavaScript "null" in a GtkListStore.

 src/overview.js | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/overview.js b/src/overview.js
index 8e361503..e8f699bd 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -129,11 +129,16 @@ const ViewModel = new Lang.Class({
         this._resetCount();
 
         let iter = this.append();
-        this.set(iter,
-            [ 0, 1, 2, 3, 4, 5 ],
-            [ doc.id, doc.uri, doc.name,
-              doc.author, doc.surface, doc.mtime ]);
-
+        if (doc.surface)
+            this.set(iter,
+                [ 0, 1, 2, 3, 4, 5 ],
+                [ doc.id, doc.uri, doc.name,
+                  doc.author, doc.surface, doc.mtime ]);
+        else
+            this.set(iter,
+                [ 0, 1, 2, 3, 5 ],
+                [ doc.id, doc.uri, doc.name,
+                  doc.author, doc.mtime ]);
         let treePath = this.get_path(iter);
         let treeRowRef = Gtk.TreeRowReference.new(this, treePath);
         doc.rowRefs[this._rowRefKey] = treeRowRef;
@@ -185,11 +190,18 @@ const ViewModel = new Lang.Class({
                 return;
 
             let objectIter = this.get_iter(objectPath)[1];
-            if (objectIter)
-                this.set(objectIter,
-                    [ 0, 1, 2, 3, 4, 5 ],
-                    [ doc.id, doc.uri, doc.name,
-                      doc.author, doc.surface, doc.mtime ]);
+            if (objectIter) {
+                if (doc.surface)
+                    this.set(objectIter,
+                        [ 0, 1, 2, 3, 4, 5 ],
+                        [ doc.id, doc.uri, doc.name,
+                          doc.author, doc.surface, doc.mtime ]);
+                else
+                    this.set(objectIter,
+                        [ 0, 1, 2, 3, 5 ],
+                        [ doc.id, doc.uri, doc.name,
+                          doc.author, doc.mtime ]);
+            }
         }
     },
 


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