/** * @author Felix Morgner (felix.morgner@gmail.com) * @copyright Copyright (c) 2025 * SPDX-License-Identifier: LGPL-2.1-or-later */ #include "adwaitamm/dialog.hpp" #include "adwaitamm/breakpoint.hpp" #include "adwaitamm/private/dialog_p.hpp" #include #include #include #include #include #include #include #include #include namespace Adwaita { namespace { auto constinit _class = Dialog_Class{}; } // namespace 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) : Gtk::Widget(GTK_WIDGET(gobj)) { } Dialog::Dialog() : Glib::ObjectBase{nullptr} , Gtk::Widget{Glib::ConstructParams{_class.init()}} { } auto Dialog::add_breakpoint(Glib::RefPtr const & breakpoint) -> void { // Take a copy because the dialog will take ownership of the breakpoint. adw_dialog_add_breakpoint(Glib::unwrap(this), Glib::unwrap_copy(breakpoint)); } auto Dialog::close() -> void { adw_dialog_close(Glib::unwrap(this)); } auto Dialog::force_close() -> void { adw_dialog_force_close(Glib::unwrap(this)); } auto Dialog::get_can_close() const -> bool { return adw_dialog_get_can_close(const_cast(Glib::unwrap(this))); } auto Dialog::get_child() const -> Gtk::Widget * { return Glib::wrap(adw_dialog_get_child(const_cast(Glib::unwrap(this))), true); } auto Dialog::get_content_height() const -> int { return adw_dialog_get_content_height(const_cast(Glib::unwrap(this))); } auto Dialog::get_content_width() const -> int { return adw_dialog_get_content_width(const_cast(Glib::unwrap(this))); } auto Dialog::get_current_breakpoint() const -> Glib::RefPtr { return Glib::wrap(adw_dialog_get_current_breakpoint(const_cast(Glib::unwrap(this))), true); } auto Dialog::get_default_widget() const -> Gtk::Widget * { return Glib::wrap(adw_dialog_get_default_widget(const_cast(Glib::unwrap(this)))); } auto Dialog::get_focus() const -> Gtk::Widget * { return Glib::wrap(adw_dialog_get_focus(const_cast(Glib::unwrap(this)))); } auto Dialog::present(Gtk::Widget * parent) -> void { adw_dialog_present(Glib::unwrap(this), Glib::unwrap(parent)); } auto Dialog::set_title(Glib::ustring const & str) -> void { adw_dialog_set_title(Glib::unwrap(this), Glib::c_str_or_nullptr(str)); } } // namespace Adwaita namespace Glib { auto wrap(AdwDialog * object, bool copy) -> Adwaita::Dialog * { return dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy)); } } // namespace Glib