/* Copyright(C) 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
 */

_DEFS(gtkmm,gtk)

#include <vector>

#include <gtkmm/enums.h>
#include <gtkmm/targetentry.h>
//#include <gtkmm/textbuffer.h>
#include <gdkmm/types.h>

_CC_INCLUDE(gtk/gtk.h)

namespace Gtk
{

class TextBuffer;

class TargetList
{
  //GtkTargetList is actually registered as a boxed type, but it has custom
  //reference-counting instead of copy/free functions, so we use it via RefPtr.
  _CLASS_OPAQUE_REFCOUNTED(TargetList, GtkTargetList, NONE, gtk_target_list_ref, gtk_target_list_unref)
  _IGNORE(gtk_target_list_ref, gtk_target_list_unref)
public:
  static Glib::RefPtr<Gtk::TargetList> create(const std::vector<TargetEntry>& targets);

#m4 _CONVERSION(`TargetFlags', `guint', `($2)($3)')
  _WRAP_METHOD(void add(const Glib::ustring& target, TargetFlags flags = TargetFlags(0), guint info = 0), gtk_target_list_add)
  void add(const std::vector<TargetEntry>& targets);

  _WRAP_METHOD(void add_text_targets(guint info), gtk_target_list_add_text_targets)
  _WRAP_METHOD(void add_rich_text_targets(guint info, bool deserializable, const Glib::RefPtr<TextBuffer>& buffer), gtk_target_list_add_rich_text_targets)

  _WRAP_METHOD(void add_image_targets(guint info, bool writable), gtk_target_list_add_image_targets)
  _WRAP_METHOD(void add_uri_targets(guint info), gtk_target_list_add_uri_targets)

/* TODO:
void           gtk_target_list_add_table (GtkTargetList        *list,
                                          const GtkTargetEntry *targets,
                                          guint                 ntargets);
*/

  _WRAP_METHOD(void remove(const Glib::ustring& target), gtk_target_list_remove)
  _WRAP_METHOD(bool find(const Glib::ustring& target, guint* info) const, gtk_target_list_find)
};

} // namespace Gtk

namespace Glib
{
// This is needed so Glib::RefPtr<Gtk::TargetList> can be used with
// Glib::Value and _WRAP_PROPERTY in TextBuffer.
template <>
class Value< Glib::RefPtr<Gtk::TargetList> > : public ValueBase_Boxed
{
public:
  typedef Glib::RefPtr<Gtk::TargetList> CppType;
  typedef GtkTargetList* CType;

  static GType value_type();

  void set(const CppType& data);
  CppType get() const;
};

} // namespace Glib
