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/CMakeLists.txt | 5 + adw/include/turns/adw/actionrow.hpp | 149 +++++++++++++++++++++++++++ adw/include/turns/adw/application.hpp | 51 +++++---- adw/include/turns/adw/dialog.hpp | 64 ++++++++++++ adw/include/turns/adw/helpers/gobj_cast.hpp | 37 ------- adw/include/turns/adw/helpers/gobj_mixin.hpp | 37 +++++++ adw/include/turns/adw/preferencesdialog.hpp | 66 ++++++++++++ adw/include/turns/adw/preferencespage.hpp | 61 +++++++++++ adw/include/turns/adw/preferencesrow.hpp | 118 +++++++++++++++++++++ adw/include/turns/adw/toast.hpp | 85 ++++++++------- adw/include/turns/adw/toastoverlay.hpp | 54 +++++----- 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 +++++---- 20 files changed, 1168 insertions(+), 184 deletions(-) create mode 100644 adw/include/turns/adw/actionrow.hpp create mode 100644 adw/include/turns/adw/dialog.hpp delete mode 100644 adw/include/turns/adw/helpers/gobj_cast.hpp create mode 100644 adw/include/turns/adw/helpers/gobj_mixin.hpp create mode 100644 adw/include/turns/adw/preferencesdialog.hpp create mode 100644 adw/include/turns/adw/preferencespage.hpp create mode 100644 adw/include/turns/adw/preferencesrow.hpp 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') 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 +#include +#include + +#include + +using AdwActionRow = struct _AdwActionRow; + +namespace turns::adw +{ + struct ActionRow : adw::PreferencesRow, + helpers::gobj_mixin + { + 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::gobj; + using helpers::gobj_mixin::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(self, "activatable-widget"); + } + + auto ActionRow::property_icon_name(this auto && self) + { + return helpers::make_property_proxy(self, "icon-name"); + } + + auto ActionRow::property_subtitle(this auto && self) + { + return helpers::make_property_proxy(self, "subtitle"); + } + + auto ActionRow::property_subtitle_lines(this auto && self) + { + return helpers::make_property_proxy(self, "subtitle-lines"); + } + + auto ActionRow::property_subtitle_selectable(this auto && self) + { + return helpers::make_property_proxy(self, "subtitle-selectable"); + } + + auto ActionRow::property_title_lines(this auto && self) + { + return helpers::make_property_proxy(self, "title-lines"); + } + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwActionRow * object, bool copy = false) -> Glib::RefPtr; +} // 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 #include #include @@ -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(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 - auto gobj(this Self && self) noexcept - { - return reinterpret_cast(self.gobject_); - } + using helpers::gobj_mixin::gobj; + using helpers::gobj_mixin::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; + 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 +#include + +#include + +using AdwDialog = struct _AdwDialog; + +namespace turns::adw +{ + struct Dialog_Class; + + struct Dialog : Gtk::Widget, + helpers::gobj_mixin + { + 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::gobj; + using helpers::gobj_mixin::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; +} // 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_cast.hpp deleted file mode 100644 index 1ef9089..0000000 --- a/adw/include/turns/adw/helpers/gobj_cast.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef TURNS_ADW_HELPERS_GOBJ_CAST_HPP -#define TURNS_ADW_HELPERS_GOBJ_CAST_HPP - -#include - -#include - -namespace turns::adw::helpers -{ - - template - struct gobj_mixin - { - template - auto gobj(this Self && self) noexcept - { - using clean_type = std::remove_reference_t; - using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; - using cast_type = std::conditional_t, std::add_const_t, AdwType>; - - return reinterpret_cast(static_cast(self).gobj()); - } - - template - auto gobj_copy(this Self && self) noexcept -> AdwType * - { - using clean_type = std::remove_reference_t; - using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; - - static_cast(self).reference(); - return self.gobj(); - } - }; - -} // namespace turns::adw::helpers - -#endif \ No newline at end of file diff --git a/adw/include/turns/adw/helpers/gobj_mixin.hpp b/adw/include/turns/adw/helpers/gobj_mixin.hpp new file mode 100644 index 0000000..d9e5097 --- /dev/null +++ b/adw/include/turns/adw/helpers/gobj_mixin.hpp @@ -0,0 +1,37 @@ +#ifndef TURNS_ADW_HELPERS_GOBJ_MIXIN_HPP +#define TURNS_ADW_HELPERS_GOBJ_MIXIN_HPP + +#include + +#include + +namespace turns::adw::helpers +{ + + template + struct gobj_mixin + { + template + auto gobj(this Self && self) noexcept + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + using cast_type = std::conditional_t, std::add_const_t, AdwType>; + + return reinterpret_cast(static_cast(self).gobj()); + } + + template + auto gobj_copy(this Self && self) noexcept -> AdwType * + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + + static_cast(self).reference(); + return self.gobj(); + } + }; + +} // namespace turns::adw::helpers + +#endif \ No newline at end of file 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 +#include + +#include + +using AdwPreferencesDialog = struct _AdwPreferencesDialog; + +namespace turns::adw +{ + struct PreferencesDialog_Class; + + struct PreferencesDialog : adw::Dialog, + helpers::gobj_mixin + { + 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::gobj; + using helpers::gobj_mixin::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; +} // 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 +#include +#include + +#include + +using AdwPreferencesPage = struct _AdwPreferencesPage; + +namespace turns::adw +{ + struct PreferencesPage : Gtk::Widget, + helpers::gobj_mixin + { + 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::gobj; + using helpers::gobj_mixin::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; +} // 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 +#include +#include + +#include + +using AdwPreferencesRow = struct _AdwPreferencesRow; + +namespace turns::adw +{ + struct PreferencesRow : Gtk::ListBoxRow, + helpers::gobj_mixin + { + 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::gobj; + using helpers::gobj_mixin::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(self, "title"); + } + + auto PreferencesRow::property_title_selectable(this auto && self) + { + return helpers::make_property_proxy(self, "title-selectable"); + } + + auto PreferencesRow::property_use_markup(this auto && self) + { + return helpers::make_property_proxy(self, "use-markup"); + } + + auto PreferencesRow::property_use_underline(this auto && self) + { + return helpers::make_property_proxy(self, "use-underline"); + } + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwPreferencesRow * object, bool copy = false) -> Glib::RefPtr; +} // 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 @@ -11,101 +11,106 @@ #include +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + using AdwToast = struct _AdwToast; namespace turns::adw { - struct Toast_Class; - struct Toast final : Glib::Object, helpers::gobj_mixin { + 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::gobj; - using helpers::gobj_mixin::gobj_copy; + using helpers::gobj_mixin::gobj; + using helpers::gobj_mixin::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 auto property_action_name(this Self && self); - template auto property_action_target(this Self && self); - template auto property_button_label(this Self && self); - template auto property_custom_title(this Self && self); - template auto property_priority(this Self && self); - template auto property_timeout(this Self && self); - template auto property_title(this Self && self); - template 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 - auto Toast::property_action_name(this Self && self) + auto Toast::property_action_name(this auto && self) { return helpers::make_property_proxy(self, "action-name"); } - template - auto Toast::property_action_target(this Self && self) + auto Toast::property_action_target(this auto && self) { return helpers::make_property_proxy(self, "action-target"); } - template - auto Toast::property_button_label(this Self && self) + auto Toast::property_button_label(this auto && self) { return helpers::make_property_proxy(self, "button-label"); } - template - auto Toast::property_custom_title(this Self && self) + auto Toast::property_custom_title(this auto && self) { return helpers::make_property_proxy(self, "custom-title"); } - template - auto Toast::property_priority(this Self && self) + auto Toast::property_priority(this auto && self) { return helpers::make_property_proxy(self, "priority"); } - template - auto Toast::property_timeout(this Self && self) + auto Toast::property_timeout(this auto && self) { return helpers::make_property_proxy(self, "timeout"); } - template - auto Toast::property_title(this Self && self) + auto Toast::property_title(this auto && self) { return helpers::make_property_proxy(self, "title"); } - template - auto Toast::property_use_markup(this Self && self) + auto Toast::property_use_markup(this auto && self) { return helpers::make_property_proxy(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 #include -using AdwToastOverlay = struct _AdwToastOverlay; +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE namespace turns::adw { - struct ToastOverlay_Class; - - struct Toast; - struct ToastOverlay final : Gtk::Widget, helpers::gobj_mixin { - using helpers::gobj_mixin::gobj; - using helpers::gobj_mixin::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::gobj; + using helpers::gobj_mixin::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 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 - auto ToastOverlay::property_child(this Self && self) + auto ToastOverlay::property_child(this auto && self) { return helpers::make_property_proxy(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 +#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