Refactor folder (#10475)

Move many third-party components' source codes from the src folder to a new folder called deps_src. The goal is to make the code structure clearer and easier to navigate.
This commit is contained in:
SoftFever
2025-08-22 20:02:26 +08:00
committed by GitHub
parent 3808f7eb28
commit 883607e1d4
2083 changed files with 1163 additions and 19503 deletions

30
scripts/.dockerignore Normal file
View File

@@ -0,0 +1,30 @@
Build
Build.bat
/build/
deps/build
MYMETA.json
MYMETA.yml
_build
blib
xs/buildtmp
*.o
*.log
MANIFEST.bak
xs/MANIFEST.bak
xs/assertlib*
.init_bundle.ini
.vs/*
local-lib
/src/TAGS
/.vscode/
build-linux/*
deps/build-linux/*
**/.DS_Store
install_*
build_*/
!build_linux.sh
SVG
scripts/Dockerfile
scripts/DockerBuild.sh
scripts/DockerRun.sh
scripts/.dockerignore

17
scripts/DockerBuild.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
SCRIPT_DIR=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
PROJECT_ROOT=$(dirname "$SCRIPT_DIR")
set -x
# Wishlist hint: For developers, creating a Docker Compose
# setup with persistent volumes for the build & deps directories
# would speed up recompile times significantly. For end users,
# the simplicity of a single Docker image and a one-time compilation
# seems better.
docker build -t orcaslicer \
--build-arg USER=$USER \
--build-arg UID=$(id -u) \
--build-arg GID=$(id -g) \
--build-arg NCORES=$NCORES \
-f "$SCRIPT_DIR/Dockerfile" \
$PROJECT_ROOT

29
scripts/DockerRun.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -x
# Just in case, here's some other things that might help:
# Force the container's hostname to be the same as your workstation
# -h $HOSTNAME \
# If there's problems with the X display, try this
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# If you get an error like "Authorization required, but no authorization protocol specified," run line 9 in your terminal before rerunning this program
# xhost +local:docker
docker run \
`# Use the hosts networking. Printer wifi and also dbus communication` \
--net=host \
`# Some X installs will not have permissions to talk to sockets for shared memory` \
--ipc host \
`# Run as your workstations username to keep permissions the same` \
-u $USER \
`# Bind mount your home directory into the container for loading/saving files` \
-v $HOME:/home/$USER \
`# Pass the X display number to the container` \
-e DISPLAY=$DISPLAY \
`# It seems that libGL and dbus things need privileged mode` \
--privileged=true \
`# Attach tty for running orca slicer with command line things` \
-ti \
`# Clean up after yourself` \
--rm \
`# Pass all parameters from this script to the orca slicer ENTRYPOINT binary` \
orcaslicer $*

100
scripts/Dockerfile Normal file
View File

@@ -0,0 +1,100 @@
FROM docker.io/ubuntu:24.04
LABEL maintainer "DeftDawg <DeftDawg@gmail.com>"
# Disable interactive package configuration
RUN apt-get update && \
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# Add a deb-src
RUN echo deb-src http://archive.ubuntu.com/ubuntu \
$(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) main universe>> /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
autoconf \
build-essential \
cmake \
curl \
eglexternalplatform-dev \
extra-cmake-modules \
file \
git \
gstreamer1.0-plugins-bad \
gstreamer1.0-libav \
libcairo2-dev \
libcurl4-openssl-dev \
libdbus-1-dev \
libglew-dev \
libglu1-mesa-dev \
libglu1-mesa-dev \
libgstreamer1.0-dev \
libgstreamerd-3-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev \
libgtk-3-dev \
libgtk-3-dev \
libsecret-1-dev \
libsoup2.4-dev \
libssl3 \
libssl-dev \
libtool \
libudev-dev \
libwayland-dev \
libwebkit2gtk-4.1-dev \
libxkbcommon-dev \
locales \
locales-all \
m4 \
pkgconf \
sudo \
wayland-protocols \
wget
# Change your locale here if you want. See the output
# of `locale -a` to pick the correct string formatting.
ENV LC_ALL=en_US.utf8
RUN locale-gen $LC_ALL
# Set this so that Orca Slicer doesn't complain about
# the CA cert path on every startup
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
COPY ./ OrcaSlicer
WORKDIR OrcaSlicer
# These can run together, but we run them seperate for podman caching
# Update System dependencies
RUN ./build_linux.sh -u
# Build dependencies in ./deps
RUN ./build_linux.sh -dr
# Build slic3r
RUN ./build_linux.sh -sr
# Build AppImage
ENV container podman
RUN ./build_linux.sh -ir
# It's easier to run Orca Slicer as the same username,
# UID and GID as your workstation. Since we bind mount
# your home directory into the container, it's handy
# to keep permissions the same. Just in case, defaults
# are root.
SHELL ["/bin/bash", "-l", "-c"]
ARG USER=root
ARG UID=0
ARG GID=0
RUN if [[ "$UID" != "0" ]]; then \
# Create group if it doesn't exist \
groupadd -f -g $GID $USER; \
# Check if user with this UID already exists \
if getent passwd $UID > /dev/null 2>&1; then \
echo "User with UID $UID already exists, skipping user creation"; \
else \
useradd -u $UID -g $GID $USER; \
fi \
fi
# Using an entrypoint instead of CMD because the binary
# accepts several command line arguments.
ENTRYPOINT ["/OrcaSlicer/build/package/bin/orca-slicer"]

2
scripts/flatpak/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
builddir
.flatpak-builder

View File

@@ -0,0 +1,3 @@
# OrcaSlicer
This is basically a copy of [com.bambulab.BambuStudio](https://github.com/flathub/com.bambulab.BambuStudio). As such, same rules apply here as does over there.

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
# Work-around https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/754
grep -q org.freedesktop.Platform.GL.nvidia /.flatpak-info && export WEBKIT_DISABLE_DMABUF_RENDERER=1
# Work-around https://github.com/bambulab/BambuStudio/issues/3440
export LC_ALL=C.UTF-8
exec /app/bin/orca-slicer "$@"

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 KiB

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>io.github.softfever.OrcaSlicer</id>
<launchable type="desktop-id">io.github.softfever.OrcaSlicer.desktop</launchable>
<provides>
<id>io.github.softfever.OrcaSlicer.desktop</id>
</provides>
<name>OrcaSlicer</name>
<!-- hehe hadess @ppd
... seriously though, thanks -->
<summary>Get even more perfect prints!</summary>
<developer_name>SoftFever</developer_name>
<url type="homepage">https://github.com/SoftFever/OrcaSlicer</url>
<url type="help">https://github.com/SoftFever/OrcaSlicer/wiki</url>
<url type="bugtracker">https://github.com/SoftFever/OrcaSlicer/issues/</url>
<url type="donation">https://ko-fi.com/SoftFever</url>
<metadata_license>0BSD</metadata_license>
<project_license>AGPL-3.0-only</project_license>
<content_rating type="oars-1.1" />
<requires>
<display_length compare="gt">768</display_length>
</requires>
<recommends>
<control>keyboard</control>
<control>pointing</control>
</recommends>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/1.png</image>
<caption>A model ready to be sliced on a buildplate.</caption>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/2.png
</image>
<caption>A calibration test ready to be printed out.</caption>
</screenshot>
</screenshots>
<description>
<p>A powerful, free and open-source 3D printer slicer that features cutting-edge technology.</p>
</description>
<branding>
<color type="primary" scheme_preference="light">#009688</color>
</branding>
<releases>
<release version="2.0.0-951fc8e" date="2024-01-30"> <url>https://github.com/SoftFever/OrcaSlicer/commit/951fc8e98a0d5ca0ccb254315646ce7889a44836</url>
</release>
</releases>
</component>

View File

@@ -0,0 +1,316 @@
app-id: io.github.softfever.OrcaSlicer
runtime: org.gnome.Platform
runtime-version: "47"
sdk: org.gnome.Sdk
command: entrypoint
separate-locales: true
rename-icon: OrcaSlicer
finish-args:
- --share=ipc
- --socket=x11
- --share=network
- --device=all
- --filesystem=home
- --filesystem=xdg-run/gvfs
- --filesystem=/run/media
- --filesystem=/media
- --filesystem=/run/spnav.sock:ro
# Allow OrcaSlicer to talk to other instances
- --talk-name=io.github.softfever.OrcaSlicer.InstanceCheck.*
- --system-talk-name=org.freedesktop.UDisks2
- --env=SPNAV_SOCKET=/run/spnav.sock
modules:
# JPEG codec for the liveview
- name: gst-plugins-good
buildsystem: meson
config-opts:
- -Dauto_features=disabled
- -Djpeg=enabled
- -Ddoc=disabled
- -Dexamples=disabled
- -Dtests=disabled
sources:
- type: archive
url: https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.22.8.tar.xz
sha256: e305b9f07f52743ca481da0a4e0c76c35efd60adaf1b0694eb3bb021e2137e39
- name: glu
config-opts:
- --disable-static
sources:
- type: archive
url: https://ftp.osuosl.org/pub/blfs/conglomeration/glu/glu-9.0.2.tar.xz
sha256: 6e7280ff585c6a1d9dfcdf2fca489251634b3377bfc33c29e4002466a38d02d4
cleanup:
- /include
- /lib/*.a
- /lib/*.la
- /lib/pkgconfig
- name: kde-extra-cmake-modules
buildsystem: cmake-ninja
sources:
- type: git
url: https://github.com/KDE/extra-cmake-modules
tag: v5.249.0
cleanup:
- /
- name: libspnav
sources:
- type: archive
url: https://github.com/FreeSpacenav/libspnav/releases/download/v1.2/libspnav-1.2.tar.gz
sha256: 093747e7e03b232e08ff77f1ad7f48552c06ac5236316a5012db4269951c39db
- name: orca_wxwidgets
buildsystem: simple
build-commands:
- |
mkdir builddir && cd builddir
cmake ../ -GNinja \
-DwxBUILD_PRECOMP=ON \
-DwxBUILD_TOOLKIT=gtk3 \
-DwxBUILD_DEBUG_LEVEL=0 \
-DwxBUILD_SAMPLES=OFF \
-DwxBUILD_SHARED=ON \
-DwxUSE_MEDIACTRL=ON \
-DwxUSE_DETECT_SM=OFF \
-DwxUSE_UNICODE=ON \
-DwxUSE_PRIVATE_FONTS=ON \
-DwxUSE_OPENGL=ON \
-DwxUSE_WEBREQUEST=ON \
-DwxUSE_WEBVIEW=ON \
-DwxUSE_WEBVIEW_EDGE=OFF \
-DwxUSE_WEBVIEW_IE=OFF \
-DwxUSE_REGEX=builtin \
-DwxUSE_LIBSDL=OFF \
-DwxUSE_XTEST=OFF \
-DwxUSE_STC=OFF \
-DwxUSE_AUI=ON \
-DwxUSE_LIBPNG=sys \
-DwxUSE_ZLIB=sys \
-DwxUSE_LIBJPEG=sys \
-DwxUSE_LIBTIFF=OFF \
-DwxUSE_EXPAT=sys \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:STRING=/app \
-DCMAKE_PREFIX_PATH=/app \
-DCMAKE_BUILD_TYPE=Release
cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS
sources:
- type: git
url: https://github.com/SoftFever/Orca-deps-wxWidgets
branch: master
path: ../
- type: file
path: patches/0001-Enable-using-a-dark-theme-when-Gnome-dark-style-is-s.patch
dest-filename: wxwidgets-dark-theme.patch
- type: shell
commands:
- patch -p1 < wxwidgets-dark-theme.patch
cleanup:
- "*.la"
- "*.a"
- "*.cmake"
- /include
- /app/bin/*
- name: orca_deps
buildsystem: simple
build-commands:
# start build
- |
mkdir -p deps/build_flatpak && cd deps/build_flatpak
cmake ../ \
-DDEP_WX_GTK3=ON \
-DDEP_DOWNLOAD_DIR=/run/build/orca_deps/external-packages \
-DCMAKE_PREFIX_PATH=/app \
-DDESTDIR=/app \
-DFLATPAK=ON \
-DCMAKE_INSTALL_PREFIX=/app
cmake --build . --parallel
rm -rf /run/build/orca_deps/external-packages
cleanup:
- /app/include
- "*.a"
- "*.la"
sources:
# -
# Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* .
# -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest.
#
# NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/
# -
# OrcaSlicer Source Archive
- type: dir
path: ../../
# Blosc
- type: file
url: https://github.com/tamasmeszaros/c-blosc/archive/refs/heads/v1.17.0_tm.zip
dest: external-packages/Blosc
sha256: dcb48bf43a672fa3de6a4b1de2c4c238709dad5893d1e097b8374ad84b1fc3b3
# Cereal
- type: file
url: https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.0.zip
dest: external-packages/Cereal
sha256: 71642cb54658e98c8f07a0f0d08bf9766f1c3771496936f6014169d3726d9657
# CGAL
- type: file
url: https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
dest: external-packages/CGAL
sha256: d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
# GMP
- type: file
url: https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2
dest: external-packages/GMP
sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
# curl
- type: file
url: https://github.com/curl/curl/archive/refs/tags/curl-7_75_0.zip
dest: external-packages/CURL
sha256: a63ae025bb0a14f119e73250f2c923f4bf89aa93b8d4fafa4a9f5353a96a765a
# MPFR
- type: file
url: https://www.mpfr.org/mpfr-4.2.2/mpfr-4.2.2.tar.bz2
dest: external-packages/MPFR
sha256: 9ad62c7dc910303cd384ff8f1f4767a655124980bb6d8650fe62c815a231bb7b
# NLopt
- type: file
url: https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz
dest: external-packages/NLopt
sha256: c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
# OCCT
- type: file
url: https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip
dest: external-packages/OCCT
sha256: 28334f0e98f1b1629799783e9b4d21e05349d89e695809d7e6dfa45ea43e1dbc
# OpenCSG
- type: file
url: https://github.com/floriankirsch/OpenCSG/archive/refs/tags/opencsg-1-4-2-release.zip
dest: external-packages/OpenCSG
sha256: 51afe0db79af8386e2027d56d685177135581e0ee82ade9d7f2caff8deab5ec5
# OpenCV
- type: file
url: https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz
dest: external-packages/OpenCV
sha256: 1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
# OpenEXR
- type: file
url: https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.5.zip
dest: external-packages/OpenEXR
sha256: 0307a3d7e1fa1e77e9d84d7e9a8694583fbbbfd50bdc6884e2c96b8ef6b902de
# OpenSSL
- type: file
url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1w.tar.gz
dest: external-packages/OpenSSL
sha256: 2130e8c2fb3b79d1086186f78e59e8bc8d1a6aedf17ab3907f4cb9ae20918c41
# OpenVDB
- type: file
url: https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip
dest: external-packages/OpenVDB
sha256: f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81
# Qhull
- type: file
url: https://github.com/qhull/qhull/archive/v8.0.1.zip
dest: external-packages/Qhull
sha256: 5287f5edd6a0372588f5d6640799086a4033d89d19711023ef8229dd9301d69b
# TBB
- type: file
url: https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.5.0.zip
dest: external-packages/TBB
sha256: 83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47
# Boost
- type: file
url: https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz
dest: external-packages/Boost
sha256: 4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95
# GLFW
- type: file
url: https://github.com/glfw/glfw/archive/refs/tags/3.3.7.zip
dest: external-packages/GLFW
sha256: e02d956935e5b9fb4abf90e2c2e07c9a0526d7eacae8ee5353484c69a2a76cd0
# libnoise
- type: file
url: https://github.com/SoftFever/Orca-deps-libnoise/archive/refs/tags/1.0.zip
dest: external-packages/libnoise
sha256: 96ffd6cc47898dd8147aab53d7d1b1911b507d9dbaecd5613ca2649468afd8b6
- name: OrcaSlicer
buildsystem: simple
build-commands:
- |
mkdir -p build_flatpak
CXXFLAGS=-std=gnu++20 cmake . -B build_flatpak \
-DSLIC3R_PCH=OFF \
-DSLIC3R_FHS=ON \
-DSLIC3R_GTK=3 \
-DSLIC3R_STATIC=ON \
-DSLIC3R_BUILD_TESTS=OFF \
-DSLIC3R_DESKTOP_INTEGRATION=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DFLATPAK=ON \
-DBBL_RELEASE_TO_PUBLIC=1 \
-DCMAKE_PREFIX_PATH=/app \
-DCMAKE_INSTALL_PREFIX=/app
CXXFLAGS=-std=gnu++20 cmake --build build_flatpak --target OrcaSlicer -j$FLATPAK_BUILDER_N_JOBS
./scripts/run_gettext.sh
CXXFLAGS=-std=gnu++20 cmake --build build_flatpak --target install -j$FLATPAK_BUILDER_N_JOBS
cleanup:
- /include
post-install:
- | # Desktop Integration files
install -Dm644 -t /app/share/icons/hicolor/scalable/apps/ resources/images/OrcaSlicer.svg
install -Dm644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml
mv /app/share/applications/OrcaSlicer.desktop /app/share/applications/${FLATPAK_ID}.desktop
desktop-file-edit --set-key=Exec --set-value="entrypoint %U" /app/share/applications/${FLATPAK_ID}.desktop
install -Dm755 entrypoint /app/bin
install -Dm755 umount /app/bin
sources:
# -
# Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* .
# -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest.
#
# NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/
# -
# OrcaSlicer Source Archive
- type: dir
path: ../../
# AppData metainfo for Gnome Software & Co.
- type: file
path: io.github.softfever.OrcaSlicer.metainfo.xml
# start-up script
- type: file
path: entrypoint
# umount wrapper used to redirect umount calls to udisk2
- type: file
path: umount

View File

@@ -0,0 +1,164 @@
From f0135d9c3faf0207f7100991ccf512f228b90570 Mon Sep 17 00:00:00 2001
From: Paul Cornett <paulcor@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:42:58 -0700
Subject: [PATCH] Enable using a dark theme when Gnome "dark style" is set
The dark style setting does not cause a dark theme to be used
automatically, so request it explicitly.
Co-authored-by: Colin Kinloch
---
src/gtk/settings.cpp | 118 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 117 insertions(+), 1 deletion(-)
diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp
index 3047247737..f13ea2ef24 100644
--- a/src/gtk/settings.cpp
+++ b/src/gtk/settings.cpp
@@ -183,6 +183,64 @@ static void notify_gtk_font_name(GObject*, GParamSpec*, void*)
}
}
+static bool UpdatePreferDark(GVariant* value)
+{
+ // 0: No preference, 1: Prefer dark appearance, 2: Prefer light appearance
+ gboolean preferDark = g_variant_get_uint32(value) == 1;
+
+ GtkSettings* settings = gtk_settings_get_default();
+ char* themeName;
+ gboolean preferDarkPrev;
+ g_object_get(settings,
+ "gtk-theme-name", &themeName,
+ "gtk-application-prefer-dark-theme", &preferDarkPrev, nullptr);
+
+ // We don't need to enable prefer-dark if the theme is already dark
+ if (strstr(themeName, "-dark") || strstr(themeName, "-Dark"))
+ preferDark = false;
+ g_free(themeName);
+
+ const bool changed = preferDark != preferDarkPrev;
+ if (changed)
+ {
+ g_object_set(settings,
+ "gtk-application-prefer-dark-theme", preferDark, nullptr);
+ }
+ return changed;
+}
+
+// "g-signal" from GDBusProxy
+extern "C" {
+static void
+proxy_g_signal(GDBusProxy*, const char*, const char* signal_name, GVariant* parameters, void*)
+{
+ if (strcmp(signal_name, "SettingChanged") != 0)
+ return;
+
+ const char* nameSpace;
+ const char* key;
+ GVariant* value;
+ g_variant_get(parameters, "(&s&sv)", &nameSpace, &key, &value);
+ if (strcmp(nameSpace, "org.freedesktop.appearance") == 0 &&
+ strcmp(key, "color-scheme") == 0)
+ {
+ if (UpdatePreferDark(value))
+ {
+ for (int i = wxSYS_COLOUR_MAX; i--;)
+ gs_systemColorCache[i].UnRef();
+
+ for (auto* win: wxTopLevelWindows)
+ {
+ wxSysColourChangedEvent event;
+ event.SetEventObject(win);
+ win->HandleWindowEvent(event);
+ }
+ }
+ }
+ g_variant_unref(value);
+}
+}
+
// Some notes on using GtkStyleContext. Style information from a context
// attached to a non-visible GtkWidget is not accurate. The context has an
// internal visibility state, controlled by the widget, which it presumably
@@ -1124,12 +1182,68 @@ bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
class wxSystemSettingsModule: public wxModule
{
public:
- virtual bool OnInit() wxOVERRIDE { return true; }
+ virtual bool OnInit() wxOVERRIDE;
virtual void OnExit() wxOVERRIDE;
+
+#ifdef __WXGTK3__
+ GDBusProxy* m_proxy;
+#endif
wxDECLARE_DYNAMIC_CLASS(wxSystemSettingsModule);
};
wxIMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule);
+bool wxSystemSettingsModule::OnInit()
+{
+#ifdef __WXGTK3__
+ // Gnome has gone to a dark style setting rather than a selectable dark
+ // theme, available via GSettings as the 'color-scheme' key under the
+ // 'org.gnome.desktop.interface' schema. It's also available via a "portal"
+ // (https://docs.flatpak.org/en/latest/portal-api-reference.html), which
+ // has the advantage of allowing the setting to be accessed from within a
+ // virtualized environment such as Flatpak. Since the setting does not
+ // change the theme, we propagate it to the GtkSettings
+ // 'gtk-application-prefer-dark-theme' property to get a dark theme.
+
+ m_proxy = nullptr;
+
+ if (getenv("ORCA_SLICER_DARK_THEME") != nullptr) {
+ /* 1 for prefer dark */
+ GVariant *value = g_variant_new_uint32(1);
+ UpdatePreferDark(value);
+ g_variant_unref(value);
+ }
+ // GTK_THEME environment variable overrides other settings
+ else if (getenv("GTK_THEME") == nullptr)
+ {
+ m_proxy = g_dbus_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr,
+ "org.freedesktop.portal.Desktop",
+ "/org/freedesktop/portal/desktop",
+ "org.freedesktop.portal.Settings",
+ nullptr, nullptr);
+ }
+ if (m_proxy)
+ {
+ g_signal_connect(m_proxy, "g-signal", G_CALLBACK(proxy_g_signal), nullptr);
+
+ GVariant* ret = g_dbus_proxy_call_sync(m_proxy, "Read",
+ g_variant_new("(ss)", "org.freedesktop.appearance", "color-scheme"),
+ G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr);
+ if (ret)
+ {
+ GVariant* child;
+ g_variant_get(ret, "(v)", &child);
+ GVariant* value = g_variant_get_variant(child);
+ UpdatePreferDark(value);
+ g_variant_unref(value);
+ g_variant_unref(child);
+ g_variant_unref(ret);
+ }
+ }
+#endif // __WXGTK3__
+ return true;
+}
+
void wxSystemSettingsModule::OnExit()
{
#ifdef __WXGTK3__
@@ -1141,6 +1255,8 @@ void wxSystemSettingsModule::OnExit()
g_signal_handlers_disconnect_by_func(settings,
(void*)notify_gtk_font_name, NULL);
}
+ if (m_proxy)
+ g_object_unref(m_proxy);
#endif
if (gs_tlw_parent)
{
--
2.49.0

View File

@@ -0,0 +1,15 @@
#! /bin/bash
sudo apt update
sudo apt install build-essential flatpak flatpak-builder gnome-software-plugin-flatpak -y
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.gnome.Platform//46 org.gnome.Sdk//46
##
# in OrcaSlicer folder, run following command to build Orca
# # First time build
# flatpak-builder --state-dir=.flatpak-builder --keep-build-dirs --user --force-clean build-dir scripts/flatpak/io.github.softfever.OrcaSlicer.yml
# # Subsequent builds (only rebuilding OrcaSlicer)
# flatpak-builder --state-dir=.flatpak-builder --keep-build-dirs --user build-dir scripts/flatpak/io.github.softfever.OrcaSlicer.yml --build-only=OrcaSlicer

10
scripts/flatpak/umount Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env sh
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
DEVICE=$(basename $(findmnt -oSOURCE -n "$@") )
exec /usr/bin/gdbus call -y -d org.freedesktop.UDisks2 -o /org/freedesktop/UDisks2/block_devices/$DEVICE -m org.freedesktop.UDisks2.Filesystem.Unmount "{'b': <'false'>}" 1> /dev/null

View File

@@ -0,0 +1,3 @@
Files in this directory are named for the **exact** output of `awk -F= '/^ID=/ {print $2}' /etc/os-release` for their respective distribution.
When `build_linux.sh` is executed, the respective file for the distribution will be sourced so the distribution specific instructions/logic are used.

45
scripts/linux.d/arch Normal file
View File

@@ -0,0 +1,45 @@
# these are the Arch Linux specific build functions
FOUND_GTK3=$(pacman -Q gtk3)
# Addtional Dev packages for OrcaSlicer
export REQUIRED_DEV_PACKAGES=(
cmake
curl
dbus
eglexternalplatform
extra-cmake-modules
file
gettext
git
glew
gstreamer
gstreamermm
gtk3
libmspack
libsecret
libspnav
mesa
ninja
openssl
texinfo
wayland-protocols
webkit2gtk
wget
)
if [[ -n "$UPDATE_LIB" ]]
then
echo -n -e "Updating linux ...\n"
NEEDED_PKGS=""
for PKG in ${REQUIRED_DEV_PACKAGES[@]}; do
pacman -Q ${PKG} > /dev/null || NEEDED_PKGS+=" ${PKG}"
done
if [ -n "${NEEDED_PKGS}" ]; then
sudo pacman -Syy --noconfirm ${NEEDED_PKGS}
fi
echo -e "done\n"
exit 0
fi
FOUND_GTK3_DEV=${FOUND_GTK3}

View File

@@ -0,0 +1,33 @@
# these are the Clear Linux specific build functions
FOUND_GTK3=$(ls /usr/lib64/libgtk-3.so.* 2>/dev/null | tail -n 1 || true)
# Addtional bundles for OrcaSlicer
export REQUIRED_BUNDLES=(
c-basic
dev-utils
devpkg-curl
devpkg-glew
devpkg-glu
devpkg-gstreamer
devpkg-gtk3
devpkg-libmspack
devpkg-libsecret
devpkg-openssl
devpkg-webkitgtk
file
git
lib-opengl
perl-basic
texinfo
wget
)
if [[ -n "$UPDATE_LIB" ]]
then
echo "Updating linux ..."
echo swupd bundle-add -y ${REQUIRED_BUNDLES[@]}
echo -e "done\n"
exit 0
fi
FOUND_GTK3_DEV=$(ls /usr/lib64/libgtk-3.so 2>/dev/null || true)

63
scripts/linux.d/debian Normal file
View File

@@ -0,0 +1,63 @@
FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3 || echo '')
REQUIRED_DEV_PACKAGES=(
autoconf
build-essential
cmake
eglexternalplatform-dev
extra-cmake-modules
file
gettext
git
libcurl4-openssl-dev
libdbus-1-dev
libglew-dev
libgstreamerd-3-dev
libgtk-3-dev
libmspack-dev
libsecret-1-dev
libspnav-dev
libssl-dev
libtool
libudev-dev
ninja-build
texinfo
wget
)
if [[ -n "$UPDATE_LIB" ]]
then
source /etc/os-release
if [ "${ID}" == "ubuntu" ] && [ -n "${VERSION_ID}" ]; then
# It's ubuntu and we have a VERSION_ID like "24.04".
if dpkg --compare-versions "${VERSION_ID}" ge 22 && dpkg --compare-versions "${VERSION_ID}" lt 24 ;
then
# Some extra packages needed on Ubuntu 22.x and 23.x:
REQUIRED_DEV_PACKAGES+=(curl libfuse-dev libssl-dev libcurl4-openssl-dev m4)
fi
fi
if [[ -n "$BUILD_DEBUG" ]]
then
REQUIRED_DEV_PACKAGES+=(libssl-dev libcurl4-openssl-dev)
fi
# check which version of libwebkit2gtk is available
if [ "$(apt show --quiet libwebkit2gtk-4.0-dev 2>/dev/null)" != "" ]
then
REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.0-dev)
else
REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.1-dev)
fi
# TODO: optimize this by checking which, if any, packages are already installed
# install them all at once
sudo apt update
sudo apt install -y ${REQUIRED_DEV_PACKAGES[@]}
echo -e "done\n"
exit 0
fi
FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '')

49
scripts/linux.d/fedora Normal file
View File

@@ -0,0 +1,49 @@
FOUND_GTK3=$(rpm -qa | grep -P '^gtk3' || true)
REQUIRED_DEV_PACKAGES=(
autoconf
automake
cmake
dbus-devel
eglexternalplatform-devel
extra-cmake-modules
file
gcc
gcc-c++
gettext
git
gstreamer1-devel
gstreamermm-devel
gtk3-devel
libmspack-devel
libquadmath-devel
libsecret-devel
libspnav-devel
libtool
m4
mesa-libGLU-devel
ninja-build
openssl-devel
perl-FindBin
texinfo
wayland-protocols-devel
webkit2gtk4.0-devel
wget
libcurl-devel
)
if [[ -n "$UPDATE_LIB" ]]
then
NEEDED_PKGS=""
for PKG in ${REQUIRED_DEV_PACKAGES[@]}; do
rpm -q ${PKG} > /dev/null || NEEDED_PKGS+=" ${PKG}"
done
if [ -n "${NEEDED_PKGS}" ]; then
sudo dnf install -y ${NEEDED_PKGS}
fi
echo -e "done\n"
exit 0
fi
FOUND_GTK3_DEV=$(rpm -qa | grep -P '^gtk3-devel' || true)

35
scripts/run_gettext.bat Normal file
View File

@@ -0,0 +1,35 @@
@echo off
REM OrcaSlicer gettext
REM Created by SoftFever on 27/5/23.
REM Check for --full argument
set FULL_MODE=0
for %%a in (%*) do (
if "%%a"=="--full" set FULL_MODE=1
)
if %FULL_MODE%==1 (
.\tools\xgettext.exe --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost -f ./localization/i18n/list.txt -o ./localization/i18n/OrcaSlicer.pot
python scripts/HintsToPot.py ./resources ./localization/i18n
)
REM Print the current directory
echo %cd%
set pot_file="./localization/i18n/OrcaSlicer.pot"
REM Run the script for each .po file
for /r "./localization/i18n/" %%f in (*.po) do (
call :processFile "%%f"
)
goto :eof
:processFile
set "file=%~1"
set "dir=%~dp1"
set "name=%~n1"
set "lang=%name:OrcaSlicer_=%"
if %FULL_MODE%==1 (
.\tools\msgmerge.exe -N -o "%file%" "%file%" "%pot_file%"
)
if not exist "./resources/i18n/%lang%" mkdir "./resources/i18n/%lang%"
.\tools\msgfmt.exe --check-format -o "./resources/i18n/%lang%/OrcaSlicer.mo" "%file%"
goto :eof

41
scripts/run_gettext.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
# OrcaSlicer gettext
# Created by SoftFever on 27/5/23.
#
# Check for --full argument
FULL_MODE=false
for arg in "$@"
do
if [ "$arg" = "--full" ]; then
FULL_MODE=true
fi
done
if $FULL_MODE; then
xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost -f ./localization/i18n/list.txt -o ./localization/i18n/OrcaSlicer.pot
python3 scripts/HintsToPot.py ./resources ./localization/i18n
fi
echo "$0: working dir = $PWD"
pot_file="./localization/i18n/OrcaSlicer.pot"
for dir in ./localization/i18n/*/
do
dir=${dir%*/} # remove the trailing "/"
lang=${dir##*/} # extract the language identifier
if [ -f "$dir/OrcaSlicer_${lang}.po" ]; then
if $FULL_MODE; then
msgmerge -N -o "$dir/OrcaSlicer_${lang}.po" "$dir/OrcaSlicer_${lang}.po" "$pot_file"
fi
mkdir -p "resources/i18n/${lang}"
msgfmt --check-format -o "resources/i18n/${lang}/OrcaSlicer.mo" "$dir/OrcaSlicer_${lang}.po"
# Check the exit status of the msgfmt command
if [ $? -ne 0 ]; then
echo "Error encountered with msgfmt command for language ${lang}."
exit 1 # Exit the script with an error status
fi
fi
done