1/* Copyright 1998-2002 The gtkmm Development Team 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2.1 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 */ 17 18#include <gdk/gdk.h> 19#include <gdk-pixbuf/gdk-pixbuf.h> 20 21namespace 22{ 23 24/* We use this helper function in the constructor to be able to throw 25 * before the base class' (Glib::Object) constructor is called. 26 */ 27static GdkPixbufLoader* pixbuf_loader_create_with_type(const Glib::ustring& image_type, bool mime_type) 28{ 29 GError* error = nullptr; 30 GdkPixbufLoader* loader = nullptr; 31 32 if(mime_type) 33 loader = gdk_pixbuf_loader_new_with_mime_type(image_type.c_str(), &error); 34 else 35 loader = gdk_pixbuf_loader_new_with_type(image_type.c_str(), &error); 36 37 if(error) 38 Glib::Error::throw_exception(error); 39 40 return loader; 41} 42 43} // anonymous namespace 44 45 46namespace Gdk 47{ 48 49PixbufLoader::PixbufLoader(const Glib::ustring& image_type, bool mime_type) 50: 51 Glib::ObjectBase(nullptr), 52 Glib::Object((GObject*) pixbuf_loader_create_with_type(image_type, mime_type)) 53{} 54 55} // namespace Gdk 56 57