/* Copyright 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtkmm/icontheme.h>
#include <gtk/gtk.h>

namespace Gtk
{

IconInfo::IconInfo(const Glib::RefPtr<IconTheme>& icon_theme, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
: gobject_( gtk_icon_info_new_for_pixbuf(Glib::unwrap(icon_theme), pixbuf->gobj()) )
{
}

bool IconInfo::get_attach_points(Glib::ArrayHandle<Gdk::Point>& /* points */) const
{
  GdkPoint* c_attach_points = 0;
  gint n_points = 0;
  bool result = gtk_icon_info_get_attach_points (const_cast<GtkIconInfo*>(gobj()), &c_attach_points, &n_points);

  if(c_attach_points)
  {
    //TODO: We can't use = with an ArrayHandle.
    //Investigate whether the bool return value has a special meaning - maybe we can just return an empty ArrayHandle.
    //points = Glib::ArrayHandle<Gdk::Point>(reinterpret_cast<Gdk::Point*>(c_attach_points), (size_t)n_points, Glib::OWNERSHIP_SHALLOW); //We use OWNERSHIP_SHALLOW because we just need to g_free() the array and nothing more.
  }
  return result;
}

_DEPRECATE_IFDEF_START
IconInfo::operator bool()
{
  return gobj() != 0;
}
_DEPRECATE_IFDEF_END

IconInfo::operator bool() const
{
  return gobj() != 0;
}


} // namespace Gtk
