void ige_mac_menu_set_menu_bar (GtkMenuShell *menu_shell) { CarbonMenu *current_menu; MenuRef carbon_menubar; g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); if (carbon_menu_quark == 0) carbon_menu_quark = g_quark_from_static_string ("CarbonMenu"); if (carbon_menu_item_quark == 0) carbon_menu_item_quark = g_quark_from_static_string ("CarbonMenuItem"); current_menu = carbon_menu_get (GTK_WIDGET (menu_shell)); if (current_menu) { SetRootMenu (current_menu->menu); return; } CreateNewMenu (0 /*id*/, 0 /*options*/, &carbon_menubar); SetRootMenu (carbon_menubar); setup_menu_event_handler (); if (emission_hook_id == 0) { emission_hook_id = g_signal_add_emission_hook (g_signal_lookup ("parent-set", GTK_TYPE_WIDGET), 0, parent_set_emission_hook, NULL, NULL); } emission_hook_count++; g_signal_connect (menu_shell, "destroy", G_CALLBACK (parent_set_emission_hook_remove), NULL); sync_menu_shell (menu_shell, carbon_menubar, TRUE, FALSE); }
void sync_menu_takeover_menu (GtkMenuShell *menu_shell) { static MenuRef carbon_menubar = NULL; g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); if (carbon_menu_quark == 0) carbon_menu_quark = g_quark_from_static_string ("CarbonMenu"); if (carbon_menu_item_quark == 0) carbon_menu_item_quark = g_quark_from_static_string ("CarbonMenuItem"); if (!carbon_menubar) { carbon_menubar = AcquireRootMenu(); setup_menu_event_handler (); } sync_menu_shell (menu_shell, carbon_menubar, TRUE); }
void ige_mac_menu_set_quit_menu_item (GtkMenuItem *menu_item) { MenuRef appmenu; MenuItemIndex index; g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); setup_menu_event_handler (); if (GetIndMenuItemWithCommandID (NULL, kHICommandQuit, 1, &appmenu, &index) == noErr) { SetMenuItemCommandID (appmenu, index, 0); SetMenuItemProperty (appmenu, index, IGE_QUARTZ_MENU_CREATOR, IGE_QUARTZ_ITEM_WIDGET, sizeof (menu_item), &menu_item); gtk_widget_hide (GTK_WIDGET (menu_item)); } }
void ige_mac_menu_add_app_menu_item (IgeMacMenuGroup *group, GtkMenuItem *menu_item, const gchar *label) { MenuRef appmenu; GList *list; gint index = 0; g_return_if_fail (group != NULL); g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); setup_menu_event_handler (); if (GetIndMenuItemWithCommandID (NULL, kHICommandHide, 1, &appmenu, NULL) != noErr) { g_warning ("%s: retrieving app menu failed", G_STRFUNC); return; } for (list = app_menu_groups; list; list = g_list_next (list)) { IgeMacMenuGroup *list_group = list->data; index += g_list_length (list_group->items); /* adjust index for the separator between groups, but not * before the first group */ if (list_group->items && list->prev) index++; if (group == list_group) { CFStringRef cfstr; /* add a separator before adding the first item, but not * for the first group */ if (!group->items && list->prev) { InsertMenuItemTextWithCFString (appmenu, NULL, index, kMenuItemAttrSeparator, 0); index++; } if (!label) label = get_menu_label_text (GTK_WIDGET (menu_item), NULL); cfstr = CFStringCreateWithCString (NULL, label, kCFStringEncodingUTF8); InsertMenuItemTextWithCFString (appmenu, cfstr, index, 0, 0); SetMenuItemProperty (appmenu, index + 1, IGE_QUARTZ_MENU_CREATOR, IGE_QUARTZ_ITEM_WIDGET, sizeof (menu_item), &menu_item); CFRelease (cfstr); gtk_widget_hide (GTK_WIDGET (menu_item)); group->items = g_list_append (group->items, menu_item); return; } } if (!list) g_warning ("%s: app menu group %p does not exist", G_STRFUNC, group); }