[geary] Fix attachments not being opened when using flatpak. Bug 770886.



commit ca3452b840adeb1c715ca4b11173bf0a9ca5e979
Author: Michael James Gratton <mike vee net>
Date:   Mon Feb 27 11:39:29 2017 +1100

    Fix attachments not being opened when using flatpak. Bug 770886.
    
    * src/client/application/geary-controller.vala
      (GearyController:on_attachments_activated): Just use
      Gtk.show_uri_on_window to open attachments.

 src/client/application/geary-controller.vala |   35 +++----------------------
 1 files changed, 5 insertions(+), 30 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index a7dd147..b859fd8 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2017,36 +2017,11 @@ public class GearyController : Geary.BaseObject {
         }
 
         foreach (Geary.Attachment attachment in attachments) {
-            string gio_content_type = ContentType.from_mime_type(
-                attachment.content_type.get_mime_type()
-            );
-            AppInfo? app = null;
-            if (!ContentType.can_be_executable(gio_content_type) &&
-                !ContentType.is_unknown(gio_content_type)) {
-                app = AppInfo.get_default_for_type(gio_content_type, false);
-            }
-            if (app == null) {
-                string content_type = attachment.content_type.get_mime_type();
-                Gtk.AppChooserDialog app_chooser =
-                    new Gtk.AppChooserDialog.for_content_type(
-                        this.main_window,
-                        Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR,
-                        content_type
-                    );
-                if (app_chooser.run() == Gtk.ResponseType.OK) {
-                    app = app_chooser.get_app_info();
-                }
-                app_chooser.hide();
-            }
-            if (app != null) {
-                List<File> files = new List<File>();
-                files.append(attachment.file);
-                try {
-                    app.launch(files, null);
-                } catch (Error error) {
-                    warning("Failed to launch %s: %s\n",
-                            app.get_name(), error.message);
-                }
+            string uri = attachment.file.get_uri();
+            try {
+                this.application.show_uri(uri);
+            } catch (Error err) {
+                message("Unable to open attachment \"%s\": %s", uri, err.message);
             }
         }
     }


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