From 9adaf7a8bdfe7b800fa5be3e46f7950dd6b7dfbb Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sat, 22 Jun 2019 17:52:47 +0200 Subject: fix inbox#595 macOS NSApplicationBlockTermination --- src/inkscape-application.cpp | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp index fb0485719..789ae5c94 100644 --- a/src/inkscape-application.cpp +++ b/src/inkscape-application.cpp @@ -596,6 +596,7 @@ ConcreteInkscapeApplication::on_startup2() #ifdef GDK_WINDOWING_QUARTZ static gboolean osx_openfile_callback(GtkosxApplication *, gchar const *, ConcreteInkscapeApplication *); +static gboolean osx_quit_callback(GtkosxApplication *, ConcreteInkscapeApplication *); #endif template<> @@ -644,6 +645,7 @@ ConcreteInkscapeApplication::on_startup2() #ifdef GDK_WINDOWING_QUARTZ GtkosxApplication *osxapp = gtkosx_application_get(); g_signal_connect(G_OBJECT(osxapp), "NSApplicationOpenFile", G_CALLBACK(osx_openfile_callback), this); + g_signal_connect(G_OBJECT(osxapp), "NSApplicationBlockTermination", G_CALLBACK(osx_quit_callback), this); #endif } @@ -740,20 +742,6 @@ ConcreteInkscapeApplication::create_window(const Glib::RefPtr< return (desktop); // Temp: Need to track desktop for shell mode. } -#ifdef GDK_WINDOWING_QUARTZ -/** - * On macOS, handle dropping files on Inkscape.app icon and "Open With" file association. - */ -static gboolean osx_openfile_callback(GtkosxApplication *osxapp, gchar const *path, - ConcreteInkscapeApplication *app) -{ - auto ptr = Gio::File::create_for_path(path); - g_return_val_if_fail(ptr, false); - app->create_window(ptr); - return true; -} -#endif - /** No need to destroy window if T is Gio::Application. */ template @@ -1374,6 +1362,31 @@ ConcreteInkscapeApplication::on_quit() quit(); } +// ======================== macOS ============================= + +#ifdef GDK_WINDOWING_QUARTZ +/** + * On macOS, handle dropping files on Inkscape.app icon and "Open With" file association. + */ +static gboolean osx_openfile_callback(GtkosxApplication *osxapp, gchar const *path, + ConcreteInkscapeApplication *app) +{ + auto ptr = Gio::File::create_for_path(path); + g_return_val_if_fail(ptr, false); + app->create_window(ptr); + return true; +} + +/** + * Handle macOS terminating the application + */ +static gboolean osx_quit_callback(GtkosxApplication *, ConcreteInkscapeApplication *app) +{ + app->destroy_all(); + return true; +} +#endif + template class ConcreteInkscapeApplication; template class ConcreteInkscapeApplication; -- cgit v1.2.3