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


#include <glibmm.h>

#include <idemm/application.h>
#include <idemm/private/application_p.h>


/* application.ccg
 *
 * Copyright (C) 2016 Marcin Kolny <marcin.kolny@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "application.h"

namespace {

static void
SignalProxy_async_callback(GObject*, GAsyncResult* res, gpointer data)
{
  auto the_slot = static_cast<Gio::SlotAsyncReady*>(data);

  try
  {
    auto result = Glib::wrap(res, true /* take copy */);
    (*the_slot)(result);
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }

  delete the_slot;
}

}

namespace Ide {

Application::Application()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Gtk::Application(Glib::ConstructParams(application_class_.init(), "application-id","org.gnome.Builder","flags",G_APPLICATION_HANDLES_OPEN, nullptr))
{}


void Application::get_worker_async(const Glib::ustring& plugin_name, const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::Cancellable>& cancellable)
{
  // slot_copy will be deleted in the callback.
  auto slot_copy = new Gio::SlotAsyncReady(slot);

  ide_application_get_worker_async(gobj(), plugin_name.c_str(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy);
}

void Application::get_worker_async(const Glib::ustring& plugin_name, const Gio::SlotAsyncReady& slot)
{
  // slot_copy will be deleted in the callback.
  auto slot_copy = new Gio::SlotAsyncReady(slot);

  ide_application_get_worker_async(gobj(), plugin_name.c_str(), nullptr, &SignalProxy_async_callback, slot_copy);
}

}

namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Ide::Application> wrap(IdeApplication* object, bool take_copy)
{
  return Glib::RefPtr<Ide::Application>( dynamic_cast<Ide::Application*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Ide
{


/* The *_Class implementation: */

const Glib::Class& Application_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &Application_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(ide_application_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void Application_Class::class_init_function(void* g_class, void* class_data)
{
  const auto klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


}


Glib::ObjectBase* Application_Class::wrap_new(GObject* object)
{
  return new Application((IdeApplication*)object);
}


/* The implementation: */

IdeApplication* Application::gobj_copy()
{
  reference();
  return gobj();
}

Application::Application(const Glib::ConstructParams& construct_params)
:
  Gtk::Application(construct_params)
{

}

Application::Application(IdeApplication* castitem)
:
  Gtk::Application((GtkApplication*)(castitem))
{}


Application::Application(Application&& src) noexcept
: Gtk::Application(std::move(src))
{}

Application& Application::operator=(Application&& src) noexcept
{
  Gtk::Application::operator=(std::move(src));
  return *this;
}


Application::~Application() noexcept
{}


Application::CppClassType Application::application_class_; // initialize static member

GType Application::get_type()
{
  return application_class_.init().get_type();
}


GType Application::get_base_type()
{
  return ide_application_get_type();
}


Glib::RefPtr<Application> Application::create()
{
  return Glib::RefPtr<Application>( new Application() );
}

Ide::ApplicationMode Application::get_mode() const
{
  return ((Ide::ApplicationMode)(ide_application_get_mode(const_cast<IdeApplication*>(gobj()))));
}

Glib::DateTime Application::get_started_at() const
{
  return Glib::wrap(ide_application_get_started_at(const_cast<IdeApplication*>(gobj())));
}

void Application::show_projects_window()
{
  ide_application_show_projects_window(gobj());
}

Glib::ustring Application::get_keybindings_mode() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(ide_application_get_keybindings_mode(const_cast<IdeApplication*>(gobj())));
}

Glib::RefPtr<Gio::Menu> Application::get_menu_by_id(const Glib::ustring& id)
{
  return Glib::wrap(ide_application_get_menu_by_id(gobj(), id.c_str()));
}

Glib::RefPtr<Ide::RecentProjects> Application::get_recent_projects()
{
  return Glib::wrap(ide_application_get_recent_projects(gobj()));
}

Glib::RefPtr<Gio::DBus::Proxy> Application::get_worker_finish(const Glib::RefPtr<Gio::AsyncResult>& result)
{
  GError* gerror = nullptr;
  Glib::RefPtr<Gio::DBus::Proxy> retvalue = Glib::wrap(ide_application_get_worker_finish(gobj(), Glib::unwrap(result), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


} // namespace Ide


