]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
macos: support for macOS-like GTK theme with light and dark variant selection
authorThomas Debesse <dev@illwieckz.net>
Fri, 19 Feb 2021 10:28:12 +0000 (11:28 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 20 Feb 2021 17:06:44 +0000 (18:06 +0100)
CMakeLists.txt
easy-builder
setup/apple/netradiant

index 7e083638b63c6099553b74af7d8fd66dcf7591d8..5ff959dcf2b72a26790b9cb53f61e38d430d1a84 100644 (file)
@@ -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
index 4dbb393f2670bcfe3d214ff930717e11f0f7a512..fb7cabc83bbeec7fab0089b8bfd6d0412bc80d09 100755 (executable)
@@ -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
 
index 9e27101db097a1f771cfd50dc3e3fd323ebe80d9..782f013f0cf1a9170b687d5692d69610cd36366d 100755 (executable)
@@ -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 &