[gnome-documents/gnome-3-18] documents: Open in the default recommended app
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-18] documents: Open in the default recommended app
- Date: Tue, 5 Jan 2016 10:35:48 +0000 (UTC)
commit 4813fba6fce30a489b4fc2dff440b7b2757097cf
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 16bb704..f3893e0 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -682,13 +682,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]