/* Copyright (C) 2026 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <gtkmm/widget.h>
#include <gtkmm/popover.h>
#include <giomm/menumodel.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

namespace Gtk
{

/** A single child container with a popover.
 *
 * You should use %Gtk::PopoverBin whenever you need to present a Gtk::Popover
 * to the user.
 *
 * %Gtk::PopoverBin defines the `menu.popup` action, which can be activated
 * to present the popover to the user.
 *
 * @ingroup Widgets
 * @newin{4,22}
 */
class GTKMM_API PopoverBin : public Widget
{
  _CLASS_GTKOBJECT(PopoverBin, GtkPopoverBin, GTK_POPOVER_BIN, Gtk::Widget, GtkWidget, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkPopoverBin is a final type
  _STRUCT_NOT_HIDDEN

public:
  _CTOR_DEFAULT

  _WRAP_METHOD(void set_child(Widget& child), gtk_popover_bin_set_child)
  /** Unsets the child.
   *
   * @newin{4,22}
   */
  void unset_child();
  _WRAP_METHOD(Widget* get_child(), gtk_popover_bin_get_child)
  _WRAP_METHOD(const Widget* get_child() const, gtk_popover_bin_get_child, constversion)

  _WRAP_METHOD(void set_menu_model(const Glib::RefPtr<Gio::MenuModel>& model),
    gtk_popover_bin_set_menu_model)
  _WRAP_METHOD(Glib::RefPtr<Gio::MenuModel> get_menu_model(),
    gtk_popover_bin_get_menu_model, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Gio::MenuModel> get_menu_model() const,
    gtk_popover_bin_get_menu_model, refreturn, constversion)

  // gtk_popover_bin_set_popover() takes a GtkWidget*, but requires it to be a GtkPopover*.
  _WRAP_METHOD(void set_popover(Popover& child), gtk_popover_bin_set_popover)
  /** Unsets the popover.
   *
   * @newin{4,22}
   */
  void unset_popover();
  _WRAP_METHOD(Popover* get_popover(), gtk_popover_bin_get_popover)
  _WRAP_METHOD(const Popover* get_popover() const, gtk_popover_bin_get_popover, constversion)

  _WRAP_METHOD(void popup(), gtk_popover_bin_popup)
  _WRAP_METHOD(void popdown(), gtk_popover_bin_popdown)

  _WRAP_METHOD(void set_handle_input(bool handle_input = true), gtk_popover_bin_set_handle_input)
  _WRAP_METHOD(bool get_handle_input() const, gtk_popover_bin_get_handle_input)

  _WRAP_PROPERTY("child", Widget*)
  _WRAP_PROPERTY("popover", Popover*)
  _WRAP_PROPERTY("menu-model", Glib::RefPtr<Gio::MenuModel>)
  _WRAP_PROPERTY("handle-input", bool)
};

} // namespace Gtk
