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

#include <gdkmm/pixbuf.h>
#include <gdkmm/screen.h>

#include <gtkmm/iconinfo.h>
#include <giomm/icon.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gtk
{

_WRAP_ENUM(IconLookupFlags, GtkIconLookupFlags, NO_GTYPE)

/** Exception class for Gtk::IconTheme errors.
 */
_WRAP_GERROR(IconThemeError,GtkIconThemeError,GTK_ICON_THEME_ERROR)

class IconTheme : public Glib::Object
{
  _CLASS_GOBJECT(IconTheme, GtkIconTheme, GTK_ICON_THEME, Glib::Object, GObject)
  _IGNORE(gtk_icon_theme_set_search_path, gtk_icon_theme_get_search_path)

protected:
  _CTOR_DEFAULT()
public:
  _WRAP_CREATE()

  _WRAP_METHOD(static Glib::RefPtr<IconTheme> get_default(), gtk_icon_theme_get_default, refreturn)
  _WRAP_METHOD(static Glib::RefPtr<IconTheme> get_for_screen(const Glib::RefPtr<Gdk::Screen>& screen), gtk_icon_theme_get_for_screen, refreturn)
  _WRAP_METHOD(void set_screen(const Glib::RefPtr<Gdk::Screen>& screen), gtk_icon_theme_set_screen)
  void set_search_path(const std::vector<Glib::ustring>& path);
  std::vector<Glib::ustring> get_search_path() const;
  _WRAP_METHOD(void append_search_path(const Glib::ustring& path), gtk_icon_theme_append_search_path)
  _WRAP_METHOD(void prepend_search_path(const Glib::ustring& path), gtk_icon_theme_prepend_search_path)

  _WRAP_METHOD(void add_resource_path(const std::string& path), gtk_icon_theme_add_resource_path)

  _WRAP_METHOD(void set_custom_theme(const Glib::ustring& theme_name), gtk_icon_theme_set_custom_theme)
  _WRAP_METHOD(bool has_icon(const Glib::ustring& icon_name) const, gtk_icon_theme_has_icon)

  std::vector<int> get_icon_sizes(const Glib::ustring& icon_name) const;
  _IGNORE(gtk_icon_theme_get_icon_sizes)

  _WRAP_METHOD(IconInfo lookup_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_lookup_icon)
  _WRAP_METHOD(IconInfo lookup_icon(const Glib::ustring& icon_name, int size, int scale, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_lookup_icon_for_scale)
  _WRAP_METHOD(IconInfo lookup_icon(const Glib::RefPtr<const Gio::Icon>& icon, int size, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_lookup_by_gicon)
  _WRAP_METHOD(IconInfo lookup_icon(const Glib::RefPtr<const Gio::Icon>& icon, int size, int scale, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_lookup_by_gicon_for_scale)

  #m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const gchar*[]',`const_cast<const gchar**>(Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ())')
  _WRAP_METHOD(IconInfo choose_icon(const std::vector<Glib::ustring>& icon_names, int size, IconLookupFlags flags = (IconLookupFlags)0), gtk_icon_theme_choose_icon)
  _WRAP_METHOD(IconInfo choose_icon(const std::vector<Glib::ustring>& icon_names, int size, int scale, IconLookupFlags flags = (IconLookupFlags)0), gtk_icon_theme_choose_icon_for_scale)

  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_load_icon, errthrow)
    _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon(const Glib::ustring& icon_name, int size, int scale, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_load_icon_for_scale, errthrow)

 #m4 _CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::Surface>',`::Cairo::RefPtr< ::Cairo::Surface>(new Cairo::Surface($3, true /* do not take reference */))')
  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> load_surface(const Glib::ustring& icon_name, int size, int scale, const Glib::RefPtr<Gdk::Window>& for_window, IconLookupFlags flags = (IconLookupFlags)0), gtk_icon_theme_load_surface, errthrow)

#m4 _CONVERSION(`GList*',`std::vector<Glib::ustring>',`Glib::ListHandler<Glib::ustring>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(std::vector<Glib::ustring> list_icons(const Glib::ustring& context) const, gtk_icon_theme_list_icons)

  /** Lists the icons in the current icon theme.
   *
   * @return A list holding the names of all the
   * icons in the theme.
   *
   * @newin{2,10}
   */
   std::vector<Glib::ustring> list_icons() const;

  _WRAP_METHOD(std::vector<Glib::ustring> list_contexts() const, gtk_icon_theme_list_contexts)

  _WRAP_METHOD(Glib::ustring get_example_icon_name() const, gtk_icon_theme_get_example_icon_name)
  _WRAP_METHOD(bool rescan_if_needed(), gtk_icon_theme_rescan_if_needed)
  _WRAP_METHOD(static void add_builtin_icon(const Glib::ustring& icon_name, int size, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_icon_theme_add_builtin_icon, deprecated "Use add_resource_path() to add application-specific icons to the icon theme.")

  _WRAP_SIGNAL(void changed(), "changed")
};

} // namespace Gtk

