From a92eaa4c1bffc97db037328249b52a0740651a07 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 28 May 2025 20:30:10 +0200 Subject: gui: reintroduce settings schemas --- cmake/Modules/Glib.cmake | 23 ++++++++++++----------- gui/CMakeLists.txt | 24 ++++++++++++++++++++++++ gui/ch.arknet.Turns.gschema.xml | 27 +++++++++++++++++++++++++++ gui/gschema.xml | 27 --------------------------- gui/include/settings.hpp | 8 ++++---- gui/src/main.cpp | 4 ++++ gui/src/settings.cpp | 10 +++++----- 7 files changed, 76 insertions(+), 47 deletions(-) create mode 100644 gui/ch.arknet.Turns.gschema.xml delete mode 100644 gui/gschema.xml diff --git a/cmake/Modules/Glib.cmake b/cmake/Modules/Glib.cmake index 0e5ab61..8707f06 100644 --- a/cmake/Modules/Glib.cmake +++ b/cmake/Modules/Glib.cmake @@ -192,6 +192,10 @@ function(glib_add_schemas TARGET) message(FATAL_ERROR "Glib: Target '${TARGET}' does not exist") endif() + if(NOT _SCHEMA_DIR) + set(_SCHEMA_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + if(NOT IS_ABSOLUTE "${_SCHEMA_DIR}") get_filename_component(_SCHEMA_DIR "${_SCHEMA_DIR}" REALPATH) endif() @@ -200,24 +204,21 @@ function(glib_add_schemas TARGET) message(FATAL_ERROR "Glib: Directory '${_SCHEMA_DIR}' does not exists") endif() - file(GLOB SCHAMA_FILES CONFIGURE_DEPENDS "${_SCHEMA_DIR}/*.gschema.xml") + file(GLOB SCHEMA_FILES CONFIGURE_DEPENDS "${_SCHEMA_DIR}/*.gschema.xml") - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas/gschemas.compiled" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + set(OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas") + set(OUTPUT_FILE "${OUTPUT_DIRECTORY}/gschemas.compiled") + + add_custom_command(OUTPUT "${OUTPUT_FILE}" COMMAND "${GLIB_COMPILE_SCHEMAS_BIN}" - ARGS - "--targetdir=${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas" + "--targetdir=${OUTPUT_DIRECTORY}" "--strict" "${_SCHEMA_DIR}" - VERBATIM COMMENT "Compiling gsettings schemas" - DEPENDS - ${SCHEMA_FILES} + DEPENDS ${SCHEMA_FILES} ) - add_custom_target("${TARGET}_schemas" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas/gschemas.compiled") - - add_dependencies("${TARGET}" "${TARGET}_schemas") + target_sources("${TARGET}" PRIVATE "${OUTPUT_DIRECTORY}/gschemas.compiled") endfunction() diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index d9d3410..3753979 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -62,6 +62,28 @@ target_compile_definitions("resources" PUBLIC "LOCALEDIR=\"$,${CMAKE_INSTALL_FULL_LOCALEDIR},${CMAKE_CURRENT_BINARY_DIR}/locale>\"" ) +# Library + +add_library("gui_impl" + "src/settings.cpp" +) + +target_include_directories("gui_impl" PUBLIC + "include" +) + +target_link_libraries("gui_impl" PUBLIC + "resources" + "adwaitamm::adwaitamm" + "turns::mm" +) + +target_compile_definitions("gui_impl" PUBLIC + "$<$>:SCHEMADIR=\"${CMAKE_CURRENT_BINARY_DIR}\">" +) + +glib_add_schemas("gui_impl") + # Application add_executable("gui" "src/main.cpp") @@ -77,6 +99,8 @@ target_include_directories("gui" PUBLIC ) target_link_libraries("gui" PUBLIC + "gui_impl" + "adwaitamm::adwaitamm" "PkgConfig::glib" "PkgConfig::glibmm" diff --git a/gui/ch.arknet.Turns.gschema.xml b/gui/ch.arknet.Turns.gschema.xml new file mode 100644 index 0000000..bea1f8b --- /dev/null +++ b/gui/ch.arknet.Turns.gschema.xml @@ -0,0 +1,27 @@ + + + + + + + '#33d17a' + Friendly Disposition Color + The color used to shade friendly participants. + + + '#e01b24' + Hostile Disposition Color + The color used to shade hostile participants. + + + '#9141ac' + Secret Disposition Color + The color used to shade secret participants. + + + false + Skip Defeated Participants + Whether or not defeated participants shall be skipped while stepping through the turn order. + + + \ No newline at end of file diff --git a/gui/gschema.xml b/gui/gschema.xml deleted file mode 100644 index bea1f8b..0000000 --- a/gui/gschema.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - '#33d17a' - Friendly Disposition Color - The color used to shade friendly participants. - - - '#e01b24' - Hostile Disposition Color - The color used to shade hostile participants. - - - '#9141ac' - Secret Disposition Color - The color used to shade secret participants. - - - false - Skip Defeated Participants - Whether or not defeated participants shall be skipped while stepping through the turn order. - - - \ No newline at end of file diff --git a/gui/include/settings.hpp b/gui/include/settings.hpp index 70e429a..668758f 100644 --- a/gui/include/settings.hpp +++ b/gui/include/settings.hpp @@ -3,14 +3,14 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#ifndef TURNS_CORE_SETTINGS_HPP -#define TURNS_CORE_SETTINGS_HPP +#ifndef TURNS_GUI_SETTINGS_HPP +#define TURNS_GUI_SETTINGS_HPP #include #include -namespace turns::core +namespace Turns::gui { namespace settings::key { @@ -21,6 +21,6 @@ namespace turns::core } // namespace settings::key auto get_settings() -> Glib::RefPtr; -} // namespace turns::core +} // namespace Turns::gui #endif \ No newline at end of file diff --git a/gui/src/main.cpp b/gui/src/main.cpp index a4dd2ae..8c20b31 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -3,6 +3,8 @@ * SPDX-License-Identifier: LGPL-2.1-only */ +#include "settings.hpp" + #include #include @@ -20,6 +22,8 @@ auto main(int argc, char ** argv) -> int auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN); + [[maybe_unused]] auto settings = Turns::gui::get_settings(); + return app->run(argc, argv); } diff --git a/gui/src/settings.cpp b/gui/src/settings.cpp index 161a709..fed7452 100644 --- a/gui/src/settings.cpp +++ b/gui/src/settings.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#include "turns/core/settings.hpp" +#include "settings.hpp" #include #include @@ -13,15 +13,15 @@ #include -namespace turns::core +namespace Turns::gui { auto get_settings() -> Glib::RefPtr { auto constexpr schema_id = "ch.arknet.Turns"; -#ifdef TURNS_SETTINGS_SCHEMA_DIR - auto source = Gio::SettingsSchemaSource::create(TURNS_SETTINGS_SCHEMA_DIR "/glib-2.0/schemas", true); +#ifdef SCHEMADIR + auto source = Gio::SettingsSchemaSource::create(SCHEMADIR "/glib-2.0/schemas", true); auto schema = source->lookup(schema_id, true); auto settings = g_settings_new_full(Glib::unwrap(schema), nullptr, nullptr); return Glib::wrap(settings); @@ -30,4 +30,4 @@ namespace turns::core #endif } -} // namespace turns::core +} // namespace Turns::gui -- cgit v1.2.3