From 20989b89af18c9d3e26de1c8bd50a8f43fed19b4 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 19 Feb 2021 11:28:12 +0100 Subject: [PATCH] macos: support for macOS-like GTK theme with light and dark variant selection --- CMakeLists.txt | 27 ++++++++++++++++++++++++++- easy-builder | 2 +- setup/apple/netradiant | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e083638..5ff959dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,12 @@ set(BUILTINS_LIB_DIR "${BUILTINS_INSTALL_DIR}/lib") set(BUILTINS_PKGCONFIG_DIR "${BUILTINS_INSTALL_DIR}/lib/pkgconfig") option(BUILTIN_GTKGLEXT "Builtin GtkGLExt" OFF) +option(BUILTIN_GTKTHEME_MOJAVE "Builtin Mojave GTK theme" OFF) + +if (APPLE) + set(BUILTIN_GTKGLEXT ON) + set(BUILTIN_GTKTHEME_MOJAVE ON) +endif () set(BUILTIN_GTKGLEXT_BUILT OFF CACHE INTERNAL "...") if (EXISTS "${BUILTINS_INSTALL_DIR}/lib/pkgconfig/gtkglext-1.0.pc") @@ -334,9 +340,11 @@ endif () add_custom_target(builtins) -if (BUILTIN_GTKGLEXT) +if (BUILTIN_GTKGLEXT OR BUILTIN_GTKTHEME_MOJAVE) include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) +endif () +if (BUILTIN_GTKGLEXT) execute_process(COMMAND pkg-config --libs gdk-2.0 gtk+-2.0 glib-2.0 gl OUTPUT_VARIABLE GTKGLEXT_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE @@ -379,6 +387,19 @@ if (BUNDLE_LIBRARIES AND EXISTS ${BUILTINS_LIB_DIR}) set(CMAKE_SKIP_BUILD_RPATH ON) endif() +if (BUILTIN_GTKTHEME_MOJAVE) + ExternalProject_Add(gtktheme-mojave + GIT_REPOSITORY https://github.com/vinceliuice/Mojave-gtk-theme.git + GIT_TAG master + BUILD_IN_SOURCE ON + CONFIGURE_COMMAND echo + BUILD_COMMAND echo + INSTALL_COMMAND ./install.sh -o standard -a standard -s standard -i standard -d "${PROJECT_BINARY_DIR}/themes" + ) + add_dependencies(builtins gtktheme-mojave) + set_target_properties(gtktheme-mojave PROPERTIES EXCLUDE_FROM_ALL ON) +endif () + #----------------------------------------------------------------------- # Libraries #----------------------------------------------------------------------- @@ -511,6 +532,10 @@ if (APPLE) setup/apple/Contents DESTINATION ${APPLE_INSTALL_PREFIX} ) + install(DIRECTORY + ${PROJECT_BINARY_DIR}/themes + DESTINATION ${APPLE_INSTALL_PREFIX}/Contents/Prefix/share + ) install(PROGRAMS setup/apple/netradiant DESTINATION ${APPLE_INSTALL_PREFIX}/Contents/MacOS diff --git a/easy-builder b/easy-builder index 4dbb393f..fb7cabc8 100755 --- a/easy-builder +++ b/easy-builder @@ -83,7 +83,7 @@ done case "$(uname -s)" in 'Darwin') - cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON' + cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON -DBUILTIN_GTKTHEME_MOJAVE=ON' ;; esac diff --git a/setup/apple/netradiant b/setup/apple/netradiant index 9e27101d..782f013f 100755 --- a/setup/apple/netradiant +++ b/setup/apple/netradiant @@ -35,4 +35,18 @@ then export GTK_PATH="${bundle_dir}" fi +if [ "$(defaults read -g AppleInterfaceStyle 2>/dev/null)" = 'Dark' ] +then + color='dark' +else + color='light' +fi + +gtkrc_file="${bundle_dir}/share/themes/Mojave-${color}/gtk-2.0/gtkrc" + +if [ -f "${gtkrc_file}" ] +then + export GTK2_RC_FILES="${gtkrc_file}" +fi + ./netradiant & -- 2.39.2