From 7724fd14b2d20619edca4119d076a7b0fcdc1c4d Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 29 Aug 2019 23:31:50 +1000 Subject: [PATCH 1/2] Explicitly handle Application::open Using Geary not working as a mailto: handler broke after the conversion to being DBus-activated, due to the GAppplication DBus implementation not passing on the open action if the `HANDLES_OPEN` flag is not set. This sets the flag and implements the `open` signal. See GNOME/glib#1853 Fixes #522 --- src/client/application/geary-application.vala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala index 77307393..11e6480b 100644 --- a/src/client/application/geary-application.vala +++ b/src/client/application/geary-application.vala @@ -363,7 +363,10 @@ public class GearyApplication : Gtk.Application { public GearyApplication() { Object( application_id: APP_ID, - flags: GLib.ApplicationFlags.HANDLES_COMMAND_LINE + flags: ( + GLib.ApplicationFlags.HANDLES_OPEN | + GLib.ApplicationFlags.HANDLES_COMMAND_LINE + ) ); this.add_main_option_entries(OPTION_ENTRIES); _instance = this; @@ -460,6 +463,14 @@ public class GearyApplication : Gtk.Application { this.present.begin(); } + public override void open(GLib.File[] targets, string hint) { + foreach (GLib.File target in targets) { + if (target.get_uri_scheme() == "mailto") { + this.new_composer.begin(target.get_uri()); + } + } + } + public void add_window_accelerators(string action, string[] accelerators, Variant? param = null) { From e8a7d7937f8e6f2c28e549b99fdcf4184e07535b Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 5 Sep 2019 19:15:36 +1000 Subject: [PATCH 2/2] Work around GLib inserting '///' in mailto URIs Since GApplication::open passes GFile instances around, when `mailto` URIs are passed in, they are mangled by GFile to have the form 'mailto:///...'. Check for that and work around. See GNOME/glib#1886 --- src/client/application/geary-application.vala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala index 11e6480b..c8f2e1b6 100644 --- a/src/client/application/geary-application.vala +++ b/src/client/application/geary-application.vala @@ -466,7 +466,16 @@ public class GearyApplication : Gtk.Application { public override void open(GLib.File[] targets, string hint) { foreach (GLib.File target in targets) { if (target.get_uri_scheme() == "mailto") { - this.new_composer.begin(target.get_uri()); + string mailto = target.get_uri(); + // Due to GNOME/glib#1886, the email address may be + // prefixed by a '///'. If so, remove it. + if (mailto.has_prefix("mailto:///")) { + mailto = ( + Geary.ComposedEmail.MAILTO_SCHEME + + mailto.substring("mailto:///".length) + ); + } + this.new_composer.begin(mailto); } } }