summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/include/turns/app/application.hpp16
-rw-r--r--app/src/application.cpp32
-rw-r--r--app/src/widgets/participant_list_row.cpp2
-rw-r--r--app/tests/windows/main.cpp2
-rw-r--r--cmake/Modules/GlibCompileResources.cmake8
-rw-r--r--res/CMakeLists.txt4
-rw-r--r--res/style.css15
-rw-r--r--res/tests/windows.cpp2
8 files changed, 59 insertions, 22 deletions
diff --git a/app/include/turns/app/application.hpp b/app/include/turns/app/application.hpp
index 4a29254..c74f340 100644
--- a/app/include/turns/app/application.hpp
+++ b/app/include/turns/app/application.hpp
@@ -7,22 +7,28 @@
#include <gtkmm/application.h>
#include <gtkmm/applicationwindow.h>
+#include <memory>
+
namespace turns::app
{
- struct application : Gtk::Application
+ struct application
{
- auto static create() -> Glib::RefPtr<application>;
+ auto static create() -> std::shared_ptr<application>;
+
+ auto run(int argc, char * argv[]) -> int;
private:
application();
auto handle_action_quit() -> void;
- auto on_activate() -> void override;
- auto on_shutdown() -> void override;
- auto on_startup() -> void override;
+ auto on_activate() -> void;
+ auto on_shutdown() -> void;
+ auto on_startup() -> void;
+ AdwApplication * m_self;
+ Glib::RefPtr<Gtk::Application> m_application;
AdwApplicationWindow * m_main_window;
};
diff --git a/app/src/application.cpp b/app/src/application.cpp
index a998210..a120f40 100644
--- a/app/src/application.cpp
+++ b/app/src/application.cpp
@@ -4,6 +4,7 @@
#include <glibmm.h>
#include <gtkmm/builder.h>
+#include <gtkmm/init.h>
#include <gtkmm/window.h>
#include <sigc++/functors/functors.h>
@@ -11,18 +12,30 @@
namespace turns::app
{
- auto application::create() -> Glib::RefPtr<application>
+ auto application::create() -> std::shared_ptr<application>
{
- return Glib::make_refptr_for_instance(new application{});
+ Gtk::init_gtkmm_internals();
+ return std::shared_ptr<application>{new application{}};
+ }
+
+ auto application::run(int argc, char * argv[]) -> int
+ {
+ return g_application_run(G_APPLICATION(m_self), argc, argv);
}
application::application()
- : Gtk::Application{"ch.arknet.Turns"}
{
- auto builder = Gtk::Builder::create_from_resource("/turns/windows/main_window.ui");
+ m_self = adw_application_new("ch.arknet.Turns", G_APPLICATION_DEFAULT_FLAGS);
+ m_application = Glib::wrap(GTK_APPLICATION(m_self));
+
+ auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/windows/main_window.ui");
auto main_window = Gtk::Builder::get_widget_derived<windows::main>(builder, "main_window");
m_main_window = ADW_APPLICATION_WINDOW(main_window->gobj());
+
+ m_application->signal_activate().connect(sigc::mem_fun(*this, &application::on_activate));
+ m_application->signal_shutdown().connect(sigc::mem_fun(*this, &application::on_shutdown));
+ m_application->signal_startup().connect(sigc::mem_fun(*this, &application::on_startup));
}
auto application::handle_action_quit() -> void
@@ -32,28 +45,23 @@ namespace turns::app
auto application::on_activate() -> void
{
- Gtk::Application::on_activate();
- gtk_application_add_window(GTK_APPLICATION(gobj()), GTK_WINDOW(m_main_window));
+ gtk_application_add_window(m_application->gobj(), GTK_WINDOW(m_main_window));
gtk_window_present(GTK_WINDOW(m_main_window));
}
auto application::on_shutdown() -> void
{
- Gtk::Application::on_shutdown();
-
gtk_window_close(GTK_WINDOW(m_main_window));
delete Glib::wrap(GTK_WINDOW(m_main_window));
}
auto application::on_startup() -> void
{
- Gtk::Application::on_startup();
-
auto style_manager = adw_style_manager_get_default();
adw_style_manager_set_color_scheme(style_manager, ADW_COLOR_SCHEME_PREFER_LIGHT);
- add_action("quit", sigc::mem_fun(*this, &application::handle_action_quit));
- set_accel_for_action("app.quit", "<ctrl>q");
+ m_application->add_action("quit", sigc::mem_fun(*this, &application::handle_action_quit));
+ m_application->set_accel_for_action("app.quit", "<ctrl>q");
}
} // namespace turns::app \ No newline at end of file
diff --git a/app/src/widgets/participant_list_row.cpp b/app/src/widgets/participant_list_row.cpp
index 772495e..358a947 100644
--- a/app/src/widgets/participant_list_row.cpp
+++ b/app/src/widgets/participant_list_row.cpp
@@ -10,7 +10,7 @@ namespace turns::app::widgets
namespace
{
auto constexpr static TYPE_NAME = "participant_list_row";
- auto constexpr static TEMPLATE = "/turns/widgets/participant_list_row.ui";
+ auto constexpr static TEMPLATE = "/ch/arknet/Turns/widgets/participant_list_row.ui";
} // namespace
participant_list_row::participant_list_row()
diff --git a/app/tests/windows/main.cpp b/app/tests/windows/main.cpp
index b6e1122..fa340be 100644
--- a/app/tests/windows/main.cpp
+++ b/app/tests/windows/main.cpp
@@ -25,7 +25,7 @@ namespace turns::app::windows::tests
auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8");
setlocale(LC_ALL, locale);
- auto builder = Gtk::Builder::create_from_resource("/turns/windows/main_window.ui");
+ auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/windows/main_window.ui");
auto instance = Gtk::Builder::get_widget_derived<main>(builder, "main_window");
SECTION("construction via builder succeeds")
diff --git a/cmake/Modules/GlibCompileResources.cmake b/cmake/Modules/GlibCompileResources.cmake
index dcd9df5..d2e2784 100644
--- a/cmake/Modules/GlibCompileResources.cmake
+++ b/cmake/Modules/GlibCompileResources.cmake
@@ -5,7 +5,7 @@ find_program(GLIB_COMPILE_RESOURCES
function(target_add_glib_resources TARGET)
set(SINGLE_VALUE_ARGS "PREFIX")
- set(MULTI_VALUE_ARGS "UI_FILES")
+ set(MULTI_VALUE_ARGS "CSS_FILES" "UI_FILES")
cmake_parse_arguments(
PARSE_ARGV 1
""
@@ -35,6 +35,11 @@ function(target_add_glib_resources TARGET)
foreach(UI_FILE IN LISTS _UI_FILES)
string(APPEND GLIB_RESOURCE_FILES " <file compressed=\"true\" preprocess=\"xml-stripblanks\">${UI_FILE}</file>\n")
endforeach()
+
+ foreach(CSS_FILE IN LISTS _CSS_FILES)
+ string(APPEND GLIB_RESOURCE_FILES " <file compressed=\"true\">${CSS_FILE}</file>\n")
+ endforeach()
+
string(STRIP "${GLIB_RESOURCE_FILES}" GLIB_RESOURCE_FILES)
set(GLIB_RESOURCE_PREFIX "${_PREFIX}")
configure_file("${PROJECT_SOURCE_DIR}/cmake/Modules/GlibCompileResources.in"
@@ -54,6 +59,7 @@ function(target_add_glib_resources TARGET)
VERBATIM
MAIN_DEPENDENCY "${GLIB_RESOURCE_MANIFEST}"
DEPENDS
+ ${_CSS_FILES}
${_UI_FILES}
)
diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt
index b2b723a..36f23ff 100644
--- a/res/CMakeLists.txt
+++ b/res/CMakeLists.txt
@@ -3,10 +3,12 @@
add_library("res")
target_add_glib_resources("res"
- PREFIX "turns"
+ PREFIX "ch/arknet/Turns"
UI_FILES
"widgets/participant_list_row.ui"
"windows/main_window.ui"
+ CSS_FILES
+ "style.css"
)
target_compile_options("res" PRIVATE
diff --git a/res/style.css b/res/style.css
new file mode 100644
index 0000000..d26a9ba
--- /dev/null
+++ b/res/style.css
@@ -0,0 +1,15 @@
+button.disposition-hostile {
+ background-color: shade(@orange_1, 1);
+}
+
+button:checked.disposition-hostile {
+ background-color: shade(@orange_1, 0.8);
+}
+
+button.disposition-friendly {
+ background-color: shade(@green_1, 1);
+}
+
+button:checked.disposition-friendly {
+ background-color: shade(@green_1, 0.8);
+} \ No newline at end of file
diff --git a/res/tests/windows.cpp b/res/tests/windows.cpp
index 9daab51..20063ad 100644
--- a/res/tests/windows.cpp
+++ b/res/tests/windows.cpp
@@ -4,7 +4,7 @@
TEST_CASE("GResource for main_window")
{
- auto builder = Gtk::Builder::create_from_resource("/turns/windows/main_window.ui");
+ auto builder = Gtk::Builder::create_from_resource("/ch/arknet/Turns/windows/main_window.ui");
SECTION("can create Gtk.Builder for the main window UI definition")
{