/* 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <gtk/gtk.h>

namespace Gtk
{

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

  result->load_from_key_file(key_file);

  return result;
}

Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
{
  Glib::RefPtr<PageSetup> 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)
{
  Glib::RefPtr<PageSetup> result = PageSetup::create();

  result->load_from_file(file_name);

  return result;
}

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

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

  return retvalue;
}

} //namespace
