summaryrefslogtreecommitdiff
path: root/plugins/gepub-thumbnailer/gepub-thumbnailer-provider.c
blob: 2204bd3328da08bdb8624cf4d9b133c82685457e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
 * Copyright (c) 2010 Jannis Pohlmann <jannis@xfce.org>
 * Copyright (c) 2020, Olivier Duchateau <duchateau.olivier@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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 Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General 
 * Public License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <glib-object.h>

#include <tumbler/tumbler.h>

#include "gepub-thumbnailer-provider.h"
#include "gepub-thumbnailer.h"



static void   gepub_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
static GList *gepub_thumbnailer_provider_get_thumbnailers          (TumblerThumbnailerProvider      *provider);



struct _GepubThumbnailerProviderClass
{
  GObjectClass __parent__;
};

struct _GepubThumbnailerProvider
{
  GObject __parent__;
};



G_DEFINE_DYNAMIC_TYPE_EXTENDED (GepubThumbnailerProvider,
                                gepub_thumbnailer_provider,
                                G_TYPE_OBJECT,
                                0,
                                TUMBLER_ADD_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER,
                                                       gepub_thumbnailer_provider_thumbnailer_provider_init));



void
gepub_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
{
  gepub_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
}



static void
gepub_thumbnailer_provider_class_init (GepubThumbnailerProviderClass *klass)
{
}



static void
gepub_thumbnailer_provider_class_finalize (GepubThumbnailerProviderClass *klass)
{
}



static void
gepub_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
{
  iface->get_thumbnailers = gepub_thumbnailer_provider_get_thumbnailers;
}



static void
gepub_thumbnailer_provider_init (GepubThumbnailerProvider *provider)
{
}



static GList *
gepub_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
{
  GepubThumbnailer   *thumbnailer;
  GList              *thumbnailers = NULL;
  static const gchar *mime_types[] = 
  {
    "application/epub",
    "application/epub+zip",
    NULL
  };
  GStrv               uri_schemes;

  /* determine which URI schemes are supported by GIO */
  uri_schemes = tumbler_util_get_supported_uri_schemes ();

  /* create the pixbuf thumbnailer */
  thumbnailer = g_object_new (TYPE_GEPUB_THUMBNAILER, 
                              "uri-schemes", uri_schemes,
                              "mime-types", mime_types, 
                              NULL);

  /* add the thumbnailer to the list */
  thumbnailers = g_list_append (thumbnailers, thumbnailer);

  /* free URI schemes and MIME types */
  g_strfreev (uri_schemes);

  return thumbnailers;
}