grim/guifications3

e62da38a5799
removed gflib-query-plugins since we're using gplugin now...
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <gflib-gtk/gf_gtk_image.h>
GdkPixbuf *
gf_gtk_image_to_pixbuf(const GfImage *image, GError **error) {
GdkPixbuf *pixbuf = NULL;
GdkPixbufLoader *loader = NULL;
const guchar *data = NULL;
gsize size = 0;
g_return_val_if_fail(GF_IS_IMAGE(image), NULL);
data = gf_image_get_data(image, &size);
if(size <= 0 || !data)
return NULL;
loader = gdk_pixbuf_loader_new();
if(!gdk_pixbuf_loader_write(loader, data, size, error)) {
gf_log_info("GfGtkImage",
"Failed to convert image %p to a GdkPixbuf\n",
image);
g_object_unref(loader);
return NULL;
}
pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
g_object_ref(pixbuf);
gdk_pixbuf_loader_close(loader, error);
g_object_unref(loader);
return pixbuf;
}
GdkPixbuf *
gf_gtk_image_to_scaled_pixbuf(const GfImage *image, gint width, gint height,
GError **error)
{
GdkPixbuf *original = NULL, *scaled = NULL;
original = gf_gtk_image_to_pixbuf(image, error);
g_return_val_if_fail(GDK_IS_PIXBUF(original), NULL);
scaled = gdk_pixbuf_scale_simple(original, width, height,
GDK_INTERP_BILINEAR);
g_object_unref(original);
return scaled;
}