From 8714470ebb41abec07e178abf4d4739dcd6087fb Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 12 Jul 2024 16:54:48 +0200 Subject: lang: extract constants for messages --- app/include/turns/app/windows/main.hpp | 4 +++- app/src/windows/main.cpp | 8 +++++++- app/tests/windows/main.cpp | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/include/turns/app/windows/main.hpp b/app/include/turns/app/windows/main.hpp index 9d2e1c3..a39d156 100644 --- a/app/include/turns/app/windows/main.hpp +++ b/app/include/turns/app/windows/main.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace turns::app::windows { @@ -14,10 +15,11 @@ namespace turns::app::windows main(BaseObjectType * base, Glib::RefPtr const builder); private: + Gtk::Button * m_add_participant; AdwApplicationWindow * m_adw; AdwWindowTitle * m_title; }; -} // namespace turns::app +} // namespace turns::app::windows #endif \ No newline at end of file diff --git a/app/src/windows/main.cpp b/app/src/windows/main.cpp index 0000f60..d8118c6 100644 --- a/app/src/windows/main.cpp +++ b/app/src/windows/main.cpp @@ -1,17 +1,23 @@ #include "turns/app/windows/main.hpp" +#include "turns/lang/messages.hpp" + #include #include namespace turns::app::windows { + using namespace turns::lang; + main::main(BaseObjectType * base, Glib::RefPtr const builder) : Gtk::ApplicationWindow{base} + , m_add_participant{builder->get_widget("add_participant")} , m_adw{ADW_APPLICATION_WINDOW(gobj())} , m_title(ADW_WINDOW_TITLE(builder->get_widget("title")->gobj())) { - adw_window_title_set_subtitle(m_title, _("No active turn-order")); + m_add_participant->set_tooltip_text(_(tooltips::add_a_participant)); + adw_window_title_set_subtitle(m_title, _(labels::no_active_turn_order)); } } // namespace turns::app::windows \ No newline at end of file diff --git a/app/tests/windows/main.cpp b/app/tests/windows/main.cpp index 53c9386..fca04fd 100644 --- a/app/tests/windows/main.cpp +++ b/app/tests/windows/main.cpp @@ -1,5 +1,7 @@ #include "turns/app/windows/main.hpp" +#include "turns/lang/messages.hpp" + #include #include @@ -9,11 +11,14 @@ #include #include #include +#include #include namespace turns::app::windows::tests { + using namespace turns::lang; + TEST_CASE("Newly constructed main window", "[windows]") { auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); @@ -38,7 +43,7 @@ namespace turns::app::windows::tests { auto widget = builder->get_widget("title"); auto adw = ADW_WINDOW_TITLE(widget->gobj()); - REQUIRE(adw_window_title_get_subtitle(adw) == Glib::ustring{_("No active turn-order")}); + REQUIRE(adw_window_title_get_subtitle(adw) == Glib::ustring{_(labels::no_active_turn_order)}); } SECTION("the window title is not empty") @@ -52,7 +57,13 @@ namespace turns::app::windows::tests { auto widget = builder->get_widget("title"); auto adw = ADW_WINDOW_TITLE(widget->gobj()); - REQUIRE(adw_window_title_get_title(adw) == Glib::ustring{_("Turns")}); + REQUIRE(adw_window_title_get_title(adw) == Glib::ustring{_(labels::turns)}); + } + + SECTION("the add_participant button has the correct tooltip") + { + auto widget = builder->get_widget("add_participant"); + REQUIRE(widget->get_tooltip_text() == Glib::ustring{_(tooltips::add_a_participant)}); } } -- cgit v1.2.3