From 5467a7c2b1fb1831ca726d1ecb6b46010d146ebc Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 27 Mar 2025 08:27:32 +0100 Subject: adw: clean up implementation --- adw/CMakeLists.txt | 1 + adw/include/turns/adw/actionrow.hpp | 98 ++++++-------------------- adw/include/turns/adw/application.hpp | 3 +- adw/include/turns/adw/applicationwindow.hpp | 64 +++++++++++++++++ adw/include/turns/adw/dialog.hpp | 7 +- adw/include/turns/adw/preferencesdialog.hpp | 3 +- adw/include/turns/adw/preferencespage.hpp | 3 +- adw/include/turns/adw/preferencesrow.hpp | 3 +- adw/include/turns/adw/switchrow.hpp | 10 ++- adw/src/actionrow.cpp | 102 +++++++++++++++++++++++----- adw/src/application.cpp | 6 +- adw/src/applicationwindow.cpp | 83 ++++++++++++++++++++++ adw/src/dialog.cpp | 14 ++-- adw/src/preferencesdialog.cpp | 12 ++-- adw/src/preferencespage.cpp | 17 +++-- adw/src/preferencesrow.cpp | 19 +++--- adw/src/switchrow.cpp | 13 +++- adw/src/toast.cpp | 10 ++- adw/src/toastoverlay.cpp | 13 +++- adw/src/wrap_init.cpp | 3 + 20 files changed, 339 insertions(+), 145 deletions(-) create mode 100644 adw/include/turns/adw/applicationwindow.hpp create mode 100644 adw/src/applicationwindow.cpp (limited to 'adw') diff --git a/adw/CMakeLists.txt b/adw/CMakeLists.txt index f1ac616..49ac424 100644 --- a/adw/CMakeLists.txt +++ b/adw/CMakeLists.txt @@ -1,6 +1,7 @@ add_library("adw" "src/actionrow.cpp" "src/application.cpp" + "src/applicationwindow.cpp" "src/dialog.cpp" "src/preferencesdialog.cpp" "src/preferencespage.cpp" diff --git a/adw/include/turns/adw/actionrow.hpp b/adw/include/turns/adw/actionrow.hpp index 15ddbb1..d098d65 100644 --- a/adw/include/turns/adw/actionrow.hpp +++ b/adw/include/turns/adw/actionrow.hpp @@ -2,16 +2,22 @@ #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 #include #include #include +#include +#include + using AdwActionRow = struct _AdwActionRow; +using AdwActionRowClass = struct _AdwActionRowClass; namespace turns::adw { @@ -21,9 +27,9 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwPreferencesRowClass; - using BaseClassType = struct AdwActionRowClass; + using BaseClassType = AdwActionRowClass; using BaseObjectType = AdwActionRow; - using CppClassParent = adw::PreferencesRow; + using CppClassParent = adw::PreferencesRow::Class; using CppObjectType = ActionRow; auto init() -> Glib::Class const &; @@ -53,12 +59,19 @@ namespace turns::adw 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 get_activatable_widget() const noexcept -> Glib::RefPtr; + [[deprecated("replaced by add_prefix")]] auto get_icon_name() const -> Glib::ustring; + auto get_subtitle() const -> Glib::ustring; + auto get_subtitle_lines() const noexcept -> int; + auto get_subtitle_selectable() const noexcept -> bool; + auto get_title_lines() const noexcept -> int; + + auto property_activatable_widget() noexcept -> Glib::PropertyProxy; + [[deprecated("replaced by add_prefix")]] auto property_icon_name() noexcept -> Glib::PropertyProxy; + auto property_subtitle() noexcept -> Glib::PropertyProxy; + auto property_subtitle_lines() noexcept -> Glib::PropertyProxy; + auto property_subtitle_selectable() noexcept -> Glib::PropertyProxy; + auto property_title_lines() noexcept -> Glib::PropertyProxy; auto set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &; [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> CppObjectType &; @@ -67,78 +80,11 @@ namespace turns::adw 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 diff --git a/adw/include/turns/adw/application.hpp b/adw/include/turns/adw/application.hpp index 64efcb0..df5e930 100644 --- a/adw/include/turns/adw/application.hpp +++ b/adw/include/turns/adw/application.hpp @@ -12,6 +12,7 @@ #include using AdwApplication = struct _AdwApplication; +using AdwApplicationClass = struct _AdwApplicationClass; namespace turns::adw { @@ -21,7 +22,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkApplicationClass; - using BaseClassType = struct AdwApplicationClass; + using BaseClassType = AdwApplicationClass; using BaseObjectType = AdwApplication; using CppClassParent = struct Gtk::Application_Class; using CppObjectType = Application; diff --git a/adw/include/turns/adw/applicationwindow.hpp b/adw/include/turns/adw/applicationwindow.hpp new file mode 100644 index 0000000..e5b02b0 --- /dev/null +++ b/adw/include/turns/adw/applicationwindow.hpp @@ -0,0 +1,64 @@ +#ifndef TURNS_ADW_APPLICATION_WINDOW_HPP +#define TURNS_ADW_APPLICATION_WINDOW_HPP + +#include "helpers/gobj_mixin.hpp" + +#include +#include +#include +#include + +#include +#include + +using AdwApplicationWindow = struct _AdwApplicationWindow; +using AdwApplicationWindowClass = struct _AdwApplicationWindowClass; + +namespace turns::adw +{ + struct ApplicationWindow : Gtk::ApplicationWindow, + helpers::gobj_mixin + { + struct Class : Glib::Class + { + using BaseClassParent = GtkApplicationWindowClass; + using BaseClassType = AdwApplicationWindowClass; + using BaseObjectType = AdwApplicationWindow; + using CppClassParent = struct Gtk::ApplicationWindow_Class; + using CppObjectType = ApplicationWindow; + + 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 ApplicationWindow(Gtk::Application & app); + ApplicationWindow(ApplicationWindow const & other) = delete; + ApplicationWindow(ApplicationWindow && other) noexcept = default; + + auto operator=(ApplicationWindow const & other) noexcept -> ApplicationWindow & = delete; + auto operator=(ApplicationWindow && other) noexcept -> ApplicationWindow & = default; + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + protected: + explicit ApplicationWindow(Glib::ConstructParams const & params); + explicit ApplicationWindow(BaseObjectType * gobj); + }; +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwApplicationWindow * object, bool copy = false) -> turns::adw::ApplicationWindow *; +} // namespace Glib + +#endif \ No newline at end of file diff --git a/adw/include/turns/adw/dialog.hpp b/adw/include/turns/adw/dialog.hpp index af5f5da..75a095c 100644 --- a/adw/include/turns/adw/dialog.hpp +++ b/adw/include/turns/adw/dialog.hpp @@ -4,11 +4,16 @@ #include "helpers/gobj_mixin.hpp" #include +#include +#include #include #include +#include + using AdwDialog = struct _AdwDialog; +using AdwDialogClass = struct _AdwDialogClass; namespace turns::adw { @@ -20,7 +25,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkWidgetClass; - using BaseClassType = struct AdwDialogClass; + using BaseClassType = AdwDialogClass; using BaseObjectType = AdwDialog; using CppClassParent = struct Gtk::Widget_Class; using CppObjectType = Dialog; diff --git a/adw/include/turns/adw/preferencesdialog.hpp b/adw/include/turns/adw/preferencesdialog.hpp index 06ac600..85735ef 100644 --- a/adw/include/turns/adw/preferencesdialog.hpp +++ b/adw/include/turns/adw/preferencesdialog.hpp @@ -11,6 +11,7 @@ #include using AdwPreferencesDialog = struct _AdwPreferencesDialog; +using AdwPreferencesDialogClass = struct _AdwPreferencesDialogClass; namespace turns::adw { @@ -22,7 +23,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwDialogClass; - using BaseClassType = struct AdwPreferencesDialogClass; + using BaseClassType = AdwPreferencesDialogClass; using BaseObjectType = AdwPreferencesDialog; using CppClassParent = adw::Dialog::Class; using CppObjectType = PreferencesDialog; diff --git a/adw/include/turns/adw/preferencespage.hpp b/adw/include/turns/adw/preferencespage.hpp index 30e7eed..b8b4051 100644 --- a/adw/include/turns/adw/preferencespage.hpp +++ b/adw/include/turns/adw/preferencespage.hpp @@ -10,6 +10,7 @@ #include using AdwPreferencesPage = struct _AdwPreferencesPage; +using AdwPreferencesPageClass = struct _AdwPreferencesPageClass; namespace turns::adw { @@ -19,7 +20,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkWidgetClass; - using BaseClassType = struct AdwPreferencesPageClass; + using BaseClassType = AdwPreferencesPageClass; using BaseObjectType = AdwPreferencesPage; using CppClassParent = struct Gtk::Widget_Class; using CppObjectType = PreferencesPage; diff --git a/adw/include/turns/adw/preferencesrow.hpp b/adw/include/turns/adw/preferencesrow.hpp index 6f831b0..a0f22ed 100644 --- a/adw/include/turns/adw/preferencesrow.hpp +++ b/adw/include/turns/adw/preferencesrow.hpp @@ -11,6 +11,7 @@ #include using AdwPreferencesRow = struct _AdwPreferencesRow; +using AdwPreferencesRowClass = struct _AdwPreferencesRowClass; namespace turns::adw { @@ -20,7 +21,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkListBoxRowClass; - using BaseClassType = struct AdwPreferencesRowClass; + using BaseClassType = AdwPreferencesRowClass; using BaseObjectType = AdwPreferencesRow; using CppClassParent = struct Gtk::ListBoxRow_Class; using CppObjectType = PreferencesRow; diff --git a/adw/include/turns/adw/switchrow.hpp b/adw/include/turns/adw/switchrow.hpp index ed5190a..e7e0131 100644 --- a/adw/include/turns/adw/switchrow.hpp +++ b/adw/include/turns/adw/switchrow.hpp @@ -6,11 +6,17 @@ #include "turns/adw/helpers/properties.hpp" #include +#include +#include #include #include #include +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + using AdwSwitchRow = struct _AdwSwitchRow; namespace turns::adw @@ -21,9 +27,9 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwActionRowClass; - using BaseClassType = struct AdwSwitchRowClass; + using BaseClassType = AdwSwitchRowClass; using BaseObjectType = AdwSwitchRow; - using CppClassParent = adw::ActionRow; + using CppClassParent = adw::ActionRow::Class; using CppObjectType = SwitchRow; auto init() -> Glib::Class const &; diff --git a/adw/src/actionrow.cpp b/adw/src/actionrow.cpp index f45f7a3..e8cfc7d 100644 --- a/adw/src/actionrow.cpp +++ b/adw/src/actionrow.cpp @@ -1,10 +1,12 @@ #include "turns/adw/actionrow.hpp" +#include "turns/adw/helpers/properties.hpp" #include "turns/adw/preferencesrow.hpp" #include #include #include +#include #include #include #include @@ -12,10 +14,13 @@ #include #include +#include #include +#include #include #include +#include #include namespace turns::adw @@ -29,7 +34,7 @@ namespace turns::adw { if (!gtype_) { - class_init_func_ = &ActionRow::Class::class_init_function; + class_init_func_ = &class_init_function; register_derived_type(adw_action_row_get_type()); } return *this; @@ -37,13 +42,13 @@ namespace turns::adw 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 const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); } auto ActionRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new ActionRow(ADW_ACTION_ROW(object)); + return Gtk::manage(new ActionRow(ADW_ACTION_ROW(object))); } auto ActionRow::get_type() -> GType @@ -62,6 +67,16 @@ namespace turns::adw { } + ActionRow::ActionRow(Glib::ConstructParams const & params) + : adw::PreferencesRow{params} + { + } + + ActionRow::ActionRow(BaseObjectType * gobj) + : adw::PreferencesRow(ADW_PREFERENCES_ROW(gobj)) + { + } + auto ActionRow::add_prefix(Gtk::Widget & widget) -> ActionRow & { adw_action_row_add_prefix(Glib::unwrap(this), Glib::unwrap(&widget)); @@ -80,6 +95,69 @@ namespace turns::adw return *this; } + auto ActionRow::get_activatable_widget() const noexcept -> Glib::RefPtr + { + return Glib::make_refptr_for_instance(Glib::wrap(adw_action_row_get_activatable_widget(const_cast(Glib::unwrap(this))))); + } + + auto ActionRow::get_icon_name() const -> Glib::ustring + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + return adw_action_row_get_icon_name(const_cast(Glib::unwrap(this))); +#pragma GCC diagnostic pop + } + + auto ActionRow::get_subtitle() const -> Glib::ustring + { + return adw_action_row_get_subtitle(const_cast(Glib::unwrap(this))); + } + + auto ActionRow::get_subtitle_lines() const noexcept -> int + { + return adw_action_row_get_subtitle_lines(const_cast(Glib::unwrap(this))); + } + + auto ActionRow::get_subtitle_selectable() const noexcept -> bool + { + return adw_action_row_get_subtitle_selectable(const_cast(Glib::unwrap(this))); + } + + auto ActionRow::get_title_lines() const noexcept -> int + { + return adw_action_row_get_title_lines(const_cast(Glib::unwrap(this))); + } + + auto ActionRow::property_activatable_widget() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "activatable-widget"); + } + + auto ActionRow::property_icon_name() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "icon-name"); + } + + auto ActionRow::property_subtitle() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "subtitle"); + } + + auto ActionRow::property_subtitle_lines() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "subtitle-lines"); + } + + auto ActionRow::property_subtitle_selectable() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "subtitle-selectable"); + } + + auto ActionRow::property_title_lines() noexcept -> Glib::PropertyProxy + { + return helpers::make_property_proxy(*this, "title-lines"); + } + auto ActionRow::set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType & { adw_action_row_set_activatable_widget(Glib::unwrap(this), Glib::unwrap(&widget)); @@ -109,7 +187,7 @@ namespace turns::adw auto ActionRow::set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType & { - adw_action_row_set_subtitle_selectable(Glib::unwrap(this), subtitle_selectable); + adw_action_row_set_subtitle_selectable(Glib::unwrap(this), static_cast(subtitle_selectable)); return *this; } @@ -119,24 +197,12 @@ namespace turns::adw 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))); + 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 1fe47c3..05bc07a 100644 --- a/adw/src/application.cpp +++ b/adw/src/application.cpp @@ -77,8 +77,7 @@ namespace turns::adw } Application::Application(AdwApplication * gobj) - : Glib::ObjectBase{nullptr} - , Gtk::Application((GtkApplication *)gobj) + : Gtk::Application((GtkApplication *)gobj) { } @@ -94,7 +93,6 @@ namespace Glib { auto wrap(AdwApplication * object, bool copy) -> Glib::RefPtr { - return Glib::make_refptr_for_instance( - dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy))); + 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/applicationwindow.cpp b/adw/src/applicationwindow.cpp new file mode 100644 index 0000000..af21a5e --- /dev/null +++ b/adw/src/applicationwindow.cpp @@ -0,0 +1,83 @@ +#include "turns/adw/applicationwindow.hpp" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace turns::adw +{ + namespace + { + auto constinit _class = ApplicationWindow::Class{}; + } // namespace + + auto ApplicationWindow::Class::init() -> Glib::Class const & + { + if (!gtype_) + { + class_init_func_ = &class_init_function; + register_derived_type(adw_application_window_get_type()); + } + return *this; + } + + auto ApplicationWindow::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); + } + + auto ApplicationWindow::Class::wrap_new(GObject * object) -> Glib::ObjectBase * + { + return new ApplicationWindow(ADW_APPLICATION_WINDOW(object)); + } + + auto ApplicationWindow::get_type() -> GType + { + return _class.init().get_type(); + } + + auto ApplicationWindow::get_base_type() -> GType + { + return adw_application_window_get_type(); + } + + ApplicationWindow::ApplicationWindow(Gtk::Application & app) + : Glib::ObjectBase{nullptr} + , Gtk::ApplicationWindow{Glib::ConstructParams{_class.init(), "app", &app, nullptr}} + { + } + + ApplicationWindow::ApplicationWindow(Glib::ConstructParams const & params) + : Gtk::ApplicationWindow{params} + { + } + + ApplicationWindow::ApplicationWindow(BaseObjectType * gobj) + : Gtk::ApplicationWindow(GTK_APPLICATION_WINDOW(gobj)) + { + } + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwApplicationWindow * object, bool copy) -> turns::adw::ApplicationWindow * + { + return dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy)); + } +} // namespace Glib \ No newline at end of file diff --git a/adw/src/dialog.cpp b/adw/src/dialog.cpp index 3fe9752..c6d5e2b 100644 --- a/adw/src/dialog.cpp +++ b/adw/src/dialog.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -27,7 +28,7 @@ namespace turns::adw { if (!gtype_) { - class_init_func_ = &Dialog::Class::class_init_function; + class_init_func_ = &class_init_function; register_derived_type(adw_dialog_get_type()); } return *this; @@ -35,13 +36,13 @@ namespace turns::adw 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 const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); } auto Dialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new Dialog(ADW_DIALOG(object)); + return Gtk::manage(new Dialog(ADW_DIALOG(object))); } auto Dialog::get_type() -> GType @@ -60,8 +61,7 @@ namespace turns::adw } Dialog::Dialog(AdwDialog * gobj) - : Glib::ObjectBase{nullptr} - , Gtk::Widget(GTK_WIDGET(gobj)) + : Gtk::Widget(GTK_WIDGET(gobj)) { } @@ -82,6 +82,6 @@ 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))); + 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 index b18c0e6..10419fe 100644 --- a/adw/src/preferencesdialog.cpp +++ b/adw/src/preferencesdialog.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ namespace turns::adw { if (!gtype_) { - class_init_func_ = &PreferencesDialog::Class::class_init_function; + class_init_func_ = &class_init_function; register_derived_type(adw_preferences_dialog_get_type()); } return *this; @@ -38,13 +39,13 @@ namespace turns::adw 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 const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); } auto PreferencesDialog::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new PreferencesDialog(ADW_PREFERENCES_DIALOG(object)); + return Gtk::manage(new PreferencesDialog(ADW_PREFERENCES_DIALOG(object))); } auto PreferencesDialog::get_type() -> GType @@ -63,8 +64,7 @@ namespace turns::adw } PreferencesDialog::PreferencesDialog(AdwPreferencesDialog * gobj) - : Glib::ObjectBase{nullptr} - , adw::Dialog(ADW_DIALOG(gobj)) + : adw::Dialog(ADW_DIALOG(gobj)) { } diff --git a/adw/src/preferencespage.cpp b/adw/src/preferencespage.cpp index 475f591..8467e29 100644 --- a/adw/src/preferencespage.cpp +++ b/adw/src/preferencespage.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -21,13 +22,13 @@ namespace turns::adw namespace { auto constinit _class = PreferencesPage::Class{}; - } + } // namespace auto PreferencesPage::Class::init() -> Glib::Class const & { if (!gtype_) { - class_init_func_ = &PreferencesPage::Class::class_init_function; + class_init_func_ = &class_init_function; register_derived_type(adw_preferences_page_get_type()); } return *this; @@ -35,13 +36,13 @@ namespace turns::adw 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 const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); } auto PreferencesPage::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new PreferencesPage(ADW_PREFERENCES_PAGE(object)); + return Gtk::manage(new PreferencesPage(ADW_PREFERENCES_PAGE(object))); } auto PreferencesPage::get_type() -> GType @@ -60,8 +61,7 @@ namespace turns::adw } PreferencesPage::PreferencesPage(AdwPreferencesPage * gobj) - : Glib::ObjectBase{nullptr} - , Gtk::Widget(GTK_WIDGET(gobj)) + : Gtk::Widget(GTK_WIDGET(gobj)) { } @@ -77,7 +77,6 @@ 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))); + 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 index ef9b281..039da96 100644 --- a/adw/src/preferencesrow.cpp +++ b/adw/src/preferencesrow.cpp @@ -10,7 +10,8 @@ #include #include -#include +#include +#include #include #include @@ -21,13 +22,13 @@ namespace turns::adw namespace { auto constinit _class = PreferencesRow::Class{}; - } + } // namespace auto PreferencesRow::Class::init() -> Glib::Class const & { if (!gtype_) { - class_init_func_ = &PreferencesRow::Class::class_init_function; + class_init_func_ = &class_init_function; register_derived_type(adw_preferences_row_get_type()); } return *this; @@ -35,13 +36,13 @@ namespace turns::adw 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 const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); } auto PreferencesRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new PreferencesRow(ADW_PREFERENCES_ROW(object)); + return Gtk::manage(new PreferencesRow(ADW_PREFERENCES_ROW(object))); } auto PreferencesRow::get_type() -> GType @@ -90,8 +91,7 @@ namespace turns::adw } PreferencesRow::PreferencesRow(BaseObjectType * gobj) - : Glib::ObjectBase{nullptr} - , Gtk::ListBoxRow(GTK_LIST_BOX_ROW(gobj)) + : Gtk::ListBoxRow(GTK_LIST_BOX_ROW(gobj)) { } @@ -101,7 +101,6 @@ 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))); + 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/switchrow.cpp b/adw/src/switchrow.cpp index 8e9508d..3bd4a89 100644 --- a/adw/src/switchrow.cpp +++ b/adw/src/switchrow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -23,14 +24,21 @@ namespace turns::adw { if (!gtype_) { + class_init_func_ = &class_init_function; gtype_ = adw_switch_row_get_type(); } return *this; } + auto SwitchRow::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); + } + auto SwitchRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new SwitchRow(ADW_SWITCH_ROW(object)); + return Gtk::manage(new SwitchRow(ADW_SWITCH_ROW(object))); } SwitchRow::SwitchRow() @@ -55,8 +63,7 @@ namespace turns::adw } SwitchRow::SwitchRow(BaseObjectType * gobj) - : Glib::ObjectBase{nullptr} - , adw::ActionRow(ADW_ACTION_ROW(gobj)) + : adw::ActionRow(ADW_ACTION_ROW(gobj)) { } diff --git a/adw/src/toast.cpp b/adw/src/toast.cpp index a173532..c830496 100644 --- a/adw/src/toast.cpp +++ b/adw/src/toast.cpp @@ -30,11 +30,18 @@ namespace turns::adw { if (!gtype_) { + class_init_func_ = &class_init_function; gtype_ = adw_toast_get_type(); } return *this; } + auto Toast::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); + } + auto Toast::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { return new Toast(ADW_TOAST(object)); @@ -67,8 +74,7 @@ namespace turns::adw } Toast::Toast(BaseObjectType * gobj) - : Glib::ObjectBase{nullptr} - , Glib::Object((GObject *)gobj) + : Glib::Object((GObject *)gobj) { } diff --git a/adw/src/toastoverlay.cpp b/adw/src/toastoverlay.cpp index 27e0824..d785e60 100644 --- a/adw/src/toastoverlay.cpp +++ b/adw/src/toastoverlay.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -28,14 +29,21 @@ namespace turns::adw { if (!gtype_) { + class_init_func_ = &class_init_function; gtype_ = adw_toast_overlay_get_type(); } return *this; } + auto ToastOverlay::Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast(gclass); + CppClassParent::class_init_function(klass, data); + } + auto ToastOverlay::Class::wrap_new(GObject * object) -> Glib::ObjectBase * { - return new ToastOverlay(ADW_TOAST_OVERLAY(object)); + return Gtk::manage(new ToastOverlay(ADW_TOAST_OVERLAY(object))); } auto ToastOverlay::get_type() -> GType @@ -59,8 +67,7 @@ namespace turns::adw } ToastOverlay::ToastOverlay(BaseObjectType * gobj) - : Glib::ObjectBase{nullptr} - , Gtk::Widget((GtkWidget *)gobj) + : Gtk::Widget((GtkWidget *)gobj) { } diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp index f77dacd..16f87c3 100644 --- a/adw/src/wrap_init.cpp +++ b/adw/src/wrap_init.cpp @@ -2,6 +2,7 @@ #include "turns/adw/actionrow.hpp" #include "turns/adw/application.hpp" +#include "turns/adw/applicationwindow.hpp" #include "turns/adw/dialog.hpp" #include "turns/adw/preferencesdialog.hpp" #include "turns/adw/preferencespage.hpp" @@ -26,6 +27,7 @@ namespace turns::adw WRAP_CLASS(ActionRow, action_row); WRAP_CLASS(Application, application); + WRAP_CLASS(ApplicationWindow, application_window); WRAP_CLASS(Dialog, dialog); WRAP_CLASS(Toast, toast); WRAP_CLASS(PreferencesDialog, preferences_dialog); @@ -36,6 +38,7 @@ namespace turns::adw ENSURE_TYPE(ActionRow); ENSURE_TYPE(Application); + ENSURE_TYPE(ApplicationWindow); ENSURE_TYPE(Dialog); ENSURE_TYPE(Toast); ENSURE_TYPE(PreferencesDialog); -- cgit v1.2.3