Ref #820: Problem with window in the current build
[geeqie.git] / src / image_load_gdk.c
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: Vladimir Nadvornik
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #include "main.h"
23 #include "image-load.h"
24 #include "image_load_gdk.h"
25
26
27 static gchar* image_loader_gdk_get_format_name(gpointer loader)
28 {
29         GdkPixbufFormat *format;
30
31         format = gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader));
32         if (format)
33                 {
34                 return gdk_pixbuf_format_get_name(format);
35                 }
36         else
37                 {
38                 return NULL;
39                 }
40 }
41 static gchar** image_loader_gdk_get_format_mime_types(gpointer loader)
42 {
43         return gdk_pixbuf_format_get_mime_types(gdk_pixbuf_loader_get_format(GDK_PIXBUF_LOADER(loader)));
44 }
45
46 static gpointer image_loader_gdk_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
47 {
48         GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
49
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;
54 }
55
56 static void image_loader_gdk_abort(gpointer loader)
57 {
58 }
59
60 static void image_loader_gdk_free(gpointer loader)
61 {
62         g_object_unref(G_OBJECT(loader));
63 }
64
65 void image_loader_backend_set_default(ImageLoaderBackend *funcs)
66 {
67         funcs->loader_new = image_loader_gdk_new;
68         funcs->set_size = (ImageLoaderBackendFuncSetSize) gdk_pixbuf_loader_set_size;
69         funcs->load = NULL;
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;
75
76         funcs->get_format_name = image_loader_gdk_get_format_name;
77         funcs->get_format_mime_types = image_loader_gdk_get_format_mime_types;
78 }
79
80
81 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */