diff --git a/CMakeLists.txt b/CMakeLists.txt index cebc873a..6efd2a23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,14 @@ if (WIN32) message ("Automatically set ENABLE_MATHTEX OFF on Windows") endif () +# Mac integration +pkg_check_modules (MacIntegration "gtk-mac-integration") +if (MacIntegration_FOUND) + message("Enable Mac integration") + add_includes_ldflags ("${MacIntegration_LDFLAGS}" "${MacIntegration_INCLUDE_DIRS}") + add_definitions(-DMAC_INTEGRATION) +endif () + # Unstable features option (UNSTABLE_HIGHDPI_FIXES "HighDPI Fixes (unstable)" OFF) @@ -199,7 +207,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Install icons install(FILES ui/pixmaps/xournalpp.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps) - + # Symlink are not easy to use with CMake, therefor simple install a copy... install(FILES ui/pixmaps/application-x-xopp.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/mimetypes/) @@ -223,7 +231,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mimelnk/application) install(FILES desktop/x-xopt.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mimelnk/application) - + install(FILES desktop/xournalpp.thumbnailer DESTINATION ${CMAKE_INSTALL_PREFIX}/share/thumbnailers) install(PROGRAMS utility/usr/local/bin/xopp-recording.sh diff --git a/mac-setup/.gitignore b/mac-setup/.gitignore index ce27e251..373d7cbe 100644 --- a/mac-setup/.gitignore +++ b/mac-setup/.gitignore @@ -8,3 +8,4 @@ openjpeg* gtk-mac-bundler .xournalpp* *.zip +gtk-mac-integration diff --git a/mac-setup/README.md b/mac-setup/README.md index 1e925ca3..2a0d8f07 100644 --- a/mac-setup/README.md +++ b/mac-setup/README.md @@ -3,10 +3,12 @@ Do not install macports or homebrew. If you have installed it, you need to create a new user, and use this for the whole process. jhbuild does not work, if there is such an environment installed. -### Make sure the Development environement is installed +### Make sure the Development environment is installed Open a Terminal, and type in **git**, confirm popup from Appstore with "Install" to install development tools. -### Build GTK +### Build Libraries, needs to be once + +#### 1. Build GTK Execute in this folder. ````bash ./build-gtk3.sh @@ -19,6 +21,23 @@ Execute $HOME/gtk/inst/bin/python setup.py install ```` +Build again. It should now build +````bash +./build-gtk3.sh +```` + +#### 2. Build Poppler +Execute in this folder. +````bash +./build-poppler.sh +```` + +#### 3. Build Mac integration +Execute in this folder. +````bash +./build-mac-integration.sh +```` + ### Build Xournal++ ````bash export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" diff --git a/mac-setup/build-app.sh b/mac-setup/build-app.sh index e46951a7..d47bcde2 100755 --- a/mac-setup/build-app.sh +++ b/mac-setup/build-app.sh @@ -55,7 +55,10 @@ for locale in "${supportedLocales[@]}" ; do mkdir -p setup/share/locale/$locale/LC_MESSAGES # Xournal Translation - cp -r ../build/po/$locale.gmo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/xournalpp.mo + cp ../build/po/$locale.gmo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/xournalpp.mo + + # Mac Integration + cp $HOME/gtk/inst/share/locale/zh_CN/LC_MESSAGES/gtk-mac-integration.mo ./Xournal++.app/Contents/Resources/share/locale/$locale/LC_MESSAGES/gtk-mac-integration.mo done echo "Create zip" diff --git a/mac-setup/build-mac-integration.sh b/mac-setup/build-mac-integration.sh new file mode 100755 index 00000000..779a4f1b --- /dev/null +++ b/mac-setup/build-mac-integration.sh @@ -0,0 +1,12 @@ +export PATH="$HOME/.local/bin:$HOME/gtk/inst/bin:$PATH" + +rm -rf ./gtk-mac-integration +git clone https://gitlab.gnome.org/GNOME/gtk-mac-integration.git + +cd ./gtk-mac-integration +./autogen.sh +./configure --prefix=$HOME/gtk/inst +make -j4 +make install + +cd .. diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index bc693c20..c90678ee 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -22,6 +22,10 @@ #include #include +#ifdef MAC_INTEGRATION +#include +#endif + #include MainWindow::MainWindow(GladeSearchpath* gladeSearchPath, Control* control) @@ -128,6 +132,23 @@ MainWindow::MainWindow(GladeSearchpath* gladeSearchPath, Control* control) gtk_drag_dest_add_text_targets(this->window); LayerCtrlListener::registerListener(control->getLayerController()); + +#ifdef MAC_INTEGRATION + GtkosxApplication* osxApp = gtkosx_application_get(); + + GtkWidget* menubar = get("mainMenubar"); + gtk_widget_hide(menubar); + gtkosx_application_set_menu_bar(osxApp, GTK_MENU_SHELL(menubar)); + + g_signal_connect(osxApp, "NSApplicationWillTerminate", G_CALLBACK( + +[](GtkosxApplication* osxApp, MainWindow* self) + { + XOJ_CHECK_TYPE_OBJ(self, MainWindow); + self->control->quit(); + }), this); + + gtkosx_application_ready(osxApp); +#endif } MainWindow::~MainWindow()