From fb917713e55147c6b0de514924c4867d9e8d5894 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 17 Aug 2024 11:41:43 +0200 Subject: ui: add participant shading color preferences --- adw/src/actionrow.cpp | 142 ++++++++++++++++++++++++++++++++++++++++++ adw/src/application.cpp | 30 +++------ adw/src/dialog.cpp | 87 ++++++++++++++++++++++++++ adw/src/preferencesdialog.cpp | 91 +++++++++++++++++++++++++++ adw/src/preferencespage.cpp | 83 ++++++++++++++++++++++++ adw/src/preferencesrow.cpp | 107 +++++++++++++++++++++++++++++++ adw/src/toast.cpp | 20 +++--- adw/src/toastoverlay.cpp | 19 +++--- adw/src/wrap_init.cpp | 46 +++++++------- 9 files changed, 561 insertions(+), 64 deletions(-) create mode 100644 adw/src/actionrow.cpp create mode 100644 adw/src/dialog.cpp create mode 100644 adw/src/preferencesdialog.cpp create mode 100644 adw/src/preferencespage.cpp create mode 100644 adw/src/preferencesrow.cpp (limited to 'adw/src') 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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(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 + { + return Glib::make_refptr_for_instance( + dynamic_cast(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 #include #include -#include +#include #include @@ -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(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 { 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(flags), nullptr}} + , Gtk::Application{Glib::ConstructParams{_class.init(), "application_id", Glib::c_str_or_nullptr(id), "flags", static_cast(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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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(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 + { + return Glib::make_refptr_for_instance(dynamic_cast(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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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(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 + { + return Glib::make_refptr_for_instance( + dynamic_cast(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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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(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 + { + return Glib::make_refptr_for_instance( + dynamic_cast(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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +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(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 + { + return Glib::make_refptr_for_instance( + dynamic_cast(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(Toast::Priority::NORMAL) == ADW_TOAST_PRIORITY_NORMAL); static_assert(static_cast(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 #include +#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 -- cgit v1.2.3