Re: [Gtk-osx-users] menu synchronisation



On Apr 2, 2010, at 11:03 PM, Olivier Sessink wrote:

> John Ralls wrote:
> 
>> OK, I get it.
>> 
>> You can try moving
>>    if (GTK_IS_CHECK_MENU_ITEM (menu_item))
>> 	carbon_menu_item_update_active (carbon_item, menu_item);
>> 
>> from 630 in carbon_menu_item_create, to 932 in sync_menu_shell before 
>> 	if (GTK_IS_CHECK_MENU_ITEM(carbon_item) && carbon_item
>> 	if (!carbon_item->submenu) {
>> 	    carbon_index++;
>> 	    continue;
>> 	}
> 
> tried that, and I added a g_print() to carbon_menu_item_update_active()
> to show the state that needs to be set. In the console I see a lot of
> 'active=1', but none of the menu items is actually showing an activated
> state... Any ideas?
> 

Does that mean that moving the call to carbon_menu_item_update_active has broken the sync on menu creation as well? If you switch from a document that has a particular menu item checked to one that doesn't (shouldn't?), does the checkmark get turned off? 

Add the following to get the carbon menu item's title and add it to your g_print:

CFStringRef cfstr;
gchar *label;
OSStatus err;
err = CopyMenuItemTextAsCFString(carbon_item->menu, carbon_item->index, &cfstr);
if (!err) {
  label = CFStringGetCStringPtr(cfstr, kCFStringEncodingUTF8);
  g_print ("Menu Item %s active %d\n", label, active);
}
else
  g_print ("Unable to retrieve menu item label, %s\n", carbon_menu_error_string(err));
if (cfstr)
  CFRelease (cfstr);

to see that the right menu item is having CheckMenuItem called on it.

(I didn't test that; the docs for Menu Manager are at http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Menu_Manager/Reference/reference.html
and for CFString at
http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html)

Regards,
John Ralls





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]