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/src/actionrow.cpp | 102 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 18 deletions(-) (limited to 'adw/src/actionrow.cpp') 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 -- cgit v1.2.3