/** * @author Felix Morgner (felix.morgner@gmail.com) * @copyright Copyright (c) 2025 * SPDX-License-Identifier: LGPL-2.1-or-later */ #include "adwaitamm/private/dialog_p.hpp" #include "adwaitamm/dialog.hpp" #include #include #include #include #include #include #include #include namespace Adwaita { auto Dialog_Class::init() -> Glib::Class const & { if (!gtype_) { class_init_func_ = &class_init_function; register_derived_type(adw_dialog_get_type()); Gtk::ShortcutManager::add_interface(get_type()); } return *this; } auto Dialog_Class::class_init_function(void * gclass, void * data) -> void { auto const klass = static_cast(gclass); CppClassParent::class_init_function(klass, data); klass->close_attempt = &close_attempt; klass->closed = &closed; } auto Dialog_Class::wrap_new(GObject * object) -> Glib::ObjectBase * { return Gtk::manage(new Dialog(ADW_DIALOG(object))); } auto Dialog_Class::close_attempt(BaseObjectType * self) -> void { auto base_object = static_cast(Glib::ObjectBase::_get_current_wrapper(G_OBJECT(self))); if (base_object && base_object->is_derived_()) { auto object = dynamic_cast(base_object); if (object) { try { return object->on_close_attempt(); } catch (...) { Glib::exception_handlers_invoke(); } } } auto base_class = static_cast(g_type_class_peek_parent(G_OBJECT_GET_CLASS(self))); if (base_class && base_class->close_attempt) { return (base_class->close_attempt)(self); } } auto Dialog_Class::closed(BaseObjectType * self) -> void { auto base_object = static_cast(Glib::ObjectBase::_get_current_wrapper(G_OBJECT(self))); if (base_object && base_object->is_derived_()) { auto object = dynamic_cast(base_object); if (object) { try { return object->on_closed(); } catch (...) { Glib::exception_handlers_invoke(); } } } auto base_class = static_cast(g_type_class_peek_parent(G_OBJECT_GET_CLASS(self))); if (base_class && base_class->closed) { return (base_class->closed)(self); } } } // namespace Adwaita