// Generated by gtkmmproc -- DO NOT MODIFY!


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

// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-

/* Copyright (C) 2007 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gio/gio.h>
#include <giomm/file.h>

namespace Gio
{

Glib::RefPtr<Application> Application::create(const Glib::ustring& appid)
{
  return Glib::wrap(g_application_new(appid.c_str(), 0, 0));
}


Glib::RefPtr<Application> Application::create_try(const Glib::ustring& appid)
{
  GError* gerror = 0;
  Glib::RefPtr<Application> retvalue = Glib::wrap(g_application_try_new(appid.c_str(), 0, 0, &(gerror)));

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


Glib::RefPtr<Application> Application::create_unregistered_try(const Glib::ustring& appid)
{
  GError* gerror = 0;
  Glib::RefPtr<Application> retvalue = Glib::wrap(g_application_unregistered_try_new(appid.c_str(), 0, 0, &(gerror)));

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


} // namespace Gio

namespace
{


static void Application_signal_action_with_data_callback(GApplication* self, const gchar* p0,GVariant* p1,void* data)
{
  using namespace Gio;
  typedef sigc::slot< void,const Glib::ustring&,const Glib::VariantBase& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::ustring(p0)
, Glib::wrap(p1, true)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Application_signal_action_with_data_info =
{
  "action-with-data",
  (GCallback) &Application_signal_action_with_data_callback,
  (GCallback) &Application_signal_action_with_data_callback
};


static void Application_signal_prepare_activation_callback(GApplication* self, GVariant* p0,GVariant* p1,void* data)
{
  using namespace Gio;
  typedef sigc::slot< void,const Glib::VariantBase&,const Glib::VariantBase& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
, Glib::wrap(p1, true)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Application_signal_prepare_activation_info =
{
  "prepare-activation",
  (GCallback) &Application_signal_prepare_activation_callback,
  (GCallback) &Application_signal_prepare_activation_callback
};


static gboolean Application_signal_quit_with_data_callback(GApplication* self, GVariant* p0,void* data)
{
  using namespace Gio;
  typedef sigc::slot< bool,const Glib::VariantBase& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        return static_cast<int>((*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
));
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef gboolean RType;
  return RType();
}

static gboolean Application_signal_quit_with_data_notify_callback(GApplication* self, GVariant* p0, void* data)
{
  using namespace Gio;
  typedef sigc::slot< void,const Glib::VariantBase& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef gboolean RType;
  return RType();
}

static const Glib::SignalProxyInfo Application_signal_quit_with_data_info =
{
  "quit-with-data",
  (GCallback) &Application_signal_quit_with_data_callback,
  (GCallback) &Application_signal_quit_with_data_notify_callback
};


} // anonymous namespace


namespace Glib
{

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

} /* namespace Glib */


namespace Gio
{


/* 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(g_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)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


  klass->action_with_data = &action_with_data_callback;
  klass->prepare_activation = &prepare_activation_callback;
  klass->quit_with_data = &quit_with_data_callback;
}


void Application_Class::action_with_data_callback(GApplication* self, const gchar* p0, GVariant* p1)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_action_with_data(Glib::ustring(p0)
, Glib::wrap(p1, true)
);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->action_with_data)
    (*base->action_with_data)(self, p0, p1);
}
void Application_Class::prepare_activation_callback(GApplication* self, GVariant* p0, GVariant* p1)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_prepare_activation(Glib::wrap(p0, true)
, Glib::wrap(p1, true)
);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->prepare_activation)
    (*base->prepare_activation)(self, p0, p1);
}
gboolean Application_Class::quit_with_data_callback(GApplication* self, GVariant* p0)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        return static_cast<int>(obj->on_quit_with_data(Glib::wrap(p0, true)
));
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->quit_with_data)
    return (*base->quit_with_data)(self, p0);

  typedef gboolean RType;
  return RType();
}


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


/* The implementation: */

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

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

}

Application::Application(GApplication* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


Application::~Application()
{}


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

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


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


Application::Application()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(application_class_.init()))
{
  

}

Glib::RefPtr<Application> Application::create(const Glib::ustring& appid, int argc, char** argv)
{
  return Glib::wrap(g_application_new(appid.c_str(), argc, argv));
}


Glib::RefPtr<Application> Application::create_try(const Glib::ustring& appid, int argc, char** argv)
{
  GError* gerror = 0;
  Glib::RefPtr<Application> retvalue = Glib::wrap(g_application_try_new(appid.c_str(), argc, argv, &(gerror)));

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


Glib::RefPtr<Application> Application::create_unregistered_try(const Glib::ustring& appid, int argc, char** argv)
{
  GError* gerror = 0;
  Glib::RefPtr<Application> retvalue = Glib::wrap(g_application_unregistered_try_new(appid.c_str(), argc, argv, &(gerror)));

  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}


bool Application::register_application()
{
  return g_application_register(gobj());
}

Glib::RefPtr<Application> Application::get_instance()
{

  Glib::RefPtr<Application> retvalue = Glib::wrap(g_application_get_instance());

  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}


Glib::ustring Application::get_id() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(g_application_get_id(const_cast<GApplication*>(gobj())));
}

void Application::add_action(const Glib::ustring& name, const Glib::ustring& description)
{
g_application_add_action(gobj(), name.c_str(), description.c_str()); 
}

void Application::remove_action(const Glib::ustring& name)
{
g_application_remove_action(gobj(), name.c_str()); 
}

Glib::StringArrayHandle Application::list_actions() const
{
  return Glib::StringArrayHandle(g_application_list_actions(const_cast<GApplication*>(gobj())), Glib::OWNERSHIP_DEEP);
}

void Application::set_action_enabled(const Glib::ustring& name, bool enabled)
{
g_application_set_action_enabled(gobj(), name.c_str(), static_cast<int>(enabled)); 
}

bool Application::get_action_enabled(const Glib::ustring& name) const
{
  return g_application_get_action_enabled(const_cast<GApplication*>(gobj()), name.c_str());
}

Glib::ustring Application::get_action_description(const Glib::ustring& name)
{
  return Glib::convert_const_gchar_ptr_to_ustring(g_application_get_action_description(gobj(), name.c_str()));
}

void Application::invoke_action(const Glib::ustring& name, const Glib::VariantBase& platform_data)
{
g_application_invoke_action(gobj(), name.c_str(), const_cast<GVariant*>((platform_data).gobj())); 
}

void Application::run()
{
g_application_run(gobj()); 
}

bool Application::quit_with_data(const Glib::VariantBase& platform_data)
{
  return g_application_quit_with_data(gobj(), const_cast<GVariant*>((platform_data).gobj()));
}

bool Application::is_remote() const
{
  return g_application_is_remote(const_cast<GApplication*>(gobj()));
}


Glib::SignalProxy2< void,const Glib::ustring&,const Glib::VariantBase& > Application::signal_action_with_data()
{
  return Glib::SignalProxy2< void,const Glib::ustring&,const Glib::VariantBase& >(this, &Application_signal_action_with_data_info);
}


Glib::SignalProxy2< void,const Glib::VariantBase&,const Glib::VariantBase& > Application::signal_prepare_activation()
{
  return Glib::SignalProxy2< void,const Glib::VariantBase&,const Glib::VariantBase& >(this, &Application_signal_prepare_activation_info);
}


Glib::SignalProxy1< bool,const Glib::VariantBase& > Application::signal_quit_with_data()
{
  return Glib::SignalProxy1< bool,const Glib::VariantBase& >(this, &Application_signal_quit_with_data_info);
}


void Gio::Application::on_action_with_data(const Glib::ustring& name, const Glib::VariantBase& platform_data)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->action_with_data)
    (*base->action_with_data)(gobj(),name.c_str(),const_cast<GVariant*>((platform_data).gobj()));
}
void Gio::Application::on_prepare_activation(const Glib::VariantBase& arguments, const Glib::VariantBase& platform_data)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->prepare_activation)
    (*base->prepare_activation)(gobj(),const_cast<GVariant*>((arguments).gobj()),const_cast<GVariant*>((platform_data).gobj()));
}
bool Gio::Application::on_quit_with_data(const Glib::VariantBase& platform_data)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->quit_with_data)
    return (*base->quit_with_data)(gobj(),const_cast<GVariant*>((platform_data).gobj()));

  typedef bool RType;
  return RType();
}


} // namespace Gio


