2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
5 * Author: Vladimir Nadvornik
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "image-load.h"
24 #include "image_load_gdk.h"
27 static gchar* image_loader_gdk_get_format_name(gpointer loader)
29 GdkPixbufFormat *format;
31 format = gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader));
34 return gdk_pixbuf_format_get_name(format);
41 static gchar** image_loader_gdk_get_format_mime_types(gpointer loader)
43 return gdk_pixbuf_format_get_mime_types(gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader)));
46 static gpointer image_loader_gdk_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
48 GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
50 g_signal_connect(G_OBJECT(loader), "area_updated", G_CALLBACK(area_updated_cb), data);
51 g_signal_connect(G_OBJECT(loader), "size_prepared", G_CALLBACK(size_cb), data);
52 g_signal_connect(G_OBJECT(loader), "area_prepared", G_CALLBACK(area_prepared_cb), data);
53 return (gpointer) loader;
56 static void image_loader_gdk_abort(gpointer loader)
60 static void image_loader_gdk_free(gpointer loader)
62 g_object_unref(G_OBJECT(loader));
65 void image_loader_backend_set_default(ImageLoaderBackend *funcs)
67 funcs->loader_new = image_loader_gdk_new;
68 funcs->set_size = (ImageLoaderBackendFuncSetSize) gdk_pixbuf_loader_set_size;
70 funcs->write = (ImageLoaderBackendFuncWrite) gdk_pixbuf_loader_write;
71 funcs->get_pixbuf = (ImageLoaderBackendFuncGetPixbuf) gdk_pixbuf_loader_get_pixbuf;
72 funcs->close = (ImageLoaderBackendFuncClose) gdk_pixbuf_loader_close;
73 funcs->abort = image_loader_gdk_abort;
74 funcs->free = image_loader_gdk_free;
76 funcs->get_format_name = image_loader_gdk_get_format_name;
77 funcs->get_format_mime_types = image_loader_gdk_get_format_mime_types;
81 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */