diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-26 18:05:40 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-26 18:05:40 +0200 |
| commit | 663ec6def00cb498eb12de363ddb721828ab8175 (patch) | |
| tree | 38355f679c8fe206f3382392dc788efa9201f91f | |
| parent | 558bfbab432caaafa324e669d0987457b5e48b80 (diff) | |
| download | turns-663ec6def00cb498eb12de363ddb721828ab8175.tar.xz turns-663ec6def00cb498eb12de363ddb721828ab8175.zip | |
adw: add missing ActionRow functions
| -rw-r--r-- | adw/include/adwaitamm/actionrow.hpp | 16 | ||||
| -rw-r--r-- | adw/include/adwaitamm/private/actionrow_p.hpp | 3 | ||||
| -rw-r--r-- | adw/src/actionrow.cpp | 87 | ||||
| -rw-r--r-- | adw/src/private/actionrow_p.cpp | 44 |
4 files changed, 119 insertions, 31 deletions
diff --git a/adw/include/adwaitamm/actionrow.hpp b/adw/include/adwaitamm/actionrow.hpp index b6507b7..8b5db03 100644 --- a/adw/include/adwaitamm/actionrow.hpp +++ b/adw/include/adwaitamm/actionrow.hpp @@ -14,7 +14,7 @@ #include <glibmm/object.h> #include <glibmm/objectbase.h> #include <glibmm/propertyproxy.h> -#include <glibmm/refptr.h> +#include <glibmm/signalproxy.h> #include <glibmm/ustring.h> #include <gtkmm/widget.h> @@ -49,17 +49,21 @@ namespace Adwaita auto static get_type() -> GType; auto static get_base_type() -> GType; +#pragma mark - Functions + auto activate() -> void; auto add_prefix(Gtk::Widget & widget) -> void; auto add_suffix(Gtk::Widget & widget) -> void; auto remove(Gtk::Widget & widget) -> void; - auto get_activatable_widget() const noexcept -> Glib::RefPtr<Gtk::Widget>; +#pragma mark - Getters + auto get_activatable_widget() const noexcept -> Gtk::Widget *; [[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; +#pragma mark - Setters auto set_activatable_widget(Gtk::Widget & widget) noexcept -> void; [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> void; auto set_subtitle(Glib::ustring const & subtitle) -> void; @@ -67,6 +71,7 @@ namespace Adwaita auto set_subtitle_selectable(bool subtitle_selectable) noexcept -> void; auto set_title_lines(int title_lines) noexcept -> void; +#pragma mark - Properties auto property_activatable_widget() noexcept -> Glib::PropertyProxy<Gtk::Widget *>; auto property_activatable_widget() const noexcept -> Glib::PropertyProxy_ReadOnly<Gtk::Widget *>; [[deprecated("replaced by add_prefix")]] auto property_icon_name() noexcept -> Glib::PropertyProxy<Glib::ustring>; @@ -80,9 +85,16 @@ namespace Adwaita auto property_title_lines() noexcept -> Glib::PropertyProxy<int>; auto property_title_lines() const noexcept -> Glib::PropertyProxy_ReadOnly<int>; +#pragma mark - Signals + auto signal_activated() -> Glib::SignalProxy<void()>; + protected: friend struct ActionRow_Class; +#pragma mark - GTK Virtual Functions + auto virtual activate_vfunc() -> void; + +#pragma mark - Internal Constructors explicit ActionRow(Glib::ConstructParams const & params); explicit ActionRow(BaseObjectType * gobj); }; diff --git a/adw/include/adwaitamm/private/actionrow_p.hpp b/adw/include/adwaitamm/private/actionrow_p.hpp index b8a24eb..2b7ddf9 100644 --- a/adw/include/adwaitamm/private/actionrow_p.hpp +++ b/adw/include/adwaitamm/private/actionrow_p.hpp @@ -29,6 +29,9 @@ namespace Adwaita auto init() -> Glib::Class const &; auto static class_init_function(void * gclass, void * data) -> void; auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + + protected: + auto static activate_vfunc_callback(AdwActionRow * self) -> void; }; } // namespace Adwaita diff --git a/adw/src/actionrow.cpp b/adw/src/actionrow.cpp index 9c33aec..f17eef3 100644 --- a/adw/src/actionrow.cpp +++ b/adw/src/actionrow.cpp @@ -13,6 +13,7 @@ #include <glibmm/objectbase.h> #include <glibmm/propertyproxy.h> #include <glibmm/refptr.h> +#include <glibmm/signalproxy.h> #include <glibmm/ustring.h> #include <glibmm/wrap.h> @@ -37,8 +38,23 @@ namespace Adwaita auto constexpr subtitle_selectable = "subtitle-selectable"; auto constexpr title_lines = "title-lines"; } // namespace property_name + + namespace signal_info + { + auto const static activated = Glib::SignalProxyInfo{ + "activated", + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + }; + } // namespace signal_info } // namespace + ActionRow::ActionRow() + : Glib::ObjectBase{nullptr} + , PreferencesRow{Glib::ConstructParams{_class.init()}} + { + } + auto ActionRow::get_type() -> GType { return _class.init().get_type(); @@ -49,101 +65,90 @@ namespace Adwaita return adw_action_row_get_type(); } - ActionRow::ActionRow() - : Glib::ObjectBase{nullptr} - , PreferencesRow{Glib::ConstructParams{_class.init()}} - { - } - - ActionRow::ActionRow(Glib::ConstructParams const & params) - : PreferencesRow{params} - { - } - - ActionRow::ActionRow(BaseObjectType * gobj) - : PreferencesRow(ADW_PREFERENCES_ROW(gobj)) + auto ActionRow::activate() -> void { + return adw_action_row_activate(unwrap(this)); } auto ActionRow::add_prefix(Gtk::Widget & widget) -> void { - adw_action_row_add_prefix(Glib::unwrap(this), Glib::unwrap(&widget)); + return adw_action_row_add_prefix(unwrap(this), unwrap(&widget)); } auto ActionRow::add_suffix(Gtk::Widget & widget) -> void { - adw_action_row_add_suffix(Glib::unwrap(this), Glib::unwrap(&widget)); + return adw_action_row_add_suffix(unwrap(this), unwrap(&widget)); } auto ActionRow::remove(Gtk::Widget & widget) -> void { - adw_action_row_remove(Glib::unwrap(this), Glib::unwrap(&widget)); + return adw_action_row_remove(unwrap(this), unwrap(&widget)); } - auto ActionRow::get_activatable_widget() const noexcept -> Glib::RefPtr<Gtk::Widget> + auto ActionRow::get_activatable_widget() const noexcept -> Gtk::Widget * { - return Glib::make_refptr_for_instance(Glib::wrap(adw_action_row_get_activatable_widget(const_cast<BaseObjectType *>(Glib::unwrap(this))))); + return Glib::wrap(adw_action_row_get_activatable_widget(const_cast<BaseObjectType *>(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<BaseObjectType *>(Glib::unwrap(this))); + return adw_action_row_get_icon_name(const_cast<BaseObjectType *>(unwrap(this))); #pragma GCC diagnostic pop } auto ActionRow::get_subtitle() const -> Glib::ustring { - return adw_action_row_get_subtitle(const_cast<BaseObjectType *>(Glib::unwrap(this))); + return adw_action_row_get_subtitle(const_cast<BaseObjectType *>(unwrap(this))); } auto ActionRow::get_subtitle_lines() const noexcept -> int { - return adw_action_row_get_subtitle_lines(const_cast<BaseObjectType *>(Glib::unwrap(this))); + return adw_action_row_get_subtitle_lines(const_cast<BaseObjectType *>(unwrap(this))); } auto ActionRow::get_subtitle_selectable() const noexcept -> bool { - return adw_action_row_get_subtitle_selectable(const_cast<BaseObjectType *>(Glib::unwrap(this))); + return adw_action_row_get_subtitle_selectable(const_cast<BaseObjectType *>(unwrap(this))); } auto ActionRow::get_title_lines() const noexcept -> int { - return adw_action_row_get_title_lines(const_cast<BaseObjectType *>(Glib::unwrap(this))); + return adw_action_row_get_title_lines(const_cast<BaseObjectType *>(unwrap(this))); } auto ActionRow::set_activatable_widget(Gtk::Widget & widget) noexcept -> void { - adw_action_row_set_activatable_widget(Glib::unwrap(this), Glib::unwrap(&widget)); + adw_action_row_set_activatable_widget(unwrap(this), unwrap(&widget)); } auto ActionRow::set_icon_name(Glib::ustring const & name) -> void { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - adw_action_row_set_icon_name(Glib::unwrap(this), name.c_str()); + adw_action_row_set_icon_name(unwrap(this), name.c_str()); #pragma GCC diagnostic pop } auto ActionRow::set_subtitle(Glib::ustring const & subtitle) -> void { - adw_action_row_set_subtitle(Glib::unwrap(this), subtitle.c_str()); + adw_action_row_set_subtitle(unwrap(this), subtitle.c_str()); } auto ActionRow::set_subtitle_lines(int subtitle_lines) noexcept -> void { - adw_action_row_set_subtitle_lines(Glib::unwrap(this), subtitle_lines); + adw_action_row_set_subtitle_lines(unwrap(this), subtitle_lines); } auto ActionRow::set_subtitle_selectable(bool subtitle_selectable) noexcept -> void { - adw_action_row_set_subtitle_selectable(Glib::unwrap(this), static_cast<gboolean>(subtitle_selectable)); + adw_action_row_set_subtitle_selectable(unwrap(this), static_cast<gboolean>(subtitle_selectable)); } auto ActionRow::set_title_lines(int title_lines) noexcept -> void { - adw_action_row_set_title_lines(Glib::unwrap(this), title_lines); + adw_action_row_set_title_lines(unwrap(this), title_lines); } auto ActionRow::property_activatable_widget() noexcept -> Glib::PropertyProxy<Gtk::Widget *> @@ -206,6 +211,30 @@ namespace Adwaita return Glib::PropertyProxy_ReadOnly<int>(this, property_name::title_lines); } + auto ActionRow::signal_activated() -> Glib::SignalProxy<void()> + { + return Glib::SignalProxy<void()>{this, &signal_info::activated}; + } + + auto ActionRow::activate_vfunc() -> void + { + auto base_object = static_cast<BaseClassType *>(g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_))); + if (base_object && base_object->activate) + { + (base_object->activate)(unwrap(this)); + } + } + + ActionRow::ActionRow(Glib::ConstructParams const & params) + : PreferencesRow{params} + { + } + + ActionRow::ActionRow(BaseObjectType * gobj) + : PreferencesRow(ADW_PREFERENCES_ROW(gobj)) + { + } + } // namespace Adwaita namespace Glib diff --git a/adw/src/private/actionrow_p.cpp b/adw/src/private/actionrow_p.cpp index 4a31bc8..9c4e936 100644 --- a/adw/src/private/actionrow_p.cpp +++ b/adw/src/private/actionrow_p.cpp @@ -9,14 +9,28 @@ #include "adwaitamm/actionrow.hpp" #include <glibmm/class.h> +#include <glibmm/exceptionhandler.h> #include <glibmm/objectbase.h> #include <gtkmm/object.h> #include <adwaita.h> +#include <glib-object.h> namespace Adwaita { + namespace + { + namespace vfuncs + { + void (*activate_vfunc_ptr)(AdwActionRow *){}; + auto static activate_vfunc_c_callback(AdwActionRow * self) + { + activate_vfunc_ptr(self); + } + } // namespace vfuncs + } // namespace + auto ActionRow_Class::init() -> Glib::Class const & { if (!gtype_) @@ -31,10 +45,40 @@ namespace Adwaita { auto const klass = static_cast<BaseClassType *>(gclass); CppClassParent::class_init_function(klass, data); + + klass->activate = &vfuncs::activate_vfunc_c_callback; + vfuncs::activate_vfunc_ptr = &ActionRow_Class::activate_vfunc_callback; } auto ActionRow_Class::wrap_new(GObject * object) -> Glib::ObjectBase * { return Gtk::manage(new ActionRow(ADW_ACTION_ROW(object))); } + + auto ActionRow_Class::activate_vfunc_callback(AdwActionRow * self) -> void + { + auto base_object = static_cast<Glib::ObjectBase *>(Glib::ObjectBase::_get_current_wrapper(G_OBJECT(self))); + if (base_object && base_object->is_derived_()) + { + auto object = dynamic_cast<ActionRow *>(base_object); + if (object) + { + try + { + object->activate_vfunc(); + return; + } + catch (...) + { + Glib::exception_handlers_invoke(); + } + } + } + + auto base_class = static_cast<BaseClassType *>(g_type_class_peek_parent(G_OBJECT_GET_CLASS(self))); + if (base_class && base_class->activate) + { + (base_class->activate)(self); + } + } } // namespace Adwaita
\ No newline at end of file |
