GNOME Bugzilla – Bug 477381
Use the Mac OS X menubar when built with GTK+/Quartz
Last modified: 2018-05-22 13:23:01 UTC
I have been working on building gnumeric using GTK+/Quartz (no X11) [1]. A developer at Imendio has written a function that allows GTK+/Quartz applications to use the Mac OS X menubar [2]. I have written a patch to gnumeric to take advantage of this function to integrate gnumeric more completely into the Mac OS X environment. The steps I take to build gnumeric using GTK+/Quartz are documented at [3]. [1] http://developer.imendio.com/projects/gtk-macosx [2] http://developer.imendio.com/projects/gtk-macosx/menubar [3] http://flyn.org/apple/
Created attachment 95663 [details] [review] Patch to use Mac OS X menubar
Intersting. Most of it looks like it belongs in gtk+, though.
Very interesting. If you get a native build please tell us how to regenerate. However, Morten is correct. The native code belongs in gtk, or at worst libgoffice. I don't like #ifdefs, but that's small enough that it could go in. Any screenshots ?
I do have some crude instructions at http://www.flyn.org/apple/index.html. Also, there is a screenshot of GTK+/Quartz gnumeric at http://www.flyn.org/apple/screenshots/gnumeric.png.
Imendio is working on a new library to replace their sync-menu code. See http://developer.imendio.com/projects/gtk-macosx/integration . I asked the developer a bit about future plans for the code and his response may be found at http://developer.imendio.com/node/216 .
Created attachment 111381 [details] [review] Patch to use Mac OS X menubar This is a new patch against 1.9.0 that uses the new Imendio library.
Created attachment 111461 [details] [review] Patch to use Mac OS X menubar This moves the "Quit" menu item to the application menu (a Mac OS X convention) and hides the GTK+ menu.
Created attachment 111462 [details] [review] Patch to use Mac OS X menubar Replaces previous patch because I uploaded the wrong file.
For reference, Inkscape uses the Imendio Mac OS X menu library, though they include ige-mac-menu.c and ige-mac-menu.h directly in their source tree.
Apparently ige library is not actively maintained for a while. There is a plan to integrate ige-mac-menu xxx into Global Menu at http://code.google.com/p/gnome2-globalmenu/issues/detail?id=136 If anyone wants to make effort on this? the gtk module won't require anything to be modified with GTK, and it will be transparent: once the module is loaded, menu go to mac, unloaded, they come back to the application.
Created attachment 158350 [details] [review] Patch to use Mac OS X menubar This patch is against gnumeric 1.10.1. Work on the IGE library has resumed. See http://gtk-osx.sourceforge.net/.
Building on the previous work, I was able to make a new patch (using the MacPorts convention) that uses the newer gtk-osx-application. This is not intended to be patched into the gnumeric code base but rather at the MacPorts level, but I still put it here for study and review. There are still a couple problems, trying to move Help and Preferences segfaults, and Quit does not want to be hidden (Gtk-CRITICAL **: void gtk_widget_hide(GtkWidget *): assertion `GTK_IS_WIDGET (widget)' failed). Opening a new workbook causes the terminal to throw a tantrum since the menu object has already been sent to OS X, but still works in the end (this might be a bug in gtk-osx-application). However, any general advise would be well appreciated. Comment 2 states that this belongs in Gtk, and it probably does, but the gtk-osx-application documentation states it currently has to be done in the application itself.
Created attachment 254433 [details] [review] use gtk-osx-application api This is experimental.
P.S. Contrary to the gtk-osx-application documentation, the order of gtkosx_application_set_help_menu and gtkosx_application_set_window_menu doesn't seem to make any difference in putting them in the correct order on the menubar (probably another gtk-osx-application bug).
Created attachment 254437 [details] [review] use gtk-osx-application api Now that I have been able to look over this again, I found that most of the problems in Comment 12 were due to typos in the "/menubar/*" parameters. It still throws errors when opening a second window, and the windows/help menus are still out of order. I still don't know how to remove/hide the separators in the original menu structures other than to make a patch that removes them from GNOME_Gnumeric-gtk-xml.in
Created attachment 254902 [details] [review] use gtk-osx-application api I found that by putting this functionality at the end of the UI setup function, the Toolbars submenu reappears, and things seem to work a bit better. This also adds the Gnumeric icon to the dock, and tidies up a few other things. It is probably the last update I will include here. There seem to be efforts to remake gtkosx-application functionality into part of the official quartz backend in Gtk3. However, for study and review, here it is.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnumeric/issues/81.