[gnome-documents/gnome-3-16] documents: Open in the default recommended app



commit c89a21f9d92684cc7b9396c7707ff40c0a0edb3d
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 4 16:52:21 2016 +0100

    documents: Open in the default recommended app
    
    We still don't want to simply choose the default app as the one opening
    files, as it could lead to ePubs being opened in the archive manager.
    But we also want to make sure that the default settings are respected.
    
    Prefer the default application if it's part of the recommended
    applications, or the first recommended application failing that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758529

 src/documents.js |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index cb9bab4..6728956 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -678,13 +678,25 @@ const LocalDocument = new Lang.Class({
         this.sourceName = _("Local");
 
         if (this.mimeType) {
+            let defaultApp = Gio.app_info_get_default_for_type(this.mimeType, true);
+            let recommendedApp = null;
+
             let apps = Gio.app_info_get_recommended_for_type (this.mimeType);
             for (let i = 0; i < apps.length; i++) {
                 if (apps[i].supports_uris ()) {
-                    this.defaultApp = apps[i];
-                    break;
+                    if (defaultApp && apps[i].equal (defaultApp)) {
+                        // Found the recommended app that's also the default
+                        recommendedApp = apps[i];
+                        break;
+                    }
+                    // Set the first recommendedApp as the default if
+                    // they don't match
+                    if (!recommendedApp)
+                        recommendedApp = apps[i];
                 }
             }
+
+            this.defaultApp = recommendedApp;
         }
 
         if (this.defaultApp)


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