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.
This commit is contained in:
Michael James Gratton 2017-02-27 11:39:29 +11:00
parent 2349ea6892
commit ca3452b840

View file

@ -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);
}
}
}