[gnome-documents] places: Hide "Contents" tab when no TOC is available



commit 6f9764e3fadc0dd6bd4d3a847f2aaee6229790ab
Author: Muhammet Kara <muhammetk gmail com>
Date:   Wed Apr 8 16:08:26 2015 +0300

    places: Hide "Contents" tab when no TOC is available
    
    In the preview of a document, clicking the "Bookmarks" button
    on the bottom left of the page shows a window with two tabs titled
    'Contents' and 'Bookmarks' even if there is no table of contents
    for the document. Now, the opened window doesn't show the Contents
    tab if there is no TOC within the document.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741780

 src/places.js |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/places.js b/src/places.js
index 966732f..e5682d2 100644
--- a/src/places.js
+++ b/src/places.js
@@ -63,12 +63,25 @@ const PlacesDialog = new Lang.Class({
         let switcher = new Gtk.StackSwitcher({ stack: this._stack });
         header.set_custom_title(switcher);
 
-        this._linksPage = new GdPrivate.PlacesLinks();
-        this._linksPage.connect('link-activated', Lang.bind(this,
-            function(widget, link) {
-                this._handleLink(link);
-            }));
-        this._addPage(this._linksPage);
+        let evDoc = this._model.get_document();
+        let docHasLinks = false;
+
+        try {
+            // This is a hack to find out if evDoc implements the
+            // EvDocument.DocumentLinks interface or not.
+            docHasLinks = evDoc.has_document_links();
+        } catch (e if e instanceof TypeError) {
+        } catch (e) {
+        }
+
+        if (docHasLinks) {
+            this._linksPage = new GdPrivate.PlacesLinks();
+            this._linksPage.connect('link-activated', Lang.bind(this,
+                function(widget, link) {
+                    this._handleLink(link);
+                }));
+            this._addPage(this._linksPage);
+        }
 
         if (this._bookmarks) {
             this._bookmarksPage = new GdPrivate.PlacesBookmarks({ bookmarks: this._bookmarks });


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