// -*- c++ -*-
/* $Id: dragcontext.ccg,v 1.7 2005/02/13 13:01:36 murrayc Exp $ */

/*
 *
 * Copyright 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 <glibmm/vectorutils.h>

#include <gdkmm/window.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glibmm/utility.h> //For ScopedPtr<>.

namespace Gdk
{

void DragContext::find_window_for_screen(const Glib::RefPtr<Window>& drag_window, const Glib::RefPtr<Screen>& screen, int x_root, int y_root, Glib::RefPtr<Window>& dest_window, DragProtocol& protocol) const
{
  GdkWindow* cWindow = 0;
  GdkDragProtocol cprotocol = GDK_DRAG_PROTO_NONE; //arbitrary default.
  gdk_drag_find_window_for_screen(const_cast<GdkDragContext*>(gobj()), drag_window->gobj(), screen->gobj(), x_root, y_root, &cWindow, &cprotocol);
  dest_window = Glib::wrap(cWindow);
  protocol = (DragProtocol)cprotocol;
}

void DragContext::drag_refuse(guint32 time)
{
  gdk_drag_status(gobj(), ((GdkDragAction)(0)) /* see GDK docs */, time);
}

std::vector<std::string> DragContext::list_targets() const
{
  //Note that we don't free the GList* (or it's items), because we are accessing the struct directly:
  return Glib::ListHandler<std::string, AtomStringTraits>::list_to_vector( gdk_drag_context_list_targets(const_cast<GdkDragContext*>(gobj())), Glib::OWNERSHIP_NONE);
}

} /* namespace Gdk */
