/* In some cases GTK pops up a native window, such as when opening or *savingafile.Wemapcommonactionssuchasundo,copy,paste,etc. *toselectors,sotheseactionscanbeactivatedinanativewindow. *Asaconcequence,wealsoneedtoimplementthemonourownview, *andactivatetheactiontothefocusedwidget.
*/
/* If there are any items at all, then the first one is the app menu */ if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
g_menu_remove (quartz->combined, 0);
if (app_menu)
g_menu_prepend_submenu (quartz->combined, "Application", app_menu); else
{
GMenu *empty;
/* We must preserve the rule that index 0 is the app menu */
empty = g_menu_new ();
g_menu_prepend_submenu (quartz->combined, "Application", G_MENU_MODEL (empty));
g_object_unref (empty);
}
}
/* and put code behind the 'special' accels */
gtkinternal = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (gtkinternal), gtk_application_impl_quartz_actions,
G_N_ELEMENTS (gtk_application_impl_quartz_actions), quartz);
gtk_application_insert_action_group (impl->application, "gtkinternal", G_ACTION_GROUP (gtkinternal));
g_object_unref (gtkinternal);
/* now setup the menu */ if (quartz->standard_app_menu == NULL)
{
GtkBuilder *builder;
/* If the user didn't fill in their own menu yet, add ours. * *Thefactthatwedothishereensuresthatwewillalwayshavethe *appmenuatindex0in'combined'.
*/
builder = gtk_builder_new_from_resource ("/org/gtk/libgtk/ui/gtkapplication-quartz.ui");
quartz->standard_app_menu = G_MENU_MODEL (g_object_ref (gtk_builder_get_object (builder, "app-menu")));
g_object_unref (builder);
}
/* This may or may not add an item to 'combined' */
menubar = gtk_application_get_menubar (impl->application); if (menubar == NULL)
{
GtkBuilder *builder;
/* Provide a fallback menu, so keyboard shortcuts work in native windows too.
*/
builder = gtk_builder_new_from_resource ("/org/gtk/libgtk/ui/gtkapplication-quartz.ui");
menubar = G_MENU_MODEL (g_object_ref (gtk_builder_get_object (builder, "default-menu")));
g_object_unref (builder);
}
gtk_application_impl_set_menubar (impl, menubar);
/* OK. Now put it in the menu. */
gtk_application_impl_quartz_setup_menu (G_MENU_MODEL (quartz->combined), quartz->muxer);
/* If we have the menubar, it is a section at index '1' */ if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)) > 1)
g_menu_remove (quartz->combined, 1);
if (menubar)
g_menu_append_section (quartz->combined, NULL, menubar);
}
for (iter = quartz->inhibitors; iter; iter = iter->next)
{
GtkApplicationQuartzInhibitor *inhibitor = iter->data;
if (inhibitor->cookie == cookie)
{ if (inhibitor->flags & GTK_APPLICATION_INHIBIT_LOGOUT)
quartz->quit_inhibit--;
gtk_application_quartz_inhibitor_free (inhibitor);
quartz->inhibitors = g_slist_delete_link (quartz->inhibitors, iter); return;
}
}
g_warning ("Invalid inhibitor cookie");
}
staticvoid
gtk_application_impl_quartz_init (GtkApplicationImplQuartz *quartz)
{ /* This is required so that Cocoa is not going to parse the commandlineargumentsbyitselfandgenerateOpenFileevents. Wealreadyparsethecommandlineourselves,sothisisneeded
to prevent opening files twice, etc. */
[[NSUserDefaults standardUserDefaults] setObject:@"NO"
forKey:@"NSTreatUnknownArgumentsAsOpen"];
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet am 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.