aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--adw/CMakeLists.txt5
-rw-r--r--adw/include/turns/adw/actionrow.hpp149
-rw-r--r--adw/include/turns/adw/application.hpp51
-rw-r--r--adw/include/turns/adw/dialog.hpp64
-rw-r--r--adw/include/turns/adw/helpers/gobj_mixin.hpp (renamed from adw/include/turns/adw/helpers/gobj_cast.hpp)4
-rw-r--r--adw/include/turns/adw/preferencesdialog.hpp66
-rw-r--r--adw/include/turns/adw/preferencespage.hpp61
-rw-r--r--adw/include/turns/adw/preferencesrow.hpp118
-rw-r--r--adw/include/turns/adw/toast.hpp85
-rw-r--r--adw/include/turns/adw/toastoverlay.hpp54
-rw-r--r--adw/src/actionrow.cpp142
-rw-r--r--adw/src/application.cpp30
-rw-r--r--adw/src/dialog.cpp87
-rw-r--r--adw/src/preferencesdialog.cpp91
-rw-r--r--adw/src/preferencespage.cpp83
-rw-r--r--adw/src/preferencesrow.cpp107
-rw-r--r--adw/src/toast.cpp20
-rw-r--r--adw/src/toastoverlay.cpp19
-rw-r--r--adw/src/wrap_init.cpp46
-rw-r--r--app/ch.arknet.Turns.gschema.xml6
-rw-r--r--style/style-dark.css29
-rw-r--r--style/style.css6
-rw-r--r--ui/CMakeLists.txt1
-rw-r--r--ui/include/turns/ui/widgets/preferences.hpp42
-rw-r--r--ui/include/turns/ui/windows/tracker.hpp8
-rw-r--r--ui/res/CMakeLists.txt1
-rw-r--r--ui/res/ui.cmb24
-rw-r--r--ui/src/widgets/preferences.cpp68
-rw-r--r--ui/src/windows/tracker.cpp6
-rw-r--r--ui/src/windows/tracker/actions.cpp13
31 files changed, 1314 insertions, 176 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9ea774d..1cb0d99 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,10 +11,12 @@ build-and-test:
CMAKE_INSTALL_PREFIX: "ch.arknet.Turns"
script:
- weston --no-config --socket=$WAYLAND_DISPLAY --backend=headless &
+ - export XDG_DATA_DIRS=$(pwd)/${CMAKE_INSTALL_PREFIX}/share:${XDG_DATA_DIRS}
- cmake --preset default
- cmake --build --preset default --config $BUILD_TYPE
- cmake --install build --config $BUILD_TYPE
- - ctest --preset default --build-config $BUILD_TYPE
+ - glib-compile-schemas ${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas
+ - dbus-run-session -- ctest --preset default --build-config $BUILD_TYPE
artifacts:
paths:
- ${CMAKE_INSTALL_PREFIX}/
diff --git a/adw/CMakeLists.txt b/adw/CMakeLists.txt
index 736aac6..ce0323f 100644
--- a/adw/CMakeLists.txt
+++ b/adw/CMakeLists.txt
@@ -1,5 +1,10 @@
add_library("adw"
+ "src/actionrow.cpp"
"src/application.cpp"
+ "src/dialog.cpp"
+ "src/preferencesdialog.cpp"
+ "src/preferencespage.cpp"
+ "src/preferencesrow.cpp"
"src/toast.cpp"
"src/toastoverlay.cpp"
"src/wrap_init.cpp"
diff --git a/adw/include/turns/adw/actionrow.hpp b/adw/include/turns/adw/actionrow.hpp
new file mode 100644
index 0000000..15ddbb1
--- /dev/null
+++ b/adw/include/turns/adw/actionrow.hpp
@@ -0,0 +1,149 @@
+#ifndef TURNS_ADW_ACTION_ROW_HPP
+#define TURNS_ADW_ACTION_ROW_HPP
+
+#include "helpers/gobj_mixin.hpp"
+#include "turns/adw/helpers/properties.hpp"
+#include "turns/adw/preferencesrow.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <gtkmm/widget.h>
+
+using AdwActionRow = struct _AdwActionRow;
+
+namespace turns::adw
+{
+ struct ActionRow : adw::PreferencesRow,
+ helpers::gobj_mixin<ActionRow, AdwActionRow>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = AdwPreferencesRowClass;
+ using BaseClassType = struct AdwActionRowClass;
+ using BaseObjectType = AdwActionRow;
+ using CppClassParent = adw::PreferencesRow;
+ using CppObjectType = ActionRow;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit ActionRow();
+ ActionRow(ActionRow const & other) = delete;
+ ActionRow(ActionRow && other) noexcept = default;
+
+ auto operator=(ActionRow const & other) noexcept -> ActionRow & = delete;
+ auto operator=(ActionRow && other) noexcept -> ActionRow & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ auto add_prefix(Gtk::Widget & widget) -> ActionRow &;
+ auto add_suffix(Gtk::Widget & widget) -> ActionRow &;
+ auto remove(Gtk::Widget & widget) -> ActionRow &;
+
+ auto get_activatable_widget(this auto && self) noexcept;
+ [[deprecated("replaced by add_prefix")]] auto get_icon_name(this auto && self);
+ auto get_subtitle(this auto && self);
+ auto get_subtitle_lines(this auto && self) noexcept;
+ auto get_subtitle_selectable(this auto && self) noexcept;
+ auto get_title_lines(this auto && self) noexcept;
+
+ auto set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &;
+ [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> CppObjectType &;
+ auto set_subtitle(Glib::ustring const & subtitle) -> CppObjectType &;
+ auto set_subtitle_lines(int subtitle_lines) noexcept -> CppObjectType &;
+ auto set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType &;
+ auto set_title_lines(int title_lines) noexcept -> CppObjectType &;
+
+ auto property_activatable_widget(this auto && self);
+ [[deprecated("replaced by add_prefix")]] auto property_icon_name(this auto && self);
+ auto property_subtitle(this auto && self);
+ auto property_subtitle_lines(this auto && self);
+ auto property_subtitle_selectable(this auto && self);
+ auto property_title_lines(this auto && self);
+
+ protected:
+ explicit ActionRow(Glib::ConstructParams const & params);
+ explicit ActionRow(BaseObjectType * gobj);
+ };
+
+ auto ActionRow::get_activatable_widget(this auto && self) noexcept
+ {
+ return self.property_activatable_widget().value();
+ }
+
+ auto ActionRow::get_icon_name(this auto && self)
+ {
+ return self.property_icon_name().value();
+ }
+
+ auto ActionRow::get_subtitle(this auto && self)
+ {
+ return self.property_subtitle().value();
+ }
+
+ auto ActionRow::get_subtitle_lines(this auto && self) noexcept
+ {
+ return self.property_subtitle_lines().value();
+ }
+
+ auto ActionRow::get_subtitle_selectable(this auto && self) noexcept
+ {
+ return self.property_subtitle_selectable().value();
+ }
+
+ auto ActionRow::get_title_lines(this auto && self) noexcept
+ {
+ return self.property_title_lines().value();
+ }
+
+ auto ActionRow::property_activatable_widget(this auto && self)
+ {
+ return helpers::make_property_proxy<Gtk::Widget *>(self, "activatable-widget");
+ }
+
+ auto ActionRow::property_icon_name(this auto && self)
+ {
+ return helpers::make_property_proxy<Glib::ustring>(self, "icon-name");
+ }
+
+ auto ActionRow::property_subtitle(this auto && self)
+ {
+ return helpers::make_property_proxy<Glib::ustring>(self, "subtitle");
+ }
+
+ auto ActionRow::property_subtitle_lines(this auto && self)
+ {
+ return helpers::make_property_proxy<int>(self, "subtitle-lines");
+ }
+
+ auto ActionRow::property_subtitle_selectable(this auto && self)
+ {
+ return helpers::make_property_proxy<bool>(self, "subtitle-selectable");
+ }
+
+ auto ActionRow::property_title_lines(this auto && self)
+ {
+ return helpers::make_property_proxy<int>(self, "title-lines");
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwActionRow * object, bool copy = false) -> Glib::RefPtr<turns::adw::ActionRow>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/application.hpp b/adw/include/turns/adw/application.hpp
index 26bec41..64efcb0 100644
--- a/adw/include/turns/adw/application.hpp
+++ b/adw/include/turns/adw/application.hpp
@@ -1,6 +1,9 @@
#ifndef TURNS_ADW_APPLICATION_HPP
#define TURNS_ADW_APPLICATION_HPP
+#include "turns/adw/helpers/gobj_mixin.hpp"
+
+#include <glibmm/class.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
@@ -12,38 +15,46 @@ using AdwApplication = struct _AdwApplication;
namespace turns::adw
{
- struct Application_Class;
-
- struct Application : Gtk::Application
+ struct Application : Gtk::Application,
+ helpers::gobj_mixin<Application, AdwApplication>
{
- Application(Application && other) noexcept = default;
- auto operator=(Application && other) noexcept -> Application & = default;
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GtkApplicationClass;
+ using BaseClassType = struct AdwApplicationClass;
+ using BaseObjectType = AdwApplication;
+ using CppClassParent = struct Gtk::Application_Class;
+ using CppObjectType = Application;
- Application(Application const & other) = delete;
- auto operator=(Application const & other) noexcept -> Application & = delete;
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
- auto static get_type() -> GType;
- auto static get_base_type() -> GType;
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
- template<typename Self>
- auto gobj(this Self && self) noexcept
- {
- return reinterpret_cast<AdwApplication *>(self.gobject_);
- }
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
- auto gobj_copy() -> AdwApplication *;
+ Application(Application const & other) = delete;
+ Application(Application && other) noexcept = default;
+
+ auto operator=(Application const & other) noexcept -> Application & = delete;
+ auto operator=(Application && other) noexcept -> Application & = default;
auto static create(Glib::ustring const & id = {},
Gio::Application::Flags flags = Gio::Application::Flags::NONE) -> Glib::RefPtr<Application>;
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
protected:
explicit Application(Glib::ConstructParams const & params);
- explicit Application(AdwApplication * gobj);
+ explicit Application(BaseObjectType * gobj);
explicit Application(Glib::ustring const & id = {}, Gio::Application::Flags flags = Gio::Application::Flags::NONE);
-
- private:
- friend Application_Class;
- static Application_Class s_class;
};
} // namespace turns::adw
diff --git a/adw/include/turns/adw/dialog.hpp b/adw/include/turns/adw/dialog.hpp
new file mode 100644
index 0000000..af5f5da
--- /dev/null
+++ b/adw/include/turns/adw/dialog.hpp
@@ -0,0 +1,64 @@
+#ifndef TURNS_ADW_DIALOG_HPP
+#define TURNS_ADW_DIALOG_HPP
+
+#include "helpers/gobj_mixin.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/refptr.h>
+
+#include <gtkmm/widget.h>
+
+using AdwDialog = struct _AdwDialog;
+
+namespace turns::adw
+{
+ struct Dialog_Class;
+
+ struct Dialog : Gtk::Widget,
+ helpers::gobj_mixin<Dialog, AdwDialog>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GtkWidgetClass;
+ using BaseClassType = struct AdwDialogClass;
+ using BaseObjectType = AdwDialog;
+ using CppClassParent = struct Gtk::Widget_Class;
+ using CppObjectType = Dialog;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit Dialog();
+ Dialog(Dialog const & other) = delete;
+ Dialog(Dialog && other) noexcept = default;
+
+ auto operator=(Dialog const & other) noexcept -> Dialog & = delete;
+ auto operator=(Dialog && other) noexcept -> Dialog & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ auto present(Gtk::Widget * parent) -> void;
+
+ protected:
+ explicit Dialog(Glib::ConstructParams const & params);
+ explicit Dialog(BaseObjectType * gobj);
+ };
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwDialog * object, bool copy = false) -> Glib::RefPtr<turns::adw::Dialog>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/helpers/gobj_cast.hpp b/adw/include/turns/adw/helpers/gobj_mixin.hpp
index 1ef9089..d9e5097 100644
--- a/adw/include/turns/adw/helpers/gobj_cast.hpp
+++ b/adw/include/turns/adw/helpers/gobj_mixin.hpp
@@ -1,5 +1,5 @@
-#ifndef TURNS_ADW_HELPERS_GOBJ_CAST_HPP
-#define TURNS_ADW_HELPERS_GOBJ_CAST_HPP
+#ifndef TURNS_ADW_HELPERS_GOBJ_MIXIN_HPP
+#define TURNS_ADW_HELPERS_GOBJ_MIXIN_HPP
#include <glibmm/object.h>
diff --git a/adw/include/turns/adw/preferencesdialog.hpp b/adw/include/turns/adw/preferencesdialog.hpp
new file mode 100644
index 0000000..06ac600
--- /dev/null
+++ b/adw/include/turns/adw/preferencesdialog.hpp
@@ -0,0 +1,66 @@
+#ifndef TURNS_ADW_PREFERENCES_DIALOG_HPP
+#define TURNS_ADW_PREFERENCES_DIALOG_HPP
+
+#include "dialog.hpp"
+#include "helpers/gobj_mixin.hpp"
+#include "turns/adw/preferencespage.hpp"
+
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <gtkmm/widget.h>
+
+using AdwPreferencesDialog = struct _AdwPreferencesDialog;
+
+namespace turns::adw
+{
+ struct PreferencesDialog_Class;
+
+ struct PreferencesDialog : adw::Dialog,
+ helpers::gobj_mixin<PreferencesDialog, AdwPreferencesDialog>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = AdwDialogClass;
+ using BaseClassType = struct AdwPreferencesDialogClass;
+ using BaseObjectType = AdwPreferencesDialog;
+ using CppClassParent = adw::Dialog::Class;
+ using CppObjectType = PreferencesDialog;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit PreferencesDialog();
+ PreferencesDialog(PreferencesDialog const & other) = delete;
+ PreferencesDialog(PreferencesDialog && other) noexcept = default;
+
+ auto operator=(PreferencesDialog const & other) noexcept -> PreferencesDialog & = delete;
+ auto operator=(PreferencesDialog && other) noexcept -> PreferencesDialog & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ auto add(adw::PreferencesPage & page) -> void;
+
+ protected:
+ explicit PreferencesDialog(Glib::ConstructParams const & params);
+ explicit PreferencesDialog(BaseObjectType * gobj);
+ };
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesDialog * object, bool copy = false) -> Glib::RefPtr<turns::adw::PreferencesDialog>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/preferencespage.hpp b/adw/include/turns/adw/preferencespage.hpp
new file mode 100644
index 0000000..30e7eed
--- /dev/null
+++ b/adw/include/turns/adw/preferencespage.hpp
@@ -0,0 +1,61 @@
+#ifndef TURNS_ADW_PREFERENCES_PAGE_HPP
+#define TURNS_ADW_PREFERENCES_PAGE_HPP
+
+#include "helpers/gobj_mixin.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <gtkmm/widget.h>
+
+using AdwPreferencesPage = struct _AdwPreferencesPage;
+
+namespace turns::adw
+{
+ struct PreferencesPage : Gtk::Widget,
+ helpers::gobj_mixin<PreferencesPage, AdwPreferencesPage>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GtkWidgetClass;
+ using BaseClassType = struct AdwPreferencesPageClass;
+ using BaseObjectType = AdwPreferencesPage;
+ using CppClassParent = struct Gtk::Widget_Class;
+ using CppObjectType = PreferencesPage;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit PreferencesPage();
+ PreferencesPage(PreferencesPage const & other) = delete;
+ PreferencesPage(PreferencesPage && other) noexcept = default;
+
+ auto operator=(PreferencesPage const & other) noexcept -> PreferencesPage & = delete;
+ auto operator=(PreferencesPage && other) noexcept -> PreferencesPage & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ protected:
+ explicit PreferencesPage(Glib::ConstructParams const & params);
+ explicit PreferencesPage(BaseObjectType * gobj);
+ };
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesPage * object, bool copy = false) -> Glib::RefPtr<turns::adw::PreferencesPage>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/preferencesrow.hpp b/adw/include/turns/adw/preferencesrow.hpp
new file mode 100644
index 0000000..6f831b0
--- /dev/null
+++ b/adw/include/turns/adw/preferencesrow.hpp
@@ -0,0 +1,118 @@
+#ifndef TURNS_ADW_PREFERENCES_ROW_HPP
+#define TURNS_ADW_PREFERENCES_ROW_HPP
+
+#include "helpers/gobj_mixin.hpp"
+#include "turns/adw/helpers/properties.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <gtkmm/listboxrow.h>
+
+using AdwPreferencesRow = struct _AdwPreferencesRow;
+
+namespace turns::adw
+{
+ struct PreferencesRow : Gtk::ListBoxRow,
+ helpers::gobj_mixin<PreferencesRow, AdwPreferencesRow>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GtkListBoxRowClass;
+ using BaseClassType = struct AdwPreferencesRowClass;
+ using BaseObjectType = AdwPreferencesRow;
+ using CppClassParent = struct Gtk::ListBoxRow_Class;
+ using CppObjectType = PreferencesRow;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit PreferencesRow();
+ PreferencesRow(PreferencesRow const & other) = delete;
+ PreferencesRow(PreferencesRow && other) noexcept = default;
+
+ auto operator=(PreferencesRow const & other) noexcept -> PreferencesRow & = delete;
+ auto operator=(PreferencesRow && other) noexcept -> PreferencesRow & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ auto get_title(this auto && self);
+ auto get_title_selectable(this auto && self) noexcept;
+ auto get_use_markup(this auto && self) noexcept;
+ auto get_use_underline(this auto && self) noexcept;
+
+ auto set_title(Glib::ustring const & title) -> CppObjectType &;
+ auto set_title_selectable(bool selectable) noexcept -> CppObjectType &;
+ auto set_use_markup(bool use) noexcept -> CppObjectType &;
+ auto set_use_underline(bool use) noexcept -> CppObjectType &;
+
+ auto property_title(this auto && self);
+ auto property_title_selectable(this auto && self);
+ auto property_use_markup(this auto && self);
+ auto property_use_underline(this auto && self);
+
+ protected:
+ explicit PreferencesRow(Glib::ConstructParams const & params);
+ explicit PreferencesRow(BaseObjectType * gobj);
+ };
+
+ auto PreferencesRow::get_title(this auto && self)
+ {
+ return self.property_title().value();
+ }
+
+ auto PreferencesRow::get_title_selectable(this auto && self) noexcept
+ {
+ return self.property_title_selectable().value();
+ }
+
+ auto PreferencesRow::get_use_markup(this auto && self) noexcept
+ {
+ return self.property_use_markup().value();
+ }
+
+ auto PreferencesRow::get_use_underline(this auto && self) noexcept
+ {
+ return self.property_use_underline().value();
+ }
+
+ auto PreferencesRow::property_title(this auto && self)
+ {
+ return helpers::make_property_proxy<Glib::ustring>(self, "title");
+ }
+
+ auto PreferencesRow::property_title_selectable(this auto && self)
+ {
+ return helpers::make_property_proxy<bool>(self, "title-selectable");
+ }
+
+ auto PreferencesRow::property_use_markup(this auto && self)
+ {
+ return helpers::make_property_proxy<bool>(self, "use-markup");
+ }
+
+ auto PreferencesRow::property_use_underline(this auto && self)
+ {
+ return helpers::make_property_proxy<bool>(self, "use-underline");
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesRow * object, bool copy = false) -> Glib::RefPtr<turns::adw::PreferencesRow>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/toast.hpp b/adw/include/turns/adw/toast.hpp
index f82e01e..83242c7 100644
--- a/adw/include/turns/adw/toast.hpp
+++ b/adw/include/turns/adw/toast.hpp
@@ -1,7 +1,7 @@
#ifndef TURNS_ADW_TOAST_HPP
#define TURNS_ADW_TOAST_HPP
-#include "turns/adw/helpers/gobj_cast.hpp"
+#include "turns/adw/helpers/gobj_mixin.hpp"
#include "turns/adw/helpers/properties.hpp"
#include <glibmm/object.h>
@@ -11,101 +11,106 @@
#include <gtkmm/widget.h>
+#define _ADWAITA_INSIDE
+#include <adw-toast.h>
+#undef _ADWAITA_INSIDE
+
using AdwToast = struct _AdwToast;
namespace turns::adw
{
- struct Toast_Class;
-
struct Toast final : Glib::Object,
helpers::gobj_mixin<Toast, AdwToast>
{
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GObjectClass;
+ using BaseClassType = AdwToastClass;
+ using BaseObjectType = AdwToast;
+ using CppClassParent = struct Glib::Object_Class;
+ using CppObjectType = Toast;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
enum class Priority
{
NORMAL,
HIGH,
};
- using helpers::gobj_mixin<Toast, AdwToast>::gobj;
- using helpers::gobj_mixin<Toast, AdwToast>::gobj_copy;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+ explicit Toast(Glib::ustring const & title);
+ Toast(Toast const & other) = delete;
Toast(Toast && other) noexcept = default;
- auto operator=(Toast && other) noexcept -> Toast & = default;
- Toast(Toast const & other) = delete;
auto operator=(Toast const & other) noexcept -> Toast & = delete;
-
- explicit Toast(Glib::ustring const & title);
+ auto operator=(Toast && other) noexcept -> Toast & = default;
auto static get_type() -> GType;
auto static get_base_type() -> GType;
auto dismiss() -> void;
- // clang-format off
- template<typename Self> auto property_action_name(this Self && self);
- template<typename Self> auto property_action_target(this Self && self);
- template<typename Self> auto property_button_label(this Self && self);
- template<typename Self> auto property_custom_title(this Self && self);
- template<typename Self> auto property_priority(this Self && self);
- template<typename Self> auto property_timeout(this Self && self);
- template<typename Self> auto property_title(this Self && self);
- template<typename Self> auto property_use_markup(this Self && self);
- // clang-format on
+ auto property_action_name(this auto && self);
+ auto property_action_target(this auto && self);
+ auto property_button_label(this auto && self);
+ auto property_custom_title(this auto && self);
+ auto property_priority(this auto && self);
+ auto property_timeout(this auto && self);
+ auto property_title(this auto && self);
+ auto property_use_markup(this auto && self);
protected:
explicit Toast(Glib::ConstructParams const & params);
- explicit Toast(AdwToast * gobj);
-
- private:
- friend Toast_Class;
- static Toast_Class s_class;
+ explicit Toast(BaseObjectType * gobj);
};
- template<typename Self>
- auto Toast::property_action_name(this Self && self)
+ auto Toast::property_action_name(this auto && self)
{
return helpers::make_property_proxy<Glib::ustring>(self, "action-name");
}
- template<typename Self>
- auto Toast::property_action_target(this Self && self)
+ auto Toast::property_action_target(this auto && self)
{
return helpers::make_property_proxy<Glib::VariantBase>(self, "action-target");
}
- template<typename Self>
- auto Toast::property_button_label(this Self && self)
+ auto Toast::property_button_label(this auto && self)
{
return helpers::make_property_proxy<Glib::ustring>(self, "button-label");
}
- template<typename Self>
- auto Toast::property_custom_title(this Self && self)
+ auto Toast::property_custom_title(this auto && self)
{
return helpers::make_property_proxy<Gtk::Widget *>(self, "custom-title");
}
- template<typename Self>
- auto Toast::property_priority(this Self && self)
+ auto Toast::property_priority(this auto && self)
{
return helpers::make_property_proxy<Priority>(self, "priority");
}
- template<typename Self>
- auto Toast::property_timeout(this Self && self)
+ auto Toast::property_timeout(this auto && self)
{
return helpers::make_property_proxy<unsigned>(self, "timeout");
}
- template<typename Self>
- auto Toast::property_title(this Self && self)
+ auto Toast::property_title(this auto && self)
{
return helpers::make_property_proxy<Glib::ustring>(self, "title");
}
- template<typename Self>
- auto Toast::property_use_markup(this Self && self)
+ auto Toast::property_use_markup(this auto && self)
{
return helpers::make_property_proxy<bool>(self, "use-markup");
}
diff --git a/adw/include/turns/adw/toastoverlay.hpp b/adw/include/turns/adw/toastoverlay.hpp
index 958266b..49f6a59 100644
--- a/adw/include/turns/adw/toastoverlay.hpp
+++ b/adw/include/turns/adw/toastoverlay.hpp
@@ -1,55 +1,63 @@
#ifndef TURNS_ADW_TOASTOVERLAY_HPP
#define TURNS_ADW_TOASTOVERLAY_HPP
-#include "turns/adw/helpers/gobj_cast.hpp"
+#include "turns/adw/helpers/gobj_mixin.hpp"
#include "turns/adw/helpers/properties.hpp"
#include <glibmm/refptr.h>
#include <gtkmm/widget.h>
-using AdwToastOverlay = struct _AdwToastOverlay;
+#define _ADWAITA_INSIDE
+#include <adw-toast-overlay.h>
+#undef _ADWAITA_INSIDE
namespace turns::adw
{
- struct ToastOverlay_Class;
-
- struct Toast;
-
struct ToastOverlay final : Gtk::Widget,
helpers::gobj_mixin<ToastOverlay, AdwToastOverlay>
{
- using helpers::gobj_mixin<ToastOverlay, AdwToastOverlay>::gobj;
- using helpers::gobj_mixin<ToastOverlay, AdwToastOverlay>::gobj_copy;
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = GtkWidgetClass;
+ using BaseClassType = AdwToastOverlayClass;
+ using BaseObjectType = AdwToastOverlay;
+ using CppClassParent = struct Gtk::Widget_Class;
+ using CppObjectType = ToastOverlay;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+ explicit ToastOverlay();
+ ToastOverlay(ToastOverlay const & other) = delete;
ToastOverlay(ToastOverlay && other) noexcept = default;
- auto operator=(ToastOverlay && other) noexcept -> ToastOverlay & = default;
- ToastOverlay(ToastOverlay const & other) = delete;
auto operator=(ToastOverlay const & other) noexcept -> ToastOverlay & = delete;
-
- explicit ToastOverlay();
+ auto operator=(ToastOverlay && other) noexcept -> ToastOverlay & = default;
auto static get_type() -> GType;
auto static get_base_type() -> GType;
- auto add(Toast && toast) -> void;
+ auto add(struct Toast && toast) -> void;
- // clang-format off
- template<typename Self> auto property_child(this Self && self);
- // clang-format on
+ auto property_child(this auto && self);
protected:
explicit ToastOverlay(Glib::ConstructParams const & params);
- explicit ToastOverlay(AdwToastOverlay * gobj);
-
- private:
- friend ToastOverlay_Class;
- static ToastOverlay_Class s_class;
+ explicit ToastOverlay(BaseObjectType * gobj);
};
- template<typename Self>
- auto ToastOverlay::property_child(this Self && self)
+ auto ToastOverlay::property_child(this auto && self)
{
return helpers::make_property_proxy<Gtk::Widget *>(self, "child");
}
diff --git a/adw/src/actionrow.cpp b/adw/src/actionrow.cpp
new file mode 100644
index 0000000..f45f7a3
--- /dev/null
+++ b/adw/src/actionrow.cpp
@@ -0,0 +1,142 @@
+#include "turns/adw/actionrow.hpp"
+
+#include "turns/adw/preferencesrow.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <glibmm/utility.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/init.h>
+#include <gtkmm/listboxrow.h>
+#include <gtkmm/private/widget_p.h>
+
+#include <adwaita.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace turns::adw
+{
+ namespace
+ {
+ auto constinit _class = ActionRow::Class{};
+ } // namespace
+
+ auto ActionRow::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &ActionRow::Class::class_init_function;
+ register_derived_type(adw_action_row_get_type());
+ }
+ return *this;
+ }
+
+ auto ActionRow::Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwActionRowClass *>(gclass);
+ PreferencesRow::Class::class_init_function(klass, data);
+ }
+
+ auto ActionRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new ActionRow(ADW_ACTION_ROW(object));
+ }
+
+ auto ActionRow::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto ActionRow::get_base_type() -> GType
+ {
+ return adw_action_row_get_type();
+ }
+
+ ActionRow::ActionRow()
+ : Glib::ObjectBase{nullptr}
+ , adw::PreferencesRow{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto ActionRow::add_prefix(Gtk::Widget & widget) -> ActionRow &
+ {
+ adw_action_row_add_prefix(Glib::unwrap(this), Glib::unwrap(&widget));
+ return *this;
+ }
+
+ auto ActionRow::add_suffix(Gtk::Widget & widget) -> ActionRow &
+ {
+ adw_action_row_add_suffix(Glib::unwrap(this), Glib::unwrap(&widget));
+ return *this;
+ }
+
+ auto ActionRow::remove(Gtk::Widget & widget) -> ActionRow &
+ {
+ adw_action_row_remove(Glib::unwrap(this), Glib::unwrap(&widget));
+ return *this;
+ }
+
+ auto ActionRow::set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &
+ {
+ adw_action_row_set_activatable_widget(Glib::unwrap(this), Glib::unwrap(&widget));
+ return *this;
+ }
+
+ auto ActionRow::set_icon_name(Glib::ustring const & name) -> CppObjectType &
+ {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ adw_action_row_set_icon_name(Glib::unwrap(this), name.c_str());
+#pragma GCC diagnostic pop
+ return *this;
+ }
+
+ auto ActionRow::set_subtitle(Glib::ustring const & subtitle) -> CppObjectType &
+ {
+ adw_action_row_set_subtitle(Glib::unwrap(this), subtitle.c_str());
+ return *this;
+ }
+
+ auto ActionRow::set_subtitle_lines(int subtitle_lines) noexcept -> CppObjectType &
+ {
+ adw_action_row_set_subtitle_lines(Glib::unwrap(this), subtitle_lines);
+ return *this;
+ }
+
+ auto ActionRow::set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType &
+ {
+ adw_action_row_set_subtitle_selectable(Glib::unwrap(this), subtitle_selectable);
+ return *this;
+ }
+
+ auto ActionRow::set_title_lines(int title_lines) noexcept -> CppObjectType &
+ {
+ adw_action_row_set_title_lines(Glib::unwrap(this), title_lines);
+ return *this;
+ }
+
+ ActionRow::ActionRow(Glib::ConstructParams const & params)
+ : adw::PreferencesRow{params}
+ {
+ }
+
+ ActionRow::ActionRow(BaseObjectType * gobj)
+ : Glib::ObjectBase{nullptr}
+ , adw::PreferencesRow(ADW_PREFERENCES_ROW(gobj))
+ {
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwActionRow * object, bool copy) -> Glib::RefPtr<turns::adw::ActionRow>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::ActionRow>(
+ dynamic_cast<turns::adw::ActionRow *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/application.cpp b/adw/src/application.cpp
index e8f6253..1fe47c3 100644
--- a/adw/src/application.cpp
+++ b/adw/src/application.cpp
@@ -7,7 +7,7 @@
#include <glibmm/objectbase.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
-#include <glibmm/utility.h>
+#include <glibmm/wrap.h>
#include <giomm/application.h>
@@ -21,39 +21,35 @@
namespace turns::adw
{
- struct Application_Class : Glib::Class
+ namespace
{
- auto init() -> Glib::Class const &;
- auto static class_init_function(void * gclass, void * data) -> void;
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
+ auto constinit _class = Application::Class{};
+ } // namespace
- auto Application_Class::init() -> Glib::Class const &
+ auto Application::Class::init() -> Glib::Class const &
{
if (!gtype_)
{
- class_init_func_ = &Application_Class::class_init_function;
+ class_init_func_ = &Application::Class::class_init_function;
register_derived_type(adw_application_get_type());
}
return *this;
}
- auto Application_Class::class_init_function(void * gclass, void * data) -> void
+ auto Application::Class::class_init_function(void * gclass, void * data) -> void
{
auto const klass = static_cast<AdwApplicationClass *>(gclass);
Gtk::Application_Class::class_init_function(klass, data);
}
- auto Application_Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ auto Application::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
{
return new Application(ADW_APPLICATION(object));
}
- Application_Class Application::s_class{};
-
auto Application::get_type() -> GType
{
- return s_class.init().get_type();
+ return _class.init().get_type();
}
auto Application::get_base_type() -> GType
@@ -61,12 +57,6 @@ namespace turns::adw
return adw_application_get_type();
}
- auto Application::gobj_copy() -> AdwApplication *
- {
- reference();
- return gobj();
- }
-
auto Application::create(Glib::ustring const & id, Gio::Application::Flags flags) -> Glib::RefPtr<Application>
{
auto static did_init = false;
@@ -94,7 +84,7 @@ namespace turns::adw
Application::Application(Glib::ustring const & id, Gio::Application::Flags flags)
: Glib::ObjectBase{nullptr}
- , Gtk::Application{Glib::ConstructParams{s_class.init(), "application_id", Glib::c_str_or_nullptr(id), "flags", static_cast<GApplicationFlags>(flags), nullptr}}
+ , Gtk::Application{Glib::ConstructParams{_class.init(), "application_id", Glib::c_str_or_nullptr(id), "flags", static_cast<GApplicationFlags>(flags), nullptr}}
{
}
diff --git a/adw/src/dialog.cpp b/adw/src/dialog.cpp
new file mode 100644
index 0000000..3fe9752
--- /dev/null
+++ b/adw/src/dialog.cpp
@@ -0,0 +1,87 @@
+#include "turns/adw/dialog.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/init.h>
+#include <gtkmm/private/widget_p.h>
+#include <gtkmm/widget.h>
+
+#include <adwaita.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace turns::adw
+{
+
+ namespace
+ {
+ auto constinit _class = Dialog::Class{};
+ } // namespace
+
+ auto Dialog::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &Dialog::Class::class_init_function;
+ register_derived_type(adw_dialog_get_type());
+ }
+ return *this;
+ }
+
+ auto Dialog::Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwDialogClass *>(gclass);
+ Gtk::Widget_Class::class_init_function(klass, data);
+ }
+
+ auto Dialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new Dialog(ADW_DIALOG(object));
+ }
+
+ auto Dialog::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto Dialog::get_base_type() -> GType
+ {
+ return adw_dialog_get_type();
+ }
+
+ Dialog::Dialog(Glib::ConstructParams const & params)
+ : Gtk::Widget{params}
+ {
+ }
+
+ Dialog::Dialog(AdwDialog * gobj)
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Widget(GTK_WIDGET(gobj))
+ {
+ }
+
+ Dialog::Dialog()
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Widget{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto Dialog::present(Gtk::Widget * parent) -> void
+ {
+ adw_dialog_present(gobj(), Glib::unwrap(parent));
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwDialog * object, bool copy) -> Glib::RefPtr<turns::adw::Dialog>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::Dialog>(dynamic_cast<turns::adw::Dialog *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/preferencesdialog.cpp b/adw/src/preferencesdialog.cpp
new file mode 100644
index 0000000..b18c0e6
--- /dev/null
+++ b/adw/src/preferencesdialog.cpp
@@ -0,0 +1,91 @@
+#include "turns/adw/preferencesdialog.hpp"
+
+#include "turns/adw/dialog.hpp"
+#include "turns/adw/preferencespage.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <glibmm/utility.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/init.h>
+#include <gtkmm/private/widget_p.h>
+#include <gtkmm/widget.h>
+
+#include <adwaita.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace turns::adw
+{
+ namespace
+ {
+ auto constinit _class = PreferencesDialog::Class{};
+ }
+
+ auto PreferencesDialog::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &PreferencesDialog::Class::class_init_function;
+ register_derived_type(adw_preferences_dialog_get_type());
+ }
+ return *this;
+ }
+
+ auto PreferencesDialog::Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwPreferencesDialogClass *>(gclass);
+ Gtk::Widget_Class::class_init_function(klass, data);
+ }
+
+ auto PreferencesDialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new PreferencesDialog(ADW_PREFERENCES_DIALOG(object));
+ }
+
+ auto PreferencesDialog::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto PreferencesDialog::get_base_type() -> GType
+ {
+ return adw_dialog_get_type();
+ }
+
+ PreferencesDialog::PreferencesDialog(Glib::ConstructParams const & params)
+ : adw::Dialog{params}
+ {
+ }
+
+ PreferencesDialog::PreferencesDialog(AdwPreferencesDialog * gobj)
+ : Glib::ObjectBase{nullptr}
+ , adw::Dialog(ADW_DIALOG(gobj))
+ {
+ }
+
+ PreferencesDialog::PreferencesDialog()
+ : Glib::ObjectBase{nullptr}
+ , adw::Dialog{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto PreferencesDialog::add(adw::PreferencesPage & page) -> void
+ {
+ adw_preferences_dialog_add(Glib::unwrap(this), Glib::unwrap(&page));
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesDialog * object, bool copy) -> Glib::RefPtr<turns::adw::PreferencesDialog>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::PreferencesDialog>(
+ dynamic_cast<turns::adw::PreferencesDialog *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/preferencespage.cpp b/adw/src/preferencespage.cpp
new file mode 100644
index 0000000..475f591
--- /dev/null
+++ b/adw/src/preferencespage.cpp
@@ -0,0 +1,83 @@
+#include "turns/adw/preferencespage.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <glibmm/utility.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/init.h>
+#include <gtkmm/private/widget_p.h>
+#include <gtkmm/widget.h>
+
+#include <adwaita.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace turns::adw
+{
+ namespace
+ {
+ auto constinit _class = PreferencesPage::Class{};
+ }
+
+ auto PreferencesPage::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &PreferencesPage::Class::class_init_function;
+ register_derived_type(adw_preferences_page_get_type());
+ }
+ return *this;
+ }
+
+ auto PreferencesPage::Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwPreferencesPageClass *>(gclass);
+ Gtk::Widget_Class::class_init_function(klass, data);
+ }
+
+ auto PreferencesPage::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new PreferencesPage(ADW_PREFERENCES_PAGE(object));
+ }
+
+ auto PreferencesPage::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto PreferencesPage::get_base_type() -> GType
+ {
+ return adw_preferences_page_get_type();
+ }
+
+ PreferencesPage::PreferencesPage(Glib::ConstructParams const & params)
+ : Gtk::Widget{params}
+ {
+ }
+
+ PreferencesPage::PreferencesPage(AdwPreferencesPage * gobj)
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Widget(GTK_WIDGET(gobj))
+ {
+ }
+
+ PreferencesPage::PreferencesPage()
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Widget{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesPage * object, bool copy) -> Glib::RefPtr<turns::adw::PreferencesPage>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::PreferencesPage>(
+ dynamic_cast<turns::adw::PreferencesPage *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/preferencesrow.cpp b/adw/src/preferencesrow.cpp
new file mode 100644
index 0000000..ef9b281
--- /dev/null
+++ b/adw/src/preferencesrow.cpp
@@ -0,0 +1,107 @@
+#include "turns/adw/preferencesrow.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+#include <glibmm/utility.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/init.h>
+#include <gtkmm/listboxrow.h>
+#include <gtkmm/private/widget_p.h>
+
+#include <adwaita.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace turns::adw
+{
+ namespace
+ {
+ auto constinit _class = PreferencesRow::Class{};
+ }
+
+ auto PreferencesRow::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &PreferencesRow::Class::class_init_function;
+ register_derived_type(adw_preferences_row_get_type());
+ }
+ return *this;
+ }
+
+ auto PreferencesRow::Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwPreferencesRowClass *>(gclass);
+ Gtk::Widget_Class::class_init_function(klass, data);
+ }
+
+ auto PreferencesRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new PreferencesRow(ADW_PREFERENCES_ROW(object));
+ }
+
+ auto PreferencesRow::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto PreferencesRow::get_base_type() -> GType
+ {
+ return adw_preferences_row_get_type();
+ }
+
+ PreferencesRow::PreferencesRow()
+ : Glib::ObjectBase{nullptr}
+ , Gtk::ListBoxRow{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto PreferencesRow::set_title(Glib::ustring const & title) -> CppObjectType &
+ {
+ adw_preferences_row_set_title(Glib::unwrap(this), title.c_str());
+ return *this;
+ }
+
+ auto PreferencesRow::set_title_selectable(bool selectable) noexcept -> CppObjectType &
+ {
+ adw_preferences_row_set_title_selectable(Glib::unwrap(this), selectable);
+ return *this;
+ }
+
+ auto PreferencesRow::set_use_markup(bool use) noexcept -> CppObjectType &
+ {
+ adw_preferences_row_set_use_markup(Glib::unwrap(this), use);
+ return *this;
+ }
+
+ auto PreferencesRow::set_use_underline(bool use) noexcept -> CppObjectType &
+ {
+ adw_preferences_row_set_use_underline(Glib::unwrap(this), use);
+ return *this;
+ }
+
+ PreferencesRow::PreferencesRow(Glib::ConstructParams const & params)
+ : Gtk::ListBoxRow{params}
+ {
+ }
+
+ PreferencesRow::PreferencesRow(BaseObjectType * gobj)
+ : Glib::ObjectBase{nullptr}
+ , Gtk::ListBoxRow(GTK_LIST_BOX_ROW(gobj))
+ {
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwPreferencesRow * object, bool copy) -> Glib::RefPtr<turns::adw::PreferencesRow>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::PreferencesRow>(
+ dynamic_cast<turns::adw::PreferencesRow *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/toast.cpp b/adw/src/toast.cpp
index 4f8d28a..a173532 100644
--- a/adw/src/toast.cpp
+++ b/adw/src/toast.cpp
@@ -21,14 +21,12 @@ namespace turns::adw
static_assert(static_cast<int>(Toast::Priority::NORMAL) == ADW_TOAST_PRIORITY_NORMAL);
static_assert(static_cast<int>(Toast::Priority::HIGH) == ADW_TOAST_PRIORITY_HIGH);
- struct Toast_Class : Glib::Class
+ namespace
{
- auto init() -> Glib::Class const &;
- auto static class_init_function(void * gclass, void * data) -> void;
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
+ auto constinit _class = Toast::Class{};
+ } // namespace
- auto Toast_Class::init() -> Glib::Class const &
+ auto Toast::Class::init() -> Glib::Class const &
{
if (!gtype_)
{
@@ -37,22 +35,20 @@ namespace turns::adw
return *this;
}
- auto Toast_Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ auto Toast::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
{
return new Toast(ADW_TOAST(object));
}
- Toast_Class Toast::s_class{};
-
Toast::Toast(Glib::ustring const & title)
: Glib::ObjectBase{nullptr}
- , Glib::Object{Glib::ConstructParams{s_class.init(), "title", Glib::c_str_or_nullptr(title), nullptr}}
+ , Glib::Object{Glib::ConstructParams{_class.init(), "title", Glib::c_str_or_nullptr(title), nullptr}}
{
}
auto Toast::get_type() -> GType
{
- return s_class.init().get_type();
+ return _class.init().get_type();
}
auto Toast::get_base_type() -> GType
@@ -70,7 +66,7 @@ namespace turns::adw
{
}
- Toast::Toast(AdwToast * gobj)
+ Toast::Toast(BaseObjectType * gobj)
: Glib::ObjectBase{nullptr}
, Glib::Object((GObject *)gobj)
{
diff --git a/adw/src/toastoverlay.cpp b/adw/src/toastoverlay.cpp
index ca877a6..27e0824 100644
--- a/adw/src/toastoverlay.cpp
+++ b/adw/src/toastoverlay.cpp
@@ -19,13 +19,12 @@
namespace turns::adw
{
- struct ToastOverlay_Class : Glib::Class
+ namespace
{
- auto init() -> Glib::Class const &;
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
+ auto constinit _class = ToastOverlay::Class{};
+ } // namespace
- auto ToastOverlay_Class::init() -> Glib::Class const &
+ auto ToastOverlay::Class::init() -> Glib::Class const &
{
if (!gtype_)
{
@@ -34,16 +33,14 @@ namespace turns::adw
return *this;
}
- auto ToastOverlay_Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ auto ToastOverlay::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
{
return new ToastOverlay(ADW_TOAST_OVERLAY(object));
}
- ToastOverlay_Class ToastOverlay::s_class{};
-
auto ToastOverlay::get_type() -> GType
{
- return s_class.init().get_type();
+ return _class.init().get_type();
}
auto ToastOverlay::get_base_type() -> GType
@@ -61,7 +58,7 @@ namespace turns::adw
{
}
- ToastOverlay::ToastOverlay(AdwToastOverlay * gobj)
+ ToastOverlay::ToastOverlay(BaseObjectType * gobj)
: Glib::ObjectBase{nullptr}
, Gtk::Widget((GtkWidget *)gobj)
{
@@ -69,7 +66,7 @@ namespace turns::adw
ToastOverlay::ToastOverlay()
: Glib::ObjectBase{nullptr}
- , Gtk::Widget{Glib::ConstructParams{s_class.init()}}
+ , Gtk::Widget{Glib::ConstructParams{_class.init()}}
{
}
diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp
index 546f31e..6998f90 100644
--- a/adw/src/wrap_init.cpp
+++ b/adw/src/wrap_init.cpp
@@ -1,6 +1,11 @@
#include "turns/adw/wrap_init.hpp"
+#include "turns/adw/actionrow.hpp"
#include "turns/adw/application.hpp"
+#include "turns/adw/dialog.hpp"
+#include "turns/adw/preferencesdialog.hpp"
+#include "turns/adw/preferencespage.hpp"
+#include "turns/adw/preferencesrow.hpp"
#include "turns/adw/toast.hpp"
#include "turns/adw/toastoverlay.hpp"
@@ -9,32 +14,31 @@
#include <adwaita.h>
#include <glib-object.h>
+#define WRAP_CLASS(Name, name) Glib::wrap_register(adw_##name##_get_type(), &Name::Class::wrap_new)
+#define ENSURE_TYPE(Name) g_type_ensure(Name::get_type())
+
namespace turns::adw
{
- struct Application_Class
- {
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
-
- struct Toast_Class
- {
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
-
- struct ToastOverlay_Class
- {
- auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
- };
-
auto wrap_init() -> void
{
adw_init();
- Glib::wrap_register(adw_application_get_type(), &Application_Class::wrap_new);
- g_type_ensure(Application::get_type());
- Glib::wrap_register(adw_toast_get_type(), &Toast_Class::wrap_new);
- g_type_ensure(Toast::get_type());
- Glib::wrap_register(adw_toast_overlay_get_type(), &ToastOverlay_Class::wrap_new);
- g_type_ensure(ToastOverlay::get_type());
+ WRAP_CLASS(ActionRow, action_row);
+ WRAP_CLASS(Application, application);
+ WRAP_CLASS(Dialog, dialog);
+ WRAP_CLASS(Toast, toast);
+ WRAP_CLASS(PreferencesDialog, preferences_dialog);
+ WRAP_CLASS(PreferencesPage, preferences_page);
+ WRAP_CLASS(PreferencesRow, preferences_row);
+ WRAP_CLASS(ToastOverlay, toast_overlay);
+
+ ENSURE_TYPE(ActionRow);
+ ENSURE_TYPE(Application);
+ ENSURE_TYPE(Dialog);
+ ENSURE_TYPE(Toast);
+ ENSURE_TYPE(PreferencesDialog);
+ ENSURE_TYPE(PreferencesPage);
+ ENSURE_TYPE(PreferencesRow);
+ ENSURE_TYPE(ToastOverlay);
}
} // namespace turns::adw \ No newline at end of file
diff --git a/app/ch.arknet.Turns.gschema.xml b/app/ch.arknet.Turns.gschema.xml
index 4281679..bffe837 100644
--- a/app/ch.arknet.Turns.gschema.xml
+++ b/app/ch.arknet.Turns.gschema.xml
@@ -2,17 +2,17 @@
<schemalist>
<schema path="/ch/arknet/Turns/" id="ch.arknet.Turns">
<key name="disposition-color-friendly" type="s">
- <default>'@green_3'</default>
+ <default>'#33d17a'</default>
<summary>Friendly Disposition Color</summary>
<description>The color used to shade friendly participants.</description>
</key>
<key name="disposition-color-hostile" type="s">
- <default>'@red_3'</default>
+ <default>'#e01b24'</default>
<summary>Hostile Disposition Color</summary>
<description>The color used to shade hostile participants.</description>
</key>
<key name="disposition-color-secret" type="s">
- <default>'@purple_3'</default>
+ <default>'#9141ac'</default>
<summary>Secret Disposition Color</summary>
<description>The color used to shade secret participants.</description>
</key>
diff --git a/style/style-dark.css b/style/style-dark.css
index 6a060da..928264a 100644
--- a/style/style-dark.css
+++ b/style/style-dark.css
@@ -1,25 +1,30 @@
-button.disposition-hostile {
- background-color: mix(shade(@red_3, 0.8), @window_bg_color, 0.5);
+@define-color hostile #e01b24;
+@define-color friendly #33d17a;
+@define-color secret #9141ac;
+
+
+.disposition-hostile {
+ background-color: mix(shade(@hostile, 0.8), @window_bg_color, 0.5);
}
-button:checked.disposition-hostile {
- background-color: mix(shade(@red_3, 0.5), @window_bg_color, 0.5);
+:checked.disposition-hostile {
+ background-color: mix(shade(@hostile, 0.5), @window_bg_color, 0.5);
}
-button.disposition-friendly {
- background-color: mix(shade(@green_3, 0.8), @window_bg_color, 0.5);
+.disposition-friendly {
+ background-color: mix(shade(@friendly, 0.8), @window_bg_color, 0.5);
}
-button:checked.disposition-friendly {
- background-color: mix(shade(@green_3, 0.5), @window_bg_color, 0.5);
+:checked.disposition-friendly {
+ background-color: mix(shade(@friendly, 0.5), @window_bg_color, 0.5);
}
-button.disposition-secret {
- background-color: mix(shade(@purple_3, 0.8), @window_bg_color, 0.5);
+.disposition-secret {
+ background-color: mix(shade(@secret, 0.8), @window_bg_color, 0.5);
}
-button:checked.disposition-secret {
- background-color: mix(shade(@purple_3, 0.5), @window_bg_color, 0.5);
+:checked.disposition-secret {
+ background-color: mix(shade(@secret, 0.5), @window_bg_color, 0.5);
}
.active-participant {
diff --git a/style/style.css b/style/style.css
index 78be454..a185c9b 100644
--- a/style/style.css
+++ b/style/style.css
@@ -1,6 +1,6 @@
-@define-color hostile @red_3;
-@define-color friendly @green_3;
-@define-color secret @purple_3;
+@define-color hostile #e01b24;
+@define-color friendly #33d17a;
+@define-color secret #9141ac;
.disposition-hostile {
background-color: mix(shade(@hostile, 1.6), @window_bg_color, 0.5);
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index b3a03c9..844460a 100644
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -3,6 +3,7 @@
add_library("ui"
"src/init.cpp"
"src/widgets/participant_row.cpp"
+ "src/widgets/preferences.cpp"
"src/widgets/turn_order_view.cpp"
"src/windows/participant_editor.cpp"
"src/windows/tracker.cpp"
diff --git a/ui/include/turns/ui/widgets/preferences.hpp b/ui/include/turns/ui/widgets/preferences.hpp
new file mode 100644
index 0000000..21b6eef
--- /dev/null
+++ b/ui/include/turns/ui/widgets/preferences.hpp
@@ -0,0 +1,42 @@
+#ifndef TURNS_UI_WIDGETS_PREFERENCES_HPP
+#define TURNS_UI_WIDGETS_PREFERENCES_HPP
+
+#include "turns/adw/actionrow.hpp"
+#include "turns/adw/preferencespage.hpp"
+#include "turns/ui/widgets/template_widget.hpp"
+
+#include <glibmm/refptr.h>
+
+#include <giomm/settings.h>
+
+#include <gtkmm/colordialogbutton.h>
+
+#include <array>
+
+namespace turns::ui::widgets
+{
+ struct preferences : template_widget<preferences, adw::PreferencesPage>
+ {
+
+ auto constexpr inline static children = std::array{
+ "friendly",
+ "hostile",
+ "secret",
+ };
+
+ explicit preferences(Glib::RefPtr<Gio::Settings> settings = {});
+
+ private:
+ Glib::RefPtr<Gio::Settings> m_settings;
+
+ adw::ActionRow * m_friendly;
+ adw::ActionRow * m_hostile;
+ adw::ActionRow * m_secret;
+
+ Gtk::ColorDialogButton m_friendly_button{};
+ Gtk::ColorDialogButton m_hostile_button{};
+ Gtk::ColorDialogButton m_secret_button{};
+ };
+} // namespace turns::ui::widgets
+
+#endif \ No newline at end of file
diff --git a/ui/include/turns/ui/windows/tracker.hpp b/ui/include/turns/ui/windows/tracker.hpp
index e14f08a..c6cbccb 100644
--- a/ui/include/turns/ui/windows/tracker.hpp
+++ b/ui/include/turns/ui/windows/tracker.hpp
@@ -3,6 +3,7 @@
#include "turns/adw/toastoverlay.hpp"
#include "turns/core/turn_order.hpp"
+#include "turns/ui/widgets/preferences.hpp"
#include "turns/ui/widgets/turn_order_view.hpp"
#include <glibmm/propertyproxy.h>
@@ -17,11 +18,13 @@
#include <gtkmm/applicationwindow.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
+#include <gtkmm/cssprovider.h>
#include <gtkmm/filedialog.h>
#include <gtkmm/revealer.h>
#include <gtkmm/stack.h>
#include <gtkmm/widget.h>
-#include <gtkmm/cssprovider.h>
+
+#include <adwaita.h>
#include <exception>
#include <string>
@@ -45,6 +48,7 @@ namespace turns::ui::windows
auto delete_participant(Glib::VariantBase param) -> void;
auto edit_participant(Glib::VariantBase param) -> void;
auto open() -> void;
+ auto preferences() -> void;
auto save(bool force_ask) -> void;
auto stop() -> void;
@@ -70,6 +74,7 @@ namespace turns::ui::windows
Gtk::Widget * m_title;
Glib::RefPtr<core::turn_order> m_turn_order;
widgets::turn_order_view * m_turn_order_view;
+ Glib::RefPtr<Gio::Settings> m_settings{};
Glib::PropertyProxy<Glib::ustring> m_subtitle;
Glib::RefPtr<Gio::File> m_file{};
@@ -77,7 +82,6 @@ namespace turns::ui::windows
std::string m_file_buffer{};
Glib::RefPtr<Gtk::CssProvider> m_css{};
- Glib::RefPtr<Gio::Settings> m_settings{};
};
} // namespace turns::ui::windows
diff --git a/ui/res/CMakeLists.txt b/ui/res/CMakeLists.txt
index 94d41ef..ff58108 100644
--- a/ui/res/CMakeLists.txt
+++ b/ui/res/CMakeLists.txt
@@ -6,6 +6,7 @@ target_link_libraries("ui-res" PRIVATE
set(UI_FILES
"widgets/participant_row.ui"
+ "widgets/preferences.ui"
"widgets/turn_order_view.ui"
"windows/participant_editor.ui"
"windows/tracker.ui"
diff --git a/ui/res/ui.cmb b/ui/res/ui.cmb
index 28ef448..0e3de6d 100644
--- a/ui/res/ui.cmb
+++ b/ui/res/ui.cmb
@@ -5,7 +5,8 @@
(1,None,None,"windows/tracker.ui",None,None,None,None,None,None,None),
(2,None,None,"windows/participant_editor.ui",None,None,None,None,None,None,None),
(3,1,None,"widgets/participant_row.ui",None,None,None,None,None,None,None),
- (4,1,None,"widgets/turn_order_view.ui",None,None,None,None,None,None,None)
+ (4,1,None,"widgets/turn_order_view.ui",None,None,None,None,None,None,None),
+ (6,1,None,"widgets/preferences.ui",None,None,None,None,None,None,None)
</ui>
<ui_library>
(1,"gtk","4.14",None),
@@ -39,6 +40,7 @@
(1,32,"GtkButton",None,31,None,None,None,None,None,None),
(1,33,"(item)",None,9,None,None,None,3,None,None),
(1,34,"(item)",None,9,None,None,None,1,None,None),
+ (1,44,"(item)",None,9,None,None,None,5,None,None),
(2,1,"AdwDialog","participant_editor",None,None,None,None,-1,None,None),
(2,2,"AdwToolbarView",None,1,None,None,None,-1,None,None),
(2,3,"AdwHeaderBar",None,2,None,"top",None,-1,None,None),
@@ -64,7 +66,12 @@
(4,2,"GtkProgressBar","progress",1,None,None,None,None,None,None),
(4,3,"GtkScrolledWindow",None,1,None,None,None,1,None,None),
(4,4,"AdwClamp",None,3,None,None,None,-1,None,None),
- (4,5,"GtkListBox","view",4,None,None,None,-1,None,None)
+ (4,5,"GtkListBox","view",4,None,None,None,-1,None,None),
+ (6,1,"AdwPreferencesPage","gtkmm__CustomObject_preferences",None,None,None,None,None,None,None),
+ (6,2,"AdwPreferencesGroup","colors",1,None,None,None,None,None,None),
+ (6,3,"AdwActionRow","friendly",2,None,None,None,None,None,None),
+ (6,4,"AdwActionRow","hostile",2,None,None,None,1,None,None),
+ (6,5,"AdwActionRow","secret",2,None,None,None,2,None,None)
</object>
<object_property>
(1,1,"AdwApplicationWindow","content",None,None,None,None,None,2,None,None,None,None),
@@ -84,8 +91,8 @@
(1,8,"GtkActionable","action-name","win.add_participant",None,None,None,None,None,None,None,None,None),
(1,8,"GtkButton","icon-name","contact-new",None,None,None,None,None,None,None,None,None),
(1,8,"GtkWidget","tooltip-text","Add participant",1,None,None,None,None,None,None,None,None),
- (1,10,"(item)","action","app.quit",None,None,None,None,None,None,None,None,None),
- (1,10,"(item)","label","_Quit",1,None,None,None,None,None,None,None,None),
+ (1,10,"(item)","action","win.preferences",None,None,None,None,None,None,None,None,None),
+ (1,10,"(item)","label","_Preferences",1,None,None,None,None,None,None,None,None),
(1,18,"GtkActionable","action-name","win.start",None,None,None,None,None,None,None,None,None),
(1,18,"GtkButton","icon-name","media-playback-start-symbolic",None,None,None,None,None,None,None,None,None),
(1,18,"GtkWidget","tooltip-text","Start turn order",1,None,None,None,None,None,None,None,None),
@@ -114,6 +121,8 @@
(1,33,"(item)","label","Save as...",1,None,None,None,None,None,None,None,None),
(1,34,"(item)","action","win.open",None,None,None,None,None,None,None,None,None),
(1,34,"(item)","label","_Open...",1,None,None,None,None,None,None,None,None),
+ (1,44,"(item)","action","app.quit",None,None,None,None,None,None,None,None,None),
+ (1,44,"(item)","label","_Quit",1,None,None,None,None,None,None,None,None),
(2,1,"AdwDialog","child",None,None,None,None,None,2,None,None,None,None),
(2,1,"AdwDialog","default-widget",None,None,None,None,None,None,None,None,None,None),
(2,1,"GtkWidget","hexpand","True",None,None,None,None,None,None,None,None,None),
@@ -166,7 +175,12 @@
(4,4,"GtkWidget","margin-end","12",None,None,None,None,None,None,None,None,None),
(4,4,"GtkWidget","margin-start","12",None,None,None,None,None,None,None,None,None),
(4,4,"GtkWidget","margin-top","12",None,None,None,None,None,None,None,None,None),
- (4,5,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None)
+ (4,5,"GtkWidget","valign","start",None,None,None,None,None,None,None,None,None),
+ (6,1,"AdwPreferencesPage","icon-name","preferences-system-symbolic",None,None,None,None,None,None,None,None,None),
+ (6,2,"AdwPreferencesGroup","title","Colors",1,None,None,None,None,None,None,None,None),
+ (6,3,"AdwPreferencesRow","title","Friendly",1,None,None,None,None,None,None,None,None),
+ (6,4,"AdwPreferencesRow","title","Hostile",1,None,None,None,None,None,None,None,None),
+ (6,5,"AdwPreferencesRow","title","Secret",1,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,1,"GtkWidget",2,2,None,1,None,None,None,None),
diff --git a/ui/src/widgets/preferences.cpp b/ui/src/widgets/preferences.cpp
new file mode 100644
index 0000000..24de613
--- /dev/null
+++ b/ui/src/widgets/preferences.cpp
@@ -0,0 +1,68 @@
+#include "turns/ui/widgets/preferences.hpp"
+
+#include "turns/adw/actionrow.hpp"
+#include "turns/ui/widgets/template_widget.hpp"
+
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+
+#include <giomm/settings.h>
+
+#include <gtkmm/colordialog.h>
+#include <gtkmm/enums.h>
+
+#include <gdkmm/rgba.h>
+
+namespace turns::ui::widgets
+{
+ namespace
+ {
+ auto constexpr static TYPE_NAME = "preferences";
+ auto constexpr static TEMPLATE = "/widgets/preferences.ui";
+ } // namespace
+
+ preferences::preferences(Glib::RefPtr<Gio::Settings> settings)
+ : Glib::ObjectBase{TYPE_NAME}
+ , template_widget{TEMPLATE}
+ , m_settings{settings}
+ , m_friendly{get_widget<adw::ActionRow>("friendly")}
+ , m_hostile{get_widget<adw::ActionRow>("hostile")}
+ , m_secret{get_widget<adw::ActionRow>("secret")}
+ {
+ if (!m_settings)
+ {
+ return;
+ }
+
+ m_friendly->add_suffix(m_friendly_button);
+ m_friendly->set_activatable_widget(m_friendly_button);
+ m_friendly_button.set_dialog(Gtk::ColorDialog::create());
+ m_friendly_button.set_valign(Gtk::Align::CENTER);
+ m_settings->bind<Glib::ustring, Gdk::RGBA>("disposition-color-friendly",
+ m_friendly_button.property_rgba(),
+ Gio::Settings::BindFlags::DEFAULT,
+ [](auto value) { return Gdk::RGBA{value}; },
+ [](auto color) { return color.to_string(); });
+
+ m_hostile->add_suffix(m_hostile_button);
+ m_hostile->set_activatable_widget(m_hostile_button);
+ m_hostile_button.set_dialog(Gtk::ColorDialog::create());
+ m_hostile_button.set_valign(Gtk::Align::CENTER);
+ m_settings->bind<Glib::ustring, Gdk::RGBA>("disposition-color-hostile",
+ m_hostile_button.property_rgba(),
+ Gio::Settings::BindFlags::DEFAULT,
+ [](auto value) { return Gdk::RGBA{value}; },
+ [](auto color) { return color.to_string(); });
+
+ m_secret->add_suffix(m_secret_button);
+ m_secret->set_activatable_widget(m_secret_button);
+ m_secret_button.set_dialog(Gtk::ColorDialog::create());
+ m_secret_button.set_valign(Gtk::Align::CENTER);
+ m_settings->bind<Glib::ustring, Gdk::RGBA>("disposition-color-secret",
+ m_secret_button.property_rgba(),
+ Gio::Settings::BindFlags::DEFAULT,
+ [](auto value) { return Gdk::RGBA{value}; },
+ [](auto color) { return color.to_string(); });
+ }
+
+} // namespace turns::ui::widgets \ No newline at end of file
diff --git a/ui/src/windows/tracker.cpp b/ui/src/windows/tracker.cpp
index c6dc731..b9a55c0 100644
--- a/ui/src/windows/tracker.cpp
+++ b/ui/src/windows/tracker.cpp
@@ -4,6 +4,7 @@
#include "turns/adw/toastoverlay.hpp"
#include "turns/core/turn_order.hpp"
#include "turns/lang/messages.hpp"
+#include "turns/ui/widgets/preferences.hpp"
#include "turns/ui/widgets/turn_order_view.hpp"
#include <sigc++/adaptors/bind.h>
@@ -15,6 +16,7 @@
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <glibmm/varianttype.h>
+#include <glibmm/wrap.h>
#include <giomm/liststore.h>
#include <giomm/settings.h>
@@ -53,9 +55,9 @@ namespace turns::ui::windows
, m_title{builder->get_widget<Gtk::Widget>("title")}
, m_turn_order{core::turn_order::create()}
, m_turn_order_view{Gtk::make_managed<widgets::turn_order_view>(m_turn_order)}
+ , m_settings{Gio::Settings::create("ch.arknet.Turns")}
, m_subtitle{m_title, "subtitle"}
, m_css{Gtk::CssProvider::create()}
- , m_settings{Gio::Settings::create("ch.arknet.Turns")}
{
setup_colors();
setup_actions();
@@ -141,10 +143,12 @@ namespace turns::ui::windows
// win.delete
// win.edit
// win.open
+ // win.preferences
{
add_action_with_parameter("delete", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::delete_participant));
add_action_with_parameter("edit", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::edit_participant));
add_action("open", sigc::mem_fun(*this, &tracker::open));
+ add_action("preferences", sigc::mem_fun(*this, &tracker::preferences));
}
// win.save
diff --git a/ui/src/windows/tracker/actions.cpp b/ui/src/windows/tracker/actions.cpp
index 3210089..c26afbf 100644
--- a/ui/src/windows/tracker/actions.cpp
+++ b/ui/src/windows/tracker/actions.cpp
@@ -1,6 +1,8 @@
+#include "turns/adw/preferencesdialog.hpp"
#include "turns/core/participant.hpp"
#include "turns/core/turn_order.hpp"
#include "turns/lang/messages.hpp"
+#include "turns/ui/widgets/preferences.hpp"
#include "turns/ui/windows/participant_editor.hpp"
#include "turns/ui/windows/tracker.hpp"
@@ -14,10 +16,12 @@
#include <glibmm/wrap.h>
#include <giomm/liststore.h>
+#include <giomm/settings.h>
#include <gtkmm/builder.h>
#include <gtkmm/filedialog.h>
#include <gtkmm/filefilter.h>
+#include <gtkmm/object.h>
#include <adwaita.h>
#include <gio/gio.h>
@@ -89,6 +93,15 @@ namespace turns::ui::windows
dialog->open(sigc::bind(sigc::mem_fun(*this, &tracker::on_open_response), dialog));
}
+ auto tracker::preferences() -> void
+ {
+ auto preferences = Gtk::make_managed<widgets::preferences>(m_settings);
+ auto dialog = Gtk::make_managed<adw::PreferencesDialog>();
+ dialog->add(*preferences);
+ adw_preferences_dialog_set_visible_page(Glib::unwrap(dialog), Glib::unwrap(preferences));
+ dialog->present(this);
+ }
+
auto tracker::save(bool force_ask) -> void
{
if (m_file && !force_ask)