/* 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>

namespace Gtk
{

Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file)
{
  auto result = PageSetup::create();

  result->load_from_key_file(key_file);

  return result;
}

Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, const Glib::ustring& group_name)
{
  auto result = PageSetup::create();

  result->load_from_key_file(key_file, group_name);

  return result;
}

Glib::RefPtr<PageSetup> PageSetup::create_from_file(const std::string& file_name)
{
  auto result = PageSetup::create();

  result->load_from_file(file_name);

  return result;
}

void PageSetup::save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file) const
{
  gtk_page_setup_to_key_file(const_cast<GtkPageSetup*>(gobj()), Glib::unwrap(key_file), nullptr);
}

bool PageSetup::load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file)
{
  GError* gerror = nullptr;
  bool retvalue = gtk_page_setup_load_key_file(gobj(), const_cast<GKeyFile*>(Glib::unwrap(key_file)), nullptr, &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

} //namespace
