macOS: Dock "Quit" invokes "app.quit" action
Allows the application to handle "Dock icon > Quit" the same as "Application menu > Quit". Requires GtkApplication's `register-session` property. Suitable replacement for gtk-mac-integration's `NSApplicationBlockTermination` signal.
This commit is contained in:
parent
e6e4f9e630
commit
cbd9715c3c
@ -80,13 +80,19 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A
|
|||||||
|
|
||||||
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
|
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
|
||||||
{
|
{
|
||||||
/* We have no way to give our message other than to pop up a dialog
|
const gchar *quit_action_name = "quit";
|
||||||
* ourselves, which we should not do since the OS will already show
|
GActionGroup *action_group = G_ACTION_GROUP (quartz->impl.application);
|
||||||
* one when we return NSTerminateNow.
|
|
||||||
*
|
if (quartz->quit_inhibit != 0)
|
||||||
* Just let the OS show the generic message...
|
return NSTerminateCancel;
|
||||||
*/
|
|
||||||
return quartz->quit_inhibit == 0 ? NSTerminateNow : NSTerminateCancel;
|
if (g_action_group_has_action (action_group, quit_action_name))
|
||||||
|
{
|
||||||
|
g_action_group_activate_action (action_group, quit_action_name, NULL);
|
||||||
|
return NSTerminateCancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NSTerminateNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
|
-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
|
||||||
|
Loading…
Reference in New Issue
Block a user