summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2025-05-30 11:45:54 +0200
committerFelix Morgner <felix.morgner@gmail.com>2025-05-30 11:45:54 +0200
commitbfa30ed79cffee4f5c0d33b7fe7bd64581be3fdf (patch)
tree48e451c1aafcbd0d58d45292499ee81effcc82bc /gui
parent8ef970b679505ea82ea41e94ffa972a732731eae (diff)
downloadturns-bfa30ed79cffee4f5c0d33b7fe7bd64581be3fdf.tar.xz
turns-bfa30ed79cffee4f5c0d33b7fe7bd64581be3fdf.zip
gui: reintroduce ParticipantRow
Diffstat (limited to 'gui')
-rw-r--r--gui/CMakeLists.txt14
-rw-r--r--gui/include/init.hpp14
-rw-r--r--gui/include/participant_row.hpp16
-rw-r--r--gui/include/template_widget.hpp13
-rw-r--r--gui/src/init.cpp10
-rw-r--r--gui/src/main.cpp3
-rw-r--r--gui/src/participant_row.cpp31
7 files changed, 67 insertions, 34 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 799022d..a640b61 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -65,6 +65,8 @@ target_compile_definitions("resources" PUBLIC
# Library
add_library("gui_impl"
+ "src/init.cpp"
+ "src/participant_row.cpp"
"src/settings.cpp"
)
@@ -81,10 +83,6 @@ target_link_libraries("gui_impl" PUBLIC
"PkgConfig::glib"
"PkgConfig::glibmm"
-
- "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>"
- "resources"
- "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>"
)
target_compile_definitions("gui_impl" PUBLIC
@@ -109,6 +107,10 @@ target_include_directories("gui" PUBLIC
target_link_libraries("gui" PUBLIC
"gui_impl"
+
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>"
+ "resources"
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>"
)
set_target_properties("gui" PROPERTIES
@@ -150,6 +152,10 @@ add_executable("gui-tests"
target_link_libraries("gui-tests" PRIVATE
"gui_impl"
"Catch2::Catch2WithMain"
+
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>"
+ "resources"
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>"
)
target_compile_definitions("resources" PUBLIC
diff --git a/gui/include/init.hpp b/gui/include/init.hpp
new file mode 100644
index 0000000..d83544e
--- /dev/null
+++ b/gui/include/init.hpp
@@ -0,0 +1,14 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com>
+ * SPDX-License-Identifier: LGPL-2.1-only
+ */
+
+#ifndef TURNS_GUI_INIT_HPP
+#define TURNS_GUI_INIT_HPP
+
+namespace Turns::gui
+{
+ auto init() -> void;
+} // namespace Turns::gui
+
+#endif \ No newline at end of file
diff --git a/gui/include/participant_row.hpp b/gui/include/participant_row.hpp
index 81b3610..1388e41 100644
--- a/gui/include/participant_row.hpp
+++ b/gui/include/participant_row.hpp
@@ -3,16 +3,16 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
-#ifndef TURNS_UI_PARTICIPANT_ROW_HPP
-#define TURNS_UI_PARTICIPANT_ROW_HPP
+#ifndef TURNS_GUI_PARTICIPANT_ROW_HPP
+#define TURNS_GUI_PARTICIPANT_ROW_HPP
-#include "turns/core/fwd.hpp"
-#include "turns/ui/template_widget.hpp"
+#include "template_widget.hpp"
+
+#include <turnsmm/participant.hpp>
#include <glibmm/property.h>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-
#include <gtkmm/button.h>
#include <gtkmm/label.h>
#include <gtkmm/listboxrow.h>
@@ -20,7 +20,7 @@
#include <array>
-namespace turns::ui
+namespace Turns::gui
{
struct ParticipantRow : template_widget<ParticipantRow, Gtk::ListBoxRow>
{
@@ -32,7 +32,7 @@ namespace turns::ui
"toggle_defeated",
};
- ParticipantRow(Glib::RefPtr<core::Participant> participant);
+ ParticipantRow(Glib::RefPtr<Turns::Participant> participant);
auto delete_enabled() -> Glib::PropertyProxy<bool>;
auto edit_enabled() -> Glib::PropertyProxy<bool>;
@@ -50,6 +50,6 @@ namespace turns::ui
Glib::Property<bool> m_delete_enabled;
Glib::Property<bool> m_edit_enabled;
};
-} // namespace turns::ui::widgets
+} // namespace Turns::gui
#endif \ No newline at end of file
diff --git a/gui/include/template_widget.hpp b/gui/include/template_widget.hpp
index f90b473..34bc5ff 100644
--- a/gui/include/template_widget.hpp
+++ b/gui/include/template_widget.hpp
@@ -6,20 +6,19 @@
#ifndef TURNS_UI_TEMPLATE_WIDGET_HPP
#define TURNS_UI_TEMPLATE_WIDGET_HPP
+#include <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
#include <glibmm/extraclassinit.h>
#include <glibmm/ustring.h>
#include <glibmm/wrap.h>
-
#include <gtkmm/widget.h>
-#include <glib-object.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-
#include <algorithm>
#include <utility>
-namespace turns::ui
+namespace Turns::gui
{
template<typename CustomWidgetType, typename BaseWidgetType>
@@ -67,6 +66,6 @@ namespace turns::ui
}
};
-} // namespace turns::ui::widgets
+} // namespace Turns::gui
#endif \ No newline at end of file
diff --git a/gui/src/init.cpp b/gui/src/init.cpp
new file mode 100644
index 0000000..c9a7295
--- /dev/null
+++ b/gui/src/init.cpp
@@ -0,0 +1,10 @@
+#include "init.hpp"
+
+#include "participant_row.hpp"
+
+#include <glib-object.h>
+
+auto Turns::gui::init() -> void
+{
+ static_cast<void>(ParticipantRow{nullptr}.get_type());
+}
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
index c4b95e5..d8b0bf9 100644
--- a/gui/src/main.cpp
+++ b/gui/src/main.cpp
@@ -3,6 +3,8 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
+#include "init.hpp"
+
#include <turnsmm.hpp>
#include <turnsmm/enum_helpers.hpp>
@@ -23,6 +25,7 @@ auto main(int argc, char ** argv) -> int
auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN);
Turns::init();
+ Turns::gui::init();
return app->run(argc, argv);
}
diff --git a/gui/src/participant_row.cpp b/gui/src/participant_row.cpp
index c0f53df..01cf1ed 100644
--- a/gui/src/participant_row.cpp
+++ b/gui/src/participant_row.cpp
@@ -3,12 +3,12 @@
* SPDX-License-Identifier: LGPL-2.1-only
*/
-#include "turns/ui/participant_row.hpp"
+#include "participant_row.hpp"
-#include "turns/core/disposition.hpp"
-#include "turns/core/participant.hpp"
-#include "turns/lang/messages.hpp"
-#include "turns/ui/template_widget.hpp"
+#include "messages.hpp"
+#include "template_widget.hpp"
+
+#include <turnsmm/participant.hpp>
#include <sigc++/functors/mem_fun.h>
@@ -19,7 +19,6 @@
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glibmm/variant.h>
-
#include <gtkmm/button.h>
#include <gtkmm/label.h>
#include <gtkmm/listboxrow.h>
@@ -29,22 +28,24 @@
#include <format>
#include <vector>
-namespace turns::ui
+namespace Turns::gui
{
namespace
{
auto constexpr static TYPE_NAME = "ParticipantRow";
auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_row.ui";
- auto css_class_for(core::Disposition value) -> Glib::ustring
+ auto css_class_for(Participant::Disposition value) -> Glib::ustring
{
+ using Disposition = Participant::Disposition;
+
switch (value)
{
- case core::Disposition::Friendly:
+ case Disposition::Friendly:
return "disposition-friendly";
- case core::Disposition::Hostile:
+ case Disposition::Hostile:
return "disposition-hostile";
- case core::Disposition::Secret:
+ case Disposition::Secret:
return "disposition-secret";
default:
return "";
@@ -52,7 +53,7 @@ namespace turns::ui
}
} // namespace
- ParticipantRow::ParticipantRow(Glib::RefPtr<core::Participant> participant)
+ ParticipantRow::ParticipantRow(Glib::RefPtr<Participant> participant)
: Glib::ObjectBase(TYPE_NAME)
, template_widget{TEMPLATE}
, m_delete{get_widget<Gtk::Button>("delete")}
@@ -96,7 +97,7 @@ namespace turns::ui
Glib::Binding::bind_property(participant->property_priority(),
m_subtitle->property_label(),
Glib::Binding::Flags::SYNC_CREATE,
- [](auto n) { return std::vformat(_(lang::priority_number), std::make_format_args(n)); });
+ [](auto n) { return std::vformat(_(messages::priority_number), std::make_format_args(n)); });
Glib::Binding::bind_property(participant->property_disposition(),
m_toggle_defeated->property_css_classes(),
@@ -111,7 +112,7 @@ namespace turns::ui
return classes;
});
- Glib::Binding::bind_property(participant->property_is_active(),
+ Glib::Binding::bind_property(participant->property_active(),
property_css_classes(),
Glib::Binding::Flags::SYNC_CREATE,
[this](auto value) {
@@ -151,4 +152,4 @@ namespace turns::ui
activate_action("win.edit", index);
}
-} // namespace turns::ui \ No newline at end of file
+} // namespace Turns::gui \ No newline at end of file