/** * @author Felix Morgner (felix.morgner@gmail.com) * @copyright Copyright (c) 2025 * SPDX-License-Identifier: LGPL-2.1-or-later */ #include "adwaitamm/toast.hpp" #include "adwaitamm/enums.hpp" #include "adwaitamm/private/toast_p.hpp" #include #include #include #include #include #include #include #include #include #include #include #include namespace Adwaita { namespace { auto constinit _class = Toast_Class{}; static const Glib::SignalProxyInfo Toast_signal_button_clicked_info = {"button-clicked", (GCallback)&Glib::SignalProxyNormal::slot0_void_callback, (GCallback)&Glib::SignalProxyNormal::slot0_void_callback}; static const Glib::SignalProxyInfo Toast_signal_dismissed_info = {"dismissed", (GCallback)&Glib::SignalProxyNormal::slot0_void_callback, (GCallback)&Glib::SignalProxyNormal::slot0_void_callback}; } // namespace Toast::Toast(Glib::ustring const & title) : Glib::ObjectBase{nullptr} , Glib::Object{Glib::ConstructParams{_class.init(), "title", Glib::c_str_or_nullptr(title), nullptr}} { } Toast::Toast(Glib::ConstructParams const & params) : Glib::Object{params} { } Toast::Toast(BaseObjectType * gobj) : Glib::Object((GObject *)gobj) { } auto Toast::create(Glib::ustring const & title) -> Glib::RefPtr { return Glib::make_refptr_for_instance(new Toast{title}); } auto Toast::get_type() -> GType { return _class.init().get_type(); } auto Toast::get_base_type() -> GType { return adw_toast_get_type(); } auto Toast::dismiss() -> void { return adw_toast_dismiss(gobj()); } auto Toast::get_action_name() const -> Glib::ustring { return adw_toast_get_action_name(const_cast(Glib::unwrap(this))); } auto Toast::get_action_target_value() const -> Glib::VariantBase { // Take a copy because the value is owned by the toast. return Glib::wrap(adw_toast_get_action_target_value(const_cast(Glib::unwrap(this))), true); } auto Toast::get_button_label() const -> Glib::ustring { return adw_toast_get_button_label(const_cast(Glib::unwrap(this))); } auto Toast::get_custom_title() const -> Gtk::Widget * { return Glib::wrap(adw_toast_get_custom_title(const_cast(Glib::unwrap(this)))); } auto Toast::get_priority() const -> ToastPriority { return static_cast(adw_toast_get_priority(const_cast(Glib::unwrap(this)))); } auto Toast::get_timeout() const -> unsigned { return adw_toast_get_timeout(const_cast(Glib::unwrap(this))); } auto Toast::get_title() const -> Glib::ustring { return adw_toast_get_title(const_cast(Glib::unwrap(this))); } auto Toast::get_use_markup() const -> bool { return adw_toast_get_use_markup(const_cast(Glib::unwrap(this))); } auto Toast::set_action_name(Glib::ustring value) -> void { adw_toast_set_action_name(Glib::unwrap(this), Glib::c_str_or_nullptr(value)); } auto Toast::set_action_target_value(Glib::VariantBase const & value) -> void { adw_toast_set_action_target_value(Glib::unwrap(this), const_cast(Glib::unwrap(&value))); } auto Toast::set_button_label(Glib::ustring value) -> void { adw_toast_set_button_label(Glib::unwrap(this), Glib::c_str_or_nullptr(value)); } auto Toast::set_custom_title(Gtk::Widget * value) -> void { adw_toast_set_custom_title(Glib::unwrap(this), Glib::unwrap(value)); } auto Toast::set_detailed_action_name(Glib::ustring value) -> void { adw_toast_set_detailed_action_name(Glib::unwrap(this), Glib::c_str_or_nullptr(value)); } auto Toast::set_priority(ToastPriority value) -> void { adw_toast_set_priority(Glib::unwrap(this), static_cast(value)); } auto Toast::set_timeout(unsigned value) -> void { adw_toast_set_timeout(Glib::unwrap(this), value); } auto Toast::set_title(Glib::ustring value) -> void { adw_toast_set_title(Glib::unwrap(this), Glib::c_str_or_nullptr(value)); } auto Toast::set_use_markup(bool value) -> void { adw_toast_set_use_markup(Glib::unwrap(this), value); } auto Toast::property_action_name() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "action-name"); } auto Toast::property_action_name() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "action-name"); } auto Toast::property_action_target() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "action-target"); } auto Toast::property_action_target() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "action-target"); } auto Toast::property_button_label() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "button-label"); } auto Toast::property_button_label() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "button-label"); } auto Toast::property_custom_title() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "custom-title"); } auto Toast::property_custom_title() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "custom-title"); } auto Toast::property_priority() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "priority"); } auto Toast::property_priority() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "priority"); } auto Toast::property_timeout() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "timeout"); } auto Toast::property_timeout() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "timeout"); } auto Toast::property_title() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "title"); } auto Toast::property_title() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "title"); } auto Toast::property_use_markup() -> Glib::PropertyProxy { return Glib::PropertyProxy(this, "use-markup"); } auto Toast::property_use_markup() const -> Glib::PropertyProxy_ReadOnly { return Glib::PropertyProxy_ReadOnly(this, "use-markup"); } auto Toast::signal_button_clicked() -> Glib::SignalProxy { return Glib::SignalProxy{this, &Toast_signal_button_clicked_info}; } auto Toast::signal_dismissed() -> Glib::SignalProxy { return Glib::SignalProxy{this, &Toast_signal_dismissed_info}; } } // namespace Adwaita namespace Glib { auto wrap(AdwToast * object, bool copy) -> Glib::RefPtr { return Glib::make_refptr_for_instance(dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy))); } } // namespace Glib