From d66a11f144601d1bb2fb0007e3e4463a393b6bd3 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 29 May 2019 19:28:02 +0000 Subject: macOS: gtk-mac-integration --- src/widgets/desktop-widget.cpp | 19 +++++++++++++++++++ src/widgets/desktop-widget.h | 2 ++ 2 files changed, 21 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 32ca1bac2..f4e278a5a 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -79,6 +79,9 @@ #include "toolbox.h" #include "widget-sizes.h" +#ifdef GDK_WINDOWING_QUARTZ +#include +#endif using Inkscape::DocumentUndo; using Inkscape::UI::Widget::UnitTracker; @@ -928,6 +931,17 @@ sp_desktop_widget_realize (GtkWidget *widget) window->get_style_context()->remove_class("symbolic"); } } + +#ifdef GDK_WINDOWING_QUARTZ + // native macOS menu + auto osxapp = gtkosx_application_get(); + auto menushell = static_cast(dtw->menubar()); + if (osxapp && menushell && window) { + menushell->set_parent(*window); + gtkosx_application_set_menu_bar(osxapp, menushell->gobj()); + gtkosx_application_set_use_quartz_accelerators(osxapp, false); + } +#endif } /* This is just to provide access to common functionality from sp_desktop_widget_realize() above @@ -1691,7 +1705,12 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPDocument *document) dtw->_menubar = build_menubar(dtw->desktop); dtw->_menubar->set_name("MenuBar"); dtw->_menubar->show_all(); + +#ifdef GDK_WINDOWING_QUARTZ + // native macOS menu: do this later because we don't have the window handle yet +#else dtw->_vbox->pack_start(*dtw->_menubar, false, false); +#endif dtw->layoutWidgets(); diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index f0b42222d..d21ba7bb8 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -269,6 +269,8 @@ public: void updateTitle(gchar const *uri); bool onFocusInEvent(GdkEventFocus*); + Gtk::MenuBar *menubar() { return _menubar; } + Inkscape::UI::Widget::Dock* getDock(); static GType getType(); -- cgit v1.2.3