// Generated by gmmproc 2.53.2 -- DO NOT MODIFY!

#undef GTK_DISABLE_DEPRECATED
#define GDK_DISABLE_DEPRECATION_WARNINGS 1
 

#include <glibmm.h>

#include <gtkmm/main.h>
#include <gtkmm/private/main_p.h>


/*
 * Copyright 1998-2002 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 <glib.h>
#include <gtkmmconfig.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <glibmm/init.h>
#include <giomm/init.h>
#include <pangomm/wrap_init.h>
#ifdef GTKMM_ATKMM_ENABLED
#include <atkmm/wrap_init.h>
#endif //GTKMM_ATKMM_ENABLED
#include <gdkmm/wrap_init.h>
#include <gtkmm/wrap_init.h>

namespace Gtk
{

#ifndef GTKMM_DISABLE_DEPRECATED


/**** Gtk::Main -- static data *********************************************/

Main*         Main::instance_ = nullptr;

/**** Gtk::Main -- construction/destruction ********************************/

Main::Main(bool set_locale)
{
  init(set_locale);
}

Main::~Main()
{
  // A second Gtk::Main will produce a warning, but
  // Main::~Main would still run. So this prevents the crash.
  if(instance_ == this)
  {
    instance_ = nullptr;

    // Release the gtkmm type registration tables,
    // allowing Main to be instantiated again:
    Glib::wrap_register_cleanup();
    Glib::Error::register_cleanup();
  }
}

// protected
void Main::init(bool set_locale)
{
  if(instance_)
  {
    g_warning("Gtk::Main::init() called twice");
  }
  else
  {
    if(!set_locale)
      gtk_disable_setlocale();

    //TODO: Add support for gtk_init_check().
    gtk_init();

    init_gtkmm_internals();
    instance_ = this;
  }
}

#endif // GTKMM_DISABLE_DEPRECATED


// This is a static method so that it can be used before Main is instantiated,
// for instance in Gnome::canvas_init().  But if you use this method, you
// _must_ have a Gtk::Main, so that Main::~Main() is called to clean this up
// later.  Of course I can't imagine any situation in which you wouldn't have
// a Gtk::Main.
//
void Main::init_gtkmm_internals()
{
  static bool init_done = false;

  if(!init_done)
  {
    Glib::init();
    Gio::init();

    // Populate the map of GTypes to C++ wrap_new() functions.
    Pango::wrap_init();
#ifdef GTKMM_ATKMM_ENABLED
    Atk::wrap_init();
#endif //GTKMM_ATKMM_ENABLED
    Gdk::wrap_init();
    Gtk::wrap_init();

    init_done = true;
  }
}

#ifndef GTKMM_DISABLE_DEPRECATED


/**** Gtk::Main -- static forwarder methods ********************************/

Main* Main::instance()
{
  return instance_;
}

void Main::run()
{
  instance_->run_impl();
}

void Main::run(Gtk::Window& window)
{
  window.show();
  window.signal_hide().connect(sigc::mem_fun(*instance_, &Main::on_window_hide));
  instance_->run_impl();
}

void Main::quit()
{
  instance_->quit_impl();
}

guint Main::level()
{
  return instance_->level_impl();
}

#endif // GTKMM_DISABLE_DEPRECATED


bool Main::iteration(bool blocking)
{
  return gtk_main_iteration_do(blocking);
}

bool Main::events_pending()
{
  return gtk_events_pending();
}

#ifndef GTKMM_DISABLE_DEPRECATED


/**** Gtk::Main -- protected virtuals **************************************/

void Main::run_impl()
{
  gtk_main();
}

void Main::quit_impl()
{
  gtk_main_quit();
}

guint Main::level_impl()
{
  return gtk_main_level();
}

bool Main::iteration_impl(bool blocking)
{
  return gtk_main_iteration_do(blocking);
}

bool Main::events_pending_impl()
{
  return gtk_events_pending();
}

void Main::on_window_hide()
{
  quit_impl();
}

#endif // GTKMM_DISABLE_DEPRECATED


} //namespace Gtk


namespace
{
} // anonymous namespace


