/* Copyright (C) 2018 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/cancellable.h>
#include <giomm/inputstream.h>
#include <gdkmm/slot_async.h>
#include <gdkmm/contentformats.h>
#include <gdkmm/device.h>
#include <gdkmm/display.h>
#include <gdkmm/drag.h>
#include <gdkmm/surface.h>
#include <gdk/gdk.h>

namespace Gdk
{

void Drop::refuse()
{
  // see GDK docs
  gdk_drop_status(gobj(), static_cast<GdkDragAction>(0), static_cast<GdkDragAction>(0));
}

void Drop::failed()
{
  gdk_drop_finish(gobj(), (static_cast<GdkDragAction>(0)) /* see GDK docs */);
}

Glib::ValueBase Drop::read_value_finish(const Glib::RefPtr<Gio::AsyncResult>& result)
{
  GError* gerror = nullptr;
  const GValue* gvalue = gdk_drop_read_value_finish(gobj(), Glib::unwrap(result), &gerror);
  if (gerror)
    ::Glib::Error::throw_exception(gerror);

  Glib::ValueBase retvalue;
  retvalue.init(gvalue);
  return retvalue;
}

} // namespace Gdk
