/* Copyright (C) 2006 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 <https://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>

extern "C"
{
static int SignalProxy_SlotForwardPage_gtk_callback(int current_page, gpointer data)
{
  auto the_slot = static_cast<Gtk::Assistant::SlotForwardPage*>(data);

  try
  {
    return (*the_slot)(current_page);
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
    return int();
  }
}

static void SignalProxy_SlotForwardPage_gtk_callback_destroy(void* data)
{
  delete static_cast<Gtk::Assistant::SlotForwardPage*>(data);
}
} // extern "C"

namespace Gtk
{

// use-header-bar is construct-only. It must be set in the constructor,
// if you don't want the default value.
Assistant::Assistant(bool use_header_bar)
:
  _CONSTRUCT("use-header-bar", static_cast<int>(use_header_bar))
{
}

void Assistant::set_forward_page_func(const SlotForwardPage& slot)
{
  // Create a copy of the slot object. A pointer to this will be passed
  // through the callback's data parameter.  It will be deleted
  // when SignalProxy_SlotForwardPage_gtk_callback_destroy() is called.
  auto slot_copy = new SlotForwardPage(slot);

  gtk_assistant_set_forward_page_func(gobj(),
      &SignalProxy_SlotForwardPage_gtk_callback, slot_copy,
      &SignalProxy_SlotForwardPage_gtk_callback_destroy);
}

} // namespace Gtk
