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


#include <glibmm.h>

#include <giomm/appinfo.h>
#include <giomm/private/appinfo_p.h>


/* 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, see <http://www.gnu.org/licenses/>.
 */

#include <giomm/file.h>
#include <glibmm/vectorutils.h>
#include <giomm/slot_async.h>
#include <gio/gio.h>

namespace
{
/* Special type traits for pointers to the GAppInfo interface.
 * The partial specialization in glibmm/glib/glibmm/containerhandle_shared.h
 * is not well suited for interfaces which do not already have a wrapper.
 * Its to_cpp_type() calls Glib::wrap_auto() instead id Glib::wrap_auto_interface().
 * These type traits are used by Glib::ListHandler<>::list_to_vector() in
 * Gio::AppInfo::get_all() and Gio::AppInfo::get_all_for_type().
 * https://gitlab.gnome.org/GNOME/glibmm/-/issues/94
 */
struct TypeTraits_AppInfo
{
  using T = Gio::AppInfo;
  using CppType = Glib::RefPtr<T>;
  using CType = typename T::BaseObjectType*;
  using CTypeNonConst = typename T::BaseObjectType*;

  static CType to_c_type(const CppType& ptr) { return Glib::unwrap(ptr); }
  static CType to_c_type(CType ptr) { return ptr; }
  static CppType to_cpp_type(CType ptr) { return Glib::wrap(ptr, true); }

  static void release_c_type(CType ptr)
  {
    GLIBMM_DEBUG_UNREFERENCE(nullptr, ptr);
    g_object_unref(ptr);
  }
};
} // anonymous namespace

namespace Gio
{

Glib::RefPtr<AppInfo>
AppInfo::create_from_commandline(
  const std::string& commandline, const std::string& application_name, CreateFlags flags)
{
  GAppInfo* capp_info = nullptr;
  GError* gerror = nullptr;

  capp_info = g_app_info_create_from_commandline(commandline.c_str(), application_name.c_str(),
    static_cast<GAppInfoCreateFlags>(flags), &gerror);

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

  return Glib::wrap(capp_info);
}

Glib::RefPtr<AppInfo>
AppInfo::create_duplicate() const
{
  return Glib::wrap(g_app_info_dup(const_cast<GAppInfo*>(gobj())));
}

bool
AppInfo::launch(
  const Glib::RefPtr<Gio::File>& file, const Glib::RefPtr<AppLaunchContext>& launch_context)
{
  std::vector<Glib::RefPtr<Gio::File>> vec = { file };

  GError* gerror = nullptr;
  const bool retvalue = g_app_info_launch(gobj(),
    Glib::ListHandler<Glib::RefPtr<Gio::File>>::vector_to_list(vec).data(),
    Glib::unwrap(launch_context), &(gerror));
  if (gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

bool
AppInfo::launch(const Glib::RefPtr<Gio::File>& file)
{
  std::vector<Glib::RefPtr<Gio::File>> vec = { file };

  GError* gerror = nullptr;
  const bool retvalue = g_app_info_launch(gobj(),
    Glib::ListHandler<Glib::RefPtr<Gio::File>>::vector_to_list(vec).data(), nullptr, &(gerror));
  if (gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

bool
AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& launch_context)
{
  std::vector<std::string> vec = { uri };

  GError* gerror = nullptr;
  const bool retvalue =
    g_app_info_launch_uris(gobj(), Glib::ListHandler<std::string>::vector_to_list(vec).data(),
      Glib::unwrap(launch_context), &(gerror));
  if (gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

bool
AppInfo::launch_uri(const std::string& uri)
{
  std::vector<std::string> vec = { uri };

  GError* gerror = nullptr;
  const bool retvalue = g_app_info_launch_uris(
    gobj(), Glib::ListHandler<std::string>::vector_to_list(vec).data(), nullptr, &(gerror));
  if (gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;
}

} // namespace Gio

namespace
{
} // anonymous namespace


namespace Glib
{

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

} // namespace Glib


namespace Gio
{


/* The *_Class implementation: */

const Glib::Interface_Class& AppInfo_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Interface_Class has to know the interface init function
    // in order to add interfaces to implementing types.
    class_init_func_ = &AppInfo_Class::iface_init_function;

    // We can not derive from another interface, and it is not necessary anyway.
    gtype_ = g_app_info_get_type();
  }

  return *this;
}

void AppInfo_Class::iface_init_function(void* g_iface, void*)
{
  const auto klass = static_cast<BaseClassType*>(g_iface);

  //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  g_assert(klass != nullptr);


}


Glib::ObjectBase* AppInfo_Class::wrap_new(GObject* object)
{
  return new AppInfo((GAppInfo*)(object));
}


/* The implementation: */

AppInfo::AppInfo()
:
  Glib::Interface(appinfo_class_.init())
{}

AppInfo::AppInfo(GAppInfo* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

AppInfo::AppInfo(const Glib::Interface_Class& interface_class)
: Glib::Interface(interface_class)
{
}

AppInfo::AppInfo(AppInfo&& src) noexcept
: Glib::Interface(std::move(src))
{}

AppInfo& AppInfo::operator=(AppInfo&& src) noexcept
{
  Glib::Interface::operator=(std::move(src));
  return *this;
}

AppInfo::~AppInfo() noexcept
{}

// static
void AppInfo::add_interface(GType gtype_implementer)
{
  appinfo_class_.init().add_interface(gtype_implementer);
}

AppInfo::CppClassType AppInfo::appinfo_class_; // initialize static member

GType AppInfo::get_type()
{
  return appinfo_class_.init().get_type();
}


GType AppInfo::get_base_type()
{
  return g_app_info_get_type();
}


bool AppInfo::equal(const Glib::RefPtr<AppInfo>& other) const
{
  return g_app_info_equal(const_cast<GAppInfo*>(gobj()), Glib::unwrap(other));
}

std::string AppInfo::get_id() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_id(const_cast<GAppInfo*>(gobj())));
}

std::string AppInfo::get_name() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_name(const_cast<GAppInfo*>(gobj())));
}

std::string AppInfo::get_display_name() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_display_name(const_cast<GAppInfo*>(gobj())));
}

std::string AppInfo::get_description() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_description(const_cast<GAppInfo*>(gobj())));
}

std::string AppInfo::get_executable() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_executable(const_cast<GAppInfo*>(gobj())));
}

std::string AppInfo::get_commandline() const
{
  return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_commandline(const_cast<GAppInfo*>(gobj())));
}

Glib::RefPtr<Icon> AppInfo::get_icon()
{
  auto retvalue = Glib::wrap(g_app_info_get_icon(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

const Glib::RefPtr<const Icon> AppInfo::get_icon() const
{
  return const_cast<AppInfo*>(this)->get_icon();
}

bool AppInfo::launch(const std::vector< Glib::RefPtr<Gio::File> >& files, const Glib::RefPtr<AppLaunchContext>& context)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch(gobj(), Glib::ListHandler<Glib::RefPtr<Gio::File> >::vector_to_list(files).data (), Glib::unwrap(context), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::launch(const std::vector< Glib::RefPtr<Gio::File> >& files)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch(gobj(), Glib::ListHandler<Glib::RefPtr<Gio::File> >::vector_to_list(files).data (), nullptr, &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::supports_uris() const
{
  return g_app_info_supports_uris(const_cast<GAppInfo*>(gobj()));
}

bool AppInfo::supports_files() const
{
  return g_app_info_supports_files(const_cast<GAppInfo*>(gobj()));
}

bool AppInfo::launch_uris(const std::vector<std::string>& uris, const Glib::RefPtr<AppLaunchContext>& context)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_uris(gobj(), Glib::ListHandler<std::string>::vector_to_list(uris).data(), Glib::unwrap(context), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::launch_uris(const std::vector<std::string>& uris)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_uris(gobj(), Glib::ListHandler<std::string>::vector_to_list(uris).data(), nullptr, &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void AppInfo::launch_uris_async(const std::vector<std::string>& uris, const Glib::RefPtr<AppLaunchContext>& context, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_launch_uris_async(gobj(), Glib::ListHandler<std::string>::vector_to_list(uris).data(), Glib::unwrap(context), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::launch_uris_async(const std::vector<std::string>& uris, const Glib::RefPtr<AppLaunchContext>& context, const Glib::RefPtr<Cancellable>& cancellable)
{
  g_app_info_launch_uris_async(gobj(), Glib::ListHandler<std::string>::vector_to_list(uris).data(), Glib::unwrap(context), const_cast<GCancellable*>(Glib::unwrap(cancellable)), nullptr, nullptr);
}

bool AppInfo::launch_uris_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_uris_finish(gobj(), Glib::unwrap(result), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::should_show() const
{
  return g_app_info_should_show(const_cast<GAppInfo*>(gobj()));
}

bool AppInfo::can_delete() const
{
  return g_app_info_can_delete(const_cast<GAppInfo*>(gobj()));
}

bool AppInfo::do_delete()
{
  return g_app_info_delete(gobj());
}

bool AppInfo::set_as_default_for_type(const std::string& content_type)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_set_as_default_for_type(gobj(), content_type.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::set_as_default_for_extension(const std::string& extension)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_set_as_default_for_extension(gobj(), extension.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::add_supports_type(const std::string& content_type)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_add_supports_type(gobj(), content_type.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::can_remove_supports_type() const
{
  return g_app_info_can_remove_supports_type(const_cast<GAppInfo*>(gobj()));
}

bool AppInfo::remove_supports_type(const std::string& content_type)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_remove_supports_type(gobj(), content_type.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

std::vector<Glib::ustring> AppInfo::get_supported_types() const
{
  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(g_app_info_get_supported_types(const_cast<GAppInfo*>(gobj())), Glib::OWNERSHIP_NONE);
}

bool AppInfo::set_as_last_used_for_type(const std::string& content_type)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_set_as_last_used_for_type(gobj(), content_type.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

std::vector<Glib::RefPtr<AppInfo>> AppInfo::get_all()
{
  return Glib::ListHandler<Glib::RefPtr<AppInfo>, TypeTraits_AppInfo>::list_to_vector(g_app_info_get_all(), Glib::OWNERSHIP_DEEP);
}

std::vector<Glib::RefPtr<AppInfo>> AppInfo::get_all_for_type(const std::string& content_type)
{
  return Glib::ListHandler<Glib::RefPtr<AppInfo>, TypeTraits_AppInfo>::list_to_vector(g_app_info_get_all_for_type(content_type.c_str()), Glib::OWNERSHIP_DEEP);
}

std::vector<Glib::RefPtr<AppInfo>> AppInfo::get_recommended_for_type(const std::string& content_type)
{
  return Glib::ListHandler<Glib::RefPtr<AppInfo>, TypeTraits_AppInfo>::list_to_vector(g_app_info_get_recommended_for_type(content_type.c_str()), Glib::OWNERSHIP_DEEP);
}

std::vector<Glib::RefPtr<AppInfo>> AppInfo::get_fallback_for_type(const std::string& content_type)
{
  return Glib::ListHandler<Glib::RefPtr<AppInfo>, TypeTraits_AppInfo>::list_to_vector(g_app_info_get_fallback_for_type(content_type.c_str()), Glib::OWNERSHIP_DEEP);
}

Glib::RefPtr<AppInfo> AppInfo::get_default_for_type(const std::string& content_type, bool must_support_uris)
{
  return Glib::wrap(g_app_info_get_default_for_type(content_type.c_str(), static_cast<int>(must_support_uris)));
}

void AppInfo::get_default_for_type_async(const std::string& content_type, bool must_support_uris, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_get_default_for_type_async(content_type.c_str(), static_cast<int>(must_support_uris), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::get_default_for_type_async(const std::string& content_type, bool must_support_uris, const Glib::RefPtr<Cancellable>& cancellable)
{
  g_app_info_get_default_for_type_async(content_type.c_str(), static_cast<int>(must_support_uris), const_cast<GCancellable*>(Glib::unwrap(cancellable)), nullptr, nullptr);
}

Glib::RefPtr<AppInfo> AppInfo::get_default_for_type_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = Glib::wrap(g_app_info_get_default_for_type_finish(Glib::unwrap(result), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

Glib::RefPtr<AppInfo> AppInfo::get_default_for_uri_scheme(const std::string& uri_scheme)
{
  return Glib::wrap(g_app_info_get_default_for_uri_scheme(uri_scheme.c_str()));
}

void AppInfo::get_default_for_uri_scheme_async(const std::string& content_type, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_get_default_for_uri_scheme_async(content_type.c_str(), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::get_default_for_uri_scheme_async(const std::string& content_type, const Glib::RefPtr<Cancellable>& cancellable)
{
  g_app_info_get_default_for_uri_scheme_async(content_type.c_str(), const_cast<GCancellable*>(Glib::unwrap(cancellable)), nullptr, nullptr);
}

Glib::RefPtr<AppInfo> AppInfo::get_default_for_uri_scheme_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = Glib::wrap(g_app_info_get_default_for_uri_scheme_finish(Glib::unwrap(result), &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void AppInfo::reset_type_associations(const std::string& content_type)
{
  g_app_info_reset_type_associations(content_type.c_str());
}

bool AppInfo::launch_default_for_uri(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_default_for_uri(uri.c_str(), Glib::unwrap(context), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool AppInfo::launch_default_for_uri(const std::string& uri)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_default_for_uri(uri.c_str(), nullptr, &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_launch_default_for_uri_async(uri.c_str(), Glib::unwrap(context), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context, const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_launch_default_for_uri_async(uri.c_str(), Glib::unwrap(context), nullptr, &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context, const Glib::RefPtr<Cancellable>& cancellable)
{
  g_app_info_launch_default_for_uri_async(uri.c_str(), Glib::unwrap(context), const_cast<GCancellable*>(Glib::unwrap(cancellable)), nullptr, nullptr);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const Glib::RefPtr<AppLaunchContext>& context)
{
  g_app_info_launch_default_for_uri_async(uri.c_str(), Glib::unwrap(context), nullptr, nullptr, nullptr);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_launch_default_for_uri_async(uri.c_str(), nullptr, const_cast<GCancellable*>(Glib::unwrap(cancellable)), &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const SlotAsyncReady& slot)
{
  // Create a copy of the slot.
  auto slot_copy = new SlotAsyncReady(slot); 

  g_app_info_launch_default_for_uri_async(uri.c_str(), nullptr, nullptr, &giomm_SignalProxy_async_callback, slot_copy);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri, const Glib::RefPtr<Cancellable>& cancellable)
{
  g_app_info_launch_default_for_uri_async(uri.c_str(), nullptr, const_cast<GCancellable*>(Glib::unwrap(cancellable)), nullptr, nullptr);
}

void AppInfo::launch_default_for_uri_async(const std::string& uri)
{
  g_app_info_launch_default_for_uri_async(uri.c_str(), nullptr, nullptr, nullptr, nullptr);
}

bool AppInfo::launch_default_for_uri_finish(const Glib::RefPtr<AsyncResult>& result)
{
  GError* gerror = nullptr;
  auto retvalue = g_app_info_launch_default_for_uri_finish(Glib::unwrap(result), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


} // namespace Gio


