/* Copyright (C) 1998-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, see .
*/
#include
namespace Gtk
{
#ifndef GTKMM_DISABLE_DEPRECATED
Image::Image(const Gtk::StockID& stock_id, IconSize size)
:
_CONSTRUCT("stock", stock_id.get_c_str(), "icon-size", (GtkIconSize) int(size))
{}
#endif //GTKMM_DISABLE_DEPRECATED
#ifndef GTKMM_DISABLE_DEPRECATED
Image::Image(const Glib::RefPtr& icon_set, IconSize size)
:
_CONSTRUCT("icon-set", (icon_set ? icon_set->gobj() : nullptr), "icon-size", (GtkIconSize) int(size))
{}
#endif //GTKMM_DISABLE_DEPRECATED
Image::Image(const Glib::RefPtr& animation)
:
_CONSTRUCT("pixbuf-animation", Glib::unwrap(animation))
{}
#ifndef GTKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Image::get_stock(Gtk::StockID& stock_id, IconSize& size) const
{
char* pStockID = nullptr; // GTK+ iconsistency: although not const, it should not be freed.
GtkIconSize icon_size = GTK_ICON_SIZE_INVALID;
gtk_image_get_stock(const_cast(gobj()), &pStockID, &icon_size);
size = IconSize(static_cast(icon_size));
stock_id = Gtk::StockID(pStockID); // the StockID ctor checks for 0
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif //GTKMM_DISABLE_DEPRECATED
#ifndef GTKMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Image::get_icon_set(Glib::RefPtr& icon_set, IconSize& size) const
{
GtkIconSet* pIconSet = nullptr;
GtkIconSize icon_size = GTK_ICON_SIZE_INVALID;
gtk_image_get_icon_set(const_cast(gobj()), &pIconSet, &icon_size);
size = IconSize(static_cast(icon_size));
icon_set = Glib::wrap(pIconSet, true); //true = take_copy.
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif //GTKMM_DISABLE_DEPRECATED
Glib::ustring Image::get_icon_name() const
{
const gchar* pchIconName = nullptr;
gtk_image_get_icon_name(const_cast(gobj()), &pchIconName, nullptr);
return Glib::convert_const_gchar_ptr_to_ustring(pchIconName);
}
Glib::RefPtr Image::get_gicon(Gtk::IconSize& icon_size)
{
GIcon* cicon = nullptr;
GtkIconSize cicon_size = GTK_ICON_SIZE_INVALID;
gtk_image_get_gicon(gobj(), &cicon, &cicon_size);
icon_size = Gtk::IconSize(cicon_size);
return Glib::wrap(cicon);
}
Glib::RefPtr Image::get_gicon(Gtk::IconSize& icon_size) const
{
auto nonconstthis = const_cast(this);
return nonconstthis->get_gicon(icon_size);
}
} // namespace Gtk