diff options
| -rw-r--r-- | gui/include/resources.hpp | 19 | ||||
| -rw-r--r-- | gui/src/main.cpp | 3 | ||||
| -rw-r--r-- | gui/src/participant_editor.cpp | 3 | ||||
| -rw-r--r-- | gui/src/participant_row.cpp | 3 | ||||
| -rw-r--r-- | gui/src/preferences.cpp | 3 | ||||
| -rw-r--r-- | gui/src/tracker.cpp | 3 | ||||
| -rw-r--r-- | gui/src/turn_order_view.cpp | 3 | ||||
| -rw-r--r-- | gui/tests/resources.cpp | 36 |
8 files changed, 53 insertions, 20 deletions
diff --git a/gui/include/resources.hpp b/gui/include/resources.hpp new file mode 100644 index 0000000..bf37468 --- /dev/null +++ b/gui/include/resources.hpp @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com> + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNS_GUI_RESOURCES_HPP +#define TURNS_GUI_RESOURCES_HPP + +namespace Turns::gui::resource +{ + auto constexpr static metainfo_xml{"/ch/arknet/Turns/metainfo.xml"}; + auto constexpr static participant_editor_ui{"/ch/arknet/Turns/participant_editor.ui"}; + auto constexpr static participant_row_ui{"/ch/arknet/Turns/participant_row.ui"}; + auto constexpr static preferences_ui{"/ch/arknet/Turns/preferences.ui"}; + auto constexpr static tracker_ui{"/ch/arknet/Turns/tracker.ui"}; + auto constexpr static turn_order_view_ui{"/ch/arknet/Turns/turn_order_view.ui"}; +} // namespace Turns::gui::resource + +#endif
\ No newline at end of file diff --git a/gui/src/main.cpp b/gui/src/main.cpp index 8931382..0da9364 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -4,6 +4,7 @@ */ #include "init.hpp" +#include "resources.hpp" #include "settings.hpp" #include "tracker.hpp" @@ -29,7 +30,7 @@ namespace auto show_about(Glib::RefPtr<Adwaita::Application> app) { auto active_window = app->get_active_window(); - auto dialog = Gtk::make_managed<Adwaita::AboutDialog>("/ch/arknet/Turns/metainfo.xml", ""); + auto dialog = Gtk::make_managed<Adwaita::AboutDialog>(Turns::gui::resource::metainfo_xml, ""); dialog->present(active_window); } } // namespace diff --git a/gui/src/participant_editor.cpp b/gui/src/participant_editor.cpp index ca17495..e8b9ff0 100644 --- a/gui/src/participant_editor.cpp +++ b/gui/src/participant_editor.cpp @@ -6,6 +6,7 @@ #include "participant_editor.hpp" #include "messages.hpp" +#include "resources.hpp" #include "template_widget.hpp" #include <turnsmm/participant.hpp> @@ -39,7 +40,7 @@ namespace Turns::gui namespace { auto constexpr static TYPE_NAME = "ParticipantEditor"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_editor.ui"; + auto constexpr static TEMPLATE = resource::participant_editor_ui; auto presentation_name_for(Participant::Disposition disposition) -> char const * { diff --git a/gui/src/participant_row.cpp b/gui/src/participant_row.cpp index 52f0b69..e01da67 100644 --- a/gui/src/participant_row.cpp +++ b/gui/src/participant_row.cpp @@ -6,6 +6,7 @@ #include "participant_row.hpp" #include "messages.hpp" +#include "resources.hpp" #include "template_widget.hpp" #include <turnsmm/participant.hpp> @@ -33,7 +34,7 @@ namespace Turns::gui namespace { auto constexpr static TYPE_NAME = "ParticipantRow"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_row.ui"; + auto constexpr static TEMPLATE = resource::participant_row_ui; auto css_class_for(Participant::Disposition value) -> Glib::ustring { diff --git a/gui/src/preferences.cpp b/gui/src/preferences.cpp index 24bc952..7a80aa2 100644 --- a/gui/src/preferences.cpp +++ b/gui/src/preferences.cpp @@ -5,6 +5,7 @@ #include "preferences.hpp" +#include "resources.hpp" #include "settings.hpp" #include "template_widget.hpp" @@ -29,7 +30,7 @@ namespace Turns::gui namespace { auto constexpr static TYPE_NAME = "Preferences"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/preferences.ui"; + auto constexpr static TEMPLATE = resource::preferences_ui; } // namespace Preferences::Preferences(Glib::RefPtr<Gio::Settings> settings) diff --git a/gui/src/tracker.cpp b/gui/src/tracker.cpp index 6290b9c..c9ae2c5 100644 --- a/gui/src/tracker.cpp +++ b/gui/src/tracker.cpp @@ -8,6 +8,7 @@ #include "messages.hpp" #include "participant_editor.hpp" #include "preferences.hpp" +#include "resources.hpp" #include "settings.hpp" #include "template_widget.hpp" #include "turn_order_view.hpp" @@ -68,7 +69,7 @@ namespace Turns::gui namespace { auto constexpr static TYPE_NAME = "Tracker"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/tracker.ui"; + auto constexpr static TEMPLATE = resource::tracker_ui; auto file_filters() { diff --git a/gui/src/turn_order_view.cpp b/gui/src/turn_order_view.cpp index f103f44..5239269 100644 --- a/gui/src/turn_order_view.cpp +++ b/gui/src/turn_order_view.cpp @@ -6,6 +6,7 @@ #include "turn_order_view.hpp" #include "participant_row.hpp" +#include "resources.hpp" #include "template_widget.hpp" #include <turnsmm/participant.hpp> @@ -29,7 +30,7 @@ namespace Turns::gui namespace { auto constexpr static TYPE_NAME = "TurnOrderView"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/turn_order_view.ui"; + auto constexpr static TEMPLATE = resource::turn_order_view_ui; } // namespace TurnOrderView::TurnOrderView(Glib::RefPtr<model_type> model) diff --git a/gui/tests/resources.cpp b/gui/tests/resources.cpp index ccabf74..c58e217 100644 --- a/gui/tests/resources.cpp +++ b/gui/tests/resources.cpp @@ -3,6 +3,8 @@ * SPDX-License-Identifier: LGPL-2.1-only */ +#include "resources.hpp" + #include <catch2/catch_test_macros.hpp> #include <catch2/generators/catch_generators.hpp> @@ -10,25 +12,31 @@ #include <format> -SCENARIO("Resources are correctly bundled") +namespace Turns::gui::tests { - auto file = GENERATE("/ch/arknet/Turns/participant_editor.ui", - "/ch/arknet/Turns/participant_row.ui", - "/ch/arknet/Turns/preferences.ui", - "/ch/arknet/Turns/tracker.ui", - "/ch/arknet/Turns/turn_order_view.ui"); - - GIVEN(std::format("The resource path '{}'", file)) + SCENARIO("Resources are correctly bundled") { - WHEN("looking for a global resource at that path") - { - auto exists = Gio::Resource::get_file_exists_global_nothrow(file); - THEN("one exists") + auto file = GENERATE(resource::metainfo_xml, + resource::participant_editor_ui, + resource::participant_row_ui, + resource::preferences_ui, + resource::tracker_ui, + resource::turn_order_view_ui); + + GIVEN(std::format("The resource path '{}'", file)) + { + WHEN("looking for a global resource at that path") { - REQUIRE(exists); + auto exists = Gio::Resource::get_file_exists_global_nothrow(file); + + THEN("one exists") + { + REQUIRE(exists); + } } } } -} + +} // namespace Turns::gui::tests
\ No newline at end of file |
