diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-16 16:41:27 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-16 16:41:27 +0000 |
commit | a3ad7fa80f764fb7bcbe28fd1ede6a85ee85fc74 (patch) | |
tree | 486257197649c715b31dceb2925a3b0f57dd2cf2 | |
parent | 947c3e9f723ef733ab46e4dce34fa41b91cb0604 (diff) | |
parent | 665f8b6b8787534c2477ff6a076c4563b32f01df (diff) | |
download | gtk+-a3ad7fa80f764fb7bcbe28fd1ede6a85ee85fc74.tar.gz |
Merge branch 'gtk-application-quartz' into 'gtk-3-24'
quartz: Bugfix - Add openFiles delegate to gtk_application (#463)
See merge request GNOME/gtk!2098
-rw-r--r-- | gtk/gtkapplication-quartz.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gtk/gtkapplication-quartz.c b/gtk/gtkapplication-quartz.c index 9794d7b862..7abea53a5d 100644 --- a/gtk/gtkapplication-quartz.c +++ b/gtk/gtkapplication-quartz.c @@ -64,6 +64,7 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A - (id)initWithImpl:(GtkApplicationImplQuartz*)impl; - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender; +- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames; @end @implementation GtkApplicationQuartzDelegate @@ -84,6 +85,35 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A */ return quartz->quit_inhibit == 0 ? NSTerminateNow : NSTerminateCancel; } + +-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames +{ + GFile **files; + gint i; + GApplicationFlags flags; + + flags = g_application_get_flags (G_APPLICATION (quartz->impl.application)); + + if (~flags & G_APPLICATION_HANDLES_OPEN) + { + [theApplication replyToOpenOrPrint:NSApplicationDelegateReplyFailure]; + return; + } + + files = g_new (GFile *, [filenames count]); + + for (i = 0; i < [filenames count]; i++) + files[i] = g_file_new_for_path ([(NSString *)[filenames objectAtIndex:i] UTF8String]); + + g_application_open (G_APPLICATION (quartz->impl.application), files, [filenames count], ""); + + for (i = 0; i < [filenames count]; i++) + g_object_unref (files[i]); + + g_free (files); + + [theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; +} @end /* these exist only for accel handling */ |